Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > d804a9b0137b80183e28b2be3a5e1fd5 > files > 3

xdm-1.1.8-2mdv2009.0.src.rpm

From 314ef7342d4f3607b6c0ecfe69bbfd45c45668e9 Mon Sep 17 00:00:00 2001
From: Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>
Date: Mon, 21 Jan 2008 16:56:22 -0200
Subject: [PATCH]   Ass console-kit support to xdm.

---
 Makefile.am  |    5 +++++
 configure.ac |   18 ++++++++++++++++++
 session.c    |   38 +++++++++++++++++++++++++++++++++++---
 3 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index fe5f18e..37e7dba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,6 +79,11 @@ if HAS_KERBEROS_FIVE
 xdm_SOURCES += krb5auth.c
 endif
 
+if WITH_CONSOLE_KIT
+xdm_SOURCES += consolekit.c consolekit.h
+xdm_CFLAGS += -DWITH_CONSOLE_KIT $(DBUS_CFLAGS)
+endif
+
 #
 # greeter
 #
diff --git a/configure.ac b/configure.ac
index a6f8ad3..00d8802 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,6 +117,24 @@ if test "x$USE_PAM" != "xno" ; then
 		 fi])
 fi
 
+AC_ARG_WITH(consolekit, AC_HELP_STRING([--with-consolekit],[Use ConsoleKit]),
+	[USE_CONSOLE_KIT=$withval], [USE_CONSOLE_KIT=try])
+if test "x$USE_CONSOLE_KIT" != "xno" ; then
+	AC_SEARCH_LIBS(dbus_message_new_method_call,[dbus-1])
+	AC_CHECK_FUNC(dbus_message_new_method_call,
+		      [WITH_CONSOLE_KIT=1],
+		      [if test "x$USE_CONSOLE_KIT" != "xtry" ; then
+			 AC_MSG_ERROR([ConsoleKit support requested, but dbus_message_new_method_call not found.])
+			 fi])
+fi
+AM_CONDITIONAL(WITH_CONSOLE_KIT, test x$USE_CONSOLE_KIT = xyes)
+if test "x$USE_CONSOLE_KIT" = "xyes"; then
+    DBUS_CFLAGS=$(pkg-config --cflags dbus-1)
+else
+    DBUS_CFLAGS=#
+fi
+AC_SUBST(DBUS_CFLAGS)
+
 # FIXME: Find better test for which OS'es use su -m  - for now, just try to
 # mirror the Imakefile setting of:
 # if  defined(OpenBSDArchitecture) || defined(NetBSDArchitecture) || defined(FreeBSDArchitecture) || defined(DarwinArchitecture)
diff --git a/session.c b/session.c
index 195c26f..1604700 100644
--- a/session.c
+++ b/session.c
@@ -173,7 +173,11 @@ static Bool StartClient(
     struct display	*d,
     pid_t		*pidp,
     char		*name,
-    char		*passwd);
+    char		*passwd
+#ifdef WITH_CONSOLE_KIT
+    ,char		*ck_session_cookie
+#endif
+			);
 
 static pid_t			clientPid;
 static struct greet_info	greet;
@@ -288,6 +292,9 @@ ManageSession (struct display *d)
 #ifndef GREET_USER_STATIC
     void		*greet_lib_handle;
 #endif
+#ifdef WITH_CONSOLE_KIT
+    char *ck_session_cookie = NULL;
+#endif
 
     Debug ("ManageSession %s\n", d->name);
     (void)XSetIOErrorHandler(IOErrorHandler);
@@ -330,7 +337,14 @@ ManageSession (struct display *d)
 	     * Start the clients, changing uid/groups
 	     *	   setting up environment and running the session
 	     */
-	    if (StartClient (&verify, d, &clientPid, greet.name, greet.password)) {
+#ifdef WITH_CONSOLE_KIT
+	    ck_session_cookie = open_ck_session (getpwnam(greet.name), d);
+#endif
+	    if (StartClient (&verify, d, &clientPid, greet.name, greet.password
+#ifdef WITH_CONSOLE_KIT
+			     ,ck_session_cookie
+#endif
+			     )) {
 		Debug ("Client Started\n");
 
 #ifndef GREET_USER_STATIC
@@ -370,6 +384,14 @@ ManageSession (struct display *d)
 	    AbortClient (clientPid);
 	}
     }
+
+#ifdef WITH_CONSOLE_KIT
+    if (ck_session_cookie != NULL) {
+	close_ck_session (ck_session_cookie);
+	free (ck_session_cookie);
+    }
+#endif
+
     /*
      * run system-wide reset file
      */
@@ -536,7 +558,11 @@ StartClient (
     struct display	*d,
     pid_t		*pidp,
     char		*name,
-    char		*passwd)
+    char		*passwd
+#ifdef WITH_CONSOLE_KIT
+    ,char		*ck_session_cookie
+#endif
+    )
 {
     char	**f, *home;
     char	*failsafeArgv[2];
@@ -780,6 +806,12 @@ StartClient (
 	if (passwd != NULL)
 	    bzero(passwd, strlen(passwd));
 
+#ifdef WITH_CONSOLE_KIT
+	if (ck_session_cookie != NULL) {
+	    verify->userEnviron = setEnv ( verify->userEnviron, "XDG_SESSION_COOKIE", ck_session_cookie );
+	}
+#endif
+
 	SetUserAuthorization (d, verify);
 	home = getEnv (verify->userEnviron, "HOME");
 	if (home)
-- 
1.5.3.5