]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
5 weeks agoRelease 4.14.7 4.14.x 4.14.7
Alejandro Colomar [Tue, 26 Mar 2024 19:46:18 +0000 (20:46 +0100)] 
Release 4.14.7

Closes: <https://github.com/shadow-maint/shadow/issues/959>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 weeks agolib/copydir.c: copy_entry(): Use temporary stat buffer
Enrico Scholz [Mon, 18 Mar 2024 11:14:21 +0000 (12:14 +0100)] 
lib/copydir.c: copy_entry(): Use temporary stat buffer

There are no guarantees that fstatat() does not clobber the stat
buffer on errors.

Use a temporary buffer so that the following code sees correct
attributes of the source entry.

Link: <https://github.com/shadow-maint/shadow/issues/973>
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 000619344ddb ("lib/copydir:copy_entry(): use temporary stat buffer")
Link: <https://github.com/shadow-maint/shadow/pull/974>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 weeks agoman/po/fr.po: Fix wrong french translation
Antoine Roux [Tue, 19 Mar 2024 15:49:45 +0000 (16:49 +0100)] 
man/po/fr.po: Fix wrong french translation

32 characters were wrongly translated to 16 in french translation file.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 51a0d94a0892 ("Fix wrong french translation")
Link: <https://github.com/shadow-maint/shadow/pull/975>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 weeks agolib/, src/: Add checks for fd omission
Skyler Ferrante [Fri, 8 Mar 2024 17:53:21 +0000 (12:53 -0500)] 
lib/, src/: Add checks for fd omission

Adding function check_fds to new file fd.c. The function check_fds
should be called in every setuid/setgid program.

Co-developed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: d2f2c1877a30 ("Adding checks for fd omission")
Link: <https://github.com/shadow-maint/shadow/pull/964>
Link: <https://inbox.sourceware.org/libc-alpha/ZeyujhVRsDTUNUtw@debian/T/>
[alx: It seems we shouldn't need this, as libc does it for us.  But it ]
[     shouldn't hurt either.  Let's be paranoic.                       ]
Cc: <Guillem Jover <guillem@hadrons.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: "Skyler Ferrante (RIT Student)" <sjf5462@rit.edu>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Christian Brauner <christian@brauner.io>
Cc: Rich Felker <dalias@libc.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Cc: Thorsten Glaser <tg@mirbsd.de>
Cc: NRK <nrk@disroot.org>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: enh <enh@google.com>
Cc: Laurent Bercot <ska-dietlibc@skarnet.org>
Cc: Gabriel Ravier <gabravier@gmail.com>
Cc: Zack Weinberg <zack@owlfolio.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 weeks agosrc/vipw.c: Use string literals to initialize 'Prog'
Alejandro Colomar [Thu, 7 Mar 2024 22:38:48 +0000 (23:38 +0100)] 
src/vipw.c: Use string literals to initialize 'Prog'

This avoids using argv[0], which is controlled by the user,
and might inject arbitrary text in stderr and the logs.

Link: <https://github.com/shadow-maint/shadow/issues/959>
Link: <https://github.com/shadow-maint/shadow/pull/960>
Cc: "Skyler Ferrante (RIT Student)" <sjf5462@rit.edu>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Karel Zak <kzak@redhat.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Christian Brauner <christian@brauner.io>
Cherry-picked-from: 89c4da43cbe8 ("src/vipw.c: Use string literals to initialize 'Prog'")
Link: <https://github.com/shadow-maint/shadow/pull/962>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 weeks agosrc/vipw.c: Reverse logic and variable name
Alejandro Colomar [Thu, 7 Mar 2024 22:34:31 +0000 (23:34 +0100)] 
src/vipw.c: Reverse logic and variable name

Since we're checking for "vigr", it makes more sense to name the
variable accordingly.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 0ab893a734b1 ("src/vipw.c: Reverse logic and variable name")
Link: <https://github.com/shadow-maint/shadow/pull/962>
[alx: This is needed by 89c4da43cbe8 ("src/vipw.c: Use string literals to initialize 'Prog'")
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 weeks agosrc/: Hardcode Prog to known value
Skyler Ferrante [Sun, 3 Mar 2024 05:54:05 +0000 (00:54 -0500)] 
src/: Hardcode Prog to known value

Set Prog (program name) based on hardcoded value instead of argv[0].
This is to help prevent escape sequence injection.

Cherry-picked-from: e6c2e4393784 ("Hardcoding Prog to known value")
Link: <https://github.com/shadow-maint/shadow/issues/959>
Link: <https://github.com/shadow-maint/shadow/pull/960>
Cc: "Skyler Ferrante (RIT Student)" <sjf5462@rit.edu>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Karel Zak <kzak@redhat.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Christian Brauner <christian@brauner.io>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoRelease 4.14.6 4.14.6
Alejandro Colomar [Fri, 1 Mar 2024 19:52:49 +0000 (20:52 +0100)] 
Release 4.14.6

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Use the appropriate autotools macros for struct utmpx
Alejandro Colomar [Tue, 20 Feb 2024 18:15:41 +0000 (19:15 +0100)] 
lib/utmp.c: Use the appropriate autotools macros for struct utmpx

Recently, we started using utmpx instead of utmp, and we updated
<./configure.ac> to do the checks for 'struct utmpx' instead of
'struct utmp'.  However, I forgot to update the preprocessor
conditionals accordingly.

Fixes: 64bcb54fa962 ("lib/, src/, configure.ac: Use utmpx instead of utmp")
Link: <https://github.com/shadow-maint/shadow/pull/954>
Cc: Firas Khalil Khana <firasuke@gmail.com>
Cc: "A. Wilfox" <https://github.com/awilfox>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 1af6b68cbeb9 ("lib/utmp.c: Use the appropriate autotools macros for struct utmpx")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Use defined() instead of #if[n]def
Alejandro Colomar [Tue, 20 Feb 2024 18:13:03 +0000 (19:13 +0100)] 
lib/utmp.c: Use defined() instead of #if[n]def

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 2806b827d839 ("lib/utmp.c: Use defined() instead of #if[n]def")
[alx: This is needed by 1af6b68cbeb9 ("lib/utmp.c: Use the appropriate autotools macros for struct utmpx")]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Remove #endif comments
Alejandro Colomar [Tue, 20 Feb 2024 18:25:37 +0000 (19:25 +0100)] 
lib/utmp.c: Remove #endif comments

Indentation makes it clear which is which.

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 7e94a2f4841a ("lib/utmp.c: Remove #endif comments")
[alx: This is needed by 1af6b68cbeb9 ("lib/utmp.c: Use the appropriate autotools macros for struct utmpx")]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Merge preprocessor conditionals
Alejandro Colomar [Tue, 20 Feb 2024 18:09:36 +0000 (19:09 +0100)] 
lib/utmp.c: Merge preprocessor conditionals

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: e5815acf371f ("lib/utmp.c: Merge preprocessor conditionals")
[alx: This is needed by 1af6b68cbeb9 ("lib/utmp.c: Use the appropriate autotools macros for struct utmpx")]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Indent nested preprocessor conditionals
Alejandro Colomar [Tue, 20 Feb 2024 18:06:49 +0000 (19:06 +0100)] 
lib/utmp.c: Indent nested preprocessor conditionals

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: f4ea04b72861 ("lib/utmp.c: Indent nested preprocessor conditionals")
[alx: This is needed by 1af6b68cbeb9 ("lib/utmp.c: Use the appropriate autotools macros for struct utmpx")]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/utmp.c: Replace UT_LINESIZE by a NITEMS() calculation
Alejandro Colomar [Sun, 18 Feb 2024 17:36:04 +0000 (18:36 +0100)] 
lib/utmp.c: Replace UT_LINESIZE by a NITEMS() calculation

A difference between 'struct utmp' and 'struct utmpx' is that
the former uses UT_LINESIZE for the size of its array members,
while the latter doesn't have a standard variable to get its
size.  Therefore, we need to get the number of elements in
the array with NITEMS().

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cc: Firas Khalil Khana <firasuke@gmail.com>
Cc: "A. Wilfox" <https://github.com/awilfox>
Cherry-picked-from: 5ff6edf9f29e ("lib/utmp.c: Replace UT_LINESIZE by a NITEMS() calculation")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/, src/, configure.ac: Use utmpx instead of utmp
Alejandro Colomar [Sat, 17 Feb 2024 14:15:38 +0000 (15:15 +0100)] 
lib/, src/, configure.ac: Use utmpx instead of utmp

utmpx is specified by POSIX as an XSI extension.  That's more portable
than utmp, which is unavailable for example in musl libc.  The manual
page specifies that in Linux (but it probably means in glibc), utmp and
utmpx (and the functions that use them) are identical, so this commit
shouldn't affect glibc systems.

Assume utmpx is always present.

Also, if utmpx is present, POSIX guarantees that some members exist:

-  ut_user
-  ut_id
-  ut_line
-  ut_pid
-  ut_type
-  ut_tv

So, rely on them unconditionally.

Fixes: 170b76cdd1a9 ("Disable utmpx permanently")
Closes: <https://github.com/shadow-maint/shadow/issues/945>
Reported-by: Firas Khalil Khana <firasuke@gmail.com>
Reported-by: "A. Wilfox" <https://github.com/awilfox>
Tested-by: Firas Khalil Khana <firasuke@gmail.com>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 64bcb54fa962 ("lib/, src/, configure.ac: Use utmpx instead of utmp")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoRevert 3 cherry-picks
Alejandro Colomar [Tue, 20 Feb 2024 21:47:41 +0000 (22:47 +0100)] 
Revert 3 cherry-picks

This changes pull some more dependencies.  That's too much for a stable
branch, I think.  If anyone needs them, please ask for them, but for now
let's keep them out.

Reverts: 9d5591fba90f ("src/passwd.c: check password length upper limit")
Reverts: dbdda2a48a77 ("lib/: Saturate addition to avoid overflow")
Reverts: 541d4dde23e8 ("src/chage.c: Unify long overflow checks in print_day_as_date()")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/getdate.y: get_date(): Fix calculation
Alejandro Colomar [Thu, 15 Feb 2024 11:59:23 +0000 (12:59 +0100)] 
lib/getdate.y: get_date(): Fix calculation

Instead of adding 1, we should add the value the we stored previously in
the variable.

Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Closes: <https://github.com/shadow-maint/shadow/issues/939>
Link: <https://github.com/shadow-maint/shadow/pull/942>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Reported-by: Gus Kenion <https://github.com/kenion>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 4d139ca46682 ("lib/getdate.y: get_date(): Fix calculation")
Link: <https://github.com/shadow-maint/shadow/pull/952>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/passwd.c: check password length upper limit
Tomas Halman [Fri, 16 Feb 2024 08:52:39 +0000 (09:52 +0100)] 
src/passwd.c: check password length upper limit

The passwd silently truncated the password length to PASS_MAX.
This patch introduces check that prints an error message
and exits the call.

Signed-off-by: Tomas Halman <tomas@halman.net>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: f024002b3d66 ("src/passwd.c: inconsistent password length limit")
Cc: Serge Hallyn <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/953>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/passwd.c: inconsistent password length limit
Tomas Halman [Fri, 16 Feb 2024 08:33:02 +0000 (09:33 +0100)] 
src/passwd.c: inconsistent password length limit

The passwd utility had hardcoded limit for password lenght set
to 200 characters. In the agetpass.c is used PASS_MAX for
this purpose.

This patch moves the PASS_MAX definition to common place
and uses it in both places.

Signed-off-by: Tomas Halman <tomas@halman.net>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: f024002b3d66 ("src/passwd.c: inconsistent password length limit")
Cc: Serge Hallyn <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/953>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/strtoday.c: strtoday(): Fix calculation
Alejandro Colomar [Thu, 8 Feb 2024 11:53:24 +0000 (12:53 +0100)] 
lib/strtoday.c: strtoday(): Fix calculation

Days officially roll over at 00:00 UTC, not at 12:00 UTC.  I see no
reason to add that half day.

Also, remove the comment.  It's likely to get stale.

So, get_date() gets the number of seconds since the Epoch.  I wonder how
that thing works, but I'll assume it's something similar to getdate(3)
+ mktime(3).  After that, we need to convert seconds since Epoch to days
since Epoch.  That should be a simple division, AFAICS, since Epoch is
"1970‐01‐01 00:00:00 +0000 (UTC)".  See mktime(3).

Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Link: <https://github.com/shadow-maint/shadow/issues/939>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Tested-by: Gus Kenion <https://github.com/kenion>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 1175932c0c86 ("lib/strtoday.c: strtoday(): Fix calculation")
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/942>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/login.c: Fix off-by-one bugss
Alejandro Colomar [Mon, 5 Feb 2024 12:54:25 +0000 (13:54 +0100)] 
src/login.c: Fix off-by-one bugss

These functions expect a size, not a length.  Don't subtract 1 to the
size.

Link: <https://github.com/shadow-maint/shadow/pull/935>
Link: <https://github.com/shadow-maint/shadow/issues/920#issuecomment-1926002209>
Link: <https://github.com/shadow-maint/shadow/pull/757>
Link: <https://github.com/shadow-maint/shadow/issues/674>
See-also: 0656a90bfd0d ("src/login.c: Fix off-by-one buggs")
See-also: 403a2e3771be ("lib/chkname.c: Take NUL byte into account")
Fixes: 3b7cc053872c ("lib: replace `USER_NAME_MAX_LENGTH` macro")
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 15882a5f904b ("src/login.c: Fix off-by-one bugss")
Link: <https://github.com/shadow-maint/shadow/pull/936>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/login.c: Fix off-by-one buggs
Alejandro Colomar [Mon, 5 Feb 2024 12:14:13 +0000 (13:14 +0100)] 
src/login.c: Fix off-by-one buggs

Before 3b7cc053872c ("lib: replace `USER_NAME_MAX_LENGTH` macro"), this
code did use a length.  It used a utmp(5) fixed-width buffer, so the
length matches the buffer size (there was no terminating NUL byte).
However, sysconf(_SC_LOGIN_NAME_MAX) returns a buffer size that accounts
for the terminating null byte; see sysconf(3).  Thus, the commit that
introduced the call to sysconf(3), should have taken that detail into
account.

403a2e3771be ("lib/chkname.c: Take NUL byte into account"), by Tobias,
caught that bug in <lib/chkname.c>, but missed that the same commit that
introduced that bug, introduced the same bug in two other places.
This fixes all remaining calls to sysconf(_SC_LOGIN_NAME_MAX).

I still observe some suspicious code after this fix:

if (do_rlogin(hostname, username, max_size - 1, term, sizeof(term)))

...

login_prompt(username, max_size - 1);

We're passing size-1 to functions that want a size.  But since the fix
to those will be different, let's do that in the following commits.

Link: <https://github.com/shadow-maint/shadow/pull/935>
Link: <https://github.com/shadow-maint/shadow/issues/920#issuecomment-1926002209>
Link: <https://github.com/shadow-maint/shadow/pull/757>
Link: <https://github.com/shadow-maint/shadow/issues/674>
See-also: 403a2e3771be ("lib/chkname.c: Take NUL byte into account")
Fixes: 3b7cc053872c ("lib: replace `USER_NAME_MAX_LENGTH` macro")
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 6551709e96b2 ("src/login.c: Fix off-by-one buggs")
Link: <https://github.com/shadow-maint/shadow/pull/936>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/: Saturate addition to avoid overflow
Tobias Stoeckmann [Mon, 18 Dec 2023 19:45:44 +0000 (20:45 +0100)] 
lib/: Saturate addition to avoid overflow

Very large values in /etc/shadow could lead to overflows.  Make sure
that these calculations are saturated at LONG_MAX.  Since entries are
based on days and not seconds since epoch, saturating won't hurt anyone.

Co-developed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 674409e2265e ("lib/: Saturate addition to avoid overflow")
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/876>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agosrc/chage.c: Unify long overflow checks in print_day_as_date()
Tobias Stoeckmann [Thu, 14 Dec 2023 11:33:35 +0000 (12:33 +0100)] 
src/chage.c: Unify long overflow checks in print_day_as_date()

The conversion from day to seconds can be done in print_date
(renamed to print_day_as_date for clarification).  This has the nice
benefit that DAY multiplication and long to time_t conversion are done
at just one place.

Co-developed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 20100e4b22c3 ("src/chage.c: Unify long overflow checks in print_day_as_date()")
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/876>
[alx: This is a pre-requisite for 674409e2265e ("lib/: Saturate addition to avoid overflow")]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/, src/: Remove SCALE definition
Tobias Stoeckmann [Wed, 13 Dec 2023 20:25:51 +0000 (20:25 +0000)] 
lib/, src/: Remove SCALE definition

SCALE is always DAY (and has to be always DAY), so replace it with DAY
in source code and remove unneeded calculations.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: <https://github.com/shadow-maint/shadow/pull/876>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: ecc3508877d2 ("lib/, src/: Remove SCALE definition")
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/888>
Link: <https://github.com/shadow-maint/shadow/pull/876>
[alx: This is a pre-requisite for 674409e2265e ("lib/: Saturate addition to avoid overflow")]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/defines.h: Remove ITI_AGING
Tobias Stoeckmann [Tue, 12 Dec 2023 16:37:30 +0000 (17:37 +0100)] 
lib/defines.h: Remove ITI_AGING

ITI_AGING is not set through any build environment. If it would be set,
then timings in /etc/shadow would not fit anymore.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Cherry-picked-from: ab260fcd1f6f ("lib/defines.h: Remove ITI_AGING")
Link: <https://github.com/shadow-maint/shadow/pull/873>
Link: <https://github.com/shadow-maint/shadow/pull/876>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
[alx: This is a pre-requisite for 674409e2265e ("lib/: Saturate addition to avoid overflow")]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoRelease 4.14.5 4.14.5
Alejandro Colomar [Tue, 13 Feb 2024 17:59:37 +0000 (18:59 +0100)] 
Release 4.14.5

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoetc/pam.d/Makefile.am: Fix typo
Alejandro Colomar [Tue, 13 Feb 2024 12:17:44 +0000 (13:17 +0100)] 
etc/pam.d/Makefile.am: Fix typo

The commit we're fixing mentions that it wanted to move 'chpasswd', but
it removed 'ch_g_passwd' from 'pamd_acct_tools_files' and added
'chpasswd' to 'pamd_files'.  It seems it removed the wrong thing by
accident.

Fixes: 341d80c2c751 ("Makefile: move chpasswd and newusers to pamd target")
Link: <https://github.com/shadow-maint/shadow/pull/928#discussion_r1487687347>
Link: <https://github.com/shadow-maint/shadow/issues/926#issuecomment-1941324761>
Reported-by: Dominique Leuenberger <dleuenberger@suse.com>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Cc: David Runge <dvzrv@archlinux.org>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Tested-by: Michael Vetter <jubalh@iodoru.org>
Reviewed-by: Michael Vetter <jubalh@iodoru.org>
Reviewed-by: loqs <https://github.com/loqs>
Co-developed-by: Dominique Leuenberger <dleuenberger@suse.com>
Signed-off-by: Dominique Leuenberger <dleuenberger@suse.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 7eb10e6298aa ("etc/pam.d/Makefile.am: Fix typo")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agoRelease 4.14.4 4.14.4
Alejandro Colomar [Sun, 11 Feb 2024 22:46:58 +0000 (23:46 +0100)] 
Release 4.14.4

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/chkname.c: Take NUL byte into account
Tobias Stoeckmann [Sat, 3 Feb 2024 00:07:58 +0000 (01:07 +0100)] 
lib/chkname.c: Take NUL byte into account

The _SC_LOGIN_NAME_MAX value includes space for the NUL byte.  The
length of name must smaller than this value to be valid.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Cherry-picked-from: 403a2e3771be ("lib/chkname.c: Take NUL byte into account")
Link: <https://github.com/shadow-maint/shadow/pull/935>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 months agolib/chkname.c: Use tmp variable to avoid a -Wsign-compare warning
Alejandro Colomar [Sat, 2 Sep 2023 12:15:43 +0000 (14:15 +0200)] 
lib/chkname.c: Use tmp variable to avoid a -Wsign-compare warning

I used size_t because:

sysconf(3) can return -1 if the value is not supported, but then it can
only mean that there's no limit.  Having no limit is the same as having
a limit of SIZE_MAX (to which -1 is converted).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 6be85b0bafb5 ("lib/chkname.c: Use tmp variable to avoid a -Wsign-compare warning")
[alx: This is to cherry-pick the next commit without conflict]
Link: <https://github.com/shadow-maint/shadow/pull/801>
Link: <https://github.com/shadow-maint/shadow/pull/935>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agoMakefile: Move chpasswd and newusers to pamd target
loqs [Fri, 26 Jan 2024 12:41:09 +0000 (12:41 +0000)] 
Makefile: Move chpasswd and newusers to pamd target

Install pam configs for chpasswd and newusers when using:

$ ./configure --with-libpam --disable-account-tools-setuid

Closes: <https://github.com/shadow-maint/shadow/issues/810>
Link: <https://github.com/shadow-maint/shadow/pull/928>
Tested-by: David Runge <dvzrv@archlinux.org>
Cherry-picked-from: 341d80c2c751 ("Makefile: move chpasswd and newusers to pamd target")
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/logind.c: active_sessions_count(): Fix build error 'parameter name omitted'
Pablo Saavedra [Mon, 22 Jan 2024 13:46:15 +0000 (14:46 +0100)] 
lib/logind.c: active_sessions_count(): Fix build error 'parameter name omitted'

Add the omitted parameter name.

Closes: <https://github.com/shadow-maint/shadow/issues/918>
Link: <https://github.com/shadow-maint/shadow/pull/919>
Signed-off-by: Pablo Saavedra <psaavedra@igalia.com>
Cherry-picked-from: da84d0ede79a ("Fix Build error 'parameter name omitted' in logind")
Cc: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agoLink correctly with libdl
Sam James [Sun, 21 Jan 2024 14:58:33 +0000 (14:58 +0000)] 
Link correctly with libdl

This fixes build with glibc-2.33 (newer glibc merged libdl and libpthread
into libc):
```
libtool: link: x86_64-pc-linux-gnu-gcc -isystem /usr/include/bsd -DLIBBSD_OVERLAY -O2 -pipe -Wl,-O1 -o login login.o login_nopam.o  -Wl,--as-needed ../lib/.libs/libshadow.a -lcrypt -lsystemd -lpam -lpam_misc -lbsd
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: ../lib/.libs/libshadow.a(libshadow_la-nss.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
```

In Debian, the needed macro from libtool seems to be in libltdl-dev.

Signed-off-by: Sam James <sam@gentoo.org>
Cc: Iker Pedrosa <ikerpedrosam@gmail.com>
Cherry-picked-from: 0f4e59fd00cf ("Link correctly with libdl")
Link: <https://github.com/shadow-maint/shadow/pull/917>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agoRelease 4.14.3 4.14.3
Alejandro Colomar [Mon, 15 Jan 2024 23:01:06 +0000 (00:01 +0100)] 
Release 4.14.3

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 months agolib/sgetgrent.c: fix null pointer dereference
Samanta Navarro [Fri, 12 Jan 2024 11:49:27 +0000 (11:49 +0000)] 
lib/sgetgrent.c: fix null pointer dereference

If reallocation fails in function list, then reset the size to 0 again.
Without the reset, the next call assumes that `members` points to
a memory location with reserved space.

Also use size_t instead of int for size to prevent signed integer
overflows. The length of group lines is not limited.

Fixes 45c0003e53ab671c63dcd530fd9f3245d3b29e76 (4.14 release series)

Proof of Concept:

-  Prepare a group file (one long group line and a shorter one, both with a list of users)

$ echo -n "root:x:0:" > /tmp/uwu
$ yes , | tr -d '\n' | dd of=/tmp/uwu bs=10 count=3145728 seek=1 conv=notrunc iflag=fullblock
$ echo -e "\nbin:x:1:," >> /tmp/uwu

-  Run grpck with tight memory constraints

$ ulimit -d 102400
$ grpck /tmp/uwu
Segmentation fault (core dumped)

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Cherry-picked-from: a9e07c0feb43 ("lib/sgetgrent.c: fix null pointer dereference")
Link: <https://github.com/shadow-maint/shadow/pull/904>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agoRelease 4.14.2 824/head 4.14.2
Alejandro Colomar [Sun, 29 Oct 2023 23:14:15 +0000 (00:14 +0100)] 
Release 4.14.2

Link: <https://github.com/shadow-maint/shadow/pull/824>
Reviewed-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agoman: document --prefix option in chage, chpasswd and passwd
Michael Vetter [Fri, 20 Oct 2023 13:22:35 +0000 (15:22 +0200)] 
man: document --prefix option in chage, chpasswd and passwd

Support for `--prefix` was added in
https://github.com/shadow-maint/shadow/pull/714 and is available since
shadow 4.14.0.

Close https://github.com/shadow-maint/shadow/issues/822

Cherry-picked-from: 01f6258df744 ("man: document --prefix option in chage, chpasswd and passwd")
Link: <https://github.com/shadow-maint/shadow/pull/823>
Suggested-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agouseradd: Set proper SELinux labels for def_usrtemplate
Johannes Segitz [Tue, 26 Sep 2023 13:14:14 +0000 (15:14 +0200)] 
useradd: Set proper SELinux labels for def_usrtemplate

Fixes: 74c17c716 ("Add support for skeleton files from /usr/etc/skel")
Signed-off-by: Johannes Segitz <jsegitz@suse.com>
Cherry-picked-from: 48aa12af31c0b72872b411857d03a518a4200a3d
Link: <https://github.com/shadow-maint/shadow/pull/812>
Reviewed-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agoutmp: call prepare_utmp() even if utent is NULL
Iker Pedrosa [Fri, 15 Sep 2023 07:55:02 +0000 (09:55 +0200)] 
utmp: call prepare_utmp() even if utent is NULL

update_utmp() should also return 0 when success.

Fixes: 1f368e1c1838de9d476a36897d7c53394569de08 ("utmp: update
`update_utmp()")
Resolves: https://github.com/shadow-maint/shadow/issues/805

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Cherry-picked-from: 5178f8c5afb612f6ddf5363823547e080e7f546b
Link: <https://github.com/shadow-maint/shadow/issues/805>
Link: <https://github.com/shadow-maint/shadow/pull/808>
Reviewed-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agolib/btrfs: avoid NULL-dereference
Christian Göttsche [Thu, 26 Jan 2023 20:03:56 +0000 (21:03 +0100)] 
lib/btrfs: avoid NULL-dereference

    btrfs.c:42:13: warning: use of NULL 'cmd' where non-null expected [CWE-476] [-Wanalyzer-null-argument]

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 54ab542887994f8b6e5411469d6867e3a2e58800
Link: <https://github.com/shadow-maint/shadow/pull/770>
Reviewed-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
6 months agoReplace __{BEGIN,END}_DECLS with #ifdef __cplusplus
Heiko Becker [Fri, 18 Aug 2023 16:23:56 +0000 (18:23 +0200)] 
Replace __{BEGIN,END}_DECLS with #ifdef __cplusplus

Fixes the build with musl libc.

Cherry-picked-from: 890f911e17169e44b43fe98742540267093559ea
Link: <https://github.com/shadow-maint/shadow/pull/789>
Reviewed-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 months agoRelease 4.14.1 4.14.1
Alejandro Colomar [Mon, 25 Sep 2023 15:55:02 +0000 (17:55 +0200)] 
Release 4.14.1

The same thing, but this time, it's official.  :)

Link: <https://lists.sr.ht/~hallyn/shadow/%3Cphikwsgcwerp4anb4qpfkruwqqy4rqsmowv6pi23m5rqvhxw4i%40yuexyhynkim3%3E>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 months agoRelease 4.14.1-alx
Alejandro Colomar [Mon, 18 Sep 2023 12:50:02 +0000 (14:50 +0200)] 
Release 4.14.1-alx

Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 months agolib: Merge libmisc into libshadow
Alejandro Colomar [Mon, 28 Aug 2023 10:54:22 +0000 (12:54 +0200)] 
lib: Merge libmisc into libshadow

The separation was unnecessary, and caused build problems.  Let's go
wild and obliterate the library.  The files are moved to libshadow.

Scripted change:

$ find libmisc/ -type f \
| grep '\.[chy]$' \
| xargs mv -t lib;

Plus updating the Makefile and other references.  While at it, I've
sorted the sources lists.

Link: <https://github.com/shadow-maint/shadow/pull/792>
Reported-by: David Seifert <soap@gentoo.org>
Cc: Sam James <sam@gentoo.org>
Cc: Christian Bricart <christian@bricart.de>
Cc: Michael Vetter <jubalh@iodoru.org>
Cc: Robert Förster <Dessa@gmake.de>
[ soap tested the Gentoo package ]
Tested-by: David Seifert <soap@gentoo.org>
Acked-by: David Seifert <soap@gentoo.org>
Acked-by: Serge Hallyn <serge@hallyn.com>
Acked-by: Iker Pedrosa <ipedrosa@redhat.com>
Acked-by: <lslebodn@fedoraproject.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
7 months agolib, libmisc: Move source files to lib (where their headers were)
Alejandro Colomar [Fri, 25 Aug 2023 09:29:00 +0000 (11:29 +0200)] 
lib, libmisc: Move source files to lib (where their headers were)

Scripted change:

$ find lib/ -type f \
| grep '\.h$' \
| sed 's,lib/,libmisc/,' \
| sed 's,\.h$,.c,' \
| xargs find 2>/dev/null \
| xargs mv -t lib/;

Plus updating the Makefiles.

Closes: <https://github.com/shadow-maint/shadow/issues/791>
Closes: <https://bugs.gentoo.org/912446>
Link: <https://github.com/shadow-maint/shadow/issues/763#issuecomment-1664383425>
Link: <https://github.com/shadow-maint/shadow/pull/776>
Link: <https://github.com/shadow-maint/shadow/commit/d0518cc250afeaceb772a7f50a900cfc9b3ab937>
Reported-by: Christian Bricart <christian@bricart.de>
Reported-by: Robert Marmorstein <robert@marmorstein.org>
Cc: Sam James <sam@gentoo.org>
[ jubalh tested the openSUSE package ]
Tested-by: Michael Vetter <jubalh@iodoru.org>
Acked-by: Michael Vetter <jubalh@iodoru.org>
[ Robert F. tested the Gentoo package ]
Tested-by: Robert Förster <Dessa@gmake.de>
Cc: David Seifert <soap@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agorelease 4.14.0 4.14.0
Serge Hallyn [Wed, 16 Aug 2023 02:38:30 +0000 (21:38 -0500)] 
release 4.14.0

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 months agopre-release 4.14.0-rc5 4.14.0-rc5
Serge Hallyn [Mon, 14 Aug 2023 16:51:36 +0000 (11:51 -0500)] 
pre-release 4.14.0-rc5

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 months agoconfigure.ac: check for strlcpy
Serge Hallyn [Mon, 14 Aug 2023 13:27:30 +0000 (08:27 -0500)] 
configure.ac: check for strlcpy

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 months agoRemove intree website
Michael Vetter [Mon, 14 Aug 2023 06:57:40 +0000 (08:57 +0200)] 
Remove intree website

AFAIK these files were not used in a while.
On 2023-04-27 we also archived the GitHub pages based repo:
https://github.com/shadow-maint/shadow-www

In https://github.com/shadow-maint/shadow/commit/1654f42194ba7804c99d5ac96346a1a19fb793d7 we mention the regular repo URL as our home page.

Also see:
https://github.com/shadow-maint/shadow/issues/114

8 months ago4.14.0-rc4 pre-release 4.14.0-rc4
Serge Hallyn [Sun, 13 Aug 2023 04:17:52 +0000 (23:17 -0500)] 
4.14.0-rc4 pre-release

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 months agoReleases: add etc/shadow-maint to distfiles
Serge Hallyn [Fri, 11 Aug 2023 17:47:41 +0000 (12:47 -0500)] 
Releases: add etc/shadow-maint to distfiles

Closes #784

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 months ago4.14.0-rc3 4.14.0-rc3
Serge Hallyn [Thu, 10 Aug 2023 14:33:07 +0000 (09:33 -0500)] 
4.14.0-rc3

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 months agolibmisc: include freezero
Iker Pedrosa [Thu, 10 Aug 2023 07:46:38 +0000 (09:46 +0200)] 
libmisc: include freezero

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 months agolibmisc: add freezero source code
Iker Pedrosa [Thu, 10 Aug 2023 07:45:32 +0000 (09:45 +0200)] 
libmisc: add freezero source code

If shadow is built without libbsd support, then freezero() needs to be
provided from the project.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 months agolibmisc: add readpassphrase source code
Iker Pedrosa [Tue, 8 Aug 2023 14:01:41 +0000 (16:01 +0200)] 
libmisc: add readpassphrase source code

If shadow is built without libbsd support, then readpassphrase() needs
to be provided from the project.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 months agoconfigure: add `with-libbsd` option
Iker Pedrosa [Thu, 10 Aug 2023 07:15:04 +0000 (09:15 +0200)] 
configure: add `with-libbsd` option

It enables the build with libbsd support. By default it is enabled.

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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 months agoman: include `shadow-man.xsl` in tarball
Iker Pedrosa [Tue, 8 Aug 2023 10:52:21 +0000 (12:52 +0200)] 
man: include `shadow-man.xsl` in tarball

This will help generate man pages from tarball.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 months agoman: include `its.rules` in tarball
Iker Pedrosa [Tue, 8 Aug 2023 10:50:27 +0000 (12:50 +0200)] 
man: include `its.rules` in tarball

This will help generate the man pages from tarball.

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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
8 months agoautogen: enable lastlog build
Iker Pedrosa [Mon, 7 Aug 2023 08:12:04 +0000 (10:12 +0200)] 
autogen: enable lastlog build

Add "--enable-lastlog" to include lastlog man pages in tarball.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
9 months agoAdd wrapper for write(2)
Christian Göttsche [Tue, 28 Feb 2023 15:35:05 +0000 (16:35 +0100)] 
Add wrapper for write(2)

write(2) may not write the complete given buffer.  Add a wrapper to
avoid short writes.

9 months agotag 4.14.0-rc2 4.14.0-rc2
Serge Hallyn [Fri, 4 Aug 2023 21:24:54 +0000 (16:24 -0500)] 
tag 4.14.0-rc2

Signed-off-by: Serge Hallyn <serge@hallyn.com>
9 months agoAdd new files to libmisc_la_SOURCES
Michael Vetter [Fri, 4 Aug 2023 12:26:50 +0000 (14:26 +0200)] 
Add new files to libmisc_la_SOURCES

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

9 months agoAdd a make dist CI test
Serge Hallyn [Fri, 4 Aug 2023 14:59:56 +0000 (09:59 -0500)] 
Add a make dist CI test

Add a CI test to check that make dist builds a usable tarball.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
9 months ago4.14.0-rc1 4.14.0-rc1
Serge Hallyn [Mon, 31 Jul 2023 14:39:12 +0000 (09:39 -0500)] 
4.14.0-rc1

Signed-off-by: Serge Hallyn <serge@hallyn.com>
9 months agoremove xmalloc.c from POTFILES.in
Serge Hallyn [Thu, 3 Aug 2023 13:24:44 +0000 (08:24 -0500)] 
remove xmalloc.c from POTFILES.in

Signed-off-by: Serge Hallyn <serge@hallyn.com>
9 months agologoutd: add missing <utmp.h> include
Iker Pedrosa [Fri, 21 Jul 2023 06:35:17 +0000 (08:35 +0200)] 
logoutd: add missing <utmp.h> include

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
9 months agoCI: compile old utmp interface in Fedora
Iker Pedrosa [Fri, 21 Jul 2023 06:26:51 +0000 (08:26 +0200)] 
CI: compile old utmp interface in Fedora

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
9 months agosrc: add SELINUX library
Iker Pedrosa [Wed, 19 Jul 2023 11:00:17 +0000 (13:00 +0200)] 
src: add SELINUX library

With the recent changes both login and su compilation fail because there
are some missing dependencies from SELINUX library. Thus, add LIBSELINUX
to su and login for those cases where the library is used.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
9 months agolibmisc: conditionally compile `utmp.c` and `logind.c`
Iker Pedrosa [Wed, 19 Jul 2023 10:41:06 +0000 (12:41 +0200)] 
libmisc: conditionally compile `utmp.c` and `logind.c`

Depending on the configuration option selected.

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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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

9 months 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

9 months 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>
9 months 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>
9 months 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").

9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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>
9 months 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

10 months 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.

10 months 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>
10 months 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>
10 months 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>
10 months 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>
10 months 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>