X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/1a022229f2a724d88c940078fbd47bb390017b63..42f11eb24fa39e437b4f1e6beb5cc83901aa5bdd:/loginrec.c diff --git a/loginrec.c b/loginrec.c index 2f5fc769..b664a9cf 100644 --- a/loginrec.c +++ b/loginrec.c @@ -132,25 +132,26 @@ /** ** TODO: - ** homegrown ttyslot()q + ** homegrown ttyslot() ** test, test, test ** ** Platform status: ** ---------------- ** ** Known good: - ** Linux (Redhat 6.2, need more variants) + ** Linux (Redhat 6.2, Debian) + ** Solaris ** HP-UX 10.20 (gcc only) ** IRIX + ** NeXT - M68k/HPPA/Sparc (4.2/3.3) ** ** Testing required: Please send reports! - ** Solaris ** NetBSD ** HP-UX 11 ** AIX ** ** Platforms with known problems: - ** NeXT + ** Some variants of Slackware Linux ** **/ @@ -159,9 +160,19 @@ #include "ssh.h" #include "xmalloc.h" #include "loginrec.h" +#include "log.h" +#include "atomicio.h" RCSID("$Id$"); +#ifdef HAVE_UTIL_H +# include +#endif + +#ifdef HAVE_LIBUTIL_H +# include +#endif + /** ** prototypes for helper functions in this file **/ @@ -400,10 +411,12 @@ login_set_addr(struct logininfo *li, const struct sockaddr *sa, int login_write (struct logininfo *li) { +#ifndef HAVE_CYGWIN if ((int)geteuid() != 0) { log("Attempt to write login records by non-root user (aborting)"); return 1; } +#endif /* set the timestamp */ login_set_current_time(li); @@ -491,9 +504,9 @@ char * line_fullname(char *dst, const char *src, int dstsize) { memset(dst, '\0', dstsize); - if ((strncmp(src, "/dev/", 5) == 0) || (dstsize < (strlen(src) + 5))) + if ((strncmp(src, "/dev/", 5) == 0) || (dstsize < (strlen(src) + 5))) { strlcpy(dst, src, dstsize); - else { + } else { strlcpy(dst, "/dev/", dstsize); strlcat(dst, src, dstsize); } @@ -506,7 +519,7 @@ line_stripname(char *dst, const char *src, int dstsize) { memset(dst, '\0', dstsize); if (strncmp(src, "/dev/", 5) == 0) - strlcpy(dst, &src[5], dstsize); + strlcpy(dst, src + 5, dstsize); else strlcpy(dst, src, dstsize); return dst; @@ -526,8 +539,13 @@ line_abbrevname(char *dst, const char *src, int dstsize) memset(dst, '\0', dstsize); /* Always skip prefix if present */ +#ifdef sgi + if (strncmp(src, "/dev/tty", 8) == 0) + src += 8; +#else if (strncmp(src, "/dev/", 5) == 0) src += 5; +#endif len = strlen(src); @@ -675,7 +693,9 @@ construct_utmpx(struct logininfo *li, struct utmpx *utx) strncpy(utx->ut_host, li->hostname, MIN_SIZEOF(utx->ut_host, li->hostname)); # endif # ifdef HAVE_ADDR_IN_UTMPX - /* FIXME: (ATL) not supported yet */ + /* this is just a 32-bit IP address */ + if (li->hostaddr.sa.sa_family == AF_INET) + utx->ut_addr = li->hostaddr.sa_in.sin_addr.s_addr; # endif # ifdef HAVE_SYSLEN_IN_UTMPX /* ut_syslen is the length of the utx_host string */ @@ -724,7 +744,7 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut) /* FIXME: (ATL) ttyslot() needs local implementation */ -#if defined(SUNOS4) && defined(HAVE_GETTTYENT) +#if defined(HAVE_GETTTYENT) register struct ttyent *ty; tty=0; @@ -745,7 +765,7 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut) tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */ -#endif /* SUNOS4 && HAVE_GETTTYENT */ +#endif /* 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);