[OT] change user when executing some script



Hi,

it is not the first time that i am facing this kind of problem, but I
never find out .....

I decided to ask for some help.

Let's have 3 users: user1, user2 and user3
let's have a user1 script: /home/user1/script.sh

Script is:

#!/bin/bash
if [ -f '/home/user1/testfile' ]
then rm /home/user1/testfile
else touch /home/user1/testfile
fi


Both user2 and user3 can execute it. What I want is user3 be able to
delete the file that was created before by user2 during a previous
run. But I fail to find a solution. Even if user1 set the
setuid/setgid flag on the script file, the file /home/user1/testfile
belongs to user2 and user3 won't be able to delete the file.

How can I make the /home/user1/testfile belong to user1, the owner of
the script instead of the user that launches it ?

Many thanks for your help,

NB: I run on SunOS 5.10 Generic_118833-36 sun4u sparc SUNW,Sun-Fire.

Gal'


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: Unrestrict chown?
    ... allowing user1 to chown his files to user2, ... It would be a DoS against user2 if disk quotas are used. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Sound on Linux?
    ... the (non-root) user that I created during install ... belongs to all those groups, but a user that I created subsequently ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Unrestrict chown?
    ... allowing user1 to chown his files to user2, ... It would be a DoS against user2 if disk quotas are used. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Unrestrict chown?
    ... allowing user1 to chown his files to user2, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Sound on Linux?
    ... the (non-root) user that I created during install ... belongs to all those groups, but a user that I created subsequently ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)