]> andersk Git - openssh.git/commitdiff
- (djm) Fixes to login code - not setting li->uid, cleanups
authordjm <djm>
Mon, 26 Jun 2000 23:40:06 +0000 (23:40 +0000)
committerdjm <djm>
Mon, 26 Jun 2000 23:40:06 +0000 (23:40 +0000)
ChangeLog
loginrec.c

index f6f70c91e895c998301f4d0e9225918de734e1bb..292f17635be6edfaef861fc090d41c6dbed7dc80 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+20000627
+ - (djm) Fixes to login code - not setting li->uid, cleanups
+
 20000626
  - (djm) Better fix to aclocal tests from Garrick James <garrick@james.net>
  - (djm) Account expiry support from Andreas Steinmetz <ast@domdv.de>
index 7b1103c1b3137e071f210fc70225233958fc69f5..7f686db13bc678cadb604132ff1e94a53a075818 100644 (file)
@@ -198,16 +198,9 @@ int lastlog_get_entry(struct logininfo *li);
 int wtmp_get_entry(struct logininfo *li);
 int wtmpx_get_entry(struct logininfo *li);
 
-
-#ifdef MIN
-# undef MIN
-# define MIN(a,b) ( (a)<(b) ? (a) : (b) )
-#endif
-
 /* pick the shortest string */
 #define MIN_SIZEOF(s1,s2) ( sizeof(s1) < sizeof(s2) ? sizeof(s1) : sizeof(s2) )
 
-
 /**
  ** platform-independent login functions
  **/
@@ -303,7 +296,7 @@ login_get_lastlog(struct logininfo *li, const int uid)
        pw = getpwuid(uid);
        /* No MIN_SIZEOF here - we absolutely *must not* truncate the
          * username */
-       strlcpy(li->username, pw->pw_name, li->username);
+       strlcpy(li->username, pw->pw_name, sizeof(li->username));
 #endif
        if (getlast_entry(li))
                return li;
@@ -353,18 +346,27 @@ int
 login_init_entry(struct logininfo *li, int pid, const char *username, 
                 const char *hostname, const char *line)
 {
+       struct passwd *pw;
+       
        /* zero the structure */
        memset(li, 0, sizeof(struct logininfo));
   
        li->pid = pid;
+
        /* set the line information */
        if (line)
                line_fullname(li->line, line, sizeof(li->line));
 
-       if (username)
+       if (username) {
                strlcpy(li->username, username, sizeof(li->username));
+               pw = getpwnam(li->username);
+               if (pw == NULL)
+                       fatal("login_init_entry: Cannot find user \"%s\"", li->username);
+               li->uid = pw->pw_uid;
+       }
        if (hostname)
                strlcpy(li->hostname, hostname, sizeof(li->hostname));
+
        return 1;
 }
 
@@ -377,16 +379,12 @@ login_init_entry(struct logininfo *li, int pid, const char *username,
 void
 login_set_current_time(struct logininfo *li)
 {
-#ifdef HAVE_SYS_TIME_H
        struct timeval tv;
 
        gettimeofday(&tv, NULL);
-       li->tv_sec = tv.tv_sec ; li->tv_usec = tv.tv_usec;
-#else
-       time_t tm = time(0);
-
-       li->tv_sec = tm; li->tv_usec = 0;
-#endif
+       
+       li->tv_sec = tv.tv_sec;
+       li->tv_usec = tv.tv_usec;
 }
 
 
@@ -1394,17 +1392,17 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
 
        type = lastlog_filetype(LASTLOG_FILE);
        switch (type) {
-       case LL_FILE:
-               strlcpy(lastlog_file, LASTLOG_FILE, sizeof(lastlog_file));
-               break;
-       case LL_DIR:
-               snprintf(lastlog_file, sizeof(lastlog_file), "%s/%s",
-                        LASTLOG_FILE, li->username);
-               break;
-       default:
-               log("lastlog_openseek: %.100s is not a file or directory!",
-                   LASTLOG_FILE);
-               return 0;
+               case LL_FILE:
+                       strlcpy(lastlog_file, LASTLOG_FILE, sizeof(lastlog_file));
+                       break;
+               case LL_DIR:
+                       snprintf(lastlog_file, sizeof(lastlog_file), "%s/%s",
+                                LASTLOG_FILE, li->username);
+                       break;
+               default:
+                       log("lastlog_openseek: %.100s is not a file or directory!",
+                           LASTLOG_FILE);
+                       return 0;
        } /* switch */
 
        *fd = open(lastlog_file, filemode);
This page took 0.054598 seconds and 5 git commands to generate.