+ setpriority(PRIO_PROCESS, 0, 0);
+ quota(Q_SETUID, 0, 0, 0);
+ /*
+ * -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
+ */
+ (void) gethostname(me, sizeof(me));
+ domain = index(me, '.');
+ while (argc > 1) {
+ if (strcmp(argv[1], "-r") == 0) {
+ if (rflag || hflag || fflag) {
+ printf("Other options not allowed with -r\n");
+ exit(1);
+ }
+ if (argv[2] == 0)
+ exit(1);
+ rflag = 1;
+ usererr = doremotelogin(argv[2]);
+ if ((p = index(argv[2], '.')) && strcmp(p, domain) == 0)
+ *p = 0;
+ SCPYN(utmp.ut_host, argv[2]);
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+ if (strcmp(argv[1], "-h") == 0) {
+ if (getuid() == 0) {
+ if (rflag || hflag) {
+ printf("Only one of -r and -h allowed\n");
+ exit(1);
+ }
+ hflag = 1;
+ if ((p = index(argv[2], '.')) &&
+ strcmp(p, domain) == 0)
+ *p = 0;
+ SCPYN(utmp.ut_host, argv[2]);
+ }
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+ if (strcmp(argv[1], "-f") == 0 && argc > 2) {
+ if (rflag) {
+ printf("Only one of -r and -f allowed\n");
+ exit(1);
+ }
+ fflag = 1;
+ SCPYN(utmp.ut_name, argv[2]);
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+ if (strcmp(argv[1], "-p") == 0) {
+ argc--;
+ argv++;
+ pflag = 1;
+ continue;
+ }
+ break;
+ }
+ ioctl(0, TIOCLSET, &zero);