2 Check access to files by the user and by the daemon. */
12 /* See if the user has access to a file, to prevent the setuid uucp
13 and uux programs handing out unauthorized access. */
16 fsysdep_access (zfile)
19 if (access (zfile, R_OK) == 0)
21 ulog (LOG_ERROR, "%s: %s", zfile, strerror (errno));
25 /* See if the daemon has access to a file. This is called if a file
26 is not being transferred to the spool directory, since if the
27 daemon does not have access the later transfer will fail. We
28 assume that the daemon will have the same euid (or egid) as the one
29 we are running under. If our uid (gid) and euid (egid) are the
30 same, we assume that we have access. Note that is not important
31 for security, since the check will be (implicitly) done again when
32 the daemon tries to transfer the file. This routine should work
33 whether the UUCP programs are installed setuid or setgid. */
36 fsysdep_daemon_access (zfile)
40 uid_t ieuid, iuid, iegid, igid;
50 /* If our effective uid and gid are the same as our real uid and
51 gid, we assume the daemon will have access to the file. */
52 if (ieuid == iuid && iegid == igid)
55 if (stat ((char *) zfile, &s) != 0)
57 ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
61 /* If our euid is not our uid, but it is the file's uid, see if the
62 owner has read access. Otherwise, if our egid is not our gid,
63 but it is the file's gid, see if the group has read access.
64 Otherwise, see if the world has read access. We know from the
65 above check that at least one of our euid and egid are different,
66 so that is the only one we want to check. This check could fail
67 if the UUCP programs were both setuid and setgid, but why would
69 if (ieuid != iuid && ieuid == s.st_uid)
70 fok = (s.st_mode & S_IRUSR) != 0;
71 else if (iegid != igid && iegid == s.st_gid)
72 fok = (s.st_mode & S_IRGRP) != 0;
74 fok = (s.st_mode & S_IROTH) != 0;
78 ulog (LOG_ERROR, "%s: cannot be read by daemon", zfile);