+ 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;
+ }
+ }
+ fclose(hostf);
+ }
+ if (first == 1) {
+ first = 0;
+ if (chdir(pwd->pw_dir) < 0)
+ goto again;
+ hostf = fopen(".rhosts", "r");
+ goto again;
+ }
+abnormal:
+ rhost = 0;
+ rflag = -1;
+ }
+normal:
+ ioctl(0, TIOCLSET, &zero); /* XXX */