IOError - cannot create file (linux daemon-invoked script)

cassiope fpm at u.washington.edu
Sun Jan 3 22:56:24 CET 2010


On Jan 2, 6:40 pm, Christian Heimes <li... at cheimes.de> wrote:
> cassiope wrote:
> > The strange thing is that even with the right user-id, I cannot seem
> > to write to the directory, getting an IOError exception.  Changing the
> > directory to world-writable fixes this.  I can confirm the uid and gid
> > for the script by having the script print these values just before
> > trying to create/write the file.  Becoming the same lesser user, I
> > have no problem writing a file to the same directory.
>
> Are you able to write to the directory with the user id when you tried
> to create a file manually?

Yes.  Sorry that wasn't clear.

> How are you changing the uid and gid of your script? IIRC you have to
> set the effective user id with os.seteuid() and os.setegid().

I'm changing the uid and gid in the daemon (which runs with root
permissions
until the fork and uid/gid change).  The uid and gid are confirmed by
printing os.getuid() and os.getgid() in the script.

> Christian




More information about the Python-list mailing list