167 lines
4.2 KiB
Diff
167 lines
4.2 KiB
Diff
diff -up xinit-1.0.7/xinit.c.poke-ck xinit-1.0.7/xinit.c
|
|
--- xinit-1.0.7/xinit.c.poke-ck 2007-09-24 13:48:04.000000000 -0400
|
|
+++ xinit-1.0.7/xinit.c 2007-09-24 13:53:55.000000000 -0400
|
|
@@ -1,3 +1,4 @@
|
|
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
/* $Xorg: xinit.c,v 1.5 2001/02/09 02:05:49 xorgcvs Exp $ */
|
|
/* $XdotOrg: $ */
|
|
|
|
@@ -39,6 +40,13 @@ in this Software without prior written a
|
|
#include <ctype.h>
|
|
#include <stdint.h>
|
|
|
|
+#define USE_CONKIT
|
|
+#ifdef USE_CONKIT
|
|
+#include <ck-connector.h>
|
|
+#include <X11/Xatom.h>
|
|
+static CkConnector *ckc = NULL;
|
|
+#endif /* USE_CONKIT */
|
|
+
|
|
#ifdef X_POSIX_C_SOURCE
|
|
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
|
|
#include <signal.h>
|
|
@@ -521,6 +529,39 @@ processTimeout(int timeout, char *string
|
|
return( serverpid != pidfound );
|
|
}
|
|
|
|
+
|
|
+#ifdef USE_CONKIT
|
|
+static void
|
|
+register_new_session_with_console_kit (void)
|
|
+{
|
|
+ static char conkitbuf[256];
|
|
+ DBusError error;
|
|
+
|
|
+ ckc = ck_connector_new ();
|
|
+ if (ckc == NULL) {
|
|
+ Error ("Cannot register with ConsoleKit: OOM creating CkConnector\n");
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ dbus_error_init (&error);
|
|
+ if (!ck_connector_open_session (ckc, &error)) {
|
|
+ Error ("Cannot register with ConsoleKit: %s: %s\n", error.name, error.message);
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ /* If we managed to register with ConsoleKit, put the
|
|
+ * environment variable XDG_SESSION_COOKIE=cookie as second
|
|
+ * element in newenviron. See set_environment() where we
|
|
+ * earlier have made sure there is room...
|
|
+ */
|
|
+ conkitbuf[sizeof (conkitbuf) - 1] = '\0';
|
|
+ snprintf (conkitbuf, sizeof (conkitbuf) - 1, "XDG_SESSION_COOKIE=%s", ck_connector_get_cookie (ckc));
|
|
+ newenviron[1] = conkitbuf;
|
|
+out:
|
|
+ ;
|
|
+}
|
|
+#endif /* USE_CONKIT */
|
|
+
|
|
static int
|
|
startServer(char *server[])
|
|
{
|
|
@@ -631,6 +672,12 @@ startServer(char *server[])
|
|
break;
|
|
}
|
|
|
|
+#ifdef USE_CONKIT
|
|
+ if (serverpid != -1 ) {
|
|
+ register_new_session_with_console_kit ();
|
|
+ }
|
|
+#endif /* USE_CONKIT */
|
|
+
|
|
return(serverpid);
|
|
}
|
|
|
|
@@ -785,6 +832,13 @@ shutdown(void)
|
|
clientpid);
|
|
}
|
|
|
|
+#ifdef USE_CONKIT
|
|
+ if (ckc != NULL) {
|
|
+ ck_connector_unref (ckc);
|
|
+ ckc = NULL;
|
|
+ }
|
|
+#endif
|
|
+
|
|
if (serverpid < 0)
|
|
return;
|
|
errno = 0;
|
|
@@ -821,6 +875,13 @@ shutdown(void)
|
|
* make a new copy of environment that has room for DISPLAY
|
|
*/
|
|
|
|
+
|
|
+#ifdef USE_CONKIT
|
|
+#define NUM_EXTRA_ENV_VARS 3
|
|
+#else
|
|
+#define NUM_EXTRA_ENV_VARS 2
|
|
+#endif
|
|
+
|
|
static void
|
|
set_environment(void)
|
|
{
|
|
@@ -832,11 +893,11 @@ set_environment(void)
|
|
for (oldPtr = environ; *oldPtr; oldPtr++) ;
|
|
|
|
nenvvars = (oldPtr - environ);
|
|
- newenviron = (char **) malloc ((nenvvars + 3) * sizeof(char **));
|
|
+ newenviron = (char **) malloc ((nenvvars + NUM_EXTRA_ENV_VARS) * sizeof(char **));
|
|
if (!newenviron) {
|
|
fprintf (stderr,
|
|
"%s: unable to allocate %d pointers for environment\n",
|
|
- program, nenvvars + 3);
|
|
+ program, nenvvars + NUM_EXTRA_ENV_VARS);
|
|
exit (1);
|
|
}
|
|
|
|
@@ -846,10 +907,19 @@ set_environment(void)
|
|
newPtr = newenviron;
|
|
*newPtr++ = displaybuf;
|
|
|
|
+#ifdef USE_CONKIT
|
|
+ *newPtr++ = "XDG_SESSION_COOKIE=";
|
|
+#endif
|
|
+
|
|
/* copy pointers to other variables */
|
|
for (oldPtr = environ; *oldPtr; oldPtr++) {
|
|
if (strncmp (*oldPtr, "DISPLAY=", 8) != 0
|
|
- && strncmp (*oldPtr, "WINDOWPATH=", 11) != 0) {
|
|
+ && strncmp (*oldPtr, "WINDOWPATH=", 11) != 0
|
|
+#ifdef USE_CONKIT
|
|
+ && strncmp (*oldPtr, "XDG_SESSION_COOKIE=", 19) != 0
|
|
+#endif
|
|
+ )
|
|
+ {
|
|
*newPtr++ = *oldPtr;
|
|
}
|
|
}
|
|
diff -up xinit-1.0.7/configure.ac.poke-ck xinit-1.0.7/configure.ac
|
|
--- xinit-1.0.7/configure.ac.poke-ck 2007-09-17 06:46:38.000000000 -0400
|
|
+++ xinit-1.0.7/configure.ac 2007-09-24 13:48:04.000000000 -0400
|
|
@@ -92,7 +92,7 @@ AC_ARG_WITH(xinit,
|
|
[XINIT="$DEFAULT_XINIT"])
|
|
|
|
# Checks for pkg-config packages
|
|
-PKG_CHECK_MODULES(XINIT, x11)
|
|
+PKG_CHECK_MODULES(XINIT, x11 ck-connector)
|
|
|
|
case $host_os in
|
|
*bsd*)
|
|
diff -up xinit-1.0.7/startx.cpp.poke-ck xinit-1.0.7/startx.cpp
|
|
--- xinit-1.0.7/startx.cpp.poke-ck 2007-09-16 17:24:48.000000000 -0400
|
|
+++ xinit-1.0.7/startx.cpp 2007-09-24 13:48:04.000000000 -0400
|
|
@@ -223,6 +223,12 @@ EOF
|
|
fi
|
|
done
|
|
|
|
+if [ x"$display" != x ]; then
|
|
+ export DISPLAY=$display
|
|
+else
|
|
+ export DISPLAY=:0
|
|
+fi
|
|
+
|
|
#if defined(__SCO__) || defined(__UNIXWARE__)
|
|
if [ "$REMOTE_SERVER" = "TRUE" ]; then
|
|
exec SHELL_CMD ${client}
|