3841 Commits

Author SHA1 Message Date
Serge Hallyn
d3fa0ba5b8 Release 4.17.3
Signed-off-by: Serge Hallyn <serge@hallyn.com>
4.17.3
2025-02-24 08:12:25 -06:00
Chris Hofstaedtler
40bb89b6a4 chsh: do not warn about blank shell
Closes: <https://bugs.debian.org/876542>
Reported-by: 積丹尼 Dan Jacobson <jidanni@jidanni.org>
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
2025-02-21 08:27:04 +01:00
Alejandro Colomar
77eb67d4a8 lib/: Use strisdigit() instead of its pattern
Note that the old code in

	(1)  lib/strtoday.c:strtoday()
	(2)  lib/subordinateio.c:append_uids()

was considering an empty string as if it were a number.
strisdigit() does not consider an empty string to be numeric.

I think it will not affect the behavior in either case, as they should
sooner or later result in an error somewhere.  And it seems (IMO)
surprising to treat empty strings as numeric strings, so let's not do
it.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 16:12:16 -06:00
Alejandro Colomar
79142cd281 lib/string/ctype/strisascii/: strisdigit(): Add function
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 16:12:16 -06:00
Alejandro Colomar
3cba5e2e1c lib/string/: Add comments expanding the letter-soup API names
Suggested-by: Serge Hallyn <serge@hallyn.com>
Cc: Chris Bazley <Chris.Bazley@arm.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
887e77d52a lib/basename.c: Basename(): Use stprcspn() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
a0d4ea3bec lib/string/strspn/, lib/, src/: stprspn(), strrspn_(): Split API into function and macro
This provides a safer and more consistent API.

We had the strrspn(3) function as it was for compatibility with Oracle
Solaris, but let's not repeat their mistake.  Nevertheless, name our
function strrspn_() with a trailing underscore, to differentiate it from
the one in Solaris, since it's slightly different.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
872de49dcf lib/string/strspn/, lib/, src/: Move *spn() APIs to separate subdir
This provides a better organization.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
c2a634efa7 lib/string/strchr/: strrcspn(), stprcspn(): Add function and macro
These APIs are to strrspn(), like strcspn() is to strspn().
They are like strcspn(3), but search from the end of the string.

The function is meant for internal use, and consistency with libc.
The macro is meant for normal use, since it returns a pointer,
which is what algorithms using this need.

See also strspn(3) and strcspn(3).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-16 13:22:51 -06:00
Alejandro Colomar
7936241f42 src/useradd.c: Use !strcaseeq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-15 10:26:50 -06:00
Alejandro Colomar
5e362305e6 lib/, src/: Use strcaseeq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-15 10:26:50 -06:00
Alejandro Colomar
224466f603 lib/string/strcmp/: strcaseeq(): Add function
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-15 10:26:50 -06:00
Marc Haber
68c3ac04e6 man/useradd.8.xml: Document new exit code 19 (E_BAD_NAME)
Link: <https://github.com/shadow-maint/shadow/issues/1103>
Link: <https://github.com/shadow-maint/shadow/pull/1141>
Signed-off-by: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Cc: Chris Hofstaedtler <zeha@debian.org>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-09 09:00:46 -06:00
Alejandro Colomar
2e47f4dd5f src/useradd.c: E_BAD_NAME: Use a different error code for bad login names
Wrappers like adduser(8) want to do their own stuff if the login name is
bad.  For that, they need to be able to differentiate such an error.

Closes: <https://github.com/shadow-maint/shadow/issues/1103>
Suggested-by: Chris Hofstaedtler <zeha@debian.org>
Cc: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-08 22:08:06 -06:00
Alejandro Colomar
929d3e18cc src/useradd.c: create_home(): Use !streq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:47:21 -06:00
Alejandro Colomar
9a24e88482 lib/chkname.c: is_valid_name(): Use streq() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:47:21 -06:00
Alejandro Colomar
a8dd818ba4 configure.ac, lib/: Use __has_include(<gshadow.h>) instead of HAVE_GSHADOW_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
9eea4bc9cf configure.ac: Remove unused AC_CHECK_HEADERS() checks
$ grep -rE 'HAVE_(UTMP)_H'
$ grep -rE 'HAVE_(TERMIO|SGTTY|SYS_IOCTL|PATHS)_H'
$ grep -rE 'HAVE_(LASTLOG|RPC_KEY_PROT|ACL_LIBACL)_H'
$ grep -rE 'HAVE_(ATTR_LIBATTR|ATTR_ERROR_CONTEXT)_H'
$

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
7d992f16b4 configure.ac, lib/: Use __has_include(<sys/capability.h>) instead of HAVE_SYS_CAPABILITY_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
f50a39e8f9 lib/idmapping.c: Unconditionally include <sys/prctl.h>
It's a widely available header.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
d662b48e72 lib/: Use __has_include(<security/openpam.h>) instead of HAVE_SECURITY_OPENPAM_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
2ed8220835 lib/: Use __has_include(<security/pam_misc.h>) instead of HAVE_SECURITY_PAM_MISC_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
0dcce8ea4b configure.ac, lib/: Use __has_include(<sys/random.h>) instead of HAVE_SYS_RANDOM_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
87ba6c317e configure.ac, lib/: Use __has_include(<crypt.h>) instead of HAVE_CRYPT_H
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:43:55 -06:00
Alejandro Colomar
2a583e945d lib/, src/: motd(): Report errors instead of exiting from library code
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:22:10 -06:00
Alejandro Colomar
a747264bfb lib/motd.c: motd(): Invert logic to reduce indentation
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-07 23:22:10 -06:00
Alejandro Colomar
c2d14e33f7 lib/, src/, doc/: Remove pw_auth()'s $3 as dead code
We don't read the parameter at all.  Remove it.

As a consequence, all the PW_* constants are also removed (as they are
now unused).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-05 16:58:10 +01:00
Alejandro Colomar
6e8d7bf470 lib/pwauth.*: PW_{ADD,CHANGE,DELETE,FTP,REXEC}: Remove dead code
These values aren't being set anywhere.

Reviewed-by: Sam James <sam@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-05 16:58:10 +01:00
Alejandro Colomar
d4ca9fdcf9 lib/, src/, doc/: Remove dead code
pw_auth()'s $4 was always being specified as NULL.  Remove the
parameter.  Instead, set a local variable to NULL at function entry, and
remove code that never runs (conditional on $4 != NULL).

Reviewed-by: Sam James <sam@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-02-05 16:58:10 +01:00
Todd C. Miller
3b12ab7e29 src/vipw.c: Restore the original terminal pgrp after editing
This fixes a problem when the shell is not in monitor mode (job control
enabled) which resulted in the terminal pgrp being set to an invalid
value once vipw exited.

Fixes: 7eca1112fbd7 (2019-11-11; "Fix vipw not resuming correctly when suspended")
Closes: <https://github.com/shadow-maint/shadow/issues/1194>
Reported-by: <https://github.com/yonecle>
Tested-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
2025-01-26 14:59:43 +01:00
Alejandro Colomar
1d7dfa0a7b lib/, src/: Use agetgroups() instead of its pattern
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
05322ed89a lib/shadow/grp/: agetgroups(): Add function
This encapsulates the logic for calling getgroups(3), which requires two
calls plus a malloc(3) call to do it correctly.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
e083b38018 configure.ac, lib/, src/: Use gid_t instead of GETGROUPS_T
Autoconf's NEWS file says

*** AC_FUNC_GETGROUPS and AC_TYPE_GETGROUPS no longer run test programs.
  These macros were testing for OS bugs that we believe are at least
  twenty years in the past.  Most operating systems are now trusted to
  provide an accurate prototype for getgroups in unistd.h, and to
  implement it as specified in POSIX.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
a4a0dbb5d8 lib/adds.h: addslN(): Use QSORT() instead of its pattern
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
478d9785ff lib/search/sort/: QSORT(): Add macro
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
476dbe5926 lib/addgrps.c: add_groups(): Remove arbitrary limit
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
7be3b4c2a8 lib/, src/: Rename variables
Since 'list' is used for a comma/colon-separated-value list, grouplist
is incorrect and inconsistent.  grouplist is not a list, but an array.
Use the more common convention of just using plural.  Also, use 'gids'
to distinguish it from other group representations.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
aaaa3d41a5 lib/addgrps.c: add_groups(): Reallocate at once
We can calculate an upper bound of the number of added groups by
counting the number of delimiters in the string (plus one for the
element after the last delimiter).  This avoids reallocating +1 in a
loop.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
8d42b04c80 lib/string/strchr/: strchrscnt(): Add function
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
9476033aa9 lib/addgrps.c: add_groups(): Split variable to avoid sign-mismatch diagnostics
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
90cd8428c7 lib/, src/: Use LSEARCH() instead of its pattern
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
031486fcc0 lib/search/l/: LSEARCH(): Add macro
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
258265941b lib/, src/: Replace redundant checks by actual error handling
setgroups(2) already performs a test to check if the number of groups is
too large.  Don't do that ourselves, and also don't do it for every
iteration.  Just let setgroups(2) do it once.

Instead of our check, let's report errors from setgroups(2).

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
1b8ae5b551 lib/, src/: Unconditionally call setgroups(2)
Call it regardless of having added any groups.  If the group list is the
same that getgroups(3) gave us, setgroups(3) will be a no-op, and it
simplifies the surrounding code, by removing the 'added' variable, and
allowing to call lsearch(3) instead of lfind(3).

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
a2841ce77c lib/addgrps.c: add_groups(): Simplify redundant code with a goto
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
1fd1bb4c4a lib/addgrps.c: add_groups(): Allocate earlier
This will allow using lsearch(3).

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
1cd099e741 lib/addgrps.c: add_groups(): Remove useless cast
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
85767d1795 lib/, src/: Use LFIND() instead of open-coded search loops
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
e7f5f564c5 lib/search/l/: LFIND(): Add macro
The use of typeof() for the function pointer argument was suggested by
Jorenar.  This improves readability of these complex types.

Co-authored-by: Martin Uecker <uecker@tugraz.at>
Cc: Jorenar <dev@jorenar.com>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00
Alejandro Colomar
224848ebb6 lib/search/cmp/, lib/, tests/: CMP(), cmp_*(): Add macro and functions
These macros are for use with bsearch(3),lfind(3),qsort(3).

Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-01-24 07:58:13 -06:00