diff options
Diffstat (limited to 'Modules/spwdmodule.c')
-rw-r--r-- | Modules/spwdmodule.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c index 194ae196ba..68ea1b5ea4 100644 --- a/Modules/spwdmodule.c +++ b/Modules/spwdmodule.c @@ -26,22 +26,24 @@ You have to be root to be able to use this module."); #if defined(HAVE_GETSPNAM) || defined(HAVE_GETSPENT) static PyStructSequence_Field struct_spwd_type_fields[] = { - {"sp_nam", "login name"}, - {"sp_pwd", "encrypted password"}, + {"sp_namp", "login name"}, + {"sp_pwdp", "encrypted password"}, {"sp_lstchg", "date of last change"}, {"sp_min", "min #days between changes"}, {"sp_max", "max #days between changes"}, {"sp_warn", "#days before pw expires to warn user about it"}, - {"sp_inact", "#days after pw expires until account is blocked"}, - {"sp_expire", "#days since 1970-01-01 until account is disabled"}, + {"sp_inact", "#days after pw expires until account is disabled"}, + {"sp_expire", "#days since 1970-01-01 when account expires"}, {"sp_flag", "reserved"}, + {"sp_nam", "login name; deprecated"}, /* Backward compatibility */ + {"sp_pwd", "encrypted password; deprecated"}, /* Backward compatibility */ {0} }; PyDoc_STRVAR(struct_spwd__doc__, "spwd.struct_spwd: Results from getsp*() routines.\n\n\ This object may be accessed either as a 9-tuple of\n\ - (sp_nam,sp_pwd,sp_lstchg,sp_min,sp_max,sp_warn,sp_inact,sp_expire,sp_flag)\n\ + (sp_namp,sp_pwdp,sp_lstchg,sp_min,sp_max,sp_warn,sp_inact,sp_expire,sp_flag)\n\ or via the object attributes as named in the above tuple."); static PyStructSequence_Desc struct_spwd_type_desc = { @@ -86,6 +88,8 @@ static PyObject *mkspent(struct spwd *p) SETI(setIndex++, p->sp_inact); SETI(setIndex++, p->sp_expire); SETI(setIndex++, p->sp_flag); + SETS(setIndex++, p->sp_namp); /* Backward compatibility for sp_nam */ + SETS(setIndex++, p->sp_pwdp); /* Backward compatibility for sp_pwd */ #undef SETS #undef SETI @@ -196,9 +200,11 @@ PyInit_spwd(void) m=PyModule_Create(&spwdmodule); if (m == NULL) return NULL; - if (!initialized) - PyStructSequence_InitType(&StructSpwdType, - &struct_spwd_type_desc); + if (!initialized) { + if (PyStructSequence_InitType2(&StructSpwdType, + &struct_spwd_type_desc) < 0) + return NULL; + } Py_INCREF((PyObject *) &StructSpwdType); PyModule_AddObject(m, "struct_spwd", (PyObject *) &StructSpwdType); initialized = 1; |