]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
2 years agolib: replace `USER_NAME_MAX_LENGTH` macro
Iker Pedrosa [Wed, 19 Jul 2023 10:05:09 +0000 (12:05 +0200)] 
lib: replace `USER_NAME_MAX_LENGTH` macro

Replace it by `sysconf(_SC_LOGIN_NAME_MAX)`, which is the maximum
username length supported by the kernel.

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agolibmisc: call `active_sessions_count()`
Iker Pedrosa [Wed, 19 Jul 2023 10:02:31 +0000 (12:02 +0200)] 
libmisc: call `active_sessions_count()`

Replace the utmp dependent code with the call to
`active_sessions_count()`.

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agolibmisc: implement `active_sessions_count()`
Iker Pedrosa [Wed, 19 Jul 2023 09:02:55 +0000 (11:02 +0200)] 
libmisc: implement `active_sessions_count()`

Implement `active_sessions_count()` in `utmp.c` and `logind.c`.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoutmp: update `update_utmp()`
Iker Pedrosa [Wed, 19 Jul 2023 07:42:35 +0000 (09:42 +0200)] 
utmp: update `update_utmp()`

Remove `utmp` structure as an argument and include its logic inside the
function. This will help remove any reference to utmp from login.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoutmp: move `update_utmp`
Iker Pedrosa [Tue, 18 Jul 2023 14:48:02 +0000 (16:48 +0200)] 
utmp: move `update_utmp`

The functionality from this function is related to utmp. Restrict access
to `setutmp()` to the same file.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoutmp: move `failtmp()`
Iker Pedrosa [Tue, 18 Jul 2023 14:36:35 +0000 (16:36 +0200)] 
utmp: move `failtmp()`

The functionality from this function is related to btmp.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agolibmisc: implement `get_session_host()`
Iker Pedrosa [Tue, 18 Jul 2023 13:56:46 +0000 (15:56 +0200)] 
libmisc: implement `get_session_host()`

Implement `get_session_host()` in `utmp.c` and `logind.c`.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoconfigure: new option `enable-logind`
Iker Pedrosa [Tue, 18 Jul 2023 09:33:02 +0000 (11:33 +0200)] 
configure: new option `enable-logind`

Create new configuration option `enable-logind` to select which session
support functionality to build, logind or utmp. By default the option is
logind.

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoshadow userdel: add the adaptation to the busybox ps in 01-kill_user_procs.sh
xiongshenglan [Wed, 19 Jul 2023 07:13:06 +0000 (15:13 +0800)] 
shadow userdel: add the adaptation to the busybox ps in 01-kill_user_procs.sh

In some embedded systems, users only use the ps
provided by the busybox. But the ps provided by
the busybox does not support the -eo option by
default. As a result, an error is reported when
the userdel is used. So add a judgment on ps.
If there is no ps -eo, traverse the process directly.

The error information is as follows:
 # userdel xsl
ps: invalid option -- 'e'

Signed-off-by: xiongshenglan <xiongshenglan@huawei.com>
2 years agochsh: warn if root sets a shell not listed in /etc/shells
Michael Vetter [Wed, 26 Jul 2023 08:13:53 +0000 (10:13 +0200)] 
chsh: warn if root sets a shell not listed in /etc/shells

Print a warning even for the root user if the provided shell isn't
listed in /etc/shells, but continue to execute the action.
In case of non root user exit.

See https://github.com/shadow-maint/shadow/issues/535

2 years agodoc: mention ci workflow file to learn about deps
Michael Vetter [Wed, 26 Jul 2023 09:24:29 +0000 (11:24 +0200)] 
doc: mention ci workflow file to learn about deps

Fix https://github.com/shadow-maint/shadow/issues/38

2 years agoman/po/Makefile: add a comment to shadow-man-pages.pot
Serge Hallyn [Sat, 15 Jul 2023 12:50:34 +0000 (07:50 -0500)] 
man/po/Makefile: add a comment to shadow-man-pages.pot

Add a comment at the top of that file explaining how to
regenerate it.

We should add a README, but I don't have time to draft one
right now.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agonewgrp: fix potential string injection
Vegard Nossum [Fri, 21 Jul 2023 12:55:19 +0000 (14:55 +0200)] 
newgrp: fix potential string injection

Since newgrp is setuid-root, any write() system calls it does in order
to print error messages will be done as the root user.

Unprivileged users can get newgrp to print essentially arbitrary strings
to any open file in this way by passing those strings as argv[0] when
calling execve(). For example:

    $ setpid() { (exec -a $1$'\n:' newgrp '' 2>/proc/sys/kernel/ns_last_pid & wait) >/dev/null; }
    $ setpid 31000
    $ readlink /proc/self
    31001

This is not a vulnerability in newgrp; it is a bug in the Linux kernel.

However, this type of bug is not new [1] and it makes sense to try to
mitigate these types of bugs in userspace where possible.

[1]: https://lwn.net/Articles/476947/

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
2 years agolastlog: fix alignment of Latest header
Todd Zullinger [Tue, 18 Jul 2023 03:16:00 +0000 (23:16 -0400)] 
lastlog: fix alignment of Latest header

b1282224 (Add maximum padding to fit IPv6-Addresses, 2020-05-24) pads
the From field header using `maxIPv6Addrlen - 3`.  This leaves the
Latest field header misaligned.  Subtract 4 (the length of "From").

2 years agoconfigure: fix lastlog check
Iker Pedrosa [Mon, 17 Jul 2023 13:04:19 +0000 (15:04 +0200)] 
configure: fix lastlog check

Fixes: 1bdcfa8d3710bf0a3f180b590017df096d346ade ("lastlog: stop building by
default")

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agosubuid.5: reference newusers(8) rather than newusers(1)
Alan D. Salewski [Sat, 15 Jul 2023 20:36:06 +0000 (16:36 -0400)] 
subuid.5: reference newusers(8) rather than newusers(1)

Resolves: https://github.com/shadow-maint/shadow/issues/752

Signed-off-by: Alan D. Salewski <ads@salewski.email>
2 years agoCI: build lastlog in Fedora
Iker Pedrosa [Thu, 13 Jul 2023 13:33:07 +0000 (15:33 +0200)] 
CI: build lastlog in Fedora

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoman: conditionally build lastlog documentation
Iker Pedrosa [Thu, 13 Jul 2023 13:30:22 +0000 (15:30 +0200)] 
man: conditionally build lastlog documentation

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agousermod: conditionally build lastlog functionality
Iker Pedrosa [Thu, 13 Jul 2023 13:25:03 +0000 (15:25 +0200)] 
usermod: conditionally build lastlog functionality

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agouseradd: conditionally build lastlog functionality
Iker Pedrosa [Thu, 13 Jul 2023 13:24:37 +0000 (15:24 +0200)] 
useradd: conditionally build lastlog functionality

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agologin: conditionally build lastlog functionality
Iker Pedrosa [Thu, 13 Jul 2023 10:59:33 +0000 (12:59 +0200)] 
login: conditionally build lastlog functionality

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agolastlog: stop building by default
Iker Pedrosa [Thu, 13 Jul 2023 10:54:04 +0000 (12:54 +0200)] 
lastlog: stop building by default

Created a new configuration option `--enable-lastlog` to conditionally
build the lastlog binary. By default the option is disabled.

Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoCI: update debian repos
Iker Pedrosa [Fri, 14 Jul 2023 09:39:33 +0000 (11:39 +0200)] 
CI: update debian repos

Latest debian version changed the location and format for the repos
file.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoFix yescrypt support
Bernd Kuhls [Sun, 9 Jul 2023 08:55:03 +0000 (10:55 +0200)] 
Fix yescrypt support

Fixes build error:
newusers.c: In function 'update_passwd':
newusers.c:433:21: error: 'sflg' undeclared (first use in this function); did you mean 'rflg'?

introduced by
https://github.com/shadow-maint/shadow/commit/5cd04d03f94622c12220d4a6352824af081b8531
which forgot to define sflg for these configure options:

--without-sha-crypt --without-bcrypt --with-yescrypt

2 years agochgpasswd: fix segfault in command-line options
Jeffrey Bencteux [Wed, 21 Jun 2023 13:12:43 +0000 (15:12 +0200)] 
chgpasswd: fix segfault in command-line options

Using the --sha-rounds option without first giving a crypt method via the --crypt-method option results in comparisons with a NULL pointer and thus make chgpasswd segfault:

$ chgpasswd -s 1
zsh: segmentation fault  chgpasswd -s 1

Current patch add a sanity check before these comparisons to ensure there is a defined encryption method.

2 years agogpasswd(1): Fix password leak
Alejandro Colomar [Sat, 10 Jun 2023 14:20:05 +0000 (16:20 +0200)] 
gpasswd(1): Fix password leak

How to trigger this password leak?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When gpasswd(1) asks for the new password, it asks twice (as is usual
for confirming the new password).  Each of those 2 password prompts
uses agetpass() to get the password.  If the second agetpass() fails,
the first password, which has been copied into the 'static' buffer
'pass' via STRFCPY(), wasn't being zeroed.

agetpass() is defined in <./libmisc/agetpass.c> (around line 91), and
can fail for any of the following reasons:

-  malloc(3) or readpassphrase(3) failure.

   These are going to be difficult to trigger.  Maybe getting the system
   to the limits of memory utilization at that exact point, so that the
   next malloc(3) gets ENOMEM, and possibly even the OOM is triggered.
   About readpassphrase(3), ENFILE and EINTR seem the only plausible
   ones, and EINTR probably requires privilege or being the same user;
   but I wouldn't discard ENFILE so easily, if a process starts opening
   files.

-  The password is longer than PASS_MAX.

   The is plausible with physical access.  However, at that point, a
   keylogger will be a much simpler attack.

And, the attacker must be able to know when the second password is being
introduced, which is not going to be easy.

How to read the password after the leak?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Provoking the leak yourself at the right point by entering a very long
password is easy, and inspecting the process stack at that point should
be doable.  Try to find some consistent patterns.

Then, search for those patterns in free memory, right after the victim
leaks their password.

Once you get the leak, a program should read all the free memory
searching for patterns that gpasswd(1) leaves nearby the leaked
password.

On 6/10/23 03:14, Seth Arnold wrote:
> An attacker process wouldn't be able to use malloc(3) for this task.
> There's a handful of tools available for userspace to allocate memory:
>
> -  brk / sbrk
> -  mmap MAP_ANONYMOUS
> -  mmap /dev/zero
> -  mmap some other file
> -  shm_open
> -  shmget
>
> Most of these return only pages of zeros to a process.  Using mmap of an
> existing file, you can get some of the contents of the file demand-loaded
> into the memory space on the first use.
>
> The MAP_UNINITIALIZED flag only works if the kernel was compiled with
> CONFIG_MMAP_ALLOW_UNINITIALIZED.  This is rare.
>
> malloc(3) doesn't zero memory, to our collective frustration, but all the
> garbage in the allocations is from previous allocations in the current
> process.  It isn't leftover from other processes.
>
> The avenues available for reading the memory:
> -  /dev/mem and /dev/kmem (requires root, not available with Secure Boot)
> -  /proc/pid/mem (requires ptrace privileges, mediated by YAMA)
> -  ptrace (requires ptrace privileges, mediated by YAMA)
> -  causing memory to be swapped to disk, and then inspecting the swap
>
> These all require a certain amount of privileges.

How to fix it?
~~~~~~~~~~~~~~

memzero(), which internally calls explicit_bzero(3), or whatever
alternative the system provides with a slightly different name, will
make sure that the buffer is zeroed in memory, and optimizations are not
allowed to impede this zeroing.

This is not really 100% effective, since compilers may place copies of
the string somewhere hidden in the stack.  Those copies won't get zeroed
by explicit_bzero(3).  However, that's arguably a compiler bug, since
compilers should make everything possible to avoid optimizing strings
that are later passed to explicit_bzero(3).  But we all know that
sometimes it's impossible to have perfect knowledge in the compiler, so
this is plausible.  Nevertheless, there's nothing we can do against such
issues, except minimizing the time such passwords are stored in plain
text.

Security concerns
~~~~~~~~~~~~~~~~~

We believe this isn't easy to exploit.  Nevertheless, and since the fix
is trivial, this fix should probably be applied soon, and backported to
all supported distributions, to prevent someone else having more
imagination than us to find a way.

Affected versions
~~~~~~~~~~~~~~~~~

All.  Bug introduced in shadow 19990709.  That's the second commit in
the git history.

Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Reported-by: Alejandro Colomar <alx@kernel.org>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Seth Arnold <seth.arnold@canonical.com>
Cc: Christian Brauner <christian@brauner.io>
Cc: Balint Reczey <rbalint@debian.org>
Cc: Sam James <sam@gentoo.org>
Cc: David Runge <dvzrv@archlinux.org>
Cc: Andreas Jaeger <aj@suse.de>
Cc: <~hallyn/shadow@lists.sr.ht>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agosrc/useradd.c: create_mail(): Cosmetic
Alejandro Colomar [Wed, 7 Jun 2023 21:56:30 +0000 (23:56 +0200)] 
src/useradd.c: create_mail(): Cosmetic

-  Invert conditional to reduce indentation.
-  Reduce use of whitespace and newlines while unindenting.
-  Reorder variable declarations.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agosrc/useradd.c: create_home(): Cosmetic
Alejandro Colomar [Wed, 7 Jun 2023 21:56:29 +0000 (23:56 +0200)] 
src/useradd.c: create_home(): Cosmetic

-  Invert conditional to reduce indentation.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agosrc/useradd.c: create_home(): Cosmetic
Alejandro Colomar [Wed, 7 Jun 2023 21:56:28 +0000 (23:56 +0200)] 
src/useradd.c: create_home(): Cosmetic

-  Invert conditional to reduce indentation.
-  Rewrite while loop calling strtok(3) as a for loop.  This allows
   doing more simplification inside the loop (see next commit).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agosrc/useradd.c: create_home(): Cosmetic
Alejandro Colomar [Wed, 7 Jun 2023 21:56:27 +0000 (23:56 +0200)] 
src/useradd.c: create_home(): Cosmetic

-  Fix indentation.  It was very broken.
-  Move variable declaration to the top of the block in which it's used.
-  Reduce use of whitespace and newlines.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agosrc/useradd.c: close_group_files(): Cosmetic
Alejandro Colomar [Wed, 7 Jun 2023 21:56:26 +0000 (23:56 +0200)] 
src/useradd.c: close_group_files(): Cosmetic

-  Invert conditional, to reduce indentation.
-  Reduce use of whitespace and newlines while unindenting.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agosrc/useradd.c: check_uid_range(): Cosmetic
Alejandro Colomar [Wed, 7 Jun 2023 21:56:25 +0000 (23:56 +0200)] 
src/useradd.c: check_uid_range(): Cosmetic

-  Merge nested conditionals into a single if, to reduce indentation.
-  Indent (1 SP) nested preprocessor conditionals.
-  Reduce use of whitespace and newlines while unindenting.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agobuild: link passwd, chpasswd and chage against libdl
Jaroslav Jindrak [Fri, 5 May 2023 18:29:58 +0000 (20:29 +0200)] 
build: link passwd, chpasswd and chage against libdl

2 years agoconfigure: check whether fgetpwent_r is available before marking xprefix_getpwnam_r...
Jaroslav Jindrak [Thu, 4 May 2023 20:41:02 +0000 (22:41 +0200)] 
configure: check whether fgetpwent_r is available before marking xprefix_getpwnam_r as reentrant

2 years agopasswd: fall back to non-PAM code when prefix is used
Jaroslav Jindrak [Wed, 3 May 2023 20:38:28 +0000 (22:38 +0200)] 
passwd: fall back to non-PAM code when prefix is used

Prefix does not make sense when we use PAM, so when the option
is used behave as if --with-libpam=no was used to configure the
project.

2 years agochpasswd: fall back to non-PAM code when prefix is used
Jaroslav Jindrak [Wed, 3 May 2023 16:59:50 +0000 (18:59 +0200)] 
chpasswd: fall back to non-PAM code when prefix is used

The prefix option does not make sense in that scenario and the
encryption options already do this.

2 years agochpasswd: add --prefix/-P options
Jaroslav Jindrak [Fri, 28 Apr 2023 18:30:18 +0000 (20:30 +0200)] 
chpasswd: add --prefix/-P options

2 years agochage: add --prefix/-P options
Jaroslav Jindrak [Fri, 21 Apr 2023 20:24:36 +0000 (22:24 +0200)] 
chage: add --prefix/-P options

2 years agopasswd: Respect --prefix/-P options
Jaroslav Jindrak [Fri, 21 Apr 2023 18:50:41 +0000 (20:50 +0200)] 
passwd: Respect --prefix/-P options

Add prefix_getpwnam_r() and xprefix_getpwnam() and make passwd
use prefix-aware functions when handling the database.

2 years agoprefix: add prefix support
Michael Vetter [Mon, 17 Apr 2023 13:39:47 +0000 (15:39 +0200)] 
prefix: add prefix support

2 years agostrtoday: remove unnecessary cast
Iker Pedrosa [Wed, 7 Jun 2023 12:58:34 +0000 (14:58 +0200)] 
strtoday: remove unnecessary cast

Resolves: https://github.com/shadow-maint/shadow/issues/704

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoUse temporary variable
Alejandro Colomar [Sat, 27 May 2023 13:56:08 +0000 (15:56 +0200)] 
Use temporary variable

-  Use the temporary variable more, as it helps readability: it removes
   a derefecence, which itself allows removing some parentheses.

-  Use a shorter name, which is more common with temporaries, and so
   there's less to read.

-  Assign to *ranges at the end of the function.  It's the same, but
   with the other changes, I think this makes it slightly clearer.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agorealloc(NULL, ...) is equivalent to malloc(...)
Alejandro Colomar [Sat, 27 May 2023 13:35:13 +0000 (15:35 +0200)] 
realloc(NULL, ...) is equivalent to malloc(...)

Don't have a branch for when the old pointer is NULL.  realloc(3) can
handle that case just fine.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoSimplify allocation APIs
Alejandro Colomar [Wed, 5 Apr 2023 19:17:38 +0000 (21:17 +0200)] 
Simplify allocation APIs

If we consider simple objects as arrays of size 1, we can considerably
simplify these APIs, merging the *ARRAY and the non-array variants.

That will produce more readable code, since lines will be shorter (by
not having ARRAY in the macro names, as all macros will consistently
handle arrays), and the allocated size will be also more explicit.

The syntax will now be of the form:

    p = MALLOC(42, foo_t);  // allocate 42 elements of type foo_t.
    p = MALLOC(1, bar_t);   // allocate 1 element of type foo_t.

The _array() allocation functions should _never_ be called directly, and
instead these macros should be used.

The non-array functions (e.g., malloc(3)) still have their place, but
are limited to allocating structures with flexible array members.  For
any other uses, the macros should be used.

Thus, we don't use any array or ARRAY variants in any code any more, and
they are only used as implementation details of these macros.

Link: <https://software.codidact.com/posts/285898/288023#answer-288023>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoDrop alloca(3)
Christian Göttsche [Tue, 28 Feb 2023 14:50:20 +0000 (15:50 +0100)] 
Drop alloca(3)

alloca(3) fails silently if not enough memory can be allocated on the
stack.  Use checked dynamic allocation instead.

Also drop unnecessary manual NUL assignment, ensured by snprintf(3).

Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agousermod: fix off-by-one issues
Christian Göttsche [Thu, 2 Mar 2023 15:18:45 +0000 (16:18 +0100)] 
usermod: fix off-by-one issues

Allocate enough memory for the strings, two slashes and the NUL
terminator.

Reported-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agolibmisc/csrand.c: Update comments
Alejandro Colomar [Sat, 3 Jun 2023 17:25:00 +0000 (19:25 +0200)] 
libmisc/csrand.c: Update comments

Those comments were written when this function used 64 bits (and
temporary variables of 128 bits).  Now it uses 32 bits, with temporaries
of 64 bits, so some values have changed.

Fixes: 2a61122b5e8f ("Unoptimize the higher part of the domain of csrand_uniform()")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agolib/nss.c: Fix use of invalid p
Alejandro Colomar [Wed, 31 May 2023 10:24:14 +0000 (12:24 +0200)] 
lib/nss.c: Fix use of invalid p

getline(3) might have succeeded in a previous iteration, in which case
p points to an offset that is not valid.  Make p NULL at the end of the
loop, to make sure it doesn't hold old stuff.

Link: <https://github.com/shadow-maint/shadow/pull/737#issuecomment-1568948769>
Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agolib/nss.c: Fix use of uninitialized p
Alejandro Colomar [Wed, 31 May 2023 10:19:33 +0000 (12:19 +0200)] 
lib/nss.c: Fix use of uninitialized p

getline(3) might have never succeeded, in which case p is uninitialized
when used in strtok_r(3).

Link: <https://github.com/shadow-maint/shadow/pull/737#discussion_r1206007358>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoCentralize error handling
Alejandro Colomar [Fri, 26 May 2023 10:16:13 +0000 (12:16 +0200)] 
Centralize error handling

This makes the function fit in less screens.  This is to avoid consuming
more natural resources than we have available, and everyone knows the
supply of new-lines on a screen is not a renewable source[1].

Some transformations have been done thanks to free(NULL) being an alias
for loopity_loop(), as defined three comits ago.  The real definition of
free(3) that everyone has been hiding is this:

void
free(void *p)
{
if (p == NULL)
loopity_loop();
else
real_free(p);
}

Link: [1] <https://www.kernel.org/doc/html/v6.3/process/coding-style.html#placing-braces-and-spaces>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoSecond verse, it gets worse; it gets no better than this
Alejandro Colomar [Fri, 26 May 2023 09:34:10 +0000 (11:34 +0200)] 
Second verse, it gets worse; it gets no better than this

Just in case it's not obious:

strlen("") < 8
isalpha('\0') == false
isdigit('\0') == false
isspace('\0') == false

Link: <https://github.com/shadow-maint/shadow/pull/737>
Easter-egg: 8492dee6632e ("subids: support nsswitch")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoROFL: Rolling on the floor looping
Alejandro Colomar [Thu, 25 May 2023 20:24:30 +0000 (22:24 +0200)] 
ROFL: Rolling on the floor looping

Please tell me this was an easter egg :P

 #define go_banana() ({ goto nowhere; nowhere: 0-0; })

Closes: <https://github.com/shadow-maint/shadow/issues/736>
Easter-egg: 8492dee6632e ("subids: support nsswitch")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoThis ain't no loop
Alejandro Colomar [Thu, 25 May 2023 20:13:36 +0000 (22:13 +0200)] 
This ain't no loop

This was to a loop, as "1234" is to computer security.

No really; a loop that ends in a (forward) goto, and has no continue in it.

Still want a loop?  Take two:

 #define loopity_loop() do { for (;;) { break; } continue; } while (0-0)

Closes: <https://github.com/shadow-maint/shadow/issues/736>
Easter-egg: 8492dee6632e ("subids: support nsswitch")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agonewusers: Improve error message
Iker Pedrosa [Wed, 31 May 2023 07:38:12 +0000 (09:38 +0200)] 
newusers: Improve error message

Fixes: b422e3c31691: Check if crypt_method null before dereferencing
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoch(g)passwd: Check selinux permissions upon startup
Martin Kletzander [Fri, 3 Mar 2023 10:46:33 +0000 (11:46 +0100)] 
ch(g)passwd: Check selinux permissions upon startup

The permission also need to be checked before process_root_flag() since
that can chroot into non-selinux environment (unavailable selinux mount
point for example).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoCheck if crypt_method null before dereferencing
Skyler Ferrante [Tue, 30 May 2023 19:00:12 +0000 (15:00 -0400)] 
Check if crypt_method null before dereferencing

Make sure crypto_method set before sha-rounds. Only affects newusers.

2 years agoxgetXXbyYY: Simplify elifs
Alejandro Colomar [Sat, 27 May 2023 01:26:52 +0000 (03:26 +0200)] 
xgetXXbyYY: Simplify elifs

-  Use SIZE_MAX rather than (size_t)-1, to improve readability.

-  Move the only branch that breaks to the first place, so that we
   remove an else.  This reduces nesting while parsing the code.

-  Now that we only have a 2-branch conditional where both branches
   assign to the same variable, rewrite it as a ternary, to shorten.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoxgetXXbyYY: Centralize error handling
Alejandro Colomar [Sat, 27 May 2023 01:24:49 +0000 (03:24 +0200)] 
xgetXXbyYY: Centralize error handling

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoxgetXXbyYY: tfix
Alejandro Colomar [Sat, 27 May 2023 01:19:26 +0000 (03:19 +0200)] 
xgetXXbyYY: tfix

It seems obvious that it was a typo.

Link: <https://github.com/shadow-maint/shadow/pull/729#discussion_r1207551013>
Fixes: e73a2194b3d2 ("xgetXXbyYY: Handle DUP_FUNCTION failure")
Cc: Samanta Navarro <ferivoz@riseup.net>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoxgetXXbyYY: Avoid duplicated error handling block
Samanta Navarro [Mon, 15 May 2023 11:59:23 +0000 (11:59 +0000)] 
xgetXXbyYY: Avoid duplicated error handling block

The error handling is performed after the loop. By just calling break it
is possible to reuse the error handling if status is not ERANGE.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agoxgetXXbyYY: Handle DUP_FUNCTION failure
Samanta Navarro [Mon, 15 May 2023 11:58:04 +0000 (11:58 +0000)] 
xgetXXbyYY: Handle DUP_FUNCTION failure

A failure of DUP_FUNCTION is already handled for non-reentrant
function wrapper. Perform the check for reentrant version as well.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agosub_[ug]id_{add,remove}: fix return values
Serge Hallyn [Fri, 26 May 2023 03:00:36 +0000 (22:00 -0500)] 
sub_[ug]id_{add,remove}: fix return values

On failure, these are meant to return 0 with errno set.  But if
an nss module is loaded, they were returning -ERRNO instead.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agousermod: Small optimization using memmove for password unlock
Martin Kletzander [Fri, 3 Mar 2023 10:57:23 +0000 (11:57 +0100)] 
usermod: Small optimization using memmove for password unlock

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoReorder logic to improve comprehensibility
Alejandro Colomar [Sun, 5 Feb 2023 00:29:06 +0000 (01:29 +0100)] 
Reorder logic to improve comprehensibility

-  Don't else after return or fail_exit().
-  Prefer == over != (negated logic is more complex to think about it).
-  Reduce nesting when reasonable.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agonewusers: Fail early
Alejandro Colomar [Sat, 4 Feb 2023 19:54:43 +0000 (20:54 +0100)] 
newusers: Fail early

There's no reason to report all errors.  Bail out at the first one,
which is simpler.

Suggested-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agonewusers: Add missing error handling
Alejandro Colomar [Sat, 4 Feb 2023 19:52:54 +0000 (20:52 +0100)] 
newusers: Add missing error handling

Some errors were being reported in stderr, but then they weren't really
being treated as errors.

If mkdir(2) for EEXIST, it's possible that the sysadmin pre-created the
user dir; don't fail.  However, let's keep a log line, for having some
notice that it happened.

Also, run chmod(2) if mkdir(2) failed for EEXIST (so transform the
'else if' into an 'if').

Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agolibmisc: Use safer chroot/chdir sequence
Samanta Navarro [Tue, 23 May 2023 11:57:50 +0000 (11:57 +0000)] 
libmisc: Use safer chroot/chdir sequence

OpenSSH and coreutils' chroot call chroot first and then chdir. Doing it
this way is a bit safer because otherwise something could happen between
chdir and chroot to the specified path (like exchange of links) so the
working directory would not end up within the chroot environment.

This is a purely defensive measure.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agosu: Prevent stack overflow in check_perms
Samanta Navarro [Tue, 23 May 2023 11:55:09 +0000 (11:55 +0000)] 
su: Prevent stack overflow in check_perms

This is no real world security fix.

The overflow could occur if too many layered subsystems are encountered
because the function check_perms calls itself recursively.

It would already take a misconfigured system for this to achieve it.

Use an iterative approach by calling the do_check_perms in a loop
instead of calling itself recursively.

As a side note: At least GCC 13 optimized this code and already uses
a jmp in its assembler code. I could only see the stack overflow by
activating address sanitizer which prevented the optimization.

Co-developed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agosubsystem: Prevent endless loop
Samanta Navarro [Tue, 23 May 2023 11:53:53 +0000 (11:53 +0000)] 
subsystem: Prevent endless loop

If a user has home directory "/" and login shell "*" then login and su
enter an endless loop by constantly switching to the next subsystem.

This could also be achieved with a layered approach so just checking
for "/" as home directory is not enough to protect against such a
misconfiguration.

Just break the loop if it progressed too far. I doubt that this has
negative impact on any real setup.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agodef_load: avoid NULL deref
Serge Hallyn [Fri, 19 May 2023 19:49:04 +0000 (14:49 -0500)] 
def_load: avoid NULL deref

If econf_getStringValue() fails, it will return an error and
set value to NULL.  Look for the error and avoid dereferencing
value in that case.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agodef_load: split the econf from non-econf definition
Serge Hallyn [Fri, 19 May 2023 19:42:04 +0000 (14:42 -0500)] 
def_load: split the econf from non-econf definition

The function is completely different based on USE_CONF.  Either copy
will be easier to read if we just keep them completely separate.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoPlug econf memory leaks
Tobias Stoeckmann [Thu, 18 May 2023 15:25:35 +0000 (17:25 +0200)] 
Plug econf memory leaks

You can see the memory leaks with address sanitizer if shadow is
compiled with `--enable-vendordir=/usr/etc`.

How to reproduce:

1. Prepare a custom shell file as root
```
mkdir -p /etc/shells.d
echo /bin/myshell > /etc/shells.d/custom
```

2. Run chsh as regular user
```
chsh
```

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 years agochsh: Verify that login shell path is absolute
Samanta Navarro [Thu, 18 May 2023 11:58:19 +0000 (11:58 +0000)] 
chsh: Verify that login shell path is absolute

The getusershell implementation of musl returns every line within the
/etc/shells file, which even includes comments. Only consider absolute
paths for login shells.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agoprocess_prefix_flag: Drop privileges
Samanta Navarro [Thu, 18 May 2023 11:56:17 +0000 (11:56 +0000)] 
process_prefix_flag: Drop privileges

Using --prefix in a setuid binary is quite dangerous. An unprivileged
user could prepare a custom shadow file in home directory. During a data
race the user could exchange directories with links which could lead to
exchange of shadow file in system's /etc directory.

This could be used for local privilege escalation.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agoUpdate French translations
bubu [Thu, 11 May 2023 22:04:22 +0000 (17:04 -0500)] 
Update French translations

Please find attached the french updated translation of shadow-man-page,
proofread by the debian-l10n-french mailing list contributors.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoget_pid.c: Use tighter validation checks
Samanta Navarro [Fri, 12 May 2023 11:59:47 +0000 (11:59 +0000)] 
get_pid.c: Use tighter validation checks

Neither a pid_t below 1 nor a negative fd could be valid in this context.

Proof of Concept:

$ newuidmap -1 1 1 1
newuidmap: Could not open proc directory for target 4294967295

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agoreplace inadequate German translation of login error message
Markus Hiereth [Thu, 11 May 2023 22:00:51 +0000 (17:00 -0500)] 
replace inadequate German translation of login error message

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoUpdate German translations
Markus Hiereth [Wed, 10 May 2023 14:21:09 +0000 (09:21 -0500)] 
Update German translations

find the attached German message catalogue proofread by the German
language team.

Best regards
Markus

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoRemove some static char arrays
Samanta Navarro [Tue, 9 May 2023 11:59:20 +0000 (11:59 +0000)] 
Remove some static char arrays

Some strings are first written into static char arrays before passed to
functions which expect a const char pointer anyway.

It is easier to pass these strings directly as arguments.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agocommonio: Use do_lock_file again
Samanta Navarro [Wed, 10 May 2023 11:57:20 +0000 (11:57 +0000)] 
commonio: Use do_lock_file again

This avoids regressions introduced with do_fcntl_lock.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agoFix broken docbook translations
Serge Hallyn [Tue, 9 May 2023 12:56:38 +0000 (07:56 -0500)] 
Fix broken docbook translations

its by default does not support xml tags inside translatable
units.  Use custom its rules from

https://www.w3.org/TR/xml-i18n-bp/#relating-docbook-plus-its

to enable the tags which are in use by docbook.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoopen with O_CREAT when lock path does not exist
ed neville [Sat, 6 May 2023 09:05:47 +0000 (10:05 +0100)] 
open with O_CREAT when lock path does not exist

Reported in #686, by wyj611 when trying to lock a file that is not
present

Lock method should be F_SETLKW rather than open file descriptor

2 years agocommonio_open: Remove fcntl call
Samanta Navarro [Fri, 5 May 2023 11:59:07 +0000 (11:59 +0000)] 
commonio_open: Remove fcntl call

The fcntl call to set FD_CLOEXEC can be performed directly with the
previously performed open call by using the O_CLOEXEC flag.

O_CLOEXEC is required by POSIX.1-2008.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agocommonio_lock_nowait: Remove deprecated code
Samanta Navarro [Fri, 5 May 2023 11:57:06 +0000 (11:57 +0000)] 
commonio_lock_nowait: Remove deprecated code

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agologin_prompt: Simplify login_prompt API
Samanta Navarro [Fri, 28 Apr 2023 11:57:23 +0000 (11:57 +0000)] 
login_prompt: Simplify login_prompt API

The only user of login_prompt is the login tool. This implies that the
first argument is always the same.

It is much easier to verify printf's format string and its argument if
both are next to each other.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agologin_prompt: Use _exit in signal handler
Samanta Navarro [Fri, 28 Apr 2023 11:56:42 +0000 (11:56 +0000)] 
login_prompt: Use _exit in signal handler

Calling exit is not signal safe.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agologin_prompt: Do not parse environment variables
Samanta Navarro [Fri, 28 Apr 2023 11:55:14 +0000 (11:55 +0000)] 
login_prompt: Do not parse environment variables

Parsing optional environment variables after a login name is a feature
which is neither documented nor available in util-linux or busybox
login which are other wide spread login utilities used in Linux
distributions as reference.

Removing this feature resolves two issues:

- A memory leak exists if variables without an equal sign are used,
  because set_env creates copies on its own. This could lead to OOM
  situations in privileged part of login or may lead to heap spraying.
- Environment variables are not reset between login attempts. This
  could lead to additional environment variables set for a user who
  never intended to do so.

Proof of Concept on a system with shadow login without PAM and
util-linux agetty:

1. Provoke an invalid login, e.g. user `noone` and password `invalid`.
   This starts shadow login and subsequent inputs are passed through
   the function login_prompt.
2. Provoke an invalid login with environment variables, e.g.
   user `noone HISTFILE=/tmp/owo` and password `invalid`.
3. Log in correctly with user `root`.

Now you can see with `echo $HISTFILE` that `/tmp/owo` has been set for
the root user.

This requires a malicious failed login attempt and a successful login
within the configured login timeout (default 60 seconds).

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agolibmisc/yesno.c: Fix regression
Samanta Navarro [Fri, 28 Apr 2023 11:54:38 +0000 (11:54 +0000)] 
libmisc/yesno.c: Fix regression

The getline function does not return a pointer but the amount of read
characters. The error return value to check for is -1.

Set buf to NULL to avoid dereference of an uninitialized stack value.

The getline function returns -1 if size argument is NULL. Always use
a valid pointer even if size is unimportant.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agolibmisc, man: Drop old check and advice for complex character sets in passwords
Alejandro Colomar [Fri, 24 Mar 2023 17:23:59 +0000 (18:23 +0100)] 
libmisc, man: Drop old check and advice for complex character sets in passwords

Add the relevant XKCD to the passwd(1) manual page.  It already explains
most of the rationale behind this patch.

Add also reference to makepasswd(1), which is a good way to generate
strong passwords.  Personally, I commonly run `makepasswd --chars 64` to
create my passwords, or 32 for passwords I need to type interactively
often.

The strength of a password is an exponential formula, where the base is
the size of the character set, and the exponent is the length of the
password.  That already shows why long passwords of just lowercase
letters are better than short Pa$sw0rdZ3.  But an even more important
point is that humans, when forced to use symbols in a password, are more
likely to do trivial substitutions on simple passwords, which doesn't
increase strength, and can instead give a false sense of strength, which
is dangerous.

Closes: <https://github.com/shadow-maint/shadow/issues/688>
Link: <https://xkcd.com/936/>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agosemanage: disconnect to free libsemanage internals
Christian Göttsche [Sat, 1 Apr 2023 12:11:06 +0000 (14:11 +0200)] 
semanage: disconnect to free libsemanage internals

Destroying the handle does not actually disconnect, see [1].
Also free the key on user removal.

[1]: https://github.com/SELinuxProject/selinux/blob/e9072e7d45f4559887d11b518099135cbe564163/libsemanage/src/direct_api.c#L330

Example adduser leak:

    Direct leak of 1008 byte(s) in 14 object(s) allocated from:
        #0 0x5638f2e782ae in __interceptor_malloc (./src/useradd+0xee2ae)
        #1 0x7fb5cfffad09 in dbase_file_init src/database_file.c:170:45

    Direct leak of 392 byte(s) in 7 object(s) allocated from:
        #0 0x5638f2e782ae in __interceptor_malloc (./src/useradd+0xee2ae)
        #1 0x7fb5cfffc929 in dbase_policydb_init src/database_policydb.c:187:27

    Direct leak of 144 byte(s) in 2 object(s) allocated from:
        #0 0x5638f2e782ae in __interceptor_malloc (./src/useradd+0xee2ae)
        #1 0x7fb5cfffb519 in dbase_join_init src/database_join.c:249:28

    [...]

2 years agocommonio: free removed database entries
Christian Göttsche [Sat, 1 Apr 2023 11:36:51 +0000 (13:36 +0200)] 
commonio: free removed database entries

Free the actual struct of the removed entry.

Example userdel report:

    Direct leak of 40 byte(s) in 1 object(s) allocated from:
        #0 0x55b230efe857 in reallocarray (./src/userdel+0xda857)
        #1 0x55b230f6041f in mallocarray ./lib/./alloc.h:97:9
        #2 0x55b230f6041f in commonio_open ./lib/commonio.c:563:7
        #3 0x55b230f39098 in open_files ./src/userdel.c:555:6
        #4 0x55b230f39098 in main ./src/userdel.c:1189:2
        #5 0x7f9b48c64189 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

2 years agorun_parts for groupadd and groupdel
ed neville [Mon, 27 Mar 2023 19:23:03 +0000 (20:23 +0100)] 
run_parts for groupadd and groupdel

run_parts currently exists in useradd and userdel, this commit mirrors
the functionality with groupadd and groupdel

Hook for group{add,del} to include killing processes that have group
membership that would no longer exist to avoid membership ID reuse.

2 years agofix typos
lilinjie [Thu, 6 Apr 2023 09:08:17 +0000 (17:08 +0800)] 
fix typos

Signed-off-by: lilinjie <lilinjie@uniontech.com>
2 years agolibmisc/yesno.c: Use getline(3) and rpmatch(3)
Alejandro Colomar [Fri, 21 Apr 2023 23:59:33 +0000 (01:59 +0200)] 
libmisc/yesno.c: Use getline(3) and rpmatch(3)

getline(3) is much more readable than manually looping.  It has some
overhead due to the allocation of a buffer, but that shouldn't be a
problem here.  If that was a problem, we could reuse the buffer (thus
making the function non-reentrant), but I don't think that's worth the
extra complexity.

Using rpmatch(3) instead of a simple y/n test provides i18n to the
response checking.  We have a fall-back minimalistic implementation for
systems that lack this function (e.g., musl libc).

While we're at it, apply some other minor improvements to this file:

-  Remove comment saying which files use this function.  That's likely
   to get outdated.  And anyway, it's just a grep(1) away, so it doesn't
   really add any value.

-  Remove unnecessary casts to (void) that were used to verbosely ignore
   errors from stdio calls.  They add clutter without really adding much
   value to the code (or I don't see it).

-  Remove comments from the function body.  They make the function less
   readable.  Instead, centralize the description of the function into a
   man-page-like comment before the function definition.  This keeps the
   function body short and sweet.

-  Add '#include <stdbool.h>', which was missing.

-  Minor whitespace style changes (it doesn't hurt the diff at this
   point, since most of the affected lines were already touched by other
   changes, so I applied my preferred style :).

Acked-by: Samanta Navarro <ferivoz@riseup.net>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agonewgrp/useradd: always set SIGCHLD to default
Samanta Navarro [Wed, 26 Apr 2023 11:59:51 +0000 (11:59 +0000)] 
newgrp/useradd: always set SIGCHLD to default

The tools newgrp and useradd expect waitpid to behave as described in
its manual page. But the notes indicate that if SIGCHLD is ignored,
waitpid behaves differently.

A user could set SIGCHLD to ignore before starting newgrp through exec.
Children of newgrp would not become zombies and their PIDs could be
reassigned before newgrp could call kill with the child pid and SIGCONT.

The useradd tool is not installed setuid, but I have added the default
there as well (copied from vipw).

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agoUpdate AUTHORS to add Marek Michałkiewicz
Serge Hallyn [Wed, 19 Apr 2023 16:41:16 +0000 (11:41 -0500)] 
Update AUTHORS to add Marek Michałkiewicz

Closes #708

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoRead whole line in yes_or_no
Samanta Navarro [Fri, 27 Jan 2023 11:53:57 +0000 (11:53 +0000)] 
Read whole line in yes_or_no

Do not stop after 79 characters. Read the complete line to avoid
arbitrary limitations.

Proof of Concept:

```
cat > passwd-poc << EOF
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
EOF
python -c "print(80*'y')" | pwck passwd-poc
```

Two lines should still be within the file because we agreed only once
to remove a duplicated line.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
2 years agouseradd/usermod: add --selinux-range argument
Christian Göttsche [Sat, 1 Apr 2023 12:34:56 +0000 (14:34 +0200)] 
useradd/usermod: add --selinux-range argument

Add a command line argument to useradd(8) and usermod(8) to specify the
MLS range for a SELinux user mapping.

Improves: #676

2 years agoCI: Make build logs more readable
Alejandro Colomar [Wed, 5 Apr 2023 19:50:28 +0000 (21:50 +0200)] 
CI: Make build logs more readable

If make fails in a multi-process invocation, the log is pretty much
unreadable.  To make it readable, build as much as can be built without
failing.  Then run a single-process make again.  If we succeeded
previously, this should be a no-op.  If not, this run will stop at the
first error, which should be more readable, and will only print the few
lines we're interested in.

This has some side effects:  Now we build as much as we can, instead of
failing as early as possible; this may make CI a bit slower.  However,
it also has the benefit that you see _all_ the error messages that could
be given, instead of needing to fix the first error to see the next and
so on.

Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoci: remove explicit fedora dependencies
Iker Pedrosa [Thu, 13 Apr 2023 10:49:31 +0000 (12:49 +0200)] 
ci: remove explicit fedora dependencies

libbsd-devel libeconf-devel have already been added to the spec file and
they should be installed by the `dnf builddep` command.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>