]>
git.ipfire.org Git - thirdparty/shadow.git/log
Alejandro Colomar [Tue, 2 Jul 2024 12:03:27 +0000 (14:03 +0200)]
lib/port.c: getttyuser(): Remove dead code
port.pt_names cannot be NULL; it always points to the static array ttys.
$ grep -rn pt_names
lib/port.c:157: port.pt_names = ttys;
lib/port.c:159: port.pt_names[j] = cp;
lib/port.c:172: port.pt_names[j] = NULL;
lib/port.c:344: for (i = 0; NULL != port->pt_names[i]; i++) {
lib/port.c:345: if (portcmp (port->pt_names[i], tty) == 0) {
lib/port.c:350: if (port->pt_names[i] == 0) {
lib/port.h:39: * pt_names - pointer to array of device names in /dev/
lib/port.h:45: char **pt_names;
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 19 May 2024 00:05:16 +0000 (02:05 +0200)]
contrib/adduser.c: main(): Use strcpy/cat(3) instead of their pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 18 May 2024 23:53:12 +0000 (01:53 +0200)]
contrib, lib/, src/, tests/: Use stpcpy(3) instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 18 May 2024 19:38:24 +0000 (21:38 +0200)]
lib/, src/: Use strrspn() instead of its pattern
This requires changing isspace(3) calls to an explicit accept string,
and I chose " \t\n" for it (as is done in other parts of this project),
which isn't exactly the same, but we probably don't want other
isspace(3) characters in those files, so it should work.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 18 May 2024 21:45:46 +0000 (23:45 +0200)]
lib/sssd.c: Style fixes
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 18 May 2024 20:03:08 +0000 (22:03 +0200)]
src/login_nopam.c: login_access(): Simplify, calling strchr(3)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 18 May 2024 23:00:21 +0000 (01:00 +0200)]
lib/getdef.c: def_load(): Use stp[c]spn() instead of their patterns
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 18 May 2024 18:41:30 +0000 (20:41 +0200)]
lib/string/strchr/: stp[c]spn(), strrspn(), strnul(): Add macros and functions
Often, a pointer is more useful than a length when calling these.
Link: <https://docs.oracle.com/cd/E86824_01/html/E54769/strrspn-3gen.html>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 20:44:05 +0000 (21:44 +0100)]
src/chage.c: Simplify, by calling a2sl() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 20:39:43 +0000 (21:39 +0100)]
src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 20:22:30 +0000 (21:22 +0100)]
src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 20:21:00 +0000 (21:21 +0100)]
src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 20:17:13 +0000 (21:17 +0100)]
src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:54:38 +0000 (20:54 +0100)]
src/: Use get_[ug]id() where appropriate
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:20:07 +0000 (20:20 +0100)]
lib/shadow.c: my_sgetspent(): Simplify error handling
Handle negative values as errors from a2sl(), and reuse its
error-handling code.
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:21:39 +0000 (20:21 +0100)]
lib/shadow.c: my_sgetspent(): Remove dead code
spwd.sp_flag is an unsigned long, which can never be negative.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:09:58 +0000 (20:09 +0100)]
lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
This reduces indentation.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:04:43 +0000 (20:04 +0100)]
lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:03:58 +0000 (20:03 +0100)]
lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:03:33 +0000 (20:03 +0100)]
lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:03:16 +0000 (20:03 +0100)]
lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:02:38 +0000 (20:02 +0100)]
lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:01:57 +0000 (20:01 +0100)]
lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:01:09 +0000 (20:01 +0100)]
lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 19:00:03 +0000 (20:00 +0100)]
lib/getdef.c: getdef_unum(): Fix wrong limit check
The limit, since it's an unsigned int, should have been UINT_MAX, not
INT_MAX. By calling a2ui() we can fix that and simplify too.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 18:58:02 +0000 (19:58 +0100)]
lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 30 Jun 2024 22:06:48 +0000 (00:06 +0200)]
Remove groups(1)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 May 2024 12:41:45 +0000 (14:41 +0200)]
Remove id(1)
Distributions use id(1) from GNU coreutils or BusyBox. Drop ours.
Closes: <https://github.com/shadow-maint/shadow/issues/1005>
Suggested-by: dkwo <nicolopiazzalunga@gmail.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Michael Vetter <jubalh@iodoru.org>
Cc: Sam James <sam@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 31 May 2024 16:30:16 +0000 (18:30 +0200)]
lib/idmapping.c: Use long constants in prctl(2), and remove 0s
The prctl(2) system-call wrapper is implemented as a variadic function.
This makes it important to pass arguments to it of the right type (and
more importantly of the right width), to avoid undefined behavior.
While at it, check errors with ==-1, not <0, which is more explicit.
Also, PR_SET_KEEPCAPS(2const) doesn't need all arguments, so it can be
called with just two of them; remove unnecessary 0s.
See-also: prctl(2), PR_SET_KEEPCAPS(2const)
Link: <https://lore.kernel.org/linux-man/ddbdyaiptesjalgfmztxideej67e3yaob7ucsmbf6qvriwxiif@dohhxrqgwhrf/T/#med306b5b003f9cc7cc2de69fcdd7ee2d056d0954>
Cc: Xi Ruoyao <xry111@xry111.site>
Cc: Lukas Slebodnik <lslebodn@fedoraproject.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 30 Jun 2024 22:24:40 +0000 (00:24 +0200)]
lib/attr.h: Use C23-style attributes
They're stricter. The GNU attributes are too lazy, and can be misused
more easily. Also, mixing both has its own problems.
Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 30 Jun 2024 21:55:56 +0000 (23:55 +0200)]
lib/gshadow.c: Use XREALLOC() instead of silently continuing on ENOMEM
We should do better, and correctly handle errors, since this is library
code. However, I'm lazy right now, so let's die hard, and let us
improve this later.
Link: <https://github.com/shadow-maint/shadow/pull/991#discussion_r1660308154>
Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 30 Jun 2024 21:50:31 +0000 (23:50 +0200)]
src/: Remove dead code
FIRST_MEMBER_IS_ADMIN was never enabled. And BTW, that code had been
broken for a long time, so probably nobody should manually enable it.
Link: <https://github.com/shadow-maint/shadow/pull/991#discussion_r1660308748>
Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 29 Jun 2024 16:43:47 +0000 (18:43 +0200)]
lib/: Use [[gnu::alloc_size(...)]] on allocation functions
Suggested-by: Martin Uecker <uecker@tugraz.at>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 27 Jun 2024 15:19:36 +0000 (17:19 +0200)]
lib/: Use multi-line macro definitions
This reduces the complexity of those nested parentheses.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 27 Jun 2024 14:42:54 +0000 (16:42 +0200)]
lib/alloc/, lib/, src/, tests/: Organize the allocation APIs in a new subdirectory
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 27 Jun 2024 13:58:18 +0000 (15:58 +0200)]
lib/alloc.[ch]: xmalloc(): Remove unused function
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 27 Jun 2024 12:16:16 +0000 (14:16 +0200)]
lib/string/strdup/xstrdup.[ch], lib/, src/: Move xstrdup() to its own file
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 14 May 2024 16:41:21 +0000 (18:41 +0200)]
lib/string/strcpy/zustr2stp.[ch], tests/: Remove ZUSTR2STP()
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 21 May 2024 11:58:12 +0000 (13:58 +0200)]
src/logoutd.c: Use STRNCAT() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 14 May 2024 16:15:55 +0000 (18:15 +0200)]
src/logoutd.c: Use STRNDUPA() instead of its pattern
STRNDUPA() is equivalent to automatic storage allocation (alloca(3))
+ ZUSTR2STP().
The benefits of this refactor are:
- The allocation size is always correct, and needs no comments, since
it's now automatically calculated by the macro.
- STRNDUPA() is probably more familiar, since
- strndupa(3) is a libc function,
- STRNDUPA() is the obvious wrapper that
calculates the size based on the input array.
- We can remove ZUSTR2STP().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 14 May 2024 19:37:53 +0000 (21:37 +0200)]
src/newusers.c: Exit on ENOMEM, by calling xstrdup() instead of strdup(3)
The program was happily ignoring ENOMEM errors.
Fixes: 7f9e19690333 ("* NEWS, src/newusers.c, src/Makefile.am: Added support for")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 13:48:53 +0000 (15:48 +0200)]
lib/utmp.c: prepare_utmp(): Use xstrdup() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 13:47:19 +0000 (15:47 +0200)]
lib/utmp.c: Use XSTRNDUP() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 13:21:48 +0000 (15:21 +0200)]
lib/string/strdup/: XSTRNDUP(), STRNDUPA(): Add macros
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 21 May 2024 10:50:27 +0000 (12:50 +0200)]
lib/string/strcpy/strncat.[ch]: STRNCAT(): Add macro
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 12:37:14 +0000 (14:37 +0200)]
src/: Use xasprintf() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 12:46:47 +0000 (14:46 +0200)]
src/groupmems.c: Fix number of elements in allocation
We are setting `sgrent.sg_adm[1] = NULL;`, so we need 2 elements.
Fixes: 87b56b19fb72 ("* NEWS, src/groupmems.c, man/groupmems.8.xml: Added support for [...]")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 02:07:51 +0000 (04:07 +0200)]
lib/gshadow.c: build_list(): Fix REALLOC() nmemb calculation
Fixes: efbbcade43ff ("Use safer allocation macros")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 12 May 2024 23:24:47 +0000 (01:24 +0200)]
lib/gshadow.c: build_list(): Fix forever loop on ENOMEM
Before this patch, the function looped while (s != NULL && *s != '\0').
However, nothing was modifying that string if REALLOC() failed, so the
loop was forever.
Fixes: 8e167d28afd6 ("[svn-upgrade] Integrating new upstream version, shadow (4.0.8)")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 12 May 2024 23:02:59 +0000 (01:02 +0200)]
lib/, src/: Use strsep(3) instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 12 May 2024 22:13:41 +0000 (00:13 +0200)]
src/useradd.c: tallylog_reset(): Use Basename() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 12 May 2024 21:44:35 +0000 (23:44 +0200)]
lib/, src/: Use strchrnul(3) instead of its pattern
In the files where #include <string.h> is missing, add it, and sort the
includes.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 12 May 2024 21:15:12 +0000 (23:15 +0200)]
lib/commonio.c: commonio_open(): MALLOC() and REALLOCF() already set ENOMEM
We don't need to set ENOMEM on failure of those functions.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 12 May 2024 23:18:48 +0000 (01:18 +0200)]
lib/: Use REALLOCF() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 14:37:56 +0000 (16:37 +0200)]
lib/, src/: Add missing include
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 20 May 2024 15:34:30 +0000 (17:34 +0200)]
lib/failure.c: failprint(): Remove dead code
This should have gone into the #else'd branch in
8451bed8b06d , and
should have been removed in
3e602b58a2aa .
Fixes: 8451bed8b06d ("[svn-upgrade] Integrating new upstream version, shadow (4.0.13)")
Fixes: 3e602b58a2aa ("Remove HAVE_STRFTIME ifdefs")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 14 May 2024 17:58:36 +0000 (19:58 +0200)]
lib/, src/: Always pass NULL to time(2)
See time(2):
BUGS
Error returns from this system call are indistinguishable from
successful reports that the time is a few seconds before the
Epoch, so the C library wrapper function never sets errno as a re‐
sult of this call.
The tloc argument is obsolescent and should always be NULL in new
code. When tloc is NULL, the call cannot fail.
Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 14 May 2024 17:49:39 +0000 (19:49 +0200)]
lib/getdate.y: NULL doesn't need a cast
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 20 May 2024 14:22:56 +0000 (16:22 +0200)]
lib/shadow.c: my_sgetspent(): Clarify that we're assigning an empty string
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 21:24:38 +0000 (23:24 +0200)]
lib/, src/: Reduce scope of local variables
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 12:31:01 +0000 (14:31 +0200)]
src/login.c: Remove dead code
The functions that set these strings --do_rlogin() and login_prompt()--
make sure to terminate them with a NUL.
Fixes: 3704745289f5 ("* lib/defines.h: Define USER_NAME_MAX_LENGTH, based on utmp and [...]")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 13 May 2024 21:18:19 +0000 (23:18 +0200)]
src/logoutd.c: Remove unused variable
wait(2) accepts NULL if the status won't be read. Simplify.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 20 May 2024 15:51:27 +0000 (17:51 +0200)]
src/su.c: save_caller_context(): Remove unused parameter
Fixes: e6c2e4393784 ("Hardcoding Prog to known value")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 27 Jun 2024 09:48:16 +0000 (11:48 +0200)]
lib/string/strcpy/, lib/, src/, tests/: Move all copying APIs to a subdirectory
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 27 Jun 2024 09:29:56 +0000 (11:29 +0200)]
lib/string/sprintf/, lib/, src/, tests/: Move all sprintf(3)-like APIs to a subdirectory
And have a separate file for each pair of APIs.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 29 Jun 2024 17:35:14 +0000 (19:35 +0200)]
src/get_subid_owners.c: Use uid_t for holding UIDs (and GIDs)
Suggested-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 May 2024 22:25:41 +0000 (00:25 +0200)]
src/usermod.c: Fix const correctness
Now that we use liba2i's const-generic macros, we can (and must) use a
'const char **' endp where the input string is 'const char *'.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 17:02:24 +0000 (18:02 +0100)]
lib/limits.c: setrlimit_value(): Reimplement in terms of a2i()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 16:46:21 +0000 (17:46 +0100)]
lib/, po/, src/: get_uid(): Move function to "atoi/getnum.h"
Implement it as an inline function, and add restrict and ATTR_STRING()
and ATTR_ACCESS() as appropriate.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 16:40:51 +0000 (17:40 +0100)]
lib/get_uid.c: get_uid(): Reimplement in terms of a2i()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 16:35:29 +0000 (17:35 +0100)]
src/usermod.c: getulong_range(): Reimplement in terms of a2ul()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 16:05:43 +0000 (17:05 +0100)]
lib/get_pid.c: get_pidfd_from_fd(): Don't open-code get_fd()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 16:01:52 +0000 (17:01 +0100)]
lib/atoi/getnum.[ch]: get_fd(): Add function for parsing a file descriptor from a string
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 15:41:24 +0000 (16:41 +0100)]
lib/: get_pid(): Move function to "atoi/getnum.h"
Implement it as an inline function, and add restrict and ATTR_STRING()
and ATTR_ACCESS() as appropriate.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 15:36:08 +0000 (16:36 +0100)]
lib/get_pid.c: get_pid(): Reimplement in terms of a2i()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 14:48:55 +0000 (15:48 +0100)]
lib/: Don't open-code get_gid()
These functions were open-coding get_gid(). Use the actual function.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 14:34:28 +0000 (15:34 +0100)]
lib/, libsubid/, po/, src/: get_gid(): Move function to "atoi/getnum.h"
Implement it as an inline function, and add restrict and ATTR_STRING()
and ATTR_ACCESS() as appropriate.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 9 Jan 2024 14:11:25 +0000 (15:11 +0100)]
lib/get_gid.c: get_gid(): Reimplement in terms of a2i()
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 6 Jan 2024 21:12:06 +0000 (22:12 +0100)]
src/: Use str2[u]l() instead of atoi(3)
atoi(3) easily triggers Undefined Behavior. Replace it by str2[u]l(),
which are safe from that, and add type safety too.
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 29 Jun 2024 17:32:32 +0000 (19:32 +0200)]
tests/unit/test_typetraits.c: Add tests for typetraits.h macros
Suggested-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 1 Dec 2023 23:16:49 +0000 (00:16 +0100)]
lib/typetraits.h: Add macros that give information about a type
In the case of is_unsigned() and is_signed(), the natural thing would be
to compare to 0:
#define is_unsigned(x) (((typeof(x)) -1) > 0)
#define is_signed(x) (((typeof(x)) -1) < 0)
However, that would trigger -Wtype-limits, so we compare against 1,
which silences that, and does the same job.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Serge Hallyn [Fri, 28 Jun 2024 15:37:39 +0000 (10:37 -0500)]
tests/run_some: make sure unshared root user can descend build dir
This was causing errors in my local testing in vms.
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Alejandro Colomar [Fri, 28 Jun 2024 10:21:01 +0000 (12:21 +0200)]
Makefile.am: Use 'dist-hook' to clean up <tests/unit/Makefile>
Closes: <https://github.com/shadow-maint/shadow/issues/1027>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Co-developed-by: Serge Hallyn <shallyn@cisco.com>
Signed-off-by: Serge Hallyn <shallyn@cisco.com>
Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Serge Hallyn [Fri, 28 Jun 2024 06:30:40 +0000 (01:30 -0500)]
have_range: open the subid db if needed
When we run for instance
check_subid_range ubuntu u 100000 65536
when ubuntu user is defined and has that range, it returns no entries
because the subid db is not opened. Open it in have_range if needed.
I haven't figured out why this ever worked.
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Serge Hallyn [Fri, 28 Jun 2024 04:10:22 +0000 (23:10 -0500)]
libsubid test makefile: fix a typo
Fix a missing space after the -I path
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Alejandro Colomar [Fri, 28 Jun 2024 11:57:35 +0000 (13:57 +0200)]
tests/unit/test_xasprintf.c: Fix use of volatile pointer
volatile needs to be casted away behind a [[gnu::noipa]] function, to
make that invisible to the compiler. Otherwise, the compiler can see
that it is being discarded, and is free to abuse Undefined Behavior.
Closes: <https://github.com/shadow-maint/shadow/issues/1028>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Tested-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 28 Jun 2024 11:51:36 +0000 (13:51 +0200)]
tests/unit/test_xasprintf.c: Cosmetic
This is in preparation for the following commit.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Serge Hallyn [Sat, 25 May 2024 13:40:11 +0000 (08:40 -0500)]
tests/: Support run_some from exported tarball
common/config.sh currently tries to find the top directory by looking
for .git. There are also many places under tests/ where we use
hard-coded ../../.. to find things like ${TOP_DIR}/lib.
We don't actually ship the tests with 'make dist'. So we will
be exporting tests/ as a separate tarball. In particular, I want
to then import this in the debian package. However, there it will
be under shadow.git/debian/tests, not shadow.git/tests.
To support this, accept the environment variable BUILD_BASE_DIR,
which should point to shadow.git.
An alternative would be to move the tests to their own git
tree. However, keeping tests in separate git tree tends to
lead to repos getting out of sync. And we'd still need to accept
something like BUILD_BASE_DIR.
Note there are a lot of tests under run-all, which I'm not converting
as they currently are not being run in CI, so I'm more likely to
break something.
Changelog:
2024 05 26: Incorporate feedback from alejandro-colomar
Link: <https://salsa.debian.org/debian/shadow/-/merge_requests/21>
Link: <https://salsa.debian.org/debian/shadow/-/merge_requests/22>
Cc: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 19 Jun 2024 17:54:16 +0000 (19:54 +0200)]
lib/csrand.c: Fix the lower part of the domain of csrand_uniform()
I accidentally broke this code during an un-optimization. We need to
start from a random value of the width of the limit, that is, 32 bits.
Thanks to Jason for pointing to his similar code in the kernel, which
made me see my mistake.
Fixes: 2a61122b5e8f ("Unoptimize the higher part of the domain of csrand_uniform()")
Closes: <https://github.com/shadow-maint/shadow/issues/1015>
Reported-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
Link: <https://git.zx2c4.com/linux-rng/tree/drivers/char/random.c#n535>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Link: <https://github.com/shadow-maint/shadow/pull/638>
Link: <https://github.com/shadow-maint/shadow/issues/634>
Link: <https://github.com/shadow-maint/shadow/pull/624>
Tested-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
Reviewed-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Serge Hallyn [Tue, 18 Jun 2024 21:34:10 +0000 (16:34 -0500)]
configure.ac: release 4.16.0
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Serge Hallyn [Thu, 13 Jun 2024 23:09:08 +0000 (18:09 -0500)]
release 4.16.0-rc1
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Serge Hallyn [Fri, 14 Jun 2024 00:56:48 +0000 (19:56 -0500)]
configure.ac: specify tar-pax to avoid 99 char filename limit
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Alejandro Colomar [Fri, 17 May 2024 23:57:40 +0000 (01:57 +0200)]
Remove support for rlogind in login(1), that is, remove the '-r' flag
The "quick hack" finally disappeared. Probably nobody noticed. ;)
(See the changes in <configure.ac> for the context of this pun.)
Probably everybody uses SSH these days for remote login. Let's remove
this insecure method.
Closes: <https://github.com/shadow-maint/shadow/issues/992>
Reviewed-by: dkwo <nicolopiazzalunga@gmail.com>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Michael Vetter <jubalh@iodoru.org>
Cc: Sam James <sam@gentoo.org>
Cc: Benedikt Brinkmann <datacobra@thinkbot.de>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Daniel Bershatsky [Wed, 12 Jun 2024 19:25:11 +0000 (22:25 +0300)]
libsubid: Fix code style issues
Daniel Bershatsky [Wed, 12 Jun 2024 17:07:23 +0000 (20:07 +0300)]
libsubid: Fail on plugin loading if no subid_free provided
Daniel Bershatsky [Wed, 12 Jun 2024 14:38:43 +0000 (17:38 +0300)]
libsubid: Apply minor fixes
Daniel Bershatsky [Mon, 10 Jun 2024 22:12:45 +0000 (01:12 +0300)]
libsubid: Add routine to free allocated memory
Daniel Bershatsky [Wed, 12 Jun 2024 16:26:45 +0000 (19:26 +0300)]
libsubid: Dealocate memory on exit
lixinyun [Tue, 28 May 2024 22:53:02 +0000 (06:53 +0800)]
src/groupmod.c: delete gr_free_members(&grp) to avoid double free
Groupmod -U may cause crashes because of double free. If without -a, the first free of (*ogrp).gr_mem is in gr_free_members(&grp), and then in gr_update without -n or gr_remove with -n.
Considering the minimal impact of modifications on existing code, delete gr_free_members(&grp) to avoid double free.Although this may seem reckless, the second free in two different positions will definitely be triggered, and the following two test cases can be used to illustrate the situation :
[root@localhost src]# ./useradd u1
[root@localhost src]# ./useradd u2
[root@localhost src]# ./useradd u3
[root@localhost src]# ./groupadd -U u1,u2,u3 g1
[root@localhost src]# ./groupmod -n g2 -U u1,u2 g1
Segmentation fault
This case would free (*ogrp).gr_mem in gr_free_members(&grp) due to assignment statements grp = *ogrp, then in if (nflg && (gr_remove (group_name) == 0)), which finally calls gr_free_members(grent) to free (*ogrp).gr_mem again.
[root@localhost src]# ./useradd u1
[root@localhost src]# ./useradd u2
[root@localhost src]# ./useradd u3
[root@localhost src]# ./groupadd -U u1,u2,u3 g1
[root@localhost src]# ./groupmod -U u1,u2 g1
Segmentation fault
The other case would free (*ogrp).gr_mem in gr_free_members(&grp) too, then in if (gr_update (&grp) == 0), which finally calls gr_free_members(grent) too to free (*ogrp).gr_mem again.
So the first free is unnecessary, maybe we can drop it.
Fixes: 342c934a3590 ("add -U option to groupadd and groupmod")
Closes: <https://github.com/shadow-maint/shadow/issues/1013>
Link: <https://github.com/shadow-maint/shadow/pull/1007>
Link: <https://github.com/shadow-maint/shadow/pull/271>
Link: <https://github.com/shadow-maint/shadow/issues/265>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: lixinyun <li.xinyun@h3c.com>
Serge Hallyn [Wed, 5 Jun 2024 13:02:27 +0000 (08:02 -0500)]
man/lastlog: remove wrong use of keyword term
Per https://tdg.docbook.org/tdg/4.5/term, term is a word being
defined in a varlistentry. The 'high uid' description is not a
varlistentry, so <term> and </term> show up in the processed
manpage. See debian Bug#
1072297 .
Signed-off-by: Serge Hallyn <serge@hallyn.com>