summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Pleau <jason@jpleau.ca>2018-05-30 21:48:22 -0400
committerRay Strode <halfline@gmail.com>2018-06-12 09:32:12 +0000
commit086d68f24d984fb48e44aa16aa815825cd5ed0bc (patch)
tree0c17b1af339e551a77bf0304124c8be90d5df310
parent638c8dfe0653b88b07aa890497258110bc15a374 (diff)
downloadgdm-086d68f24d984fb48e44aa16aa815825cd5ed0bc.tar.gz
daemon/gdm-session-record.c: open/close the utmp database
pututxline() was used without first opening the utxmp database and without closing it, preventing the logout entry from being fully committed. This caused the number of logged-in users to increment after each login, as logging out did not correctly remove the user login record from utmp. This commit wraps pututxline() between setutxent() and endutxent(), making sure that the login/logout operation are fully flushed. Fixes #381
-rw-r--r--daemon/gdm-session-record.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/daemon/gdm-session-record.c b/daemon/gdm-session-record.c
index 487f1004..d2df5887 100644
--- a/daemon/gdm-session-record.c
+++ b/daemon/gdm-session-record.c
@@ -213,7 +213,9 @@ gdm_session_record_login (GPid session_pid,
/* Handle utmp */
#if defined(HAVE_GETUTXENT)
g_debug ("Adding or updating utmp record for login");
+ setutxent();
pututxline (&session_record);
+ endutxent();
#elif defined(HAVE_LOGIN)
login (&session_record);
#endif
@@ -256,7 +258,9 @@ gdm_session_record_logout (GPid session_pid,
/* Handle utmp */
#if defined(HAVE_GETUTXENT)
g_debug ("Adding or updating utmp record for logout");
+ setutxent();
pututxline (&session_record);
+ endutxent();
#elif defined(HAVE_LOGOUT)
logout (session_record.ut_line);
#endif