summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIker Pedrosa <ipedrosa@redhat.com>2023-09-15 09:55:02 +0200
committerSerge Hallyn <serge@hallyn.com>2023-09-15 12:57:16 -0500
commit5178f8c5afb612f6ddf5363823547e080e7f546b (patch)
tree7ff2ea88a91fa9d70e8fa34ac38deea093e837d7
parentbef4da47be72a7fd63f87f327daea9669746bb65 (diff)
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>
-rw-r--r--lib/utmp.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/utmp.c b/lib/utmp.c
index 9b173327..e0ae48a0 100644
--- a/lib/utmp.c
+++ b/lib/utmp.c
@@ -370,17 +370,16 @@ int update_utmp (const char *user,
struct utmp *utent, *ut;
utent = get_current_utmp ();
- if (utent == NULL) {
- return -1;
- }
-
ut = prepare_utmp (user, tty, host, utent);
(void) setutmp (ut); /* make entry in the utmp & wtmp files */
- free (utent);
+
+ if (utent != NULL) {
+ free (utent);
+ }
free (ut);
- return 1;
+ return 0;
}
void record_failure(const char *failent_user,