Python CGI & File Permissions
Jason Orendorff
jason at jorendorff.com
Wed Dec 19 17:42:58 EST 2001
> I had a similar problem when trying to create a directory with
> os.mkdir(path, mode). Even though I passed 0777 as mode, it only
> created it as -rwxrw-rw-. The documentation says that should work,
> but it didn't for me (Python 1.5.2 and 2.1)
This is probably your umask at work. This is a Unix feature,
not a Python bug. "umask" prevents you from creating files with
certain dangerous permissions. You can set it in Python:
os.umask().
Anyway, creating directories with 777 permissions is bad!
Instead, run your CGI script as the appropriate user.
http://httpd.apache.org/docs/suexec.html
bwaskiew at indiana.edu (Brian Waskiewicz) wrote:
> > I'm trying to use a Python CGI script to write a text file on a
> > Unix/Apache webserver. The problem is that the file created is owned
> > by 'nobody' and has permissions '-rw-r--r--'. I need to read and
> > append to the file in other scripts, so I need some way of changing
> > the file permissions. I tried os.chmod() and that didn't work.
See above.
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list
mailing list