[PATCH xdm] Re-introduce the ability of staticcally linking the greeter.

Matthieu Herrb matthieu.herrb at laas.fr
Mon Nov 7 11:57:18 PST 2011


This logically reverts 7e223d3ac6c0d549a7d6e4dcc86a053e19594028.
There are still cases (in particular OpenBSD) where the shared greeter
is not desired.

BTW, Ubuntu 11.10 and Fedora 15 both ship xdm 1.10 with the shared
greeter disabled too.

Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr>
---
 configure.ac        |   28 ++++++++++++++++++++++++++--
 greeter/Makefile.am |    8 ++++++++
 greeter/greet.c     |    6 ++++--
 xdm/Makefile.am     |    5 ++++-
 xdm/session.c       |   12 +++++++++++-
 5 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 18848e8..7d41ce7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -419,6 +419,30 @@ PKG_CHECK_MODULES(AUTH, xau)
 # Greeter
 #
 
+AC_MSG_CHECKING([if the greeter should be built as a dynamically loaded object])
+
+AC_ARG_ENABLE(dynamic-greeter,
+	AC_HELP_STRING([--enable-dynamic-greeter],
+         [Build greeter as dynamically loaded shared object]),
+	[DYNAMIC_GREETER="$enableval"], [DYNAMIC_GREETER="auto"])
+
+if test "x$DYNAMIC_GREETER" = "xauto" ; then
+	case $host_os in
+	openbsd*)
+		DYNAMIC_GREETER="no"
+		;;
+	    *)	DYNAMIC_GREETER="yes" ;;
+
+	esac
+fi
+if test "x$DYNAMIC_GREETER" = "xno"; then
+STATIC_GREETER_CFLAGS="-DGREET_USER_STATIC"
+STATIC_GREETER_LIBS="-L../greeter -lXdmGreet"
+fi
+
+AC_MSG_RESULT([$DYNAMIC_GREETER])
+AM_CONDITIONAL(DYNAMIC_GREETER, test x$DYNAMIC_GREETER = xyes)
+
 PKG_CHECK_MODULES(XDMGREET, xt >= 1.0 x11 xext)
 
 GREETERLIB="${XDMLIBDIR}/libXdmGreet.so"
@@ -431,8 +455,8 @@ XDMGREET_LIBS="$XDMGREET_LIBS $XDM_TOOLKIT_LIBS $DMCP_LIBS $GREETER_LIBS"
 #  XDM
 #
 
-XDM_CFLAGS="$XDM_CFLAGS $DMCP_CFLAGS $XLIB_CFLAGS $AUTH_CFLAGS"
-XDM_LIBS="$XDM_LIBS $DMCP_LIBS"
+XDM_CFLAGS="$XDM_CFLAGS $DMCP_CFLAGS $XLIB_CFLAGS $AUTH_CFLAGS $STATIC_GREETER_CFLAGS"
+XDM_LIBS="$XDM_LIBS $DMCP_LIBS $STATIC_GREETER_LIBS"
 
 AC_CHECK_LIB(Xdmcp, XdmcpWrap, [xdmauth="yes"], [xdmauth="no"], [$DMCP_LIBS])
 
diff --git a/greeter/Makefile.am b/greeter/Makefile.am
index f0a8491..4e0d0a1 100644
--- a/greeter/Makefile.am
+++ b/greeter/Makefile.am
@@ -1,6 +1,10 @@
 xdmlibdir = $(XDMLIBDIR)
 
+if DYNAMIC_GREETER
 xdmlib_LTLIBRARIES = libXdmGreet.la
+else
+noinst_LTLIBRARIES = libXdmGreet.la
+endif
 
 libXdmGreet_la_SOURCES = \
 		  Login.c \
@@ -14,7 +18,11 @@ libXdmGreet_la_LIBADD = $(XDMGREET_LIBS)
 AM_CPPFLAGS = -I$(top_srcdir)/include
 AM_CFLAGS = $(CWARNFLAGS) $(XDMGREET_CFLAGS) -DGREET_LIB
 
+if DYNAMIC_GREETER
 libXdmGreet_la_LDFLAGS = -module -avoid-version
+else
+libXdmGreet_la_LDFLAGS = -static
+endif
 
 if LINT
 ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
diff --git a/greeter/greet.c b/greeter/greet.c
index 82e2c21..9fb6b82 100644
--- a/greeter/greet.c
+++ b/greeter/greet.c
@@ -96,7 +96,7 @@ extern int getdomainname(char *name, size_t len);
 /*
  * Function pointers filled in by the initial call ito the library
  */
-
+#ifdef GREET_LIB
 int     (*__xdm_PingServer)(struct display *d, Display *alternateDpy) = NULL;
 void    (*__xdm_SessionPingFailed)(struct display *d) = NULL;
 void    (*__xdm_Debug)(const char * fmt, ...) = NULL;
@@ -133,6 +133,7 @@ char     *(*__xdm_crypt)(CRYPT_ARGS) = NULL;
 # ifdef USE_PAM
 pam_handle_t **(*__xdm_thepamhp)(void) = NULL;
 # endif
+#endif
 
 #ifdef SECURE_RPC
 # include <rpc/rpc.h>
@@ -426,6 +427,7 @@ greet_user_rtn GreetUser(
     int i;
     Arg		arglist[2];
 
+#ifdef GREET_LIB
 /*
  * These must be set before they are used.
  */
@@ -465,7 +467,7 @@ greet_user_rtn GreetUser(
 # ifdef USE_PAM
     __xdm_thepamhp = dlfuncs->_thepamhp;
 # endif
-
+#endif
     *dpy = InitGreet (d);
     /*
      * Run the setup script - note this usually will not work when
diff --git a/xdm/Makefile.am b/xdm/Makefile.am
index 797b5c5..6748ef1 100644
--- a/xdm/Makefile.am
+++ b/xdm/Makefile.am
@@ -24,9 +24,12 @@ bin_PROGRAMS = xdm
 AM_CPPFLAGS = -I$(top_srcdir)/include
 AM_CFLAGS = $(CWARNFLAGS) $(XDM_CFLAGS) $(SYSTEMD_DAEMON_CFLAGS)
 
+AM_LDFLAGS = $(XDM_LIBS) $(SYSTEMD_DAEMON_LIBS)
 # The xdm binary needs to export symbols so that they can be used from
 # libXdmGreet.so loaded through a dlopen call from session.c
-AM_LDFLAGS = $(XDM_LIBS) $(SYSTEMD_DAEMON_LIBS) -export-dynamic
+if DYNAMIC_GREETER
+AM_LDFLAGS = $(AM_LDFLAGS) -export-dynamic
+endif
 
 xdm_SOURCES =		\
         access.c	\
diff --git a/xdm/session.c b/xdm/session.c
index 573747d..fe9024d 100644
--- a/xdm/session.c
+++ b/xdm/session.c
@@ -76,10 +76,12 @@ extern int key_setnet(struct key_netstarg *arg);
 #include <selinux/get_context_list.h>
 #endif /* USE_SELINUX */
 
+#ifndef GREET_USER_STATIC
 # include <dlfcn.h>
 # ifndef RTLD_NOW
 #  define RTLD_NOW 1
 # endif
+#endif
 
 #ifdef USE_SYSTEMD_DAEMON
 #include <systemd/sd-daemon.h>
@@ -329,7 +331,9 @@ ManageSession (struct display *d)
     Display		*dpy;
     greet_user_rtn	greet_stat;
     static GreetUserProc greet_user_proc = NULL;
+#ifndef GREET_USER_STATIC
     void		*greet_lib_handle;
+#endif
 
     Debug ("ManageSession %s\n", d->name);
     (void)XSetIOErrorHandler(IOErrorHandler);
@@ -344,6 +348,9 @@ ManageSession (struct display *d)
      */
     LoadXloginResources (d);
 
+#ifdef GREET_USER_STATIC
+    greet_user_proc = GreetUser;
+#else
     Debug ("ManageSession: loading greeter library %s\n", greeterLib);
     greet_lib_handle = dlopen(greeterLib, RTLD_NOW);
     if (greet_lib_handle != NULL)
@@ -352,6 +359,8 @@ ManageSession (struct display *d)
 	LogError ("%s while loading %s\n", dlerror(), greeterLib);
 	exit(UNMANAGE_DISPLAY);
 	}
+#endif
+    
 
 #ifdef USE_SYSTEMD_DAEMON
 	/* Subsequent notifications will be ignored by systemd
@@ -376,9 +385,10 @@ ManageSession (struct display *d)
 	     */
 	    if (StartClient (&verify, d, &clientPid, greet.name, greet.password)) {
 		Debug ("Client Started\n");
-
+#ifndef GREET_USER_STATIC
                 /* Save memory; close library */
                 dlclose(greet_lib_handle);
+#endif
 
 		/*
 		 * Wait for session to end,
-- 
1.7.6



More information about the xorg-devel mailing list