again
Ken Arromdee
arrom at aplcen.apl.jhu.edu
Mon Apr 17 07:06:50 AEST 1989
Something I posted twice before. The first time it didn't get out of jhunix
(at least, I got no responses, and I couldn't see it on aplcen). The second
I posted to unix.wizards, realized my mistake, made another posting stating I
meant to post it to this group instead, and somehow never actually got around
to posting it here. But anyway, here's my problem; can anyone solve it?
--------------------------------------------------------------
I have a program which is run setuid. I want to set the uid back to the
original before exec'ing a shell. It doesn't work. The following illustrates
the problem (it's run on an AT&T 3B4000 with SYSV). (uids is just a small
program to print out one's real and effective uids).
--------------------------------------------------------------
% uids
Real: user 7943 (ins_akaa), group 2048
Effective: user 7943 (ins_akaa), group 2048
% cd /s/adev/src/h/src
% cat test.c
extern unsigned short getuid();
extern unsigned short geteuid();
main()
{
printf("Before setuid(getuid())\n");
printf("Real UID=%d; effective UID=%d\n",
(int)getuid(), (int)geteuid());
setuid(getuid());
printf("After setuid(getuid())\n");
printf("Real UID=%d; effective UID=%d\n",
(int)getuid(), (int)geteuid());
execl("/bin/sh", "sh", 0);
}
% ls -l a.out
-rwsr-xr-x 1 adev 210 19905 Apr 10 23:10 a.out*
% a.out
Before setuid(getuid())
Real UID=7943; effective UID=210
After setuid(getuid())
Real UID=7943; effective UID=7943
% uids
Real: user 7943 (ins_akaa), group 2048
Effective: user 210 (adev), group 2048
% %
--------------------------------------------------------------
Note that setuid(getuid()) seems to work, but the effective uid somehow gets
set back when I do the execl().
--
EARTH | --Kenneth Arromdee
smog | bricks | UUCP: ....!jhunix!ins_akaa
AIR mud FIRE| INTERNET: arromdee at crabcake.cs.jhu.edu
soda water | tequila | BITNET: g49i0188 at jhuvm
WATER |(please, no mail to arrom at aplcen)
Element chart from "Science Made Stupid". (The chart seems rather popular...)
More information about the Comp.unix.questions
mailing list