file system reorg; paths.h; add setlogname, clean up getpwent()
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 10 May 1989 04:33:07 +0000 (20:33 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 10 May 1989 04:33:07 +0000 (20:33 -0800)
SCCS-vsn: usr.bin/login/login.c 5.40

usr/src/usr.bin/login/login.c

index 33f463d..4f8110f 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)login.c    5.39 (Berkeley) %G%";
+static char sccsid[] = "@(#)login.c    5.40 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -33,7 +33,7 @@ static char sccsid[] = "@(#)login.c   5.39 (Berkeley) %G%";
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
-#include <sys/quota.h>
+#include <ufs/quota.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -42,7 +42,6 @@ static char sccsid[] = "@(#)login.c   5.39 (Berkeley) %G%";
 
 #include <utmp.h>
 #include <signal.h>
 
 #include <utmp.h>
 #include <signal.h>
-#include <lastlog.h>
 #include <errno.h>
 #include <ttyent.h>
 #include <syslog.h>
 #include <errno.h>
 #include <ttyent.h>
 #include <syslog.h>
@@ -98,7 +97,7 @@ main(argc, argv)
        int ask, fflag, hflag, pflag, rflag, cnt;
        int quietlog, passwd_req, ioctlval, timedout();
        char *domain, *salt, *envinit[1], *ttyn, *pp;
        int ask, fflag, hflag, pflag, rflag, cnt;
        int quietlog, passwd_req, ioctlval, timedout();
        char *domain, *salt, *envinit[1], *ttyn, *pp;
-       char tbuf[MAXPATHLEN + 2];
+       char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
        char *ctime(), *ttyname(), *stypeof(), *crypt(), *getpass();
        time_t time();
        off_t lseek();
        char *ctime(), *ttyname(), *stypeof(), *crypt(), *getpass();
        time_t time();
        off_t lseek();
@@ -213,8 +212,10 @@ main(argc, argv)
                close(cnt);
 
        ttyn = ttyname(0);
                close(cnt);
 
        ttyn = ttyname(0);
-       if (ttyn == NULL || *ttyn == '\0')
-               ttyn = "/dev/tty??";
+       if (ttyn == NULL || *ttyn == '\0') {
+               (void)sprintf(tname, "%s??", _PATH_TTY);
+               ttyn = tname;
+       }
        if (tty = rindex(ttyn, '/'))
                ++tty;
        else
        if (tty = rindex(ttyn, '/'))
                ++tty;
        else
@@ -294,6 +295,9 @@ main(argc, argv)
        /* committed to login -- turn off timeout */
        (void)alarm((u_int)0);
 
        /* committed to login -- turn off timeout */
        (void)alarm((u_int)0);
 
+       /* paranoia... */
+       endpwent();
+
        /*
         * If valid so far and root is logging in, see if root logins on
         * this terminal are permitted.
        /*
         * If valid so far and root is logging in, see if root logins on
         * this terminal are permitted.
@@ -457,6 +461,9 @@ main(argc, argv)
        strcpy(tbuf + 1, (p = rindex(pwd->pw_shell, '/')) ?
            p + 1 : pwd->pw_shell);
 
        strcpy(tbuf + 1, (p = rindex(pwd->pw_shell, '/')) ?
            p + 1 : pwd->pw_shell);
 
+       if (setlogname(pwd->pw_name, strlen(pwd->pw_name)) < 0)
+               syslog(LOG_ERR, "setlogname() failure: %m");
+
        /* discard permissions last so can't get killed and drop core */
        (void)setuid(pwd->pw_uid);
 
        /* discard permissions last so can't get killed and drop core */
        (void)setuid(pwd->pw_uid);