3860 Commits

Author SHA1 Message Date
Serge Hallyn
b23a5823bc release 4.17.4
Signed-off-by: Serge Hallyn <serge@hallyn.com>
4.17.4
2025-03-19 14:00:22 -05:00
Alejandro Colomar
d2d89a8e0a 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>
2025-03-04 00:08:15 +01:00
Alejandro Colomar
da7d4ed898 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>
2025-03-04 00:08:15 +01:00
Alejandro Colomar
55d73ed336 lib/sizeof.h: ssizeof(): Add signed variant of sizeof
Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-03-04 00:08:15 +01:00
Alejandro Colomar
d2554790c0 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>
2025-03-04 00:08:15 +01:00
Alejandro Colomar
df4125ec67 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>
2025-03-04 00:08:15 +01:00
Michael Vetter
d908e29411 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.
2025-03-03 20:08:41 +01:00
Alejandro Colomar
7a16663233 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>
2025-03-03 10:21:31 +01:00
Iker Pedrosa
8dfe21f592 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>
2025-03-03 10:06:48 +01:00
Iker Pedrosa
9987db9b52 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>
2025-03-03 10:06:48 +01:00
Iker Pedrosa
133ee47f31 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>
2025-03-03 10:06:48 +01:00
Alejandro Colomar
7a0f24f8d0 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>
2025-03-02 16:08:19 -06:00
Alejandro Colomar
641669f945 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>
2025-03-02 16:08:19 -06:00
Alejandro Colomar
cb266e7e0f src/chfn.c: Use stpsep() instead of its pattern
Tested-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-03-02 16:08:19 -06:00
Alejandro Colomar
b74c7c5058 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>
2025-03-02 16:08:19 -06:00
Chris Hofstaedtler
f9c2096c0b 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>
2025-03-02 07:59:56 +01:00
Alejandro Colomar
00c78bfab3 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>
2025-03-01 22:11:46 -06:00
Chris Hofstaedtler
bee77ffc29 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>
2025-02-25 20:01:37 +01:00
Alejandro Colomar
dfb2fa3c6e 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>
2025-02-25 10:09:47 +01:00
Serge Hallyn
d3fa0ba5b8 Release 4.17.3
Signed-off-by: Serge Hallyn <serge@hallyn.com>
4.17.3
2025-02-24 08:12:25 -06:00
Chris Hofstaedtler
40bb89b6a4 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>
2025-02-21 08:27:04 +01:00
Alejandro Colomar
77eb67d4a8 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>
2025-02-16 16:12:16 -06:00
Alejandro Colomar
79142cd281 lib/string/ctype/strisascii/: strisdigit(): Add function
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 16:12:16 -06:00
Alejandro Colomar
3cba5e2e1c 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>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
887e77d52a lib/basename.c: Basename(): Use stprcspn() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
a0d4ea3bec 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>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
872de49dcf lib/string/strspn/, lib/, src/: Move *spn() APIs to separate subdir
This provides a better organization.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
c2a634efa7 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>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
7936241f42 src/useradd.c: Use !strcaseeq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-15 10:26:50 -06:00
Alejandro Colomar
5e362305e6 lib/, src/: Use strcaseeq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-15 10:26:50 -06:00
Alejandro Colomar
224466f603 lib/string/strcmp/: strcaseeq(): Add function
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-15 10:26:50 -06:00
Marc Haber
68c3ac04e6 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>
2025-02-09 09:00:46 -06:00
Alejandro Colomar
2e47f4dd5f 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>
2025-02-08 22:08:06 -06:00
Alejandro Colomar
929d3e18cc src/useradd.c: create_home(): Use !streq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:47:21 -06:00
Alejandro Colomar
9a24e88482 lib/chkname.c: is_valid_name(): Use streq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:47:21 -06:00
Alejandro Colomar
a8dd818ba4 configure.ac, lib/: Use __has_include(<gshadow.h>) instead of HAVE_GSHADOW_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
9eea4bc9cf 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>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
7d992f16b4 configure.ac, lib/: Use __has_include(<sys/capability.h>) instead of HAVE_SYS_CAPABILITY_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
f50a39e8f9 lib/idmapping.c: Unconditionally include <sys/prctl.h>
It's a widely available header.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
d662b48e72 lib/: Use __has_include(<security/openpam.h>) instead of HAVE_SECURITY_OPENPAM_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
2ed8220835 lib/: Use __has_include(<security/pam_misc.h>) instead of HAVE_SECURITY_PAM_MISC_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
0dcce8ea4b configure.ac, lib/: Use __has_include(<sys/random.h>) instead of HAVE_SYS_RANDOM_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
87ba6c317e configure.ac, lib/: Use __has_include(<crypt.h>) instead of HAVE_CRYPT_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
2a583e945d lib/, src/: motd(): Report errors instead of exiting from library code
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:22:10 -06:00
Alejandro Colomar
a747264bfb lib/motd.c: motd(): Invert logic to reduce indentation
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:22:10 -06:00
Alejandro Colomar
c2d14e33f7 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>
2025-02-05 16:58:10 +01:00
Alejandro Colomar
6e8d7bf470 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>
2025-02-05 16:58:10 +01:00
Alejandro Colomar
d4ca9fdcf9 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>
2025-02-05 16:58:10 +01:00
Todd C. Miller
3b12ab7e29 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>
2025-01-26 14:59:43 +01:00
Alejandro Colomar
1d7dfa0a7b lib/, src/: Use agetgroups() instead of its pattern
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00