We have some students using java serllets, and when things go wrong
one of the effective ways to solve the problem is to remove the
files that the server creates in their work directories, which it
creates and owns. The students are not the same uid as the server, so
clearly a setuid program is needed to do this. Fine. So I have a C
wrapper which is setuid for the server and does checks on getlogin
to check who is using it, and it calls a ruby program which clears
the files out.
After a bunch of sanity checks on the username the program does this:
Here = “/home/#{user}/work”
···
puts "uid is #{Process.uid}"
puts "gid is #{Process.gid}"
puts "euid is #{Process.euid}"
puts “egid is #{Process.egid}”
/bin/rm -rf #{Here}/*
Now, uid and gid correspond to the user, and euid and egid
correspond to the server. This doesn’t work, but if I insert
Process.uid=Process.euid
Process.gid=Process.egid
at the line marked with ###### then the uid == euid, gid == egid, and
these correspond to the sever, and all is well.
So why is the effective uid ineffective? is it soem safety feature
of rm? The manual page doesn’t mention this. I thought I
understood setuid, but clearly not to enough depth. Anyone got any
good pointers on this? Maybe I should be doing this differently?
Attempts to do this with the shell failed too.
Thank you,
Hugh