]> andersk Git - openssh.git/commitdiff
- Fix login.c breakage on systems which lack ut_host in struct
authordamien <damien>
Wed, 22 Dec 1999 05:09:48 +0000 (05:09 +0000)
committerdamien <damien>
Wed, 22 Dec 1999 05:09:48 +0000 (05:09 +0000)
   utmp. Reported by Willard Dawson <willard.dawson@sbs.siemens.com>

ChangeLog
login.c

index 0d42093a4167942278dc8a8e2fbcc42cdbcd1fed..256711ebd2ac39ee242b785e565e2d51fcdfde51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 19991222
  - Fix undefined fd_set type in ssh.h from Povl H. Pedersen 
    <pope@netguide.dk>
+ - Fix login.c breakage on systems which lack ut_host in struct
+   utmp. Reported by Willard Dawson <willard.dawson@sbs.siemens.com>
 
 19991221
  - Integration of large HPUX patch from Andre Lucas 
diff --git a/login.c b/login.c
index 115af08ee2925682d9c63a31fd37846228a70332..efc0754b42e4800c40551b6ec681818d12492c03 100644 (file)
--- a/login.c
+++ b/login.c
@@ -53,7 +53,7 @@ unsigned long
 get_last_login_time(uid_t uid, const char *logname,
                    char *buf, unsigned int bufsize)
 {
-#if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG)
+#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
        struct lastlog ll;
        char *lastlog;
        int fd;
@@ -76,7 +76,7 @@ get_last_login_time(uid_t uid, const char *logname,
        buf[bufsize - 1] = 0;
        return ll.ll_time;
 
-#else /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#else /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
        /* Look in wtmp for the last login */
        struct utmp  wt;
        char        *wt_file = _PATH_WTMP;
@@ -101,10 +101,14 @@ get_last_login_time(uid_t uid, const char *logname,
                if ( wt.ut_type == USER_PROCESS) {
                        if ( !strncmp(logname, wt.ut_user, 8) ) {
                                t = (unsigned long) wt.ut_time;
+#ifdef HAVE_HOST_IN_UTMP
                                if (bufsize > sizeof(wt.ut_host) + 1)
                                bufsize = sizeof(wt.ut_host) + 1;
                                strncpy(buf, wt.ut_host, bufsize - 1);
                                buf[bufsize - 1] = 0;
+#else /* HAVE_HOST_IN_UTMP */
+                               buf[0] = 0;
+#endif /* HAVE_HOST_IN_UTMP */
                        }
                }
 
@@ -113,7 +117,7 @@ get_last_login_time(uid_t uid, const char *logname,
        } while (t == 0);
 
        return t;
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
 }
 
 /*
@@ -125,10 +129,10 @@ void
 record_login(int pid, const char *ttyname, const char *user, uid_t uid,
             const char *host, struct sockaddr_in * addr)
 {
-#if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG)
+#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
        struct lastlog ll;
        char *lastlog;
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
        struct UTMP_STR u;
        const char *utmp, *wtmp;
 
@@ -152,7 +156,7 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
 
        login(&u);
 
-#if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG)
+#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
        lastlog = _PATH_LASTLOG;
 
        /* Update lastlog unless actually recording a logout. */
@@ -176,7 +180,7 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
                        close(fd);
                }
        }
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
 }
 
 /* Records that the user has logged out. */
This page took 0.26285 seconds and 5 git commands to generate.