call sd_seat_can_tty to determine if ttys should be used, instead of hard-coding seat0

Summary: All TTYs are on seat0, but not all seat0s have TTYs

Reviewers: #efl, devilhorns

Reviewed By: #efl, devilhorns

Subscribers: bu5hm4n, stefan_schmidt, raster, cedric, #reviewers, #committers

Tags: #efl

Reviewed-by: Christopher Michael <devilhorns@comcast.net>
Differential Revision: https://phab.enlightenment.org/D12143
This commit is contained in:
nerdopolis 2020-09-18 11:44:23 +02:00 committed by Marcel Hollerbach
parent 875f05cef5
commit 57354e01ec
1 changed files with 6 additions and 2 deletions

View File

@ -21,6 +21,7 @@ static int (*_elput_sd_session_get_vt) (const char *session, unsigned *vtnr) = N
static int (*_elput_sd_session_get_tty) (const char *session, char **display) = NULL;
static int (*_elput_sd_pid_get_session) (pid_t pid, char **session) = NULL;
static int (*_elput_sd_session_get_seat) (const char *session, char **seat) = NULL;
static int (*_elput_sd_seat_can_tty) (const char *seat) = NULL;
void
_elput_sd_init(void)
@ -91,14 +92,17 @@ _elput_sd_init(void)
eina_module_symbol_get(_libsystemd, "sd_pid_get_session");
_elput_sd_session_get_seat =
eina_module_symbol_get(_libsystemd, "sd_session_get_seat");
_elput_sd_seat_can_tty =
eina_module_symbol_get(_libsystemd, "sd_seat_can_tty");
if (((!_elput_sd_session_get_vt) && (!_elput_sd_session_get_tty)) ||
(!_elput_sd_pid_get_session) ||
(!_elput_sd_session_get_seat))
(!_elput_sd_session_get_seat) || (!_elput_sd_seat_can_tty))
{
_elput_sd_session_get_vt = NULL;
_elput_sd_session_get_tty = NULL;
_elput_sd_pid_get_session = NULL;
_elput_sd_session_get_seat = NULL;
_elput_sd_seat_can_tty = NULL;
eina_module_free(_libsystemd);
_libsystemd = NULL;
_libsystemd_broken = EINA_TRUE;
@ -631,7 +635,7 @@ _logind_connect(Elput_Manager **manager, const char *seat, unsigned int tty)
goto seat_err;
}
if ((seat) && (!strcmp(seat, "seat0")))
if ((seat) && (_elput_sd_seat_can_tty(seat)))
{
if (!_logind_session_vt_get(em->sid, &em->vt_num))
{