- 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 ((user = index(ahost, '\n')) != 0)
- *user++ = '\0';
- if ((user = index(ahost, ' ')) != 0)
- *user++ = '\0';
- if (!strcmp(host, ahost) &&
- !strcmp(rusername, user ? user : lusername)) {
- fclose(hostf);
- return (1);
- }
- }
- fclose(hostf);
- }
- if (first == 1) {
- char *rhosts = ".rhosts";
- struct stat sbuf;
-
- first = 0;
- if (chdir(pwd->pw_dir) < 0)
- goto again;
- if (lstat(rhosts, &sbuf) < 0)
- goto again;
- if ((sbuf.st_mode & S_IFMT) == S_IFLNK) {
- printf("login: .rhosts is a soft link.\r\n");
- goto bad;
- }
- hostf = fopen(rhosts, "r");
- fstat(fileno(hostf), &sbuf);
- if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) {
- printf("login: Bad .rhosts ownership.\r\n");
- fclose(hostf);
- goto bad;
- }
- goto again;
- }
-bad:
- return (-1);
+ return(ruserok(host, (pwd->pw_uid == 0), rusername, lusername));