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>
This commit is contained in:
Iker Pedrosa
2023-07-18 16:48:02 +02:00
committed by Serge Hallyn
parent b6ca83ea4c
commit 6b7108e347
3 changed files with 24 additions and 24 deletions
+12 -1
View File
@@ -339,7 +339,7 @@ static void updwtmp (const char *filename, const struct utmp *ut)
*
* Return 1 on failure and 0 on success.
*/
int setutmp (struct utmp *ut)
static int setutmp (struct utmp *ut)
{
int err = 0;
@@ -358,3 +358,14 @@ int setutmp (struct utmp *ut)
return err;
}
void update_utmp (const char *user,
const char *tty,
const char *host,
/*@null@*/const struct utmp *utent)
{
struct utmp *ut = prepare_utmp (user, tty, host, utent);
(void) setutmp (ut); /* make entry in the utmp & wtmp files */
free (ut);
}