]> andersk Git - openssh.git/blobdiff - loginrec.c
Hopefully things did not get mixed around too much. It compiles under
[openssh.git] / loginrec.c
index 2f5fc769626218aa4cd34c15f5908abbd8e809cb..b664a9cfec86ef329223376359a546be38b7ecce 100644 (file)
 
 /**
  ** 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
  **
  **/
 
 #include "ssh.h"
 #include "xmalloc.h"
 #include "loginrec.h"
+#include "log.h"
+#include "atomicio.h"
 
 RCSID("$Id$");
 
+#ifdef HAVE_UTIL_H
+#  include <util.h>
+#endif
+
+#ifdef HAVE_LIBUTIL_H
+#   include <libutil.h>
+#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);
This page took 0.038027 seconds and 4 git commands to generate.