summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac30
-rw-r--r--src/plug-nis.c12
3 files changed, 41 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 0bada73..844df10 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
EXTRA_DIST = STATUS doc/*.txt doc/migrate-nis.sh doc/*.ldif.in doc/index*.ldif
-SUBDIRS = src
+SUBDIRS = src tests
VERSION=@PACKAGE_VERSION@
RELEASE=0
diff --git a/configure.ac b/configure.ac
index 541b5e2..f864337 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,5 +197,33 @@ AC_SUBST(schentryformatattr)
AC_SUBST(groupattr)
AC_SUBST(containerattr)
+AC_PATH_PROG(SLAPD,[ns-slapd],no-slapd,[$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/usr/libexec])
+AC_PATH_PROG(RPCGEN,[rpcgen],no-rpcgen,[$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/usr/libexec])
+AM_CONDITIONAL(CAN_TEST,[test "$server" = dirsrv && test "$SLAPD" != no-slapd && test "$RPCGEN" != no-rpcgen])
+AC_SUBST(CAN_TEST)
+test_user=`id -un`
+AC_SUBST(test_user)
+test_basedn=dc=example,dc=com
+AC_SUBST(test_basedn)
+while true ; do
+ test_ldapport=$RANDOM
+ if test $test_ldapport -ge 1024 ; then
+ break
+ fi
+done
+AC_SUBST(test_ldapport)
+while true ; do
+ test_nisport=$RANDOM
+ if test $test_nisport -ge 1024 ; then
+ break
+ fi
+done
+AC_SUBST(test_nisport)
+NIS_PLUGIN_CONTINUE_WITHOUT_PORTMAP_ENV="nis_plugin_continue_without_portmap_for_testing_only_no_i_really_mean_that"
+AC_DEFINE_UNQUOTED(NIS_PLUGIN_CONTINUE_WITHOUT_PORTMAP_ENV,"$NIS_PLUGIN_CONTINUE_WITHOUT_PORTMAP_ENV",[Define to the environment variable which will override the fail-if-unable-to-use-the-portmapper logic.])
+AC_SUBST(NIS_PLUGIN_CONTINUE_WITHOUT_PORTMAP_ENV)
+
AC_CONFIG_HEADER(config.h)
-AC_OUTPUT(Makefile src/Makefile doc/nis-plugin.ldif doc/sch-plugin.ldif)
+AC_OUTPUT(Makefile src/Makefile doc/nis-plugin.ldif doc/sch-plugin.ldif
+ tests/Makefile tests/clients/Makefile
+ tests/slapd.sh tests/config/dse.ldif.initial)
diff --git a/src/plug-nis.c b/src/plug-nis.c
index e0f1707..1c43a03 100644
--- a/src/plug-nis.c
+++ b/src/plug-nis.c
@@ -224,13 +224,23 @@ plugin_state_init(Slapi_PBlock *pb, struct plugin_state **lstate)
/* Create a socket for use in communicating with the portmapper. */
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if (sockfd == -1) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+ "error allocating portmap client socket\n");
goto failed;
}
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
if (bindresvport(sockfd, &sin) != 0) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+ "error binding portmap client socket to a "
+ "privileged port\n");
+ if ((getenv(NIS_PLUGIN_CONTINUE_WITHOUT_PORTMAP_ENV) == NULL) ||
+ !atol(getenv(NIS_PLUGIN_CONTINUE_WITHOUT_PORTMAP_ENV))) {
+ close(sockfd);
+ goto failed;
+ }
close(sockfd);
- goto failed;
+ sockfd = -1;
}
state->pmap_client_socket = sockfd;