]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
6 weeks agoRevert "tests/: implement binding for `getent shadow $name`" revert-1237-test-useradd
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: implement binding for `getent shadow $name`"

This reverts commit fe33ae50f7777d9477184ee3f03ba1a35308b482.

6 weeks agoRevert "tests/: implement binding for `getent gshadow $name`"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: implement binding for `getent gshadow $name`"

This reverts commit d17e1133ee832129c54d1defaa8afc0580508ef8.

6 weeks agoRevert "tests/: implement feature detection"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: implement feature detection"

This reverts commit 8e02cff47522d046030df8c9d50be9129b50a2bd.

6 weeks agoRevert "tests/: implement `days_since_epoch()`"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: implement `days_since_epoch()`"

This reverts commit b56fdc329f3deb26a04e54b9e4729fa8116b6bfc.

6 weeks agoRevert "tests/: enable `FORCE_SHADOW` in configuration"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: enable `FORCE_SHADOW` in configuration"

This reverts commit c30e357caed9aee8854aa1c6dc7c8d0b63cdf371.

6 weeks agoRevert "tests/: improve distribution detection"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: improve distribution detection"

This reverts commit 091c91fb11e04dd710eb81130690c9486d169204.

6 weeks agoRevert "tests/: improve version detection"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: improve version detection"

This reverts commit df8c9743154589a22d95d0929cbe422565eb8459.

6 weeks agoRevert "tests/: extend basic useradd test"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: extend basic useradd test"

This reverts commit d4f5397d2ce5a79fbe126abf8c025a2b369aa78b.

6 weeks agoRevert "tests/: extend basic usermod test"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: extend basic usermod test"

This reverts commit 1791d8a638fbd4d9a4fc6dc6043c764c6f997f82.

6 weeks agoRevert "tests/: extend basic userdel test"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: extend basic userdel test"

This reverts commit 174103cb9497d6a2e3808ab0955c6f1dbf5599d6.

6 weeks agoRevert "tests/: extend basic groupadd test"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: extend basic groupadd test"

This reverts commit 72c42f662716b070629537410b68a35af3f7df92.

6 weeks agoRevert "tests/: extend basic groupmod test"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: extend basic groupmod test"

This reverts commit a7aa59075b49a29e5e6b14c232f8fac2a9cfe448.

6 weeks agoRevert "tests/: extend basic groupdel tests"
Serge Hallyn [Thu, 22 May 2025 11:27:11 +0000 (06:27 -0500)] 
Revert "tests/: extend basic groupdel tests"

This reverts commit 7924fdb94bb8d34cf9480914d77c4a514c643c59.

6 weeks agotests/: extend basic groupdel tests
Iker Pedrosa [Wed, 12 Mar 2025 08:19:44 +0000 (09:19 +0100)] 
tests/: extend basic groupdel tests

Add additional check for gshadow entry.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: extend basic groupmod test
Iker Pedrosa [Wed, 12 Mar 2025 08:18:57 +0000 (09:18 +0100)] 
tests/: extend basic groupmod test

Add additional check for gshadow entry.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: extend basic groupadd test
Iker Pedrosa [Wed, 12 Mar 2025 08:16:36 +0000 (09:16 +0100)] 
tests/: extend basic groupadd test

Add additional check for gshadow entry.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: extend basic userdel test
Iker Pedrosa [Wed, 12 Mar 2025 08:10:25 +0000 (09:10 +0100)] 
tests/: extend basic userdel test

Add additional checks for shadow and gshadow entries.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: extend basic usermod test
Iker Pedrosa [Wed, 12 Mar 2025 08:09:28 +0000 (09:09 +0100)] 
tests/: extend basic usermod test

Add additional checks for shadow and gshadow entries.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: extend basic useradd test
Iker Pedrosa [Mon, 10 Mar 2025 08:50:56 +0000 (09:50 +0100)] 
tests/: extend basic useradd test

The test framework PoC only provided basic checks. I've added additional
functionality to the framework by checking shadow and gshadow entries
and I've extended the basic useradd test to check those too.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: improve version detection
Iker Pedrosa [Tue, 1 Apr 2025 07:35:46 +0000 (09:35 +0200)] 
tests/: improve version detection

Alpine Linux versions also contain the revision, and this needs to be
taken into account when detecting it.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: improve distribution detection
Iker Pedrosa [Wed, 12 Mar 2025 13:59:38 +0000 (14:59 +0100)] 
tests/: improve distribution detection

openSUSE includes comment lines in `/etc/os-release` file and this can
cause some issues during the distribution detection. Ignore those lines
as they don't cause any effect on the system.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: enable `FORCE_SHADOW` in configuration
Iker Pedrosa [Wed, 12 Mar 2025 12:03:01 +0000 (13:03 +0100)] 
tests/: enable `FORCE_SHADOW` in configuration

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: implement `days_since_epoch()`
Iker Pedrosa [Mon, 10 Mar 2025 08:48:26 +0000 (09:48 +0100)] 
tests/: implement `days_since_epoch()`

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: implement feature detection
Iker Pedrosa [Mon, 31 Mar 2025 15:49:22 +0000 (17:49 +0200)] 
tests/: implement feature detection

Implement a general function to detect features in shadow host.

Apparently, musl doesn't provide `getent gshadow`, but shadow still needs
it to check for several group attributes. Thus, check whether it exists
in the host, and if it does run it. If not, let's just skip that part of
the test.

Link: <https://gitlab.alpinelinux.org/alpine/aports/-/issues/16979>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: implement binding for `getent gshadow $name`
Iker Pedrosa [Wed, 5 Mar 2025 17:05:59 +0000 (18:05 +0100)] 
tests/: implement binding for `getent gshadow $name`

Provide a way for the system framework to run `getent gshadow $name` and
check its output in a meaningful way.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
6 weeks agotests/: implement binding for `getent shadow $name`
Iker Pedrosa [Mon, 3 Mar 2025 08:29:57 +0000 (09:29 +0100)] 
tests/: implement binding for `getent shadow $name`

Provide a way for the system framework to run `getent shadow $name` and
check its output in a meaningful way.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agonewgidmap: better error logging on failure
Matthew Hughes [Fri, 2 May 2025 10:44:27 +0000 (11:44 +0100)] 
newgidmap: better error logging on failure

Much like the previous commit, similarly relies on `sub_gid_open`
preserving `errno`.

2 months agonewuidmap: better error logging on failure
Matthew Hughes [Tue, 29 Apr 2025 16:56:59 +0000 (17:56 +0100)] 
newuidmap: better error logging on failure

The handling for `sub_uid_open` relies on `commonio_open` preserving
`errno`, which it appears to make an effort do, but doesn't explicitly
document.

Closes: https://github.com/shadow-maint/shadow/issues/1253
2 months agolib/strtoday.c: strtoday(): Replace obsolete comment
Alejandro Colomar [Tue, 18 Feb 2025 14:21:56 +0000 (15:21 +0100)] 
lib/strtoday.c: strtoday(): Replace obsolete comment

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoman/: Localized dates are not accepted anymore
Alejandro Colomar [Wed, 19 Feb 2025 17:46:54 +0000 (18:46 +0100)] 
man/: Localized dates are not accepted anymore

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoman/: Consistently express dates in standard format
Alejandro Colomar [Wed, 19 Feb 2025 17:46:18 +0000 (18:46 +0100)] 
man/: Consistently express dates in standard format

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/getdate.y: Don't parse a raw number; just a calendar date
Alejandro Colomar [Tue, 18 Feb 2025 14:29:54 +0000 (15:29 +0100)] 
lib/getdate.y: Don't parse a raw number; just a calendar date

Our caller, strtoday(), already handles a raw number.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/getdate.y: Don't parse dates in local formats; just YYYY-MM-DD
Alejandro Colomar [Tue, 18 Feb 2025 11:34:58 +0000 (12:34 +0100)] 
lib/getdate.y: Don't parse dates in local formats; just YYYY-MM-DD

2 months agolib/getdate.y: Remove unnecessary variable
Alejandro Colomar [Tue, 18 Feb 2025 12:13:09 +0000 (13:13 +0100)] 
lib/getdate.y: Remove unnecessary variable

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/getdate.y: Don't parse week days
Alejandro Colomar [Tue, 18 Feb 2025 11:28:44 +0000 (12:28 +0100)] 
lib/getdate.y: Don't parse week days

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/getdate.y: Don't parse relative dates, such as 'yesterday'
Alejandro Colomar [Tue, 18 Feb 2025 11:16:48 +0000 (12:16 +0100)] 
lib/getdate.y: Don't parse relative dates, such as 'yesterday'

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/getdate.y: Don't parse times; just dates
Alejandro Colomar [Tue, 18 Feb 2025 10:54:49 +0000 (11:54 +0100)] 
lib/getdate.y: Don't parse times; just dates

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoman/useradd.8.xml: fix the CREATE_HOME description
Serge Hallyn [Thu, 24 Apr 2025 00:28:48 +0000 (19:28 -0500)] 
man/useradd.8.xml: fix the CREATE_HOME description

Fixes: #1249
Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 months agoci: add `gawk` as a fedora dependency
Iker Pedrosa [Fri, 25 Apr 2025 07:15:40 +0000 (09:15 +0200)] 
ci: add `gawk` as a fedora dependency

Recently fedora 42 was released and `gawk` was missing as a dependency.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 months agoAdd LOGIN_ENV_SAFELIST to FOREIGNDEFS
Stanislav Brabec [Wed, 9 Apr 2025 00:03:10 +0000 (02:03 +0200)] 
Add LOGIN_ENV_SAFELIST to FOREIGNDEFS

util-linux-2.41 introduced new variable: LOGIN_ENV_SAFELIST.
Add it to known login.defs variables.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
3 months agoAccept /usr/sbin/nologin as an alternate to /sbin/nologin
Chris Hofstaedtler [Fri, 28 Mar 2025 11:12:13 +0000 (12:12 +0100)] 
Accept /usr/sbin/nologin as an alternate to /sbin/nologin

Relevant on fully-usr-merged distributions.

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Reported-by: Marc Haber
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agoQuick fix: define E_PAM_ERR in lib/pam_pass.c
Serge Hallyn [Wed, 26 Mar 2025 13:23:52 +0000 (08:23 -0500)] 
Quick fix: define E_PAM_ERR in lib/pam_pass.c

The exit code situation is a hot mess. Do a
  git grep "define.*E_SUCCESS"
Each src/*.c is defining its own set of error codes, and
they are frequently conflicting, e.g. more than one use
10.

We should probably have a common set defined in lib/exitcodes.h.
I'm thinking for a first cut, we just move all the definitions
from src/*.c to lib/exitcodes.h, and let the conflicts stand.
If we later want to change some defines to make them unambiguous
across the project, we can do that separately.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 months agopwconv.8 man page improvements
Markus Hiereth [Wed, 8 Jan 2025 21:46:46 +0000 (22:46 +0100)] 
pwconv.8 man page improvements

Bug-Debian: https://bugs.debian.org/1004418

3 months agochfn.1 man page improvements
Markus Hiereth [Wed, 8 Jan 2025 21:45:54 +0000 (22:45 +0100)] 
chfn.1 man page improvements

Bug-Debian: https://bugs.debian.org/1004688

3 months agopasswd: document exit code when PAM has errored
Serge Hallyn [Sat, 22 Mar 2025 12:54:27 +0000 (07:54 -0500)] 
passwd: document exit code when PAM has errored

closes #1219

When pam returns an error, we were exiting with exit code 10,
which was hardcoded and not documented.  Create a name for it,
and document it in the manpage.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Reported-by: Marc Haber <githubvisible@zugschlus.de>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agoCI: purge man-db
Iker Pedrosa [Thu, 20 Mar 2025 09:27:29 +0000 (10:27 +0100)] 
CI: purge man-db

This accelerates the CI.

Closes: https://github.com/shadow-maint/shadow/issues/1240
Link: <https://101010.pl/@nabijaczleweli/114149412203886808>
Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agorelease 4.17.4 4.17.4
Serge Hallyn [Wed, 19 Mar 2025 18:58:04 +0000 (13:58 -0500)] 
release 4.17.4

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 months agotests/unit/test_xasprintf.c: Fix sign-mismatch diagnostic
Alejandro Colomar [Sun, 9 Feb 2025 13:10:55 +0000 (14:10 +0100)] 
tests/unit/test_xasprintf.c: Fix sign-mismatch diagnostic

Add a signed wrapper around mock() which returns a signed integer.
This makes it possible to compare the return value with literal -1.

Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/lastlog.c: Use ssizeof() to avoid a -Wsign-compare diagnostic
Alejandro Colomar [Sun, 9 Feb 2025 11:45:11 +0000 (12:45 +0100)] 
src/lastlog.c: Use ssizeof() to avoid a -Wsign-compare diagnostic

Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/sizeof.h: ssizeof(): Add signed variant of sizeof
Alejandro Colomar [Sun, 9 Feb 2025 11:44:34 +0000 (12:44 +0100)] 
lib/sizeof.h: ssizeof(): Add signed variant of sizeof

Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoautogen.sh: Promote -Wsign-compare to an error
Alejandro Colomar [Sun, 9 Feb 2025 11:37:02 +0000 (12:37 +0100)] 
autogen.sh: Promote -Wsign-compare to an error

It is usually a sign of deep errors.  We really want to avoid them.

Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/fs/readlink/: readlinknul(): Use ssize_t to simplify
Alejandro Colomar [Sun, 9 Feb 2025 11:23:46 +0000 (12:23 +0100)] 
lib/fs/readlink/: readlinknul(): Use ssize_t to simplify

Consistently using a signed type allows us to avoid sign-mismatch
diagnostics, while keeping the code simple.  It feels weird to
accept a ssize_t instead of a size_t, but it's a matter of getting
used to it.

Another way to achieve this with a single 'len' variable and no casts
would be to compare against SIZE_MAX, but that's less readable than -1.
Or one could write a SIZE_C() macro a la UINT64_C(), and compare the
size_t against SIZE_C(-1), but that's still suboptimal (regarding
readability) compared to consistently using signed size types.

Fixes: b9d00b64a19f (2024-12-09; "lib/fs/readlink/readlinknul.h: readlinknul(): Silence warning")
Acked-by: Serge Hallyn <serge@hallyn.com>
Cc: Martin Uecker <uecker@tugraz.at>
Cc: "Robert C. Seacord" <rcseacord@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agodoc/: Remove list of distributions
Michael Vetter [Mon, 10 Feb 2025 16:43:05 +0000 (17:43 +0100)] 
doc/: Remove list of distributions

Since c8e8557803f3 (2025-01-21; "ci: add openSUSE Tumbleweed") we also
run openSUSE in CI. Since the set may grow let's not list each of them
in the documentation.

4 months agolib/commonio.c: Rely on the POSIX.1-2008 behavior of realpath(3)
Alejandro Colomar [Sat, 22 Feb 2025 23:22:13 +0000 (00:22 +0100)] 
lib/commonio.c: Rely on the POSIX.1-2008 behavior of realpath(3)

Link: <https://github.com/shadow-maint/shadow/pull/1222#discussion_r1966612238>
Link: <https://stackoverflow.com/questions/60802732/are-realpath-portability-concerns-obsolete>
Reported-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/: update group audit messages
Iker Pedrosa [Fri, 24 Jan 2025 13:19:04 +0000 (14:19 +0100)] 
src/: update group audit messages

Auditing has been broken for a long time upstream and Fedora had some
downstream patches that fixed it, upstreaming that content to fix the
problem for everybody.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/: audit function for groups
Iker Pedrosa [Fri, 24 Jan 2025 13:09:02 +0000 (14:09 +0100)] 
lib/: audit function for groups

Link: https://github.com/linux-audit/audit-documentation/wiki/SPEC-User-Account-Lifecycle-Events
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/, src/: update audit messages
Iker Pedrosa [Fri, 24 Jan 2025 13:13:27 +0000 (14:13 +0100)] 
lib/, src/: update audit messages

Auditing has been broken for a long time upstream and Fedora had some
downstream patches that fixed it, upstreaming that content to fix the
problem for everybody.

The audit of a user is performed through the AUDIT_USER_* macros.
Similarly, the audit of a group is performed through the AUDIT_GRP_*
macros. Part of the audit performed for groups was incorrectly labeled
as a user, and therefore some changes needed to be made to label them
correctly.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/chfn.c: copy_field(): Rename local variable
Alejandro Colomar [Mon, 17 Feb 2025 14:33:46 +0000 (15:33 +0100)] 
src/chfn.c: copy_field(): Rename local variable

This makes it more obvious what that pointer is.

Tested-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/chfn.c: Add local variable to refer to the separated field
Alejandro Colomar [Mon, 17 Feb 2025 12:44:55 +0000 (13:44 +0100)] 
src/chfn.c: Add local variable to refer to the separated field

Tested-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/chfn.c: Use stpsep() instead of its pattern
Alejandro Colomar [Mon, 17 Feb 2025 12:40:02 +0000 (13:40 +0100)] 
src/chfn.c: Use stpsep() instead of its pattern

Tested-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/chfn.c: Partially revert "lib/, src/: Use strsep(3) instead of its pattern"
Alejandro Colomar [Mon, 17 Feb 2025 12:23:37 +0000 (13:23 +0100)] 
src/chfn.c: Partially revert "lib/, src/: Use strsep(3) instead of its pattern"

This partially reverts commit 16cb664865541162c504a6f5ef5ca4b38b5e0c9a.

I'll try to reintroduce this change more carefully.
For now, let's revert to a known-good state.

The problem was due to accidentally ignoring the effects of the 'break'
on the 'cp' variable.

Fixes: 16cb66486554 (2024-07-01; "lib/, src/: Use strsep(3) instead of its pattern")
Closes: <https://github.com/shadow-maint/shadow/issues/1210>
Link: <https://github.com/shadow-maint/shadow/pull/1213>
Link: <https://github.com/shadow-maint/shadow/pull/1212>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Suggested-by: Chris Hofstaedtler <zeha@debian.org>
Tested-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoconfigure.ac: be deterministic about passwd location
Chris Hofstaedtler [Mon, 24 Feb 2025 21:50:01 +0000 (22:50 +0100)] 
configure.ac: be deterministic about passwd location

Statically set PASSWD_PROGRAM depending on exec_prefix, and not by where
the passwd program was at configure time.

Depending on the specific build situation before, this may or may not
change the embedded passwd program path. Also configure.ac sets
exec_prefix=/ for prefix=/usr, so this might be a bit confusing, but
at least deterministic.

Closes: #1224
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
4 months agolib/getdate.y: Ignore time-zone information and use UTC
Alejandro Colomar [Mon, 17 Feb 2025 23:41:56 +0000 (00:41 +0100)] 
lib/getdate.y: Ignore time-zone information and use UTC

There is exactly one caller of this function, and it wants a date, not a
time.  It is useless to be able to parse local dates, because we
ultimately store a UTC date.  To avoid confusion, unconditionally use
UTC.  Since this code had important bugs regarding offset, we can safely
assume that no existing users rely on being able to use their local
date (this never worked correctly).

Also, the code parsing time zones is quite bad, for today's standards.

Link: <https://github.com/shadow-maint/shadow/issues/1202>
Link: <https://github.com/shadow-maint/shadow/issues/1209>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Reported-by: Tim Parenti <tim@timtimeonline.com>
Reported-by: Lee Garrett <lgarrett@rocketjump.eu>
Cc: Gus Kenion <https://github.com/kenion>
Cc: Michael Vetter <jubalh@iodoru.org>
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoconfigure.ac: stop checking for utmp location
Chris Hofstaedtler [Mon, 24 Feb 2025 22:48:28 +0000 (23:48 +0100)] 
configure.ac: stop checking for utmp location

Nothing seems to use it.

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agoRevert "lib/, src/: Use local time for human-readable dates"
Alejandro Colomar [Fri, 14 Feb 2025 20:25:01 +0000 (21:25 +0100)] 
Revert "lib/, src/: Use local time for human-readable dates"

This reverts commit 3f5b4b56268269fefed55aa106f382037297d663.

The dates are stored as UTC, and are stored as a number of days since
Epoch.  We don't have enough precision to translate it into local time.
Using local time has caused endless issues in users.

This patch is not enough for fixing this issue completely, since
printing a date without time-zone information means that the date is a
local date, but what we're printing is a UTC date.  A future patch
should add time-zone information to the date.

For now, let's revert this change that has caused so many issues.

Fixes: 3f5b4b562682 (2024-08-01; "lib/, src/: Use local time for human-readable dates")
Link: <https://github.com/ansible/ansible/blob/devel/test/integration/targets/user/tasks/test_expires.yml#L2-L20>
Link: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1095430>
Link: <https://lists.iana.org/hyperkitty/list/tz@iana.org/message/ENE5IFV3GAH6WK22UJ6YU57D6TQINSP5/>
Link: <https://github.com/shadow-maint/shadow/issues/1202>
Link: <https://github.com/shadow-maint/shadow/issues/1057>
Link: <https://github.com/shadow-maint/shadow/issues/939>
Link: <https://github.com/shadow-maint/shadow/pull/1058>
Link: <https://github.com/shadow-maint/shadow/pull/1059#issuecomment-2309888519>
Link: <https://github.com/shadow-maint/shadow/pull/952>
Link: <https://github.com/shadow-maint/shadow/pull/942>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Reported-by: Gus Kenion <https://github.com/kenion>
Reported-by: Alejandro Colomar <alx@kernel.org>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Reported-by: Lee Garrett <lgarrett@rocketjump.eu>
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Tim Parenti <tim@timtimeonline.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoRelease 4.17.3 4.17.3
Serge Hallyn [Mon, 24 Feb 2025 13:55:18 +0000 (07:55 -0600)] 
Release 4.17.3

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 months agochsh: do not warn about blank shell
Chris Hofstaedtler [Mon, 17 Feb 2025 23:54:30 +0000 (00:54 +0100)] 
chsh: do not warn about blank shell

Closes: <https://bugs.debian.org/876542>
Reported-by: 積丹尼 Dan Jacobson <jidanni@jidanni.org>
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/: Use strisdigit() instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 15:24:33 +0000 (16:24 +0100)] 
lib/: Use strisdigit() instead of its pattern

Note that the old code in

(1)  lib/strtoday.c:strtoday()
(2)  lib/subordinateio.c:append_uids()

was considering an empty string as if it were a number.
strisdigit() does not consider an empty string to be numeric.

I think it will not affect the behavior in either case, as they should
sooner or later result in an error somewhere.  And it seems (IMO)
surprising to treat empty strings as numeric strings, so let's not do
it.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/string/ctype/strisascii/: strisdigit(): Add function
Alejandro Colomar [Wed, 11 Dec 2024 00:57:29 +0000 (01:57 +0100)] 
lib/string/ctype/strisascii/: strisdigit(): Add function

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/string/: Add comments expanding the letter-soup API names
Alejandro Colomar [Sat, 15 Feb 2025 21:06:30 +0000 (22:06 +0100)] 
lib/string/: Add comments expanding the letter-soup API names

Suggested-by: Serge Hallyn <serge@hallyn.com>
Cc: Chris Bazley <Chris.Bazley@arm.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/basename.c: Basename(): Use stprcspn() instead of its pattern
Alejandro Colomar [Sat, 16 Nov 2024 14:48:23 +0000 (15:48 +0100)] 
lib/basename.c: Basename(): Use stprcspn() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/string/strspn/, lib/, src/: stprspn(), strrspn_(): Split API into function and...
Alejandro Colomar [Sat, 16 Nov 2024 14:15:32 +0000 (15:15 +0100)] 
lib/string/strspn/, lib/, src/: stprspn(), strrspn_(): Split API into function and macro

This provides a safer and more consistent API.

We had the strrspn(3) function as it was for compatibility with Oracle
Solaris, but let's not repeat their mistake.  Nevertheless, name our
function strrspn_() with a trailing underscore, to differentiate it from
the one in Solaris, since it's slightly different.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/string/strspn/, lib/, src/: Move *spn() APIs to separate subdir
Alejandro Colomar [Sat, 16 Nov 2024 14:03:28 +0000 (15:03 +0100)] 
lib/string/strspn/, lib/, src/: Move *spn() APIs to separate subdir

This provides a better organization.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/string/strchr/: strrcspn(), stprcspn(): Add function and macro
Alejandro Colomar [Sat, 16 Nov 2024 13:33:34 +0000 (14:33 +0100)] 
lib/string/strchr/: strrcspn(), stprcspn(): Add function and macro

These APIs are to strrspn(), like strcspn() is to strspn().
They are like strcspn(3), but search from the end of the string.

The function is meant for internal use, and consistency with libc.
The macro is meant for normal use, since it returns a pointer,
which is what algorithms using this need.

See also strspn(3) and strcspn(3).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/useradd.c: Use !strcaseeq() instead of its pattern
Alejandro Colomar [Sat, 8 Feb 2025 23:19:34 +0000 (00:19 +0100)] 
src/useradd.c: Use !strcaseeq() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/, src/: Use strcaseeq() instead of its pattern
Alejandro Colomar [Sat, 8 Feb 2025 23:18:58 +0000 (00:18 +0100)] 
lib/, src/: Use strcaseeq() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/string/strcmp/: strcaseeq(): Add function
Alejandro Colomar [Wed, 5 Feb 2025 17:42:21 +0000 (18:42 +0100)] 
lib/string/strcmp/: strcaseeq(): Add function

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoman/useradd.8.xml: Document new exit code 19 (E_BAD_NAME)
Marc Haber [Thu, 5 Dec 2024 17:54:17 +0000 (18:54 +0100)] 
man/useradd.8.xml: Document new exit code 19 (E_BAD_NAME)

Link: <https://github.com/shadow-maint/shadow/issues/1103>
Link: <https://github.com/shadow-maint/shadow/pull/1141>
Signed-off-by: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Cc: Chris Hofstaedtler <zeha@debian.org>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/useradd.c: E_BAD_NAME: Use a different error code for bad login names
Alejandro Colomar [Thu, 5 Dec 2024 16:38:54 +0000 (17:38 +0100)] 
src/useradd.c: E_BAD_NAME: Use a different error code for bad login names

Wrappers like adduser(8) want to do their own stuff if the login name is
bad.  For that, they need to be able to differentiate such an error.

Closes: <https://github.com/shadow-maint/shadow/issues/1103>
Suggested-by: Chris Hofstaedtler <zeha@debian.org>
Cc: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agosrc/useradd.c: create_home(): Use !streq() instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 14:57:58 +0000 (15:57 +0100)] 
src/useradd.c: create_home(): Use !streq() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/chkname.c: is_valid_name(): Use streq() instead of its pattern
Alejandro Colomar [Mon, 2 Dec 2024 12:23:49 +0000 (13:23 +0100)] 
lib/chkname.c: is_valid_name(): Use streq() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoconfigure.ac, lib/: Use __has_include(<gshadow.h>) instead of HAVE_GSHADOW_H
Alejandro Colomar [Mon, 27 Jan 2025 12:23:57 +0000 (13:23 +0100)] 
configure.ac, lib/: Use __has_include(<gshadow.h>) instead of HAVE_GSHADOW_H

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoconfigure.ac: Remove unused AC_CHECK_HEADERS() checks
Alejandro Colomar [Tue, 12 Nov 2024 13:48:52 +0000 (14:48 +0100)] 
configure.ac: Remove unused AC_CHECK_HEADERS() checks

$ grep -rE 'HAVE_(UTMP)_H'
$ grep -rE 'HAVE_(TERMIO|SGTTY|SYS_IOCTL|PATHS)_H'
$ grep -rE 'HAVE_(LASTLOG|RPC_KEY_PROT|ACL_LIBACL)_H'
$ grep -rE 'HAVE_(ATTR_LIBATTR|ATTR_ERROR_CONTEXT)_H'
$

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoconfigure.ac, lib/: Use __has_include(<sys/capability.h>) instead of HAVE_SYS_CAPABIL...
Alejandro Colomar [Tue, 12 Nov 2024 13:45:08 +0000 (14:45 +0100)] 
configure.ac, lib/: Use __has_include(<sys/capability.h>) instead of HAVE_SYS_CAPABILITY_H

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/idmapping.c: Unconditionally include <sys/prctl.h>
Alejandro Colomar [Tue, 12 Nov 2024 13:42:12 +0000 (14:42 +0100)] 
lib/idmapping.c: Unconditionally include <sys/prctl.h>

It's a widely available header.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/: Use __has_include(<security/openpam.h>) instead of HAVE_SECURITY_OPENPAM_H
Alejandro Colomar [Tue, 12 Nov 2024 13:39:03 +0000 (14:39 +0100)] 
lib/: Use __has_include(<security/openpam.h>) instead of HAVE_SECURITY_OPENPAM_H

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/: Use __has_include(<security/pam_misc.h>) instead of HAVE_SECURITY_PAM_MISC_H
Alejandro Colomar [Tue, 12 Nov 2024 13:38:10 +0000 (14:38 +0100)] 
lib/: Use __has_include(<security/pam_misc.h>) instead of HAVE_SECURITY_PAM_MISC_H

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoconfigure.ac, lib/: Use __has_include(<sys/random.h>) instead of HAVE_SYS_RANDOM_H
Alejandro Colomar [Tue, 12 Nov 2024 13:34:36 +0000 (14:34 +0100)] 
configure.ac, lib/: Use __has_include(<sys/random.h>) instead of HAVE_SYS_RANDOM_H

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoconfigure.ac, lib/: Use __has_include(<crypt.h>) instead of HAVE_CRYPT_H
Alejandro Colomar [Tue, 12 Nov 2024 13:32:33 +0000 (14:32 +0100)] 
configure.ac, lib/: Use __has_include(<crypt.h>) instead of HAVE_CRYPT_H

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/, src/: motd(): Report errors instead of exiting from library code
Alejandro Colomar [Fri, 15 Nov 2024 22:55:18 +0000 (23:55 +0100)] 
lib/, src/: motd(): Report errors instead of exiting from library code

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/motd.c: motd(): Invert logic to reduce indentation
Alejandro Colomar [Fri, 15 Nov 2024 22:50:57 +0000 (23:50 +0100)] 
lib/motd.c: motd(): Invert logic to reduce indentation

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/, src/, doc/: Remove pw_auth()'s $3 as dead code
Alejandro Colomar [Thu, 30 Jan 2025 12:19:03 +0000 (13:19 +0100)] 
lib/, src/, doc/: Remove pw_auth()'s $3 as dead code

We don't read the parameter at all.  Remove it.

As a consequence, all the PW_* constants are also removed (as they are
now unused).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/pwauth.*: PW_{ADD,CHANGE,DELETE,FTP,REXEC}: Remove dead code
Alejandro Colomar [Wed, 29 Jan 2025 16:21:33 +0000 (17:21 +0100)] 
lib/pwauth.*: PW_{ADD,CHANGE,DELETE,FTP,REXEC}: Remove dead code

These values aren't being set anywhere.

Reviewed-by: Sam James <sam@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/, src/, doc/: Remove dead code
Alejandro Colomar [Wed, 29 Jan 2025 15:37:51 +0000 (16:37 +0100)] 
lib/, src/, doc/: Remove dead code

pw_auth()'s $4 was always being specified as NULL.  Remove the
parameter.  Instead, set a local variable to NULL at function entry, and
remove code that never runs (conditional on $4 != NULL).

Reviewed-by: Sam James <sam@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agosrc/vipw.c: Restore the original terminal pgrp after editing
Todd C. Miller [Fri, 24 Jan 2025 02:11:09 +0000 (19:11 -0700)] 
src/vipw.c: Restore the original terminal pgrp after editing

This fixes a problem when the shell is not in monitor mode (job control
enabled) which resulted in the terminal pgrp being set to an invalid
value once vipw exited.

Fixes: 7eca1112fbd7 (2019-11-11; "Fix vipw not resuming correctly when suspended")
Closes: <https://github.com/shadow-maint/shadow/issues/1194>
Reported-by: <https://github.com/yonecle>
Tested-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/, src/: Use agetgroups() instead of its pattern
Alejandro Colomar [Tue, 19 Nov 2024 00:20:56 +0000 (01:20 +0100)] 
lib/, src/: Use agetgroups() instead of its pattern

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/shadow/grp/: agetgroups(): Add function
Alejandro Colomar [Tue, 19 Nov 2024 00:20:56 +0000 (01:20 +0100)] 
lib/shadow/grp/: agetgroups(): Add function

This encapsulates the logic for calling getgroups(3), which requires two
calls plus a malloc(3) call to do it correctly.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agoconfigure.ac, lib/, src/: Use gid_t instead of GETGROUPS_T
Alejandro Colomar [Sat, 16 Nov 2024 12:08:12 +0000 (13:08 +0100)] 
configure.ac, lib/, src/: Use gid_t instead of GETGROUPS_T

Autoconf's NEWS file says

*** AC_FUNC_GETGROUPS and AC_TYPE_GETGROUPS no longer run test programs.
  These macros were testing for OS bugs that we believe are at least
  twenty years in the past.  Most operating systems are now trusted to
  provide an accurate prototype for getgroups in unistd.h, and to
  implement it as specified in POSIX.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/adds.h: addslN(): Use QSORT() instead of its pattern
Alejandro Colomar [Thu, 14 Nov 2024 21:08:01 +0000 (22:08 +0100)] 
lib/adds.h: addslN(): Use QSORT() instead of its pattern

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/search/sort/: QSORT(): Add macro
Alejandro Colomar [Thu, 14 Nov 2024 21:04:21 +0000 (22:04 +0100)] 
lib/search/sort/: QSORT(): Add macro

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>