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 vajrasky
Recipients vajrasky
Date 2013-08-20.04:12:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376971981.98.0.467831293927.issue18787@psf.upfronthosting.co.za>
In-reply-to
Content
As root:

$ sudo python3
[sudo] password for ethan: 
Python 3.2.3 (default, Apr 10 2013, 05:07:54) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import spwd
>>> spwd.getspnam("I_don't_exist")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'getspnam(): name not found'
>>> spwd.getspnam("bin")
spwd.struct_spwd(sp_nam='bin', sp_pwd='*', sp_lstchg=15259, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1)

As normal user:

$ python3
Python 3.2.3 (default, Apr 10 2013, 05:07:54) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import spwd
>>> spwd.getspnam("I_don't_exist")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'getspnam(): name not found'
>>> spwd.getspnam("bin")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'getspnam(): name not found'

People can be confused. How could the name not found if the name actually exists?

Attached the patch to differentiate the error whether the error is really 'name not found' or 'permission denied'.

I use the error message from the getspnam manual:
http://man7.org/linux/man-pages/man3/getspnam.3.html

There is another error message from getspnam beside EACCES (permission denied), which is ERANGE, but I don't think we need to handle this.
History
Date User Action Args
2013-08-20 04:13:02vajraskysetrecipients: + vajrasky
2013-08-20 04:13:01vajraskysetmessageid: <1376971981.98.0.467831293927.issue18787@psf.upfronthosting.co.za>
2013-08-20 04:13:01vajraskylinkissue18787 messages
2013-08-20 04:13:00vajraskycreate