diff options
| author | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
| commit | 33491bc4279481db8ae47213e34a6d695a0e8830 (patch) | |
| tree | 097d2b0fdff3fae6885381ae5e57a182cd8cbbba /src/nm-session-monitor-systemd.c | |
| parent | 59c3714a494c3b3765657c0551ad82842d98a7d2 (diff) | |
Imported Upstream version 0.9.10.0 upstream/0.9.10.0
Diffstat (limited to 'src/nm-session-monitor-systemd.c')
| -rw-r--r-- | src/nm-session-monitor-systemd.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/nm-session-monitor-systemd.c b/src/nm-session-monitor-systemd.c index f9fb075d..f195c1e7 100644 --- a/src/nm-session-monitor-systemd.c +++ b/src/nm-session-monitor-systemd.c @@ -193,11 +193,8 @@ nm_session_monitor_get (void) { static NMSessionMonitor *singleton = NULL; - if (singleton) - return g_object_ref (singleton); - - singleton = NM_SESSION_MONITOR (g_object_new (NM_TYPE_SESSION_MONITOR, NULL)); - g_assert (singleton); + if (!singleton) + singleton = g_object_new (NM_TYPE_SESSION_MONITOR, NULL); return singleton; } @@ -237,18 +234,19 @@ nm_session_monitor_uid_has_session (NMSessionMonitor *monitor, const char **out_user, GError **error) { - int ret; + int num_sessions; if (!nm_session_uid_to_user (uid, out_user, error)) return FALSE; - ret = sd_uid_get_sessions (uid, FALSE, NULL) > 0; - if (ret < 0) { + /* Get all sessions (including inactive ones) for the user */ + num_sessions = sd_uid_get_sessions (uid, 0, NULL); + if (num_sessions < 0) { nm_log_warn (LOGD_CORE, "Failed to get systemd sessions for uid %d: %d", - uid, ret); + uid, num_sessions); return FALSE; } - return ret > 0 ? TRUE : FALSE; + return num_sessions > 0; } gboolean @@ -256,13 +254,14 @@ nm_session_monitor_uid_active (NMSessionMonitor *monitor, uid_t uid, GError **error) { - int ret; + int num_sessions; - ret = sd_uid_get_sessions (uid, TRUE, NULL) > 0; - if (ret < 0) { + /* Get active sessions for the user */ + num_sessions = sd_uid_get_sessions (uid, 1, NULL); + if (num_sessions < 0) { nm_log_warn (LOGD_CORE, "Failed to get active systemd sessions for uid %d: %d", - uid, ret); + uid, num_sessions); return FALSE; } - return ret > 0 ? TRUE : FALSE; + return num_sessions > 0; } |