Commit d75ae314 authored by Robert Ancell's avatar Robert Ancell Committed by Ray Strode

act-user-manager: Remove ConsoleKit support

ConsoleKit is very much dead and replaced by logind or elogind.
parent 033cde3c
Pipeline #112012 passed with stage
in 1 minute and 10 seconds
......@@ -194,18 +194,11 @@ config_h.set('MINIMUM_UID', get_option('minimum_uid'))
gdm_conf_file = get_option('gdmconffile')
config_h.set_quoted('PATH_GDM_CUSTOM', gdm_conf_file)
enable_systemd = get_option('systemd')
enable_elogind = get_option('elogind')
assert(not enable_systemd or not enable_elogind, 'systemd and elogind support requested, please choose only one.')
if enable_systemd
logind_dep = dependency('libsystemd', version: '>= 186')
endif
if enable_elogind
if get_option('elogind')
logind_dep = dependency('libelogind', version: '>= 229.4')
else
logind_dep = dependency('libsystemd', version: '>= 186')
endif
config_h.set('WITH_SYSTEMD', enable_systemd or enable_elogind)
subdir('data')
subdir('src')
......
......@@ -6,7 +6,6 @@ option('user_heuristics', type: 'boolean', value: true, description: 'Enable heu
option('extra_admin_groups', type: 'array', value: [], description: 'Comma-separated list of extra groups that administrator users are part of')
option('minimum_uid', type: 'integer', value: 1000, description: 'Set minimum uid for human users')
option('systemd', type: 'boolean', value: false, description: 'Use systemd')
option('elogind', type: 'boolean', value: false, description: 'Use elogind')
option('introspection', type: 'boolean', value: true, description: 'Enable introspection for this build')
......
......@@ -40,20 +40,11 @@
#include <glib-object.h>
#include <gio/gio.h>
#include <gio/gunixinputstream.h>
#ifdef WITH_SYSTEMD
#include <systemd/sd-login.h>
/* check if logind is running */
#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
#endif
#include "act-user-manager.h"
#include "act-user-private.h"
#include "accounts-generated.h"
#include "ck-manager-generated.h"
#include "ck-seat-generated.h"
#include "ck-session-generated.h"
/**
* SECTION:act-user-manager
......@@ -90,13 +81,6 @@
* Various error codes returned by the accounts service.
*/
#define CK_NAME "org.freedesktop.ConsoleKit"
#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager"
#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
#define ACCOUNTS_NAME "org.freedesktop.Accounts"
#define ACCOUNTS_PATH "/org/freedesktop/Accounts"
#define ACCOUNTS_INTERFACE "org.freedesktop.Accounts"
......@@ -104,7 +88,6 @@
typedef enum {
ACT_USER_MANAGER_SEAT_STATE_UNLOADED = 0,
ACT_USER_MANAGER_SEAT_STATE_GET_SESSION_ID,
ACT_USER_MANAGER_SEAT_STATE_GET_SESSION_PROXY,
ACT_USER_MANAGER_SEAT_STATE_GET_ID,
ACT_USER_MANAGER_SEAT_STATE_GET_SEAT_PROXY,
ACT_USER_MANAGER_SEAT_STATE_LOADED,
......@@ -115,19 +98,14 @@ typedef struct
ActUserManagerSeatState state;
char *id;
char *session_id;
ConsoleKitSeat *seat_proxy;
ConsoleKitSession *session_proxy;
guint load_idle_id;
#ifdef WITH_SYSTEMD
sd_login_monitor *session_monitor;
GInputStream *session_monitor_stream;
guint session_monitor_source_id;
#endif
} ActUserManagerSeat;
typedef enum {
ACT_USER_MANAGER_NEW_SESSION_STATE_UNLOADED = 0,
ACT_USER_MANAGER_NEW_SESSION_STATE_GET_PROXY,
ACT_USER_MANAGER_NEW_SESSION_STATE_GET_UID,
ACT_USER_MANAGER_NEW_SESSION_STATE_GET_X11_DISPLAY,
ACT_USER_MANAGER_NEW_SESSION_STATE_MAYBE_ADD,
......@@ -139,7 +117,6 @@ typedef struct
ActUserManager *manager;
ActUserManagerNewSessionState state;
char *id;
ConsoleKitSession *proxy;
GCancellable *cancellable;
uid_t uid;
char *x11_display;
......@@ -180,7 +157,6 @@ typedef struct
GHashTable *sessions;
GDBusConnection *connection;
AccountsAccounts *accounts_proxy;
ConsoleKitManager *ck_manager_proxy;
ActUserManagerSeat seat;
......@@ -270,39 +246,6 @@ act_user_manager_error_quark (void)
return (GQuark) ret;
}
static gboolean
activate_console_kit_session_id (ActUserManager *manager,
const char *seat_id,
const char *session_id)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ConsoleKitSeat *proxy;
g_autoptr(GError) error = NULL;
gboolean res = FALSE;
proxy = console_kit_seat_proxy_new_sync (priv->connection,
G_DBUS_PROXY_FLAGS_NONE,
CK_NAME,
seat_id,
NULL,
&error);
if (proxy)
res = console_kit_seat_call_activate_session_sync (proxy,
session_id,
G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
-1,
NULL,
&error);
if (!res) {
g_warning ("Unable to activate session: %s", error->message);
return FALSE;
}
return TRUE;
}
#ifdef WITH_SYSTEMD
static gboolean
activate_systemd_session_id (ActUserManager *manager,
const char *seat_id,
......@@ -338,50 +281,10 @@ activate_systemd_session_id (ActUserManager *manager,
return TRUE;
}
#endif
static gboolean
_ck_session_is_login_window (ActUserManager *manager,
const char *session_id)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ConsoleKitSession *proxy;
g_autoptr(GError) error = NULL;
g_autofree gchar *session_type = NULL;
gboolean res = FALSE;
proxy = console_kit_session_proxy_new_sync (priv->connection,
G_DBUS_PROXY_FLAGS_NONE,
CK_NAME,
session_id,
NULL,
&error);
if (proxy)
res = console_kit_session_call_get_session_type_sync (proxy,
G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
-1,
&session_type,
NULL,
&error);
if (!res) {
if (error != NULL) {
g_debug ("ActUserManager: Failed to identify the session type: %s", error->message);
} else {
g_debug ("ActUserManager: Failed to identify the session type");
}
return FALSE;
}
if (proxy)
g_object_unref (proxy);
return strcmp (session_type, "LoginWindow") == 0;
}
#ifdef WITH_SYSTEMD
static gboolean
_systemd_session_is_login_window (ActUserManager *manager,
const char *session_id)
session_is_login_window (ActUserManager *manager,
const char *session_id)
{
int res;
g_autofree gchar *session_class = NULL;
......@@ -396,33 +299,10 @@ _systemd_session_is_login_window (ActUserManager *manager,
return g_strcmp0 (session_class, "greeter") == 0;
}
#endif
static gboolean
session_is_login_window (ActUserManager *manager,
const char *session_id)
{
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
return _systemd_session_is_login_window (manager, session_id);
}
#endif
return _ck_session_is_login_window (manager, session_id);
}
static gboolean
_ck_session_is_on_our_seat (ActUserManager *manager,
const char *session_id)
{
/* With ConsoleKit, we only ever see sessions on our seat. */
return TRUE;
}
#ifdef WITH_SYSTEMD
static gboolean
_systemd_session_is_on_our_seat (ActUserManager *manager,
const char *session_id)
session_is_on_our_seat (ActUserManager *manager,
const char *session_id)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
int res;
......@@ -440,20 +320,6 @@ _systemd_session_is_on_our_seat (ActUserManager *manager,
return g_strcmp0 (priv->seat.id, session_seat) == 0;
}
#endif
static gboolean
session_is_on_our_seat (ActUserManager *manager,
const char *session_id)
{
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
return _systemd_session_is_on_our_seat (manager, session_id);
}
#endif
return _ck_session_is_on_our_seat (manager, session_id);
}
/**
* act_user_manager_goto_login_session:
......@@ -486,7 +352,6 @@ act_user_manager_goto_login_session (ActUserManager *manager)
}
#ifdef WITH_SYSTEMD
static gboolean
_can_activate_systemd_sessions (ActUserManager *manager)
{
......@@ -502,32 +367,6 @@ _can_activate_systemd_sessions (ActUserManager *manager)
return res > 0;
}
#endif
static gboolean
_can_activate_console_kit_sessions (ActUserManager *manager)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
g_autoptr(GError) error = NULL;
gboolean can_activate_sessions = FALSE;
if (!console_kit_seat_call_can_activate_sessions_sync (priv->seat.seat_proxy,
G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
-1,
&can_activate_sessions,
NULL,
&error)) {
if (error != NULL) {
g_warning ("unable to determine if seat can activate sessions: %s",
error->message);
} else {
g_warning ("unable to determine if seat can activate sessions");
}
return FALSE;
}
return can_activate_sessions;
}
/**
* act_user_manager_can_switch:
......@@ -555,13 +394,7 @@ act_user_manager_can_switch (ActUserManager *manager)
g_debug ("ActUserManager: checking if seat can activate sessions");
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
return _can_activate_systemd_sessions (manager);
}
#endif
return _can_activate_console_kit_sessions (manager);
return _can_activate_systemd_sessions (manager);
}
/**
......@@ -597,18 +430,7 @@ act_user_manager_activate_user_session (ActUserManager *manager,
return FALSE;
}
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
return activate_systemd_session_id (manager, priv->seat.id, ssid);
}
#endif
if (!activate_console_kit_session_id (manager, priv->seat.id, ssid)) {
g_debug ("ActUserManager: unable to activate session: %s", ssid);
return FALSE;
}
return TRUE;
return activate_systemd_session_id (manager, priv->seat.id, ssid);
}
static const char *
......@@ -687,40 +509,6 @@ queue_load_seat_incrementally (ActUserManager *manager)
}
}
static void
on_get_seat_id_finished (GObject *object,
GAsyncResult *result,
gpointer data)
{
ConsoleKitSession *proxy = CONSOLE_KIT_SESSION (object);
g_autoptr(ActUserManager) manager = data;
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
g_autoptr(GError) error = NULL;
char *seat_id;
if (!console_kit_session_call_get_seat_id_finish (proxy, &seat_id, result, &error)) {
if (error != NULL) {
g_debug ("Failed to identify the seat of the "
"current session: %s",
error->message);
} else {
g_debug ("Failed to identify the seat of the "
"current session");
}
g_debug ("ActUserManager: GetSeatId call failed, so unloading seat");
unload_seat (manager);
return;
}
g_debug ("ActUserManager: Found current seat: %s", seat_id);
priv->seat.id = seat_id;
priv->seat.state++;
}
#ifdef WITH_SYSTEMD
static gboolean
_systemd_session_is_graphical (const char *session_id)
{
......@@ -824,7 +612,7 @@ _find_graphical_systemd_session (char **session_id)
}
static void
_get_systemd_seat_id (ActUserManager *manager)
get_seat_id_for_current_session (ActUserManager *manager)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
int res;
......@@ -851,26 +639,6 @@ _get_systemd_seat_id (ActUserManager *manager)
priv->seat.id = g_strdup (seat_id);
priv->seat.state++;
}
#endif
static void
get_seat_id_for_current_session (ActUserManager *manager)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
_get_systemd_seat_id (manager);
return;
}
#endif
console_kit_session_call_get_seat_id (priv->seat.session_proxy,
G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
-1,
NULL,
on_get_seat_id_finished,
g_object_ref (manager));
}
static gint
match_name_cmpfunc (gconstpointer a,
......@@ -1254,39 +1022,7 @@ on_user_removed_in_accounts_service (GDBusProxy *proxy,
}
static void
on_get_current_session_finished (GObject *object,
GAsyncResult *result,
gpointer data)
{
ConsoleKitManager *proxy = CONSOLE_KIT_MANAGER (object);
g_autoptr(ActUserManager) manager = data;
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
g_autoptr(GError) error = NULL;
char *session_id;
g_assert (priv->seat.state == ACT_USER_MANAGER_SEAT_STATE_GET_SESSION_ID);
if (!console_kit_manager_call_get_current_session_finish (proxy, &session_id, result, &error)) {
if (error != NULL) {
g_debug ("Failed to identify the current session: %s",
error->message);
} else {
g_debug ("Failed to identify the current session");
}
unload_seat (manager);
return;
}
priv->seat.session_id = session_id;
priv->seat.state++;
queue_load_seat_incrementally (manager);
}
#ifdef WITH_SYSTEMD
static void
_get_current_systemd_session_id (ActUserManager *manager)
get_current_session_id (ActUserManager *manager)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
g_autofree gchar *session_id = NULL;
......@@ -1301,47 +1037,6 @@ _get_current_systemd_session_id (ActUserManager *manager)
priv->seat.state++;
queue_load_seat_incrementally (manager);
}
#endif
static void
get_current_session_id (ActUserManager *manager)
{
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
_get_current_systemd_session_id (manager);
return;
}
#endif
if (priv->ck_manager_proxy == NULL) {
g_autoptr(GError) error = NULL;
priv->ck_manager_proxy = console_kit_manager_proxy_new_sync (priv->connection,
G_DBUS_PROXY_FLAGS_NONE,
CK_NAME,
CK_MANAGER_PATH,
NULL,
&error);
if (priv->ck_manager_proxy == NULL) {
if (error != NULL) {
g_warning ("Failed to create ConsoleKit proxy: %s", error->message);
} else {
g_warning ("Failed to create_ConsoleKit_proxy");
}
unload_seat (manager);
return;
}
}
console_kit_manager_call_get_current_session (priv->ck_manager_proxy,
G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
-1, NULL,
on_get_current_session_finished,
g_object_ref (manager));
}
static void
......@@ -1362,11 +1057,6 @@ unload_new_session (ActUserManagerNewSession *new_session)
new_session->cancellable = NULL;
}
if (new_session->proxy != NULL) {
g_object_unref (new_session->proxy);
new_session->proxy = NULL;
}
g_free (new_session->x11_display);
new_session->x11_display = NULL;
g_free (new_session->id);
......@@ -1391,79 +1081,7 @@ unload_new_session (ActUserManagerNewSession *new_session)
}
static void
get_proxy_for_new_session (ActUserManagerNewSession *new_session)
{
ActUserManager *manager = new_session->manager;
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
g_autoptr(GError) error = NULL;
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
new_session->state++;
load_new_session_incrementally (new_session);
return;
}
#endif
new_session->proxy = console_kit_session_proxy_new_sync (priv->connection,
G_DBUS_PROXY_FLAGS_NONE,
CK_NAME,
new_session->id,
NULL,
&error);
if (new_session->proxy == NULL) {
g_warning ("Failed to connect to the ConsoleKit '%s' object: %s",
new_session->id, error->message);
unload_new_session (new_session);
return;
}
new_session->state++;
load_new_session_incrementally (new_session);
}
static void
on_get_unix_user_finished (GObject *object,
GAsyncResult *result,
gpointer data)
{
ConsoleKitSession *proxy = CONSOLE_KIT_SESSION (object);
ActUserManagerNewSession *new_session = data;
g_autoptr(GError) error = NULL;
guint uid;
new_session->pending_calls--;
if (new_session->cancellable == NULL || g_cancellable_is_cancelled (new_session->cancellable)) {
unload_new_session (new_session);
return;
}
if (!console_kit_session_call_get_unix_user_finish (proxy, &uid, result, &error)) {
if (error != NULL) {
g_debug ("Failed to get uid of session '%s': %s",
new_session->id, error->message);
} else {
g_debug ("Failed to get uid of session '%s'",
new_session->id);
}
unload_new_session (new_session);
return;
}
g_debug ("ActUserManager: Found uid of session '%s': %u",
new_session->id, uid);
new_session->uid = (uid_t) uid;
new_session->state++;
load_new_session_incrementally (new_session);
}
#ifdef WITH_SYSTEMD
static void
_get_uid_for_new_systemd_session (ActUserManagerNewSession *new_session)
get_uid_for_new_session (ActUserManagerNewSession *new_session)
{
uid_t uid;
int res;
......@@ -1483,28 +1101,6 @@ _get_uid_for_new_systemd_session (ActUserManagerNewSession *new_session)
load_new_session_incrementally (new_session);
}
#endif
static void
get_uid_for_new_session (ActUserManagerNewSession *new_session)
{
#ifdef WITH_SYSTEMD
if (LOGIND_RUNNING()) {
_get_uid_for_new_systemd_session (new_session);
return;
}
#endif
g_assert (new_session->proxy != NULL);
new_session->pending_calls++;
console_kit_session_call_get_unix_user (new_session->proxy,
G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
-1,
new_session->cancellable,
on_get_unix_user_finished,
new_session);
}
static void
on_find_user_by_name_finished (GObject *object,
......@@ -1656,46 +1252,7 @@ load_included_usernames (ActUserManager *manager)
}
static void
on_get_x11_display_finished (GObject *object,
GAsyncResult *result,
gpointer data)
{
ConsoleKitSession *proxy = CONSOLE_KIT_SESSION (object);
ActUserManagerNewSession *new_session = data;
g_autoptr(GError) error = NULL;
char *x11_display;
new_session->pending_calls--;
if (new_session->cancellable == NULL || g_cancellable_is_cancelled (new_session->cancellable)) {
unload_new_session (new_session);
return;
}
if (!console_kit_session_call_get_x11_display_finish (proxy, &x11_display, result, &error)) {
if (error != NULL) {
g_debug ("Failed to get the x11 display of session '%s': %s",
new_session->id, error->message);
} else {
g_debug ("Failed to get the x11 display of session '%s'",
new_session->id);
}
unload_new_session (new_session);
return;
}