Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37864560
en ru br
ALT Linux repositórios
S:1.1.13-alt2
5.0: 1.1.8-alt2.M50.1
4.1: 1.1.8-alt0.M41.1
4.0: 1.1.8-alt0.M40.1

Group :: Sistema/X11
RPM: xdm

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: xdm-1.1.8-alt2.M50.1.patch
Download


 .gear/rules                                        |    2 +
 .../tags/32e7264789cd4ecd0d32d714fdd910ba9203d740  |   13 +
 .gear/tags/list                                    |    1 +
 Makefile.am                                        |    5 +
 configure.ac                                       |   24 +-
 consolekit.c                                       |  580 ++++++++++++++++++++
 consolekit.h                                       |   36 ++
 session.c                                          |   38 ++-
 xdm.pamd                                           |    8 +
 xdm.spec                                           |  182 ++++++
 10 files changed, 883 insertions(+), 6 deletions(-)
diff --git a/.gear/rules b/.gear/rules
new file mode 100644
index 0000000..f78a96e
--- /dev/null
+++ b/.gear/rules
@@ -0,0 +1,2 @@
+tar: @name@-@version@:.
+diff: @name@-@version@:. .
diff --git a/.gear/tags/32e7264789cd4ecd0d32d714fdd910ba9203d740 b/.gear/tags/32e7264789cd4ecd0d32d714fdd910ba9203d740
new file mode 100644
index 0000000..3063ddd
--- /dev/null
+++ b/.gear/tags/32e7264789cd4ecd0d32d714fdd910ba9203d740
@@ -0,0 +1,13 @@
+object c9cdec25130bc957b584ec15187e068f9c08862d
+type commit
+tag xdm-1.1.8
+tagger Adam Jackson <ajax@redhat.com> 1211394386 -0400
+
+xdm 1.1.8
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+iEYEABECAAYFAkg0aVIACgkQW4otUKDs0NM5UwCfR7EqWqQwkaqACJL0KljRwSX1
+wW8AniRoC00G7zz2Zbj4nP5e4BoRviae
+=buPf
+-----END PGP SIGNATURE-----
diff --git a/.gear/tags/list b/.gear/tags/list
new file mode 100644
index 0000000..2e699b4
--- /dev/null
+++ b/.gear/tags/list
@@ -0,0 +1 @@
+32e7264789cd4ecd0d32d714fdd910ba9203d740 xdm-1.1.8
diff --git a/Makefile.am b/Makefile.am
index 0edca97..a6472e8 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 329c8e8..cca69fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,6 +116,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)
@@ -305,7 +323,7 @@ AC_SUBST(XDM_PIXMAPDIR)
 
 # Packages used by multiple programs
 
-XAW_CHECK_XPRINT_SUPPORT(XDM_PRINT)
+PKG_CHECK_MODULES(XDM_PRINT, xaw7)
 PKG_CHECK_MODULES(DMCP, xdmcp)
 PKG_CHECK_MODULES(XLIB, x11)
 PKG_CHECK_MODULES(AUTH, xau)
@@ -456,7 +474,7 @@ if test -z "$DEF_USER_PATH" ; then
 		DEF_USER_PATH="/usr/bin:${bindir}"
 		;;
 	    *)
-		DEF_USER_PATH="/bin:/usr/bin:${bindir}:/usr/ucb"
+		DEF_USER_PATH="/bin:/usr/bin:/usr/local/bin"
 		;;
 	esac
 fi
@@ -478,7 +496,7 @@ if test -z "$DEF_SYSTEM_PATH" ; then
 		DEF_SYSTEM_PATH="/sbin:/usr/sbin:/usr/bin:${bindir}"
 		;;
 	    *)
-		DEF_SYSTEM_PATH="/etc:/bin:/usr/bin:${bindir}:/usr/ucb"
+		DEF_SYSTEM_PATH="/bin:/usr/bin:/usr/local/bin"
 		;;
 	esac
 fi
diff --git a/consolekit.c b/consolekit.c
new file mode 100644
index 0000000..c1cfb82
--- /dev/null
+++ b/consolekit.c
@@ -0,0 +1,580 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2007 Kevin Kofler <Kevin@tigcc.ticalc.org>
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "dm.h"
+#include "dm_auth.h"
+#include "dm_error.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <pwd.h>
+
+#include <sys/types.h>
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus.h>
+
+#include "consolekit.h"
+
+
+#define CK_NAME              "org.freedesktop.ConsoleKit"
+#define CK_PATH              "/org/freedesktop/ConsoleKit"
+#define CK_INTERFACE         "org.freedesktop.ConsoleKit"
+#define CK_MANAGER_PATH      "/org/freedesktop/ConsoleKit/Manager"
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
+
+static DBusConnection *private_connection = NULL;
+
+static void
+freeStrArr( char **arr )
+{
+	char **tarr;
+
+	if (arr) {
+		for (tarr = arr; *tarr; tarr++)
+			free( *tarr );
+		free( arr );
+	}
+}
+
+
+static void
+add_param_int (DBusMessageIter *iter_struct,
+	       const char      *key,
+	       int              value)
+{
+	DBusMessageIter iter_struct_entry;
+	DBusMessageIter iter_var;
+
+	dbus_message_iter_open_container (iter_struct,
+					  DBUS_TYPE_STRUCT,
+					  NULL,
+					  &iter_struct_entry);
+
+	dbus_message_iter_append_basic (&iter_struct_entry,
+					DBUS_TYPE_STRING,
+					&key);
+
+	dbus_message_iter_open_container (&iter_struct_entry,
+					  DBUS_TYPE_VARIANT,
+					  DBUS_TYPE_INT32_AS_STRING,
+					  &iter_var);
+
+	dbus_message_iter_append_basic (&iter_var,
+					DBUS_TYPE_INT32,
+					&value);
+
+	dbus_message_iter_close_container (&iter_struct_entry,
+					   &iter_var);
+
+	dbus_message_iter_close_container (iter_struct, &iter_struct_entry);
+}
+
+static void
+add_param_boolean (DBusMessageIter *iter_struct,
+		   const char      *key,
+		   int             value)
+{
+	DBusMessageIter iter_struct_entry;
+	DBusMessageIter iter_var;
+
+	dbus_message_iter_open_container (iter_struct,
+					  DBUS_TYPE_STRUCT,
+					  NULL,
+					  &iter_struct_entry);
+
+	dbus_message_iter_append_basic (&iter_struct_entry,
+					DBUS_TYPE_STRING,
+					&key);
+
+	dbus_message_iter_open_container (&iter_struct_entry,
+					  DBUS_TYPE_VARIANT,
+					  DBUS_TYPE_BOOLEAN_AS_STRING,
+					  &iter_var);
+
+	dbus_message_iter_append_basic (&iter_var,
+					DBUS_TYPE_BOOLEAN,
+					&value);
+
+	dbus_message_iter_close_container (&iter_struct_entry,
+					   &iter_var);
+
+	dbus_message_iter_close_container (iter_struct, &iter_struct_entry);
+}
+
+static void
+add_param_string (DBusMessageIter *iter_struct,
+		  const char      *key,
+		  const char      *value)
+{
+	DBusMessageIter iter_struct_entry;
+	DBusMessageIter iter_var;
+
+	dbus_message_iter_open_container (iter_struct,
+					  DBUS_TYPE_STRUCT,
+					  NULL,
+					  &iter_struct_entry);
+
+	dbus_message_iter_append_basic (&iter_struct_entry,
+					DBUS_TYPE_STRING,
+					&key);
+
+	dbus_message_iter_open_container (&iter_struct_entry,
+					  DBUS_TYPE_VARIANT,
+					  DBUS_TYPE_STRING_AS_STRING,
+					  &iter_var);
+
+	dbus_message_iter_append_basic (&iter_var,
+					DBUS_TYPE_STRING,
+					&value);
+
+	dbus_message_iter_close_container (&iter_struct_entry,
+					   &iter_var);
+
+	dbus_message_iter_close_container (iter_struct, &iter_struct_entry);
+}
+
+static int
+session_get_x11_display (DBusConnection *connection,
+			 const char     *ssid,
+			 char          **str)
+{
+	DBusError       error;
+	DBusMessage    *message;
+	DBusMessage    *reply;
+	DBusMessageIter iter;
+	const char     *value;
+
+	if (str != NULL) {
+		*str = NULL;
+	}
+
+	message = dbus_message_new_method_call (CK_NAME,
+						ssid,
+						CK_SESSION_INTERFACE,
+						"GetX11Display");
+	if (message == NULL) {
+		Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
+		return FALSE;
+	}
+
+	dbus_error_init (&error);
+	reply = dbus_connection_send_with_reply_and_block (connection,
+							   message,
+							   -1, &error);
+	if (dbus_error_is_set (&error)) {
+		Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
+		reply = NULL;
+	}
+
+	dbus_connection_flush (connection);
+	dbus_message_unref (message);
+
+	if (reply == NULL) {
+		return FALSE;
+	}
+
+	dbus_message_iter_init (reply, &iter);
+	dbus_message_iter_get_basic (&iter, &value);
+	if (str != NULL) {
+		*str = strdup (value);
+	}
+	dbus_message_unref (reply);
+
+	return TRUE;
+}
+
+static int
+session_unlock (DBusConnection *connection,
+		const char     *ssid)
+{
+	DBusError       error;
+	DBusMessage    *message;
+	DBusMessage    *reply;
+
+	Debug ("ConsoleKit: Unlocking session %s", ssid);
+	message = dbus_message_new_method_call (CK_NAME,
+						ssid,
+						CK_SESSION_INTERFACE,
+						"Unlock");
+	if (message == NULL) {
+		Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
+		return FALSE;
+	}
+
+	dbus_error_init (&error);
+	reply = dbus_connection_send_with_reply_and_block (connection,
+							   message,
+							   -1, &error);
+	dbus_message_unref (message);
+	dbus_message_unref (reply);
+	dbus_connection_flush (connection);
+
+	if (dbus_error_is_set (&error)) {
+		Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+/* from libhal */
+static char **
+get_path_array_from_iter (DBusMessageIter *iter,
+			  int             *num_elements)
+{
+	int count;
+	char **buffer;
+
+	count = 0;
+	buffer = (char **)malloc (sizeof (char *) * 8);
+
+	if (buffer == NULL)
+		goto oom;
+
+	buffer[0] = NULL;
+	while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_OBJECT_PATH) {
+		const char *value;
+		char *str;
+
+		if ((count % 8) == 0 && count != 0) {
+			buffer = realloc (buffer, sizeof (char *) * (count + 8));
+			if (buffer == NULL)
+				goto oom;
+		}
+
+		dbus_message_iter_get_basic (iter, &value);
+		str = strdup (value);
+		if (str == NULL)
+			goto oom;
+
+		buffer[count] = str;
+
+		dbus_message_iter_next (iter);
+		count++;
+	}
+
+	if ((count % 8) == 0) {
+		buffer = realloc (buffer, sizeof (char *) * (count + 1));
+		if (buffer == NULL)
+			goto oom;
+	}
+
+	buffer[count] = NULL;
+	if (num_elements != NULL)
+		*num_elements = count;
+	return buffer;
+
+oom:
+	LogError ("%s %d : error allocating memory\n", __FILE__, __LINE__);
+	return NULL;
+
+}
+
+static char **
+get_sessions_for_user (DBusConnection *connection,
+		       const char     *user,
+		       const char     *x11_display)
+{
+	DBusError       error;
+	DBusMessage    *message;
+	DBusMessage    *reply;
+	DBusMessageIter iter;
+	DBusMessageIter iter_reply;
+	DBusMessageIter iter_array;
+	struct passwd	*pwent;
+	char           **sessions;
+
+	sessions = NULL;
+	message = NULL;
+	reply = NULL;
+
+	pwent = getpwnam (user);
+
+	dbus_error_init (&error);
+	message = dbus_message_new_method_call (CK_NAME,
+						CK_MANAGER_PATH,
+						CK_MANAGER_INTERFACE,
+						"GetSessionsForUser");
+	if (message == NULL) {
+		Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
+		goto out;
+	}
+
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_append_basic (&iter,
+					DBUS_TYPE_UINT32,
+					&pwent->pw_uid);
+
+	dbus_error_init (&error);
+	reply = dbus_connection_send_with_reply_and_block (connection,
+							   message,
+							   -1, &error);
+	dbus_connection_flush (connection);
+
+	if (dbus_error_is_set (&error)) {
+		Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
+		goto out;
+	}
+
+	if (reply == NULL) {
+		Debug ("ConsoleKit: No reply for GetSessionsForUser");
+		goto out;
+	}
+
+	dbus_message_iter_init (reply, &iter_reply);
+	if (dbus_message_iter_get_arg_type (&iter_reply) != DBUS_TYPE_ARRAY) {
+		Debug ("ConsoleKit: Wrong reply for GetSessionsForUser - expecting an array.");
+		goto out;
+	}
+
+	dbus_message_iter_recurse (&iter_reply, &iter_array);
+	sessions = get_path_array_from_iter (&iter_array, NULL);
+
+ out:
+	if (message != NULL) {
+		dbus_message_unref (message);
+	}
+	if (reply != NULL) {
+		dbus_message_unref (reply);
+	}
+
+	return sessions;
+}
+
+void
+unlock_ck_session (const char *user,
+		   const char *x11_display)
+{
+	DBusError       error;
+	DBusConnection *connection;
+	char           **sessions;
+	int              i;
+
+	Debug ("ConsoleKit: Unlocking session for %s on %s", user, x11_display);
+
+	dbus_error_init (&error);
+	connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+	if (connection == NULL) {
+		Debug ("ConsoleKit: Failed to connect to the D-Bus daemon: %s", error.message);
+		dbus_error_free (&error);
+		return;
+	}
+
+	sessions = get_sessions_for_user (connection, user, x11_display);
+	if (sessions == NULL || sessions[0] == NULL) {
+		Debug ("ConsoleKit: no sessions found");
+		return;
+	}
+
+	for (i = 0; sessions[i] != NULL; i++) {
+		char *ssid;
+		char *xdisplay;
+
+		ssid = sessions[i];
+		session_get_x11_display (connection, ssid, &xdisplay);
+		Debug ("ConsoleKit: session %s has DISPLAY %s", ssid, xdisplay);
+
+		if (xdisplay != NULL
+		    && x11_display != NULL
+		    && strcmp (xdisplay, x11_display) == 0) {
+			int res;
+
+			res = session_unlock (connection, ssid);
+			if (! res) {
+				LogError ("ConsoleKit: Unable to unlock %s", ssid);
+			}
+		}
+
+		free (xdisplay);
+	}
+
+	freeStrArr (sessions);
+}
+
+char *
+open_ck_session (struct passwd *pwent,
+		 struct display *d)
+{
+	DBusConnection *connection;
+	DBusError       error;
+	DBusMessage    *message;
+	DBusMessage    *reply;
+	DBusMessageIter iter;
+	DBusMessageIter iter_struct;
+	char	       *cookie;
+
+	cookie = NULL;
+
+	Debug ("ConsoleKit: Opening session for %s", pwent->pw_name);
+
+	dbus_error_init (&error);
+	connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &error);
+	private_connection = connection;
+
+	if (connection == NULL) {
+		Debug ("ConsoleKit: Failed to connect to the D-Bus daemon: %s", error.message);
+		dbus_error_free (&error);
+		return NULL;
+	}
+
+	dbus_connection_set_exit_on_disconnect (connection, FALSE);
+	/* FIXME: What to do about these?
+	dbus_connection_set_watch_functions( connection,
+	                                     dbusAddWatch,
+	                                     dbusRemoveWatch,
+	                                     dbusToggleWatch,
+	                                     data, 0 );
+	dbus_connection_set_timeout_functions( connection,
+	                                       dbusAddTimeout,
+	                                       dbusRemoveTimeout,
+	                                       dbusToggleTimeout,
+	                                       data, 0 );
+	dbus_connection_set_wakeup_main_function( connection,
+	                                          dbusWakeupMain,
+	                                          data, 0 ); */
+
+	dbus_error_init (&error);
+	message = dbus_message_new_method_call (CK_NAME,
+						CK_MANAGER_PATH,
+						CK_MANAGER_INTERFACE,
+						"OpenSessionWithParameters");
+	if (message == NULL) {
+		Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
+		return NULL;
+	}
+
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_open_container (&iter,
+					  DBUS_TYPE_ARRAY,
+					  DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+					  DBUS_TYPE_STRING_AS_STRING
+					  DBUS_TYPE_VARIANT_AS_STRING
+					  DBUS_STRUCT_END_CHAR_AS_STRING,
+					  &iter_struct);
+
+	add_param_int (&iter_struct, "user", pwent->pw_uid);
+	add_param_string (&iter_struct, "x11-display", d->name);
+	add_param_boolean (&iter_struct, "is-local", d->displayType.location);
+#ifdef XDMCP
+	if (!(d->displayType.location) && d->name) {
+		int length;
+		char *ptr, name[256];
+
+		ptr = strchr(d->name, ':');
+		length = ptr ? ptr - d->name + 1 : sizeof(name);
+		snprintf(name, length, "%s", d->name);
+		add_param_string (&iter_struct, "remote-host-name", name);
+	}
+#endif
+
+	if (d->serverPid > 0) {
+		int tty;
+		FILE *fp;
+		char buffer[32];
+
+		sprintf(buffer, "/proc/%d/stat", d->serverPid);
+		if ((fp = fopen(buffer, "r")) != NULL) {
+		    if (fscanf(fp, "%*d %*s %*c %*d %*d %*d %d", &tty) == 1 &&
+			major(tty) == 4 && minor(tty) < 64) {
+			sprintf(buffer, "/dev/tty%d", minor(tty));
+			add_param_string (&iter_struct,
+					  "x11-display-device", buffer);
+		    }
+		    close(fp);
+		}
+	}
+
+	dbus_message_iter_close_container (&iter, &iter_struct);
+
+	reply = dbus_connection_send_with_reply_and_block (connection,
+							   message,
+							   -1, &error);
+	if (dbus_error_is_set (&error)) {
+		Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
+		reply = NULL;
+	}
+
+	dbus_connection_flush (connection);
+
+	dbus_message_unref (message);
+	dbus_error_free (&error);
+
+	if (reply != NULL) {
+		const char *value;
+
+		dbus_message_iter_init (reply, &iter);
+		dbus_message_iter_get_basic (&iter, &value);
+		cookie = strdup (value);
+		dbus_message_unref (reply);
+	}
+
+	return cookie;
+}
+
+void
+close_ck_session (const char *cookie)
+{
+	DBusError       error;
+	DBusMessage    *message;
+	DBusMessage    *reply;
+	DBusMessageIter iter;
+
+	if (cookie == NULL) {
+		return;
+	}
+
+	if (private_connection == NULL) {
+		return;
+	}
+
+	dbus_error_init (&error);
+	message = dbus_message_new_method_call (CK_NAME,
+						CK_MANAGER_PATH,
+						CK_MANAGER_INTERFACE,
+						"CloseSession");
+	if (message == NULL) {
+		Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
+		return;
+	}
+
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_append_basic (&iter,
+					DBUS_TYPE_STRING,
+					&cookie);
+
+	reply = dbus_connection_send_with_reply_and_block (private_connection,
+							   message,
+							   -1, &error);
+	if (dbus_error_is_set (&error)) {
+		Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
+		reply = NULL;
+	}
+
+	dbus_connection_flush (private_connection);
+
+	dbus_message_unref (message);
+	dbus_error_free (&error);
+
+        dbus_connection_close (private_connection);
+	private_connection = NULL;
+}
diff --git a/consolekit.h b/consolekit.h
new file mode 100644
index 0000000..f1cbddb
--- /dev/null
+++ b/consolekit.h
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2007 Kevin Kofler <Kevin@tigcc.ticalc.org>
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+#ifndef __CONSOLE_KIT_H
+#define __CONSOLE_KIT_H
+
+#include <pwd.h>
+
+struct display;
+
+char *      open_ck_session       (struct passwd *pwent,
+                                   struct display *display);
+void        close_ck_session      (const char    *cookie);
+void        unlock_ck_session     (const char    *user,
+                                   const char    *x11_display);
+
+#endif /* __CONSOLE_KIT_H */
diff --git a/session.c b/session.c
index b48a3ef..a767dd6 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)
diff --git a/xdm.pamd b/xdm.pamd
new file mode 100644
index 0000000..0f8fe16
--- /dev/null
+++ b/xdm.pamd
@@ -0,0 +1,8 @@
+#%PAM-1.0
+auth     include	system-auth
+auth     required	pam_nologin.so
+account  include	system-auth
+password include	system-auth
+session  include	system-auth
+session  required	pam_loginuid.so
+session	 optional	pam_console.so
diff --git a/xdm.spec b/xdm.spec
new file mode 100644
index 0000000..0aa4b87
--- /dev/null
+++ b/xdm.spec
@@ -0,0 +1,182 @@
+%define xorg xorg-x11
+%define xf86 XFree86
+
+%def_disable ipv6
+
+Name: xdm
+Version: 1.1.8
+Release: alt2.M50.1
+Serial: 2
+Summary: X Display Manager with support for XDMCP, host chooser
+License: MIT/X11
+Group: System/X11
+Url: http://xorg.freedesktop.org
+
+Packager: Valery Inozemtsev <shrek@altlinux.ru>
+
+Source: %name-%version.tar
+Patch: %name-%version-%release.patch
+
+Obsoletes: %xf86-%name %xorg-%name < %serial:%version-%release
+Provides: %xf86-%name = 4.4 %xorg-%name = %serial:%version-%release
+
+BuildRequires: libXau-devel libXaw-devel libXdmcp-devel libXext-devel libXft-devel libXinerama-devel
+BuildRequires: libXpm-devel libdbus-devel libpam-devel xorg-util-macros
+
+%description
+Xdm  manages a collection of X displays, which may be on the local host
+or remote servers.  The design of xdm was guided by the needs of X ter-
+minals  as well as The Open Group standard XDMCP, the X Display Manager
+Control Protocol.  Xdm provides services similar to those  provided  by
+init,  getty and login on character terminals: prompting for login name
+and password, authenticating the user, and running a ``session.''
+
+%prep
+%setup -q
+%patch -p1
+
+%build
+%autoreconf
+%configure \
+	%{subst_enable ipv6} \
+	--with-xdmlibdir=%_libdir/X11/xdm \
+	--with-xdmconfigdir=%_sysconfdir/X11/xdm \
+	--with-xdmscriptdir=%_sysconfdir/X11/xdm \
+	--with-pixmapdir=%_datadir/X11/xdm/pixmaps \
+	--with-xft \
+	--with-consolekit \
+	--disable-static
+
+%make_build
+
+%install
+%make DESTDIR=%buildroot install
+
+install -pD -m644 xdm.pamd %buildroot%_sysconfdir/pam.d/xdm
+
+# explicitly create X authdir
+mkdir -p %buildroot%_localstatedir/xdm
+ln -s -f ../../..%_localstatedir/xdm %buildroot%_sysconfdir/X11/xdm/authdir
+
+mkdir -p %buildroot%_sysconfdir/logrotate.d
+cat << EOF > %buildroot%_sysconfdir/logrotate.d/xdm
+%_logdir/xdm-error.log {
+	notifempty
+	missingok
+	nocompress
+}
+EOF
+
+%files
+%_sysconfdir/X11/app-defaults/*
+%dir %_sysconfdir/X11/xdm
+%_sysconfdir/X11/xdm/authdir
+%_sysconfdir/logrotate.d/xdm
+%_sysconfdir/pam.d/xdm
+%_bindir/*
+%dir %_libdir/X11/xdm
+%_libdir/X11/xdm/chooser
+%_libdir/X11/xdm/lib*.so
+%_datadir/X11/xdm
+%dir %attr(0700,root,root) %_localstatedir/xdm
+%_man1dir/*
+
+%changelog
+* Fri Mar 27 2009 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.8-alt2.M50.1
+- build for branch 5.0
+
+* Fri Mar 27 2009 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.8-alt3
+- pam: required pam_loginuid.so (close #19358)
+
+* Tue Nov 25 2008 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.8-alt2
+- fixed build with libXaw7
+
+* Thu May 22 2008 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.8-alt1
+- 1.1.8
+
+* Wed Apr 02 2008 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.7-alt2
+- build with ConsoleKit
+
+* Sat Mar 08 2008 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.7-alt1
+- 1.1.7
+- build without ConsoleKit
+
+* Thu Dec 13 2007 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.6-alt2
+- support ConsoleKit
+
+* Fri Aug 17 2007 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.6-alt1
+- 1.1.6
+
+* Sat Aug 11 2007 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.5-alt1
+- 1.1.5
+
+* Tue Jun 12 2007 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.4-alt4
+- added xdm-1.1.4-git-policy.c.patch: fixed race condition in policy.c:Willing()
+
+* Wed Apr 04 2007 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.4-alt3
+- added lost %_datadir/X11/xdm dir
+
+* Mon Mar 12 2007 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.4-alt2
+- fixed DEF_USER_PATH and DEF_SYSTEM_PATH (clased #11060)
+
+* Tue Feb 06 2007 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.4-alt1
+- 1.1.4:
+  + Bug #8561: xdm painfully slow at cursor redraws
+  + Make sure windowPath is properly initialized & freed
+  + Reset username prompt to default string at start of PAM loop
+  + Rearrange checks for maximum username & password length
+
+* Sat Dec 16 2006 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.3-alt1
+- 1.1.3
+- rename package %xorg-%name to %name
+
+* Thu Nov 30 2006 Valery Inozemtsev <shrek@altlinux.ru> 2:1.1.2-alt1
+- 1.1.2
+
+* Mon Oct 16 2006 Valery Inozemtsev <shrek@altlinux.ru> 2:1.0.5-alt1
+- rollback to 1.0.5 (1.1.0 problem with pam_console)
+
+* Fri Oct 13 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.1.0-alt2
+- build --with-xft
+
+* Wed Oct 04 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.1.0-alt1
+- 1.1.0
+
+* Fri Jun 30 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.4-alt2
+- added xdm-1.0.4-setuid.patch
+
+* Fri Apr 28 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.4-alt1
+- 1.0.4
+
+* Sun Apr 16 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.3-alt2
+- CVS snapchot 2006-04-14
+- fixed Provides/Obsoletes
+
+* Sat Apr 01 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.3-alt1
+- 1.0.3
+
+* Tue Mar 28 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.2-alt1
+- 1.0.2
+
+* Thu Mar 16 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.1-alt5
+- CVS snapshot 2006-03-10
+
+* Sun Mar 05 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.1-alt4
+- fixed segfault in netaddr.c:ConvertAddr if ifa_addr is NULL
+
+* Fri Jan 13 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.1-alt3
+- Rebuilt for new style PAM dependencies generated by rpm-build-4.0.4-alt55
+
+* Mon Jan 09 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.1-alt2
+- fixed BuildRequires
+- added servonly patch
+
+* Tue Dec 27 2005 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.1-alt1
+- Xorg-7.0
+
+* Mon Dec 05 2005 Valery Inozemtsev <shrek@altlinux.ru> 0.99.4-alt1
+- Xorg-7.0RC3
+
+* Wed Nov 23 2005 Valery Inozemtsev <shrek@altlinux.ru> 0.99.3-alt0.1
+- initial release
+
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009