]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
4 weeks agosrc/userdel.c: SELinux file context for fail_exit()
Iker Pedrosa [Tue, 1 Jul 2025 13:44:55 +0000 (15:44 +0200)] 
src/userdel.c: SELinux file context for fail_exit()

Do not process SELinux file context when running fail_exit() when chroot
or prefix options are selected.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/userdel.c: chroot or prefix SELinux file context
Iker Pedrosa [Tue, 1 Jul 2025 13:37:50 +0000 (15:37 +0200)] 
src/userdel.c: chroot or prefix SELinux file context

Do not process SELinux file context during file closure when chroot or
prefix options are selected.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/userdel.c: replace global variable by flags structure
Iker Pedrosa [Tue, 1 Jul 2025 13:35:35 +0000 (15:35 +0200)] 
src/userdel.c: replace global variable by flags structure

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/usermod.c: SELinux file context for fail_exit()
Iker Pedrosa [Tue, 1 Jul 2025 13:30:57 +0000 (15:30 +0200)] 
src/usermod.c: SELinux file context for fail_exit()

Do not process SELinux file context when running fail_exit() when chroot
or prefix options are selected.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/usermod.c: chroot or prefix SELinux file context
Iker Pedrosa [Tue, 1 Jul 2025 12:53:13 +0000 (14:53 +0200)] 
src/usermod.c: chroot or prefix SELinux file context

Do not process SELinux file context during file closure when chroot or
prefix options are selected.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/useradd.c: SELinux file context for fail_exit()
Iker Pedrosa [Tue, 1 Jul 2025 11:23:08 +0000 (13:23 +0200)] 
src/useradd.c: SELinux file context for fail_exit()

Do not process SELinux file context when running fail_exit() when chroot
or prefix options are selected.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/useradd.c: SELinux file context for home and mail
Iker Pedrosa [Tue, 20 May 2025 10:38:16 +0000 (12:38 +0200)] 
src/useradd.c: SELinux file context for home and mail

Do not process SELinux file context when creating home and mail folders
when chroot or prefix options are selected.

Closes: https://github.com/shadow-maint/shadow/issues/940
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/useradd.c: chroot or prefix SELinux file context
Iker Pedrosa [Fri, 25 Apr 2025 14:32:42 +0000 (16:32 +0200)] 
src/useradd.c: chroot or prefix SELinux file context

Do not process SELinux file context during file closure when chroot or
prefix options are selected.

Closes: https://github.com/shadow-maint/shadow/issues/940
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in sub_gid_unlock()
Iker Pedrosa [Fri, 25 Apr 2025 14:12:40 +0000 (16:12 +0200)] 
lib/, src/: add SELinux control flag in sub_gid_unlock()

Expand sub_gid_unlock() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in sub_uid_unlock()
Iker Pedrosa [Fri, 25 Apr 2025 14:10:09 +0000 (16:10 +0200)] 
lib/, src/: add SELinux control flag in sub_uid_unlock()

Expand sub_uid_unlock() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agosrc/vipw.c: add SELinux control flag in unlock
Iker Pedrosa [Fri, 25 Apr 2025 14:06:57 +0000 (16:06 +0200)] 
src/vipw.c: add SELinux control flag in unlock

All unlock functions require the SELinux control flag, thus add it as an
argument.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in sgr_unlock()
Iker Pedrosa [Fri, 25 Apr 2025 14:03:58 +0000 (16:03 +0200)] 
lib/, src/: add SELinux control flag in sgr_unlock()

Expand sgr_unlock() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in gr_unlock()
Iker Pedrosa [Fri, 25 Apr 2025 14:00:43 +0000 (16:00 +0200)] 
lib/, src/: add SELinux control flag in gr_unlock()

Expand gr_unlock() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in spw_unlock()
Iker Pedrosa [Fri, 25 Apr 2025 13:57:21 +0000 (15:57 +0200)] 
lib/, src/: add SELinux control flag in spw_unlock()

Expand spw_unlock() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in pw_unlock()
Iker Pedrosa [Fri, 25 Apr 2025 13:53:17 +0000 (15:53 +0200)] 
lib/, src/: add SELinux control flag in pw_unlock()

Expand pw_unlock() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/: add SELinux control flag in commonio_unlock()
Iker Pedrosa [Fri, 25 Apr 2025 13:44:06 +0000 (15:44 +0200)] 
lib/: add SELinux control flag in commonio_unlock()

Expand commonio_unlock() interface to add a control flag for SELinux
file context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in sub_gid_close()
Iker Pedrosa [Fri, 25 Apr 2025 13:38:18 +0000 (15:38 +0200)] 
lib/, src/: add SELinux control flag in sub_gid_close()

Expand sub_gid_close() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in sub_uid_close()
Iker Pedrosa [Fri, 25 Apr 2025 13:35:48 +0000 (15:35 +0200)] 
lib/, src/: add SELinux control flag in sub_uid_close()

Expand sub_uid_close() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in sgr_close()
Iker Pedrosa [Fri, 25 Apr 2025 13:32:05 +0000 (15:32 +0200)] 
lib/, src/: add SELinux control flag in sgr_close()

Expand sgr_close() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in gr_close()
Iker Pedrosa [Fri, 25 Apr 2025 13:28:42 +0000 (15:28 +0200)] 
lib/, src/: add SELinux control flag in gr_close()

Expand gr_close() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in spw_close()
Iker Pedrosa [Fri, 25 Apr 2025 13:23:11 +0000 (15:23 +0200)] 
lib/, src/: add SELinux control flag in spw_close()

Expand spw_close() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/, src/: add SELinux control flag in pw_close()
Iker Pedrosa [Fri, 25 Apr 2025 13:19:29 +0000 (15:19 +0200)] 
lib/, src/: add SELinux control flag in pw_close()

Expand pw_close() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/: add SELinux control flag in commonio_close()
Iker Pedrosa [Fri, 25 Apr 2025 13:13:12 +0000 (15:13 +0200)] 
lib/: add SELinux control flag in commonio_close()

Expand commonio_close() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 weeks agolib/: Use libc _FILE_SHADOW from <paths.h>
Alejandro Colomar [Sun, 28 Sep 2025 08:40:09 +0000 (10:40 +0200)] 
lib/: Use libc _FILE_SHADOW from <paths.h>

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/, po/: sgetspent(): Move to under lib/shadow/shadow/
Alejandro Colomar [Mon, 24 Feb 2025 22:06:39 +0000 (23:06 +0100)] 
lib/shadow/, lib/, po/: sgetspent(): Move to under lib/shadow/shadow/

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/
Alejandro Colomar [Sun, 10 Nov 2024 22:31:23 +0000 (23:31 +0100)] 
lib/shadow/, lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/, po/: sgetgrent(): Move to under lib/shadow/group/
Alejandro Colomar [Sun, 10 Nov 2024 22:14:28 +0000 (23:14 +0100)] 
lib/shadow/, lib/, po/: sgetgrent(): Move to under lib/shadow/group/

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/: GSHADOW: Remove unused macro
Alejandro Colomar [Sun, 10 Nov 2024 22:00:19 +0000 (23:00 +0100)] 
lib/: GSHADOW: Remove unused macro

And with it, the file that defines it, which does nothing else.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/: getsgent(): Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 18:04:06 +0000 (19:04 +0100)] 
lib/shadow/, lib/: getsgent(): Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/, src/: getsgnam(): Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 17:52:57 +0000 (18:52 +0100)] 
lib/shadow/, lib/, src/: getsgnam(): Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/: sgetsgent(): Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 17:44:05 +0000 (18:44 +0100)] 
lib/shadow/, lib/: sgetsgent(): Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/: fgetsgent(): Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 17:18:19 +0000 (18:18 +0100)] 
lib/shadow/, lib/: fgetsgent(): Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/, src/: struct sgrp: Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 17:07:59 +0000 (18:07 +0100)] 
lib/shadow/, lib/, src/: struct sgrp: Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/: setsgent(): Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 16:44:23 +0000 (17:44 +0100)] 
lib/shadow/, lib/: setsgent(): Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/, src/: Use _PATH_GSHADOW from <paths.h>
Alejandro Colomar [Sun, 10 Nov 2024 16:36:44 +0000 (17:36 +0100)] 
lib/shadow/, lib/, src/: Use _PATH_GSHADOW from <paths.h>

This macro is provided by glibc (but not musl) as _PATH_GSHADOW in
<paths.h>.  Let's use that macro, and define it only if libc doesn't
provide it.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/, src/: endsgent(): Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 15:48:15 +0000 (16:48 +0100)] 
lib/shadow/, lib/, src/: endsgent(): Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/: gshadow: Move to separate file and rename
Alejandro Colomar [Sun, 10 Nov 2024 15:22:12 +0000 (16:22 +0100)] 
lib/shadow/, lib/: gshadow: Move to separate file and rename

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agolib/shadow/, lib/: putsgent(): Move to separate file
Alejandro Colomar [Sun, 10 Nov 2024 14:27:43 +0000 (15:27 +0100)] 
lib/shadow/, lib/: putsgent(): Move to separate file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 weeks agopwck/grpck: only force nscd/sssd caches flush if anything was changed
Alexey Tikhonov [Fri, 3 Oct 2025 14:52:38 +0000 (16:52 +0200)] 
pwck/grpck: only force nscd/sssd caches flush if anything was changed

4 weeks agoMake sure 'sss_cache' can get both 'U' and 'G' args
Alexey Tikhonov [Fri, 3 Oct 2025 14:46:49 +0000 (16:46 +0200)] 
Make sure 'sss_cache' can get both 'U' and 'G' args

Fixes: 59e5eef38f89 (2024-07-03; "contrib, lib/, src/, tests/: Use stpcpy(3) instead of its pattern")
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 weeks agopo/nl.po: Update
Frans Spiesschaert [Fri, 3 Oct 2025 09:03:20 +0000 (11:03 +0200)] 
po/nl.po: Update

Closes: <https://github.com/shadow-maint/shadow/issues/1360>
Signed-off-by: Frans Spiesschaert <Frans.Spiesschaert@yucom.be>
Cc: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 weeks agolib/string/README: Add guidelines for using strings
Alejandro Colomar [Tue, 19 Aug 2025 21:18:57 +0000 (23:18 +0200)] 
lib/string/README: Add guidelines for using strings

Suggested-by: Iker Pedrosa <ipedrosa@redhat.com>
Suggested-by: Serge Hallyn <serge@hallyn.com>
Suggested-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Suggested-by: Lukas Slebodnik <lslebodn@fedoraproject.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 weeks agolib/, src/: Use consistent style using strchr(3) in conditionals
Alejandro Colomar [Thu, 4 Jul 2024 17:00:53 +0000 (19:00 +0200)] 
lib/, src/: Use consistent style using strchr(3) in conditionals

While the return value is a pointer, it can be interpreted as a boolean
value meaning "found".  In general, we use explicit comparisons of
pointers to NULL, but in this specific case, let's use that
interpretation, and make an exception, using an implicit conversion to
boolean.

For negative matches, use
if (!strchr(...))

For positive matches, use
if (strchr(...))

For positive matches, when a variable is also set, use
while (NULL != (p = strchr(...)))

Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 weeks agoconfigure.ac, lib/: Use _PATH_WTMP from <paths.h>
Alejandro Colomar [Sun, 31 Aug 2025 11:57:22 +0000 (13:57 +0200)] 
configure.ac, lib/: Use _PATH_WTMP from <paths.h>

That's the libc macro for this file.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 weeks agoconfigure.ac, lib/, src/: Use _PATH_LASTLOG from <paths.h>
Alejandro Colomar [Sun, 31 Aug 2025 11:53:54 +0000 (13:53 +0200)] 
configure.ac, lib/, src/: Use _PATH_LASTLOG from <paths.h>

That's the libc macro for this file.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 weeks agoWhen using nss-module, avoid using '/etc/sub[ug]id'
Anders Blomdell [Tue, 2 Sep 2025 09:51:14 +0000 (11:51 +0200)] 
When using nss-module, avoid using '/etc/sub[ug]id'

Use 'want_sub[ug]id_file' to short-circuit acess to '/etc/sub[ug]id' when
nss-moduleis active

8 weeks agoFactor out 'want_sub[ug]ids' and rename to 'want_sub[ug]id_file'
Anders Blomdell [Tue, 2 Sep 2025 09:45:37 +0000 (11:45 +0200)] 
Factor out 'want_sub[ug]ids' and rename to 'want_sub[ug]id_file'

Move 'want_sub[ug]ids' from 'src/newusers.c' to 'lib/subordinateio.[ch]'
and rename them to 'want_sub[ug]id_file' to clearly indicate that it
refers to the '/etc/sub[ug]id' and not to subids in general.

8 weeks agosrc/su.c: Fix incorrect (non-matching) parentheses
Alejandro Colomar [Tue, 22 Jul 2025 23:21:38 +0000 (01:21 +0200)] 
src/su.c: Fix incorrect (non-matching) parentheses

Fixes: 45c6603cc86c (2007-10-07; "[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Closes: <https://github.com/shadow-maint/shadow/issues/1310>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 weeks ago.github/workflows/static-code-analysis.yml: add Python linters
Iker Pedrosa [Mon, 1 Sep 2025 17:02:20 +0000 (19:02 +0200)] 
.github/workflows/static-code-analysis.yml: add Python linters

Add flake8, pycodestyle, isort, black and mypy in CI for Python linting.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 weeks agotests/system/tests/: fix Python linter issues
Iker Pedrosa [Mon, 1 Sep 2025 13:12:14 +0000 (15:12 +0200)] 
tests/system/tests/: fix Python linter issues

Fix issues reported by flake8, pycodestyle, isort, black and mypy.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 weeks agotests/system/framework/: fix Python linter issues
Iker Pedrosa [Mon, 1 Sep 2025 13:08:53 +0000 (15:08 +0200)] 
tests/system/framework/: fix Python linter issues

Fix issues reported by flake8, pycodestyle, isort, black and mypy.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 weeks agotests/system/pyproject.toml: add mypy rules
Iker Pedrosa [Mon, 1 Sep 2025 13:02:17 +0000 (15:02 +0200)] 
tests/system/pyproject.toml: add mypy rules

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 months agoman/chsh: deduplicate shells text
Georg Pfuetzenreuter [Mon, 25 Aug 2025 18:59:55 +0000 (20:59 +0200)] 
man/chsh: deduplicate shells text

Restructure the paragraphs to avoid duplication of text inside multiple
conditions, making maintenance easier and avoiding accidental
duplication in the rendered output.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2 months agoman/chsh: remove duplicate paragraph
Georg Pfuetzenreuter [Sun, 24 Aug 2025 21:20:47 +0000 (23:20 +0200)] 
man/chsh: remove duplicate paragraph

The section about the risk of placing a restricted shell was duplicated
in the rendered manual page if the "without_vendordir" condition
matched.

Fixes: a27d5c51f1f3 ("Supporting vendor given -shells- configuration file")
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2 months agolib/subordinateio.c: list_owner_ranges(): Fix duplicate range when username matches ID
Alejandro Colomar [Sun, 24 Aug 2025 07:29:33 +0000 (09:29 +0200)] 
lib/subordinateio.c: list_owner_ranges(): Fix duplicate range when username matches ID

Fixes: 3ec32f9975f2 (2022-07-20; "subordinateio: also compare the owner ID")
Closes: <https://github.com/shadow-maint/shadow/issues/1339>
Link: <https://github.com/cri-o/cri-o/issues/9416>
Reported-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoshare/ansible/: fix Debian 13 build
Iker Pedrosa [Mon, 18 Aug 2025 08:38:33 +0000 (10:38 +0200)] 
share/ansible/: fix Debian 13 build

Install `gpg` package as Debian 13 container image stopped installing it
by default, making the CI fail.

Closes: <https://github.com/shadow-maint/shadow/issues/1335>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 months agolib/utmp.c: Add explicit include <stdlib.h> for free() and other functions
Evgeny Grin (Karlson2k) [Mon, 11 Aug 2025 00:50:30 +0000 (02:50 +0200)] 
lib/utmp.c: Add explicit include <stdlib.h> for free() and other functions

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
2 months agolib/utmp.c: Add ATTR_MALLOC(free) attribute
Evgeny Grin (Karlson2k) [Sun, 10 Aug 2025 13:31:01 +0000 (15:31 +0200)] 
lib/utmp.c: Add ATTR_MALLOC(free) attribute

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
2 months agolib/utmp.c: get_session_host(): Fix memory leak
Alejandro Colomar [Mon, 14 Jul 2025 12:08:52 +0000 (14:08 +0200)] 
lib/utmp.c: get_session_host(): Fix memory leak

Fixes: f40bdfa66a3a (2023-08-02; "libmisc: implement `get_session_host()`")
Closes: <https://github.com/shadow-maint/shadow/issues/1291>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Fix use of last utmp entry instead of patrial-match entry
Evgeny Grin (Karlson2k) [Sun, 10 Aug 2025 12:08:18 +0000 (14:08 +0200)] 
lib/utmp.c: Fix use of last utmp entry instead of patrial-match entry

The pointer returned by getutxent() function may always point to
the same shared and reused buffer.

Instead of copying the utmp entry pointer value the content of utmp
entry must be copied otherwise the next call of getutxent() will
overwrite previously found entry.

This commit has no optimisations to highlight what is really fixed.

Fixes: 841776561f56bae7382c6bd47e428201a155d39c (09-08-2025; "lib/utmp.c: Fix umtp entry search")
Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
2 months agosrc/chfn.c: Use stpeprintf() to improve readability
Alejandro Colomar [Sat, 19 Jul 2025 08:56:28 +0000 (10:56 +0200)] 
src/chfn.c: Use stpeprintf() to improve readability

This allows us to split the formation of the string into several
s*printf() calls.

Shorten comment, to make it fit in one line.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/chfn.c: Simplify checking for a long GECOS field
Alejandro Colomar [Sat, 19 Jul 2025 08:48:06 +0000 (10:48 +0200)] 
src/chfn.c: Simplify checking for a long GECOS field

Use a buffer of the exact size we want, and let SNPRINTF() decide if it
fits or not.

BTW, the old check seemed to be wrong: it wasn't accounting for the
commas in the 80-character limit, but that didn't make much sense.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/chfn.c: slop: Reduce buffer size
Alejandro Colomar [Sat, 19 Jul 2025 08:36:33 +0000 (10:36 +0200)] 
src/chfn.c: slop: Reduce buffer size

We never use more than BUFSIZ.  (And we could use way less than that.)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/chfn.c: Write an empty string if there's nothing in the GECOS field
Alejandro Colomar [Fri, 18 Jul 2025 22:18:30 +0000 (00:18 +0200)] 
src/chfn.c: Write an empty string if there's nothing in the GECOS field

Otherwise, the buffer would contain garbage.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/chfn.c: Use strsep(3) and strcpy(3) instead of its pattern
Alejandro Colomar [Fri, 18 Jul 2025 22:11:11 +0000 (00:11 +0200)] 
src/chfn.c: Use strsep(3) and strcpy(3) instead of its pattern

This wrapper was very weird, and it's simpler to open-code the calls to
strsep(3) and strcpy(3) instead.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/chfn.c: Do not allow the 'slop' fields to appear before any non-slop gecos fields
Alejandro Colomar [Fri, 18 Jul 2025 21:53:30 +0000 (23:53 +0200)] 
src/chfn.c: Do not allow the 'slop' fields to appear before any non-slop gecos fields

According to the Wikipedia page for the 'Gecos field', the "typical"
format for the GECOS field is a comma-delimited list with this order:

1)  User's full name (or application name, if the account is for a program)
2)  Building and room number or contact person
3)  Office telephone number
4)  Home telephone number
5+) Any other contact information (pager number, fax, external e-mail address, etc.)

But our code supported the "other contact information", which we call
slop, and which is composed of an arbitrary number of key=value fields,
to appear before any of the other 4 fields.

This seems to be undocumented, and none of the documentation I've found
for the GECOS field in any systems I checked claims to support this.
By removing support for those, we can significantly simplify the
copy_field() function, which was quite unreadable.

After this patch, the GECOS field is treated as a CSV, blindly copying
the fields as they appear, where the first 4 fields are as specified
above, and anything after them is the slop (5+ fields, any other contact
information).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/agetpass.c: Pass "" instead of NULL as an ignored prompt
Alejandro Colomar [Sat, 9 Aug 2025 15:53:26 +0000 (17:53 +0200)] 
lib/agetpass.c: Pass "" instead of NULL as an ignored prompt

This is safer, since in general, readpassphrase(3) does not accept
a null pointer as input.

This was discovered thanks to Chris Bazley's _Optional qualifier, which
I'm testing at the moment.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/, src/: Reorder while() conditions for safety
Alejandro Colomar [Fri, 18 Jul 2025 10:23:42 +0000 (12:23 +0200)] 
lib/, src/: Reorder while() conditions for safety

In conditions that perform simple assignment (=) before comparison,
it's safer to put the comparison first, as a mistake would result in a
compiler error, as opposed to assigning something incorrect.
It's also more readable, IMO.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Fix umtp entry search
Evgeny Grin (Karlson2k) [Mon, 14 Jul 2025 19:37:08 +0000 (21:37 +0200)] 
lib/utmp.c: Fix umtp entry search

Updated utmp entry search algorithm to follow GNU/Linux description:
https://man7.org/linux/man-pages/man5/utmp.5.html#DESCRIPTION

An entry is found by looking for matching PID.  If several such entries
found (for example, due to cleanup failure of old entries) then first
entry with both matching PID and matching 'ut_line' (current terminal)
is used.  If not entry has matching 'ut_line' then first entry with
matching PID is used (if getty/init process does not set 'ut_line').

When no single entry is matched by PID, then but at least one entry is
matched current terminal the the first such entry is selected (if getty
does not set correct PID).

This commit uses non-portable Elvis operator is it is already used
everywhere in the code.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agosrc/groupmod.c: --help: wfix
Alejandro Colomar [Tue, 29 Jul 2025 22:18:33 +0000 (00:18 +0200)] 
src/groupmod.c: --help: wfix

Closes: <https://github.com/shadow-maint/shadow/issues/1313>
Reported-by: Arshdeep Singh <arshdeepsinghsahni8@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agoconfigure.ac: cosmetics - unified check for $enable_logind value
Evgeny Grin (Karlson2k) [Thu, 10 Jul 2025 16:38:48 +0000 (18:38 +0200)] 
configure.ac: cosmetics - unified check for $enable_logind value

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure.ac: Make sure that logind is enabled if requested, make --enable-logind...
Evgeny Grin (Karlson2k) [Thu, 10 Jul 2025 16:38:48 +0000 (18:38 +0200)] 
configure.ac: Make sure that logind is enabled if requested, make --enable-logind default

Before this commit, if configured with --enable-logind, but libsystemd
is not found, configure silently succeed, however logind is efficiently
disabled.
With this commit, the configure fails if logind is not explicitly
disabled and libsystemd is not found.
--disable-logind is mandatory if logind integration should not be used.

Automatic detection is disabled by Alejandro Colomar's request.
Extra help in the error message is added by lslebodn's request.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure.ac: Improve formatting for libsystemd check
Evgeny Grin (Karlson2k) [Thu, 10 Jul 2025 16:38:48 +0000 (18:38 +0200)] 
configure.ac: Improve formatting for libsystemd check

Improve formatting and readability of single configure check.
Also remove unneeded overquoting of "LIBSYSTEMD=-lsystemd".

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure.ac: Add check for value given for --enable-logind
Evgeny Grin (Karlson2k) [Thu, 10 Jul 2025 16:38:48 +0000 (18:38 +0200)] 
configure.ac: Add check for value given for --enable-logind

Fail with error if wrong value is provided.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure: Document --enable-logind behaviour correctly
Evgeny Grin (Karlson2k) [Sun, 20 Jul 2025 09:12:40 +0000 (11:12 +0200)] 
configure: Document --enable-logind behaviour correctly

The code does not enabled logind unconditionally by default.  Instead
configure checks for logind (libsystemd) availability and enables it
only if found.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agohurd: do not include sys/prctl.h when it is not available
Samuel Thibault [Tue, 22 Jul 2025 11:22:49 +0000 (13:22 +0200)] 
hurd: do not include sys/prctl.h when it is not available

3 months agochpasswd: Check hash before write when using -e
vinz [Fri, 11 Jul 2025 16:08:22 +0000 (16:08 +0000)] 
chpasswd: Check hash before write when using -e

Add is_valid_hash to prevent adding a bad hash in /etc/shadow (and so prevent user to be lock) when using chpasswd -e

    # before
    echo 'vinz:test123' | chpasswd -e
    grep vinz /etc/shadow
    vinz:test123:20280:0:99999:7:::

    # now
    echo 'vinz:test123' | sudo ./chpasswd -e
    chpasswd: (line 1, user vinz) invalid password hash
    chpasswd: error detected, changes ignored

3 months agoconfigure: Print configuration summary to the log (in addtion to stdout)
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 19:14:02 +0000 (21:14 +0200)] 
configure: Print configuration summary to the log (in addtion to stdout)

Signed-off-by: Ontogeny Grin (Karlson2k) <k2k@drgrin.dev>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agoconfigure: Fix outdated and non-portable 'test' syntax
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 18:24:48 +0000 (20:24 +0200)] 
configure: Fix outdated and non-portable 'test' syntax

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agoconfigure: Unify checks for variable values
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 16:47:59 +0000 (18:47 +0200)] 
configure: Unify checks for variable values

This is a workaround for broken shells, which incorrectly performs
'test "$var" = "value"' when variable is empty or not set.
Also this is a guard for variable values that may break "test", like
"!", "-z", "-n".

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agoconfigure: Move helper files to 'build-aux/'
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 15:51:00 +0000 (17:51 +0200)] 
configure: Move helper files to 'build-aux/'

Grouped autoconf settings.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoMakefile.am: Fix libtool warning
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 15:33:34 +0000 (17:33 +0200)] 
Makefile.am: Fix libtool warning

When running 'autoconf -vi' libtoolize always prints suggestion to
add this variable.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure: Fix quoting of the "#" symbol
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 15:19:09 +0000 (17:19 +0200)] 
configure: Fix quoting of the "#" symbol

[[]] means "use literally, without expansion and substitution".
# symbol potentially could be interpreted as a comment.
Also fixed one check with indented " #include <security/pam_appl.h>"
which is not correct C syntax.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure: Move AC_ARG_ENABLE. It cannot be conditional.
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 15:11:05 +0000 (17:11 +0200)] 
configure: Move AC_ARG_ENABLE. It cannot be conditional.

AC_ARG_ENABLE() expands to nothing where it is used, but adds arguments
parsing, help message and other related things.
It does not make any sense to put this macro into if branch.  It may
also confuse the reader.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure: Unify M4 quoting
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 13:46:30 +0000 (15:46 +0200)] 
configure: Unify M4 quoting

Always quoting of all arguments is recommended by autoconf manual.

The commit is checked by autoreconf -v before and after commit.
Resulting configure is identical (excluding some newlines).

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agoconfigure: Fix incorrect use of AM_CONDITIONAL
Evgeny Grin (Karlson2k) [Sat, 12 Jul 2025 14:32:29 +0000 (16:32 +0200)] 
configure: Fix incorrect use of AM_CONDITIONAL

AM_CONDITIONAL() must not be used in shell's if branches.  Instead it
must be specified one time only (per conditional variable) with test
"something" as a second parameter.
See https://www.gnu.org/software/automake/manual/html_node/Usage-of-Conditionals.html#index-AM_005fCONDITIONAL-2

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agoconfigure: Remove duplicated check and unused Makefile substitution
Evgeny Grin (Karlson2k) [Fri, 11 Jul 2025 17:57:39 +0000 (19:57 +0200)] 
configure: Remove duplicated check and unused Makefile substitution

Lines were incorrectly added by 5cd04d03f94622c12220d4a6352824af081b8531
The check is fully duplicated and does nothing except setting wrong
variable LIYESCRYPT.  Such variable was never used in the project.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agosrc/login.c: Fix checking whether 'login' is started as 'init'
Evgeny Grin (Karlson2k) [Mon, 14 Jul 2025 20:08:32 +0000 (22:08 +0200)] 
src/login.c: Fix checking whether 'login' is started as 'init'

When PAM is not used, login does not fork itself so its own PID should
be checked instead of parent PID.

Fixes: b44a6c316d96ab038492c63443156810670d176d (26-12-2007; "If started as init, login and sulogin need to start a new session.")
Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agolib/, src/: Fix utmp update: use initial PID
Evgeny Grin (Karlson2k) [Mon, 14 Jul 2025 18:57:03 +0000 (20:57 +0200)] 
lib/, src/: Fix utmp update: use initial PID

The correct utmp update functionality was broken mainly by commit
91fc51387ca5341e1a1f778a967886c5fe589cb8, which moved update of utmp
after forking (when PAM is used).  It was also misinterpretation of
GNU/Linux utmp specifications, where is specified that ut_pid must be
the PID of the **login** process (not a PID of any forked process).
Wrong ut_pid also prevents utmp cleanup, which performed by init process
and should clean entry with the same ut_pid as started login process.
GNU/Linux description of utmp updates can be found at the next url:
https://man7.org/linux/man-pages/man5/utmp.5.html

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agolib/utmp.c: Additional refactoring for readability
Evgeny Grin (Karlson2k) [Tue, 15 Jul 2025 14:36:07 +0000 (16:36 +0200)] 
lib/utmp.c: Additional refactoring for readability

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agolib/utmp.c: Refactoring for readability
Evgeny Grin (Karlson2k) [Tue, 15 Jul 2025 14:34:21 +0000 (16:34 +0200)] 
lib/utmp.c: Refactoring for readability

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agolib/utmp.c: Align generated "ut_id" with modern software
Evgeny Grin (Karlson2k) [Wed, 16 Jul 2025 15:50:53 +0000 (17:50 +0200)] 
lib/utmp.c: Align generated "ut_id" with modern software

Modern software (systemd, utemper) usually use full "ut_line" as "ut_id"
if string is up to four chars or last four chars if "ut_line" is longer.
For reference:
* libutemper (used by many graphical terminal emulator applications
  (konsole, xterm, others) to deal with utmp file):
  https://github.com/altlinux/libutempter/blob/4caa8ab94ff8b207228fa723a89214bf5e929321/libutempter/utempter.c#L99-L103
* systemd:
  uses full name of the device:
  https://github.com/systemd/systemd/blob/8013beb4a2221680b2c741bac6b3a33fe66406e1/units/getty%40.service.in#L41-L44
  or **last** four characters:
  https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#UtmpIdentifier=

The code in the commit is optimised for visual C code size.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/, src/: Use printf(3) instead of its pattern
Alejandro Colomar [Sun, 13 Jul 2025 15:04:40 +0000 (17:04 +0200)] 
lib/, src/: Use printf(3) instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agosrc/vipw.c: usage(): Print everything to the same stream
Alejandro Colomar [Sun, 13 Jul 2025 14:58:56 +0000 (16:58 +0200)] 
src/vipw.c: usage(): Print everything to the same stream

Closes: <https://github.com/shadow-maint/shadow/issues/1288>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/utmp.c: Fixed generated strings for "ut_id"
Evgeny Grin (Karlson2k) [Mon, 14 Jul 2025 20:05:21 +0000 (22:05 +0200)] 
lib/utmp.c: Fixed generated strings for "ut_id"

When no "ut_id" is provided by previous utmp file entry, "login" must
generate its own "ut_id". Historically tty number  was used for it.
However, if current device name is three characters or shorter, then
empty "ut_id" is produced or even garbage is copied from uninitialised
part of the "line".
This commit fixes it.
This patch uses unportable C extension Elvis operator as it is already
used everywhere in the code.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agolib/shadow/grp/: agetgroups(): Fix possible buffer overrun on non-Linux systems
Alejandro Colomar [Wed, 16 Jul 2025 12:49:26 +0000 (14:49 +0200)] 
lib/shadow/grp/: agetgroups(): Fix possible buffer overrun on non-Linux systems

Linux seems to at least write one group always from getgroups(2).
However, POSIX doesn't guarantee this, and a system might have 0 groups.

It is implementation‐defined whether getgroups() also returns
the effective group ID in the grouplist array.

Considering such a system, the call getgroups(0,NULL) could indeed
return 0, and the second call to getgroups might return a higher value,
if the group list has grown in between (race condition).  If this is the
case, we'd return an array of 0 elements (or 1, due to the MALLOC()
trick to avoid calling it with 0), with no elements filled, but where
ngids has been updated to have a positive value.  When the caller of
agetgroups() reads the array, they'd overrun the buffer.

Fixes: 05322ed89a1c (2025-01-24; "lib/shadow/grp/: agetgroups(): Add function")
Fixes: de941a7601f8 (2025-01-24; "lib/, src/: Simplify allocation of buffer")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months ago*/: Fix including <config.h> as system header
Evgeny Grin (Karlson2k) [Tue, 15 Jul 2025 11:18:54 +0000 (13:18 +0200)] 
*/: Fix including <config.h> as system header

"config.h" is a locally generated header. It must be included as
'#include "config.h"'.
It is already included correctly in some sources files. This commit
unifies the way how "config.h" is included.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
3 months agolib/utmp.c: check parent PID too when looking for utmp entry
Evgeny Grin (Karlson2k) [Thu, 10 Jul 2025 16:12:29 +0000 (18:12 +0200)] 
lib/utmp.c: check parent PID too when looking for utmp entry

'login' binary may fork itself before this check, so the entry may
contain parent PID instead of current process PID

4 months agotests/unit/test_xaprintf.c: Fix test by using streq() instead of strcmp(3)
Alejandro Colomar [Fri, 27 Jun 2025 16:59:23 +0000 (18:59 +0200)] 
tests/unit/test_xaprintf.c: Fix test by using streq() instead of strcmp(3)

Fixes: 423fd652b563 (2025-06-03; "lib/string/sprintf/, tests/unit/: Transform x[v]asprintf() into x[v]aprintf()")
Closes: <https://github.com/shadow-maint/shadow/issues/1279>
Reported-by: Timo Gurr <timo.gurr@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoRelease 4.18.0 4.18.0
Serge Hallyn [Tue, 24 Jun 2025 19:52:53 +0000 (14:52 -0500)] 
Release 4.18.0

Signed-off-by: Serge Hallyn <serge@hallyn.com>