Hi,

Background for others: olpc3 is a bit broken because HAL doesn't let
sugar do anything like mount USB drives, reboot/shutdown, etc. This is
because HAL is not able to determine if sugar is the "active" user of
the machine.
sugar (well, olpc-dm) needs to register itself with ConsoleKit so that
HAL/PolicyKit can know whether sugar is active or inactive (in our case
- a single user system - it will always be active). There is a
complication here, olpc-dm does not work like a "normal" desktop manager
because it simply does stuff then runs startx. Normal DMs run under the
X environment so know their X display address etc.

Here's my work on getting olpc-dm registered with ConsoleKit. It
registers a connector and a session, but since it does not know the X
display device or server address, ConsoleKit is not able to detect
whether the session is active or not. It is basically missing some
parameters to ck_connector_open_session_with_parameters(). It should
also tear down the CK session when sugar exits.

Here are some useful resources if you want to take this further:
http://svn.gnome.org/viewvc/gdm/trunk/daemon/gdm-session-direct.c?view=markup
http://lists.pld-linux.org/mailman/pipermail/pld-cvs-commit/Week-of-Mon-20071217/179599.html

Daniel

Index: olpc-utils-0.73/Makefile.am
===================================================================
--- olpc-utils-0.73.orig/Makefile.am
+++ olpc-utils-0.73/Makefile.am
@@ -83,7 +83,8 @@ AM_CFLAGS = -Wall -W
 setolpckeys_SOURCES = setolpckeys.c
 
 olpc_dm_SOURCES = olpc-dm.c
-olpc_dm_LDFLAGS = -lpam_misc -lpam
+olpc_dm_CFLAGS = $(CK_CFLAGS)
+olpc_dm_LDFLAGS = -lpam_misc -lpam $(CK_LIBS)
 
 EXTRA_DIST = autogen.sh $(SPECFILE) cvs-import.sh
 
Index: olpc-utils-0.73/configure.ac
===================================================================
--- olpc-utils-0.73.orig/configure.ac
+++ olpc-utils-0.73/configure.ac
@@ -16,6 +16,10 @@ AC_CHECK_HEADERS([security/pam_appl.h se
 	[], AC_MSG_ERROR([Missing PAM headers])
 )
 
+PKG_CHECK_MODULES(CK, ck-connector)
+AC_SUBST(CK_CFLAGS)
+AC_SUBST(CK_LIBS)
+
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
Index: olpc-utils-0.73/olpc-dm.c
===================================================================
--- olpc-utils-0.73.orig/olpc-dm.c
+++ olpc-utils-0.73/olpc-dm.c
@@ -22,6 +22,8 @@
 
 #include <linux/major.h>
 
+#include <ck-connector.h>
+
 #define OLPC_USER        "olpc"
 
 #define TTY_MODE         0620
@@ -61,7 +63,7 @@ static inline void xstrncpy(char *dest, 
 static int childPid = 0;
 static volatile int got_sig = 0;
 
-
+static CkConnector *ckc = NULL;
 
 static void
 parent_sig_handler(int signal)
@@ -217,6 +219,24 @@ olpc_login(void)
 
   endpwent();
 
+  DBusError error;
+  int r;
+
+  ckc = ck_connector_new();
+  if (ckc == NULL) {
+    fprintf(stderr, "\nCannot create CK connector\n");
+    exit(1);
+  }
+
+  dbus_error_init(&error);
+  r = ck_connector_open_session_with_parameters(ckc, &error,
+                                                "unix-user", &pwd->pw_uid,
+                                                NULL);
+  if (!r) {
+    fprintf(stderr, "\nCannot open CK session\n");
+    exit(1);
+  }
+
   /* This requires some explanation: As root we may not be able to
      read the directory of the user if it is on an NFS mounted
      filesystem. We temporarily set our effective uid to the user-uid
@@ -319,6 +339,7 @@ olpc_login(void)
   setenv("HOME", pwd->pw_dir, 0);    /* legal to override */
   setenv("PATH", _PATH_DEFPATH, 1);
   setenv("SHELL", pwd->pw_shell, 1);
+  setenv("XDG_SESSION_COOKIE", ck_connector_get_cookie(ckc), 1);
 
   /* LOGNAME is not documented in login(1) but
      HP-UX 6.5 does it. We'll not allow modifying it.
_______________________________________________
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel

Reply via email to