summaryrefslogtreecommitdiff
path: root/src/lib/elput/elput_logind.c
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-06-06 14:53:35 -0400
committerChris Michael <cpmichael@osg.samsung.com>2016-06-06 14:53:35 -0400
commit180e64653d8a06609dc6ad22d58fa51455e40cf9 (patch)
tree40a6e9335f64d6c260136fd55682ea4a4326494e /src/lib/elput/elput_logind.c
parentb1f62061b960a4c40e89a440d7aa90473c9bfd9c (diff)
elput: Fix crash whem sd_session_get_seat fails
If systemd fails to give us a valid session id, then any further calls to get a seat from that session are going to fail. As such, check for a valid seat return from systemd before calling any systemd functions which require session id. Fixes T3785 @fix Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
Diffstat (limited to 'src/lib/elput/elput_logind.c')
-rw-r--r--src/lib/elput/elput_logind.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/elput/elput_logind.c b/src/lib/elput/elput_logind.c
index 57b00dc8d4..22cb1b02cc 100644
--- a/src/lib/elput/elput_logind.c
+++ b/src/lib/elput/elput_logind.c
@@ -406,7 +406,7 @@ _logind_connect(Elput_Manager **manager, const char *seat, unsigned int tty)
406{ 406{
407 Elput_Manager *em; 407 Elput_Manager *em;
408 int ret = 0; 408 int ret = 0;
409 char *s; 409 char *s = NULL;
410 410
411 em = calloc(1, sizeof(Elput_Manager)); 411 em = calloc(1, sizeof(Elput_Manager));
412 if (!em) return EINA_FALSE; 412 if (!em) return EINA_FALSE;
@@ -421,6 +421,8 @@ _logind_connect(Elput_Manager **manager, const char *seat, unsigned int tty)
421 goto session_err; 421 goto session_err;
422 } 422 }
423 423
424 if (!em->sid) goto session_err;
425
424 ret = sd_session_get_seat(em->sid, &s); 426 ret = sd_session_get_seat(em->sid, &s);
425 if (ret < 0) 427 if (ret < 0)
426 { 428 {
@@ -428,7 +430,7 @@ _logind_connect(Elput_Manager **manager, const char *seat, unsigned int tty)
428 free(s); 430 free(s);
429 goto seat_err; 431 goto seat_err;
430 } 432 }
431 else if ((seat) && (strcmp(seat, s))) 433 else if ((seat) && (s) && (strcmp(seat, s)))
432 { 434 {
433 ERR("Seat '%s' differs from session seat '%s'", seat, s); 435 ERR("Seat '%s' differs from session seat '%s'", seat, s);
434 free(s); 436 free(s);