pySerial in a daemon process

paul paul.faulstich at gmail.com
Mon Aug 27 00:08:18 CEST 2007


On Aug 26, 5:20 pm, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n... at spamgourmet.com> wrote:
> paul wrote:
> > If I put these back in and try to run the daemon, the script fails
> > when I try to connect to the serial port, with this error:
> > serial.serialutil.SerialException: Could not open port: [Errno 13]
> > Permission denied: '/dev/ttyS0'
>
> Did you check the permissions on this file? Often you have to be
> member of a "dialout" group or similar to get access.
>
> Regards,
>
> Björn
>
> --
> BOFH excuse #172:
>
> pseudo-user on a pseudo-terminal


THANKS! That did it, but perhaps can you explain to me why...

Before I had posted this question first thing I did was to look at /
dev/ttyS0, and indeed the group is dialout (gid=20), so I tried a
couple of things:

1. checked my id to see if I was a member of dialout, and indeed I
am.  So, I edited the daemon script to use my id and set the gid to
dialout (ie: os.setegid(20) & os.seteuid(1000)) and it still failed.

2. made the id I really want to use (pydaemon, uid=110) a member of
dialout, and set the daemon script to use those (ie: os.setegid(20) &
os.seteuid(110)) and it still failed...

After reading your comment, I went and did a chgrp to set the various
script file groups to dialout, and indeed it now works.  What confuses
me is that if the script needed that group, why doesn't the setegid or
seteuid fail?  Why does the script keep running okay until the
connect, and fail then?

Thanks!

Paul




More information about the Python-list mailing list