aboutsummaryrefslogtreecommitdiff
path: root/libseat/backend
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-24 02:55:14 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-24 02:55:14 +0200
commitab4b961492ef91a9e2b456b4e2812eaad9994c3a (patch)
tree045070316dfae86d9cd3390d111f93c2189ddb4f /libseat/backend
parent26aff210586479ae5d40f101633c96c0d4f670e3 (diff)
libseat: Remove useless logind fallbacks
The logind code is based on the wlroots implementation, which in turn contained copy-paste code from Mutter that serves no purpose here.
Diffstat (limited to 'libseat/backend')
-rw-r--r--libseat/backend/logind.c72
1 files changed, 4 insertions, 68 deletions
diff --git a/libseat/backend/logind.c b/libseat/backend/logind.c
index 9f4eabc..4ebeb17 100644
--- a/libseat/backend/logind.c
+++ b/libseat/backend/logind.c
@@ -538,51 +538,6 @@ static bool add_signal_matches(struct backend_logind *backend) {
return true;
}
-static bool contains_str(const char *needle, const char **haystack) {
- for (int i = 0; haystack[i]; i++) {
- if (strcmp(haystack[i], needle) == 0) {
- return true;
- }
- }
-
- return false;
-}
-
-static bool get_greeter_session(char **session_id) {
- char *class = NULL;
- char **user_sessions = NULL;
- int user_session_count = sd_uid_get_sessions(getuid(), 1, &user_sessions);
-
- if (user_session_count < 0) {
- goto out;
- }
-
- if (user_session_count == 0) {
- goto out;
- }
-
- for (int i = 0; i < user_session_count; ++i) {
- int ret = sd_session_get_class(user_sessions[i], &class);
- if (ret < 0) {
- continue;
- }
-
- if (strcmp(class, "greeter") == 0) {
- *session_id = strdup(user_sessions[i]);
- goto out;
- }
- }
-
-out:
- free(class);
- for (int i = 0; i < user_session_count; ++i) {
- free(user_sessions[i]);
- }
- free(user_sessions);
-
- return *session_id != NULL;
-}
-
static bool find_session_path(struct backend_logind *session) {
int ret;
sd_bus_message *msg = NULL;
@@ -638,7 +593,6 @@ out:
static bool get_display_session(char **session_id) {
assert(session_id != NULL);
char *xdg_session_id = getenv("XDG_SESSION_ID");
- char *state = NULL;
if (xdg_session_id) {
// This just checks whether the supplied session ID is valid
@@ -646,48 +600,30 @@ static bool get_display_session(char **session_id) {
goto error;
}
*session_id = strdup(xdg_session_id);
- return true;
+ goto success;
}
// If there's a session active for the current process then just use
// that
int ret = sd_pid_get_session(getpid(), session_id);
if (ret == 0) {
- return true;
+ goto success;
}
// Find any active sessions for the user if the process isn't part of an
// active session itself
ret = sd_uid_get_display(getuid(), session_id);
- if (ret < 0 && ret != -ENODATA) {
- goto error;
- }
-
- if (ret != 0 && !get_greeter_session(session_id)) {
- goto error;
- }
-
- assert(*session_id != NULL);
-
- // Check that the session is active
- ret = sd_session_get_state(*session_id, &state);
if (ret < 0) {
goto error;
}
- const char *active_states[] = {"active", "online", NULL};
- if (!contains_str(state, active_states)) {
- goto error;
- }
-
- free(state);
+success:
+ assert(*session_id != NULL);
return true;
error:
- free(state);
free(*session_id);
*session_id = NULL;
-
return false;
}