- register char *namep;
- int t, f, c;
- int invalid;
- int quietlog;
- int i;
- FILE *nlfd;
- char *ttyn;
- int ldisc = 0, zero = 0;
- FILE *hostf; int first = 1;
-
- alarm(60);
- signal(SIGQUIT, SIG_IGN);
- signal(SIGINT, SIG_IGN);
- nice(-100);
- nice(20);
- nice(0);
- if (argc > 1 && !strcmp(argv[1], "-r")) {
- rflag++;
- rhost = argv[2];
- argc = 1;
- getstr(rusername, sizeof (rusername), "remuser");
- getstr(lusername, sizeof (lusername), "locuser");
- getstr(term+5, sizeof(term)-5, "Terminal type");
- if (getuid())
- goto abnormal;
- setpwent();
- pwd = getpwnam(lusername);
- endpwent();
- if (pwd == NULL) {
- if (strcmp(rusername, lusername))
- printf("%s: No such user\r\n", lusername);
- goto abnormal;
- }
- hostf = pwd->pw_uid ? fopen("/etc/hosts.equiv", "r") : 0;
- again:
- if (hostf) {
- char ahost[32];
- while (fgets(ahost, sizeof (ahost), hostf)) {
- char *user;
- if (index(ahost, '\n'))
- *index(ahost, '\n') = 0;
- user = index(ahost, ' ');
- if (user)
- *user++ = 0;
- if (!strcmp(rhost, ahost) &&
- !strcmp(rusername, user ? user : lusername)) {
- fclose(hostf);
- goto normal;
+ 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);