]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
8 weeks agolib/fs/mkstemp/: mkostemp(): Split API from fmkomstemp()
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>
8 weeks agolib/fs/mkstemp/, src/: fmkomstemp(): Move function to separate file
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>
8 weeks agolib/getdef.c: Use countof() instead of its pattern
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>
8 weeks agolib/, src/: Move macros to "typetraits.h"
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>
8 weeks agoautogen.sh, lib/: Replace must_be_array() by -Werror=sizeof-pointer-div
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>
8 weeks agolib/sizeof.h: Define SIZEOF_ARRAY() in terms of countof()
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>
8 weeks agolib/, src/, tests/: Use the standard countof() instead of our NITEMS()
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>
8 weeks agolib/fields.c: valid_field(): Clarify comments
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>
8 weeks agolib/fields.c: valid_field(): Use strchriscntrl() instead of its pattern
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>
8 weeks agolib/fields.c: valid_field(): Use strisprint() instead of its pattern
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>
8 weeks agolib/fields.c: valid_field(): Return early on error
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>
8 weeks agolib/fields.c: valid_field(): Remove useless check
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>
8 weeks agolib/fields.*: valid_field: Make sure that $2 is a string literal
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>
8 weeks agolib/, src/: Move prototypes of "lib/fields.c" to "lib/fields.h"
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>
8 weeks agolib/string/ctype/strchrisascii/: strchriscntrl(): Add function
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>
8 weeks agolib/string/ctype/strisascii/: strisprint(): Add function
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>
8 weeks agolib/nss.c: Use !strcaseprefix() instead of its pattern
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>
8 weeks agocontrib/, lib/: Use strcaseprefix() instead of its pattern
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>
8 weeks agolib/string/strcmp/: strcaseprefix(): Add API
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>
8 weeks agotests/: test chage last changed date
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>
8 weeks agotests/: test chage expiration date
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>
8 weeks agotests/: implement binding for `chage`
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>
8 weeks agotests/: test useradd expiration date
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>
8 weeks agotests/: test usermod expiration date
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>
8 weeks agolib/strtoday.c: Actually return a date from get_date()
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>
8 weeks agolib/: Move get_date() to lib/strtoday.c
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>
8 weeks agolib/strtoday.c: strtoday(): Remove obsolete comment
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>
8 weeks agolib/strtoday.c: strtoday(): Attempt parsing with str2sl() directly
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>
8 weeks agolib/getdate.c: Use strptime(3) to simplify
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>
8 weeks agolib/: get_date(): Remove unused parameter
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>
8 weeks agolib/: Fix indentation and alignment
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>
8 weeks agolib/getdate.*: Reimplement in pure C
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>
2 months agolib/: sget*ent(): Remove unnecessary 'static', and rename variable
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>
2 months agolib/sgetpwent.c: sgetpwent(): Trim the trailing '\n'
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>
2 months agolib/: Rename local variable
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>
2 months agolib/: Remove arbitrary limitation by calling strdup(3)
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>
2 months agolib/: Simplify by calling strdup(3)
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>
2 months agolib/: Use strtolower() instead of its pattern
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>
2 months agolib/string/ctype/strtoascii/: strtolower(): Add API
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>
2 months agolib/atoi/str2i/, *: Simplify implementations
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>
2 months agolib/atoi/a2i/: Simplify these macros by calling a2i()
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>
2 months agoconfigure.ac: Remove unused check for futimes(3)
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>
2 months agoconfigure.ac, contrib/, src/: Remove dead code
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>
2 months agolib/, configure.ac, po/: Remove dead file <lib/shadow.c>
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>
2 months agolib/string/strdup/strndupa.h: STRNDUPA(): Simplify implementation
Alejandro Colomar [Sun, 19 Jan 2025 14:32:12 +0000 (15:32 +0100)] 
lib/string/strdup/strndupa.h: STRNDUPA(): Simplify implementation

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/string/strdup/strndupa.h: strndupa(3): Add macro
Alejandro Colomar [Sun, 19 Jan 2025 15:01:45 +0000 (16:01 +0100)] 
lib/string/strdup/strndupa.h: strndupa(3): Add macro

musl doesn't provide strndupa(3).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/: Treat strpbrk(3)'s return value as a boolean
Alejandro Colomar [Wed, 1 Jan 2025 00:04:38 +0000 (01:04 +0100)] 
lib/: Treat strpbrk(3)'s return value as a boolean

with the meaning "a character was found".

strpbrk(3) is just like strchr(3), but searches for multiple characters.
Both functions have a boolean-like return value, which evaluates to true
if a character was found.

A better name for strpbrk(3) would have been strchrs().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/: Simplify, using strpbrk(3)
Alejandro Colomar [Tue, 31 Dec 2024 22:37:39 +0000 (23:37 +0100)] 
src/: Simplify, using strpbrk(3)

Checking a boolean (actually, a boolean-like pointer) is more readable
than comparing against a length.

This removes the only uses of strcspn(3) in this project.

strpbrk(3) is a simpler call, even though it has a weird name.  It's
just like strchr(3) but searches for several characters.  I'd have named
it strchrs().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/, src/: Use strprefix() instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 13:27:02 +0000 (14:27 +0100)] 
lib/, src/: Use strprefix() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/: Use !strprefix() instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 14:24:45 +0000 (15:24 +0100)] 
lib/: Use !strprefix() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/: Use strprefix() instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 02:00:18 +0000 (03:00 +0100)] 
lib/: Use strprefix() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/env.c: sanitize_env(): Use !strprefix() instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 04:10:02 +0000 (05:10 +0100)] 
lib/env.c: sanitize_env(): Use !strprefix() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/, src/: Use strprefix() instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 03:58:12 +0000 (04:58 +0100)] 
lib/, src/: Use strprefix() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/, src/: Use s=strprefix(s,p)?:s instead of its pattern
Alejandro Colomar [Tue, 10 Dec 2024 03:38:45 +0000 (04:38 +0100)] 
lib/, src/: Use s=strprefix(s,p)?:s instead of its pattern

This skips an optional prefix.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/string/strcmp/: strprefix(): Add API
Alejandro Colomar [Fri, 26 Jul 2024 09:13:37 +0000 (11:13 +0200)] 
lib/string/strcmp/: strprefix(): Add API

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/, src/: Reduce scope of local variables
Alejandro Colomar [Tue, 10 Dec 2024 02:23:30 +0000 (03:23 +0100)] 
lib/, src/: Reduce scope of local variables

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/sizeof.h: Make sure STRLEN() only accepts string literals
Alejandro Colomar [Sun, 25 May 2025 13:04:25 +0000 (15:04 +0200)] 
lib/sizeof.h: Make sure STRLEN() only accepts string literals

Link: <https://stackoverflow.com/a/79369560/6872717>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agotests/: extend basic groupdel tests
Iker Pedrosa [Wed, 12 Mar 2025 08:19:44 +0000 (09:19 +0100)] 
tests/: extend basic groupdel tests

Add additional check for gshadow entry.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: extend basic groupmod test
Iker Pedrosa [Wed, 12 Mar 2025 08:18:57 +0000 (09:18 +0100)] 
tests/: extend basic groupmod test

Add additional check for gshadow entry.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: extend basic groupadd test
Iker Pedrosa [Wed, 12 Mar 2025 08:16:36 +0000 (09:16 +0100)] 
tests/: extend basic groupadd test

Add additional check for gshadow entry.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: extend basic userdel test
Iker Pedrosa [Wed, 12 Mar 2025 08:10:25 +0000 (09:10 +0100)] 
tests/: extend basic userdel test

Add additional checks for shadow and gshadow entries.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: extend basic usermod test
Iker Pedrosa [Wed, 12 Mar 2025 08:09:28 +0000 (09:09 +0100)] 
tests/: extend basic usermod test

Add additional checks for shadow and gshadow entries.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: extend basic useradd test
Iker Pedrosa [Mon, 10 Mar 2025 08:50:56 +0000 (09:50 +0100)] 
tests/: extend basic useradd test

The test framework PoC only provided basic checks. I've added additional
functionality to the framework by checking shadow and gshadow entries
and I've extended the basic useradd test to check those too.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: improve version detection
Iker Pedrosa [Tue, 1 Apr 2025 07:35:46 +0000 (09:35 +0200)] 
tests/: improve version detection

Alpine Linux versions also contain the revision, and this needs to be
taken into account when detecting it.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: improve distribution detection
Iker Pedrosa [Wed, 12 Mar 2025 13:59:38 +0000 (14:59 +0100)] 
tests/: improve distribution detection

openSUSE includes comment lines in `/etc/os-release` file and this can
cause some issues during the distribution detection. Ignore those lines
as they don't cause any effect on the system.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: enable `FORCE_SHADOW` in configuration
Iker Pedrosa [Wed, 12 Mar 2025 12:03:01 +0000 (13:03 +0100)] 
tests/: enable `FORCE_SHADOW` in configuration

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: implement `days_since_epoch()`
Iker Pedrosa [Mon, 10 Mar 2025 08:48:26 +0000 (09:48 +0100)] 
tests/: implement `days_since_epoch()`

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: implement feature detection
Iker Pedrosa [Mon, 31 Mar 2025 15:49:22 +0000 (17:49 +0200)] 
tests/: implement feature detection

Implement a general function to detect features in shadow host.

Apparently, musl doesn't provide `getent gshadow`, but shadow still needs
it to check for several group attributes. Thus, check whether it exists
in the host, and if it does run it. If not, let's just skip that part of
the test.

Link: <https://gitlab.alpinelinux.org/alpine/aports/-/issues/16979>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: implement binding for `getent gshadow $name`
Iker Pedrosa [Wed, 5 Mar 2025 17:05:59 +0000 (18:05 +0100)] 
tests/: implement binding for `getent gshadow $name`

Provide a way for the system framework to run `getent gshadow $name` and
check its output in a meaningful way.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agotests/: implement binding for `getent shadow $name`
Iker Pedrosa [Mon, 3 Mar 2025 08:29:57 +0000 (09:29 +0100)] 
tests/: implement binding for `getent shadow $name`

Provide a way for the system framework to run `getent shadow $name` and
check its output in a meaningful way.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
2 months agonewgidmap: better error logging on failure
Matthew Hughes [Fri, 2 May 2025 10:44:27 +0000 (11:44 +0100)] 
newgidmap: better error logging on failure

Much like the previous commit, similarly relies on `sub_gid_open`
preserving `errno`.

2 months agonewuidmap: better error logging on failure
Matthew Hughes [Tue, 29 Apr 2025 16:56:59 +0000 (17:56 +0100)] 
newuidmap: better error logging on failure

The handling for `sub_uid_open` relies on `commonio_open` preserving
`errno`, which it appears to make an effort do, but doesn't explicitly
document.

Closes: https://github.com/shadow-maint/shadow/issues/1253
3 months agolib/strtoday.c: strtoday(): Replace obsolete comment
Alejandro Colomar [Tue, 18 Feb 2025 14:21:56 +0000 (15:21 +0100)] 
lib/strtoday.c: strtoday(): Replace obsolete comment

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agoman/: Localized dates are not accepted anymore
Alejandro Colomar [Wed, 19 Feb 2025 17:46:54 +0000 (18:46 +0100)] 
man/: Localized dates are not accepted anymore

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agoman/: Consistently express dates in standard format
Alejandro Colomar [Wed, 19 Feb 2025 17:46:18 +0000 (18:46 +0100)] 
man/: Consistently express dates in standard format

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/getdate.y: Don't parse a raw number; just a calendar date
Alejandro Colomar [Tue, 18 Feb 2025 14:29:54 +0000 (15:29 +0100)] 
lib/getdate.y: Don't parse a raw number; just a calendar date

Our caller, strtoday(), already handles a raw number.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/getdate.y: Don't parse dates in local formats; just YYYY-MM-DD
Alejandro Colomar [Tue, 18 Feb 2025 11:34:58 +0000 (12:34 +0100)] 
lib/getdate.y: Don't parse dates in local formats; just YYYY-MM-DD

3 months agolib/getdate.y: Remove unnecessary variable
Alejandro Colomar [Tue, 18 Feb 2025 12:13:09 +0000 (13:13 +0100)] 
lib/getdate.y: Remove unnecessary variable

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/getdate.y: Don't parse week days
Alejandro Colomar [Tue, 18 Feb 2025 11:28:44 +0000 (12:28 +0100)] 
lib/getdate.y: Don't parse week days

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/getdate.y: Don't parse relative dates, such as 'yesterday'
Alejandro Colomar [Tue, 18 Feb 2025 11:16:48 +0000 (12:16 +0100)] 
lib/getdate.y: Don't parse relative dates, such as 'yesterday'

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/getdate.y: Don't parse times; just dates
Alejandro Colomar [Tue, 18 Feb 2025 10:54:49 +0000 (11:54 +0100)] 
lib/getdate.y: Don't parse times; just dates

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agoman/useradd.8.xml: fix the CREATE_HOME description
Serge Hallyn [Thu, 24 Apr 2025 00:28:48 +0000 (19:28 -0500)] 
man/useradd.8.xml: fix the CREATE_HOME description

Fixes: #1249
Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 months agoci: add `gawk` as a fedora dependency
Iker Pedrosa [Fri, 25 Apr 2025 07:15:40 +0000 (09:15 +0200)] 
ci: add `gawk` as a fedora dependency

Recently fedora 42 was released and `gawk` was missing as a dependency.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 months agoAdd LOGIN_ENV_SAFELIST to FOREIGNDEFS
Stanislav Brabec [Wed, 9 Apr 2025 00:03:10 +0000 (02:03 +0200)] 
Add LOGIN_ENV_SAFELIST to FOREIGNDEFS

util-linux-2.41 introduced new variable: LOGIN_ENV_SAFELIST.
Add it to known login.defs variables.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
4 months agoAccept /usr/sbin/nologin as an alternate to /sbin/nologin
Chris Hofstaedtler [Fri, 28 Mar 2025 11:12:13 +0000 (12:12 +0100)] 
Accept /usr/sbin/nologin as an alternate to /sbin/nologin

Relevant on fully-usr-merged distributions.

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Reported-by: Marc Haber
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agoQuick fix: define E_PAM_ERR in lib/pam_pass.c
Serge Hallyn [Wed, 26 Mar 2025 13:23:52 +0000 (08:23 -0500)] 
Quick fix: define E_PAM_ERR in lib/pam_pass.c

The exit code situation is a hot mess. Do a
  git grep "define.*E_SUCCESS"
Each src/*.c is defining its own set of error codes, and
they are frequently conflicting, e.g. more than one use
10.

We should probably have a common set defined in lib/exitcodes.h.
I'm thinking for a first cut, we just move all the definitions
from src/*.c to lib/exitcodes.h, and let the conflicts stand.
If we later want to change some defines to make them unambiguous
across the project, we can do that separately.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 months agopwconv.8 man page improvements
Markus Hiereth [Wed, 8 Jan 2025 21:46:46 +0000 (22:46 +0100)] 
pwconv.8 man page improvements

Bug-Debian: https://bugs.debian.org/1004418

4 months agochfn.1 man page improvements
Markus Hiereth [Wed, 8 Jan 2025 21:45:54 +0000 (22:45 +0100)] 
chfn.1 man page improvements

Bug-Debian: https://bugs.debian.org/1004688

4 months agopasswd: document exit code when PAM has errored
Serge Hallyn [Sat, 22 Mar 2025 12:54:27 +0000 (07:54 -0500)] 
passwd: document exit code when PAM has errored

closes #1219

When pam returns an error, we were exiting with exit code 10,
which was hardcoded and not documented.  Create a name for it,
and document it in the manpage.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Reported-by: Marc Haber <githubvisible@zugschlus.de>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agoCI: purge man-db
Iker Pedrosa [Thu, 20 Mar 2025 09:27:29 +0000 (10:27 +0100)] 
CI: purge man-db

This accelerates the CI.

Closes: https://github.com/shadow-maint/shadow/issues/1240
Link: <https://101010.pl/@nabijaczleweli/114149412203886808>
Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
4 months agorelease 4.17.4 4.17.4
Serge Hallyn [Wed, 19 Mar 2025 18:58:04 +0000 (13:58 -0500)] 
release 4.17.4

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 months agotests/unit/test_xasprintf.c: Fix sign-mismatch diagnostic
Alejandro Colomar [Sun, 9 Feb 2025 13:10:55 +0000 (14:10 +0100)] 
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>
4 months agosrc/lastlog.c: Use ssizeof() to avoid a -Wsign-compare diagnostic
Alejandro Colomar [Sun, 9 Feb 2025 11:45:11 +0000 (12:45 +0100)] 
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>
4 months agolib/sizeof.h: ssizeof(): Add signed variant of sizeof
Alejandro Colomar [Sun, 9 Feb 2025 11:44:34 +0000 (12:44 +0100)] 
lib/sizeof.h: ssizeof(): Add signed variant of sizeof

Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 months agoautogen.sh: Promote -Wsign-compare to an error
Alejandro Colomar [Sun, 9 Feb 2025 11:37:02 +0000 (12:37 +0100)] 
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>
4 months agolib/fs/readlink/: readlinknul(): Use ssize_t to simplify
Alejandro Colomar [Sun, 9 Feb 2025 11:23:46 +0000 (12:23 +0100)] 
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>
4 months agodoc/: Remove list of distributions
Michael Vetter [Mon, 10 Feb 2025 16:43:05 +0000 (17:43 +0100)] 
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.

4 months agolib/commonio.c: Rely on the POSIX.1-2008 behavior of realpath(3)
Alejandro Colomar [Sat, 22 Feb 2025 23:22:13 +0000 (00:22 +0100)] 
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>
4 months agosrc/: update group audit messages
Iker Pedrosa [Fri, 24 Jan 2025 13:19:04 +0000 (14:19 +0100)] 
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>
4 months agolib/: audit function for groups
Iker Pedrosa [Fri, 24 Jan 2025 13:09:02 +0000 (14:09 +0100)] 
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>