I am using a python script to create a copy of the Linux file system. I am having problems with permissions on the created / tmp directory. There must be 1777 permissions in the / tmp directory, i.e.:
ls -l /
drwxrwxrwt 17 root root 16384 2011-03-01 09:50 tmp
when i do the following
os.mkdir('/mnt/tmp',1777)
I get weird permissions:
ls -l /
d-wxr----t 2 root root 4096 2011-03-01 09:53 tmp
Then I wondered about umask and chmod, so I tried this:
os.mkdir('/mnt/tmp')
old_mask=os.umask(0000)
os.chmod('/mnt/tmp',1777)
os.umask(old_mask)
but I still get unexpected permissions:
ls -l /
d-wxrwS--t 2 root root 4096 2011-03-01 09:57 tmp
However, what gives me the correct permissions of the created directory is the following:
os.mkdir('/mnt/tmp')
os.system("chmod 1777 /mnt/tmp")
I should note that I run this script through sudo, but there are no umask settings in / etc / sudoers. Doing it as the actual root user does not make any difference. It is not possible to run it as a regular user, since I am making a copy of FS, which should include files that are accessible only to root.
? .