]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
newusers: Allow creation without aging information
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 15 Dec 2025 09:22:17 +0000 (10:22 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 15 Dec 2025 13:51:28 +0000 (14:51 +0100)
If PASS_MAX_DAYS is not set, newusers falls back to 10000 days, which is
considered "unlimited" in some parts of the source tree. All other tools
fall back to -1, which truely implies unlimited.

Sync newusers with all other shadow tools.

How to reproduce:

1. Remove or comment out PASS_MAX_DAYS from /etc/login.defs
2. Run `newusers <<< user:pass:1234:1234::/home/user:/bin/bash`
3. Check user line in /etc/shadow
```
/etc/shadow:user:HASH:19721:0:10000:7:::
```

Max days are set to 10000. Instead, this should be:

```
/etc/shadow:user:HASH:19721:0::7:::
```

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/newusers.c

index 2e69f2c99fa29a93504bdf46833a6cd889a88a74..ab16a219c6dd83b96a64a2559722446b7a0ed153 100644 (file)
@@ -616,8 +616,7 @@ add_passwd(struct passwd *pwd, MAYBE_UNUSED const char *password)
                spent.sp_lstchg = -1;
        }
        spent.sp_min    = getdef_num ("PASS_MIN_DAYS", 0);
-       /* 10000 is infinity this week */
-       spent.sp_max    = getdef_num ("PASS_MAX_DAYS", 10000);
+       spent.sp_max    = getdef_num ("PASS_MAX_DAYS", -1);
        spent.sp_warn   = getdef_num ("PASS_WARN_AGE", -1);
        spent.sp_inact  = -1;
        spent.sp_expire = -1;