diff options
author | Iker Pedrosa <ipedrosa@redhat.com> | 2023-09-15 09:55:02 +0200 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2023-10-30 00:00:19 +0100 |
commit | de50b394757eedcfa86298971cc20176ed8778ba (patch) | |
tree | c61bd2373dd4b31e7f61ff02a03c4e9134f3f54e | |
parent | b5c99ec30eb5fbe46ed3f4d7bf03415132850a30 (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>
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>
-rw-r--r-- | lib/utmp.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -368,17 +368,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, |