]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/pwd2spwd.c: Set no aging information
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 15 Dec 2025 09:45:41 +0000 (10:45 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 15 Dec 2025 10:38:34 +0000 (11:38 +0100)
The pwd_to_spwd routine claims that fields without corresponding
information in the password file are set to uninitialized values,
but sets some aging information. These cannot be available in
struct passwd.

Also, the code is only used in passwd to temporarily hold the
new password. All other values are copied from an existing entry
later on. If no entry exists, all values are dismissed anyway.

Clarify that everything is uninitialized except name and password.
Gets rid of magic value 10000 for sp_max.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
lib/pwd2spwd.c

index fceb4d86b783ce4b5450166feb829b8e210f3eba..ea1bf064b28500e94e5a8ff2ef8cae6f199fdc0e 100644 (file)
@@ -12,7 +12,6 @@
 #ident "$Id$"
 
 #include <sys/types.h>
-#include "prototypes.h"
 #include "defines.h"
 #include <pwd.h>
 
@@ -34,22 +33,13 @@ struct spwd *pwd_to_spwd (const struct passwd *pw)
        sp.sp_namp = pw->pw_name;
        sp.sp_pwdp = pw->pw_passwd;
 
-       /*
-        * Defaults used if there is no pw_age information.
-        */
-       sp.sp_min = 0;
-       sp.sp_max = 10000;
-       sp.sp_lstchg = gettime () / DAY;
-       if (0 == sp.sp_lstchg) {
-               /* Better disable aging than requiring a password
-                * change */
-               sp.sp_lstchg = -1;
-       }
-
        /*
         * These fields have no corresponding information in the password
         * file.  They are set to uninitialized values.
         */
+       sp.sp_lstchg = -1;
+       sp.sp_min = 0;
+       sp.sp_max = -1;
        sp.sp_warn = -1;
        sp.sp_expire = -1;
        sp.sp_inact = -1;