9 /* #include <sys/stat.h>
10 /* #include <lstat_as.h>
12 /* int lstat_as(path, st, euid, egid)
18 /* lstat_as() looks up the file status of the named \fIpath\fR,
19 /* using the effective rights specified by \fIeuid\fR
20 /* and \fIegid\fR, and stores the result into the structure pointed
21 /* to by \fIst\fR. A -1 result means the lookup failed.
22 /* This call does not follow symbolic links.
24 /* Fatal error: no permission to change privilege level.
26 /* set_eugid(3) switch effective rights
30 /* The Secure Mailer license must be distributed with this software.
33 /* IBM T.J. Watson Research
35 /* Yorktown Heights, NY 10598, USA
44 /* Utility library. */
47 #include "set_eugid.h"
50 /* lstat_as - lstat file as user */
52 int lstat_as(const char *path
, struct stat
* st
, uid_t euid
, gid_t egid
)
54 uid_t saved_euid
= geteuid();
55 gid_t saved_egid
= getegid();
59 * Switch to the target user privileges.
61 set_eugid(euid
, egid
);
66 status
= lstat(path
, st
);
69 * Restore saved privileges.
71 set_eugid(saved_euid
, saved_egid
);