]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
4 months agoRelease 4.17.1 4.17.1
Serge Hallyn [Tue, 31 Dec 2024 19:06:01 +0000 (13:06 -0600)] 
Release 4.17.1

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 months agosu: Fix su - regression
Tobias Stoeckmann [Mon, 30 Dec 2024 14:12:32 +0000 (15:12 +0100)] 
su: Fix su - regression

Launch a login shell again if requested through "su -" or "su -l".

Fixes: d9923431eb38 ("src/: Use xasprintf() instead of its pattern")
Closes: <https://github.com/shadow-maint/shadow/issues/1160>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 months agoRelease 4.17.0 4.17.0
Serge Hallyn [Wed, 25 Dec 2024 14:47:03 +0000 (08:47 -0600)] 
Release 4.17.0

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 months agoAdded information in lastlog man page for new option '-a'
Pranav Lawate [Thu, 12 Dec 2024 05:50:36 +0000 (11:20 +0530)] 
Added information in lastlog man page for new option '-a'

Signed-off-by: Pranav Lawate <pran.lawate@gmail.com>
4 months agolib/fs/readlink/: readlinknul(): Fix return type
Alejandro Colomar [Mon, 2 Dec 2024 10:05:05 +0000 (11:05 +0100)] 
lib/fs/readlink/: readlinknul(): Fix return type

Fixes: 419ce14b6f72 (2024-11-01, "lib/fs/readlink/: readlinknul(): Add function")
Cc: Serge Halyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/fs/readlink/readlinknul.h: readlinknul(): Silence warning
Alejandro Colomar [Sat, 2 Nov 2024 11:28:44 +0000 (12:28 +0100)] 
lib/fs/readlink/readlinknul.h: readlinknul(): Silence warning

Use a temporary variable to silence a sign-mismatch diagnostic.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoAdded option -a for listing active users only, optimized using if aflg,return
Pranav Lawate [Tue, 29 Oct 2024 09:57:51 +0000 (15:27 +0530)] 
Added option -a for listing active users only, optimized using if aflg,return

Signed-off-by: Pranav Lawate <pran.lawate@gmail.com>
4 months agolib/, src/: Use !streq() instead of its pattern
Alejandro Colomar [Fri, 6 Dec 2024 00:59:23 +0000 (01:59 +0100)] 
lib/, src/: Use !streq() instead of its pattern

Except for the added (and sorted) includes, the removal of redundant
parentheses, and a few non-string cases that I've left out of the
change, this patch can be approximated with the following semantic
patch:

$ cat ~/tmp/spatch/strneq.sp
@@
expression s;
@@

- '\0' != *s
+ !streq(s, "")

@@
expression s;
@@

- '\0' != s[0]
+ !streq(s, "")

@@
expression s;
@@

- *s != '\0'
+ !streq(s, "")

@@
expression s;
@@

- s[0] != '\0'
+ !streq(s, "")

$ find contrib/ lib* src/ -type f \
| xargs spatch --in-place --sp-file ~/tmp/spatch/strneq.sp;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/, src/: Use streq() instead of its pattern
Alejandro Colomar [Mon, 2 Dec 2024 12:16:56 +0000 (13:16 +0100)] 
lib/, src/: Use streq() instead of its pattern

Except for the added (and sorted) includes, the removal of redundant
parentheses, a few cases that have been refactored for readability, and
a couple of non-string cases that I've left out of the change, this
patch can be approximated with the following semantic patch:

$ cat ~/tmp/spatch/streq.sp
@@
expression s;
@@

- '\0' == *s
+ streq(s, "")

@@
expression s;
@@

- '\0' == s[0]
+ streq(s, "")

@@
expression s;
@@

- *s == '\0'
+ streq(s, "")

@@
expression s;
@@

- s[0] == '\0'
+ streq(s, "")

$ find contrib/ lib* src/ -type f \
| xargs spatch --in-place --sp-file ~/tmp/spatch/streq.sp;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agolib/sgetgrent.c: sgetgrent(): Fix use-after-free bug
Alejandro Colomar [Fri, 6 Dec 2024 23:07:27 +0000 (00:07 +0100)] 
lib/sgetgrent.c: sgetgrent(): Fix use-after-free bug

We were reusing a leftover from parsing a previous line if
(i == NFIELDS-1).  A few lines below this check, we use read the element
in [3] (that is, [NFIELDS-1]), without having written it in this call.

Be stricter, and require that all NFIELDS fields are found.

Fixes: 45c6603cc86c (2007-10-07, "[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Closes: <https://github.com/shadow-maint/shadow/issues/1144>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agoRelease 4.17.0-rc1
Serge Hallyn [Fri, 6 Dec 2024 05:39:32 +0000 (23:39 -0600)] 
Release 4.17.0-rc1

Signed-off-by: Serge Hallyn <serge@hallyn.com>
5 months agolib/gshadow.c: build_list(): Transform while loop into for loop
Alejandro Colomar [Wed, 6 Nov 2024 00:22:42 +0000 (01:22 +0100)] 
lib/gshadow.c: build_list(): Transform while loop into for loop

And 'n' is now an iterator.  Rename it to 'i' as usual.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Allocate at once
Alejandro Colomar [Wed, 6 Nov 2024 00:20:17 +0000 (01:20 +0100)] 
lib/gshadow.c: build_list(): Allocate at once

Instead of reallocating 1 more meber per iteration, calculate the total
amount that we want by counting the number of commas (delimiters) in the
string, plus one for the last element, plus one for the terminating
NULL.

This might result in overallocation of one element if the string is an
empty string, or if there's a trailing comma; however, that's not an
issue.  We can afford overallocating one element in certain cases, and
we get in exchange a much simpler function.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: Remove redundant variables
Alejandro Colomar [Tue, 5 Nov 2024 14:30:41 +0000 (15:30 +0100)] 
lib/gshadow.c: Remove redundant variables

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Remove second parameter
Alejandro Colomar [Tue, 5 Nov 2024 14:13:35 +0000 (15:13 +0100)] 
lib/gshadow.c: build_list(): Remove second parameter

We've simplified the function so much in the previous commits, that now
$2 is rather useless.  It only sets the output parameter to the same
value that the function returns.  It's simpler if the caller just sets
it itself after the call.

This removes the only 3-star pointer in the entire project.  :)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: sgetsgent(): Be consistent using NULL
Alejandro Colomar [Tue, 5 Nov 2024 13:10:23 +0000 (14:10 +0100)] 
lib/gshadow.c: sgetsgent(): Be consistent using NULL

0 is a horrible null-pointer constant.  Don't use it.
Especially, when just a few lines above, in the same function,
we've used NULL for the same thing.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Compact ++ into previous statement
Alejandro Colomar [Mon, 4 Nov 2024 20:59:27 +0000 (21:59 +0100)] 
lib/gshadow.c: build_list(): Compact ++ into previous statement

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Minimize use of pointer parameters
Alejandro Colomar [Mon, 4 Nov 2024 20:57:06 +0000 (21:57 +0100)] 
lib/gshadow.c: build_list(): Minimize use of pointer parameters

Use instead automatic variables as much as possible.
This reduces the number of dereferences, enhancing readability.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: Remove dead code
Alejandro Colomar [Mon, 4 Nov 2024 21:09:46 +0000 (22:09 +0100)] 
lib/gshadow.c: Remove dead code

Nothing is using that value outside of build_list().
Keep it as an local variable.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: Move zeroing to within build_list()
Alejandro Colomar [Tue, 5 Nov 2024 13:56:14 +0000 (14:56 +0100)] 
lib/gshadow.c: Move zeroing to within build_list()

This makes build_list() less dependent on the context.
It starts from clean, whatever the state before the call was.
I was having a hard time understanding the reallocation,
until I saw that we were zeroing everything right before the call.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: sgetsgent(): Remove superfluous condition
Alejandro Colomar [Mon, 4 Nov 2024 20:47:42 +0000 (21:47 +0100)] 
lib/gshadow.c: sgetsgent(): Remove superfluous condition

If n was 0, it doesn't hurt to set it again to 0;
and the list would be NULL, so it doesn't hurt free(3)ing it
and setting to NULL again either.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Remove dead assignment
Alejandro Colomar [Tue, 5 Nov 2024 13:50:35 +0000 (14:50 +0100)] 
lib/gshadow.c: build_list(): Remove dead assignment

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Improve variable and parameter names
Alejandro Colomar [Mon, 4 Nov 2024 16:48:39 +0000 (17:48 +0100)] 
lib/gshadow.c: build_list(): Improve variable and parameter names

It was hard to understand what each variable is.  Use a consistent
scheme, where a 'p' means a pointer, 'l' means list, and 'n' means
number of elements.  Those should be obvious from the name of the
function and the context, and will make it easier to read the code.
Also, the shorter names will allow focusing on the rest of the code.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Remove unused variable
Alejandro Colomar [Mon, 4 Nov 2024 16:33:19 +0000 (17:33 +0100)] 
lib/gshadow.c: build_list(): Remove unused variable

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: build_list(): Fix type of parameter
Alejandro Colomar [Mon, 4 Nov 2024 16:16:33 +0000 (17:16 +0100)] 
lib/gshadow.c: build_list(): Fix type of parameter

list ($2) is a pointer to a list of strings.  We were declaring it as an
array of pointers to strings, which was bogus.  It worked out of luck,
because array parameters are transformed into pointers by the compiler,
but it was incorrect.  Just look at how we're calling this function.

$ grep build_list lib/gshadow.c
build_list(char *s, char ***list, size_t *nlist)
sgroup.sg_adm = build_list (fields[2], &admins, &nadmins);
sgroup.sg_mem = build_list (fields[3], &members, &nmembers);
$ grep '^static .*\<admins\>' lib/gshadow.c
static /*@null@*//*@only@*/char **admins = NULL;
$ grep '^static .*\<members\>' lib/gshadow.c
static /*@null@*//*@only@*/char **members = NULL;

Fixes: 8e167d28afd6 ("[svn-upgrade] Integrating new upstream version, shadow (4.0.8)")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agosrc/: Transform do-while into while
Alejandro Colomar [Mon, 4 Nov 2024 15:37:48 +0000 (16:37 +0100)] 
src/: Transform do-while into while

list cannot be NULL in the first iteration, so we don't need a do-while.

Just in case it's not obvious: we know it's not NULL in the first
iteration because right above, in line 772, we've already dereferenced
it.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/, src/: Use strsep(3) instead of strtok(3)
Alejandro Colomar [Thu, 4 Jul 2024 11:21:12 +0000 (13:21 +0200)] 
lib/, src/: Use strsep(3) instead of strtok(3)

strsep(3) is stateless, and so is easier to reason about.

It also has a slight difference: strtok(3) jumps over empty fields,
while strsep(3) respects them as empty fields.  In most of the cases
where we were using strtok(3), it makes more sense to respect empty
fields, and this commit probably silently fixes a few bugs.

In other cases (most notably filesystem paths), contiguous delimiters
("//") should be collapsed, so strtok(3) still makes more sense there.
This commit doesn't replace such strtok(3) calls.

While at this, remove some useless variables used by these calls, and
reduce the scope of others.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agoCI: update artifacts action
Iker Pedrosa [Thu, 5 Dec 2024 11:39:33 +0000 (12:39 +0100)] 
CI: update artifacts action

v3 of upload-artifact actions is being deprecated, so let's move to v4.

Link: https://github.com/actions/upload-artifact
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
5 months agogroupadd, groupmod: Update gshadow file with -U
Dennis Baurichter [Sun, 17 Nov 2024 02:27:40 +0000 (03:27 +0100)] 
groupadd, groupmod: Update gshadow file with -U

When running groupadd or groupmod with the -U|--user option, also update
the group shadow database if it is used.

Fixes: 342c934a (2020-08-09, "add -U option to groupadd and groupmod")
Closes: <https://github.com/shadow-maint/shadow/issues/1124>
5 months agolib/, src/: Use !streq() instead of its pattern
Alejandro Colomar [Sun, 24 Nov 2024 17:40:48 +0000 (18:40 +0100)] 
lib/, src/: Use !streq() instead of its pattern

Except for the added (and sorted) includes, and the removal of redundant
parentheses, and one special case, this patch can be approximated with
the following semantic patch:

$ cat ~/tmp/spatch/strneq.sp;
@@
expression a, b;
@@

- strcmp(a, b) != 0
+ !streq(a, b)

@@
expression a, b;
@@

- 0 != strcmp(a, b)
+ !streq(a, b)

$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/strneq.sp --in-place;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agocontrib/, lib/, src/: Use streq() instead of its pattern
Alejandro Colomar [Sun, 17 Nov 2024 02:17:41 +0000 (03:17 +0100)] 
contrib/, lib/, src/: Use streq() instead of its pattern

Except for the added (and sorted) includes, and the removal of redundant
parentheses, this patch can be approximated with the following semantic
patch:

$ cat ~/tmp/spatch/streq.sp;
@@
expression a, b;
@@

- strcmp(a, b) == 0
+ streq(a, b)

@@
expression a, b;
@@

- 0 == strcmp(a, b)
+ streq(a, b)

@@
expression a, b;
@@

- !strcmp(a, b)
+ streq(a, b)

$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/streq.sp --in-place;
$ git restore lib/string/strcmp/streq.h;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow_.h: __STDC__ is always 1
Alejandro Colomar [Mon, 4 Nov 2024 23:37:03 +0000 (00:37 +0100)] 
lib/gshadow_.h: __STDC__ is always 1

We require C11 since a long time ago.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/csrand.c: csrand(): Use read(2) instead of fread(2)
Alejandro Colomar [Tue, 12 Nov 2024 14:19:19 +0000 (15:19 +0100)] 
lib/csrand.c: csrand(): Use read(2) instead of fread(2)

We don't need the heavy stdio for getting a few bytes from
</dev/urandom>.  Let's use the simpler POSIX API.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agosrc/login_nopam.c: resolve_hostname(): Use NI_MAXHOST instead of MAXHOSTNAMELEN with...
Alejandro Colomar [Tue, 22 Oct 2024 22:49:50 +0000 (00:49 +0200)] 
src/login_nopam.c: resolve_hostname(): Use NI_MAXHOST instead of MAXHOSTNAMELEN with getnameinfo(3)

That's what the getnameinfo(3) manual page recommends.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agoAllow setting an empty homedir
Volker Theile [Tue, 26 Nov 2024 08:26:14 +0000 (09:26 +0100)] 
Allow setting an empty homedir

With the PR 352 it is not possible anymore to run `usermod --home "" <USERNAME>`. This PR will fix that regression.

Related to: https://github.com/shadow-maint/shadow/pull/352

Signed-off-by: Volker Theile <votdev@gmx.de>
5 months agoshare/container-build.sh: Fix path
Alejandro Colomar [Mon, 25 Nov 2024 14:22:10 +0000 (15:22 +0100)] 
share/container-build.sh: Fix path

The instructions are written so that this script should be run from the
root of the repository.  Specify the path from the root of the repo.
Before this fix, the command needed to be run from within <share/>.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agoCI: avoid cancelling all jobs when one fails
Iker Pedrosa [Fri, 22 Nov 2024 11:49:41 +0000 (12:49 +0100)] 
CI: avoid cancelling all jobs when one fails

If a job in a matrix fails we don't want to cancel all jobs, thus we
need to set `fail-fast: false` as a strategy property.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
5 months agolib/idmapping.c: Fix get_map_ranges range check
Tobias Stoeckmann [Mon, 11 Nov 2024 19:28:52 +0000 (20:28 +0100)] 
lib/idmapping.c: Fix get_map_ranges range check

The get_map_ranges function shall support the whole accepted range
as specified in user_namespaces(7), i.e. upper and lower from 0 to
UINT_MAX - 1 as well as range from 1 to UINT_MAX. The actual limit of
range depends on values of upper and lower and adding the range
to either upper or lower shall never overflow UINT_MAX.

Fixes: 7c43eb2c4ea6 (2024-07-11, "lib/idmapping.c: get_map_ranges(): Move range check to a2ul() call")
Fixes: ff2baed5dbf8 (2016-08-14, "idmapping: add more checks for overflow")
Fixes: 94da3dc5c853 (2016-08-14, "also check upper for wrap")
Fixes: 7f5a14817d30 (2016-07-31, "get_map_ranges: check for overflow")
Co-authored-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/, src/: Use NULL instead of 0 as a null pointer constant
Alejandro Colomar [Wed, 13 Nov 2024 12:23:35 +0000 (13:23 +0100)] 
lib/, src/: Use NULL instead of 0 as a null pointer constant

GCC 15 will add -Wzero-as-null-pointer-constant for deprecating it,
and I'm working on a paper for deprecating it from ISO C too.
Let's remove any uses in our code base.

I've done this change by building GCC from master, adding
-Werror=zero-as-null-pointer-constant to ./autogen.sh, and fixing every
error that showed up.

Closes: <https://github.com/shadow-maint/shadow/issues/1120>
Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059>
Link: <https://software.codidact.com/posts/292718/292759#answer-292759>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/shadow.c: my_sgetspent(): There can be only one!
Alejandro Colomar [Mon, 11 Nov 2024 10:58:30 +0000 (11:58 +0100)] 
lib/shadow.c: my_sgetspent(): There can be only one!

We already have sgetspent(), with identical semantics, defined in
<lib/sgetspent.c>.

$ diff -u <(grepc sgetspent .) <(grepc my_sgetspent .)
--- /dev/fd/63 2024-11-11 11:56:55.444055921 +0100
+++ /dev/fd/62 2024-11-11 11:56:55.444055921 +0100
@@ -1,23 +1,19 @@
-./lib/sgetspent.c:struct spwd *
-sgetspent(const char *string)
+./lib/shadow.c:static struct spwd *my_sgetspent (const char *string)
 {
- static char spwbuf[PASSWD_ENTRY_MAX_LENGTH];
- static struct spwd spwd;
- char *fields[FIELDS];
- char *cp;
- int i;
+ int                 i;
+ char                *fields[FIELDS];
+ char                *cp;
+ static char         spwbuf[BUFSIZ];
+ static char         empty[] = "";
+ static struct spwd  spwd;

/*
 * Copy string to local buffer.  It has to be tokenized and we
 * have to do that to our private copy.
 */

- if (strlen (string) >= sizeof spwbuf) {
- fprintf (shadow_logfd,
-          "%s: Too long passwd entry encountered, file corruption?\n",
-          shadow_progname);
- return NULL; /* fail if too long */
- }
+ if (strlen (string) >= sizeof spwbuf)
+ return 0;
strcpy (spwbuf, string);
stpsep(spwbuf, "\n");

@@ -30,14 +26,16 @@
fields[i] = strsep(&cp, ":");

if (i == (FIELDS - 1))
- fields[i++] = "";
+ fields[i++] = empty;

if (cp != NULL || (i != FIELDS && i != OFIELDS))
- return NULL;
+ return 0;

/*
 * Start populating the structure.  The fields are all in
-  * static storage, as is the structure we pass back.
+  * static storage, as is the structure we pass back.  If we
+  * ever see a name with '+' as the first character, we try
+  * to turn on NIS processing.
 */

spwd.sp_namp = fields[0];
@@ -46,13 +44,13 @@
/*
 * Get the last changed date.  For all of the integer fields,
 * we check for proper format.  It is an error to have an
-  * incorrectly formatted number.
+  * incorrectly formatted number, unless we are using NIS.
 */

if (fields[2][0] == '\0')
spwd.sp_lstchg = -1;
else if (a2sl(&spwd.sp_lstchg, fields[2], NULL, 0, 0, LONG_MAX) == -1)
- return NULL;
+ return 0;

/*
 * Get the minimum period between password changes.
@@ -61,7 +59,7 @@
if (fields[3][0] == '\0')
spwd.sp_min = -1;
else if (a2sl(&spwd.sp_min, fields[3], NULL, 0, 0, LONG_MAX) == -1)
- return NULL;
+ return 0;

/*
 * Get the maximum number of days a password is valid.
@@ -70,7 +68,7 @@
if (fields[4][0] == '\0')
spwd.sp_max = -1;
else if (a2sl(&spwd.sp_max, fields[4], NULL, 0, 0, LONG_MAX) == -1)
- return NULL;
+ return 0;

/*
 * If there are only OFIELDS fields (this is a SVR3.2 /etc/shadow
@@ -93,7 +91,7 @@
if (fields[5][0] == '\0')
spwd.sp_warn = -1;
else if (a2sl(&spwd.sp_warn, fields[5], NULL, 0, 0, LONG_MAX) == -1)
- return NULL;
+ return 0;

/*
 * Get the number of days of inactivity before an account is
@@ -103,7 +101,7 @@
if (fields[6][0] == '\0')
spwd.sp_inact = -1;
else if (a2sl(&spwd.sp_inact, fields[6], NULL, 0, 0, LONG_MAX) == -1)
- return NULL;
+ return 0;

/*
 * Get the number of days after the epoch before the account is
@@ -113,7 +111,7 @@
if (fields[7][0] == '\0')
spwd.sp_expire = -1;
else if (a2sl(&spwd.sp_expire, fields[7], NULL, 0, 0, LONG_MAX) == -1)
- return NULL;
+ return 0;

/*
 * This field is reserved for future use.  But it isn't supposed
@@ -123,8 +121,7 @@
if (fields[8][0] == '\0')
spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
else if (str2ul(&spwd.sp_flag, fields[8]) == -1)
- return NULL;
+ return 0;

return (&spwd);
 }
-./lib/prototypes.h:extern struct spwd *sgetspent (const char *string);

Closes: <https://github.com/shadow-maint/shadow/issues/1114>
Link: <https://www.youtube.com/watch?v=IpbvtSQvgWM>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agosrc/login_nopam.c: Rely on the system's MAXHOSTNAMELEN
Alejandro Colomar [Tue, 22 Oct 2024 22:14:12 +0000 (00:14 +0200)] 
src/login_nopam.c: Rely on the system's MAXHOSTNAMELEN

The reason for that code seems to be some ancient AIX version that
defined a value that was too small (32).  We don't support such systems.
In the link below, I found the following comment and code:

 /*
  * Some AIX versions advertise a too small MAXHOSTNAMELEN value (32).
  * Result: long hostnames would be truncated, and connections would be
  * dropped because of host name verification failures. Adrian van Bloois
  * (A.vanBloois@info.nic.surfnet.nl) figured out what was the problem.
  */

#if (MAXHOSTNAMELEN < 64)
#undef MAXHOSTNAMELEN
#endif

/* In case not defined in <sys/param.h>. */

#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN  256             /* storage for host name */
#endif

Today's systems seem to be much better regarding this macro.  Rely on
them.

Link: <https://sources.debian.org/src/tcp-wrappers/7.6.q-33/workarounds.c/?hl=36#L36>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/gshadow.c: endsgent(): Invert logic to reduce indentation
Alejandro Colomar [Sun, 21 Jul 2024 16:18:08 +0000 (18:18 +0200)] 
lib/gshadow.c: endsgent(): Invert logic to reduce indentation

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/list.c: comma_to_list(): Use strchrcnt() instead of its pattern
Alejandro Colomar [Thu, 4 Jul 2024 13:42:17 +0000 (15:42 +0200)] 
lib/list.c: comma_to_list(): Use strchrcnt() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/string/strchr/: strchrcnt(): Add function
Alejandro Colomar [Thu, 4 Jul 2024 13:30:58 +0000 (15:30 +0200)] 
lib/string/strchr/: strchrcnt(): Add function

Signed-off-by: Alejandro Colomar <alx@kernel.org>
5 months agolib/string/strcmp/: streq(): Add function
Alejandro Colomar [Tue, 15 Oct 2024 11:21:17 +0000 (13:21 +0200)] 
lib/string/strcmp/: streq(): Add function

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agosrc/gpasswd.c: is_valid_user_list(): Fix invalid free(3)
frostb1te [Fri, 8 Nov 2024 11:00:24 +0000 (05:00 -0600)] 
src/gpasswd.c: is_valid_user_list(): Fix invalid free(3)

This fix addresses an issue in is_valid_user_list() where the free
operation was attempted on an address not allocated with malloc().  By
duplicating the pointer with xstrdup(users) into dup, and using dup as
the original pointer, we ensure that only the valid pointer is freed,
avoiding an invalid free operation.

This bug was introduced when changing some code that used strchrnul(3)
to use strsep(3) instead.  strsep(3) advances the pointer, unlike the
previous code.

This unconditionally leads to a bug:

-  Passing NULL to free(3), if the last field in the
   colon-separated-value list is non-empty.  This results in a memory
   leak.

-  Passing a pointer to the null byte ('\0') that terminates the string,
   if the last element of the colon-separated-value list is empty.  The
   most obvious reproducer of such a bogus free(3) call is:

       free(strdup("foo:") + 4);

   This results in Undefined Behavior, and could result in allocator
   data corruption.

Fixes: 16cb66486554 (2024-07-01, "lib/, src/: Use strsep(3) instead of its pattern")
Suggested-by: <https://github.com/frostb1ten>
Reported-by: <https://github.com/frostb1ten>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Christian Brauner <christian@brauner.io>
6 months agoman/shadow,man/gshadow: Fix grammar
Miroslav Cimerman [Mon, 4 Nov 2024 09:06:56 +0000 (10:06 +0100)] 
man/shadow,man/gshadow: Fix grammar

Signed-off-by: Miroslav Cimerman <mc@doas.su>
6 months agolib/fs/readlink/areadlink.h: areadlink(): Use PATH_MAX instead of a magic value
Alejandro Colomar [Tue, 22 Oct 2024 10:15:48 +0000 (12:15 +0200)] 
lib/fs/readlink/areadlink.h: areadlink(): Use PATH_MAX instead of a magic value

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/fs/readlink/areadlink.h: Cosmetic changes
Alejandro Colomar [Mon, 14 Oct 2024 11:53:31 +0000 (13:53 +0200)] 
lib/fs/readlink/areadlink.h: Cosmetic changes

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/fs/readlink/, lib/: areadlink(): Move and rename function
Alejandro Colomar [Wed, 3 Jul 2024 01:31:24 +0000 (03:31 +0200)] 
lib/fs/readlink/, lib/: areadlink(): Move and rename function

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/: Use READLINKNUL() instead of its pattern
Alejandro Colomar [Wed, 3 Jul 2024 01:21:10 +0000 (03:21 +0200)] 
lib/: Use READLINKNUL() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/: Use readlinknul() instead of its pattern
Alejandro Colomar [Wed, 3 Jul 2024 01:20:34 +0000 (03:20 +0200)] 
lib/: Use readlinknul() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/fs/readlink/readlinknul.h: READLINKNUL(): Add macro
Alejandro Colomar [Wed, 3 Jul 2024 01:08:59 +0000 (03:08 +0200)] 
lib/fs/readlink/readlinknul.h: READLINKNUL(): Add macro

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/fs/readlink/: readlinknul(): Add function
Alejandro Colomar [Wed, 3 Jul 2024 01:00:49 +0000 (03:00 +0200)] 
lib/fs/readlink/: readlinknul(): Add function

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agoCI: fix fedora build problems
Iker Pedrosa [Thu, 31 Oct 2024 08:25:57 +0000 (09:25 +0100)] 
CI: fix fedora build problems

The new fedora 41 has been released and some things have changed. Make
sure to install python and python3-dnf and specify the dnf version in
the roles.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
6 months agoCI: fix handling of sources.list
Serge Hallyn [Thu, 31 Oct 2024 03:06:44 +0000 (22:06 -0500)] 
CI: fix handling of sources.list

Closes #1088

We can't be sure whether a github runner will have new- or old-
style sources.list, so check whether the new exists, else use
the old style.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
6 months agolib/loginprompt.c: login_prompt(): Use strtcpy() instead of its pattern
Alejandro Colomar [Thu, 4 Jul 2024 14:32:17 +0000 (16:32 +0200)] 
lib/loginprompt.c: login_prompt(): Use strtcpy() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/getdef.c: Remove dead code
Alejandro Colomar [Mon, 12 Aug 2024 08:52:16 +0000 (10:52 +0200)] 
lib/getdef.c: Remove dead code

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/fields.c: Remove dead code
Alejandro Colomar [Thu, 4 Jul 2024 20:42:15 +0000 (22:42 +0200)] 
lib/fields.c: Remove dead code

A few lines above, we've removed the '\n' already.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agosrc/useradd.c: get_groups(): Fix memory leak
sgakerru [Sat, 19 Oct 2024 09:26:44 +0000 (13:26 +0400)] 
src/useradd.c: get_groups(): Fix memory leak

6 months agoFix coverity unbound buffer issues
Marcin Nowakowski [Tue, 25 Jun 2024 07:45:33 +0000 (09:45 +0200)] 
Fix coverity unbound buffer issues

During coverity scan, there are reported four issues
with unbounded source buffer for each usage of input arg
directly with syslog function.

Sample coverity test report for chsh.c file:

 1. string_size_argv: argv contains strings with unknown size.
 int main (int argc, char **argv)
[...]
 4. var_assign_var: Assigning: user = argv[optind]. Both are now tainted.
 user = argv[optind];
[...]
CID 5771784: (#1 of 1): Unbounded source buffer (STRING_SIZE)
15. string_size: Passing string user of unknown size to syslog.
 SYSLOG ((LOG_INFO, "changed user '%s' shell to '%s'", user, loginsh));

Similar issue is reported three times more:
File: chfn.c, function: main, variable: user
File: passwd.c, function: main, variable: name
File: newgrp.c, function: main, variable: group

This commit is the first approach to fix the reported issues.
The proposed changes add conditions, which verify
the user and group names arguments, including their lengths.
This will not silence the coverity reports, but the change causes
that they are irrelevant and could be ignored.

6 months agolib/alloc/realloc*.h: Always reallocate at least 1 byte
Alejandro Colomar [Wed, 16 Oct 2024 18:31:25 +0000 (20:31 +0200)] 
lib/alloc/realloc*.h: Always reallocate at least 1 byte

glibc's realloc(3) is broken.  It was originally good (I believe) until
at some point, when it was changed to conform to C89, which had a bogus
specification that required that it returns NULL.  C99 fixed the mistake
from C89, and so glibc's realloc(3) is non-conforming to
C99/C11/POSIX.1-2008.  C17 broke again the definition of realloc(3).

Link: <https://github.com/shadow-maint/shadow/pull/1095>
Link: <https://nabijaczleweli.xyz/content/blogn_t/017-malloc0.html>
Link: <https://inbox.sourceware.org/libc-alpha/5gclfbrxfd7446gtwd2x2gfuquy7ukjdbrndphyfmfszxlft76@wwjz7spd4vd7/T/#t>
Co-developed-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Acked-by: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/alloc/realloc*.h: Rename macro parameter
Alejandro Colomar [Wed, 16 Oct 2024 18:22:31 +0000 (20:22 +0200)] 
lib/alloc/realloc*.h: Rename macro parameter

This is in preparation for the following commit, which will need this
shorter parameter name to avoid breaking long lines.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agodoc/contributions/introduction.md: Fix typo in link
Alejandro Colomar [Thu, 17 Oct 2024 14:34:26 +0000 (16:34 +0200)] 
doc/contributions/introduction.md: Fix typo in link

Fixes: 981bb8f9d1ba ("doc: add contributions introduction")
Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agoCI: install `libltdl-dev`
Iker Pedrosa [Mon, 14 Oct 2024 10:46:05 +0000 (12:46 +0200)] 
CI: install `libltdl-dev`

Required to manage an autoconf macro.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
6 months agoCI: run command as non-root user
Iker Pedrosa [Mon, 14 Oct 2024 10:40:09 +0000 (12:40 +0200)] 
CI: run command as non-root user

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
6 months agoCI: run `Install dependencies` workflow
Iker Pedrosa [Mon, 14 Oct 2024 10:38:45 +0000 (12:38 +0200)] 
CI: run `Install dependencies` workflow

Run this workflow instead of replicating the script every time we need
to install the dependencies.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
6 months agoCI: update Ubuntu repositories configuration
Iker Pedrosa [Mon, 14 Oct 2024 09:53:50 +0000 (11:53 +0200)] 
CI: update Ubuntu repositories configuration

Recently Ubuntu updated its repositories configuration file from
`/etc/apt/sources.list` to `/etc/apt/sources.list.d/ubuntu.source`.
Thus, we need to update its location to be able to install all the
package dependencies.

In addition, the CI script was trying to uncomment the lines starting
with `deb-src`, but there is none in the new configuration file format.
Replace `Types: deb` by `Types: deb deb-src` at the beginning of the
line instead.

This commit merges all dependency installation scripts into a single
workflow, which will be called from all sites that have to install
dependencies.

Link: https://linuxconfig.org/ubuntus-repository-configuration-ubuntu-sources-have-moved-to-etc-apt-sources-list-d-ubuntu-sources
Closes: https://github.com/shadow-maint/shadow/issues/1088
Reported-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
6 months agosrc/suauth.c: check_su_auth(): Use pointers to simplify
Alejandro Colomar [Wed, 3 Jul 2024 21:49:04 +0000 (23:49 +0200)] 
src/suauth.c: check_su_auth(): Use pointers to simplify

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agosrc/suauth.c: check_su_auth(): Use strspn(3) instead of its pattern
Alejandro Colomar [Wed, 3 Jul 2024 21:46:50 +0000 (23:46 +0200)] 
src/suauth.c: check_su_auth(): Use strspn(3) instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/gshadow.c: endsgent(): Remove dead assignment
Alejandro Colomar [Wed, 3 Jul 2024 21:40:08 +0000 (23:40 +0200)] 
lib/gshadow.c: endsgent(): Remove dead assignment

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/port.c: portcmp(): Use strcmp(3) instead of its pattern
Alejandro Colomar [Wed, 3 Jul 2024 21:13:18 +0000 (23:13 +0200)] 
lib/port.c: portcmp(): Use strcmp(3) instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/, src/: Use stpspn() instead of its pattern
Alejandro Colomar [Wed, 3 Jul 2024 20:47:45 +0000 (22:47 +0200)] 
lib/, src/: Use stpspn() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 months agouseradd: fix comparison sign for write_full() return
Iker Pedrosa [Fri, 4 Oct 2024 13:02:59 +0000 (15:02 +0200)] 
useradd: fix comparison sign for write_full() return

I forgot to change the comparison sign that checks the return value of
write_full()

Closes: https://github.com/shadow-maint/shadow/issues/1072
Fixes: 8903b94c86c9 ("useradd: fix write_full() return value")
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2313559

Reported-by: <https://github.com/brown-midas>
Suggested-by: <https://github.com/brown-midas>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
7 months agosrc/useradd.c: Add the missing equals sign
kugarocks [Thu, 3 Oct 2024 12:18:59 +0000 (20:18 +0800)] 
src/useradd.c: Add the missing equals sign

Fixes: a7b169be1862 ("src/useradd.c: Use stpsep() to simplify")
Reviewed-by: Alejandro Colomar <alx@kernel.org>
7 months agosrc/check_subid_range.c: Remove dead code
Alejandro Colomar [Wed, 2 Oct 2024 22:19:02 +0000 (00:19 +0200)] 
src/check_subid_range.c: Remove dead code

I forgot to remove the setting of errno when I switched from
strtoul_noneg() to str2ul().  strtoul(3) needs errno for determining
success, but str2ul() does not.

Fixes: f3a1e1cf098d ("src/check_subid_range.c: Call str2ul() instead of strtoul_noneg()")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 months agoman/subgid,man/subuid: Fix program list
Tobias Stoeckmann [Fri, 13 Sep 2024 19:40:28 +0000 (21:40 +0200)] 
man/subgid,man/subuid: Fix program list

The groupadd utility does not set information in subgid. Instead, list
all programs which actually can do so.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agoman/passwd: Fix typo
Tobias Stoeckmann [Fri, 13 Sep 2024 19:40:22 +0000 (21:40 +0200)] 
man/passwd: Fix typo

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agosrc/useradd.c: Add fmkomstemp() to fix mode of </etc/default/useradd>
Alejandro Colomar [Sun, 29 Sep 2024 11:09:40 +0000 (13:09 +0200)] 
src/useradd.c: Add fmkomstemp() to fix mode of </etc/default/useradd>

The mode of the file should be 644, but mkstemp(2) was transforming it
to 600.

To do this, we need a function that accepts a mode parameter.  While we
don't need a flags parameter, to avoid confusion with mkostemp(2), let's
add both a flags and a mode parameter.

Link: <https://github.com/shadow-maint/shadow/pull/1080>
Reported-by: kugarocks <kugacola@gmail.com>
Suggested-by: kugarocks <kugacola@gmail.com>
Tested-by: kugarocks <kugacola@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 months agolib: Eliminate dead code
Tobias Stoeckmann [Thu, 19 Sep 2024 20:10:17 +0000 (22:10 +0200)] 
lib: Eliminate dead code

The tz function is only called if ENV_TZ starts with a slash.

If the specified file cannot be read, the code implies that ENV_TZ
would be returned if it does not start with a slash.

Since we know that it DOES start with a slash, the code can be
simplified to state that "TZ=CST6CDT" is returned as a default if
the specified file cannot be read.

Benefit of this change is that strcpy's use case here can be
easier verified.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agolib/run_part: Adjust style
Tobias Stoeckmann [Fri, 13 Sep 2024 22:17:45 +0000 (00:17 +0200)] 
lib/run_part: Adjust style

Remove some of these whitespaces.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agolib/run_part: Unify error messages
Tobias Stoeckmann [Fri, 13 Sep 2024 22:14:20 +0000 (00:14 +0200)] 
lib/run_part: Unify error messages

At least if they can be assigned directly to a function call.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agolib: Fix typo
Tobias Stoeckmann [Fri, 13 Sep 2024 21:38:15 +0000 (23:38 +0200)] 
lib: Fix typo

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agolib/run_part: Reduce visibility
Tobias Stoeckmann [Fri, 13 Sep 2024 19:50:00 +0000 (21:50 +0200)] 
lib/run_part: Reduce visibility

The run_part function is only used in run_part.c itself, so no
need to expose it to other files.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agolib/run_part: Unify logging
Tobias Stoeckmann [Fri, 13 Sep 2024 19:49:24 +0000 (21:49 +0200)] 
lib/run_part: Unify logging

Use shadow_logfd for logging instead of fixed stderr to use
shadow's own logging infrastructure.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agolib/run_part: Use correct data types
Tobias Stoeckmann [Fri, 13 Sep 2024 19:49:08 +0000 (21:49 +0200)] 
lib/run_part: Use correct data types

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agoFix typos
Tobias Stoeckmann [Fri, 13 Sep 2024 19:30:52 +0000 (21:30 +0200)] 
Fix typos

Typos in comments and configure output, i.e. no functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 months agouseradd: fix write_full() return value
Iker Pedrosa [Mon, 9 Sep 2024 08:36:17 +0000 (10:36 +0200)] 
useradd: fix write_full() return value

write_full() returns -1 on error and useradd was checking another value.

Closes: https://github.com/shadow-maint/shadow/issues/1072
Fixes: f45498a6c286 ("libmisc/write_full.c: Improve write_full()")
Reported-by: <https://github.com/brown-midas>
Suggested-by: <https://github.com/brown-midas>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
7 months agolib/user_busy.c: Include <utmpx.h>
Pino Toscano [Tue, 10 Sep 2024 12:36:49 +0000 (14:36 +0200)] 
lib/user_busy.c: Include <utmpx.h>

Since:
- utmpx APIs are used in non-Linux code blocks
- <utmpx.h> is already unconditionally included in Linux parts in other
  files
then unconditionally include it in this file as well.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
8 months agosrc/: Recommend --badname only if it is useful
Alejandro Colomar [Sat, 31 Aug 2024 09:55:27 +0000 (11:55 +0200)] 
src/: Recommend --badname only if it is useful

(Review with -w (--ignore-all-space).)

Closes: <https://github.com/shadow-maint/shadow/issues/1067>
Reported-by: Anselm Schüler <mail@anselmschueler.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agosrc/: Invert logic to improve readability
Alejandro Colomar [Sat, 31 Aug 2024 09:37:40 +0000 (11:37 +0200)] 
src/: Invert logic to improve readability

And remove the (now) redundant comments.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agolib/chkname.c: is_valid_{user,group}_name(): Set errno to distinguish the reasons
Alejandro Colomar [Sat, 31 Aug 2024 09:25:00 +0000 (11:25 +0200)] 
lib/chkname.c: is_valid_{user,group}_name(): Set errno to distinguish the reasons

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/userdel.8.xml: Reword '-f'
Alejandro Colomar [Sat, 31 Aug 2024 09:07:04 +0000 (11:07 +0200)] 
man/userdel.8.xml: Reword '-f'

The previous wording seemed to say that -f implied -r.  It doesn't; -f
only skips safety checks, so reword accordingly.

Closes: <https://github.com/shadow-maint/shadow/issues/1062>
Reported-by: Martin von Wittich <martin.von.wittich@iserv.eu>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agolib/: Chain free(strzero(s))
Alejandro Colomar [Mon, 12 Aug 2024 00:21:01 +0000 (02:21 +0200)] 
lib/: Chain free(strzero(s))

This reduces the repetition of the argument, which could be error-prone.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agolib/string/memset/: memzero(), strzero(): Return the pointer
Alejandro Colomar [Mon, 12 Aug 2024 00:15:18 +0000 (02:15 +0200)] 
lib/string/memset/: memzero(), strzero(): Return the pointer

This allows chaining with free(3) on the same line.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agolib/: Move memzero.[ch] under lib/string/memset/
Alejandro Colomar [Sun, 11 Aug 2024 23:53:45 +0000 (01:53 +0200)] 
lib/: Move memzero.[ch] under lib/string/memset/

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agopo/es.po: wsfix
Alejandro Colomar [Sat, 3 Aug 2024 09:51:23 +0000 (11:51 +0200)] 
po/es.po: wsfix

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agolib/string/strftime.h: STRFTIME(): Tighten macro definition
Alejandro Colomar [Thu, 1 Aug 2024 10:37:24 +0000 (12:37 +0200)] 
lib/string/strftime.h: STRFTIME(): Tighten macro definition

strftime(3) is not a variadic function; there's exactly one argument
after the format string.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agosrc/chage.c: print_day_as_date(): Handle errors from strfime(3)
Alejandro Colomar [Sun, 11 Aug 2024 19:42:03 +0000 (21:42 +0200)] 
src/chage.c: print_day_as_date(): Handle errors from strfime(3)

Just like we do in day_to_str().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agosrc/chage.c: print_day_as_date(): Simplify error handling
Alejandro Colomar [Wed, 31 Jul 2024 12:53:12 +0000 (14:53 +0200)] 
src/chage.c: print_day_as_date(): Simplify error handling

If localtime_r(3) fails, just print future, as we do in day_to_str().
It should only fail for unrealistic dates, if at all.

Signed-off-by: Alejandro Colomar <alx@kernel.org>