summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-03-06 09:20:36 -0500
committerVictor Kareh <[email protected]>2019-03-07 09:45:59 -0500
commit7f0a938467e4e3d57c68af1caa146a664458a911 (patch)
tree8f6af59837db9428f04ce6fcf473146b06c19c75
parenta6be59797e503d77bde9e52b86812c3acf34d52f (diff)
downloadmate-session-manager-7f0a938467e4e3d57c68af1caa146a664458a911.tar.bz2
mate-session-manager-7f0a938467e4e3d57c68af1caa146a664458a911.tar.xz
Guard against missing systemd
-rw-r--r--mate-session/gsm-systemd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/mate-session/gsm-systemd.c b/mate-session/gsm-systemd.c
index da3f23b..d03cafd 100644
--- a/mate-session/gsm-systemd.c
+++ b/mate-session/gsm-systemd.c
@@ -429,16 +429,31 @@ gsm_systemd_is_last_session_for_user (GsmSystemd *manager)
gboolean is_last_session;
int ret, i;
+#ifdef HAVE_SYSTEMD
ret = sd_pid_get_session (getpid (), &session);
+#endif
+
+ if (session == NULL) {
+ return FALSE;
+ }
if (ret != 0) {
+ free (session);
return FALSE;
}
+#ifdef HAVE_SYSTEMD
ret = sd_uid_get_sessions (getuid (), FALSE, &sessions);
+#endif
+
+ if (sessions == NULL) {
+ free (session);
+ return FALSE;
+ }
if (ret <= 0) {
free (session);
+ free (sessions);
return FALSE;
}
@@ -450,7 +465,9 @@ gsm_systemd_is_last_session_for_user (GsmSystemd *manager)
if (g_strcmp0 (sessions[i], session) == 0)
continue;
+#ifdef HAVE_SYSTEMD
ret = sd_session_get_state (sessions[i], &state);
+#endif
if (ret != 0)
continue;
@@ -461,7 +478,9 @@ gsm_systemd_is_last_session_for_user (GsmSystemd *manager)
}
free (state);
+#ifdef HAVE_SYSTEMD
ret = sd_session_get_type (sessions[i], &type);
+#endif
if (ret != 0)
continue;