]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
21 hours agosrc/usermod.c: -U: Report E_PASSWORDLESS on error due to passwordless account master
Alejandro Colomar [Mon, 5 Jan 2026 23:01:07 +0000 (00:01 +0100)] 
src/usermod.c: -U: Report E_PASSWORDLESS on error due to passwordless account

Reproducer:

$ useradd foo
$ grep foo /etc/passwd /etc/shadow
/etc/passwd:foo:x:1001:1001::/home/foo:/usr/bin/bash
/etc/shadow:foo:!:20458:0:99999:7:::
$ usermod -U testuser
usermod: unlocking the user's password would result in a passwordless account.
You should set a password with usermod -p to unlock this user's password.
$ echo $?
0
$ grep foo /etc/passwd /etc/shadow
/etc/passwd:foo:x:1001:1001::/home/foo:/usr/bin/bash
/etc/shadow:foo:!:20458:0:99999:7:::

The program failed (didn't change anything, and reported the problem to
stderr) but reported success (0).  After this patch, the error is
reported as E_PASSWORDLESS (20).

Closes: <https://github.com/shadow-maint/shadow/issues/1479>
Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Acked-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
34 hours agolib/commonio.c: Drop lrename
Tobias Stoeckmann [Sun, 11 Jan 2026 14:23:26 +0000 (15:23 +0100)] 
lib/commonio.c: Drop lrename

The lrename function follows symlinks when renaming files. Since the
source is a temporary file and the target is the database file itself,
which is opened with O_NOFOLLOW, this function is only useful for an
attacker who manages to win some form of race.

Fixes: 0fa908302660 (2007-10-07; "[svn-upgrade] Integrating new upstream version, shadow (4.0.16)")
Fixes: 391a3847157c (2010-03-04; "2010-01-30 Paweł Hajdan, Jr. <phajdan.jr@gentoo.org>")
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
34 hours agolib/commonio.c: Call utime for correct target
Tobias Stoeckmann [Wed, 14 Jan 2026 21:26:00 +0000 (22:26 +0100)] 
lib/commonio.c: Call utime for correct target

Since tmpf has been already renamed to target at this point, call utime
with target instead of tmpf.

Fixes: f8732b17dd1d (2026-01-14; "lib/commonio.c: Use unpredictable temporary names")
Reported-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
34 hours agovipw: Set correct pattern for fmkomstemp
Tobias Stoeckmann [Wed, 14 Jan 2026 21:58:51 +0000 (22:58 +0100)] 
vipw: Set correct pattern for fmkomstemp

The fmkomstemp call requires a suffix of XXXXXX for correct operation.
Do so in TCB case as well.

Note: If something fails and the file resides in this directory, it
could be interpreted as a username. Use the ',' character as an illegal
character to prevent shadow tools from erroneously accessing this file
and assuming that the user actually exists.

Fixes: a5b3d56e2902 (2026-01-09; "vipw: Use fmkomstemp for temporary file")
Reported-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
37 hours agovipw: Set ownership, then mode
Tobias Stoeckmann [Wed, 14 Jan 2026 18:58:40 +0000 (19:58 +0100)] 
vipw: Set ownership, then mode

This is a safer approach, which handles cases in which a file would have
less permissions for a group than others.

A rare edge case, but let's be safe than sorry.

Reported-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
37 hours agovipw: Prefer fchmod/fchown over chmod/chown
Tobias Stoeckmann [Wed, 14 Jan 2026 18:57:00 +0000 (19:57 +0100)] 
vipw: Prefer fchmod/fchown over chmod/chown

Use file descriptor functions when file descriptor is available, instead
of path based operations. The latter resolve symbolic links and are
prone to race conditions.

Reported-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
45 hours agolib/commonio.c: Larger buffer size for file names
Tobias Stoeckmann [Mon, 12 Jan 2026 17:29:54 +0000 (18:29 +0100)] 
lib/commonio.c: Larger buffer size for file names

Make sure that enough bytes exist for file name of temporary file which
is used to construct the next database file.

While at it, use a better variable name.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
45 hours agolib/commonio.c: Use unpredictable temporary names
Tobias Stoeckmann [Sun, 11 Jan 2026 15:33:16 +0000 (16:33 +0100)] 
lib/commonio.c: Use unpredictable temporary names

Make sure that an attacker with sufficient privileges cannot simply
create a file with expected temporary name to retrieve content of
previous and/or future database.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
45 hours agolib/commonio.c: Unlink backup file on error
Tobias Stoeckmann [Sun, 11 Jan 2026 22:18:48 +0000 (23:18 +0100)] 
lib/commonio.c: Unlink backup file on error

It doesn't make sense to keep a file around if it's not even a proper
backup.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days agolib/shadowlog_internal.h: Hide shadow_progname
Tobias Stoeckmann [Sun, 11 Jan 2026 11:34:46 +0000 (12:34 +0100)] 
lib/shadowlog_internal.h: Hide shadow_progname

Accessing and setting shadow_progname is not as straight-forward as it
might seem due to the way of linking libshadow_la with libsubid and
programs.

Enforce the usage of log_get_progname to make this less messy.

With last entry of shadowlog_internal.h gone, remove the file entirely.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days agolib/shadowlog_internal.h: Drop shadow_logfd
Tobias Stoeckmann [Sun, 11 Jan 2026 11:28:46 +0000 (12:28 +0100)] 
lib/shadowlog_internal.h: Drop shadow_logfd

Accessing this variable directly is a recipe for disaster, because
binaries and libraries can have different versions in them due to how
libshadow_la linking is performed.

Make sure that at least NULL check is always performed by calling the
proper getter function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days agolibsubid: Avoid shadow_logfd as variable name
Tobias Stoeckmann [Sun, 11 Jan 2026 11:28:02 +0000 (12:28 +0100)] 
libsubid: Avoid shadow_logfd as variable name

A global shadow_logfd variable exists, so this effectively shadows it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days agoRemove unused `logoutd` utility
Iker Pedrosa [Mon, 25 Aug 2025 07:58:51 +0000 (09:58 +0200)] 
Remove unused `logoutd` utility

Link: <https://github.com/shadow-maint/shadow/issues/999>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 days agosrc/: Properly set up libsubid tools
Tobias Stoeckmann [Sun, 11 Jan 2026 11:46:24 +0000 (12:46 +0100)] 
src/: Properly set up libsubid tools

Do not call any shadowlog functions directly from program source files
which are also linked with libsubid.

Both, the program and the library, will have their own version of the
static variables within shadowlog.c and thus would have different
logging mechanisms.

Use subid_init instead.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Use exit instead of _exit in kill_child
Tobias Stoeckmann [Fri, 9 Jan 2026 16:49:39 +0000 (17:49 +0100)] 
su: Use exit instead of _exit in kill_child

Since this is no signal handler anymore, allow regular exit routine to
flush stderr etc.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Mark kill_child with NORETURN
Tobias Stoeckmann [Fri, 9 Jan 2026 16:34:20 +0000 (17:34 +0100)] 
su: Mark kill_child with NORETURN

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Remove dead code
Tobias Stoeckmann [Fri, 9 Jan 2026 16:32:37 +0000 (17:32 +0100)] 
su: Remove dead code

The pid_child is never 0 when reaching kill_child, since kill_child
is called within an if-block which checks explicitly for pid_child not
being 0.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Turn pid_child into local variable
Tobias Stoeckmann [Fri, 9 Jan 2026 16:30:25 +0000 (17:30 +0100)] 
su: Turn pid_child into local variable

The pid_child can be passed into kill_child, since it is no signal
handler anymore.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Drop unneeded char buffers
Tobias Stoeckmann [Fri, 9 Jan 2026 16:28:53 +0000 (17:28 +0100)] 
su: Drop unneeded char buffers

Since kill_child is no signal handler any longer, it is safe to call the
gettext macros directly and only when needed.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Kill child outside of signal handler
Tobias Stoeckmann [Fri, 9 Jan 2026 16:23:38 +0000 (17:23 +0100)] 
su: Kill child outside of signal handler

This simplifies the alarm handler to just set a volatile
sig_atomic_t like catch_signals does, which makes the handler way
easier to review.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Turn caught into volatile sig_atomic_t
Tobias Stoeckmann [Fri, 9 Jan 2026 16:20:07 +0000 (17:20 +0100)] 
su: Turn caught into volatile sig_atomic_t

Only these shared variables can be safely written to by signal handlers.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agosu: Fix typos in comment
Tobias Stoeckmann [Fri, 9 Jan 2026 16:19:57 +0000 (17:19 +0100)] 
su: Fix typos in comment

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 days agolib/motd.c: Remove unused include
Tobias Stoeckmann [Sat, 10 Jan 2026 23:25:07 +0000 (00:25 +0100)] 
lib/motd.c: Remove unused include

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6 days agovipw: set SIGCHLD before fork
Tobias Stoeckmann [Wed, 7 Jan 2026 16:34:36 +0000 (17:34 +0100)] 
vipw: set SIGCHLD before fork

It could happen that, if SIGCHLD was set to SIG_IGN before calling vipw,
the forked child is already gone before SIGCHLD is set to SIG_DFL after
the fork.

Prevent this race condition and also properly set up SIGCHLD for child
handling within the fork, even though system() should take care of that.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6 days agovipw: Use fmkomstemp for temporary file
Tobias Stoeckmann [Wed, 7 Jan 2026 16:39:42 +0000 (17:39 +0100)] 
vipw: Use fmkomstemp for temporary file

Avoid fixed and thus predictable temporary file names. Especially avoid
just opening already existing ones.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agoFix typos
Tobias Stoeckmann [Thu, 8 Jan 2026 19:02:01 +0000 (20:02 +0100)] 
Fix typos

Typos found with codespell

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoconfigure.ac: Drop libattr linking
Tobias Stoeckmann [Sat, 3 Jan 2026 18:03:32 +0000 (19:03 +0100)] 
configure.ac: Drop libattr linking

The libattr dependency is no longer needed.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agolib/copydir.c: Drop reset_selinux
Tobias Stoeckmann [Sat, 3 Jan 2026 17:55:55 +0000 (18:55 +0100)] 
lib/copydir.c: Drop reset_selinux

The reset_selinux flag is always true, so it can be removed.
Remove all functions which are not used anymore as well.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agolib/chkhash.c: is_valid_hash(): Accept '*' as the hash
Alejandro Colomar [Wed, 7 Jan 2026 22:44:26 +0000 (23:44 +0100)] 
lib/chkhash.c: is_valid_hash(): Accept '*' as the hash

This is widely accepted as an invalid hash, to remove password access
for an account (that is, no passwords will match the "hash").

Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e")
Closes: <https://github.com/shadow-maint/shadow/issues/1483>
Closes: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1124835>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Chris Hofstaedtler <zeha@debian.org>
Cc: vinz <mmpx09@protonmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 days agolib/chkhash.c: is_valid_hash(): Accept a leading '!'
Alejandro Colomar [Wed, 7 Jan 2026 22:39:53 +0000 (23:39 +0100)] 
lib/chkhash.c: is_valid_hash(): Accept a leading '!'

A leading '!' means that the account is locked.

Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e")
Link: <https://github.com/shadow-maint/shadow/issues/1483>
Link: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1124835>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Chris Hofstaedtler <zeha@debian.org>
Cc: vinz <mmpx09@protonmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
10 days agoman/chage.1: Drop empty configuration section
Tobias Stoeckmann [Mon, 5 Jan 2026 17:11:06 +0000 (18:11 +0100)] 
man/chage.1: Drop empty configuration section

If TCB is not in use, the whole configuration section is a stub,
containing no useful information. Make it conditional so it
disappears if TCB is not in use.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
11 days agoman/groupmems: Fix grammar
Tobias Stoeckmann [Sun, 4 Jan 2026 17:26:50 +0000 (18:26 +0100)] 
man/groupmems: Fix grammar

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agosrc/useradd: Support config for creating home dirs as Btrfs subvolumes
Hadi Chokr [Fri, 12 Dec 2025 10:18:06 +0000 (11:18 +0100)] 
src/useradd: Support config for creating home dirs as Btrfs subvolumes

Closes: #1162
Co-authored-by: Neal Gompa <ngompa@velocitylimitless.com>
Signed-off-by: Hadi Chokr <hadichokr@icloud.com>
Signed-off-by: Neal Gompa <ngompa@velocitylimitless.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
2 weeks agotests/system/tests/test_groupmod.py: add test for groupmod -U with user list
Iker Pedrosa [Tue, 23 Dec 2025 08:51:56 +0000 (09:51 +0100)] 
tests/system/tests/test_groupmod.py: add test for groupmod -U with user list

Add comprehensive test for the groupmod -U option when provided with a
list of users to set group membership. This test verifies:

- Setting initial group membership with multiple users
- Proper membership verification in both group and gshadow entries
- Updating group membership by modifying the user list
- Correct handling of membership changes in group databases

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 weeks agotests/system/framework/utils/tools.py: fix GShadowEntry
Iker Pedrosa [Tue, 23 Dec 2025 09:26:33 +0000 (10:26 +0100)] 
tests/system/framework/utils/tools.py: fix GShadowEntry

GShadowEntry administrators and members represent a list of usernames,
not a single string. Thus, set them to `list[str]`. This fixes type
safety and clarifies the expected data structure.

Fixes: 458700b5d670 (2025-09-10; "tests/system/framework/: fix Python linter issues")
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 weeks agoRelease 4.19.0 1459/head 4.19.0
Alejandro Colomar [Mon, 29 Dec 2025 12:38:53 +0000 (13:38 +0100)] 
Release 4.19.0

Breaking changes:

-  Remove support for escaped newlines in configuration files.
   It never worked correctly.
   b0a7ce58b924 (2025-12-05; "lib/, po/: Remove fgetsx() and fputsx()")

-  Some user names and group names are too dangerous and are rejected,
   even with --badname.
   25aea7422615 (2025-12-25; "lib/chkname.c, src/: Strictly disallow really bad names")

Future breaking changes:

-  SHA512 and SHA256 will be supported unconditionally in the next
   release.  The build-time flag '--with-sha-crypt' will be removed.
   See <https://github.com/shadow-maint/shadow/pull/1452>.

Support:

-  Several years ago, there were talks about deprecating su(1) and
   login(1), back when this project was maintained as part of Debian.
   However, nothing was clearly stated, and there were doubts about the
   status of these programs.  Let's clarify them now.

   Our implementations of su(1) and login(1) are fully supported, and we
   don't have any plans to remove them.  They are NOT deprecated.
   See <https://github.com/shadow-maint/shadow/issues/464>.

Deprecations:

-  groupmems(8)
The program will be removed in a future release.
See <https://github.com/shadow-maint/shadow/issues/1343>.

-  logoutd(8)
The program will be removed in the next release.
See <https://github.com/shadow-maint/shadow/issues/999>,
and <https://github.com/shadow-maint/shadow/pull/1344>.

-  DES
This hashing algorithm has been deprecated for a long time,
and support for it will be removed in a future release.
See <https://github.com/shadow-maint/shadow/pull/1456>

-  MD5
This hashing algorithm has been deprecated for a long time,
and support for it will be removed in a future release.
See <https://github.com/shadow-maint/shadow/pull/1457>

-  login.defs(5): MD_CRYPT_ENAB
This feature had been deprecated for decades.  It will be
removed in a future release.
The command-line equivalents (-m, --md5) of this feature in
chpasswd(8) and chgpasswd(8) will also be removed in a future
release.
See <https://github.com/shadow-maint/shadow/pull/1455>.

-  login.defs(5): PASS_MAX_LEN
This feature is ignored except for DES.  Once DES is removed,
it makes no sense keeping it.  It may be removed in a future
release.

-  Password aging
Scientific research shows that periodic password expiration
leads to predictable password patterns, and that even in a
theoretical scenario where that wouldn't happen the gains in
security are mathematically negligible.
<https://people.scs.carleton.ca/~paulv/papers/expiration-authorcopy.pdf>

Modern security standards, such as NIST SP 800-63B-4 in the USA,
prohibit periodic password expiration.
<https://pages.nist.gov/800-63-4/sp800-63b.html#passwordver>
<https://pages.nist.gov/800-63-FAQ/#q-b05>
<https://www.ncsc.gov.uk/collection/passwords/updating-your-approach#PasswordGuidance:UpdatingYourApproach-Don'tenforceregularpasswordexpiry>

To align with these, we're deprecating the ability to
periodically expire passwords.  The specifics and long-term
roadmap are currently being discussed, and we invite feedback
from users, particularly from those in regulated environments.
See <https://github.com/shadow-maint/shadow/pull/1432>.

This deprecation includes the following programs and features:

expiry(1)
chage(1):
-I,--inactive (also the interactive version)
-m,--mindays (also the interactive version)
-M,--maxdays (also the interactive version)
-W,--warndays (also the interactive version)
passwd(1):
-k,--keep-tokens
-n,--mindays
-x,--maxdays
-i,--inactive
-w,--warndays
useradd(8):
-f,--inactive
usermod(8):
-f,--inactive
login.defs(5):
PASS_MIN_DAYS
PASS_MAX_DAYS
PASS_WARN_AGE
/etc/default/useradd:
INACTIVE
shadow(5):
sp_lstchg: Restrict to just the values 0 and empty.
sp_min
sp_max
sp_warn
sp_inact

We recognize that many users operate in environments with
regulatory or contractual requirements that still mandate
password aging.  To minimize disruption, these features will
remain functional for a significant period.  However, we
encourage administrators to review their internal policies,
talk to their regulators if appropriate, and participate in the
roadmap discussion linked above.

Co-authored-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 weeks agopo/: Update
Alejandro Colomar [Tue, 30 Dec 2025 13:25:16 +0000 (14:25 +0100)] 
po/: Update

I don't know what this commit does, to be honest.  I just
did './autogen.sh && make && make dist' and committed the
changes to .po files.  Why?  I don't know.

BTW, I kept out some changes that were actually bad.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 weeks agopo/shadow.pot: Update
Alejandro Colomar [Mon, 29 Dec 2025 22:37:18 +0000 (23:37 +0100)] 
po/shadow.pot: Update

I don't know what this commit does, to be honest.  I just
did './autogen.sh && make && make dist' and committed the
changes to .pot files.  Why?  I don't know.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 weeks agolib/: Use non-empty compound literals
Alejandro Colomar [Tue, 30 Dec 2025 15:17:55 +0000 (16:17 +0100)] 
lib/: Use non-empty compound literals

While the empty one is more correct, {0} will also work, and will
likely silence diagnostics in old compiler versions.

Empty compound literals are only supported in GCC since commit
gcc.git 14cfa01755a6 (2022-08-25; "c: Support C2x empty initializer braces")

Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 weeks agoAdd ubuntu-22.04 to the CI test matrix
Serge Hallyn [Tue, 30 Dec 2025 15:52:10 +0000 (09:52 -0600)] 
Add ubuntu-22.04 to the CI test matrix

we need to check against older compilers.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 weeks agoman/lastlog.8: Drop redundant closing brackets
Tobias Stoeckmann [Tue, 30 Dec 2025 11:52:35 +0000 (12:52 +0100)] 
man/lastlog.8: Drop redundant closing brackets

Only one opening bracket is used before two closing brackets are
encountered for "(--user)".

Drop redundant ones within the file.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoman/: Fix SELinux note formatting
Tobias Stoeckmann [Tue, 30 Dec 2025 11:11:33 +0000 (12:11 +0100)] 
man/: Fix SELinux note formatting

Use tab instead of spaces to comply with rest of files.

Fixes: 923aeac250d0 (2025-07-04; "man/: update `--root` flag with no SELinux support")
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agosg: Properly document synopsis and options
Tobias Stoeckmann [Sun, 28 Dec 2025 15:36:19 +0000 (16:36 +0100)] 
sg: Properly document synopsis and options

The usage message of sg and synopsis of its manual page diverged. The
difference was even noted in a comment, instead of fixing it.

Synchronize both, add information about hidden options and document
what they do.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agosg: group is not optional
Tobias Stoeckmann [Mon, 29 Dec 2025 18:06:33 +0000 (19:06 +0100)] 
sg: group is not optional

The group argument is not optional, so do not specify it as such in the
manual page.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agosg: Fix grammar in documentation
Tobias Stoeckmann [Sun, 28 Dec 2025 15:34:54 +0000 (16:34 +0100)] 
sg: Fix grammar in documentation

Use "an" in front of sg due to its pronounciation. Also, start a comment
with capital letter in its first sentence to comply with other comments.

No functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agolib/, src/: Reduce scope of local variables
Alejandro Colomar [Sat, 13 Dec 2025 23:57:19 +0000 (00:57 +0100)] 
lib/, src/: Reduce scope of local variables

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 weeks agolib/, src/: Some empty lists have 0 elements, not 1 empty string
Alejandro Colomar [Sat, 13 Dec 2025 23:51:34 +0000 (00:51 +0100)] 
lib/, src/: Some empty lists have 0 elements, not 1 empty string

In general, empty fields in a CSV are errors.  However, in some cases,
we want to allow passing empty lists, and the way to encode that is as
an empty string.  This was accidentally broken in 4.17.0, when we
switched from using strtok(3) to strsep(3), without remembering to
special-case an empty CSV.

The bug affected directly groupadd(8) and groupmod(8).

The bug also affected the library function add_groups().  In systems
using PAM, that function is unused.  On systems without PAM, it is
called by the library function setup_uid_gid(), with the contents of the
"CONSOLE_GROUPS" configuration (login.defs) CSV string.

setup_uid_gid() is directly called by su(1) and login(1) on systems
without PAM.

setup_uid_gid() is also called by the library function expire().

expire() is directly called by expiry(1), su(1), and login(1).

This bug is a regression introduced in the release 4.17.0, and present
in the releases 4.17.{0..4} and 4.18.0.

Fixes: 90afe61003ef (2024-12-05; "lib/, src/: Use strsep(3) instead of strtok(3)")
Link: <https://github.com/shadow-maint/shadow/issues/1420>
Reported-by: Osark Vieira <https://github.com/osark084>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 weeks agolib/, src/: Add blocks
Alejandro Colomar [Mon, 22 Dec 2025 19:05:36 +0000 (20:05 +0100)] 
lib/, src/: Add blocks

This is in preparation for the following patch.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 weeks agotests/system/tests/test_groupadd.py: add test for groupadd -U with empty string
Iker Pedrosa [Mon, 15 Dec 2025 11:47:08 +0000 (12:47 +0100)] 
tests/system/tests/test_groupadd.py: add test for groupadd -U with empty string

Test verifies that groupadd -U '' correctly creates group with no
members.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 weeks agotests/system/tests/test_groupmod.py: add test for groupmod -U with empty string
Iker Pedrosa [Mon, 15 Dec 2025 11:42:46 +0000 (12:42 +0100)] 
tests/system/tests/test_groupmod.py: add test for groupmod -U with empty string

Test verifies that groupmod -U '' correctly clears group membership.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 weeks agolib/chkname.c, src/: Strictly disallow really bad names
Alejandro Colomar [Mon, 23 Dec 2024 10:06:33 +0000 (11:06 +0100)] 
lib/chkname.c, src/: Strictly disallow really bad names

Some names are bad, and some names are really bad.  '--badname' should
only allow the mildly bad ones, which we can handle.  Some names are too
bad, and it's not possible to deal with them.  Reject them
unconditionally.

-  A leading '-' is too dangerous.  It breaks things like execve(2), and
   almost every command.

-  Spaces are used for delimiting lists of users and groups.

-  '"' is special in many languages, including the shell.  Having it in
   user names would be unnecessarily dangerous.

-  '#' is used for delimiting comments in several of our config files.
   Having it in usernames could result in incorrect configuration files.

-  "'" is special in many languages, including the shell.  Having it in
   user names would be unnecessarily dangerous.

-  ',' is used for delimiting lists of users and groups.

-  '/' is used for delimiting files, and thus could result in incorrect
   handling of users and groups.

-  ':' is the main delimiter in /etc/shadow and /etc/passwd.

-  ';' is special in many languages, including the shell.  Having it in
   user names would be unnecessarily dangerous.

There are other characters that we should disallow, but they need more
research to make sure we don't introduce regressions.  This set should
be less problematic.

Acked-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Chris Hofstaedtler <zeha@debian.org>
Cc: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 weeks agouserdel: Fix syslog message
Tobias Stoeckmann [Tue, 23 Dec 2025 11:05:09 +0000 (12:05 +0100)] 
userdel: Fix syslog message

Actually log the user name as done with stderr message.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolib/run_part.c: Fix error message
Tobias Stoeckmann [Tue, 23 Dec 2025 11:04:23 +0000 (12:04 +0100)] 
lib/run_part.c: Fix error message

The failing function call was wait, not waitpid.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agochage: Remove unneeded xstrdup calls
Tobias Stoeckmann [Tue, 23 Dec 2025 11:32:02 +0000 (12:32 +0100)] 
chage: Remove unneeded xstrdup calls

Duplicating name and hash is not needed here, because duplication
occurs in spw_update. You can detect the small memory leak with
tools like valgrind.

More importantly though, if xstrdup fails, it calls exit. The
update_age function is in the "criticial section" between
open_files and close_files, though. Correct error handling would
require fail_exit to release the held locks.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agosrc/gpasswd.c: fix segfault in clean up callbacks
Iker Pedrosa [Fri, 19 Dec 2025 15:27:54 +0000 (16:27 +0100)] 
src/gpasswd.c: fix segfault in clean up callbacks

The gpasswd utility was segfaulting when cleanup functions were called
because these functions expect a pointer to `process_selinux` but was
being passed NULL. This caused a NULL pointer dereference.

This commits adds the pointer to `process_selinux` to clean up
functions making `gpasswd` consistent with other group utilities.

Reproduction steps:
$ useradd tuser
$ groupadd tuser
$ gpasswd -a tuser tgroup
Adding user tuser to group tgroup
Segmentation fault (core dumped)

Fixes: 4d431898bad8 (2025-10-07; "src/gpasswd.c: chroot or prefix SELinux file context")
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 weeks agolib/obscure.c: Introduce obscure_get_range
Tobias Stoeckmann [Fri, 19 Dec 2025 11:36:59 +0000 (11:36 +0000)] 
lib/obscure.c: Introduce obscure_get_range

Unify the retrieval of PASS_MIN_LEN and PASS_MAX_LEN for output
in passwd and actual checks.

Fixes wrong output for minimum password lengths if no such
restriction is configured: 5 is printed, 0 is in effect.

How to reproduce:

1. Use passwd compiled without PAM support
2. Do not specify PASS_MIN_LEN in login.defs
3. Run passwd as a user and enter your old password, then
   - you will see that 5 characters are expected
   - you can just press enter twice

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolib/obscure.c: Fix PASS_MIN_LEN -1 case
Tobias Stoeckmann [Fri, 19 Dec 2025 11:33:45 +0000 (11:33 +0000)] 
lib/obscure.c: Fix PASS_MIN_LEN -1 case

The getdef_num implementation allows -1 to be specified in login.defs.
In general, -1 should be treated the same way as "not specified". In
this case, casting -1 to size_t leads to every password being "too
short."

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agogshadow: Open audit socket after check_fds
Tobias Stoeckmann [Sat, 20 Dec 2025 17:25:03 +0000 (17:25 +0000)] 
gshadow: Open audit socket after check_fds

Protect gshadow the same way as newgrp.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agonewgrp, sg: Open audit socket after check_fds
Tobias Stoeckmann [Sat, 20 Dec 2025 16:46:18 +0000 (16:46 +0000)] 
newgrp, sg: Open audit socket after check_fds

The check_fds function is supposed to ensure that fds 0, 1, and 2 are
opened in a well-defined state, i.e. either they are already connected
to supposed input/output files or will be connected to /dev/null if not.

Opening the audit socket before checking the fds allows the audit socket
to get one of these numbers.

Avoid this by opening the audit socket after the check.

In general, this check is already covered by system libraries, but this
proof of concept works for root user. Note the different states of the
file descriptor 2.

In bash or another shell that interprets `2>&-` as closing stderr with
shadow + audit support, e.g. Arch Linux:
```
sg bin 'ls -l /proc/self/fd'
sg bin 'ls -l /proc/self/fd' 2>/dev/null
sg bin 'ls -l /proc/self/fd' 2>&-
```

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoetc/login.defs: Clarify PASS_MAX_LEN usage
Tobias Stoeckmann [Fri, 19 Dec 2025 12:15:00 +0000 (12:15 +0000)] 
etc/login.defs: Clarify PASS_MAX_LEN usage

The PASS_MAX_LEN option is only used with DES.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoPASS_MAX_LEN.xml: Explain PASS_MAX_LEN use cases
Tobias Stoeckmann [Fri, 19 Dec 2025 11:02:45 +0000 (11:02 +0000)] 
PASS_MAX_LEN.xml: Explain PASS_MAX_LEN use cases

The `PASS_MAX_LEN` is effectively only used for DES. Do not describe it
in a way that makes it sound like `MD_CRYPT_ENAB=yes` is required to
disable it. Any other `ENCRYPT_METHOD` disables it as well.

Also, even for DES, `PASS_MAX_LEN` requires `OBSCURE_CHECKS_ENAB` to
have any effect.

Even more, `PASS_MIN_LEN` and `PASS_MAX_LEN` are only used for
user passwords. Group passwords are not checked.

Note: All of this is actually true even if compiled with PAM if command
line arguments change root. But if compiled with PAM support, this
section is not added to manual pages... Since this is true for some
more files, it's not part of this commit.

Link to source files:
- lib/obscure.c line 133 stops further checks, including max length,
  if OBSCURE_CHECS_ENAB is not yes
- lib/obscure.c line 172 is only reached in case of DES
- src/passwd.c line 248 duplicates the check for output
- src/gpasswd.c has no reference to obscure

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoman/passwd.5.xml: Use sentences for descriptions
Tobias Stoeckmann [Fri, 19 Dec 2025 12:47:59 +0000 (12:47 +0000)] 
man/passwd.5.xml: Use sentences for descriptions

Even though this is technically no sentence, it stays in sync with the
other file descriptions this way.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agotests: Fix typos in comments
Tobias Stoeckmann [Fri, 19 Dec 2025 14:54:12 +0000 (14:54 +0000)] 
tests: Fix typos in comments

No functional change

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoFix documentation style
Tobias Stoeckmann [Fri, 19 Dec 2025 10:56:50 +0000 (10:56 +0000)] 
Fix documentation style

Always start a sentence with lowercase letter after 'Note:', 'Warning:',
etc. This unifies all occurrences.

No functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolib/, src/: Drop 10000 as infinity
Tobias Stoeckmann [Fri, 19 Dec 2025 12:50:46 +0000 (12:50 +0000)] 
lib/, src/: Drop 10000 as infinity

If password aging should not be performed, disable it properly. Just
specifying a "long enough time" is not infinity.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agopwunconv: Drop incorrect comment
Tobias Stoeckmann [Fri, 19 Dec 2025 12:50:01 +0000 (12:50 +0000)] 
pwunconv: Drop incorrect comment

Shadow password files do not necessarily need aging information.
Also, passwd has no aging information.

No conversion is performed, so drop the comment entirely.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agopasswd: Clarify password strength check comment
Tobias Stoeckmann [Fri, 19 Dec 2025 11:10:58 +0000 (11:10 +0000)] 
passwd: Clarify password strength check comment

- The total number of password change tries can be configured
- Except min length, password strength checks can be disabled
- Even the root user can have password strength checks...
- ... except in some cases (stdin, command line arguments)

In general, this code does not run for PAM, except root directory
is modified through command line arguments by root user.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoENCRYPT_METHOD.xml: Fix grammar
Tobias Stoeckmann [Fri, 19 Dec 2025 11:00:02 +0000 (11:00 +0000)] 
ENCRYPT_METHOD.xml: Fix grammar

Use singular in these cases.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agolib/, src/: Fix formatting
Tobias Stoeckmann [Tue, 16 Dec 2025 21:59:59 +0000 (22:59 +0100)] 
lib/, src/: Fix formatting

Fix places where spaces were used instead of tabs.

No functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agopasswd: Fix TOCTOU race condition (no PAM)
Tobias Stoeckmann [Tue, 16 Dec 2025 13:00:54 +0000 (14:00 +0100)] 
passwd: Fix TOCTOU race condition (no PAM)

The passwd tool checks if the password of a user may be changed before
locking the passwd/shadow files. This leaves a time window to perform
the same action twice (e.g. circumventing PASS_MIN_DAYS limit) or to
circumvent a locked password by an administrator.

Perform the check after the lock again. This keeps the behavior as it
is today for a user and also prevents the race condition.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agopasswd: Use fail_exit in check_password
Tobias Stoeckmann [Tue, 16 Dec 2025 12:58:54 +0000 (13:58 +0100)] 
passwd: Use fail_exit in check_password

Calling fail_exit here prepares an upcoming commit to reuse the
functions when databases have been locked.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agopasswd: check_password: Use shadow entry for logs
Tobias Stoeckmann [Tue, 16 Dec 2025 09:03:43 +0000 (10:03 +0100)] 
passwd: check_password: Use shadow entry for logs

Always use the name in shadow entry for logging. This reduces the
amount of data retrieved from password entry to bare minimum, i.e.
passing through into library call.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agopasswd: Unify (un)locking routines
Tobias Stoeckmann [Mon, 15 Dec 2025 16:08:05 +0000 (17:08 +0100)] 
passwd: Unify (un)locking routines

Make sure that passwd and shadow are always opened in the correct
order to avoid possible dead locks with other tools:

- Lock passwd first, then shadow
- Unlock shadow first, then passwd

The passwd utility may work without a shadow entry. In that case, it
operates on the passwd file. But to figure this out, the shadow file
must have been opened and thus locked already. Unconditionally open the
passwd file first, even though it's not needed most of the time.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agopasswd: Call fail_exit on pwd lock failure
Tobias Stoeckmann [Mon, 15 Dec 2025 16:06:00 +0000 (17:06 +0100)] 
passwd: Call fail_exit on pwd lock failure

At this point, shadow might be already locked if update_noshadow is
called as fallback within update_shadow. Make sure that unlock is
called before exit.

Fixes: 45c6603cc86c (2007-10-07; "[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agopasswd: Fix style
Tobias Stoeckmann [Mon, 15 Dec 2025 16:03:52 +0000 (17:03 +0100)] 
passwd: Fix style

No functional change

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agopasswd: Pass process_selinux flag directly
Tobias Stoeckmann [Mon, 15 Dec 2025 15:21:22 +0000 (16:21 +0100)] 
passwd: Pass process_selinux flag directly

No need to re-evaluate option_flags in functions. Unifies checks and
simplifies code.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agonewusers: Allow creation without aging information
Tobias Stoeckmann [Mon, 15 Dec 2025 09:22:17 +0000 (10:22 +0100)] 
newusers: Allow creation without aging information

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>
4 weeks agonewusers: Add test for creation without aging
Tobias Stoeckmann [Mon, 15 Dec 2025 09:22:15 +0000 (10:22 +0100)] 
newusers: Add test for creation without aging

If PASS_MAX_DAYS is not set, newusers should not set max password age.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agolib/pwd2spwd.c: Set no aging information
Tobias Stoeckmann [Mon, 15 Dec 2025 09:45:41 +0000 (10:45 +0100)] 
lib/pwd2spwd.c: Set no aging information

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>
4 weeks agolib/pwd2spwd.c: Simplify style
Tobias Stoeckmann [Mon, 15 Dec 2025 09:41:11 +0000 (10:41 +0100)] 
lib/pwd2spwd.c: Simplify style

No need for a nested block here.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agolib/xgetXXbyYY.c: include stdint.h for SIZE_MAX
Mike Gilbert [Sat, 13 Dec 2025 20:07:02 +0000 (15:07 -0500)] 
lib/xgetXXbyYY.c: include stdint.h for SIZE_MAX

Fixes build failure:
```
In file included from xgetgrnam.c:40:
xgetXXbyYY.c: In function ‘xgetgrnam’:
xgetXXbyYY.c:83:31: error: ‘SIZE_MAX’ undeclared (first use in this function)
   83 |                 if (length == SIZE_MAX) {
      |                               ^~~~~~~~
```

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
5 weeks agosrc/chsh.c: add argument for fail_exit()
Iker Pedrosa [Tue, 9 Dec 2025 11:10:33 +0000 (12:10 +0100)] 
src/chsh.c: add argument for fail_exit()

Fixes: 374ca05c282f (2025-10-07; "src/chsh.c: SELinux file context for fail_exit()")
Reported-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
5 weeks agoupdated Dutch translation
Frans Spiesschaert [Sun, 7 Dec 2025 22:33:09 +0000 (23:33 +0100)] 
updated Dutch translation

5 weeks ago(pre-)Release 4.19.0-rc1 2025-12-07/4.19.0-rc1 1411/head 4.19.0-rc1
Serge Hallyn [Sun, 7 Dec 2025 16:08:19 +0000 (10:08 -0600)] 
(pre-)Release 4.19.0-rc1

First pre-release of 'herve', 4.19.0

Signed-off-by: Serge Hallyn <serge@hallyn.com>
5 weeks agolib/tcbfuncs.c: rmdir_leading(): Create string just once
Alejandro Colomar [Sat, 16 Nov 2024 21:20:16 +0000 (22:20 +0100)] 
lib/tcbfuncs.c: rmdir_leading(): Create string just once

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/tcbfuncs.c: rmdir_leading(): Constify input
Alejandro Colomar [Sat, 16 Nov 2024 17:16:40 +0000 (18:16 +0100)] 
lib/tcbfuncs.c: rmdir_leading(): Constify input

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/search/: lsearch_T(): Don't return anything
Alejandro Colomar [Mon, 17 Nov 2025 19:50:31 +0000 (20:50 +0100)] 
lib/search/: lsearch_T(): Don't return anything

We don't use this value.  This silences a diagnostic about the unused
return value.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Rename XCALLOC() => xcalloc_T()
Alejandro Colomar [Sat, 15 Nov 2025 21:12:22 +0000 (22:12 +0100)] 
lib/: Rename XCALLOC() => xcalloc_T()

The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Rename CALLOC() => calloc_T()
Alejandro Colomar [Sat, 15 Nov 2025 21:08:15 +0000 (22:08 +0100)] 
lib/: Rename CALLOC() => calloc_T()

The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Rename XMALLOC() => xmalloc_T()
Alejandro Colomar [Sat, 15 Nov 2025 21:02:33 +0000 (22:02 +0100)] 
lib/: Rename XMALLOC() => xmalloc_T()

The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Rename MALLOC() => malloc_T()
Alejandro Colomar [Sat, 15 Nov 2025 21:01:20 +0000 (22:01 +0100)] 
lib/: Rename MALLOC() => malloc_T()

The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Rename XREALLOC() => xrealloc_T()
Alejandro Colomar [Sat, 15 Nov 2025 20:58:10 +0000 (21:58 +0100)] 
lib/: Rename XREALLOC() => xrealloc_T()

The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Rename REALLOC() => realloc_T()
Alejandro Colomar [Sat, 15 Nov 2025 20:56:34 +0000 (21:56 +0100)] 
lib/: Rename REALLOC() => realloc_T()

The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/, src/: Rename REALLOCF() => reallocf_T()
Alejandro Colomar [Sat, 15 Nov 2025 20:47:56 +0000 (21:47 +0100)] 
lib/, src/: Rename REALLOCF() => reallocf_T()

The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/alloc/: REALLOC[F](): Move _Generic(3) to separate line
Alejandro Colomar [Fri, 14 Nov 2025 00:50:11 +0000 (01:50 +0100)] 
lib/alloc/: REALLOC[F](): Move _Generic(3) to separate line

This should be more readable.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Use compound literals to avoid casts
Alejandro Colomar [Fri, 14 Nov 2025 01:29:16 +0000 (02:29 +0100)] 
lib/: Use compound literals to avoid casts

Casts are unsafe.

Compound literals also have the ability of converting values, but they
don't have the unwanted effects on safety --casts disable most useful
diagnostics--.

Compound literals are lvalues, which means their address can be taken,
and they can also be assigned to.  To avoid this, we force lvalue
conversion through a statement expression.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/alloc/: reallocarray[f]_(): Add helper macros to handle n?:1
Alejandro Colomar [Sat, 15 Nov 2025 20:33:21 +0000 (21:33 +0100)] 
lib/alloc/: reallocarray[f]_(): Add helper macros to handle n?:1

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/gshadow.c: fgetsgent(): Don't use static variables
Alejandro Colomar [Mon, 22 Jul 2024 17:34:21 +0000 (19:34 +0200)] 
lib/gshadow.c: fgetsgent(): Don't use static variables

BTW, getline(3) says we are responsible for free(3)ing the buffer on
error.

Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/: Use getline(3) instead of its pattern
Alejandro Colomar [Mon, 22 Jul 2024 11:46:32 +0000 (13:46 +0200)] 
lib/: Use getline(3) instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 weeks agolib/, po/: Remove fgetsx() and fputsx()
Alejandro Colomar [Sun, 21 Jul 2024 16:40:25 +0000 (18:40 +0200)] 
lib/, po/: Remove fgetsx() and fputsx()

It seems they never worked correctly.  Let's keep it simple and remove
support for escaped newlines.

Closes: <https://github.com/shadow-maint/shadow/issues/1055>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>