This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ned.deily
Recipients Tjeerd.Pinkert, ned.deily
Date 2010-10-06.01:42:00
SpamBayes Score 6.4601375e-07
Marked as misclassified No
Message-id <1286329325.57.0.197855182424.issue10032@psf.upfronthosting.co.za>
In-reply-to
Content
While you did not specify what platform you are running this on, the issue here is almost certainly a misunderstanding of how permissions work.  On UNIX-y systems, access to device files is normally governed by permissions like any other file or directory.  On many systems, groups are set up to allow users to access devices without requiring root permission.  User "tjp" is very likely a member of a supplementary group that has group permission to the device in question.  When run under sudo, the program initially can access the device because of the superuser (root) permission.  After it is daemonizied, though, it no longer has root but it does not have the supplementary group permissions it would have had running normally; it only has uid 1000 and gid 1000.

The following example illustrates:

# in this example, /dev/mixer has a gid of 29 (group=audio)
# and the user (uid=501,gid=501) is a member of group 29
$ id -u
501
$ id -g
501
$ id -G
501 6 22 24 25 27 29 44 46 107 112 114 1001 40100 40200
$ ls -ln /dev/mixer
crw-rw---- 1 0 29 14, 0 Oct  5 14:06 /dev/mixer
$ python -c "open('/dev/mixer','r')"
$ sudo python -c "open('/dev/mixer','r')
$ sudo python -c "import os; os.setgid(501); os.setuid(501); open('/dev/mixer','r')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
IOError: [Errno 13] Permission denied: '/dev/mixer'
$ python -c "import os; print(os.getgroups())"
[6, 22, 24, 25, 27, 29, 44, 46, 107, 112, 114, 501, 1001, 40100, 40200]
$ sudo python -c "import os; print(os.getgroups())"
[0]

If this does not explain the results you are seeing, please re-open with additional supporting information.
History
Date User Action Args
2010-10-06 01:42:07ned.deilysetrecipients: + ned.deily, Tjeerd.Pinkert
2010-10-06 01:42:05ned.deilysetmessageid: <1286329325.57.0.197855182424.issue10032@psf.upfronthosting.co.za>
2010-10-06 01:42:04ned.deilylinkissue10032 messages
2010-10-06 01:42:02ned.deilycreate