]>
git.ipfire.org Git - thirdparty/shadow.git/log
Iker Pedrosa [Thu, 22 Dec 2022 15:29:00 +0000 (16:29 +0100)]
strtoday.c: remove unused defines.h inclusion
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Iker Pedrosa [Thu, 22 Dec 2022 15:26:21 +0000 (16:26 +0100)]
strtoday.c: remove USE_GETDATE as it was always used
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Iker Pedrosa [Thu, 22 Dec 2022 15:14:24 +0000 (16:14 +0100)]
strtoday.c: remove POSIX 1995 conditional dependency
Since the project is supposed to be POSIX.1-2001 compliant it doesn't
make sense to have that added conditionally.
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Alejandro Colomar [Thu, 22 Dec 2022 10:53:44 +0000 (11:53 +0100)]
Assume struct tm is defined in <time.h>
It has been a requirement since at least C90, according to tm(3type).
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 22 Dec 2022 10:42:44 +0000 (11:42 +0100)]
Assume struct stat has st_atim and st_mtim fields
That's required by POSIX.1-2008.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 Dec 2022 16:53:16 +0000 (17:53 +0100)]
Remove USE_SYSLOG preprocessor conditional, which was always defined
Reported-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 Dec 2022 16:43:31 +0000 (17:43 +0100)]
Remove dead code
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 Dec 2022 18:02:25 +0000 (19:02 +0100)]
Don't redefine errno(3)
It is Undefined Behavior to declare errno (see NOTES in its manual page).
Instead of using the errno dummy declaration, use one that doesn't need
a comment.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 16 Dec 2022 00:08:12 +0000 (01:08 +0100)]
Fix typos in length calculations
Link: <https://github.com/shadow-maint/shadow/pull/607>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 16 Dec 2022 00:06:09 +0000 (01:06 +0100)]
Use 'uintmax_t' to print 'gid_t'
This is shorter to write than 'unsigned long int', so we can collapse
some lines. It is guaranteed by C99.
Link: <https://github.com/shadow-maint/shadow/pull/607>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 15 Dec 2022 23:52:27 +0000 (00:52 +0100)]
Fix off-by-one mistakes
The buffers have a size of 512 (see xmalloc() above), which is what
snprintf(3) expects.
Link: <https://github.com/shadow-maint/shadow/pull/607>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 Dec 2022 17:44:06 +0000 (18:44 +0100)]
Cosmetic fixes
Previous commits, to keep readability of the diffs, left the code that
was previously wrapped by preprocessor coditionals untouched. Apply
some minor cosmetic changes to merge it in the surrounding code.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 Dec 2022 17:36:57 +0000 (18:36 +0100)]
Remove traces of utmpx
- USER_NAME_MAX_LENGTH was being calculated in terms of utmpx. Do it
in terms of utmp.
- Remove utmpx support from the whishlist.
- Remove unused tests about utmpx members.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 Dec 2022 17:33:40 +0000 (18:33 +0100)]
Disable utmpx permanently
On Linux, utmpx and utmp are identical. However, documentation (manual
pages) covers utmp, and just says about utmpx that it's identical to
utmp. It seems that it's preferred to use utmp, at least by reading the
manual pages.
Moreover, we were defaulting to utmp (utmpx had to be explicitly enabled
at configuration time). So, it seems safer to just make it permanent,
which should not affect default builds.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 21 Dec 2022 16:59:30 +0000 (17:59 +0100)]
Assume <utmpx.h> always exists
We already made that assumption in commit
b47aa1e9aaf4 . While the
header is not required by POSIX (it is an XSI extension), it is defined
in systems that are of interest to this project (GNU/Linux).
Fixes: b47aa1e9aaf4 ("Assume <utmpx.h> exists")
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 20 Dec 2022 14:10:49 +0000 (15:10 +0100)]
Remove pwdauth.c
We don't know what it was for. If anyone cares, it's in git history.
In my distro, there seem to be no traces of it:
alx@debian:~$ apt-file find pwdauth
alx@debian:~$
Link: <https://codesearch.debian.net/search?q=pwdauth&literal=1>
Link: <https://github.com/shadow-maint/shadow/pull/612>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Michael Vetter [Wed, 9 Nov 2022 13:41:31 +0000 (14:41 +0100)]
Add support for skeleton files from /usr/etc/skel
This patch is used by openSUSE to make useradd look for
skeleton files in /usr/etc/skel additionally to /etc/skel
in accordance with
https://uapi-group.org/specifications/specs/base_directory_specification/
Michael Vetter [Thu, 15 Dec 2022 10:52:58 +0000 (11:52 +0100)]
Fix useradd audit event logging of ID field
When useradd sends its ADD_USER event, it is filling in the id field. This is not yet written to disk. When auditd sees the event and the log format is enriched, auditd tries to lookup the user name but it does not exist. This causes the event to never be resolvable since ausearch relies on the lookup information attached by auditd.
The fix is to not send the id information for any event until after close_files() is called. Just the acct field is all that is
Patch by Steve Grubb (afaik).
Reported at https://bugzilla.redhat.com/show_bug.cgi?id=
1713432
Alejandro Colomar [Tue, 13 Dec 2022 21:30:05 +0000 (22:30 +0100)]
Remove comments that survived the Helicoprion
The OSes that are referred to by these comments, are extinct, but
their comments survived, fossilized in amber.
Reported-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 13 Dec 2022 21:17:51 +0000 (22:17 +0100)]
Ping? :)
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 13 Dec 2022 21:12:51 +0000 (22:12 +0100)]
Remove preprocessor conditionals that are always true
In a previous commit, we made USE_TERMIOS unconditionally defined.
Let's just remove it, and remove the condition everywhere.
Reported-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 13 Dec 2022 21:10:16 +0000 (22:10 +0100)]
Remove code conditional on USE_TERMIO
The definition for this macro was removed in a previous commit.
Reported-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 19:06:39 +0000 (20:06 +0100)]
Assume socket(2) exists
It is required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 19:05:47 +0000 (20:05 +0100)]
Assume inet_ntoa(3) exists
It is required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 18:55:12 +0000 (19:55 +0100)]
Assume F_* and SEEK_* macros are defined
They are required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 18:46:17 +0000 (19:46 +0100)]
Remove code conditional on S_SPLINT_S
I don't know for sure what that is, but it's redefining setlocale(3)
and LC_ALL, which is are defined by C99, so it's supect of being some
variety of an extinct dynosaur. Maybe related to the Dodo.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 18:23:24 +0000 (19:23 +0100)]
Assume strdup(3) exists
It is required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 18:22:25 +0000 (19:22 +0100)]
Assume strcasecmp(3) exists
It is required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 18:20:47 +0000 (19:20 +0100)]
Assume rmdir(2) exists
It is required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 12 Dec 2022 18:17:44 +0000 (19:17 +0100)]
Assume mkdir(2) exists
It is required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 22:07:56 +0000 (23:07 +0100)]
Assume B[0-9]* macros are defined
All of the macros we're using are required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 22:03:29 +0000 (23:03 +0100)]
Assume SIGTTOU is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 22:02:24 +0000 (23:02 +0100)]
Assume SIGTSTP is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:57:47 +0000 (22:57 +0100)]
Assume RLIMIT_STACK is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:56:43 +0000 (22:56 +0100)]
Assume RLIMIT_NOFILE is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:55:18 +0000 (22:55 +0100)]
Assume RLIMIT_FSIZE is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:53:45 +0000 (22:53 +0100)]
Assume RLIMIT_DATA is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:52:52 +0000 (22:52 +0100)]
Assume RLIMIT_CPU is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:51:41 +0000 (22:51 +0100)]
Assume RLIMIT_AS is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:49:57 +0000 (22:49 +0100)]
Assume RLIMIT_CORE is defined
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:42:39 +0000 (22:42 +0100)]
Assume getgrgid_r(3) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:41:48 +0000 (22:41 +0100)]
Assume getgrnam_r(3) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:40:47 +0000 (22:40 +0100)]
Assume getpwuid_r(3) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:39:28 +0000 (22:39 +0100)]
Assume getpwnam_r(3) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:32:59 +0000 (22:32 +0100)]
Assume fsync(2) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:31:38 +0000 (22:31 +0100)]
Assume fchown(2) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:30:24 +0000 (22:30 +0100)]
Assume fchmod(2) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:28:25 +0000 (22:28 +0100)]
Assume l64a(3) exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:24:56 +0000 (22:24 +0100)]
Assume <netdb.h> exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:22:55 +0000 (22:22 +0100)]
Remove preprocessor conditionals that are always true
Since the last commit, LIMITS is always defined. Remove the dummy
macro, and all conditionals on it.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:20:55 +0000 (22:20 +0100)]
Assume <sys/resource.h> exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 21:10:18 +0000 (22:10 +0100)]
Remove uses of ulimit(3)
The function is obsolete. It is recommended to use getrlimit(2) instead
(see the manual page for ulimit(3) or the POSIX manual for it). Since
getrlimit(2) is required by POSIX.1-2001, we can rely on it.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:58:14 +0000 (21:58 +0100)]
Add indentation to heavy use of preprocessor conditionals
This clarifies which code is under which conditions,
for further clenaup.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:55:16 +0000 (21:55 +0100)]
Remove unused check for <utime.h>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:54:18 +0000 (21:54 +0100)]
Remove unused check for <syslog.h>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:52:19 +0000 (21:52 +0100)]
Assume <termios.h> exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:50:40 +0000 (21:50 +0100)]
Assume <utmpx.h> exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:48:51 +0000 (21:48 +0100)]
Remove unused check for <sys/time.h>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:39:15 +0000 (21:39 +0100)]
Assume <unistd.h> exists
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 20:37:50 +0000 (21:37 +0100)]
Remove unused check for <fcntl.h>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 5 Dec 2022 12:54:37 +0000 (13:54 +0100)]
Assume strstr(3) exists
ISO C99 requires strstr(3).
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 5 Dec 2022 12:53:08 +0000 (13:53 +0100)]
Assume snprintf(3) exists
ISO C99 requires snprintf(3).
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 5 Dec 2022 12:52:04 +0000 (13:52 +0100)]
Assume rename(2) exists
ISO C99 requires rename(2).
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 16:25:07 +0000 (17:25 +0100)]
Assume NULL exists
ISO C99 requires NULL.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 16:23:03 +0000 (17:23 +0100)]
Assume strerror(3) exists
ISO C99 requires strerror(3).
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 16:22:25 +0000 (17:22 +0100)]
Assume fputs(3) exists
ISO C99 requires fputs(3).
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 16:06:47 +0000 (17:06 +0100)]
Assume <locale.h> exists
ISO C99 requires <locale.h>.
Other files in the project already include <locale.h> unconditionally,
so it's reasonable to assume that it is always available.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 16:04:03 +0000 (17:04 +0100)]
Remove unused check for <limits.h>
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 15:58:12 +0000 (16:58 +0100)]
Assume <errno.h> exists
ISO C99 requires <errno.h>.
Many files in the project already include <errno.h> unconditionally,
so it's reasonable to assume that it is always available.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 2 Dec 2022 15:51:05 +0000 (16:51 +0100)]
Assume <stdbool.h> exists
ISO C99 requires <stdbool.h>.
Many files in the project already include <stdbool.h> unconditionally,
so it's reasonable to assume that it is always available.
Link: <https://github.com/shadow-maint/shadow/pull/600>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
James Addison [Fri, 18 Nov 2022 22:14:43 +0000 (22:14 +0000)]
Add '62_usermod_remove_supplementary_groups' test case to test runner scripts (run_some)
James Addison [Thu, 17 Nov 2022 12:58:13 +0000 (12:58 +0000)]
Add '62_usermod_remove_supplementary_groups' test case to test runner scripts (run_all, run_all.coverage)
James Addison [Thu, 17 Nov 2022 12:47:31 +0000 (12:47 +0000)]
Add regression test for 'usermod -rG' -- it should not add users to groups they did not previously belong to
James Addison [Thu, 17 Nov 2022 11:35:52 +0000 (11:35 +0000)]
Preparation / clarity: rename existing usermod test from 'remove_supplemental_groups' to 'clear_supplemental_groups'
Guillem Jover [Mon, 21 Nov 2022 13:00:13 +0000 (14:00 +0100)]
agetpass: Hook into build-system
Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 28 Sep 2022 21:09:19 +0000 (23:09 +0200)]
Hide [[gnu::malloc(deallocator)]] in a macro
Clang doesn't implement this attribute and reports an error. Work
around it by hiding it in a macro that will be empty in clang.
Reported-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 27 Sep 2022 19:21:35 +0000 (21:21 +0200)]
Replace the deprecated getpass(3) by our agetpass()
getpass(3) is broken in all implementations; in some, more than
others, but somewhat broken in all of them. Check the immediate
previous commit, which added the functions, for more details.
Check also the Linux man-pages commit that marked it as
deprecated, for more details:
7ca189099d73bde954eed2d7fc21732bcc8ddc6b .
Link: <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit?id=
7ca189099d73bde954eed2d7fc21732bcc8ddc6b >
Reported-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alex Colomar [Mon, 26 Sep 2022 20:22:24 +0000 (22:22 +0200)]
libmisc: agetpass(), erase_pass(): Add functions for getting passwords safely
There are several issues with getpass(3).
Many implementations of it share the same issues that the infamous
gets(3). In glibc it's not so terrible, since it's a wrapper
around getline(3). But it still has an important bug:
If the password is long enough, getline(3) will realloc(3) memory,
and prefixes of the password will be laying around in some
deallocated memory.
See the getpass(3) manual page for more details, and especially
the commit that marked it as deprecated, which links to a long
discussion in the linux-man@ mailing list.
So, readpassphrase(3bsd) is preferrable, which is provided by
libbsd on GNU systems. However, using readpassphrase(3) directly
is a bit verbose, so we can write our own wrapper with a simpler
interface similar to that of getpass(3).
One of the benefits of writing our own interface around
readpassphrase(3) is that we can hide there any checks that should
be done always and which would be error-prone to repeat every
time. For example, check that there was no truncation in the
password.
Also, use malloc(3) to get the buffer, instead of using a global
buffer. We're not using a multithreaded program (and it wouldn't
make sense to do so), but it's nice to know that the visibility of
our passwords is as limited as possible.
erase_pass() is a clean-up function that handles all clean-up
correctly, including zeroing the entire buffer, and then
free(3)ing the memory. By using [[gnu::malloc(erase_pass)]], we
make sure that we don't leak the buffers in any case, since the
compiler will be able to enforce clean up.
Link: <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit?id=
7ca189099d73bde954eed2d7fc21732bcc8ddc6b >
Reported-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alex Colomar [Tue, 27 Sep 2022 22:03:46 +0000 (00:03 +0200)]
Don't 'else' after a 'noreturn' call
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Iker Pedrosa [Tue, 22 Nov 2022 13:35:06 +0000 (14:35 +0100)]
CI: add libbsd and pkg-config dependencies
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Florian Weimer [Mon, 21 Nov 2022 10:52:45 +0000 (11:52 +0100)]
Fix HAVE_SHADOWGRP configure check
The missing #include <gshadow.h> causes the configure check to fail
spuriously, resulting in HAVE_SHADOWGRP not being defined even
on systems that actually have sgetsgent (such as current glibc).
Andy Zaugg [Tue, 18 Oct 2022 23:30:14 +0000 (16:30 -0700)]
Allow supplementary groups to be added via config file
Allow supplementary groups to be set via the /etc/default/useradd config
file. Allowing an administrator to set additonal groups via the GROUPS
configurable and control the default behaviour of useradd.
Iker Pedrosa [Mon, 24 Oct 2022 08:46:36 +0000 (10:46 +0200)]
useradd: check if subid range exists for user
Check if a user already has a subid range before assigning one.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=
2012929
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Serge Hallyn [Tue, 8 Nov 2022 16:29:30 +0000 (10:29 -0600)]
Release 4.13
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Serge Hallyn [Tue, 8 Nov 2022 16:28:10 +0000 (10:28 -0600)]
update changelog
Serge Hallyn [Mon, 7 Nov 2022 15:54:50 +0000 (09:54 -0600)]
Don't warn when failed to open /etc/nsswitch.conf
Maybe we should have a debug mode where it's still printed, but
we don't, so let's be quieter.
Closes #557
David Michael [Sun, 23 Oct 2022 22:51:33 +0000 (18:51 -0400)]
useradd: Fix buffer overflow when using a prefix
The buffer length did not count the string's trailing null byte.
Signed-off-by: David Michael <fedora.dm0@gmail.com>
Alejandro Colomar [Fri, 7 Oct 2022 23:58:07 +0000 (01:58 +0200)]
adduser-old.c: Remove program
This program has 10 calls to gets(3) according to grep(1). That
makes it a very unsafe program which should not be used at all.
Let's kill the program already.
See what gets(3) has to say:
SYNOPSIS
#include <stdio.h>
[[deprecated]] char *gets(char *s);
DESCRIPTION
Never use this function.
...
BUGS
Never use gets(). Because it is impossible to tell with‐
out knowing the data in advance how many characters
gets() will read, and because gets() will continue to
store characters past the end of the buffer, it is ex‐
tremely dangerous to use. It has been used to break com‐
puter security. Use fgets() instead.
For more information, see CWE‐242 (aka "Use of Inherently
Dangerous Function") at http://cwe.mitre.org/data/defini‐
tions/242.html
Acked-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Iker Pedrosa [Fri, 7 Oct 2022 10:36:59 +0000 (12:36 +0200)]
Raise limit for passwd and shadow entry length
Moreover, include checks to prevent writing entries longer than the
length limit.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=
1422497
Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Iker Pedrosa [Thu, 6 Oct 2022 08:05:44 +0000 (10:05 +0200)]
lastlog: check for localtime() return value
Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Iker Pedrosa [Fri, 7 Oct 2022 10:17:41 +0000 (12:17 +0200)]
man: add missing space in useradd.8.xml
Resolves: https://github.com/shadow-maint/shadow/issues/580
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
xyz [Sat, 27 Aug 2022 02:23:13 +0000 (19:23 -0700)]
fix `usermod -rG x y` while user `y` is not in group `x` will cause user `y` add into group `x`
Iker Pedrosa [Thu, 6 Oct 2022 09:21:18 +0000 (11:21 +0200)]
libmisc: minimum id check for system accounts
The minimum id allocation for system accounts shouldn't be 0 as this is
reserved for root.
Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Iker Pedrosa [Wed, 5 Oct 2022 13:20:43 +0000 (15:20 +0200)]
usermod: report error if homedir does not exist
Report error if usermod asked for moving homedir and it does not exist.
Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Xiami [Wed, 5 Oct 2022 10:11:28 +0000 (18:11 +0800)]
chage: Fix regression in print_date
Introduced by
c6c8130db4319613a91dd07bbb845f6c33c5f79f
After removing snprintf, the format string should get unescaped once.
Fixes #564
Reporter and patch author: DerMouse (github.com/DerMouse)
Alejandro Colomar [Wed, 28 Sep 2022 21:19:37 +0000 (23:19 +0200)]
Use libc MAX() and MIN()
glibc, musl, FreeBSD, and OpenBSD define the MAX() and MIN()
macros in <sys/param.h> with the same definition that we use.
Let's not redefine it here and use the system one, as it's
effectively the same as we define (modulo whitespace).
See:
shadow (previously):
alx@asus5775:~/src/shadow/shadow$ grepc -ktm MAX
./lib/defines.h:318:#define MAX(x,y) (((x) > (y)) ? (x) : (y))
glibc:
alx@asus5775:~/src/gnu/glibc$ grepc -ktm -x 'sys/param.h$' MAX
./misc/sys/param.h:103:#define MAX(a,b) (((a)>(b))?(a):(b))
musl:
alx@asus5775:~/src/musl/musl$ grepc -ktm -x 'sys/param.h$' MAX
./include/sys/param.h:19:#define MAX(a,b) (((a)>(b))?(a):(b))
OpenBSD:
alx@asus5775:~/src/bsd/openbsd/src$ grepc -ktm -x 'sys/param.h$' MAX
./sys/sys/param.h:193:#define MAX(a,b) (((a)>(b))?(a):(b))
FreeBSD:
alx@asus5775:~/src/bsd/freebsd/freebsd-src$ grepc -ktm -x 'sys/param.h$' MAX
./sys/sys/param.h:333:#define MAX(a,b) (((a)>(b))?(a):(b))
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alex Colomar [Wed, 28 Sep 2022 20:03:52 +0000 (22:03 +0200)]
Don't test for NULL before calling free(3)
free(3) accepts NULL, since the oldest ISO C. I guess the
paranoid code was taking care of prehistoric implementations of
free(3). I've never known of an implementation that doesn't
conform to this, so let's simplify this.
Remove xfree(3), which was effectively an equivalent of free(3).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Frans Spiesschaert [Tue, 27 Sep 2022 15:11:02 +0000 (17:11 +0200)]
updated Dutch translation
Christian Göttsche [Sat, 17 Sep 2022 16:03:46 +0000 (18:03 +0200)]
lib: use memzero where applicable
Use memzero when operating in a buffer of known size to clear all bytes
and avoid leaking the size of the stored data.
Christian Göttsche [Sat, 17 Sep 2022 15:56:49 +0000 (17:56 +0200)]
lib: use strzero where applicable
Replace `memzero (s, strlen(s))` with just the internal wrapper
`strzero (s)` where the underlying allocated size is not known.