Serge Hallyn
045652a925
Release 4.18.0
...
Signed-off-by: Serge Hallyn <serge@hallyn.com>
4.18.0
2025-06-24 15:24:05 -05:00
Serge Hallyn
8c3aa0c9af
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>
4.18.0-rc2
2025-06-23 12:16:07 -05:00
Alejandro Colomar
4773fc4167
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>
2025-06-18 09:15:02 +02:00
Dominika Borges
fe49b677c4
man/: wfix usermod inactive
2025-06-09 10:23:37 +02:00
Dominika Borges
bbde977231
man/: wfix usermod expiredate
2025-06-09 10:23:37 +02:00
Dominika Borges
a132628c88
man/: wfix useradd expiredate
2025-06-09 10:23:37 +02:00
Dominika Borges
abfcddc798
man/: wfix useradd inactive
2025-06-09 10:23:37 +02:00
Dominika Borges
ac0c57532d
man: Update doc style of passwd man page
2025-06-09 10:23:37 +02:00
Dominika Borges
8d19543da1
man: Update doc style in shadow man page
2025-06-09 10:23:37 +02:00
Dominika Borges
57ff28ce05
man/: wfix
2025-06-09 10:23:37 +02:00
Dominika Borges
13b9f8224f
man: Update chage -d -E options
2025-06-09 10:23:37 +02:00
Serge Hallyn
95834a1d6e
Pre-release 4.18.0-rc1
...
Signed-off-by: Serge Hallyn <serge@hallyn.com>
2025-06-08 20:01:59 +02:00
Samuel Thibault
ec88c2ccb8
configure: Fix typo
...
The test was about lastlog, not subids
Fixes: 1bdcfa8d3710 (2023-07-15; "lastlog: stop building by default")
2025-06-08 11:22:34 +02:00
Samuel Thibault
cafcda246e
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>
2025-06-07 19:41:59 +02:00
Alejandro Colomar
71ea4998d2
lib/: Use xastrsep2ls() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
422a5e9975
lib/string/strtok/: xastrsep2ls(): Add function
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
e7a8c2b0e5
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>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
e168508b00
lib/string/strtok/: astrsep2ls(): Add function
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
81821d3ec8
lib/: Use STRSEP2ARR() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
70e2f2b1fb
lib/: Use strsep2arr() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
28789c87d1
lib/port.c: getportent(): Use STRSEP2ARR() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
b8e26eb851
lib/port.c: Use STRSEP2LS() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
cadd9c355e
lib/list.c: Use strsep2ls() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
2af9f9d012
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>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
4e64ef6993
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>
2025-06-07 16:52:03 +02:00
Alejandro Colomar
3ee8692fd6
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>
2025-06-07 07:33:04 -05:00
Alejandro Colomar
983a86610c
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>
2025-06-06 20:08:56 -05:00
Alejandro Colomar
f7b9ac5b7b
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>
2025-06-06 20:08:56 -05:00
Alejandro Colomar
b9323a0ae3
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>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
638c31c352
lib/tcbfuncs.c: shadowtcb_path_rel(): Use strdup(3) instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
9466b8c83b
lib/, src/: Remove unnecessary variables
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
2d7a049a86
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>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
423fd652b5
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>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
d895ee1ac8
lib/: Use vaprintf() instead of vasprintf(3)
2025-06-03 23:25:02 -05:00
Alejandro Colomar
86303b1233
lib/, src/: Use aprintf() instead of asprintf(3)
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
39f41a604b
lib/tcbfuncs.c: Split conditionals
...
This is in preparation for the next commit.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
5949132308
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>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
5fc6509dcb
lib/fs/mkstemp/: mkostemp(): Split API from fmkomstemp()
...
This reduces the complexity of fmkomstemp().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:49:44 -05:00
Alejandro Colomar
4b62a2ebea
lib/fs/mkstemp/, src/: fmkomstemp(): Move function to separate file
...
And make it inline.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:49:44 -05:00
Alejandro Colomar
4e80ca87e7
lib/getdef.c: Use countof() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:34:55 -05:00
Alejandro Colomar
bb503351cd
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>
2025-06-03 09:34:55 -05:00
Alejandro Colomar
dc8ead618d
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>
2025-06-03 09:34:55 -05:00
Alejandro Colomar
c5d8fcb4cd
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>
2025-06-03 09:34:55 -05:00
Alejandro Colomar
ba3456c9fd
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>
2025-06-03 09:34:55 -05:00
Alejandro Colomar
a5fc731dea
lib/fields.c: valid_field(): Clarify comments
...
And apply minor style changes.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:04:01 -05:00
Alejandro Colomar
fb5f9db283
lib/fields.c: valid_field(): Use strchriscntrl() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:04:01 -05:00
Alejandro Colomar
5080898f2a
lib/fields.c: valid_field(): Use strisprint() instead of its pattern
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:04:01 -05:00
Alejandro Colomar
5f8349bc0b
lib/fields.c: valid_field(): Return early on error
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:04:01 -05:00
Alejandro Colomar
6a024449f9
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>
2025-06-03 09:04:01 -05:00
Alejandro Colomar
8b3e9c3400
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>
2025-06-03 09:04:01 -05:00