]>
git.ipfire.org Git - thirdparty/shadow.git/log
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
Serge Hallyn [Mon, 23 Jun 2025 15:45:31 +0000 (10:45 -0500)]
Pre-release 4.18.0-rc2
Let's do one quick prerelease before we release 4.18 tomorrow.
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Alejandro Colomar [Fri, 13 Jun 2025 11:49:19 +0000 (13:49 +0200)]
contrib/: Burn it all
Closes: <https://github.com/shadow-maint/shadow/issues/1273>
Cc: Chris Hofstaedtler <zeha@debian.org>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Dominika Borges [Sun, 23 Mar 2025 18:54:31 +0000 (19:54 +0100)]
man/: wfix usermod inactive
Dominika Borges [Sun, 23 Mar 2025 18:29:39 +0000 (19:29 +0100)]
man/: wfix usermod expiredate
Dominika Borges [Sun, 23 Mar 2025 18:02:50 +0000 (19:02 +0100)]
man/: wfix useradd expiredate
Dominika Borges [Sun, 23 Mar 2025 17:58:28 +0000 (18:58 +0100)]
man/: wfix useradd inactive
Dominika Borges [Wed, 19 Mar 2025 15:28:34 +0000 (16:28 +0100)]
man: Update doc style of passwd man page
Dominika Borges [Wed, 19 Mar 2025 14:58:54 +0000 (15:58 +0100)]
man: Update doc style in shadow man page
Dominika Borges [Fri, 21 Mar 2025 14:43:25 +0000 (15:43 +0100)]
man/: wfix
Dominika Borges [Wed, 19 Mar 2025 14:25:32 +0000 (15:25 +0100)]
man: Update chage -d -E options
Serge Hallyn [Sun, 8 Jun 2025 13:54:50 +0000 (08:54 -0500)]
Pre-release 4.18.0-rc1
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Samuel Thibault [Sat, 7 Jun 2025 16:06:21 +0000 (18:06 +0200)]
configure: Fix typo
The test was about lastlog, not subids
Fixes: 1bdcfa8d3710 (2023-07-15; "lastlog: stop building by default")
Samuel Thibault [Sat, 22 Feb 2025 10:22:48 +0000 (11:22 +0100)]
lib/defines.h: PATH_MAX/MAXHOSTNAMELEN: define when not set by OS
E.g. GNU/Hurd does not define such limitations. Let "defines.h"
provide some good-enough value.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Alejandro Colomar [Sat, 7 Dec 2024 01:02:07 +0000 (02:02 +0100)]
lib/: Use xastrsep2ls() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 00:59:57 +0000 (01:59 +0100)]
lib/string/strtok/: xastrsep2ls(): Add function
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 00:34:41 +0000 (01:34 +0100)]
lib/sgetgrent.c: list(): Explicitly free(3) at the start of the function
This makes it clear we wipe anything that was in the buffer.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 00:15:12 +0000 (01:15 +0100)]
lib/string/strtok/: astrsep2ls(): Add function
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Dec 2024 20:21:24 +0000 (21:21 +0100)]
lib/: Use STRSEP2ARR() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Dec 2024 23:51:14 +0000 (00:51 +0100)]
lib/: Use strsep2arr() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Dec 2024 22:32:03 +0000 (23:32 +0100)]
lib/port.c: getportent(): Use STRSEP2ARR() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Dec 2024 21:03:48 +0000 (22:03 +0100)]
lib/port.c: Use STRSEP2LS() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 8 Feb 2025 12:00:22 +0000 (13:00 +0100)]
lib/list.c: Use strsep2ls() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Dec 2024 21:00:43 +0000 (22:00 +0100)]
lib/string/strtok/: strsep2ls(), STRSEP2LS(): Add APIs
This API set implements another usual loop around strsep(3).
This one implements a loop where we are interested in an arbitrary
number of fields. For that, a NULL terminator is added at the end.
That is commonly referred to as "list".
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Dec 2024 20:15:10 +0000 (21:15 +0100)]
lib/string/strtok/: strsep2arr(), STRSEP2ARR(): Add APIs
This API set implements the usual loop around strsep(3).
This one implements a loop where we are interested in an exact number of
fields. I'll add another API set, strsep2ls() and STRSEP2LS(), which
will add a NULL terminator, for arbitrary numbers of fields.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Jun 2025 14:15:07 +0000 (16:15 +0200)]
src/newusers.c: Fix off-by-one benign bug in array declaration
This array is only ever used as an array of 7.
alx@devuan:/srv/alx/src/shadow/shadow/master$ sed_rm_ccomments()
{
perl -p -e 's%/\*.*?\*/%%g' \
|sed -E '\%/\*%, \%\*/% {\%(\*/|/\*)%!d}' \
|sed -E '\%/\*% {s%/\*.*%%; n; s%.*\*/%%;}' \
|sed -E '\%/\*% {s%/\*.*%%; n; s%.*\*/%%;}' \
|sed 's%//.*%%';
}
alx@devuan:/srv/alx/src/shadow/shadow/master$ cat src/newusers.c | grepc main | sed_rm_ccomments | grep -nT 'n\?fields\(\[.*]\)\?'
4: char *fields[8];
5: int nfields;
59: for (cp = buf, nfields = 0; nfields < 7; nfields++) {
60: fields[nfields] = strsep(&cp, ":");
64: if (nfields != 6) {
72: pw = pw_locate (fields[0]);
74: if (NULL == pw && getpwnam(fields[0]) != NULL) {
77: Prog, fields[0]);
81: if (NULL == pw && get_user_id(fields[2], &uid) != 0) {
91: && (add_group (fields[0], fields[3], &gid, uid) != 0)) {
101: && (add_user (fields[0], uid, gid) != 0)) {
110: pw = pw_locate (fields[0]);
114: Prog, line, fields[0], pw_dbname ());
132: usernames[nusers-1] = xstrdup(fields[0]);
133: passwords[nusers-1] = xstrdup(fields[1]);
135: if (add_passwd (&newpw, fields[1]) != 0) {
141: if (!streq(fields[4], "")) {
142: newpw.pw_gecos = fields[4];
145: if (!streq(fields[5], "")) {
146: newpw.pw_dir = fields[5];
149: if (!streq(fields[6], "")) {
150: newpw.pw_shell = fields[6];
153: if ( !streq(fields[5], "")
195: if (is_sub_uid && want_subuids() && !local_sub_uid_assigned(fields[0])) {
205: if (sub_uid_add(fields[0], sub_uid_start, sub_uid_count) == 0)
216: if (is_sub_gid && want_subgids() && !local_sub_gid_assigned(fields[0])) {
225: if (sub_gid_add(fields[0], sub_gid_start, sub_gid_count) == 0) {
alx@devuan:/srv/alx/src/shadow/shadow/master$ cat src/newusers.c | grepc main | sed_rm_ccomments | grep -nTo 'n\?fields\(\[.*]\)\?'
4: fields[8]
5: nfields
59: nfields
59: nfields
59: nfields
60: fields[nfields]
64: nfields
72: fields[0]
74: fields[0]
77: fields[0]
81: fields[2]
91: fields[0], fields[3]
101: fields[0]
110: fields[0]
114: fields[0]
132: fields[0]
133: fields[1]
135: fields[1]
141: fields[4]
142: fields[4]
145: fields[5]
146: fields[5]
149: fields[6]
150: fields[6]
153: fields[5]
195: fields[0]
205: fields[0]
216: fields[0]
225: fields[0]
Fixes: 45c6603cc86c (2007-10-07; "[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Link: <https://github.com/shadow-maint/shadow/pull/1155#discussion_r2132261260>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 22 Feb 2025 13:47:22 +0000 (14:47 +0100)]
lib/get_pid.c: pid_t is a signed integer
Print it with "%d".
Acked-by: Lukas Slebodnik <lslebodn@fedoraproject.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 6 Jun 2025 13:45:15 +0000 (15:45 +0200)]
lib/get_pid.c: Use PATH_MAX instead of a magic number
Acked-by: Lukas Slebodnik <lslebodn@fedoraproject.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Jan 2025 01:14:16 +0000 (02:14 +0100)]
lib/tcbfuncs.c: shadowtcb_path_rel(): Centralize error handling
All these 3 branches have a compatible return value, which we can check
at once after the branches.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Jan 2025 00:47:16 +0000 (01:47 +0100)]
lib/tcbfuncs.c: shadowtcb_path_rel(): Use strdup(3) instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 1 Jan 2025 14:56:08 +0000 (15:56 +0100)]
lib/, src/: Remove unnecessary variables
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 1 Jan 2025 13:41:18 +0000 (14:41 +0100)]
lib/, src/: Use xaprintf() instead of xasprintf()
This makes some temporary variables unnecessary. They'll be removed in
the next commit.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 1 Jan 2025 13:07:40 +0000 (14:07 +0100)]
lib/string/sprintf/, tests/unit/: Transform x[v]asprintf() into x[v]aprintf()
Wrap [v]aprintf() instead of [v]asprintf(3).
Repurpose x[v]asprintf()'s tests to test x[v]aprintf().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 1 Jan 2025 14:53:19 +0000 (15:53 +0100)]
lib/: Use vaprintf() instead of vasprintf(3)
Alejandro Colomar [Wed, 1 Jan 2025 13:02:08 +0000 (14:02 +0100)]
lib/, src/: Use aprintf() instead of asprintf(3)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 1 Jan 2025 12:52:09 +0000 (13:52 +0100)]
lib/tcbfuncs.c: Split conditionals
This is in preparation for the next commit.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 1 Jan 2025 12:10:35 +0000 (13:10 +0100)]
lib/string/sprintf/: [v]aprintf(): Add functions
These functions are just like [v]asprintf(3), but simpler.
They return the newly allocated memory, which allows us to use the
[[gnu::malloc(free)]] attribute, which enhances static analysis.
They also omit the length, which we don't care about at all.
As a curiosity, Plan9 seems to provide this same API, under the name
smprint(3).
Link: <https://9fans.github.io/plan9port/man/man3/print.html>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 4 Dec 2024 12:47:37 +0000 (13:47 +0100)]
lib/fs/mkstemp/: mkostemp(): Split API from fmkomstemp()
This reduces the complexity of fmkomstemp().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 4 Dec 2024 12:33:58 +0000 (13:33 +0100)]
lib/fs/mkstemp/, src/: fmkomstemp(): Move function to separate file
And make it inline.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 28 May 2025 11:52:12 +0000 (13:52 +0200)]
lib/getdef.c: Use countof() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 26 May 2025 12:17:25 +0000 (14:17 +0200)]
lib/, src/: Move macros to "typetraits.h"
The macros that remain in "must_be.h" really belong in "typetraits.h".
Move them there, and remove "must_be.h".
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 May 2025 12:03:06 +0000 (14:03 +0200)]
autogen.sh, lib/: Replace must_be_array() by -Werror=sizeof-pointer-div
The error works as well as the magic macro, and we get cleaner code.
Plus, very soon we'll get the countof() operator from GCC 16 and
Clang 21, which doesn't even need this diagnostic to work safely.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 May 2025 11:58:05 +0000 (13:58 +0200)]
lib/sizeof.h: Define SIZEOF_ARRAY() in terms of countof()
This will allow us to eventually get rid of must_be_array(), once
we make sure countof() is safe.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 May 2025 11:33:37 +0000 (13:33 +0200)]
lib/, src/, tests/: Use the standard countof() instead of our NITEMS()
countof() is the name blessed by the C Committee for ISO C2y.
Use it if available, and define it if not.
countof() will be provided by GCC 16 and Clang 21.
This is mostly a scripted change:
$ grep -rl NITEMS | xargs sed -i s/NITEMS/countof/;
Apart from the scripted changes, I've adjusted white-space alignment,
and of course the definition at "lib/sizeof.h".
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf#subsubsection.0.6.5.4.5>
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf#section.0.7.21>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 11 Dec 2024 22:03:54 +0000 (23:03 +0100)]
lib/fields.c: valid_field(): Clarify comments
And apply minor style changes.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 13 Dec 2024 02:49:49 +0000 (03:49 +0100)]
lib/fields.c: valid_field(): Use strchriscntrl() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 11 Dec 2024 21:45:05 +0000 (22:45 +0100)]
lib/fields.c: valid_field(): Use strisprint() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 11 Dec 2024 20:16:13 +0000 (21:16 +0100)]
lib/fields.c: valid_field(): Return early on error
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 11 Dec 2024 20:04:52 +0000 (21:04 +0100)]
lib/fields.c: valid_field(): Remove useless check
We only call this function with a string literal, and it makes little
sense to pass something else. Let's simplify.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 3 Jun 2025 07:10:57 +0000 (09:10 +0200)]
lib/fields.*: valid_field: Make sure that $2 is a string literal
and thus, nonnull.
Suggested-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 3 Jun 2025 07:06:54 +0000 (09:06 +0200)]
lib/, src/: Move prototypes of "lib/fields.c" to "lib/fields.h"
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 13 Dec 2024 02:46:33 +0000 (03:46 +0100)]
lib/string/ctype/strchrisascii/: strchriscntrl(): Add function
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 11 Dec 2024 20:42:07 +0000 (21:42 +0100)]
lib/string/ctype/strisascii/: strisprint(): Add function
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 8 Feb 2025 10:06:40 +0000 (11:06 +0100)]
lib/nss.c: Use !strcaseprefix() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 8 Feb 2025 10:02:37 +0000 (11:02 +0100)]
contrib/, lib/: Use strcaseprefix() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 8 Feb 2025 09:57:51 +0000 (10:57 +0100)]
lib/string/strcmp/: strcaseprefix(): Add API
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Iker Pedrosa [Thu, 27 Mar 2025 10:45:35 +0000 (11:45 +0100)]
tests/: test chage last changed date
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
Iker Pedrosa [Tue, 4 Mar 2025 11:40:20 +0000 (12:40 +0100)]
tests/: test chage expiration date
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
Iker Pedrosa [Tue, 4 Mar 2025 11:39:35 +0000 (12:39 +0100)]
tests/: implement binding for `chage`
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
Iker Pedrosa [Tue, 4 Mar 2025 11:31:39 +0000 (12:31 +0100)]
tests/: test useradd expiration date
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
Iker Pedrosa [Mon, 3 Mar 2025 08:38:55 +0000 (09:38 +0100)]
tests/: test usermod expiration date
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
Alejandro Colomar [Tue, 18 Feb 2025 22:37:17 +0000 (23:37 +0100)]
lib/strtoday.c: Actually return a date from get_date()
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 18 Feb 2025 14:38:35 +0000 (15:38 +0100)]
lib/: Move get_date() to lib/strtoday.c
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 18 Feb 2025 14:43:29 +0000 (15:43 +0100)]
lib/strtoday.c: strtoday(): Remove obsolete comment
get_date() doesn't treat "" as a date anymore, so the comment is
obsolete. We still need the code, though, as for example usermod(8)
uses an empty string as a synonym for -1.
Link: <https://github.com/shadow-maint/shadow/pull/1217#issuecomment-
2668174079 >
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 18 Feb 2025 14:24:34 +0000 (15:24 +0100)]
lib/strtoday.c: strtoday(): Attempt parsing with str2sl() directly
If it fails, let's fall back to get_date().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 18 Feb 2025 22:25:29 +0000 (23:25 +0100)]
lib/getdate.c: Use strptime(3) to simplify
The following trick:
t = 0;
gmtime_r(&t, &tm);
is a clever way to clear the tm(3type) structure, and set it to use UTC.
We need to set it to set UTC with this trick, because strptime(3)
doesn't set the timezone. I (Alex) tried previously using
bzero(&tm, sizeof(tm));
strptime("UTC", "%Z", &tm);
but glibc ignores the timezone, and musl (at least I tried in an Alpine
container) seems to report an error.
The idea to use gmtime_r(3) was from lanodan.
Link: <https://inbox.sourceware.org/libc-alpha/Z_LqUgildoq33vI-@cloudsdale.the-delta.net.eu.org/T/#u>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Rich Felker <dalias@libc.org>
Co-authored-by: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
Signed-off-by: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 18 Feb 2025 14:19:38 +0000 (15:19 +0100)]
lib/: get_date(): Remove unused parameter
And rename the remaining parameter.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 18 Feb 2025 14:08:52 +0000 (15:08 +0100)]
lib/: Fix indentation and alignment
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 18 Feb 2025 13:52:04 +0000 (14:52 +0100)]
lib/getdate.*: Reimplement in pure C
This removes all yacc(1) code from this project. Add copyright and
license, since there remains nothing of the original code.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 14:01:19 +0000 (15:01 +0100)]
lib/: sget*ent(): Remove unnecessary 'static', and rename variable
For consistency, use 'fields[]' in all these functions,
and don't make it unnecessarily 'static'.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 22:29:58 +0000 (23:29 +0100)]
lib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
Just like the other sget*ent() functions do.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 12:17:01 +0000 (13:17 +0100)]
lib/: Rename local variable
Call it 'dup', which reminds that it's a strdup(3)d string.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 21:01:08 +0000 (22:01 +0100)]
lib/: Remove arbitrary limitation by calling strdup(3)
This makes these APIs more consistent with the ones for groups,
which strdup(3) memory as necessary.
It also makes the code simpler.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 7 Dec 2024 12:12:11 +0000 (13:12 +0100)]
lib/: Simplify by calling strdup(3)
While at it, rename the function parameter.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 17 Feb 2025 11:33:07 +0000 (12:33 +0100)]
lib/: Use strtolower() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 17 Feb 2025 11:26:41 +0000 (12:26 +0100)]
lib/string/ctype/strtoascii/: strtolower(): Add API
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 13 Mar 2025 02:19:09 +0000 (03:19 +0100)]
lib/atoi/str2i/, *: Simplify implementations
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 3 Dec 2024 01:18:38 +0000 (02:18 +0100)]
lib/atoi/a2i/: Simplify these macros by calling a2i()
I applied a similar patch in liba2i, where I've tested it.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 24 Feb 2025 23:06:49 +0000 (00:06 +0100)]
configure.ac: Remove unused check for futimes(3)
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 24 Feb 2025 23:05:11 +0000 (00:05 +0100)]
configure.ac, contrib/, src/: Remove dead code
Both glibc and musl provide getusershell(3). It's an API from 4.3BSD,
according to the manual page, so let's assume it exists everywhere that
we would care, even if it's not in POSIX.
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 24 Feb 2025 22:22:02 +0000 (23:22 +0100)]
lib/, configure.ac, po/: Remove dead file <lib/shadow.c>
We didn't even have prototypes for these APIs since long ago, when the
prototypes were removed, but misteriously the implementations remained.
Both glibc and musl provide getspnam(3), so this file was effectively
being ignored by the compiler. Just remove it.
Also remove the check for getspnam, which isn't used elsewhere.
Fixes: 0ee095abd8db (2007-10-07; "[svn-upgrade] Integrating new upstream version, shadow (4.0.7)")
Closes: <https://github.com/shadow-maint/shadow/issues/1228>
Signed-off-by: Alejandro Colomar <alx@kernel.org>