From 348c9b7a9564986000743fe379de21ae6f73f7d4 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Tue, 15 Aug 2000 10:01:22 +1000 Subject: - (djm) More SunOS 4.1.x fixes from Nate Itkin --- CREDITS | 1 + ChangeLog | 3 +++ configure.in | 4 ++-- includes.h | 3 +++ loginrec.c | 40 +++++++++++++++++++++++++++++++--------- session.c | 5 +++-- 6 files changed, 43 insertions(+), 13 deletions(-) diff --git a/CREDITS b/CREDITS index 59ffd5531..67f694bcd 100644 --- a/CREDITS +++ b/CREDITS @@ -49,6 +49,7 @@ Marc G. Fournier - Solaris patches Matt Richards - AIX patches Michael Stone - Irix enhancements Nalin Dahyabhai - PAM environment patch +Nate Itkin - SunOS 4.1.x fixes Niels Kristian Bech Jensen - Assorted patches Peter Kocks - Makefile fixes Phil Hands - Debian scripts, assorted patches diff --git a/ChangeLog b/ChangeLog index f6e8746c8..de8ddf38e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +20000815 + - (djm) More SunOS 4.1.x fixes from Nate Itkin + 20000813 - (djm) Add $(srcdir) to includes when compiling (for VPATH). Report from Fabrice bacchella diff --git a/configure.in b/configure.in index c74f65b91..0c9e4fc66 100644 --- a/configure.in +++ b/configure.in @@ -221,10 +221,10 @@ if test -z "$no_libnsl" ; then fi # Checks for header files. -AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h lastlog.h limits.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h usersec.h util.h utmp.h utmpx.h) +AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h lastlog.h limits.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h) # Checks for library functions. -AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage inet_aton innetgr md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid sigaction sigvec snprintf strerror strlcat strlcpy strsep vsnprintf vhangup _getpty __b64_ntop) +AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage getttyent inet_aton innetgr md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid sigaction sigvec snprintf strerror strlcat strlcpy strsep vsnprintf vhangup _getpty __b64_ntop) dnl checks for time functions AC_CHECK_FUNCS(gettimeofday time) dnl checks for libutil functions diff --git a/includes.h b/includes.h index 2f3a56ec6..13042fd21 100644 --- a/includes.h +++ b/includes.h @@ -70,6 +70,9 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #ifdef HAVE_SYS_BSDTTY_H # include #endif +#ifdef HAVE_TTYENT_H +# include +#endif #ifdef USE_PAM # include #endif diff --git a/loginrec.c b/loginrec.c index e7542c92a..798e966f0 100644 --- a/loginrec.c +++ b/loginrec.c @@ -160,7 +160,7 @@ #include "xmalloc.h" #include "loginrec.h" -RCSID("$Id: loginrec.c,v 1.18 2000/08/09 06:34:28 djm Exp $"); +RCSID("$Id: loginrec.c,v 1.19 2000/08/15 00:01:22 djm Exp $"); /** ** prototypes for helper functions in this file @@ -273,7 +273,7 @@ login_get_lastlog(struct logininfo *li, const int uid) { struct passwd *pw; - memset(li, '\0', sizeof(struct logininfo)); + memset(li, '\0', sizeof(*li)); li->uid = uid; /* @@ -311,7 +311,7 @@ logininfo *login_alloc_entry(int pid, const char *username, { struct logininfo *newli; - newli = (struct logininfo *) xmalloc (sizeof(struct logininfo)); + newli = (struct logininfo *) xmalloc (sizeof(*newli)); (void)login_init_entry(newli, pid, username, hostname, line); return newli; } @@ -339,7 +339,7 @@ login_init_entry(struct logininfo *li, int pid, const char *username, { struct passwd *pw; - memset(li, 0, sizeof(struct logininfo)); + memset(li, 0, sizeof(*li)); li->pid = pid; @@ -569,7 +569,7 @@ void construct_utmp(struct logininfo *li, struct utmp *ut) { - memset(ut, '\0', sizeof(struct utmp)); + memset(ut, '\0', sizeof(*ut)); /* First fill out fields used for both logins and logouts */ @@ -643,7 +643,7 @@ set_utmpx_time(struct logininfo *li, struct utmpx *utx) void construct_utmpx(struct logininfo *li, struct utmpx *utx) { - memset(utx, '\0', sizeof(struct utmpx)); + memset(utx, '\0', sizeof(*utx)); # ifdef HAVE_ID_IN_UTMPX line_abbrevname(utx->ut_id, li->line, sizeof(utx->ut_id)); # endif @@ -723,8 +723,30 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut) int tty; /* FIXME: (ATL) ttyslot() needs local implementation */ + +#if defined(SUNOS4) && defined(HAVE_GETTTYENT) + register struct ttyent *ty; + + tty=0; + + setttyent(); + while ((struct ttyent *)0 != (ty = getttyent())) { + tty++; + if (!strncmp(ty->ty_name, ut->ut_line, sizeof(ut->ut_line))) + break; + } + endttyent(); + + if((struct ttyent *)0 == ty) { + log("utmp_write_entry: tty not found"); + return(1); + } +#else /* FIXME */ + tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */ +#endif /* SUNOS4 && HAVE_GETTTYENT */ + if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) { (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); /* @@ -1031,7 +1053,7 @@ wtmp_get_entry(struct logininfo *li) } /* Seek to the start of the last struct utmp */ - if (lseek(fd, (off_t)(0-sizeof(struct utmp)), SEEK_END) == -1) { + if (lseek(fd, (off_t)(0 - sizeof(struct utmp)), SEEK_END) == -1) { /* Looks like we've got a fresh wtmp file */ close(fd); return 0; @@ -1238,7 +1260,7 @@ syslogin_perform_login(struct logininfo *li) { struct utmp *ut; - if (! (ut = (struct utmp *)malloc(sizeof(struct utmp)))) { + if (! (ut = (struct utmp *)malloc(sizeof(*ut)))) { log("syslogin_perform_login: couldn't malloc()"); return 0; } @@ -1301,7 +1323,7 @@ static void lastlog_construct(struct logininfo *li, struct lastlog *last) { /* clear the structure */ - memset(last, '\0', sizeof(struct lastlog)); + memset(last, '\0', sizeof(*last)); (void)line_stripname(last->ll_line, li->line, sizeof(last->ll_line)); strlcpy(last->ll_host, li->hostname, diff --git a/session.c b/session.c index 388d96bb2..47787e778 100644 --- a/session.c +++ b/session.c @@ -601,8 +601,9 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw) } } /* Record that there was a login on that terminal. */ - record_login(pid, s->tty, pw->pw_name, pw->pw_uid, hostname, - (struct sockaddr *)&from); + if (!options.use_login || command != NULL) + record_login(pid, s->tty, pw->pw_name, pw->pw_uid, + hostname, (struct sockaddr *)&from); /* Check if .hushlogin exists. */ snprintf(line, sizeof line, "%.200s/.hushlogin", pw->pw_dir); -- cgit v1.2.3