Message194618
Both python2 and python3 have this behaviour.
>>> import os; os.getuid()
0
>>> 'I am root'
'I am root'
>>> import spwd
>>> spwd.getspnam('bin')
spwd.struct_spwd(sp_nam='bin', sp_pwd='*', sp_lstchg=15558, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1)
>>> spwd.getspnam.__doc__
'getspnam(name) -> (sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max,\n sp_warn, sp_inact, sp_expire, sp_flag)\nReturn the shadow password database entry for the given user name.\nSee spwd.__doc__ for more on shadow password database entries.'
The documentation tells the function getspnam will give struct which has member sp_namp and sp_pwdp. But as you can see, the function getspnam gives me a tuple with has member sp_nam (without p) and sp_pwd (without p).
If you "man spwd", you can see the documentation is correct:
Structure
The shadow password structure is defined in <shadow.h> as follows:
struct spwd {
char *sp_namp; /* Login name */
char *sp_pwdp; /* Encrypted password */
long sp_lstchg; /* Date of last change (measured
in days since 1970-01-01 00:00:00 +0000 (UTC)) */
long sp_min; /* Min # of days between changes */
long sp_max; /* Max # of days between changes */
long sp_warn; /* # of days before password expires
to warn user to change it */
long sp_inact; /* # of days after password expires
until account is disabled */
long sp_expire; /* Date when account expires (measured
in days since 1970-01-01 00:00:00 +0000 (UTC)) */
unsigned long sp_flag; /* Reserved */
};
For curious souls who do not have unix box:
http://linux.die.net/man/3/getspnam
I have contemplated about whether this behaviour is intended as it is, but I guess this is just a bug. Typo.
Attached the patch to fix this inconsistency. I also fixed some documentation about sp_inact and sp_expire.
I only marked this as Python 3.4 fix because I am not sure whether we should backport it to previous python versions. Some programs that expect sp_nam and sp_pwd names could break. |
|
Date |
User |
Action |
Args |
2013-08-07 14:50:00 | vajrasky | set | recipients:
+ vajrasky |
2013-08-07 14:50:00 | vajrasky | set | messageid: <1375887000.77.0.620898445025.issue18678@psf.upfronthosting.co.za> |
2013-08-07 14:50:00 | vajrasky | link | issue18678 messages |
2013-08-07 14:50:00 | vajrasky | create | |
|