[Tutor] uid

Rick Pasotto rick@niof.net
Sat, 15 Sep 2001 10:58:41 -0400


On Sat, Sep 15, 2001 at 02:09:15PM +0200, Joerg Woelke wrote:
> On Sat, Sep 15, 2001 at 12:17:56PM +0200, Hans Gubitz wrote:
> > I want to cp a file and extract it to different users. I can do this
> > as root, but I want extract  to be done with the uid of the user.
> > 
> > import os, pwd
> > users = ['usera','userb']
> > 
> > def copy(user):
> >         list = pwd.getpwnam(user)
> >         #uid = list[2]
> >         home = list[5]
> >         os.chdir(home)
> >         os.system('cp /tmp/file.tgz .')
> >         os.system('tar -xzf file.tgz')
> > 
> > for u in info_1:
> >         copy(u)
> >         
> > ??????        
> 
> os.suid()

Did you *try* that? It doesn't exist on my system.

'suid' -- meaning 'set user id' -- is not at all what he wants.

He simply needs to set the owner of the file so

os.chown(user) 

will do what he wants.

-- 
If man were perfect, if he were infallible, society would present
a very different kind of harmony from that which we may actually
expect it to offer us. Our idea of harmony is not Fourier's. It
does not exclude the existence of evil; it leaves room for
discord; and yet we shall recognize that harmony nonetheless
exists, provided that discord serves to prepare the way and to
lead us back to harmony.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net