summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Nagy <robert@openbsd.org>2022-11-10 13:29:06 +0100
committerRobert Nagy <robert@openbsd.org>2022-11-10 13:29:06 +0100
commitf4ac61f5fe2632f30a7ef2125cbea1d281571bfc (patch)
tree8cf386e986d7649b5b39dfd79684fdc8194eba5d
parent74695630307785e571599a5c93f4a3bda129a17a (diff)
downloadConsoleKit2-f4ac61f5fe2632f30a7ef2125cbea1d281571bfc.tar.gz
implement more sd_* shim functions
-rw-r--r--libconsolekit/libconsolekit.h11
-rw-r--r--libconsolekit/sd-compat.c77
-rw-r--r--libconsolekit/sd-login.h5
3 files changed, 93 insertions, 0 deletions
diff --git a/libconsolekit/libconsolekit.h b/libconsolekit/libconsolekit.h
index c435215..b928872 100644
--- a/libconsolekit/libconsolekit.h
+++ b/libconsolekit/libconsolekit.h
@@ -126,6 +126,11 @@ gboolean lib_consolekit_session_get_remote_host (LibConsoleKit *ck,
gchar **remote_host,
GError **error);
+gboolean lib_consolekit_session_get_service (LibConsoleKit *ck,
+ const gchar *session,
+ gchar **sercice,
+ GError **error);
+
gboolean lib_consolekit_session_get_tty (LibConsoleKit *ck,
const gchar *session,
gchar **tty,
@@ -143,6 +148,12 @@ gboolean lib_consolekit_pid_get_session (LibConsoleKit *ck,
gint
+lib_consolekit_pid_get_sessions (LibConsoleKit *ck,
+ pid_t pid,
+ gchar **sessions,
+ GError **error);
+
+gint
lib_consolekit_uid_get_sessions (LibConsoleKit *ck,
uid_t uid,
gchar ***sessions,
diff --git a/libconsolekit/sd-compat.c b/libconsolekit/sd-compat.c
index a5ed457..31cbb5d 100644
--- a/libconsolekit/sd-compat.c
+++ b/libconsolekit/sd-compat.c
@@ -121,6 +121,52 @@ sd_session_get_uid(const char *session, uid_t *uid)
}
int
+sd_session_get_service(const char *session, char **service)
+{
+ LibConsoleKit *ck = NULL;
+ GError *error = NULL;
+
+ ck = lib_consolekit_new ();
+
+ lib_consolekit_session_get_service (ck, session, service, &error);
+ if (error) {
+ g_warning ("Unable to determine session service: %s",
+ error ? error->message : "");
+ g_error_free (error);
+ g_object_unref (ck);
+ return -ENXIO;
+ }
+
+ g_object_unref (ck);
+
+ return 0;
+}
+
+
+int
+sd_pid_get_session(pid_t pid, char **session)
+{
+ LibConsoleKit *ck = NULL;
+ GError *error = NULL;
+ int ret = 0;
+
+ ck = lib_consolekit_new ();
+
+ ret = lib_consolekit_pid_get_session (ck, pid, session, &error);
+ if (error) {
+ g_warning ("Unable to determine list of session for pid: %s",
+ error ? error->message : "");
+ g_error_free (error);
+ g_object_unref (ck);
+ return -ENXIO;
+ }
+
+ g_object_unref (ck);
+
+ return ret;
+}
+
+int
sd_uid_get_sessions(uid_t uid, int require_active, char ***sessions)
{
LibConsoleKit *ck = NULL;
@@ -144,6 +190,13 @@ sd_uid_get_sessions(uid_t uid, int require_active, char ***sessions)
}
int
+sd_seat_can_graphical(const char *seat)
+{
+ // XXX
+ return 1;
+}
+
+int
sd_seat_can_multi_session(const char *seat)
{
LibConsoleKit *ck = NULL;
@@ -167,6 +220,30 @@ sd_seat_can_multi_session(const char *seat)
}
int
+sd_seat_get_sessions(const char *seat, char ***sessions,
+ uid_t **uid, unsigned int *n_uids)
+{
+ LibConsoleKit *ck = NULL;
+ GError *error = NULL;
+ int num_sessions;
+
+ ck = lib_consolekit_new ();
+
+ num_sessions = lib_consolekit_seat_get_sessions (ck, seat, sessions, &error);
+ if (error) {
+ g_warning ("Unable to determine if seat can activate sessions: %s",
+ error ? error->message : "");
+ g_error_free (error);
+ g_object_unref (ck);
+ return FALSE;
+ }
+
+ g_object_unref (ck);
+
+ return num_sessions;
+}
+
+int
sd_get_sessions(char ***sessions)
{
LibConsoleKit *ck = NULL;
diff --git a/libconsolekit/sd-login.h b/libconsolekit/sd-login.h
index bbaca76..232598b 100644
--- a/libconsolekit/sd-login.h
+++ b/libconsolekit/sd-login.h
@@ -5,8 +5,13 @@ int sd_session_get_seat(const char *session, char **seat);
int sd_session_get_type(const char *session, char **type);
int sd_session_get_state(const char *session, char **state);
int sd_session_get_uid(const char *session, uid_t *uid);
+
+int sd_pid_get_session(pid_t pid, char **session);
+
int sd_uid_get_sessions(uid_t uid, int require_active, char ***sessions);
+int sd_seat_can_graphical(const char *seat);
int sd_seat_can_multi_session(const char *seat);
+int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **uid, unsigned int *n_uids);
int sd_get_sessions(char ***sessions);