sd-login: add sd_session_get_leader interface

This commit is contained in:
Thorsten Kukuk
2023-06-07 09:33:36 +01:00
committed by Luca Boccassi
parent 3fa3d612a2
commit 403082602d
4 changed files with 35 additions and 0 deletions
+1
View File
@@ -826,4 +826,5 @@ global:
sd_pid_notify_barrier;
sd_event_source_leave_ratelimit;
sd_journal_step_one;
sd_session_get_leader;
} LIBSYSTEMD_253;
+19
View File
@@ -870,6 +870,25 @@ _public_ int sd_session_get_remote_host(const char *session, char **remote_host)
return session_get_string(session, "REMOTE_HOST", remote_host);
}
_public_ int sd_session_get_leader(const char *session, pid_t *leader) {
_cleanup_free_ char *leader_string = NULL;
pid_t pid;
int r;
assert_return(leader, -EINVAL);
r = session_get_string(session, "LEADER", &leader_string);
if (r < 0)
return r;
r = parse_pid(leader_string, &pid);
if (r < 0)
return r;
*leader = pid;
return 0;
}
_public_ int sd_seat_get_active(const char *seat, char **session, uid_t *uid) {
_cleanup_free_ char *p = NULL, *s = NULL, *t = NULL;
int r;
+3
View File
@@ -184,6 +184,9 @@ int sd_session_get_desktop(const char *session, char **desktop);
/* Determine the X11 display of this session. */
int sd_session_get_display(const char *session, char **display);
/* Determine the leader process of this session. */
int sd_session_get_leader(const char *session, pid_t *leader);
/* Determine the remote host of this session. */
int sd_session_get_remote_host(const char *session, char **remote_host);