SCCS-vsn: usr.bin/login/login.c 5.40
#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%";
*/
#include <sys/param.h>
*/
#include <sys/param.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>
#include <utmp.h>
#include <signal.h>
#include <utmp.h>
#include <signal.h>
#include <errno.h>
#include <ttyent.h>
#include <syslog.h>
#include <errno.h>
#include <ttyent.h>
#include <syslog.h>
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();
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
/* 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.
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);