Problems with setuid(), SVr2v2
Bob Lenk
rml at hpfcdc.HP.COM
Sat Sep 27 05:03:18 AEST 1986
The manual does not reflect the implementation in three areas:
1) If the caller's effective uid is 0, setuid sets
all of the effective, real, and saved uids. Thus
there is no way to toggle back.
2) A setuid(0) call fails if the current effective uid
is not 0, even if the real uid or saved set-user id
is 0 (the latter is actually impossible because of
(1) above).
3) The saved set-group id is not implemented.
This is true of all variants of S5R2 that I have seen (not necessarily
all versions that exist). I believe that (2) and (3) are changed in
S5R3. It seems that (1) causes your problems (although you would run
into (2) if (1) did not exist).
One possible workaround is to fork a child process and have it
setuid(getuid()) and do the file access. Another is to use access(2).
Bob Lenk
{hplabs, ihnp4}!hpfcla!rml
More information about the Net.bugs.usg
mailing list