- register char *namep;
- int t, f, c;
- int invalid;
- int quietlog;
- int i;
- FILE *nlfd;
- char *ttyn;
- int ldisc = 0;
-#ifdef UNAME
- struct utsname uts;
-#endif
-
- alarm(60);
- signal(SIGQUIT, SIG_IGN);
- signal(SIGINT, SIG_IGN);
- nice(-100);
- nice(20);
- nice(0);
- if (argc > 0 && !strcmp(argv[1], "-r")) {
- rflag++;
- getstr(rusername, sizeof (rusername), "Username");
- getstr(rpassword, sizeof (rpassword), "Password");
- getstr(term+5, sizeof(term)-5, "Terminal type");
- }
-#ifdef TIOCLSET
- ioctl(0, TIOCLSET, 0);
-#endif
- ioctl(0, TIOCNXCL, 0);
- gtty(0, &ttyb);
- if (rflag) {
- char *cp = index(term, '/');
- if (cp) {
- int i;
- *cp++ = 0;
- for (i = 0; i < NSPEEDS; i++)
- if (!strcmp(speeds[i], cp)) {
- ttyb.sg_ispeed = ttyb.sg_ospeed = i;
- break;
- }
+ extern int errno, optind;
+ extern char *optarg, **environ;
+ struct timeval tp;
+ struct tm *ttp;
+ struct timeval tp;
+ struct tm *ttp;
+ struct group *gr;
+ register int ch;
+ register char *p;
+ int ask, fflag, hflag, pflag, cnt;
+ int quietlog, passwd_req, ioctlval, timedout();
+ char *domain, *salt, *envinit[1], *ttyn, *pp;
+ char tbuf[MAXPATHLEN + 2];
+ char *ctime(), *ttyname(), *stypeof(), *crypt(), *getpass();
+ time_t time();
+ off_t lseek();
+
+ (void)signal(SIGALRM, timedout);
+ (void)alarm((u_int)timeout);
+ (void)signal(SIGQUIT, SIG_IGN);
+ (void)signal(SIGINT, SIG_IGN);
+ (void)setpriority(PRIO_PROCESS, 0, 0);
+ (void)quota(Q_SETUID, 0, 0, 0);
+
+ /*
+ * -p is used by getty to tell login not to destroy the environment
+ * -f is used to skip a second login authentication
+ * -h is used by other servers to pass the name of the remote
+ * host to login so that it may be placed in utmp and wtmp
+ */
+ (void)gethostname(tbuf, sizeof(tbuf));
+ domain = index(tbuf, '.');
+
+ fflag = hflag = pflag = 0;
+ passwd_req = 1;
+ while ((ch = getopt(argc, argv, "fh:p")) != EOF)
+ switch (ch) {
+ case 'f':
+ fflag = 1;
+ break;
+ case 'h':
+ if (getuid()) {
+ fprintf(stderr,
+ "login: -h for super-user only.\n");
+ exit(1);
+ }
+ hflag = 1;
+ if (domain && (p = index(optarg, '.')) &&
+ strcasecmp(p, domain) == 0)
+ *p = 0;
+ hostname = optarg;
+ break;
+ case 'p':
+ pflag = 1;
+ break;
+ case '?':
+ default:
+ fprintf(stderr, "usage: login [-fp] [username]\n");
+ exit(1);