- 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)
- 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 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, rflag, cnt;
+ int quietlog, passwd_req, ioctlval, rval;
+ char *domain, *salt, *ttyn;
+ char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
+ char localhost[MAXHOSTNAMELEN];
+ char *ctime(), *ttyname(), *stypeof(), *crypt(), *getpass();
+ time_t time();
+ off_t lseek();
+ void timedout();
+
+ (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);
+
+ openlog("login", LOG_ODELAY, LOG_AUTH);
+
+ /*
+ * -p is used by getty to tell login not to destroy the environment
+ * -r is used by rlogind to cause the autologin protocol;
+ * -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
+ */
+ domain = NULL;
+ if (gethostname(localhost, sizeof(localhost)) < 0)
+ syslog(LOG_ERR, "couldn't get local hostname: %m");
+ else
+ domain = index(localhost, '.');
+
+ fflag = hflag = pflag = rflag = 0;
+ passwd_req = 1;
+ uid = getuid();
+ while ((ch = getopt(argc, argv, "fh:pr:")) != EOF)
+ switch (ch) {
+ case 'f':
+ if (rflag) {
+ fprintf(stderr,
+ "login: only one of -r and -f allowed.\n");
+ exit(1);