[comp.lang.perl] Problems with setuid emulation on System V

ade@clark.edu (Adrian Miranda) (11/18/90)

Hello,
  I seem to be having some problems with the setuid/setgid emulation 
in Perl.  This is a System Vr3.2 machine, ESIX to be exact.  I apologize
if this is a known problem, but it appears this should work.  So what
have I done wrong?

Anyway, when I compiled Perl (with gcc) I told it I wanted
setuid/setgid emulation.  The resulting binary passes "make test"
without problem.

Here is the test program:

#!/usr/lbin/perl -S  

eval "exec /usr/lbin/perl -S $0 $*"
    if $running_under_some_shell;

print $<, " ", $>, " ", $(, " ", $), "\n";


If this program doesn't have any setuid or setgid bits set, it
produces the following output:

109 109 1 1

If I make it set group id mail, like so:
-rwxr-sr-x   1 ade      mail         148 Nov 17 16:47 set.prl

I get the following results:

65535 6 1 1

Which appears to be way off.  It appears the true uid has become 
65535 and the effective uid has become that of the group id of mail.
The group ids themselves seem to be unaffected.

If I make it setuid to brad (whose uid is 158), like so:
-rwsr-xr-x   1 brad     assist       148 Nov 17 16:47 set.prl

I get the following output:
65535 158 1 1

Which isn't completely unreasonable, though I think the the true uid
should stay 109 (mine).

Any help you can give will be appreciated.  Email preferred.
Adrian Miranda
uunet!clark!ade  or  ade@clark.edu