From c6784a8fc1fdc7d64ae1529f1b7594db7f35c82a Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Wed, 17 Feb 2010 09:14:40 -0500
Subject: [PATCH 1/3] Eliminate separate build tree for sss_client

---
 Makefile.am                                        |    2 +-
 configure.ac                                       |    2 +-
 server/Makefile.am                                 |   46 +++++++++++++++++++-
 server/configure.ac                                |   13 ++++++
 server/po/POTFILES.in                              |    5 ++
 server/providers/data_provider.h                   |    2 +-
 server/responder/common/responder.h                |    2 +-
 server/responder/common/responder_packet.h         |    2 +-
 {sss_client => server/sss_client}/Makefile.am      |    0
 {sss_client => server/sss_client}/autogen.sh       |    0
 {sss_client => server/sss_client}/common.c         |    0
 {sss_client => server/sss_client}/conf_macros.m4   |    0
 {sss_client => server/sss_client}/config.guess     |    0
 {sss_client => server/sss_client}/config.sub       |    0
 {sss_client => server/sss_client}/configure.ac     |    0
 .../sss_client}/external/docbook.m4                |    0
 {sss_client => server/sss_client}/group.c          |    0
 {sss_client => server/sss_client}/install-sh       |    0
 {sss_client => server/sss_client}/m4/.dir          |    0
 .../sss_client}/man/pam_sss.8.xml                  |    0
 {sss_client => server/sss_client}/pam_sss.c        |    0
 .../sss_client}/pam_test_client.c                  |    0
 {sss_client => server/sss_client}/passwd.c         |    0
 {sss_client => server/sss_client}/po/LINGUAS       |    0
 {sss_client => server/sss_client}/po/Makevars      |    0
 {sss_client => server/sss_client}/po/POTFILES.in   |    0
 {sss_client => server/sss_client}/po/de.po         |    0
 {sss_client => server/sss_client}/po/es.po         |    0
 {sss_client => server/sss_client}/po/fr.po         |    0
 {sss_client => server/sss_client}/po/it.po         |    0
 {sss_client => server/sss_client}/po/ja.po         |    0
 {sss_client => server/sss_client}/po/nl.po         |    0
 {sss_client => server/sss_client}/po/pl.po         |    0
 {sss_client => server/sss_client}/po/pt.po         |    0
 .../sss_client}/po/sss_client.pot                  |    0
 {sss_client => server/sss_client}/po/sv.po         |    0
 {sss_client => server/sss_client}/protos.h         |    0
 {sss_client => server/sss_client}/sss_cli.h        |    0
 {sss_client => server/sss_client}/sss_nss.exports  |    0
 {sss_client => server/sss_client}/sss_pam.exports  |    0
 {sss_client => server/sss_client}/sss_pam_macros.h |    0
 server/util/user_info_msg.c                        |    2 +-
 42 files changed, 69 insertions(+), 7 deletions(-)
 rename {sss_client => server/sss_client}/Makefile.am (100%)
 rename {sss_client => server/sss_client}/autogen.sh (100%)
 rename {sss_client => server/sss_client}/common.c (100%)
 rename {sss_client => server/sss_client}/conf_macros.m4 (100%)
 rename {sss_client => server/sss_client}/config.guess (100%)
 rename {sss_client => server/sss_client}/config.sub (100%)
 rename {sss_client => server/sss_client}/configure.ac (100%)
 rename {sss_client => server/sss_client}/external/docbook.m4 (100%)
 rename {sss_client => server/sss_client}/group.c (100%)
 rename {sss_client => server/sss_client}/install-sh (100%)
 rename {sss_client => server/sss_client}/m4/.dir (100%)
 rename {sss_client => server/sss_client}/man/pam_sss.8.xml (100%)
 rename {sss_client => server/sss_client}/pam_sss.c (100%)
 rename {sss_client => server/sss_client}/pam_test_client.c (100%)
 rename {sss_client => server/sss_client}/passwd.c (100%)
 rename {sss_client => server/sss_client}/po/LINGUAS (100%)
 rename {sss_client => server/sss_client}/po/Makevars (100%)
 rename {sss_client => server/sss_client}/po/POTFILES.in (100%)
 rename {sss_client => server/sss_client}/po/de.po (100%)
 rename {sss_client => server/sss_client}/po/es.po (100%)
 rename {sss_client => server/sss_client}/po/fr.po (100%)
 rename {sss_client => server/sss_client}/po/it.po (100%)
 rename {sss_client => server/sss_client}/po/ja.po (100%)
 rename {sss_client => server/sss_client}/po/nl.po (100%)
 rename {sss_client => server/sss_client}/po/pl.po (100%)
 rename {sss_client => server/sss_client}/po/pt.po (100%)
 rename {sss_client => server/sss_client}/po/sss_client.pot (100%)
 rename {sss_client => server/sss_client}/po/sv.po (100%)
 rename {sss_client => server/sss_client}/protos.h (100%)
 rename {sss_client => server/sss_client}/sss_cli.h (100%)
 rename {sss_client => server/sss_client}/sss_nss.exports (100%)
 rename {sss_client => server/sss_client}/sss_pam.exports (100%)
 rename {sss_client => server/sss_client}/sss_pam_macros.h (100%)

diff --git a/Makefile.am b/Makefile.am
index 45275dc..f20fc56 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = common server sss_client
+SUBDIRS = common server
 
 DISTCHECK_CONFIGURE_FLAGS = --with-ldb-lib-dir="$$dc_install_base"/lib/ldb
 
diff --git a/configure.ac b/configure.ac
index a48c583..030ebc9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,7 +8,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_CONFIG_MACRO_DIR([m4])
 AC_PROG_INSTALL
 
-AC_CONFIG_SUBDIRS([common server sss_client])
+AC_CONFIG_SUBDIRS([common server])
 
 AC_SUBST([PRERELEASE_VERSION],
          PRERELEASE_VERSION_NUMBER)
diff --git a/server/Makefile.am b/server/Makefile.am
index 21ae79a..eeb8cfe 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -17,6 +17,8 @@ sssdapiplugindir = $(sssdconfdir)/sssd.api.d
 dbusintrospectdir = $(datarootdir)/sssd/introspect
 dbuspolicydir = $(sysconfdir)/dbus-1/system.d
 localedir = @localedir@
+nsslibdir = @nsslibdir@
+pamlibdir = $(nsslibdir)/security
 
 dbpath = @dbpath@
 pluginpath = @pluginpath@
@@ -179,6 +181,7 @@ AM_CPPFLAGS = -Wall \
     -Iinclude \
     -I.. \
     -I$(srcdir)/include \
+    -I$(srcdir)/sss_client \
     -Iinclude \
     -I. \
     $(POPT_CFLAGS) \
@@ -619,6 +622,42 @@ stress_tests_SOURCES = \
 stress_tests_LDADD = \
     $(SSSD_LIBS)
 
+noinst_PROGRAMS = pam_test_client
+pam_test_client_SOURCES = sss_client/pam_test_client.c
+pam_test_client_LDFLAGS = -lpam -lpam_misc
+
+####################
+# Client Libraries #
+####################
+
+nsslib_LTLIBRARIES = libnss_sss.la
+libnss_sss_la_SOURCES = \
+    sss_client/common.c \
+    sss_client/passwd.c \
+    sss_client/group.c \
+    sss_client/sss_cli.h
+libnss_sss_la_LDFLAGS = \
+    -module \
+    -version-info 2:0:0 \
+    -Wl,--version-script,$(srcdir)/sss_client/sss_nss.exports
+
+pamlib_LTLIBRARIES = pam_sss.la
+pam_sss_la_SOURCES = \
+    sss_client/pam_sss.c \
+    sss_client/common.c \
+    sss_client/sss_cli.h \
+    sss_client/sss_pam_macros.h
+
+pam_sss_la_LDFLAGS = \
+    -lpam \
+    -module \
+    -avoid-version \
+    -Wl,--version-script,$(srcdir)/sss_client/sss_pam.exports
+
+dist_noinst_DATA += \
+    sss_client/sss_nss.exports \
+    sss_client/sss_pam.exports
+
 ####################
 # Plugin Libraries #
 ####################
@@ -799,7 +838,7 @@ dist_man_MANS = man/sss_useradd.8 man/sss_userdel.8 man/sss_usermod.8 \
 		man/sss_groupadd.8 man/sss_groupdel.8 man/sss_groupmod.8 \
 		man/sssd.8 man/sssd.conf.5 man/sssd-ldap.5 man/sssd-krb5.5 \
 		man/sssd-ipa.5 man/sssd_krb5_locator_plugin.8 \
-		man/sss_groupshow.8
+		man/sss_groupshow.8 sss_client/man/pam_sss.8
 
 SUFFIXES = .1.xml .1 .3.xml .3 .5.xml .5 .8.xml .8
 .1.xml.1:
@@ -881,6 +920,11 @@ install-exec-hook: installsssddirs
 	fi
 	mkdir -p doc $(DESTDIR)/$(docdir); cp -a doc $(DESTDIR)/$(docdir)/
 
+install-data-hook:
+	rm $(DESTDIR)/$(nsslibdir)/libnss_sss.so.2 \
+       $(DESTDIR)/$(nsslibdir)/libnss_sss.so
+	mv $(DESTDIR)/$(nsslibdir)/libnss_sss.so.2.0.0 $(DESTDIR)/$(nsslibdir)/libnss_sss.so.2
+
 uninstall-hook:
 	if [ -f $(abs_builddir)/config/.files ]; then \
 	    cat $(abs_builddir)/config/.files | xargs -iq rm -f $(DESTDIR)/q; \
diff --git a/server/configure.ac b/server/configure.ac
index f24debb..4198ee9 100644
--- a/server/configure.ac
+++ b/server/configure.ac
@@ -43,6 +43,19 @@ AC_CHECK_TYPES([errno_t], [], [], [[#include <errno.h>]])
 m4_include([build_macros.m4])
 BUILD_WITH_SHARED_BUILD_DIR
 
+#Check for PAM headers
+AC_CHECK_HEADERS([security/pam_appl.h security/pam_misc.h security/pam_modules.h],
+    [AC_CHECK_LIB(pam, pam_get_item, [ PAM_LIBS="-lpam" ], [AC_MSG_ERROR([PAM must support pam_get_item])])],
+    [AC_MSG_ERROR([PAM development libraries not installed])]
+)
+
+#Set the NSS library install path
+AC_ARG_ENABLE([nsslibdir], [AS_HELP_STRING([--enable-nsslibdir],
+                                        [Where to install nss libraries ($libdir)])],
+              [nsslibdir=$enableval],
+              [nsslibdir=$libdir])
+AC_SUBST(nsslibdir)
+
 m4_include(conf_macros.m4)
 WITH_DB_PATH
 WITH_PLUGIN_PATH
diff --git a/server/po/POTFILES.in b/server/po/POTFILES.in
index 2dacfe8..e317161 100644
--- a/server/po/POTFILES.in
+++ b/server/po/POTFILES.in
@@ -9,3 +9,8 @@ tools/tools_util.h
 tools/sss_useradd.c
 tools/sss_groupadd.c
 tools/sss_usermod.c
+sss_client/common.c
+sss_client/group.c
+sss_client/pam_sss.c
+sss_client/pam_test_client.c
+sss_client/passwd.c
diff --git a/server/providers/data_provider.h b/server/providers/data_provider.h
index c524662..76ba4cf 100644
--- a/server/providers/data_provider.h
+++ b/server/providers/data_provider.h
@@ -34,7 +34,7 @@
 #include "dbus/dbus.h"
 #include "sbus/sssd_dbus.h"
 #include "sbus/sbus_client.h"
-#include "../sss_client/sss_cli.h"
+#include "sss_client/sss_cli.h"
 
 #define DATA_PROVIDER_VERSION 0x0001
 #define DATA_PROVIDER_SERVICE_NAME "dp"
diff --git a/server/responder/common/responder.h b/server/responder/common/responder.h
index 9294f40..ea6ba58 100644
--- a/server/responder/common/responder.h
+++ b/server/responder/common/responder.h
@@ -31,7 +31,7 @@
 #include "ldb.h"
 #include "dhash.h"
 #include "sbus/sssd_dbus.h"
-#include "../sss_client/sss_cli.h"
+#include "sss_client/sss_cli.h"
 
 extern hash_table_t *dp_requests;
 
diff --git a/server/responder/common/responder_packet.h b/server/responder/common/responder_packet.h
index e98707a..2bfdc8a 100644
--- a/server/responder/common/responder_packet.h
+++ b/server/responder/common/responder_packet.h
@@ -22,7 +22,7 @@
 #ifndef __SSSSRV_PACKET_H__
 #define __SSSSRV_PACKET_H__
 
-#include "../sss_client/sss_cli.h"
+#include "sss_client/sss_cli.h"
 
 #define SSS_PACKET_MAX_RECV_SIZE 1024
 
diff --git a/sss_client/Makefile.am b/server/sss_client/Makefile.am
similarity index 100%
rename from sss_client/Makefile.am
rename to server/sss_client/Makefile.am
diff --git a/sss_client/autogen.sh b/server/sss_client/autogen.sh
similarity index 100%
rename from sss_client/autogen.sh
rename to server/sss_client/autogen.sh
diff --git a/sss_client/common.c b/server/sss_client/common.c
similarity index 100%
rename from sss_client/common.c
rename to server/sss_client/common.c
diff --git a/sss_client/conf_macros.m4 b/server/sss_client/conf_macros.m4
similarity index 100%
rename from sss_client/conf_macros.m4
rename to server/sss_client/conf_macros.m4
diff --git a/sss_client/config.guess b/server/sss_client/config.guess
similarity index 100%
rename from sss_client/config.guess
rename to server/sss_client/config.guess
diff --git a/sss_client/config.sub b/server/sss_client/config.sub
similarity index 100%
rename from sss_client/config.sub
rename to server/sss_client/config.sub
diff --git a/sss_client/configure.ac b/server/sss_client/configure.ac
similarity index 100%
rename from sss_client/configure.ac
rename to server/sss_client/configure.ac
diff --git a/sss_client/external/docbook.m4 b/server/sss_client/external/docbook.m4
similarity index 100%
rename from sss_client/external/docbook.m4
rename to server/sss_client/external/docbook.m4
diff --git a/sss_client/group.c b/server/sss_client/group.c
similarity index 100%
rename from sss_client/group.c
rename to server/sss_client/group.c
diff --git a/sss_client/install-sh b/server/sss_client/install-sh
similarity index 100%
rename from sss_client/install-sh
rename to server/sss_client/install-sh
diff --git a/sss_client/m4/.dir b/server/sss_client/m4/.dir
similarity index 100%
rename from sss_client/m4/.dir
rename to server/sss_client/m4/.dir
diff --git a/sss_client/man/pam_sss.8.xml b/server/sss_client/man/pam_sss.8.xml
similarity index 100%
rename from sss_client/man/pam_sss.8.xml
rename to server/sss_client/man/pam_sss.8.xml
diff --git a/sss_client/pam_sss.c b/server/sss_client/pam_sss.c
similarity index 100%
rename from sss_client/pam_sss.c
rename to server/sss_client/pam_sss.c
diff --git a/sss_client/pam_test_client.c b/server/sss_client/pam_test_client.c
similarity index 100%
rename from sss_client/pam_test_client.c
rename to server/sss_client/pam_test_client.c
diff --git a/sss_client/passwd.c b/server/sss_client/passwd.c
similarity index 100%
rename from sss_client/passwd.c
rename to server/sss_client/passwd.c
diff --git a/sss_client/po/LINGUAS b/server/sss_client/po/LINGUAS
similarity index 100%
rename from sss_client/po/LINGUAS
rename to server/sss_client/po/LINGUAS
diff --git a/sss_client/po/Makevars b/server/sss_client/po/Makevars
similarity index 100%
rename from sss_client/po/Makevars
rename to server/sss_client/po/Makevars
diff --git a/sss_client/po/POTFILES.in b/server/sss_client/po/POTFILES.in
similarity index 100%
rename from sss_client/po/POTFILES.in
rename to server/sss_client/po/POTFILES.in
diff --git a/sss_client/po/de.po b/server/sss_client/po/de.po
similarity index 100%
rename from sss_client/po/de.po
rename to server/sss_client/po/de.po
diff --git a/sss_client/po/es.po b/server/sss_client/po/es.po
similarity index 100%
rename from sss_client/po/es.po
rename to server/sss_client/po/es.po
diff --git a/sss_client/po/fr.po b/server/sss_client/po/fr.po
similarity index 100%
rename from sss_client/po/fr.po
rename to server/sss_client/po/fr.po
diff --git a/sss_client/po/it.po b/server/sss_client/po/it.po
similarity index 100%
rename from sss_client/po/it.po
rename to server/sss_client/po/it.po
diff --git a/sss_client/po/ja.po b/server/sss_client/po/ja.po
similarity index 100%
rename from sss_client/po/ja.po
rename to server/sss_client/po/ja.po
diff --git a/sss_client/po/nl.po b/server/sss_client/po/nl.po
similarity index 100%
rename from sss_client/po/nl.po
rename to server/sss_client/po/nl.po
diff --git a/sss_client/po/pl.po b/server/sss_client/po/pl.po
similarity index 100%
rename from sss_client/po/pl.po
rename to server/sss_client/po/pl.po
diff --git a/sss_client/po/pt.po b/server/sss_client/po/pt.po
similarity index 100%
rename from sss_client/po/pt.po
rename to server/sss_client/po/pt.po
diff --git a/sss_client/po/sss_client.pot b/server/sss_client/po/sss_client.pot
similarity index 100%
rename from sss_client/po/sss_client.pot
rename to server/sss_client/po/sss_client.pot
diff --git a/sss_client/po/sv.po b/server/sss_client/po/sv.po
similarity index 100%
rename from sss_client/po/sv.po
rename to server/sss_client/po/sv.po
diff --git a/sss_client/protos.h b/server/sss_client/protos.h
similarity index 100%
rename from sss_client/protos.h
rename to server/sss_client/protos.h
diff --git a/sss_client/sss_cli.h b/server/sss_client/sss_cli.h
similarity index 100%
rename from sss_client/sss_cli.h
rename to server/sss_client/sss_cli.h
diff --git a/sss_client/sss_nss.exports b/server/sss_client/sss_nss.exports
similarity index 100%
rename from sss_client/sss_nss.exports
rename to server/sss_client/sss_nss.exports
diff --git a/sss_client/sss_pam.exports b/server/sss_client/sss_pam.exports
similarity index 100%
rename from sss_client/sss_pam.exports
rename to server/sss_client/sss_pam.exports
diff --git a/sss_client/sss_pam_macros.h b/server/sss_client/sss_pam_macros.h
similarity index 100%
rename from sss_client/sss_pam_macros.h
rename to server/sss_client/sss_pam_macros.h
diff --git a/server/util/user_info_msg.c b/server/util/user_info_msg.c
index 1886537..547e3bb 100644
--- a/server/util/user_info_msg.c
+++ b/server/util/user_info_msg.c
@@ -23,7 +23,7 @@
 */
 
 #include "util/util.h"
-#include "../sss_client/sss_cli.h"
+#include "sss_client/sss_cli.h"
 
 errno_t pack_user_info_chpass_error(TALLOC_CTX *mem_ctx,
                                     const char *user_error_message,
-- 
1.6.6

