Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2015-03-21 18:54:32 +0100
committerArthur de Jong <arthur@arthurdejong.org>2015-03-22 20:08:52 +0100
commit0420232b7989c99ad7992f0f10a47f3f48a28fc7 (patch)
tree287f91e8f3ad9006da58a266545bf5c637c1b97c
parent788475f94b27e3583e4bb35d8a7643fe9ff6719d (diff)
Various small fixes when using --with-module-name
This updates the test framework to support --with-module-name, ensures that exports.map is rebuilt when configure is re-ran, fixes parsing of nsswitch.conf (to determine what to return for passwd lookups) and fixes the check for _nss_ldap_version.
-rw-r--r--nslcd/nslcd.c2
-rw-r--r--nslcd/nsswitch.c6
-rw-r--r--nss/Makefile.am2
-rwxr-xr-xtests/testenv.sh20
4 files changed, 19 insertions, 11 deletions
diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c
index 36b151d..f765b9c 100644
--- a/nslcd/nslcd.c
+++ b/nslcd/nslcd.c
@@ -612,7 +612,7 @@ static void disable_nss_ldap(void)
/* clear any existing errors */
dlerror();
/* lookup the NSS version if possible */
- version_info = (char **)dlsym(handle, "_nss_ldap_version");
+ version_info = (char **)dlsym(handle, "_nss_" MODULE_NAME "_version");
error = dlerror();
if ((version_info != NULL) && (error == NULL))
log_log(LOG_DEBUG, "NSS_LDAP %s %s", version_info[0], version_info[1]);
diff --git a/nslcd/nsswitch.c b/nslcd/nsswitch.c
index ff9d9d5..babf40e 100644
--- a/nslcd/nsswitch.c
+++ b/nslcd/nsswitch.c
@@ -1,7 +1,7 @@
/*
nsswitch.c - functions for parsing /etc/nsswitch.conf
- Copyright (C) 2011, 2012 Arthur de Jong
+ Copyright (C) 2011-2015 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -151,7 +151,7 @@ static int shadow_uses_ldap(void)
if (services != NULL)
{
shadow_found = 1;
- if (has_service(services, "ldap", NSSWITCH_FILE, lnr))
+ if (has_service(services, MODULE_NAME, NSSWITCH_FILE, lnr))
{
fclose(fp);
return 1;
@@ -160,7 +160,7 @@ static int shadow_uses_ldap(void)
/* see if we have a passwd line */
services = find_db(linebuf, "passwd");
if (services != NULL)
- passwd_has_ldap = has_service(services, "ldap", NSSWITCH_FILE, lnr);
+ passwd_has_ldap = has_service(services, MODULE_NAME, NSSWITCH_FILE, lnr);
}
fclose(fp);
if (shadow_found)
diff --git a/nss/Makefile.am b/nss/Makefile.am
index cfa05e0..1a8f35a 100644
--- a/nss/Makefile.am
+++ b/nss/Makefile.am
@@ -44,7 +44,7 @@ nss_ldap_so_DEPENDENCIES = $(nss_ldap_so_LDADD) exports.map
EXTRA_DIST = exports.glibc exports.solaris exports.freebsd
CLEANFILES = exports.map
-exports.map: $(EXTRA_DIST)
+exports.map: $(EXTRA_DIST) Makefile
sed 's/ldap/@MODULE_NAME@/' < $(srcdir)/exports.$(NSS_FLAVOUR) > exports.map
install-exec-local: install-nss_ldap_so
diff --git a/tests/testenv.sh b/tests/testenv.sh
index 6b59873..4d807b8 100755
--- a/tests/testenv.sh
+++ b/tests/testenv.sh
@@ -2,7 +2,7 @@
# testenv.sh - script to check test environment
#
-# Copyright (C) 2011, 2013 Arthur de Jong
+# Copyright (C) 2011-2015 Arthur de Jong
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -24,16 +24,24 @@ set -e
# get the script name
script="`basename "$0"`"
-# find source directory (used for finding auxiliary files)
+# find source and build directory (used for finding auxiliary files)
srcdir="${srcdir-`dirname "$0"`}"
+builddir="${builddir-`dirname "$0"`}"
# location of nslcd configuration file
nslcd_cfg="${nslcd_cfg-/etc/nslcd.conf}"
+# the configured module name (usually ldap)
+if [ -f "$builddir"/../config.h ]
+then
+ module_name=`sed -n 's/^#define MODULE_NAME "\(.*\)"$/\1/p' "$builddir"/../config.h`
+fi
+module_name="${module_name-ldap}"
+
# find the names of services that are configured to use LDAP
nss_list_configured()
{
- sed -n 's/^[ \t]*\([a-z]*\)[ \t]*:.*[ \t]ldap.*$/\1/p' /etc/nsswitch.conf \
+ sed -n 's/^[ \t]*\([a-z]*\)[ \t]*:.*[ \t]'$module_name'.*$/\1/p' /etc/nsswitch.conf \
| xargs
}
@@ -41,7 +49,7 @@ nss_list_configured()
nss_is_enabled()
{
name="$1"
- grep '^[ \t]*'$name'[ \t]*:.*ldap.*' /etc/nsswitch.conf > /dev/null
+ grep '^[ \t]*'$name'[ \t]*:.*'$module_name'.*' /etc/nsswitch.conf > /dev/null
}
# check to see if name is configured to do lookups through
@@ -57,10 +65,10 @@ nss_enable()
if grep -q '^[ \t]*'$name'[ \t]*:' /etc/nsswitch.conf
then
# modify an existing entry by just adding ldap to the end
- sed -i 's/^\([ \t]*'$name'[ \t]*:.*[^ \t]\)[ \t]*$/\1 ldap/' /etc/nsswitch.conf
+ sed -i 's/^\([ \t]*'$name'[ \t]*:.*[^ \t]\)[ \t]*$/\1 '$module_name'/' /etc/nsswitch.conf
else
# append a new line
- printf '%-15s ldap\n' $name':' >> /etc/nsswitch.conf
+ printf '%-15s '$module_name'\n' $name':' >> /etc/nsswitch.conf
fi
# invalidate nscd cache
nscd -i "$name" > /dev/null 2>&1 || true