useradd: fix write_full() return value

Resolves: #2313559

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
This commit is contained in:
Iker Pedrosa 2024-09-19 16:52:21 +02:00
commit 79e26c836e
2 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,34 @@
From 8903b94c86c978e8abef623358fd3e4629c06967 Mon Sep 17 00:00:00 2001
From: Iker Pedrosa <ipedrosa@redhat.com>
Date: Mon, 9 Sep 2024 10:36:17 +0200
Subject: [PATCH] useradd: fix write_full() return value
write_full() returns -1 on error and useradd was checking another value.
Closes: https://github.com/shadow-maint/shadow/issues/1072
Fixes: f45498a6c286 ("libmisc/write_full.c: Improve write_full()")
Reported-by: <https://github.com/brown-midas>
Suggested-by: <https://github.com/brown-midas>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
---
src/useradd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/useradd.c b/src/useradd.c
index 02c500d0..d64fd892 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -2042,7 +2042,7 @@ static void lastlog_reset (uid_t uid)
return;
}
if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
- || (write_full (fd, &ll, sizeof (ll)) != (ssize_t) sizeof (ll))
+ || (write_full (fd, &ll, sizeof (ll)) != -1)
|| (fsync (fd) != 0)) {
fprintf (stderr,
_("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
--
2.46.0

View file

@ -1,7 +1,7 @@
Summary: Utilities for managing accounts and shadow password files
Name: shadow-utils
Version: 4.15.1
Release: 10%{?dist}
Release: 11%{?dist}
Epoch: 2
License: BSD-3-Clause AND GPL-2.0-or-later
URL: https://github.com/shadow-maint/shadow
@ -30,6 +30,8 @@ Patch3: shadow-4.15.1-audit-update.patch
Patch4: shadow-4.15.0-account-tools-setuid.patch
# https://github.com/shadow-maint/shadow/commit/ead55e9ba8958504e23e29545f90c4dd925c7462
Patch5: shadow-4.15.0-getdef-spurious-error.patch
# https://github.com/shadow-maint/shadow/commit/8903b94c86c978e8abef623358fd3e4629c06967
Patch6: shadow-4.15.1-useradd-fix-write-full-return.patch
### Dependencies ###
Requires: audit-libs >= 1.6.5
@ -296,6 +298,9 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/libsubid.a
%{_libdir}/libsubid.so
%changelog
* Mon Sep 30 2024 Iker Pedrosa <ipedrosa@redhat.com> - 2:4.15.1-11
- useradd: fix write_full() return value. Resolves: #2313559
* Wed Sep 18 2024 Iker Pedrosa <ipedrosa@redhat.com> - 2:4.15.1-10
- Disable nscd