]> andersk Git - openssh.git/blobdiff - loginrec.c
- (djm) Bug #406: s/msg_send/ssh_msg_send/ for Mac OS X 1.2
[openssh.git] / loginrec.c
index 2aff6d2b53cd90f17052d7196c16777db7dcd5bc..0c4ceddc1d9e40831cc485872337f267bd1e67f8 100644 (file)
   symbols for the platform.
 
   Use logintest to check which symbols are defined before modifying
-  configure.in and loginrec.c. (You have to build logintest yourself
+  configure.ac and loginrec.c. (You have to build logintest yourself
   with 'make logintest' as it's not built by default.)
 
   Otherwise, patches to the specific method(s) are very helpful!
@@ -443,6 +443,28 @@ login_write (struct logininfo *li)
        return 0;
 }
 
+#ifdef LOGIN_NEEDS_UTMPX
+int
+login_utmp_only(struct logininfo *li)
+{
+       li->type = LTYPE_LOGIN; 
+       login_set_current_time(li);
+# ifdef USE_UTMP
+       utmp_write_entry(li);
+# endif
+# ifdef USE_WTMP
+       wtmp_write_entry(li);
+# endif
+# ifdef USE_UTMPX
+       utmpx_write_entry(li);
+# endif
+# ifdef USE_WTMPX
+       wtmpx_write_entry(li);
+# endif
+       return 0;
+}
+#endif
+
 /**
  ** getlast_entry: Call low-level functions to retrieve the last login
  **                time.
@@ -542,6 +564,11 @@ line_abbrevname(char *dst, const char *src, int dstsize)
        if (strncmp(src, "/dev/", 5) == 0)
                src += 5;
 
+#ifdef WITH_ABBREV_NO_TTY
+       if (strncmp(src, "tty", 3) == 0)
+               src += 3;
+#endif
+
        len = strlen(src);
 
        if (len > 0) {
@@ -595,9 +622,15 @@ construct_utmp(struct logininfo *li,
        switch (li->type) {
        case LTYPE_LOGIN:
                ut->ut_type = USER_PROCESS;
+#ifdef _UNICOS
+               cray_set_tmpdir(ut);
+#endif
                break;
        case LTYPE_LOGOUT:
                ut->ut_type = DEAD_PROCESS;
+#ifdef _UNICOS
+               cray_retain_utmp(ut, li->pid);
+#endif
                break;
        }
 # endif
@@ -673,6 +706,8 @@ construct_utmpx(struct logininfo *li, struct utmpx *utx)
        line_stripname(utx->ut_line, li->line, sizeof(utx->ut_line));
        set_utmpx_time(li, utx);
        utx->ut_pid = li->pid;
+       /* strncpy(): Don't necessarily want null termination */
+       strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username));
 
        if (li->type == LTYPE_LOGOUT)
                return;
@@ -682,8 +717,6 @@ construct_utmpx(struct logininfo *li, struct utmpx *utx)
         * for logouts.
         */
 
-       /* strncpy(): Don't necessarily want null termination */
-       strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username));
 # ifdef HAVE_HOST_IN_UTMPX
        strncpy(utx->ut_host, li->hostname, MIN_SIZEOF(utx->ut_host, li->hostname));
 # endif
@@ -914,9 +947,7 @@ utmpx_perform_logout(struct logininfo *li)
 {
        struct utmpx utx;
 
-       memset(&utx, '\0', sizeof(utx));
-       set_utmpx_time(li, &utx);
-       line_stripname(utx.ut_line, li->line, sizeof(utx.ut_line));
+       construct_utmpx(li, &utx);
 # ifdef HAVE_ID_IN_UTMPX
        line_abbrevname(utx.ut_id, li->line, sizeof(utx.ut_id));
 # endif
@@ -1068,7 +1099,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)sizeof(struct utmp), SEEK_END) == -1) {
                /* Looks like we've got a fresh wtmp file */
                close(fd);
                return 0;
@@ -1101,7 +1132,7 @@ wtmp_get_entry(struct logininfo *li)
                        continue;
                }
                /* Seek back 2 x struct utmp */
-               if (lseek(fd, (off_t)(0-2*sizeof(struct utmp)), SEEK_CUR) == -1) {
+               if (lseek(fd, -(off_t)(2 * sizeof(struct utmp)), SEEK_CUR) == -1) {
                        /* We've found the start of the file, so quit */
                        close (fd);
                        return 0;
@@ -1218,13 +1249,13 @@ wtmpx_get_entry(struct logininfo *li)
        }
        if (fstat(fd, &st) != 0) {
                log("wtmpx_get_entry: couldn't stat %s: %s",
-                   WTMP_FILE, strerror(errno));
+                   WTMPX_FILE, strerror(errno));
                close(fd);
                return 0;
        }
 
        /* Seek to the start of the last struct utmpx */
-       if (lseek(fd, (off_t)(0-sizeof(struct utmpx)), SEEK_END) == -1 ) {
+       if (lseek(fd, -(off_t)sizeof(struct utmpx), SEEK_END) == -1 ) {
                /* probably a newly rotated wtmpx file */
                close(fd);
                return 0;
@@ -1240,6 +1271,7 @@ wtmpx_get_entry(struct logininfo *li)
                /* Logouts are recorded as a blank username on a particular line.
                 * So, we just need to find the username in struct utmpx */
                if ( wtmpx_islogin(li, &utx) ) {
+                       found = 1;
 # ifdef HAVE_TV_IN_UTMPX
                        li->tv_sec = utx.ut_tv.tv_sec;
 # else
@@ -1254,7 +1286,7 @@ wtmpx_get_entry(struct logininfo *li)
 # endif
                        continue;
                }
-               if (lseek(fd, (off_t)(0-2*sizeof(struct utmpx)), SEEK_CUR) == -1) {
+               if (lseek(fd, -(off_t)(2 * sizeof(struct utmpx)), SEEK_CUR) == -1) {
                        close (fd);
                        return 0;
                }
@@ -1397,7 +1429,7 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
 
        if (type == LL_FILE) {
                /* find this uid's offset in the lastlog file */
-               offset = (off_t) ( (long)li->uid * sizeof(struct lastlog));
+               offset = (off_t) ((long)li->uid * sizeof(struct lastlog));
 
                if ( lseek(*fd, offset, SEEK_SET) != offset ) {
                        log("lastlog_openseek: %s->lseek(): %s",
@@ -1460,17 +1492,20 @@ lastlog_get_entry(struct logininfo *li)
        struct lastlog last;
        int fd;
 
-       if (lastlog_openseek(li, &fd, O_RDONLY)) {
-               if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) {
-                       log("lastlog_get_entry: Error reading from %s: %s",
-                           LASTLOG_FILE, strerror(errno));
-                       return 0;
-               } else {
-                       lastlog_populate_entry(li, &last);
-                       return 1;
-               }
-       } else {
+       if (!lastlog_openseek(li, &fd, O_RDONLY))
+               return 0;
+
+       if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) {
+               close(fd);
+               log("lastlog_get_entry: Error reading from %s: %s",
+                   LASTLOG_FILE, strerror(errno));
                return 0;
        }
+
+       close(fd);
+
+       lastlog_populate_entry(li, &last);
+
+       return 1;
 }
 #endif /* USE_LASTLOG */
This page took 0.045287 seconds and 4 git commands to generate.