[Spice-devel] [vdagent-linux v1] Remove ConsoleKit integration
Victor Toso
victortoso at redhat.com
Sat Apr 9 07:16:37 UTC 2016
ConsoleKit is no longer maintained upstream. New code should be focusing
with the integration with systemd-logind.
---
Makefile.am | 4 -
configure.ac | 23 +---
src/console-kit.c | 354 -----------------------------------------------------
src/session-info.h | 2 +-
src/vdagentd.c | 3 -
5 files changed, 3 insertions(+), 383 deletions(-)
delete mode 100644 src/console-kit.c
diff --git a/Makefile.am b/Makefile.am
index 7def506..84df428 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,15 +22,11 @@ src_spice_vdagentd_SOURCES = src/vdagentd.c \
src/vdagentd-xorg-conf.c \
src/vdagent-virtio-port.c \
src/udscs.c
-if HAVE_CONSOLE_KIT
-src_spice_vdagentd_SOURCES += src/console-kit.c
-else
if HAVE_LIBSYSTEMD_LOGIN
src_spice_vdagentd_SOURCES += src/systemd-login.c
else
src_spice_vdagentd_SOURCES += src/dummy-session-info.c
endif
-endif
noinst_HEADERS = src/glib-compat.h \
src/session-info.h \
diff --git a/configure.ac b/configure.ac
index de72ea2..6ddada1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,10 +17,10 @@ AC_DEFINE(_GNU_SOURCE, [1], [Enable GNU extensions])
PKG_PROG_PKG_CONFIG
AC_ARG_WITH([session-info],
- [AS_HELP_STRING([--with-session-info=@<:@auto/console-kit/systemd/none@:>@],
+ [AS_HELP_STRING([--with-session-info=@<:@auto/systemd/none@:>@],
[Session-info source to use @<:@default=auto@:>@])],
[case "$with_session_info" in
- auto|console-kit|systemd|none) ;;
+ auto|systemd|none) ;;
*) AC_MSG_ERROR([invalid session-info type specified]) ;;
esac],
[with_session_info="auto"])
@@ -106,25 +106,6 @@ else
fi
AM_CONDITIONAL(HAVE_LIBSYSTEMD_LOGIN, test x"$have_libsystemd_login" = "xyes")
-if test "$with_session_info" = "auto" || test "$with_session_info" = "console-kit"; then
- PKG_CHECK_MODULES([DBUS],
- [dbus-1],
- [have_console_kit="yes"],
- [have_console_kit="no"])
- if test x"$have_console_kit" = "xno" && test "$with_session_info" = "console-kit"; then
- AC_MSG_ERROR([console-kit support explicitly requested, but some required packages are not available])
- fi
- if test x"$have_console_kit" = "xyes"; then
- AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support])
- with_session_info="console-kit"
- else
- with_session_info="none"
- fi
-else
- have_console_kit="no"
-fi
-AM_CONDITIONAL(HAVE_CONSOLE_KIT, test x"$have_console_kit" = "xyes")
-
if test x"$enable_pciaccess" = "xyes" ; then
PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
AC_DEFINE([HAVE_PCIACCESS], [1], [If defined, vdagentd will be compiled with pciaccess support] )
diff --git a/src/console-kit.c b/src/console-kit.c
deleted file mode 100644
index 6e83bf2..0000000
--- a/src/console-kit.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* console-kit.c vdagentd ConsoleKit integration code
-
- Copyright 2010-2012 Red Hat, Inc.
-
- Red Hat Authors:
- Hans de Goede <hdegoede at redhat.com>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "session-info.h"
-#include <dbus/dbus.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-
-struct session_info {
- DBusConnection *connection;
- int fd;
- char *seat;
- char *active_session;
-};
-
-static char *console_kit_get_first_seat(struct session_info *ck);
-static char *console_kit_check_active_session_change(struct session_info *ck);
-
-struct session_info *session_info_create(int verbose)
-{
- struct session_info *ck;
- DBusError error;
- char match[1024];
-
- ck = calloc(1, sizeof(*ck));
- if (!ck)
- return NULL;
-
- dbus_error_init(&error);
- ck->connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
- if (ck->connection == NULL || dbus_error_is_set(&error)) {
- if (dbus_error_is_set(&error)) {
- syslog(LOG_ERR, "Unable to connect to system bus: %s",
- error.message);
- dbus_error_free(&error);
- } else
- syslog(LOG_ERR, "Unable to connect to system bus");
- free(ck);
- return NULL;
- }
-
- if (!dbus_connection_get_unix_fd(ck->connection, &ck->fd)) {
- syslog(LOG_ERR, "Unable to get connection fd");
- session_info_destroy(ck);
- return NULL;
- }
-
- if (!console_kit_get_first_seat(ck)) {
- session_info_destroy(ck);
- return NULL;
- }
-
- /* Register for active session changes */
- snprintf(match, sizeof(match),
- "type='signal',interface='org.freedesktop.ConsoleKit.Seat',"
- "path='%s',member='ActiveSessionChanged'", ck->seat);
- dbus_error_init(&error);
- dbus_bus_add_match(ck->connection, match, &error);
- if (dbus_error_is_set(&error)) {
- syslog(LOG_ERR, "Match Error (%s)", error.message);
- session_info_destroy(ck);
- return NULL;
- }
-
- return ck;
-}
-
-void session_info_destroy(struct session_info *ck)
-{
- if (!ck)
- return;
-
- dbus_connection_close(ck->connection);
- free(ck->seat);
- free(ck->active_session);
- free(ck);
-}
-
-int session_info_get_fd(struct session_info *ck)
-{
- return ck->fd;
-}
-
-static char *console_kit_get_first_seat(struct session_info *ck)
-{
- DBusError error;
- DBusMessage *message = NULL;
- DBusMessage *reply = NULL;
- DBusMessageIter iter, subiter;
- int type;
- char *seat = NULL;
-
- message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
- "/org/freedesktop/ConsoleKit/Manager",
- "org.freedesktop.ConsoleKit.Manager",
- "GetSeats");
- if (message == NULL) {
- syslog(LOG_ERR, "Unable to create dbus message");
- goto exit;
- }
-
- dbus_error_init(&error);
- reply = dbus_connection_send_with_reply_and_block(ck->connection,
- message,
- -1,
- &error);
- if (reply == NULL || dbus_error_is_set(&error)) {
- if (dbus_error_is_set(&error)) {
- syslog(LOG_ERR, "GetSeats failed: %s", error.message);
- dbus_error_free(&error);
- } else
- syslog(LOG_ERR, "GetSeats failed");
- goto exit;
- }
-
- dbus_message_iter_init(reply, &iter);
- type = dbus_message_iter_get_arg_type(&iter);
- if (type != DBUS_TYPE_ARRAY) {
- syslog(LOG_ERR,
- "expected an array return value, got a '%c' instead", type);
- goto exit;
- }
-
- dbus_message_iter_recurse(&iter, &subiter);
- type = dbus_message_iter_get_arg_type(&subiter);
- if (type != DBUS_TYPE_OBJECT_PATH) {
- syslog(LOG_ERR,
- "expected an object path element, got a '%c' instead", type);
- goto exit;
- }
-
- dbus_message_iter_get_basic(&subiter, &seat);
- ck->seat = strdup(seat);
-
-exit:
- if (reply != NULL) {
- dbus_message_unref(reply);
- }
-
- if (message != NULL) {
- dbus_message_unref(message);
- }
-
- return ck->seat;
-}
-
-const char *session_info_get_active_session(struct session_info *ck)
-{
- DBusError error;
- DBusMessage *message = NULL;
- DBusMessage *reply = NULL;
- char *session = NULL;
-
- if (!ck)
- return NULL;
-
- if (ck->active_session)
- return console_kit_check_active_session_change(ck);
-
- message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
- ck->seat,
- "org.freedesktop.ConsoleKit.Seat",
- "GetActiveSession");
- if (message == NULL) {
- syslog(LOG_ERR, "Unable to create dbus message");
- goto exit;
- }
-
- dbus_error_init(&error);
- reply = dbus_connection_send_with_reply_and_block(ck->connection,
- message,
- -1,
- &error);
- if (reply == NULL || dbus_error_is_set(&error)) {
- if (dbus_error_is_set(&error)) {
- syslog(LOG_ERR, "GetActiveSession failed: %s", error.message);
- dbus_error_free(&error);
- } else
- syslog(LOG_ERR, "GetActiveSession failed");
- goto exit;
- }
-
- dbus_error_init(&error);
- if (!dbus_message_get_args(reply,
- &error,
- DBUS_TYPE_OBJECT_PATH, &session,
- DBUS_TYPE_INVALID)) {
- if (dbus_error_is_set(&error)) {
- syslog(LOG_ERR, "error get ssid from reply: %s", error.message);
- dbus_error_free(&error);
- } else
- syslog(LOG_ERR, "error getting ssid from reply");
- session = NULL;
- goto exit;
- }
-
- ck->active_session = strdup(session);
-
-exit:
- if (reply != NULL) {
- dbus_message_unref(reply);
- }
-
- if (message != NULL) {
- dbus_message_unref(message);
- }
-
- /* In case the session was changed while we were running */
- return console_kit_check_active_session_change(ck);
-}
-
-char *session_info_session_for_pid(struct session_info *ck, uint32_t pid)
-{
- DBusError error;
- DBusMessage *message = NULL;
- DBusMessage *reply = NULL;
- DBusMessageIter args;
- char *ssid = NULL;
-
- if (!ck)
- return NULL;
-
- message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
- "/org/freedesktop/ConsoleKit/Manager",
- "org.freedesktop.ConsoleKit.Manager",
- "GetSessionForUnixProcess");
- if (message == NULL) {
- syslog(LOG_ERR, "Unable to create dbus message");
- goto exit;
- }
-
- dbus_message_iter_init_append(message, &args);
- if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT32, &pid)) {
- syslog(LOG_ERR, "Unable to append dbus message args");
- goto exit;
- }
-
- dbus_error_init(&error);
- reply = dbus_connection_send_with_reply_and_block(ck->connection,
- message,
- -1,
- &error);
- if (reply == NULL || dbus_error_is_set(&error)) {
- if (dbus_error_is_set(&error)) {
- syslog(LOG_ERR, "GetSessionForUnixProcess failed: %s",
- error.message);
- dbus_error_free(&error);
- } else
- syslog(LOG_ERR, "GetSessionForUnixProces failed");
- goto exit;
- }
-
- dbus_error_init(&error);
- if (!dbus_message_get_args(reply,
- &error,
- DBUS_TYPE_OBJECT_PATH, &ssid,
- DBUS_TYPE_INVALID)) {
- if (dbus_error_is_set(&error)) {
- syslog(LOG_ERR, "error get ssid from reply: %s", error.message);
- dbus_error_free(&error);
- } else
- syslog(LOG_ERR, "error getting ssid from reply");
- ssid = NULL;
- goto exit;
- }
-
- ssid = strdup(ssid);
-
-exit:
- if (reply != NULL) {
- dbus_message_unref(reply);
- }
-
- if (message != NULL) {
- dbus_message_unref(message);
- }
-
- return ssid;
-}
-
-static char *console_kit_check_active_session_change(struct session_info *ck)
-{
- DBusMessage *message = NULL;
- DBusMessageIter iter;
- char *session;
- int type;
-
- /* non blocking read of the next available message */
- dbus_connection_read_write(ck->connection, 0);
- while ((message = dbus_connection_pop_message(ck->connection))) {
- if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL) {
- const char *member = dbus_message_get_member (message);
- if (!strcmp(member, "NameAcquired")) {
- dbus_message_unref(message);
- continue;
- }
- if (strcmp(member, "ActiveSessionChanged")) {
- syslog(LOG_ERR, "unexpected signal member: %s", member);
- dbus_message_unref(message);
- continue;
- }
- } else {
- syslog(LOG_ERR, "received non signal message!");
- dbus_message_unref(message);
- continue;
- }
-
- free(ck->active_session);
- ck->active_session = NULL;
-
- dbus_message_iter_init(message, &iter);
- type = dbus_message_iter_get_arg_type(&iter);
- /* Session should be an object path, but there is a bug in
- ConsoleKit where it sends a string rather then an object_path
- accept object_path too in case the bug ever gets fixed */
- if (type != DBUS_TYPE_STRING && type != DBUS_TYPE_OBJECT_PATH) {
- syslog(LOG_ERR,
- "ActiveSessionChanged message has unexpected type: '%c'",
- type);
- dbus_message_unref(message);
- continue;
- }
-
- dbus_message_iter_get_basic(&iter, &session);
- ck->active_session = strdup(session);
- dbus_message_unref(message);
-
- /* non blocking read of the next available message */
- dbus_connection_read_write(ck->connection, 0);
- }
-
- return ck->active_session;
-}
diff --git a/src/session-info.h b/src/session-info.h
index c4f8187..dab2241 100644
--- a/src/session-info.h
+++ b/src/session-info.h
@@ -1,4 +1,4 @@
-/* console-kit.h vdagentd ConsoleKit integration code - header
+/* session-info.h vdagentd integration code - header
Copyright 2010-2012 Red Hat, Inc.
diff --git a/src/vdagentd.c b/src/vdagentd.c
index 69332ff..ce366aa 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -782,9 +782,6 @@ static void usage(FILE *fp)
" -f treat uinput device as fake; no ioctls\n"
" -x don't daemonize\n"
" -o Only handle one virtio serial session.\n"
-#ifdef HAVE_CONSOLE_KIT
- " -X Disable console kit integration\n"
-#endif
#ifdef HAVE_LIBSYSTEMD_LOGIN
" -X Disable systemd-logind integration\n"
#endif
--
2.5.5
More information about the Spice-devel
mailing list