summaryrefslogtreecommitdiff
path: root/inet
diff options
context:
space:
mode:
Diffstat (limited to 'inet')
-rw-r--r--inet/rcmd.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c
index fb91f851b7..342c1c909e 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -306,7 +306,6 @@ iruserok(raddr, superuser, ruser, luser)
struct stat sbuf;
struct passwd pwdbuf, *pwd;
FILE *hostf;
- uid_t uid;
int first;
first = 1;
@@ -326,7 +325,7 @@ again:
char *buffer = __alloca (buflen);
first = 0;
- if (getpwnam_r (luser, &pwdbuf, buffer, buflen, &pwd) < 0)
+ if (__getpwnam_r (luser, &pwdbuf, buffer, buflen, &pwd) < 0)
return -1;
dirlen = strlen (pwd->pw_dir);
@@ -339,10 +338,15 @@ again:
* reading an NFS mounted file system, can't read files that
* are protected read/write owner only.
*/
- uid = geteuid();
- (void)seteuid(pwd->pw_uid);
- hostf = fopen(pbuf, "r");
- (void)seteuid(uid);
+ if (__euidaccess (pbuf, R_OK) != 0)
+ hostf = NULL;
+ else
+ {
+ uid_t uid = geteuid ();
+ seteuid (pwd->pw_uid);
+ hostf = fopen (pbuf, "r");
+ seteuid (uid);
+ }
if (hostf == NULL)
return (-1);