IOError - cannot create file (linux daemon-invoked script)
cassiope
fpm at u.washington.edu
Sun Jan 3 16:54:16 EST 2010
On Jan 2, 3:46 pm, Steve Holden <st... at holdenweb.com> wrote:
> cassiope wrote:
> > I have a daemon on a Linux system that supports a number of Windows
> > clients. Among the functions is to send e-mails, which is
> > sufficiently complicated that I fork() a separate process which gets
> > setuid to a lesser user, and calls a python script which does the
> > actual formatting and emailing (the daemon is written in C). I want
> > to save a copy of the email in a particular directory which is
> > accessible to the Windows clients via samba.
>
> > 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.
>
> Have you looked at the IOError's errno attribute to find out exactly why
> the Python subprocess is unable to write to the directory?
It's errno=13 ... "permission denied".
> > Is there anything that I can do to diagnose why this script is
> > failing? For various reasons I don't want to make the directory world-
> > writable.
>
> I'd concur on that decision.
>
> > This is on a Debian "squeeze" system, with python 2.5.
>
> > Thanks for any insights!
>
> Take a closer look at the exception, that might stimulate a thought or two.
>
> regards
> Steve
> --
> Steve Holden +1 571 484 6266 +1 800 494 3119
> PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
> Holden Web LLC http://www.holdenweb.com/
> UPCOMING EVENTS: http://holdenweb.eventbrite.com/
More information about the Python-list
mailing list