mdev: do not follow symlinks in /sys (as was intended prior to rev 18811).
[oweals/busybox.git] / loginutils / login.c
index d7eb8d35bae41bcb32082480d43613168ff3d5a3..9c7941e0dbc335268b11a8b46366163e611e1267 100644 (file)
@@ -80,7 +80,7 @@ static void read_or_build_utent(struct utmp *utptr, int picky)
                 * remotely meaningful by skipping "tty"... */
                strncpy(utptr->ut_id, short_tty + 3, sizeof(utptr->ut_id));
                strncpy(utptr->ut_user, "LOGIN", sizeof(utptr->ut_user));
-               utptr->ut_time = time(NULL);
+               utptr->ut_tv.tv_sec = time(NULL);
        }
        if (!picky)     /* root login */
                memset(utptr->ut_host, 0, sizeof(utptr->ut_host));
@@ -96,7 +96,7 @@ static void write_utent(struct utmp *utptr, const char *username)
 {
        utptr->ut_type = USER_PROCESS;
        strncpy(utptr->ut_user, username, sizeof(utptr->ut_user));
-       utptr->ut_time = time(NULL);
+       utptr->ut_tv.tv_sec = time(NULL);
        /* other fields already filled in by read_or_build_utent above */
        setutent();
        pututline(utptr);
@@ -130,7 +130,7 @@ static void die_if_nologin(void)
                fclose(fp);
        } else
                puts("\r\nSystem closed for routine maintenance\r");
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 #else
 static ALWAYS_INLINE void die_if_nologin(void) {}
@@ -178,18 +178,18 @@ static void get_username_or_die(char *buf, int size_buf)
        /* skip whitespace */
        do {
                c = getchar();
-               if (c == EOF) exit(1);
+               if (c == EOF) exit(EXIT_FAILURE);
                if (c == '\n') {
-                       if (!--cntdown) exit(1);
+                       if (!--cntdown) exit(EXIT_FAILURE);
                        goto prompt;
                }
        } while (isspace(c));
 
        *buf++ = c;
        if (!fgets(buf, size_buf-2, stdin))
-               exit(1);
+               exit(EXIT_FAILURE);
        if (!strchr(buf, '\n'))
-               exit(1);
+               exit(EXIT_FAILURE);
        while (isgraph(*buf)) buf++;
        *buf = '\0';
 }
@@ -206,7 +206,7 @@ static void motd(void)
        }
 }
 
-static void alarm_handler(int sig ATTRIBUTE_UNUSED)
+static void alarm_handler(int sig UNUSED_PARAM)
 {
        /* This is the escape hatch!  Poor serial line users and the like
         * arrive here when their connection is broken.
@@ -221,7 +221,7 @@ static void alarm_handler(int sig ATTRIBUTE_UNUSED)
 }
 
 int login_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int login_main(int argc, char **argv)
+int login_main(int argc UNUSED_PARAM, char **argv)
 {
        enum {
                LOGIN_OPT_f = (1<<0),
@@ -269,8 +269,9 @@ int login_main(int argc, char **argv)
                        bb_error_msg_and_die("-f is for root only");
                safe_strncpy(username, opt_user, sizeof(username));
        }
-       if (optind < argc) /* user from command line (getty) */
-               safe_strncpy(username, argv[optind], sizeof(username));
+       argv += optind;
+       if (argv[0]) /* user from command line (getty) */
+               safe_strncpy(username, argv[0], sizeof(username));
 
        /* Let's find out and memorize our tty */
        if (!isatty(0) || !isatty(1) || !isatty(2))