diff -Nur kdebase-workspace-4.0.98/cmake/modules/FindCkConnector.cmake kdebase-workspace-4.0.98-consolekit-kdm/cmake/modules/FindCkConnector.cmake
--- kdebase-workspace-4.0.98/cmake/modules/FindCkConnector.cmake 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-workspace-4.0.98-consolekit-kdm/cmake/modules/FindCkConnector.cmake 2008-07-15 03:31:04.000000000 +0200
@@ -0,0 +1,58 @@
+# - Try to find the ConsoleKit connector library (libck-connector)
+# Once done this will define
+#
+# CKCONNECTOR_FOUND - system has the CK Connector
+# CKCONNECTOR_INCLUDE_DIR - the CK Connector include directory
+# CKCONNECTOR_LIBRARIES - The libraries needed to use CK Connector
+
+# Copyright (c) 2008, Kevin Kofler, <kevin.kofler@chello.at>
+# modeled after FindLibArt.cmake:
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+if (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)
+
+ # in cache already
+ SET(CKCONNECTOR_FOUND TRUE)
+
+else (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)
+
+ IF (NOT WIN32)
+ INCLUDE(UsePkgConfig)
+ # use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ PKGCONFIG(ck-connector _ckConnectorIncDir _ckConnectorLinkDir _ckConnectorLinkFlags _ckConnectorCflags)
+ ENDIF (NOT WIN32)
+
+ FIND_PATH(CKCONNECTOR_INCLUDE_DIR ck-connector.h
+ ${_ckConnectorIncDir}/ConsoleKit/ck-connector
+ ${_ckConnectorIncDir}
+ )
+
+ FIND_LIBRARY(CKCONNECTOR_LIBRARIES NAMES ck-connector
+ PATHS
+ ${_ckConnectorLinkDir}
+ )
+
+
+ if (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)
+ set(CKCONNECTOR_FOUND TRUE)
+ endif (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)
+
+
+ if (CKCONNECTOR_FOUND)
+ if (NOT CkConnector_FIND_QUIETLY)
+ message(STATUS "Found ck-connector: ${CKCONNECTOR_LIBRARIES}")
+ endif (NOT CkConnector_FIND_QUIETLY)
+ else (CKCONNECTOR_FOUND)
+ if (CkConnector_FIND_REQUIRED)
+ message(FATAL_ERROR "Could NOT find ck-connector")
+ endif (CkConnector_FIND_REQUIRED)
+ endif (CKCONNECTOR_FOUND)
+
+ MARK_AS_ADVANCED(CKCONNECTOR_INCLUDE_DIR CKCONNECTOR_LIBRARIES)
+
+endif (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)
diff -Nur kdebase-workspace-4.0.98/cmake/modules/FindDBus.cmake kdebase-workspace-4.0.98-consolekit-kdm/cmake/modules/FindDBus.cmake
--- kdebase-workspace-4.0.98/cmake/modules/FindDBus.cmake 1970-01-01 01:00:00.000000000 +0100
+++ kdebase-workspace-4.0.98-consolekit-kdm/cmake/modules/FindDBus.cmake 2008-07-14 23:56:36.000000000 +0200
@@ -0,0 +1,39 @@
+
+if(DBUS_INCLUDE_DIR AND DBUS_LIBRARY AND DBUS_ARCH_INCLUDE_DIR)
+ # Already in cache, be silent
+ set(DBUS_FIND_QUIETLY TRUE)
+endif(DBUS_INCLUDE_DIR AND DBUS_LIBRARY AND DBUS_ARCH_INCLUDE_DIR)
+
+set(DBUS_LIBRARY)
+set(DBUS_INCLUDE_DIR)
+set(DBUS_ARCH_INCLUDE_DIR)
+
+FIND_PATH(DBUS_INCLUDE_DIR dbus/dbus.h
+ /usr/include
+ /usr/include/dbus-1.0
+ /usr/local/include
+)
+
+FIND_PATH(DBUS_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h
+ /usr/lib${LIB_SUFFIX}/include
+ /usr/lib${LIB_SUFFIX}/dbus-1.0/include
+ /usr/lib64/include
+ /usr/lib64/dbus-1.0/include
+ /usr/lib/include
+ /usr/lib/dbus-1.0/include
+)
+
+FIND_LIBRARY(DBUS_LIBRARY NAMES dbus-1 dbus
+ PATHS
+ /usr/lib
+ /usr/local/lib
+)
+
+if(DBUS_INCLUDE_DIR AND DBUS_LIBRARY AND DBUS_ARCH_INCLUDE_DIR)
+ MESSAGE( STATUS "dbus found: includes in ${DBUS_INCLUDE_DIR}, library in ${DBUS_LIBRARY}")
+ set(DBUS_FOUND TRUE)
+else(DBUS_INCLUDE_DIR AND DBUS_LIBRARY AND DBUS_ARCH_INCLUDE_DIR)
+ MESSAGE( STATUS "dbus not found")
+endif(DBUS_INCLUDE_DIR AND DBUS_LIBRARY AND DBUS_ARCH_INCLUDE_DIR)
+
+MARK_AS_ADVANCED(DBUS_INCLUDE_DIR DBUS_LIBRARY DBUS_ARCH_INCLUDE_DIR)
diff -Nur kdebase-workspace-4.0.98/kdm/backend/client.c kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/client.c
--- kdebase-workspace-4.0.98/kdm/backend/client.c 2008-05-07 11:05:26.000000000 +0200
+++ kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/client.c 2008-07-14 23:48:35.000000000 +0200
@@ -1180,7 +1180,11 @@
*/
int
+#ifdef HAVE_CKCONNECTOR
+startClient( volatile int *pid, const char *ck_session_cookie )
+#else
startClient( volatile int *pid )
+#endif
{
const char *home, *sessargs, *desksess;
char **env, *xma;
@@ -1269,6 +1273,11 @@
if (krbtkfile[0] != '\0')
env = setEnv( env, "KRBTKFILE", krbtkfile );
#endif
+#ifdef HAVE_CKCONNECTOR
+ if (ck_session_cookie != NULL) {
+ env = setEnv ( env, "XDG_SESSION_COOKIE", ck_session_cookie );
+ }
+#endif
userEnviron = inheritEnv( env, envvars );
env = systemEnv( 0, curuser );
systemEnviron = setEnv( env, "HOME", p->pw_dir );
diff -Nur kdebase-workspace-4.0.98/kdm/backend/CMakeLists.txt kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/CMakeLists.txt
--- kdebase-workspace-4.0.98/kdm/backend/CMakeLists.txt 2008-05-29 13:19:01.000000000 +0200
+++ kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/CMakeLists.txt 2008-07-15 00:32:29.000000000 +0200
@@ -60,6 +60,10 @@
${SOCKET_LIBRARIES}
${RESOLV_LIBRARIES}
)
+if (CKCONNECTOR_FOUND)
+ include_directories(${CKCONNECTOR_INCLUDE_DIR} ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
+ target_link_libraries( kdm ${CKCONNECTOR_LIBRARIES} ${DBUS_LIBRARY} )
+endif (CKCONNECTOR_FOUND)
if(UTIL_LIBRARIES)
target_link_libraries( kdm ${UTIL_LIBRARIES} )
endif(UTIL_LIBRARIES)
diff -Nur kdebase-workspace-4.0.98/kdm/backend/dm.h kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/dm.h
--- kdebase-workspace-4.0.98/kdm/backend/dm.h 2008-01-05 00:55:44.000000000 +0100
+++ kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/dm.h 2008-07-14 23:48:35.000000000 +0200
@@ -504,7 +504,11 @@
#define GCONV_BINARY 5
typedef char *(*GConvFunc)( int what, const char *prompt );
int verify( GConvFunc gconv, int rootok );
+#ifdef HAVE_CKCONNECTOR
+int startClient( volatile int *pid, const char *ck_session_cookie );
+#else
int startClient( volatile int *pid );
+#endif
void clientExited( void );
void sessionExit( int status ) ATTR_NORETURN;
int readDmrc( void );
diff -Nur kdebase-workspace-4.0.98/kdm/backend/session.c kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/session.c
--- kdebase-workspace-4.0.98/kdm/backend/session.c 2008-01-05 00:55:44.000000000 +0100
+++ kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/session.c 2008-07-16 15:26:40.000000000 +0200
@@ -45,6 +45,14 @@
#include <ctype.h>
#include <signal.h>
+#ifdef HAVE_CKCONNECTOR
+#include <ck-connector.h>
+#include <dbus/dbus.h>
+/* for getpwnam */
+#include <sys/types.h>
+#include <pwd.h>
+#endif
+
struct display *td;
const char *td_setup = "auto";
@@ -553,6 +561,19 @@
volatile time_t tdiff = 0;
sigset_t ss;
+#ifdef HAVE_CKCONNECTOR
+ DBusError error;
+ CkConnector *connector;
+ char *ck_session_cookie;
+ struct passwd *pwent;
+ char devicebuf[20] = "";
+ char *device = devicebuf;
+ dbus_bool_t is_local;
+#ifdef XDMCP
+ char *remote_host_name = "";
+#endif
+#endif
+
td = d;
debug( "manageSession %s\n", d->name );
if ((ex = Setjmp( abortSession ))) {
@@ -628,7 +649,57 @@
if (td_setup)
setupDisplay( td_setup );
+#ifdef HAVE_CKCONNECTOR
+#ifdef HAVE_VTS
+ if (d->serverVT > 0) {
+ /* FIXME: how does xorg construct this */
+ sprintf(device, "/dev/tty%d", d->serverVT);
+ }
+#endif
+
+ pwent = getpwnam(curuser);
+ if (pwent == NULL) {
+ debug ("NULL user\n");
+ ck_session_cookie = NULL;
+ } else {
+ connector = ck_connector_new ();
+ if (connector != NULL) {
+ is_local = ((d->displayType & d_location) == dLocal);
+#ifdef XDMCP
+ if (!is_local && d->remoteHost)
+ remote_host_name = d->remoteHost;
+#endif
+
+ dbus_error_init (&error);
+ if ( !(ck_connector_open_session_with_parameters (connector,
+ &error, "unix-user", &(pwent->pw_uid),
+ "x11-display-device", &device,
+ "x11-display", &(d->name),
+ "is-local", &is_local,
+#ifdef XDMCP
+ "remote-host-name", &remote_host_name,
+#endif
+ NULL))) {
+ if (dbus_error_is_set (&error)) {
+ logError( "ConsoleKit open: %s\n", error.message);
+ dbus_error_free (&error);
+ } else {
+ logError("cannot open CK session: OOM, D-Bus system bus not available,\n"
+ "ConsoleKit not available or insufficient privileges.\n");
+ }
+ ck_connector_unref (connector);
+ sessionExit( EX_NORMAL );
+ }
+ } else {
+ debug ("OOM creating CkConnector\n");
+ sessionExit( EX_NORMAL );
+ }
+ ck_session_cookie = ck_connector_get_cookie (connector);
+ }
+ if (!startClient( &clientPid, ck_session_cookie )) {
+#else
if (!startClient( &clientPid )) {
+#endif
logError( "Client start failed\n" );
sessionExit( EX_NORMAL ); /* XXX maybe EX_REMANAGE_DPY? -- enable in dm.c! */
}
@@ -650,6 +721,23 @@
catchTerm( SIGTERM );
}
}
+
+/* close consolekit session */
+#ifdef HAVE_CKCONNECTOR
+ if (ck_session_cookie != NULL) {
+ dbus_error_init (&error);
+ if (! ck_connector_close_session (connector, &error)) {
+ if (dbus_error_is_set (&error)) {
+ logError ("ConsoleKit close: %s\n", error.message);
+ dbus_error_free (&error);
+ } else {
+ logError ("Cannot close CK session: OOM, D-Bus system bus not available,\n"
+ "ConsoleKit not available or insufficient privileges.\n");
+ }
+ }
+ ck_connector_unref (connector);
+ }
+#endif
/*
* Sometimes the Xsession somehow manages to exit before
* a server crash is noticed - so we sleep a bit and wait
diff -Nur kdebase-workspace-4.0.98/kdm/backend/xdmcp.c kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/xdmcp.c
--- kdebase-workspace-4.0.98/kdm/backend/xdmcp.c 2008-01-05 00:55:44.000000000 +0100
+++ kdebase-workspace-4.0.98-consolekit-kdm/kdm/backend/xdmcp.c 2008-07-14 23:48:35.000000000 +0200
@@ -1016,6 +1016,8 @@
d->clientAddr = clientAddress;
d->clientPort = clientPort;
d->connectionType = connectionType;
+ d->remoteHost = networkAddressToHostname (pdpy->connectionType,
+ &pdpy->connectionAddress);
if (pdpy->fileAuthorization) {
d->authorizations = (Xauth **)Malloc( sizeof(Xauth *) );
if (!d->authorizations) {
diff -Nur kdebase-workspace-4.0.98/kdm/CMakeLists.txt kdebase-workspace-4.0.98-consolekit-kdm/kdm/CMakeLists.txt
--- kdebase-workspace-4.0.98/kdm/CMakeLists.txt 2008-02-07 14:19:51.000000000 +0100
+++ kdebase-workspace-4.0.98-consolekit-kdm/kdm/CMakeLists.txt 2008-07-15 00:28:16.000000000 +0200
@@ -4,6 +4,17 @@
install_pam_service(KDM)
include(ConfigureChecks.cmake)
+
+macro_optional_find_package(CkConnector)
+if(CKCONNECTOR_FOUND)
+ # when building with libck-connector, we also need the low-level D-Bus API
+ find_package(DBus REQUIRED)
+endif(CKCONNECTOR_FOUND)
+
+macro_log_feature(CKCONNECTOR_FOUND "ck-connector" "The ConsoleKit connector library" "http://freedesktop.org/wiki/Software/ConsoleKit" FALSE "" "Provides ConsoleKit integration in KDM")
+
+macro_bool_to_01(CKCONNECTOR_FOUND HAVE_CKCONNECTOR)
+
configure_file(config-kdm.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdm.h)
install( FILES README DESTINATION ${DATA_INSTALL_DIR}/doc/kdm )
diff -Nur kdebase-workspace-4.0.98/kdm/config-kdm.h.cmake kdebase-workspace-4.0.98-consolekit-kdm/kdm/config-kdm.h.cmake
--- kdebase-workspace-4.0.98/kdm/config-kdm.h.cmake 2008-01-05 00:55:45.000000000 +0100
+++ kdebase-workspace-4.0.98-consolekit-kdm/kdm/config-kdm.h.cmake 2008-07-14 23:48:35.000000000 +0200
@@ -123,6 +123,9 @@
/* Define to 1 if you have the <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H 1
+/* Define to 1 if the ck-connector library is found */
+#cmakedefine HAVE_CKCONNECTOR 1
+
/* $PATH defaults set by KDM */
#cmakedefine KDM_DEF_USER_PATH "${KDM_DEF_USER_PATH}"
#cmakedefine KDM_DEF_SYSTEM_PATH "${KDM_DEF_SYSTEM_PATH}"