summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Hartman <hartmans@mit.edu>1995-08-07 23:58:26 +0000
committerSam Hartman <hartmans@mit.edu>1995-08-07 23:58:26 +0000
commit086beadfebe7c157f8c3f53c3c07a92d9624e38b (patch)
tree4db42c71b06eafa3e143343c52c33174458020ce /src
parent3b3e327fdb2cfd939c4a9e56f0670b3ec5ad896f (diff)
downloadkrb5-086beadfebe7c157f8c3f53c3c07a92d9624e38b.tar.gz
krb5-086beadfebe7c157f8c3f53c3c07a92d9624e38b.tar.xz
krb5-086beadfebe7c157f8c3f53c3c07a92d9624e38b.zip
* Modify pty_update_utmp so it takes additional parameters instead of
struct utmp. * Move pty_update_wtmp to an internal function; pty_update_utmp and pty_logwtmp call it. * Don't include utmp.h or utmpx.h in libpty.h; they don't need it any more. * Don't use pid_t in libpty.h or any interfaces it defines\. We'll have to settle for int. * Add logic so that UTMP_FILE and WTMP_FILE get defined on NetBSD (Actually fairly clean). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6453 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/util/pty/ChangeLog16
-rw-r--r--src/util/pty/cleanup.c9
-rw-r--r--src/util/pty/libpty.h18
-rw-r--r--src/util/pty/logwtmp.c2
-rw-r--r--src/util/pty/pty-int.h10
-rw-r--r--src/util/pty/pty_err.et2
-rw-r--r--src/util/pty/update_utmp.c50
-rw-r--r--src/util/pty/update_wtmp.c8
8 files changed, 80 insertions, 35 deletions
diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog
index 02566df73..a893b5e06 100644
--- a/src/util/pty/ChangeLog
+++ b/src/util/pty/ChangeLog
@@ -1,3 +1,19 @@
+Mon Aug 7 17:41:39 1995 Sam Hartman <hartmans@tertius.mit.edu>
+
+ * cleanup.c (pty_cleanup): Call pty_update_utmp using new interface.
+
+ * update_utmp.c logwtmp.c : Call ptyint_update_wtmp not pty_update_wtmp.
+
+ * cleanup.c (pty_cleanup): We can't use pid_t because we need to
+ use something in libpty.h and we can't wait for pid_t to be
+ defined there because we may not have configure.
+
+ * update_wtmp.c (pty_update_wtmp): Rename to ptyint_update_wtmp.
+
+ * update_utmp.c (pty_update_utmp): Change interface so it doesn't take a struct utmp.
+
+ * libpty.h: Remove pty_update_wtmp as it's becoming an internal interface.
+
Sat Aug 5 01:00:35 1995 Ezra Peisach <epeisach@kangaroo.mit.edu>
* open_slave.c (pty_open_slave): pty_open_ctty returns != 0 on
diff --git a/src/util/pty/cleanup.c b/src/util/pty/cleanup.c
index 6c40ce094..50eecc56f 100644
--- a/src/util/pty/cleanup.c
+++ b/src/util/pty/cleanup.c
@@ -23,17 +23,12 @@
long pty_cleanup (slave, pid, update_utmp)
char *slave;
- pid_t pid; /* May be zero for unknown.*/
+ int pid; /* May be zero for unknown.*/
int update_utmp;
{
- struct utmp ut;
int retval, fd;
-#ifndef NO_UT_PID
- ut.ut_pid = 0;
- ut.ut_type = DEAD_PROCESS;
-#endif
- pty_update_utmp(&ut, "", slave, (char *)0);
+ pty_update_utmp(PTY_DEAD_PROCESS,0, "", slave, (char *)0);
(void)chmod(slave, 0666);
(void)chown(slave, 0, 0);
diff --git a/src/util/pty/libpty.h b/src/util/pty/libpty.h
index 07b34fc38..c90a3300e 100644
--- a/src/util/pty/libpty.h
+++ b/src/util/pty/libpty.h
@@ -18,13 +18,11 @@
*/
#ifndef __LIBPTY_H__
-#include <sys/types.h>
-#ifdef HAVE_UTMP_H
-#include <utmp.h>
-#endif
-#ifdef HAVE_UTMPX_H
-#include <utmpx.h>
-#endif
+
+/* Constants for pty_update_utmp */
+#define PTY_LOGIN_PROCESS 0
+#define PTY_USER_PROCESS 1
+#define PTY_DEAD_PROCESS 2
#ifdef __STDC__ /* use prototypes */
@@ -35,12 +33,11 @@ long pty_open_slave (const char *slave, int *fd);
long pty_open_ctty (const char *slave, int *fd);
long pty_initialize_slave ( int fd);
-long pty_update_utmp (struct utmp *ut, char *user, char *line, char *host);
+long pty_update_utmp (int process_type,int pid, char *user, char *line, char *host);
-long pty_update_wtmp (struct utmp *ut);
long pty_logwtmp (char *tty, char * user, char *host);
-long pty_cleanup(char *slave, pid_t pid, int update_utmp);
+long pty_cleanup(char *slave, int pid, int update_utmp);
#else /*__STDC__*/
long pty_init();
long pty_getpty();
@@ -50,7 +47,6 @@ long pty_open_ctty();
long pty_initialize_slave();
long pty_update_utmp();
-long pty_utmp_wtmp();
long pty_logwtmp();
long pty_cleanup();
#endif /* __STDC__*/
diff --git a/src/util/pty/logwtmp.c b/src/util/pty/logwtmp.c
index 70b4ae6b0..9c88d5606 100644
--- a/src/util/pty/logwtmp.c
+++ b/src/util/pty/logwtmp.c
@@ -56,7 +56,7 @@ long pty_logwtmp (tty, user, host )
strncpy(ut.ut_name, user, sizeof(ut.ut_name));
#endif
- return pty_update_wtmp(&ut);
+ return ptyint_update_wtmp(&ut);
#endif /*HAVE_LOGWTMP*/
}
diff --git a/src/util/pty/pty-int.h b/src/util/pty/pty-int.h
index 675079259..2bd450c61 100644
--- a/src/util/pty/pty-int.h
+++ b/src/util/pty/pty-int.h
@@ -2,6 +2,13 @@
#ifndef __PTY_INT_H__
#include <pty_err.h>
#include <sys/types.h>
+#ifdef HAVE_UTMP_H
+#include <utmp.h>
+#endif
+#ifdef HAVE_UTMPX_H
+#include <utmpx.h>
+#endif
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -87,12 +94,15 @@
void initialize_pty_error_table(void);
long ptyint_void_association(void);
long ptyint_open_ctty (char *slave, int *fd);
+long ptyint_update_wtmp (struct utmp *ut);
+
void ptyint_vhangup(void);
#else /*__STDC__*/
long ptyint_void_association();
void ptyint_vhangup();
void initialize_pty_error_table();
+long ptyint_update_wtmp();
#endif /* __STDC__*/
#define __PTY_INT_H__
diff --git a/src/util/pty/pty_err.et b/src/util/pty/pty_err.et
index 0c28dfc2d..ac99a6df0 100644
--- a/src/util/pty/pty_err.et
+++ b/src/util/pty/pty_err.et
@@ -41,3 +41,5 @@ error_code PTY_OPEN_SLAVE_PUSH_FAIL, "Failed to push stream on slave side of pty
error_code PTY_OPEN_SLAVE_REVOKEFAIL, "Failed to revoke slave side of pty"
+
+error_code PTY_UPDATE_UTMP_PROCTYPE_INVALID, "bad process type passed to pty_update_utmp"
diff --git a/src/util/pty/update_utmp.c b/src/util/pty/update_utmp.c
index 82c67e8b9..b80d075eb 100644
--- a/src/util/pty/update_utmp.c
+++ b/src/util/pty/update_utmp.c
@@ -21,11 +21,17 @@
#include "libpty.h"
#include "pty-int.h"
-long pty_update_utmp (ent, username, line, host)
- struct utmp *ent;
+#if !defined(UTMP_FILE) && defined(_UTMP_PATH)
+#define UTMP_FILE _UTMP_PATH
+#endif
+
+long pty_update_utmp (process_type, pid, username, line, host)
+ int process_type;
+ int pid;
char *username, *line, *host;
{
-#ifdef HAVE_SETUTENT
+ struct utmp ent;
+ #ifdef HAVE_SETUTENT
struct utmp ut;
#else
struct stat statb;
@@ -40,41 +46,57 @@ long pty_update_utmp (ent, username, line, host)
#endif
int fd;
- strncpy(ent->ut_line, line+sizeof("/dev/")-1, sizeof(ent->ut_line));
- ent->ut_time = time(0);
+ strncpy(ent.ut_line, line+sizeof("/dev/")-1, sizeof(ent.ut_line));
+ ent.ut_time = time(0);
+#ifdef NO_UT_PID
+ ent.ut_pid = pid;
+ switch ( process_type ) {
+ case PTY_LOGIN_PROCESS:
+ ent . ut_type = LOGIN_PROCESS;
+ break;
+ case PTY_USER_PROCESS:
+ ent.ut_type = USER_PROCESS;
+ break;
+ case PTY_DEAD_PROCESS:
+ ent.ut_type = DEAD_PROCESS;
+ break;
+ default:
+ return PTY_UPDATE_UTMP_PROCTYPE_INVALID;
+ }
+#endif /*NO_UT_PID*/
#ifndef NO_UT_HOST
if (host)
- strncpy(ent->ut_host, host, sizeof(ent->ut_host));
+ strncpy(ent.ut_host, host, sizeof(ent.ut_host));
else
- ent->ut_host[0] = '\0';
+ ent.ut_host[0] = '\0';
#endif
#ifndef NO_UT_PID
tmpx = line + strlen(line)-1;
if (*(tmpx-1) != '/') tmpx--; /* last two characters, unless it's a / */
sprintf(utmp_id, "kl%s", tmpx);
- strncpy(ent->ut_id, utmp_id, sizeof(ent->ut_id));
- strncpy(ent->ut_user, username, sizeof(ent->ut_user));
+ strncpy(ent.ut_id, utmp_id, sizeof(ent.ut_id));
+ strncpy(ent.ut_user, username, sizeof(ent.ut_user));
#else
- strncpy(ent->ut_name, username, sizeof(ent->ut_name));
+ strncpy(ent.ut_name, username, sizeof(ent.ut_name));
#endif
#ifdef HAVE_SETUTENT
utmpname(UTMP_FILE);
setutent();
- pututline(ent);
+ pututline(&ent);
endutent();
#if 0
/* XXX -- NOT NEEDED ANYMORE */
- if (ent->ut_type == DEAD_PROCESS) {
+ if (ent.ut_type == DEAD_PROCESS) {
if ((fd = open(UTMP_FILE, O_RDWR)) >= 0) {
int cnt = 0;
while(read(fd, (char *)&ut, sizeof(ut)) == sizeof(ut)) {
- if (!strncmp(ut.ut_id, ent->ut_id, sizeof(ut.ut_id))) {
+ if (!strncmp(ut.ut_id, ent.ut_id, sizeof(ut.ut_id))) {
(void) memset(ut.ut_host, 0, sizeof(ut.ut_host));
(void) memset(ut.ut_user, 0, sizeof(ut.ut_user));
(void) time(&ut.ut_time);
@@ -108,5 +130,5 @@ long pty_update_utmp (ent, username, line, host)
#endif /* HAVE_SETUTENT */
- return pty_update_wtmp(ent);
+ return ptyint_update_wtmp(&ent);
}
diff --git a/src/util/pty/update_wtmp.c b/src/util/pty/update_wtmp.c
index 8f7a3c419..0c07023bf 100644
--- a/src/util/pty/update_wtmp.c
+++ b/src/util/pty/update_wtmp.c
@@ -1,5 +1,5 @@
/*
- * pty_update_utmp: Update or create a utmp entry
+ * ptyint_update_utmp: Update or create a utmp entry
*
* Copyright 1995 by the Massachusetts Institute of Technology.
*
@@ -21,7 +21,11 @@
#include "libpty.h"
#include "pty-int.h"
-long pty_update_wtmp (ent)
+#if !defined(WTMP_FILE) && defined(_PATH_WTMP)
+#define WTMP_FILE _PATH_WTMP
+#endif
+
+long ptyint_update_wtmp (ent)
struct utmp *ent;
{
struct utmp ut;