Alejandro Colomar cc2970c3a1
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>
2024-02-14 04:10:03 +01:00
2023-08-04 14:15:49 -05:00
2023-02-09 10:03:03 -06:00
2024-02-13 18:47:39 +01:00
2023-09-10 14:13:01 +02:00
2024-01-26 13:32:08 +01:00
2024-02-14 04:10:03 +01:00
2023-09-10 14:13:01 +02:00
2023-03-02 16:33:06 -06:00
2023-09-10 14:13:01 +02:00
2023-04-18 09:21:09 +02:00
2023-08-07 09:42:11 -05:00
2023-04-26 17:35:58 -05:00
2024-02-13 18:59:37 +01:00
2021-12-23 19:36:50 -06:00
2023-09-10 14:13:01 +02:00
2023-04-26 17:35:58 -05:00
2021-12-19 14:09:08 -06:00
2023-03-20 10:54:45 -05:00
2023-09-10 14:13:01 +02:00

shadow-utils

Introduction

The shadow-utils package includes the necessary programs for converting UNIX password files to the shadow password format, plus programs for managing user and group accounts. The pwconv command converts passwords to the shadow password format. The pwunconv command unconverts shadow passwords and generates a passwd file (a standard UNIX password file). The pwck command checks the integrity of password and shadow files. The lastlog command prints out the last login times for all users. The useradd, userdel, and usermod commands are used for managing user accounts. The groupadd, groupdel, and groupmod commands are used for managing group accounts.

Sites

Contacts

There are several ways to contact us:

Mailing archives

Contributions

Contributions are welcome. Follow the guidelines before posting any patches.

Authors and maintainers

Authors and maintainers are listed in AUTHORS.md.

Description
Upstream shadow tree
Readme 30 MiB
Languages
Shell 54.2%
C 41.2%
Python 3.1%
M4 0.8%
Makefile 0.6%
Other 0.1%