From ba6df12813f1311afa312706af520fdbf80b53ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rados=C5=82aw=20Korzeniewski?= Date: Fri, 19 Feb 2021 14:14:24 +0100 Subject: [PATCH] BPAM: move code to the proper location and correct regression build. --- bacula/autoconf/configure.in | 6 +-- bacula/src/plugins/dir/Makefile | 41 +++++++++++-------- .../src/plugins/dir/ldap/{src => }/.gitignore | 0 .../src/plugins/dir/ldap/{src => }/Makefile | 20 ++++----- .../src/plugins/dir/ldap/{src => }/ldap-dir.c | 0 .../src/plugins/dir/ldap/{src => }/ldap-dir.h | 0 .../plugins/dir/ldap/{src => }/ldap-util.c | 0 .../plugins/dir/ldap/{src => }/ldap-util.h | 0 .../src/plugins/dir/ldap/{src => }/ldaptest.c | 0 regress/scripts/setup | 5 ++- regress/tests/ldap-auth-plugin-test | 16 ++++---- 11 files changed, 47 insertions(+), 41 deletions(-) rename bacula/src/plugins/dir/ldap/{src => }/.gitignore (100%) rename bacula/src/plugins/dir/ldap/{src => }/Makefile (83%) rename bacula/src/plugins/dir/ldap/{src => }/ldap-dir.c (100%) rename bacula/src/plugins/dir/ldap/{src => }/ldap-dir.h (100%) rename bacula/src/plugins/dir/ldap/{src => }/ldap-util.c (100%) rename bacula/src/plugins/dir/ldap/{src => }/ldap-util.h (100%) rename bacula/src/plugins/dir/ldap/{src => }/ldaptest.c (100%) diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 6eb075d5c..d001177e4 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -620,7 +620,7 @@ AC_ARG_ENABLE(build-dird, DIRD_DIR="src/dird" DIR_TOOLS="DIRTOOLS" -DIR_PLUGIN_DIR="src/plugins/dir" +# DIR_PLUGIN_DIR="src/plugins/dir" if test x$build_dird = xyes; then DIRD_DIR="src/dird" @@ -632,7 +632,7 @@ fi AC_SUBST(DIRD_DIR) AC_SUBST(DIR_TOOLS) -AC_SUBST(DIR_PLUGIN_DIR) +# AC_SUBST(DIR_PLUGIN_DIR) dnl ------------------------------------------- dnl stored (default on) @@ -3351,7 +3351,7 @@ if test x$support_ldap_bpam = xyes -o x$support_ldap_bpam = xauto; then fi fi if test x$support_ldap_bpam = xyes; then - DIR_PLUGIN_DIR="${DIR_PLUGIN_DIR} src/plugins/dir/ldap/src" + DIR_PLUGIN_DIR="${DIR_PLUGIN_DIR} src/plugins/dir/ldap" fi AC_SUBST(BPAM_LDAP_TARGET) diff --git a/bacula/src/plugins/dir/Makefile b/bacula/src/plugins/dir/Makefile index 3f5e858f2..eafbb2d50 100644 --- a/bacula/src/plugins/dir/Makefile +++ b/bacula/src/plugins/dir/Makefile @@ -8,39 +8,48 @@ include Makefile.inc .c.lo: - $(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I${SRCDIR} -I${DIRDIR} -DTEST_PROGRAM -c $< + @echo "Compiling $< ..." + $(NO_ECHO)$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I${SRCDIR} -I${DIRDIR} -I${LIBDIR} -DWORKDIR=\"$(DESTDIR)$(working_dir)\" -c $< -all: dirpluglib.lo +%.lo: %.c %.h + @echo "Pattern compiling $< ..." + $(NO_ECHO)$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I${SRCDIR} -I${DIRDIR} -I${LIBDIR} -DWORKDIR=\"$(DESTDIR)$(working_dir)\" -c $(@:.lo=.c) -example-plugin-dir.lo: example-plugin-dir.c ${DIRDIR}/dir_plugins.h - $(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CFLAGS) -I../.. -I${DIRDIR} -c example-plugin-dir.c +all: dirpluglib.lo example-plugin-dir.la test-authentication-api-dir.la -example-plugin-dir.la: Makefile example-plugin-dir.lo - $(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -shared example-plugin-dir.lo -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version +# example-plugin-dir.lo: example-plugin-dir.c ${DIRDIR}/dir_plugins.h +# $(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CFLAGS) -I../.. -I${DIRDIR} -c example-plugin-dir.c -test-authentication-api-dir.lo: test-authentication-api-dir.c ${DIRDIR}/dir_plugins.h - $(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CFLAGS) -I../.. -I${DIRDIR} -c test-authentication-api-dir.c +example-plugin-dir.la: example-plugin-dir.lo + @echo "Linking $(@:.la=.so) ..." + $(NO_ECHO)$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -shared example-plugin-dir.lo -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version + +# test-authentication-api-dir.lo: test-authentication-api-dir.c ${DIRDIR}/dir_plugins.h +# $(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CFLAGS) -I../.. -I${DIRDIR} -c test-authentication-api-dir.c -test-authentication-api-dir.la: Makefile test-authentication-api-dir.lo dirpluglib.lo +test-authentication-api-dir.la: test-authentication-api-dir.lo dirpluglib.lo @echo "Linking $(@:.la=.so) ..." $(NO_ECHO)$(LIBTOOL_LINK) --silent $(CXX) $(LDFLAGS) -shared $^ -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version install: all - $(MKDIR) $(DESTDIR)$(plugindir) + $(NO_ECHO)$(MKDIR) $(DESTDIR)$(plugindir) + +install-bpam-ldap: + $(MAKE) -C ldap install $(LIBTOOL_CLEAN_TARGET): - find . -name '*.lo' -print | xargs $(LIBTOOL_CLEAN) $(RMF) - $(RMF) *.la - $(RMF) -r .libs _libs + $(NO_ECHO)find . -name '*.lo' -print | xargs $(LIBTOOL_CLEAN) $(RMF) + $(NO_ECHO)$(RMF) *.la + $(NO_ECHO)$(RMF) -r .libs _libs clean: $(LIBTOOL_CLEAN_TARGET) - rm -f main *.so *.o 1 2 3 + $(NO_ECHO)rm -f main *.so *.o 1 2 3 distclean: clean - rm -f Makefile + $(NO_ECHO)rm -f Makefile $(LIBTOOL_UNINSTALL_TARGET): - $(LIBTOOL_UNINSTALL) $(RMF) $(DESTDIR)$(plugindir)/example-plugin-dir.la + $(NO_ECHO)$(LIBTOOL_UNINSTALL) $(RMF) $(DESTDIR)$(plugindir)/example-plugin-dir.la uninstall: $(LIBTOOL_UNINSTALL_TARGET) diff --git a/bacula/src/plugins/dir/ldap/src/.gitignore b/bacula/src/plugins/dir/ldap/.gitignore similarity index 100% rename from bacula/src/plugins/dir/ldap/src/.gitignore rename to bacula/src/plugins/dir/ldap/.gitignore diff --git a/bacula/src/plugins/dir/ldap/src/Makefile b/bacula/src/plugins/dir/ldap/Makefile similarity index 83% rename from bacula/src/plugins/dir/ldap/src/Makefile rename to bacula/src/plugins/dir/ldap/Makefile index f5f1983e4..143cc00e8 100644 --- a/bacula/src/plugins/dir/ldap/src/Makefile +++ b/bacula/src/plugins/dir/ldap/Makefile @@ -6,7 +6,7 @@ # # -include ../../Makefile.inc +include ../Makefile.inc LDAPSRC = ldap-dir.c LDAPTESTSRC = ldaptest.c @@ -39,7 +39,7 @@ install: $(BPAM_LDAP_TARGET_INSTALL) install-ldap: ldap-dir.la @echo "Installing plugin $(^:.la=.so) ..." - $(MKDIR) $(DESTDIR)$(plugindir) + $(NO_ECHO)$(MKDIR) $(DESTDIR)$(plugindir) $(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) ldap-dir.la $(DESTDIR)$(plugindir) $(NO_ECHO)$(RMF) $(DESTDIR)$(plugindir)/ldap-dir.la @@ -47,21 +47,17 @@ install-ldaptest: ldaptest @echo "Installing $< ..." $(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) $< $(DESTDIR)$(sbindir) -Makefile: Makefile.in $(topdir)/config.status - cd $(topdir) \ - && CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - $(LIBTOOL_CLEAN_TARGET): - @find . -name '*.lo' -print | xargs $(LIBTOOL_CLEAN) $(RMF) - @$(RMF) *.la - @$(RMF) -r .libs _libs + $(NO_ECHO)find . -name '*.lo' -print | xargs $(LIBTOOL_CLEAN) $(RMF) + $(NO_ECHO)$(RMF) *.la + $(NO_ECHO)$(RMF) -r .libs _libs clean: $(LIBTOOL_CLEAN_TARGET) - @rm -f main ldaptest *.so *.o + $(NO_ECHO)rm -f main ldaptest *.so *.o distclean: clean - @rm -f Makefile *.la *.lo - @rm -rf .libs + $(NO_ECHO)rm -f Makefile *.la *.lo + $(NO_ECHO)rm -rf .libs $(LIBTOOL_UNINSTALL_TARGET): $(LIBTOOL_UNINSTALL) $(RMF) $(DESTDIR)$(plugindir)/ldap-dir.so diff --git a/bacula/src/plugins/dir/ldap/src/ldap-dir.c b/bacula/src/plugins/dir/ldap/ldap-dir.c similarity index 100% rename from bacula/src/plugins/dir/ldap/src/ldap-dir.c rename to bacula/src/plugins/dir/ldap/ldap-dir.c diff --git a/bacula/src/plugins/dir/ldap/src/ldap-dir.h b/bacula/src/plugins/dir/ldap/ldap-dir.h similarity index 100% rename from bacula/src/plugins/dir/ldap/src/ldap-dir.h rename to bacula/src/plugins/dir/ldap/ldap-dir.h diff --git a/bacula/src/plugins/dir/ldap/src/ldap-util.c b/bacula/src/plugins/dir/ldap/ldap-util.c similarity index 100% rename from bacula/src/plugins/dir/ldap/src/ldap-util.c rename to bacula/src/plugins/dir/ldap/ldap-util.c diff --git a/bacula/src/plugins/dir/ldap/src/ldap-util.h b/bacula/src/plugins/dir/ldap/ldap-util.h similarity index 100% rename from bacula/src/plugins/dir/ldap/src/ldap-util.h rename to bacula/src/plugins/dir/ldap/ldap-util.h diff --git a/bacula/src/plugins/dir/ldap/src/ldaptest.c b/bacula/src/plugins/dir/ldap/ldaptest.c similarity index 100% rename from bacula/src/plugins/dir/ldap/src/ldaptest.c rename to bacula/src/plugins/dir/ldap/ldaptest.c diff --git a/regress/scripts/setup b/regress/scripts/setup index 97989b6fa..ea34b5435 100755 --- a/regress/scripts/setup +++ b/regress/scripts/setup @@ -10,7 +10,7 @@ check_exit_code() { if [ $? != 0 ] ; then echo "Bad exit code giving up" - exit 1 + exit 1 fi } @@ -43,7 +43,7 @@ if [ x$PREBUILT != xyes ]; then fi fi scripts/create_sed -# In default bacula-dir.conf.in, change default file +# In default bacula-dir.conf.in, change default file # to backup to be build directory echo "s%File = @sbindir@%File = @BUILD_DIR@%g" >tmp/t$$ sed -f tmp/t$$ build/src/dird/bacula-dir.conf.in >tmp/o$$ @@ -72,6 +72,7 @@ if [ x$PREBUILT != xyes ]; then make ${MAKEOPT} check_exit_code make install + make install-plugins fi if [ a${KEEP_SOURCE} = a ]; then rm -rf examples patches diff --git a/regress/tests/ldap-auth-plugin-test b/regress/tests/ldap-auth-plugin-test index 6ed4de331..12e4db5fc 100755 --- a/regress/tests/ldap-auth-plugin-test +++ b/regress/tests/ldap-auth-plugin-test @@ -16,7 +16,7 @@ scripts/copy-ldap-auth-plugin-confs start_local_slapd # Authentication Plugin = "ldap:binddn=@BINDDN@ bindpass=@BINDPASS@ url=ldap://localhost:3890 query=@LDAPQUERY@" -db_name=`cat ${tmp}/ldap_db_name` +db_name=$(cat ${tmp}/ldap_db_name) BINDDN="cn=root,dc=$db_name,dc=bacula,dc=com" BINDPASS=rootroot LDAPQUERY="dc=$db_name,dc=bacula,dc=com/(cn=%u)" @@ -47,7 +47,7 @@ END_OF_DATA run_bacula # now check if we have ldap-dir loaded -if [ `grep ldap-dir ${tmp}/log.out | wc -l` -lt 1 ] +if [ "$(grep -c ldap-dir ${tmp}/log.out)" -lt 1 ] then echo "BPAM LDAP Plugin is not loaded, cannot perform the test!" exit 1 @@ -58,26 +58,26 @@ printf "Authentication test ... " estat=0 # check invalid login -printf "admin\nadmin\nstatus dir\nquit\n" | ${bin}/bconsole -p -C ldaptest -c bconsole.auth-ldap-plugin.conf 2>&1 > ${tmp}/log1.out -if [ `grep Version: ${tmp}/log1.out | wc -l` -gt 0 ] +printf "admin\nadmin\nstatus dir\nquit\n" | ${bin}/bconsole -p -C ldaptest -c bconsole.auth-ldap-plugin.conf > ${tmp}/log1.out 2>&1 +if [ "$(grep -c Version: ${tmp}/log1.out)" -gt 0 ] then printf "failed ... " estat=1 else - if [ `grep "LDAP Authentication Successfull" ${working}/*.trace | wc -l` -gt 0 ] + if [ "$(grep -c "LDAP Authentication Successfull" ${working}/*.trace)" -gt 0 ] then estat=2 fi fi # check proper login -printf "root\nrootroot\nstatus dir\nquit\n" | ${bin}/bconsole -p -C ldaptest -c bconsole.auth-ldap-plugin.conf 2>&1 > ${tmp}/log2.out -if [ `grep Version: ${tmp}/log2.out | wc -l` -lt 1 ] +printf "root\nrootroot\nstatus dir\nquit\n" | ${bin}/bconsole -p -C ldaptest -c bconsole.auth-ldap-plugin.conf > ${tmp}/log2.out 2>&1 +if [ "$(grep -c Version: ${tmp}/log2.out)" -lt 1 ] then printf "failed ... " estat=3 else - if [ `grep "LDAP Authentication Successfull" ${working}/*.trace | wc -l` -lt 1 ] + if [ "$(grep -c "LDAP Authentication Successfull" ${working}/*.trace)" -lt 1 ] then estat=4 fi -- 2.47.3