summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMark McLoughlin <mark@skynet.ie>2005-04-22 16:29:20 +0000
committerMark McLoughlin <markmc@src.gnome.org>2005-04-22 16:29:20 +0000
commitcbacaed0e62147451be3883e64ec55898caf8d15 (patch)
tree9a1177f5dccf2cd8d5ed9c1c46972cc1ecd47727 /utils
parentedfe5f290bb21db973205b7186f802df8b6ffa74 (diff)
downloadgdm-cbacaed0e62147451be3883e64ec55898caf8d15.tar.gz
Add the ability to make GDM spawn XDMCP sessions on a local X proxy
2005-04-22 Mark McLoughlin <mark@skynet.ie> Add the ability to make GDM spawn XDMCP sessions on a local X proxy server. Experimental support for disconnect/reconnect or "session migration" is also implemented using DMX. More details in bug #301602. * configure.in: require glib 2.6.0 and check for DMX. * config/gdm.conf.in: add xdmpc/EnableProxy, xdmcp/ProxyXServer and xdmcp/ProxyReconnect config keys. * docs/C/gdm.xml: document new config keys. * daemon/gdm.h: add TYPE_XDMCP_PROXY server type, add #defines for the new config keys, re-name various xnest related GdmDisplay members to be applicable for all proxy servers, add xdmcp_dispnum GdmDisplay member, modify the format of GDM_SOP_QUERYLOGIN and add GDM_SOP_AUTHFILE and GDM_SOP_MIGRATE. * daemon/gdm.c: read the new config keys, change format of what GDM_SOP_QUERYLOGIN returns, implement GDM_SOP_AUTHFILE and GDM_SOP_MIGRATE. * daemon/xdmcp.h: add gdm_xdmcp_migrate. * daemon/xdmcp.c: when xdmpc/EnableProxy and xdmcp/ProxyXServer, set things up such that a proxy sever (which displays on the requesting X server) is run locally by the slave. Also implement migrating the proxy server from one parent display to another using the xdmcp/ProxyReconnect command. * daemon/server.c: if we're running a proxy server (e.g. Xnest or Xdmx), hold a connection open to the parent display so that it doesn't reset. Run proxy servers with -display rather than setting $DISPLAY. * daemon/slave.c: Once we've successfully logged the user in, send SOP_QUERYLOGIN to the slave - if the result from that indicates that the user is already logged in and that session is migratable (e.g. by reconnecting a proxy server or changing the VT), then migrate to the existing session using SOP_MIGRATE. In the case of an Xdmcp proxy, hold open the connection to the parent display so that it doesn't reset. Exit the slave as soon as that connection closes. * utils/Makefile.am, utils/gdm-dmx-reconnect-proxy.c: implementation of xdmcp/ProxyReconnect for use with Xdmx.
Diffstat (limited to 'utils')
-rw-r--r--utils/.cvsignore1
-rw-r--r--utils/Makefile.am16
-rw-r--r--utils/gdm-dmx-reconnect-proxy.c133
3 files changed, 150 insertions, 0 deletions
diff --git a/utils/.cvsignore b/utils/.cvsignore
index 80868fe5..9f61016a 100644
--- a/utils/.cvsignore
+++ b/utils/.cvsignore
@@ -6,3 +6,4 @@ gdmaskpass
gdmopen
gdmmktemp
gdmtranslate
+gdm-dmx-reconnect-proxy
diff --git a/utils/Makefile.am b/utils/Makefile.am
index f22e4363..7ec28603 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -20,6 +20,10 @@ libexec_PROGRAMS = \
# bin_PROGRAMS = \
# gdmmktemp
+if DMX_SUPPORT
+bin_PROGRAMS = gdm-dmx-reconnect-proxy
+endif
+
EXTRA_PROGRAMS = gdmaskpass gdmopen
gdmaskpass_SOURCES = \
@@ -47,3 +51,15 @@ gdmtranslate_LDADD = \
#gdmmktemp_LDADD = \
# $(INTLLIBS)
+
+if DMX_SUPPORT
+gdm_dmx_reconnect_proxy_SOURCES = \
+ gdm-dmx-reconnect-proxy.c
+
+gdm_dmx_reconnect_proxy_LDADD = \
+ $(GLIB_LIBS) \
+ $(X_EXTRA_LIBS) \
+ $(X_LIBS) \
+ -lX11 \
+ $(DMX_LIBS)
+endif
diff --git a/utils/gdm-dmx-reconnect-proxy.c b/utils/gdm-dmx-reconnect-proxy.c
new file mode 100644
index 00000000..352db3f7
--- /dev/null
+++ b/utils/gdm-dmx-reconnect-proxy.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+#include <ve-misc.h>
+
+static char *to_display = NULL;
+static char *backend_display = NULL;
+static char *to_authfile = NULL;
+static char *backend_authfile = NULL;
+
+static GOptionEntry options[] = {
+ {
+ "to", 0, 0, G_OPTION_ARG_STRING, &to_display,
+ N_("DMX display to migrate to"),
+ N_("DISPLAY")
+ },
+ {
+ "display", 0, 0, G_OPTION_ARG_STRING, &backend_display,
+ N_("Backend display name"),
+ N_("DISPLAY")
+ },
+ {
+ "to-authfile", 0, 0, G_OPTION_ARG_STRING, &to_authfile,
+ N_("Xauthority file for destination display"),
+ N_("AUTHFILE")
+ },
+ {
+ "display-authfile", 0, 0, G_OPTION_ARG_STRING, &backend_authfile,
+ N_("Xauthority file for backend display"),
+ N_("AUTHFILE")
+ },
+ { NULL }
+};
+
+static Display *
+get_dmx_display (const char *display_name,
+ const char *authfile)
+{
+ Display *display;
+ int event_base, error_base;
+ const char *old_authfile;
+
+ old_authfile = getenv ("XAUTHORITY");
+ ve_setenv ("XAUTHORITY", authfile, TRUE);
+
+ if ((display = XOpenDisplay (display_name)) == NULL)
+ g_printerr (_("Failed to open display \"%s\"\n"), display_name);
+
+ if (display != NULL &&
+ !DMXQueryExtension (display, &event_base, &error_base)) {
+ g_printerr (_("DMX extension not present on \"%s\"\n"), display_name);
+ XCloseDisplay (display);
+ display = NULL;
+ }
+
+ ve_setenv ("XAUTHORITY", old_authfile, TRUE);
+
+ return display;
+}
+
+int
+main (int argc, char **argv)
+{
+ GOptionContext *options_context;
+ Display *display;
+ DMXScreenAttributes attr;
+ guint mask;
+ int screen;
+
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+
+ options_context = g_option_context_new (_("- migrate a backend display from one DMX display to another"));
+ g_option_context_add_main_entries (options_context, options, GETTEXT_PACKAGE);
+ g_option_context_parse (options_context, &argc, &argv, NULL);
+
+ if (to_display == NULL) {
+ g_printerr (_("You must specify a destination DMX display using %s\n"), "--to");
+ return 1;
+ }
+
+ if (backend_display == NULL) {
+ g_printerr (_("You must specify a backend display which using %s\n"), "--display");
+ return 1;
+ }
+
+ if ((display = get_dmx_display (to_display, to_authfile)) == NULL)
+ return 1;
+
+ /* Note, we have no way yet of using backend_authfile to ensure
+ * that the DMX server can authenticate against the backend Xserver.
+ * For now, we must disable access control on the backend server.
+ */
+
+ mask = 0;
+ screen = 0;
+ if (!DMXAddScreen (display, backend_display, mask, &attr, &screen)) {
+ g_printerr (_("DMXAddScreen \"%s\" failed on \"%s\"\n"),
+ backend_display, to_display);
+ XCloseDisplay (display);
+ return 1;
+ }
+
+ XCloseDisplay (display);
+
+ return 0;
+}