commit_id
string | repo
string | commit_message
string | diff
string | label
int64 |
---|---|---|---|---|
ad85c482b235c603bd29da7d754415065400bdf1
|
389ds/389-ds-base
|
Resolves: bug 245815
Description: DS Admin Migration framework
Reviewed by: nhosoi (Thanks!)
Fix Description: Created a Migration class that is very similar to the Setup class - to act as a sort of global context for the migration process. Moved most of the guts of migrateTo11 into the new DSMigration class and the new migrate-ds.pl - we should deprecate migrateTo11 in favor of migrate-ds.pl. I had to enhance the check_and_add_entry function to handle pseudo-LDIF change records - pseudo because mozilla perldap LDIF has no real LDIF change record support.
Fixed a bug in create_instance.c - creating an instance without starting it was not working if the port number of an existing directory server was supplied.
Added a new method createDSInstance to Util - this just wraps ds_newinst.pl for now.
Platforms tested: RHEL4
Doc: Yes. We will need to document the migration procedures.
Flag day: Yes. Autotool file changes.
|
commit ad85c482b235c603bd29da7d754415065400bdf1
Author: Rich Megginson <[email protected]>
Date: Fri Jun 29 21:12:22 2007 +0000
Resolves: bug 245815
Description: DS Admin Migration framework
Reviewed by: nhosoi (Thanks!)
Fix Description: Created a Migration class that is very similar to the Setup class - to act as a sort of global context for the migration process. Moved most of the guts of migrateTo11 into the new DSMigration class and the new migrate-ds.pl - we should deprecate migrateTo11 in favor of migrate-ds.pl. I had to enhance the check_and_add_entry function to handle pseudo-LDIF change records - pseudo because mozilla perldap LDIF has no real LDIF change record support.
Fixed a bug in create_instance.c - creating an instance without starting it was not working if the port number of an existing directory server was supplied.
Added a new method createDSInstance to Util - this just wraps ds_newinst.pl for now.
Platforms tested: RHEL4
Doc: Yes. We will need to document the migration procedures.
Flag day: Yes. Autotool file changes.
diff --git a/Makefile.am b/Makefile.am
index 37ae67af7..ea116701f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -186,7 +186,8 @@ bin_SCRIPTS = $(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl \
ldap/admin/src/scripts/cl-dump.pl \
wrappers/repl-monitor \
ldap/admin/src/scripts/repl-monitor.pl \
- ldap/admin/src/scripts/setup-ds.pl
+ ldap/admin/src/scripts/setup-ds.pl \
+ ldap/admin/src/scripts/migrate-ds.pl
perl_SCRIPTS = ldap/admin/src/scripts/SetupLog.pm \
ldap/admin/src/scripts/Resource.pm \
@@ -197,9 +198,12 @@ perl_SCRIPTS = ldap/admin/src/scripts/SetupLog.pm \
ldap/admin/src/scripts/DialogManager.pm \
ldap/admin/src/scripts/Dialog.pm \
ldap/admin/src/scripts/DSDialogs.pm \
- ldap/admin/src/scripts/Setup.pm
+ ldap/admin/src/scripts/Setup.pm \
+ ldap/admin/src/scripts/Migration.pm \
+ ldap/admin/src/scripts/DSMigration.pm
-property_DATA = ldap/admin/src/scripts/setup-ds.res
+property_DATA = ldap/admin/src/scripts/setup-ds.res \
+ ldap/admin/src/scripts/migrate-ds.res
task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
ldap/admin/src/scripts/template-db2bak \
diff --git a/Makefile.in b/Makefile.in
index eb00d462e..6235d97bc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -877,6 +877,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
+SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOLARIS_FALSE = @SOLARIS_FALSE@
@@ -1122,7 +1123,8 @@ bin_SCRIPTS = $(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl \
ldap/admin/src/scripts/cl-dump.pl \
wrappers/repl-monitor \
ldap/admin/src/scripts/repl-monitor.pl \
- ldap/admin/src/scripts/setup-ds.pl
+ ldap/admin/src/scripts/setup-ds.pl \
+ ldap/admin/src/scripts/migrate-ds.pl
perl_SCRIPTS = ldap/admin/src/scripts/SetupLog.pm \
ldap/admin/src/scripts/Resource.pm \
@@ -1133,9 +1135,13 @@ perl_SCRIPTS = ldap/admin/src/scripts/SetupLog.pm \
ldap/admin/src/scripts/DialogManager.pm \
ldap/admin/src/scripts/Dialog.pm \
ldap/admin/src/scripts/DSDialogs.pm \
- ldap/admin/src/scripts/Setup.pm
+ ldap/admin/src/scripts/Setup.pm \
+ ldap/admin/src/scripts/Migration.pm \
+ ldap/admin/src/scripts/DSMigration.pm
+
+property_DATA = ldap/admin/src/scripts/setup-ds.res \
+ ldap/admin/src/scripts/migrate-ds.res
-property_DATA = ldap/admin/src/scripts/setup-ds.res
task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
ldap/admin/src/scripts/template-db2bak \
ldap/admin/src/scripts/template-db2index \
diff --git a/aclocal.m4 b/aclocal.m4
index 9064efa9b..c7c1c6fbc 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1578,10 +1578,27 @@ linux*)
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390x*|powerpc64*)
+ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -4288,6 +4305,9 @@ CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
# Is the compiler the GNU C compiler?
with_gcc=$_LT_AC_TAGVAR(GCC, $1)
+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
+gcc_ver=\`gcc -dumpversion\`
+
# An ERE matcher.
EGREP=$lt_EGREP
@@ -4421,11 +4441,11 @@ striplib=$lt_striplib
# Dependencies to place before the objects being linked to create a
# shared library.
-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
+predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place after the objects being linked to create a
# shared library.
-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
+postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place before the objects being linked to create a
# shared library.
@@ -4437,7 +4457,7 @@ postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
# The library search path used internally by the compiler when linking
# a shared library.
-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
+compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method
@@ -4517,7 +4537,7 @@ variables_saved_for_relink="$variables_saved_for_relink"
link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
@@ -6353,6 +6373,7 @@ do
done
done
done
+IFS=$as_save_IFS
lt_ac_max=0
lt_ac_count=0
# Add /usr/xpg4/bin/sed as it is typically found on Solaris
@@ -6385,6 +6406,7 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
done
])
SED=$lt_cv_path_SED
+AC_SUBST([SED])
AC_MSG_RESULT([$SED])
])
diff --git a/configure b/configure
index 2747da937..21acdfe54 100755
--- a/configure
+++ b/configure
@@ -465,7 +465,7 @@ ac_includes_default="\
#endif"
ac_default_prefix=/opt/$PACKAGE_NAME
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_bitwise_TRUE enable_bitwise_FALSE configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir infdir defaultuser defaultgroup instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG PACKAGE_BASE_VERSION nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link brand capbrand vendor LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_bitwise_TRUE enable_bitwise_FALSE configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir infdir defaultuser defaultgroup instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG PACKAGE_BASE_VERSION nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link brand capbrand vendor LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -3836,6 +3836,7 @@ do
done
done
done
+IFS=$as_save_IFS
lt_ac_max=0
lt_ac_count=0
# Add /usr/xpg4/bin/sed as it is typically found on Solaris
@@ -3870,6 +3871,7 @@ done
fi
SED=$lt_cv_path_SED
+
echo "$as_me:$LINENO: result: $SED" >&5
echo "${ECHO_T}$SED" >&6
@@ -4310,7 +4312,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4313 "configure"' > conftest.$ac_ext
+ echo '#line 4315 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5445,7 +5447,7 @@ fi
# Provide some information about the compiler.
-echo "$as_me:5448:" \
+echo "$as_me:5450:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -6508,11 +6510,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6511: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6513: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6515: \$? = $ac_status" >&5
+ echo "$as_me:6517: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6776,11 +6778,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6779: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6781: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6783: \$? = $ac_status" >&5
+ echo "$as_me:6785: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6880,11 +6882,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6883: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6885: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:6887: \$? = $ac_status" >&5
+ echo "$as_me:6889: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -8345,10 +8347,31 @@ linux*)
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390x*|powerpc64*)
+ echo '#line 8354 "configure"' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -9225,7 +9248,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9228 "configure"
+#line 9251 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -9325,7 +9348,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9328 "configure"
+#line 9351 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -9656,6 +9679,9 @@ CC=$lt_compiler
# Is the compiler the GNU C compiler?
with_gcc=$GCC
+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
+gcc_ver=\`gcc -dumpversion\`
+
# An ERE matcher.
EGREP=$lt_EGREP
@@ -9789,11 +9815,11 @@ striplib=$lt_striplib
# Dependencies to place before the objects being linked to create a
# shared library.
-predep_objects=$lt_predep_objects
+predep_objects=\`echo $lt_predep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place after the objects being linked to create a
# shared library.
-postdep_objects=$lt_postdep_objects
+postdep_objects=\`echo $lt_postdep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place before the objects being linked to create a
# shared library.
@@ -9805,7 +9831,7 @@ postdeps=$lt_postdeps
# The library search path used internally by the compiler when linking
# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path
+compiler_lib_search_path=\`echo $lt_compiler_lib_search_path | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method
@@ -9885,7 +9911,7 @@ variables_saved_for_relink="$variables_saved_for_relink"
link_all_deplibs=$link_all_deplibs
# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
@@ -11665,11 +11691,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11668: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11694: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:11672: \$? = $ac_status" >&5
+ echo "$as_me:11698: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -11769,11 +11795,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11772: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11798: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:11776: \$? = $ac_status" >&5
+ echo "$as_me:11802: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -12301,10 +12327,31 @@ linux*)
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390x*|powerpc64*)
+ echo '#line 12334 "configure"' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -12688,6 +12735,9 @@ CC=$lt_compiler_CXX
# Is the compiler the GNU C compiler?
with_gcc=$GCC_CXX
+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
+gcc_ver=\`gcc -dumpversion\`
+
# An ERE matcher.
EGREP=$lt_EGREP
@@ -12821,11 +12871,11 @@ striplib=$lt_striplib
# Dependencies to place before the objects being linked to create a
# shared library.
-predep_objects=$lt_predep_objects_CXX
+predep_objects=\`echo $lt_predep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place after the objects being linked to create a
# shared library.
-postdep_objects=$lt_postdep_objects_CXX
+postdep_objects=\`echo $lt_postdep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place before the objects being linked to create a
# shared library.
@@ -12837,7 +12887,7 @@ postdeps=$lt_postdeps_CXX
# The library search path used internally by the compiler when linking
# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method
@@ -12917,7 +12967,7 @@ variables_saved_for_relink="$variables_saved_for_relink"
link_all_deplibs=$link_all_deplibs_CXX
# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
@@ -13339,11 +13389,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13342: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13392: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:13346: \$? = $ac_status" >&5
+ echo "$as_me:13396: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -13443,11 +13493,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13446: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13496: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:13450: \$? = $ac_status" >&5
+ echo "$as_me:13500: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -14888,10 +14938,31 @@ linux*)
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390x*|powerpc64*)
+ echo '#line 14945 "configure"' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -15275,6 +15346,9 @@ CC=$lt_compiler_F77
# Is the compiler the GNU C compiler?
with_gcc=$GCC_F77
+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
+gcc_ver=\`gcc -dumpversion\`
+
# An ERE matcher.
EGREP=$lt_EGREP
@@ -15408,11 +15482,11 @@ striplib=$lt_striplib
# Dependencies to place before the objects being linked to create a
# shared library.
-predep_objects=$lt_predep_objects_F77
+predep_objects=\`echo $lt_predep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place after the objects being linked to create a
# shared library.
-postdep_objects=$lt_postdep_objects_F77
+postdep_objects=\`echo $lt_postdep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place before the objects being linked to create a
# shared library.
@@ -15424,7 +15498,7 @@ postdeps=$lt_postdeps_F77
# The library search path used internally by the compiler when linking
# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_F77
+compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method
@@ -15504,7 +15578,7 @@ variables_saved_for_relink="$variables_saved_for_relink"
link_all_deplibs=$link_all_deplibs_F77
# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
@@ -15646,11 +15720,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15649: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15723: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15653: \$? = $ac_status" >&5
+ echo "$as_me:15727: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -15914,11 +15988,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15917: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15991: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15921: \$? = $ac_status" >&5
+ echo "$as_me:15995: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16018,11 +16092,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16021: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16095: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16025: \$? = $ac_status" >&5
+ echo "$as_me:16099: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -17483,10 +17557,31 @@ linux*)
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390x*|powerpc64*)
+ echo '#line 17564 "configure"' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -17870,6 +17965,9 @@ CC=$lt_compiler_GCJ
# Is the compiler the GNU C compiler?
with_gcc=$GCC_GCJ
+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
+gcc_ver=\`gcc -dumpversion\`
+
# An ERE matcher.
EGREP=$lt_EGREP
@@ -18003,11 +18101,11 @@ striplib=$lt_striplib
# Dependencies to place before the objects being linked to create a
# shared library.
-predep_objects=$lt_predep_objects_GCJ
+predep_objects=\`echo $lt_predep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place after the objects being linked to create a
# shared library.
-postdep_objects=$lt_postdep_objects_GCJ
+postdep_objects=\`echo $lt_postdep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place before the objects being linked to create a
# shared library.
@@ -18019,7 +18117,7 @@ postdeps=$lt_postdeps_GCJ
# The library search path used internally by the compiler when linking
# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
+compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method
@@ -18099,7 +18197,7 @@ variables_saved_for_relink="$variables_saved_for_relink"
link_all_deplibs=$link_all_deplibs_GCJ
# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
@@ -18351,6 +18449,9 @@ CC=$lt_compiler_RC
# Is the compiler the GNU C compiler?
with_gcc=$GCC_RC
+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
+gcc_ver=\`gcc -dumpversion\`
+
# An ERE matcher.
EGREP=$lt_EGREP
@@ -18484,11 +18585,11 @@ striplib=$lt_striplib
# Dependencies to place before the objects being linked to create a
# shared library.
-predep_objects=$lt_predep_objects_RC
+predep_objects=\`echo $lt_predep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place after the objects being linked to create a
# shared library.
-postdep_objects=$lt_postdep_objects_RC
+postdep_objects=\`echo $lt_postdep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Dependencies to place before the objects being linked to create a
# shared library.
@@ -18500,7 +18601,7 @@ postdeps=$lt_postdeps_RC
# The library search path used internally by the compiler when linking
# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_RC
+compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method
@@ -18580,7 +18681,7 @@ variables_saved_for_relink="$variables_saved_for_relink"
link_all_deplibs=$link_all_deplibs_RC
# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
@@ -25895,6 +25996,7 @@ s,@ac_ct_CC@,$ac_ct_CC,;t t
s,@CCDEPMODE@,$CCDEPMODE,;t t
s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
+s,@SED@,$SED,;t t
s,@EGREP@,$EGREP,;t t
s,@LN_S@,$LN_S,;t t
s,@ECHO@,$ECHO,;t t
diff --git a/ldap/admin/src/create_instance.c b/ldap/admin/src/create_instance.c
index f5421589e..526414257 100644
--- a/ldap/admin/src/create_instance.c
+++ b/ldap/admin/src/create_instance.c
@@ -437,7 +437,7 @@ static char *sanity_check(server_config_s *cf, char *param_name)
/* if we don't need to start the server right away, we can skip the
port number checks
*/
- if (!needToStartServer(cf))
+ if (needToStartServer(cf))
{
if( (t = create_instance_checkports(cf)))
{
diff --git a/ldap/admin/src/migrateTo11.in b/ldap/admin/src/migrateTo11.in
index 1618dece9..01ba572c5 100644
--- a/ldap/admin/src/migrateTo11.in
+++ b/ldap/admin/src/migrateTo11.in
@@ -294,38 +294,6 @@ sub copyDatabases {
# updateDBguardian($newdbdir);
}
-sub copySecurityFiles {
- my $oldroot = shift;
- my $inst = shift;
- my $destdir = shift;
-
- if (! -d "$oldroot/alias") {
- debug(0, "Error: security file directory $oldroot/alias not found\n");
- } elsif (! -d $destdir) {
- debug(0, "Error: new security file directory $destdir not found\n");
- } else {
- debug(1, "Copying $oldroot/alias/$inst-cert8.db to $destdir/cert8.db\n");
- system ("cp -p $oldroot/alias/$inst-cert8.db $destdir/cert8.db") == 0 or
- die "Error: could not copy $oldroot/alias/$inst-cert8.db to $destdir/cert8.db: $!";
- debug(1, "Copying $oldroot/alias/$inst-key3.db to $destdir/key3.db\n");
- system ("cp -p $oldroot/alias/$inst-key3.db $destdir/key3.db") == 0 or
- die "Error: could not copy $oldroot/alias/$inst-key3.db to $destdir/key3.db: $!";
- debug(1, "Copying $oldroot/alias/secmod.db to $destdir/secmod.db\n");
- system ("cp -p $oldroot/alias/secmod.db $destdir/secmod.db") == 0 or
- die "Error: could not copy $oldroot/alias/secmod.db to $destdir/secmod.db: $!";
- if (-f "$oldroot/alias/$inst-pin.txt") {
- debug(1, "Copying $oldroot/alias/$inst-pin.txt to $destdir/pin.txt\n");
- system ("cp -p $oldroot/alias/$inst-pin.txt $destdir/pin.txt") == 0 or
- die "Error: could not copy $oldroot/alias/$inst-pin.txt to $destdir/pin.txt: $!";
- }
- if (-f "$oldroot/shared/config/certmap.conf") {
- debug(1, "Copying $oldroot/shared/config/certmap.conf to $destdir/certmap.conf\n");
- system ("cp -p $oldroot/shared/config/certmap.conf $destdir/certmap.conf") == 0 or
- die "Error: could not copy $oldroot/shared/config/certmap.conf to $destdir/certmap.conf: $!";
- }
- }
-}
-
sub copyChangelogDB {
my $oldroot = shift;
my $inst = shift;
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
new file mode 100644
index 000000000..86f0cb4d7
--- /dev/null
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -0,0 +1,437 @@
+# BEGIN COPYRIGHT BLOCK
+# This Program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2 of the License.
+#
+# This Program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# In addition, as a special exception, Red Hat, Inc. gives You the additional
+# right to link the code of this Program with code not covered under the GNU
+# General Public License ("Non-GPL Code") and to distribute linked combinations
+# including the two, subject to the limitations in this paragraph. Non-GPL Code
+# permitted under this exception must only link to the code of this Program
+# through those well defined interfaces identified in the file named EXCEPTION
+# found in the source code files (the "Approved Interfaces"). The files of
+# Non-GPL Code may instantiate templates or use macros or inline functions from
+# the Approved Interfaces without causing the resulting work to be covered by
+# the GNU General Public License. Only Red Hat, Inc. may make changes or
+# additions to the list of Approved Interfaces. You must obey the GNU General
+# Public License in all respects for all of the Program code and other code used
+# in conjunction with the Program except the Non-GPL Code covered by this
+# exception. If you modify this file, you may extend this exception to your
+# version of the file, but you are not obligated to do so. If you do not wish to
+# provide this exception without modification, you must delete this exception
+# statement from your version and license this file solely under the GPL without
+# exception.
+#
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+###########################
+#
+# This perl module provides a way to set up a new installation after
+# the binaries have already been extracted. This is typically after
+# using native packaging support to install the package e.g. RPM,
+# pkgadd, depot, etc. This script will show the license, readme,
+# dsktune, then run the usual setup pre and post installers.
+#
+##########################
+
+package DSMigration;
+use Migration;
+use Util;
+use Inf;
+
+# tempfiles
+use File::Temp qw(tempfile tempdir);
+
+# load perldap
+use Mozilla::LDAP::Conn;
+use Mozilla::LDAP::Utils qw(normalizeDN);
+use Mozilla::LDAP::API qw(ldap_explode_dn);
+use Mozilla::LDAP::LDIF;
+
+use Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(migrateDS);
+@EXPORT_OK = qw(migrateDS);
+
+use strict;
+
+use SetupLog;
+use Util;
+
+# these are the attributes for which we will always use
+# the new value, or which do not apply anymore
+my %ignoreOld =
+(
+ 'nsslapd-errorlog' => 'nsslapd-errorlog',
+ 'nsslapd-accesslog' => 'nsslapd-accesslog',
+ 'nsslapd-auditlog' => 'nsslapd-auditlog',
+ 'nskeyfile' => 'nsKeyfile',
+ 'nscertfile' => 'nsCertfile',
+ 'nsslapd-pluginpath' => 'nsslapd-pluginPath',
+ 'nsslapd-plugintype' => 'nsslapd-pluginType',
+ 'nsslapd-pluginversion' => 'nsslapd-pluginVersion',
+ 'nsslapd-plugin-depends-on-named' => 'nsslapd-plugin-depends-on-named',
+# these are new attrs that we should just pass through
+ 'nsslapd-schemadir' => 'nsslapd-schemadir',
+ 'nsslapd-lockdir' => 'nsslapd-lockdir',
+ 'nsslapd-tmpdir' => 'nsslapd-tmpdir',
+ 'nsslapd-certdir' => 'nsslapd-certdir',
+ 'nsslapd-ldapifilepath' => 'nsslapd-ldapifilepath',
+ 'nsslapd-ldapilisten' => 'nsslapd-ldapilisten',
+ 'nsslapd-ldapiautobind' => 'nsslapd-ldapiautobind',
+ 'nsslapd-ldapimaprootdn' => 'nsslapd-ldapimaprootdn',
+ 'nsslapd-ldapimaptoentries' => 'nsslapd-ldapimaptoentries',
+ 'nsslapd-ldapiuidnumbertype' => 'nsslapd-ldapiuidnumbertype',
+ 'nsslapd-ldapigidnumbertype' => 'nsslapd-ldapigidnumbertype',
+ 'nsslapd-ldapientrysearchbase' => 'nsslapd-ldapientrysearchbase',
+ 'nsslapd-ldapiautodnsuffix' => 'nsslapd-ldapiautodnsuffix'
+);
+
+# these are the attributes for which we will always use
+# the old value
+my %alwaysUseOld =
+(
+ 'aci' => 'aci'
+);
+
+my $pkgname; # global used in several different places - set in migrateDS
+my $oldsroot; # global used in several different places - set in migrateDS
+
+sub getNewDbDir {
+ my ($ent, $attr, $inst) = @_;
+ my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
+ my $cn = $ent->getValues('cn');
+ my $newval;
+ if ($objclasses{nsbackendinstance}) {
+ $newval = "@localstatedir@/lib/$pkgname/$inst/db/$cn";
+ } elsif (lc $cn eq 'config') {
+ $newval = "@localstatedir@/lib/$pkgname/$inst/db";
+ } elsif (lc $cn eq 'changelog5') {
+ $newval = "@localstatedir@/lib/$pkgname/$inst/cldb";
+ }
+ debug(2, "New value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
+ return $newval;
+}
+
+sub migrateCredentials {
+ my ($ent, $attr, $inst) = @_;
+ my $oldval = $ent->getValues($attr);
+ debug(3, "Executing migratecred -o $oldsroot/$inst -n @instconfigdir@/$inst -c $oldval . . .\n");
+ my $newval = `migratecred -o $oldsroot/$inst -n @instconfigdir@/$inst -c $oldval`;
+ debug(3, "Converted old value [$oldval] to new value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
+ return $newval;
+}
+
+# these are attributes that we have to transform from
+# the old value to the new value (e.g. a pathname)
+# The key of this hash is the attribute name. The value
+# is an anonymous sub which takes two arguments - the entry
+# and the old value. The return value of the sub is
+# the new value
+my %transformAttr =
+(
+ 'nsslapd-directory' => \&getNewDbDir,
+ 'nsslapd-db-logdirectory' => \&getNewDbDir,
+ 'nsslapd-changelogdir' => \&getNewDbDir,
+ 'nsds5replicacredentials' => \&migrateCredentials,
+ 'nsmultiplexorcredentials' => \&migrateCredentials
+);
+
+sub copyDatabaseDirs {
+ my $srcdir = shift;
+ my $destdir = shift;
+ if (-d $srcdir && ! -d $destdir) {
+ debug(1, "Copying database directory $srcdir to $destdir\n");
+ system ("cp -p -r $srcdir $destdir") == 0 or
+ die "Could not copy database directory $srcdir to $destdir: $?";
+ } elsif (! -d $srcdir) {
+ die "Error: database directory $srcdir does not exist";
+ } else {
+ debug(1, "The destination directory $destdir already exists, copying files/dirs individually\n");
+ foreach my $file (glob("$srcdir/*")) {
+ debug(3, "Copying $file to $destdir\n");
+ if (-f $file) {
+ system ("cp -p $file $destdir") == 0 or
+ die "Error: could not copy $file to $destdir: $!";
+ } elsif (-d $file) {
+ system ("cp -p -r $file $destdir") == 0 or
+ die "Error: could not copy $file to $destdir: $!";
+ }
+ }
+ }
+}
+
+sub copyDatabases {
+ my $oldroot = shift;
+ my $inst = shift;
+ my $newdbdir = shift;
+
+ # global config and instance specific config are children of this entry
+ my $basedbdn = normalizeDN("cn=ldbm database,cn=plugins,cn=config");
+ # get the list of databases, their index and transaction log locations
+ my $fname = "$oldroot/$inst/config/dse.ldif";
+ open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
+ my $in = new Mozilla::LDAP::LDIF(*DSELDIF);
+ my $targetdn = normalizeDN("cn=config,cn=ldbm database,cn=plugins,cn=config");
+ while (my $ent = readOneEntry $in) {
+ next if (!$ent->getDN()); # just skip root dse
+ # look for the one level children of $basedbdn
+ my @rdns = ldap_explode_dn($ent->getDN(), 0);
+ my $parentdn = normalizeDN(join(',', @rdns[1..$#rdns]));
+ if ($parentdn eq $basedbdn) {
+ my $cn = $ent->getValues('cn');
+ my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
+ if ($cn eq 'config') { # global config
+ debug(1, "Found ldbm database plugin config entry ", $ent->getDN(), "\n");
+ my $dir = $ent->getValues('nsslapd-directory');
+ my $homedir = $ent->getValues('nsslapd-db-home-directory');
+ my $logdir = $ent->getValues('nsslapd-db-logdirectory');
+ debug(1, "old db dir = $dir homedir = $homedir logdir = $logdir\n");
+ my $srcdir = $homedir || $dir || "$oldroot/$inst/db";
+ copyDatabaseDirs($srcdir, $newdbdir);
+ copyDatabaseDirs($logdir, $newdbdir) if ($logdir && $logdir ne $srcdir);
+ } elsif ($objclasses{nsbackendinstance}) {
+ debug(1, "Found ldbm database instance entry ", $ent->getDN(), "\n");
+ my $dir = $ent->getValues('nsslapd-directory');
+ # the default db instance directory is
+ # $oldroot/$inst/$cn
+ debug(1, "old instance $cn dbdir $dir\n");
+ my $srcdir = $dir || "$oldroot/$inst/db/$cn";
+ copyDatabaseDirs($srcdir, "$newdbdir/$cn");
+ } # else just ignore for now
+ }
+ }
+ close DSELDIF;
+}
+
+sub copyChangelogDB {
+ my $oldroot = shift;
+ my $inst = shift;
+ my $newdbdir = shift;
+ # changelog config entry
+ my $cldn = normalizeDN("cn=changelog5, cn=config");
+ my $fname = "$oldroot/$inst/config/dse.ldif";
+ open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
+ my $in = new Mozilla::LDAP::LDIF(*DSELDIF);
+ while (my $ent = readOneEntry $in) {
+ my $targetdn = normalizeDN($ent->getDN());
+ if ($targetdn eq $cldn) {
+ my $oldcldir = $ent->getValues('nsslapd-changelogdir');
+ debug(1, "old cldb dir = $oldcldir\n");
+ my $srcdir = $oldcldir || "$oldroot/$inst/cldb";
+ copyDatabaseDirs($srcdir, $newdbdir);
+ last;
+ }
+ }
+ close DSELDIF;
+}
+
+sub fixAttrsInEntry {
+ my ($ent, $inst) = @_;
+ for my $attr (keys %{$ent}) {
+ my $lcattr = lc $attr;
+ if ($transformAttr{$lcattr}) {
+ $ent->setValues($attr, &{$transformAttr{$lcattr}}($ent, $attr, $inst));
+ }
+ }
+}
+
+sub mergeEntries {
+ my ($old, $new, $inst) = @_;
+ my %inoldonly; # attrs in old entry but not new one
+ my %innewonly; # attrs in new entry but not old one
+ my @attrs; # attrs common to old and new
+ # if the attribute exists in the old entry but not the new one
+ # we should probably add it (checking for special cases first)
+ # if the attribute exists in the new entry but not the old one
+ # we might have to delete it from the new entry
+ # first, get a list of all attributes
+ foreach my $attr (keys %{$old}) {
+ if (! $new->exists($attr)) {
+ $inoldonly{$attr} = $attr;
+ } else {
+ push @attrs, $attr;
+ }
+ }
+ foreach my $attr (keys %{$new}) {
+ if (! $old->exists($attr)) {
+ $innewonly{$attr} = $attr;
+ }
+ }
+
+ # iterate through the attr lists
+ my $cn = lc $new->getValues("cn");
+ foreach my $attr (keys %inoldonly, keys %innewonly, @attrs) {
+ my $lcattr = lc $attr;
+ if ($ignoreOld{$lcattr}) {
+ next; # use new value or just omit if attr is obsolete
+ } elsif ($transformAttr{$lcattr}) {
+ # only transform if the value is in the old entry
+ if (!$innewonly{$attr}) {
+ $new->setValues($attr, &{$transformAttr{$lcattr}}($old, $attr, $inst));
+ }
+ } elsif ($cn eq "internationalization plugin" and $lcattr eq "nsslapd-pluginarg0") {
+ next; # use the new value of this path name
+ } elsif ($cn eq "referential integrity postoperation" and $lcattr eq "nsslapd-pluginarg1") {
+ next; # use the new value of this path name
+ } elsif ($innewonly{$attr}) {
+ $new->remove($attr); # in new but not old - just remove it
+ } else {
+ $new->setValues($attr, $old->getValues($attr)); # use old value
+ }
+ }
+}
+
+sub mergeDseLdif {
+ my $oldroot = shift;
+ my $inst = shift;
+ my $ent;
+
+ # first, read in old file
+ my %olddse; # map of normalized DN to Entry
+ my @olddns; # the DNs in their original order
+ my $fname = "$oldroot/$inst/config/dse.ldif";
+ open( OLDDSELDIF, $fname ) || die "Can't open $fname: $!";
+ my $in = new Mozilla::LDAP::LDIF(*OLDDSELDIF);
+ while ($ent = readOneEntry $in) {
+ my $dn = normalizeDN($ent->getDN());
+ push @olddns, $dn;
+ $olddse{$dn} = $ent;
+ }
+ close OLDDSELDIF;
+
+ # next, read in new file
+ my %newdse; # map of normalized DN to Entry
+ my @newdns; # the DNs in their original order that are not in olddns
+ $fname = "@instconfigdir@/$inst/dse.ldif";
+ open( NEWDSELDIF, $fname ) || die "Can't open $fname: $!";
+ $in = new Mozilla::LDAP::LDIF(*NEWDSELDIF);
+ while ($ent = readOneEntry $in) {
+ my $dn = normalizeDN($ent->getDN());
+ $newdse{$dn} = $ent;
+ if (! exists $olddse{$dn}) {
+ push @newdns, $dn;
+ }
+ }
+ close NEWDSELDIF;
+
+ # temp file for new, merged dse.ldif
+ my ($dsefh, $tmpdse) = tempfile(SUFFIX => '.ldif');
+ # now, compare entries
+ # if the entry exists in the old tree but not the new, add it
+ # if the entry exists in the new tree but not the old, delete it
+ # otherwise, merge the entries
+ # @olddns contains the dns in the old dse.ldif, including ones that
+ # may also be in the new dse.ldif
+ # @newdns contains dns that are only in the new dse.ldif
+ for my $dn (@olddns, @newdns) {
+ my $oldent = $olddse{$dn};
+ my $newent = $newdse{$dn};
+ my $outputent;
+ if ($oldent && !$newent) {
+ # may have to fix up some values in the old entry
+ fixAttrsInEntry($oldent, $inst);
+ # output $oldent
+ $outputent = $oldent;
+ } elsif (!$oldent && $newent) {
+ next if ($dn =~ /o=deleteAfterMigration/i);
+ # output $newent
+ $outputent = $newent;
+ } else { #merge
+ # $newent will contain the merged entry
+ mergeEntries($oldent, $newent, $inst);
+ $outputent = $newent;
+ }
+ # special fix for rootDSE - perldap doesn't like "" for a dn
+ if (! $outputent->getDN()) {
+ my $ary = $outputent->getLDIFrecords();
+ shift @$ary; # remove "dn"
+ shift @$ary; # remove the empty dn value
+ print $dsefh "dn:\n";
+ print $dsefh (Mozilla::LDAP::LDIF::pack_LDIF (78, $ary), "\n");
+ } else {
+ Mozilla::LDAP::LDIF::put_LDIF($dsefh, 78, $outputent);
+ }
+ }
+ close $dsefh;
+
+ return $tmpdse;
+}
+
+sub migrateDS {
+ my $mig = shift;
+ $pkgname = $mig->{pkgname}; # set globals
+ $oldsroot = $mig->{oldsroot}; # set globals
+
+ # for each instance
+ foreach my $inst (@{$mig->{instances}}) {
+ if (-f "@instconfigdir@/$inst/dse.ldif") {
+ $mig->msg($WARN, 'instance_already_exists', "@instconfigdir@/$inst/dse.ldif");
+ next;
+ }
+ # set instance specific defaults
+ my $newdbdir = "@localstatedir@/lib/$pkgname/$inst/db";
+ my $newcertdir = "@instconfigdir@/$inst";
+ my $newcldbdir = "@localstatedir@/lib/$pkgname/$inst/cldb";
+
+ # extract the information needed for ds_newinst.pl
+ my $configdir = "$oldsroot/$inst/config";
+ my $inf = createInfFromConfig($configdir, $inst);
+ debug(2, "Using inffile $inf->{filename} created from $configdir\n");
+
+ # create the new instance
+ my ($rc, $output) = createDSInstance($inf);
+ unlink($inf->{filename});
+ if ($rc) {
+ $mig->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
+ return 0;
+ } else {
+ $mig->msg('created_dsinstance', $output);
+ }
+
+ # copy over the files/directories
+ # copy the databases
+ copyDatabases($oldsroot, $inst, $newdbdir);
+
+ # copy the security related files
+ $mig->migrateSecurityFiles($inst, $newcertdir);
+
+ # copy the repl changelog database
+ copyChangelogDB($oldsroot, $inst, $newcldbdir);
+
+ # merge the old info into the new dse.ldif
+ my $tmpdse = mergeDseLdif($oldsroot, $inst);
+
+ # get user/group of new dse
+ my ($dev, $ino, $mode, $uid, $gid, @rest) = stat "@instconfigdir@/$inst/dse.ldif";
+ # save the original new dse.ldif
+ system("cp -p @instconfigdir@/$inst/dse.ldif @instconfigdir@/$inst/dse.ldif.premigrate");
+ # copy the new one
+ system("cp $tmpdse @instconfigdir@/$inst/dse.ldif");
+ # change owner/group
+ chmod $mode, "@instconfigdir@/$inst/dse.ldif";
+ chown $uid, $gid, "@instconfigdir@/$inst/dse.ldif";
+
+ # remove the temp one
+ unlink($tmpdse);
+ }
+
+ return 1;
+}
+
+#############################################################################
+# Mandatory TRUE return value.
+#
+1;
diff --git a/ldap/admin/src/scripts/Migration.pm.in b/ldap/admin/src/scripts/Migration.pm.in
new file mode 100644
index 000000000..94123d375
--- /dev/null
+++ b/ldap/admin/src/scripts/Migration.pm.in
@@ -0,0 +1,294 @@
+# BEGIN COPYRIGHT BLOCK
+# This Program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2 of the License.
+#
+# This Program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# In addition, as a special exception, Red Hat, Inc. gives You the additional
+# right to link the code of this Program with code not covered under the GNU
+# General Public License ("Non-GPL Code") and to distribute linked combinations
+# including the two, subject to the limitations in this paragraph. Non-GPL Code
+# permitted under this exception must only link to the code of this Program
+# through those well defined interfaces identified in the file named EXCEPTION
+# found in the source code files (the "Approved Interfaces"). The files of
+# Non-GPL Code may instantiate templates or use macros or inline functions from
+# the Approved Interfaces without causing the resulting work to be covered by
+# the GNU General Public License. Only Red Hat, Inc. may make changes or
+# additions to the list of Approved Interfaces. You must obey the GNU General
+# Public License in all respects for all of the Program code and other code used
+# in conjunction with the Program except the Non-GPL Code covered by this
+# exception. If you modify this file, you may extend this exception to your
+# version of the file, but you are not obligated to do so. If you do not wish to
+# provide this exception without modification, you must delete this exception
+# statement from your version and license this file solely under the GPL without
+# exception.
+#
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+###########################
+#
+# This perl module provides a way to set up a new installation after
+# the binaries have already been extracted. This is typically after
+# using native packaging support to install the package e.g. RPM,
+# pkgadd, depot, etc. This script will show the license, readme,
+# dsktune, then run the usual setup pre and post installers.
+#
+##########################
+
+package Migration;
+use Setup;
+
+use Exporter ();
+@ISA = qw(Exporter Setup);
+@EXPORT = qw();
+@EXPORT_OK = qw();
+
+# tempfiles
+use File::Temp qw(tempfile tempdir);
+
+# hostname
+use Net::Domain qw(hostfqdn);
+
+# load perldap
+use Mozilla::LDAP::Conn;
+use Mozilla::LDAP::Utils qw(normalizeDN);
+use Mozilla::LDAP::API qw(ldap_explode_dn);
+use Mozilla::LDAP::LDIF;
+
+use Getopt::Long;
+
+use File::Temp qw(tempfile tempdir);
+
+use SetupLog;
+use Util;
+
+# process command line options
+Getopt::Long::Configure(qw(bundling)); # bundling allows -ddddd
+
+sub VersionMessage {
+ print "@capbrand@ Directory Server Migration Program Version @PACKAGE_VERSION@\n";
+}
+
+sub HelpMessage {
+ print <<EOF;
+
+INTRODUCTION
+
+This script will copy instances (data and configuration) from the old
+server root directory to their new FHS locations. This script does a
+copy only - the data in the old instances will be left untouched. The
+old instances must be shutdown first to ensure that the databases are
+copied safely. The new instances will not be started by migration,
+but can be started after running migration.
+
+USAGE
+
+ $0 [--options] -- [args]
+
+options:
+ --help This message
+ --version Print the version and exit
+ --debug Turn on debugging
+ --oldsroot The old server root directory to migrate from
+ --actualsroot This is the old location of the old server root. See below.
+ --silent Use silent setup - no user input
+ --file=name Use the file 'name' in .inf format to supply the default answers
+ --keepcache Do not delete the temporary .inf file generated by this program
+ --logfile Log migration messages to this file - otherwise, a temp file will be used
+ --instance By default, all directory server instances will be migrated. You can use
+ this argument to specify one or more (e.g. -i slapd-foo -i slapd-bar) if
+ you do not want to migrate all of them.
+For all options, you can also use the short name e.g. -h, -d, etc. For the -d argument,
+specifying it more than once will increase the debug level e.g. -ddddd
+
+args:
+You can supply default .inf data in this format:
+ section.param=value
+e.g.
+ General.FullMachineName=foo.example.com
+or
+ "slapd.Suffix=dc=example, dc=com"
+Values passed in this manner will override values in an .inf file given with the -f argument.
+
+actualsroot:
+This is used when you must migrate from one machine to another. The
+usual case is that you have mounted the old server root on a different
+root directory, either via a network mount, or by copying a tarball
+made using a relative directory on the source machine to the
+destination machine and untarring it.
+
+For example: machineA is a 32bit machine, and you want to migrate your
+servers to a new 64bit machine. Lets assume your old server root on
+machineA was /opt/myds, and your new machine also wants to use a
+server root of /opt/myds. There are a couple of different ways to
+proceed. Either make a tarball of opt/myds from machineA using a
+relative path (i.e. NOT /opt/myds) or use NFS to mount
+machineA:/opt/myds on a different mount point
+(e.g. machineB:/migration/opt/myds).
+
+If you do this, you should give the old "real" server root (/opt/myds)
+as the --actualsroot argument, and use /migration/opt/myds for the
+--oldsroot argument. That is, the oldsroot is the physical location of
+the files on disk. The actualsroot is the old value of the server root
+on the source machine.
+EOF
+}
+
+sub init {
+ my $self = shift;
+ $self->{res} = shift;
+ my ($silent, $inffile, $keep, $preonly, $logfile, $oldsroot, $actualsroot);
+ my @instances;
+
+ GetOptions('help|h|?' => sub { VersionMessage(); HelpMessage(); exit 0 },
+ 'version|v' => sub { VersionMessage(); exit 0 },
+ 'debug|d+' => \$Util::debuglevel,
+ 'silent|s' => \$silent,
+ 'file|f=s' => \$inffile,
+ 'keepcache|k' => \$keep,
+ 'preonly|p' => \$preonly,
+ 'logfile|l=s' => \$logfile,
+ 'oldsroot|o=s' => \$oldsroot,
+ 'actualsroot|a=s' => \$actualsroot,
+ 'instance|i=s' => \@instances
+ );
+
+ my $pkgname = "@package_name@";
+ # this is the new pkgname which may be something like
+ # fedora-ds-base - we have to strip off the -suffix
+ if ($pkgname =~ /-(core|base)$/) {
+ $pkgname =~ s/-(core|base)$//;
+ }
+ my $oldpkgname = $pkgname;
+
+ $self->{pkgname} = $pkgname;
+ $self->{oldsroot} = $oldsroot || "/opt/$oldpkgname";
+ $self->{actualsroot} = $actualsroot || $oldsroot;
+ $self->{silent} = $silent;
+ $self->{inffile} = $inffile;
+ $self->{keep} = $keep;
+ $self->{preonly} = $preonly;
+ $self->{logfile} = $logfile;
+ $self->{log} = new SetupLog($self->{logfile}, "migrate");
+ # if user supplied inf file, use that to initialize
+ if (defined($self->{inffile})) {
+ $self->{inf} = new Inf($self->{inffile});
+ } else {
+ $self->{inf} = new Inf;
+ }
+ my $fh;
+ # create a temp inf file for writing for other processes
+ # never overwrite the user supplied inf file
+ ($fh, $self->{inffile}) = tempfile("migrateXXXXXX", UNLINK => !$keep,
+ SUFFIX => ".inf", OPEN => 0,
+ DIR => File::Spec->tmpdir);
+ $self->{inf}->{filename} = $self->{inffile};
+
+ # see if user passed in default inf values - also, command line
+ # arguments override those passed in via an inf file - this
+ # allows the reuse of .inf files with some parameters overridden
+ for (@ARGV) {
+ if (/^([\w_-]+)\.([\w_-]+)=(.*)$/) { # e.g. section.param=value
+ $self->{inf}->{$1}->{$2} = $3;
+ } else { # error
+ print STDERR "Error: unknown command line option $_\n";
+ usage();
+ exit 1;
+ }
+ }
+
+ # this is the base config directory - the directory containing
+ # the slapd-instance instance specific config directories
+ $self->{configdir} = $ENV{DS_CONFIG_DIR} || "@instconfigdir@";
+
+ # get list of instances to migrate
+ if (! @instances) {
+ # an instance must be a directory called $oldsroot/slapd-something and the file
+ # $oldsroot/slapd-something/config/dse.ldif must exist
+ @instances = grep { -d && -f "$_/config/dse.ldif" && ($_ =~ s,$self->{oldsroot}/,,) }
+ glob("$self->{oldsroot}/slapd-*");
+ }
+
+ die "No instances found to migrate" unless (@instances);
+
+ $self->{instances} = \@instances;
+}
+
+sub doExit {
+ my $self = shift;
+ $self->msg($FATAL, 'migration_exiting', $self->{log}->{filename});
+ exit 1;
+}
+
+sub migrateSecurityFiles {
+ my $self = shift;
+ my $inst = shift;
+ my $destdir = shift;
+ my $oldroot = $self->{oldsroot};
+
+ if (! -d "$oldroot/alias") {
+ $self->msg('old_secdir_error', "$oldroot/alias", $!);
+ return 0;
+ } elsif (! -d $destdir) {
+ $self->msg('new_secdir_error', $destdir, $!);
+ return 0;
+ } else {
+ $self->log($INFO, "Copying $oldroot/alias/$inst-cert8.db to $destdir/cert8.db\n");
+ if (system ("cp -p $oldroot/alias/$inst-cert8.db $destdir/cert8.db")) {
+ $self->msg($FATAL, 'error_copying_certdb', "$oldroot/alias/$inst-cert8.db",
+ "$destdir/cert8.db", $!);
+ return 0;
+ }
+ $self->log($INFO, "Copying $oldroot/alias/$inst-key3.db to $destdir/key3.db\n");
+ if (system ("cp -p $oldroot/alias/$inst-key3.db $destdir/key3.db")) {
+ $self->msg($FATAL, 'error_copying_keydb', "$oldroot/alias/$inst-key3.db",
+ "$destdir/key3.db", $!);
+ return 0;
+ }
+ $self->log($INFO, "Copying $oldroot/alias/secmod.db to $destdir/secmod.db\n");
+ if (system ("cp -p $oldroot/alias/secmod.db $destdir/secmod.db")) {
+ $self->msg($FATAL, 'error_copying_secmoddb', "$oldroot/alias/secmod.db",
+ "$destdir/secmod.db", $!);
+ return 0;
+ }
+ if (-f "$oldroot/alias/$inst-pin.txt") {
+ $self->log($INFO, "Copying $oldroot/alias/$inst-pin.txt to $destdir/pin.txt\n");
+ if (system ("cp -p $oldroot/alias/$inst-pin.txt $destdir/pin.txt")) {
+ $self->msg($FATAL, 'error_copying_pinfile', "$oldroot/alias/$inst-pin.txt",
+ "$destdir/pin.txt", $!);
+ return 0;
+ }
+ } else {
+ $self->log($INFO, "No $oldroot/alias/$inst-pin.txt to migrate\n");
+ }
+
+ if (-f "$oldroot/shared/config/certmap.conf") {
+ $self->log($INFO, "Copying $oldroot/shared/config/certmap.conf to $destdir/certmap.conf\n");
+ if (system ("cp -p $oldroot/shared/config/certmap.conf $destdir/certmap.conf")) {
+ $self->msg($FATAL, 'error_copying_certmap', "$oldroot/shared/config/certmap.conf",
+ "$destdir/certmap.conf", $!);
+ return 0;
+ }
+ } else {
+ $self->log($INFO, "No $oldroot/shared/config/certmap.conf to migrate\n");
+ }
+ }
+
+ return 1;
+}
+
+#############################################################################
+# Mandatory TRUE return value.
+#
+1;
diff --git a/ldap/admin/src/scripts/Setup.pm.in b/ldap/admin/src/scripts/Setup.pm.in
index 1aae1a790..93d532910 100644
--- a/ldap/admin/src/scripts/Setup.pm.in
+++ b/ldap/admin/src/scripts/Setup.pm.in
@@ -69,6 +69,11 @@ use Getopt::Long;
use File::Temp qw(tempfile tempdir);
use SetupLog;
+use Util;
+use Inf;
+
+use strict;
+use vars qw($EXPRESS $TYPICAL $CUSTOM $SILENT);
# the setup types
$EXPRESS = 1;
@@ -111,13 +116,19 @@ EOF
sub new {
my $type = shift;
my $self = {};
+ $self = bless $self, $type;
+ $self->init(@_);
+ return $self;
+}
+
+sub init {
+ my $self = shift;
$self->{res} = shift;
- my ($debuglevel, $silent, $inffile, $keep, $preonly, $logfile);
- my @otherargs;
+ my ($silent, $inffile, $keep, $preonly, $logfile);
GetOptions('help|h|?' => sub { VersionMessage(); HelpMessage(); exit 0 },
'version|v' => sub { VersionMessage(); exit 0 },
- 'debug|d+' => \$debuglevel,
+ 'debug|d+' => \$Util::debuglevel,
'silent|s' => \$silent,
'file|f=s' => \$inffile,
'keepcache|k' => \$keep,
@@ -125,7 +136,6 @@ sub new {
'logfile|l=s' => \$logfile
);
- $self->{debuglevel} = $debuglevel;
$self->{silent} = $silent;
$self->{inffile} = $inffile;
$self->{keep} = $keep;
@@ -162,9 +172,6 @@ sub new {
# this is the base config directory - the directory containing
# the slapd-instance instance specific config directories
$self->{configdir} = $ENV{DS_CONFIG_DIR} || "@instconfigdir@";
-
- $self = bless $self, $type;
- return $self;
}
# log only goes the the logfile
diff --git a/ldap/admin/src/scripts/SetupLog.pm b/ldap/admin/src/scripts/SetupLog.pm
index 4eaa7b7cb..f51329fc3 100644
--- a/ldap/admin/src/scripts/SetupLog.pm
+++ b/ldap/admin/src/scripts/SetupLog.pm
@@ -59,11 +59,12 @@ $DEBUG = "Debug";
sub new {
my $type = shift;
my $filename = shift;
+ my $prefix = shift || "setup";
my $self = {};
my $fh;
if (!$filename) {
- ($fh, $filename) = tempfile("setupXXXXXX", UNLINK => 0,
+ ($fh, $filename) = tempfile("${prefix}XXXXXX", UNLINK => 0,
SUFFIX => ".log", DIR => File::Spec->tmpdir);
} else {
open LOGFILE, ">$filename" or die "Error: could not open logfile $filename: $!";
diff --git a/ldap/admin/src/scripts/Util.pm.in b/ldap/admin/src/scripts/Util.pm.in
index 740cd39b3..008b42105 100644
--- a/ldap/admin/src/scripts/Util.pm.in
+++ b/ldap/admin/src/scripts/Util.pm.in
@@ -47,15 +47,28 @@ require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword);
+ getHashedPassword debug createDSInstance createInfFromConfig);
@EXPORT_OK = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword);
+ getHashedPassword debug createDSInstance createInfFromConfig);
use strict;
use Socket;
+use File::Temp qw(tempfile tempdir);
+
+$Util::debuglevel = 0;
+# use like this:
+# debug(3, "message");
+# this will only print "message" if $debuglevel is 3 or higher (-ddd on the command line)
+sub debug {
+ my ($level, @rest) = @_;
+ if ($level <= $Util::debuglevel) {
+ print STDERR "+" x $level, @rest;
+ }
+}
+
# return true if the given port number is available, false otherwise
sub portAvailable {
my $port = shift;
@@ -89,10 +102,6 @@ sub isValidDN {
return ($dn =~ /^[0-9a-zA-Z_-]+=.*$/);
}
-sub debug {
-# print @_, "\n";
-}
-
# delete the subtree starting from the passed entry
sub delete_all
{
@@ -217,9 +226,18 @@ sub check_and_add_entry
my $verbose = $context->[2];
my @ctypes = $aentry->getValues("changetype");
my $sentry = $conn->search($aentry->{dn}, "base", "(objectclass=*)", 0, ("*", "aci"));
+ if ($sentry) {
+ debug(3, "check_and_add_entry: Found entry " . $sentry->getDN() . "\n");
+ } else {
+ debug(3, "check_and_add_entry: Entry not found " . $aentry->{dn} .
+ " error " . $conn->getErrorString() . "\n");
+ }
do
{
my $needtoadd;
+ my @addtypes; # list of attr types for mod add
+ my @reptypes; # list of attr types for mod replace
+ my @deltypes; # list of attr types for mod delete
my $MOD_NONE = 0;
my $MOD_ADD = 1;
my $MOD_REPLACE = 2;
@@ -248,19 +266,18 @@ sub check_and_add_entry
{
$needtoadd = 0;
$needtomod = $MOD_ADD;
+ @addtypes = keys %{$aentry}; # add all attrs
}
elsif ( $sentry && $sentry->{dn} )
{
# $fresh || $rc == -1
# an entry having the same DN exists, but the attributes do not
# match. remove the entry and the subtree underneath.
- if ( $verbose )
- {
- print "Deleting an entry dn: $sentry->{dn} ...\n";
- }
+ debug(1, "Deleting an entry dn: $sentry->{dn} ...\n");
$rc = delete_all($conn, $sentry);
if ( 0 != $rc )
{
+ debug(1, "Error deleting $sentry->{dn}\n");
return 0;
}
}
@@ -270,28 +287,10 @@ sub check_and_add_entry
$needtoadd = 0;
if ( $sentry )
{
- my @atypes = $aentry->getValues("add");
- if ( 0 <= $#atypes )
- {
- $needtomod = $MOD_ADD;
- }
- else
- {
- @atypes = $aentry->getValues("replace");
- if ( 0 <= $#atypes )
- {
- $needtomod = $MOD_REPLACE;
- }
- else
- {
- @atypes = $aentry->getValues("delete");
- if ( 0 <= $#atypes )
- {
- print "\"delete\" is not supported; ignoring...\n";
- }
- $needtomod = $MOD_NONE;
- }
- }
+ @addtypes = $aentry->getValues("add");
+ @reptypes = $aentry->getValues("replace");
+ @deltypes = $aentry->getValues("delete");
+ $needtomod = $MOD_REPLACE;
}
else
{
@@ -305,63 +304,62 @@ sub check_and_add_entry
my $rc = $conn->getErrorCode();
if ( $rc != 0 )
{
- print "ERROR: adding an entry $aentry->{dn} failed, error code: $rc\n";
+ my $string = $conn->getErrorString();
+ print "ERROR: adding an entry $aentry->{dn} failed, error: $string\n";
print "[entry]\n";
$aentry->printLDIF();
$conn->close();
return 0;
}
- debug("Entry $aentry->{dn} is added\n");
+ debug(1, "Entry $aentry->{dn} is added\n");
}
elsif ( 0 < $needtomod ) # $sentry exists
{
+ my $attr;
if ( $needtomod == $MOD_SPECIAL )
{
- foreach my $attr ( keys %speciallist )
+ debug(3, "Doing MOD_SPECIAL for entry $aentry->{dn}\n");
+ foreach $attr ( keys %speciallist )
{
foreach my $nval ( @{$aentry->{$attr}} )
{
$sentry->addValue( $attr, $nval );
}
}
- $conn->update($sentry);
}
- elsif ( $needtomod == $MOD_ADD )
+ foreach $attr ( @addtypes )
{
- foreach my $attr ( keys %{$aentry} )
- {
- next if $attr =~ /add|changetype/;
- foreach my $nval ( @{$aentry->{$attr}} )
- {
- $sentry->addValue( $attr, $nval );
- }
- }
- $conn->update($sentry);
+ debug(3, "Adding attr=$attr values=" . $aentry->getValues($attr) . " to entry $aentry->{dn}\n");
+ $sentry->addValue( $attr, $aentry->getValues($attr) );
}
- elsif ( $needtomod == $MOD_REPLACE )
+ foreach $attr ( @reptypes )
{
- my $entry = new Mozilla::LDAP::Entry();
- $entry->setDN($aentry->getDN());
- foreach my $attr ( keys %{$aentry} )
+ debug(3, "Replacing attr=$attr values=" . $aentry->getValues($attr) . " to entry $aentry->{dn}\n");
+ $sentry->setValues($attr, $aentry->getValues($attr));
+ }
+ foreach $attr ( @deltypes )
+ {
+ # removeValue takes a single value only
+ if (!$aentry->size($attr))
{
- next if $attr =~ /replace|changetype/;
- foreach my $nval ( @{$aentry->{$attr}} )
+ debug(3, "Deleting attr=$attr from entry $aentry->{dn}\n");
+ $sentry->remove($attr); # just delete the attribute
+ }
+ else
+ {
+ debug(3, "Deleting attr=$attr values=" . $aentry->getValues($attr) . " from entry $aentry->{dn}\n");
+ foreach my $val ($aentry->getValues($attr))
{
- $entry->addValue( $attr, $nval );
+ $sentry->removeValue($attr, $val);
}
}
- $conn->update($entry);
- }
- else
- {
- print "ERROR: needtomod == $needtomod is not supported.\n";
- $conn->close();
- return 0;
}
+ $conn->update($sentry);
my $rc = $conn->getErrorCode();
if ( $rc != 0 )
{
- print "ERROR: updating an entry $sentry->{dn} failed, error code: $rc\n";
+ my $string = $conn->getErrorString();
+ print "ERROR: updating an entry $sentry->{dn} failed, error: $string\n";
print "[entry]\n";
$aentry->printLDIF();
$conn->close();
@@ -455,7 +453,7 @@ sub getMappedEntries {
foreach my $ldiffile (@{$ldiffiles}) {
open(MYLDIF, "< $ldiffile") or die "Can't open $ldiffile : $!";
my $in = new Mozilla::LDAP::LDIF(*MYLDIF);
- debug("Processing $ldiffile ...");
+ debug(1, "Processing $ldiffile ...\n");
ENTRY: while (my $entry = Mozilla::LDAP::LDIF::readOneEntry($in)) {
# first, fix the DN
my $dn = $entry->getDN();
@@ -709,4 +707,55 @@ sub getHashedPassword {
return $hashedpwd;
}
+sub createDSInstance {
+ my $inf = shift;
+# find ds_newinst.pl - in same directory as this script or in PATH
+ my $ds_newinst;
+ ($ds_newinst = $0) =~ s|/[^/]+$|/ds_newinst.pl|;
+ if (! -x $ds_newinst) {
+ $ds_newinst = "@bindir@/ds_newinst.pl";
+ }
+ if (! -x $ds_newinst) {
+ $ds_newinst = "ds_newinst.pl"; # just get from path
+ }
+ $? = 0; # clear error condition
+ my $output = `$ds_newinst $inf->{filename}`;
+ return ($?, $output);
+}
+
+# this creates an Inf suitable for passing to createDSInstance
+sub createInfFromConfig {
+ my $configdir = shift;
+ my $inst = shift;
+ my $fname = "$configdir/dse.ldif";
+ my $id;
+ ($id = $inst) =~ s/^slapd-//;
+ open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
+ my ($outfh, $inffile) = tempfile(SUFFIX => '.inf');
+ my $in = new Mozilla::LDAP::LDIF(*DSELDIF) ;
+ while (my $ent = readOneEntry $in) {
+ my $dn = $ent->getDN();
+ if ($dn =~ /cn=config/) {
+ print $outfh "[General]\n";
+ print $outfh "FullMachineName = ", $ent->getValues('nsslapd-localhost'), "\n";
+ print $outfh "SuiteSpotUserID = ", $ent->getValues('nsslapd-localuser'), "\n";
+ print $outfh "ServerRoot = @serverdir@\n";
+ print $outfh "[slapd]\n";
+ print $outfh "RootDN = ", $ent->getValues('nsslapd-rootdn'), "\n";
+ print $outfh "RootDNPwd = ", $ent->getValues('nsslapd-rootpw'), "\n";
+ print $outfh "ServerPort = ", $ent->getValues('nsslapd-port'), "\n";
+ print $outfh "ServerIdentifier = $id\n";
+ print $outfh "Suffix = o=deleteAfterMigration\n";
+ print $outfh "start_server= 0\n";
+ last;
+ }
+ }
+ close $outfh;
+ close DSELDIF;
+
+ my $inf = new Inf($inffile);
+
+ return $inf;
+}
+
1;
diff --git a/ldap/admin/src/scripts/migrate-ds.pl.in b/ldap/admin/src/scripts/migrate-ds.pl.in
new file mode 100644
index 000000000..e11d810c2
--- /dev/null
+++ b/ldap/admin/src/scripts/migrate-ds.pl.in
@@ -0,0 +1,65 @@
+#!/usr/bin/env perl
+# BEGIN COPYRIGHT BLOCK
+# This Program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2 of the License.
+#
+# This Program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# In addition, as a special exception, Red Hat, Inc. gives You the additional
+# right to link the code of this Program with code not covered under the GNU
+# General Public License ("Non-GPL Code") and to distribute linked combinations
+# including the two, subject to the limitations in this paragraph. Non-GPL Code
+# permitted under this exception must only link to the code of this Program
+# through those well defined interfaces identified in the file named EXCEPTION
+# found in the source code files (the "Approved Interfaces"). The files of
+# Non-GPL Code may instantiate templates or use macros or inline functions from
+# the Approved Interfaces without causing the resulting work to be covered by
+# the GNU General Public License. Only Red Hat, Inc. may make changes or
+# additions to the list of Approved Interfaces. You must obey the GNU General
+# Public License in all respects for all of the Program code and other code used
+# in conjunction with the Program except the Non-GPL Code covered by this
+# exception. If you modify this file, you may extend this exception to your
+# version of the file, but you are not obligated to do so. If you do not wish to
+# provide this exception without modification, you must delete this exception
+# statement from your version and license this file solely under the GPL without
+# exception.
+#
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+###########################
+#
+# This perl module provides a way to set up a new installation after
+# the binaries have already been extracted. This is typically after
+# using native packaging support to install the package e.g. RPM,
+# pkgadd, depot, etc. This script will show the license, readme,
+# dsktune, then run the usual setup pre and post installers.
+#
+##########################
+
+use lib '@perldir@';
+
+use strict;
+
+use DSMigration;
+use Migration;
+use Resource;
+
+my $res = new Resource("@propertydir@/migrate-ds.res",
+ "@propertydir@/setup-ds.res");
+
+my $mig = new Migration($res);
+
+$mig->msg('begin_ds_migration', $mig->{oldsroot});
+migrateDS($mig);
+$mig->msg('end_ds_migration');
diff --git a/ldap/admin/src/scripts/migrate-ds.res b/ldap/admin/src/scripts/migrate-ds.res
new file mode 100644
index 000000000..e0eec6985
--- /dev/null
+++ b/ldap/admin/src/scripts/migrate-ds.res
@@ -0,0 +1,4 @@
+begin_ds_migration = Beginning migration of directory server instances in %s . . .\n
+end_ds_migration = Directory server migration is complete. Please check output and log files for details.\n
+migration_exiting = Exiting . . .\nLog file is '%s'\n\n
+instance_already_exists = The target directory server instance already exists at %s. Skipping migration.\n\
diff --git a/ldap/admin/src/scripts/setup-ds.pl.in b/ldap/admin/src/scripts/setup-ds.pl.in
index f73258ac8..0117bdefb 100644
--- a/ldap/admin/src/scripts/setup-ds.pl.in
+++ b/ldap/admin/src/scripts/setup-ds.pl.in
@@ -45,6 +45,7 @@ use Setup;
use Inf;
use Resource;
use DialogManager;
+use Util;
my $res = new Resource("@propertydir@/setup-ds.res");
@@ -68,6 +69,11 @@ if (!$setup->{silent}) {
$setup->{inf}->write();
}
-system("@bindir@/ds_newinst.pl $setup->{inffile}");
+my ($rc, $output) = createDSInstance($setup->{inf});
+if ($rc) {
+ $setup->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
+} else {
+ $setup->msg('created_dsinstance', $output);
+}
$setup->doExit();
diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in
index 1915be3c7..3c6b6fa8a 100644
--- a/ldap/admin/src/scripts/setup-ds.res.in
+++ b/ldap/admin/src/scripts/setup-ds.res.in
@@ -87,3 +87,5 @@ error_creating_suffix_backend = Could not create the suffix '%s'. There was an
error_creating_suffix = Could not create the suffix '%s'. Error: %s\n\n
setup_exiting = Exiting . . .\nLog file is '%s'\n\n
+error_creating_dsinstance = Error: Could not create directory server instance. Error code %s. Output:\n%s\n
+created_dsinstance = Your new DS instance was successfully created. Output:\n%s\n
| 0 |
6963780bd89a37b758799ec390983db5392b596f
|
389ds/389-ds-base
|
Ticket 50213 - fix list instance issue
Bug Description: A format string would not always be created
which caused instance list to fail. This may lead to instance
removal failing (creation and api removal still functioned)
Fix Description: Use a correctly initialised paths object, and
add extra debugging around the list capability for -v
https://pagure.io/389-ds-base/issue/50213
Author: William Brown <[email protected]>
Review by: mreynolds (Thanks)
|
commit 6963780bd89a37b758799ec390983db5392b596f
Author: William Brown <[email protected]>
Date: Mon Feb 25 11:37:53 2019 +1000
Ticket 50213 - fix list instance issue
Bug Description: A format string would not always be created
which caused instance list to fail. This may lead to instance
removal failing (creation and api removal still functioned)
Fix Description: Use a correctly initialised paths object, and
add extra debugging around the list capability for -v
https://pagure.io/389-ds-base/issue/50213
Author: William Brown <[email protected]>
Review by: mreynolds (Thanks)
diff --git a/src/lib389/cli/dsctl b/src/lib389/cli/dsctl
index cad37aebb..a6df24118 100755
--- a/src/lib389/cli/dsctl
+++ b/src/lib389/cli/dsctl
@@ -103,7 +103,7 @@ if __name__ == '__main__':
log.error("Unable to access instance information. Are you running as root or dirsrv?")
sys.exit(1)
if len(insts) != 1:
- log.error("No such instance %s" % args.instance)
+ log.error("No such instance '%s': this may be a permission issue." % args.instance)
sys.exit(1)
inst.allocate(insts[0])
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 1d0d693c3..470d252a8 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -753,7 +753,14 @@ class DirSrv(SimpleLDAPObject, object):
# now prepare the list of instances properties
if not all:
- dse_ldif = os.path.join(self.ds_paths.config_dir, 'dse.ldif')
+ # Don't use self.ds_paths here, because it has no server id : this
+ # causes the config_dir to have a formatting issue.
+ #
+ # As dse.ldif is one of the only fixed locations in the server, this is
+ # okay to use this without parsing of dse.ldif to add the other paths
+ # required: yet.
+ inst_paths = Paths(serverid)
+ dse_ldif = os.path.join(inst_paths.config_dir, 'dse.ldif')
# easy case we just look for the current instance
if os.path.exists(dse_ldif):
# It's real
@@ -761,7 +768,7 @@ class DirSrv(SimpleLDAPObject, object):
instances.append(_parse_configfile(dse_ldif, serverid))
else:
# it's not
- self.log.debug("list instance not found: %s\n", serverid)
+ self.log.debug("list instance not found: %s -> %s\n" % (serverid, dse_ldif))
else:
# For each dir that starts with slapd-*
diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
index 9e7f3eea0..c5d662261 100644
--- a/src/lib389/lib389/instance/remove.py
+++ b/src/lib389/lib389/instance/remove.py
@@ -36,10 +36,7 @@ def remove_ds_instance(dirsrv, force=False):
"""
_log = dirsrv.log.getChild('remove_ds')
_log.debug("Removing instance %s" % dirsrv.serverid)
- # Stop the instance (if running)
- _log.debug("Stopping instance %s" % dirsrv.serverid)
- dirsrv.stop()
- # Copy all the paths we are about to tamp with
+ # Copy all the paths we are about to tamper with
remove_paths = {}
remove_paths['backup_dir'] = dirsrv.ds_paths.backup_dir
remove_paths['cert_dir'] = dirsrv.ds_paths.cert_dir
@@ -54,13 +51,13 @@ def remove_ds_instance(dirsrv, force=False):
remove_paths['lock_dir'] = dirsrv.ds_paths.lock_dir
remove_paths['log_dir'] = dirsrv.ds_paths.log_dir
# remove_paths['run_dir'] = dirsrv.ds_paths.run_dir
- remove_paths['tmpfiles_d'] = dirsrv.ds_paths.tmpfiles_d + "/dirsrv-" + dirsrv.serverid + ".conf"
remove_paths['inst_dir'] = dirsrv.ds_paths.inst_dir
remove_paths['etc_sysconfig'] = "%s/sysconfig/dirsrv-%s" % (dirsrv.ds_paths.sysconf_dir, dirsrv.serverid)
+ tmpfiles_d_path = dirsrv.ds_paths.tmpfiles_d + "/dirsrv-" + dirsrv.serverid + ".conf"
+
# These are handled in a special way.
- etc_dirsrv_path = os.path.join(dirsrv.ds_paths.sysconf_dir, 'dirsrv/')
- dse_ldif_path = os.path.join(etc_dirsrv_path, 'dse.ldif')
+ dse_ldif_path = os.path.join(dirsrv.ds_paths.config_dir, 'dse.ldif')
# Check the marker exists. If it *does not* warn about this, and say that to
# force removal you should touch this file.
@@ -70,6 +67,12 @@ def remove_ds_instance(dirsrv, force=False):
_log.info("Instance configuration not found, no action will be taken")
_log.info("If you want us to cleanup anyway, recreate '%s'" % dse_ldif_path)
return
+ _log.debug("Found instance marker at %s! Proceeding to remove ..." % dse_ldif_path)
+
+ # Stop the instance (if running) and now we know it really does exist
+ # and hopefully have permission to access it ...
+ _log.debug("Stopping instance %s" % dirsrv.serverid)
+ dirsrv.stop()
### ANY NEW REMOVAL ACTION MUST BE BELOW THIS LINE!!!
@@ -89,6 +92,9 @@ def remove_ds_instance(dirsrv, force=False):
_log.debug("Removing the systemd symlink")
subprocess.check_call(["systemctl", "disable", "dirsrv@{}".format(dirsrv.serverid)])
+ _log.debug("Removing %s" % tmpfiles_d_path)
+ shutil.rmtree(tmpfiles_d_path, ignore_errors=True)
+
# Nor can we assume we have selinux. Try docker sometime ;)
if dirsrv.ds_paths.with_selinux:
# Remove selinux port label
| 0 |
fae006821bd6e524c0f7f8d5f023f4fe5e160ef0
|
389ds/389-ds-base
|
Ticket #47313 - Indexed search with filter containing '&' and "!" with attribute subtypes gives wrong result
Bug description: Index db files do not contain the subtype knowledge,
which is only in the primary id2entry db and entries in the memory.
If the search filter includes subtype in the NOT condition and
the type is indexed, the condition is mistakenly simplified to
the one equivalent to not having the subtype.
E.g., if the given filter is (&(cn=A*)(!(cn;fr=ABC en)), it's
evaluated as (&(cn=A*)(!(cn=ABC en)).
Fix description: If a filter contains a subtype in NOT condition,
we give up using the index and leave the not evaluation to the
search return code.
Reviewed by Rich (Thank you!!)
https://fedorahosted.org/389/ticket/47313
|
commit fae006821bd6e524c0f7f8d5f023f4fe5e160ef0
Author: Noriko Hosoi <[email protected]>
Date: Wed Apr 17 14:55:56 2013 -0700
Ticket #47313 - Indexed search with filter containing '&' and "!" with attribute subtypes gives wrong result
Bug description: Index db files do not contain the subtype knowledge,
which is only in the primary id2entry db and entries in the memory.
If the search filter includes subtype in the NOT condition and
the type is indexed, the condition is mistakenly simplified to
the one equivalent to not having the subtype.
E.g., if the given filter is (&(cn=A*)(!(cn;fr=ABC en)), it's
evaluated as (&(cn=A*)(!(cn=ABC en)).
Fix description: If a filter contains a subtype in NOT condition,
we give up using the index and leave the not evaluation to the
search return code.
Reviewed by Rich (Thank you!!)
https://fedorahosted.org/389/ticket/47313
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c
index 9dc9cbf15..865f8ab50 100644
--- a/ldap/servers/slapd/back-ldbm/filterindex.c
+++ b/ldap/servers/slapd/back-ldbm/filterindex.c
@@ -630,6 +630,27 @@ done:
return idl;
}
+/*
+ * If the filter type contains subtype, it returns 1; otherwise, returns 0.
+ */
+static int
+filter_is_subtype(Slapi_Filter *f)
+{
+ char *p = NULL;
+ size_t len = 0;
+ int issubtype = 0;
+ if (f) {
+ p = strchr(f->f_type, ';');
+ if (p) {
+ len = p - f->f_type;
+ if (len < strlen(f->f_type)) {
+ issubtype = 1;
+ }
+ }
+ }
+ return issubtype;
+}
+
static IDList *
list_candidates(
Slapi_PBlock *pb,
@@ -777,7 +798,17 @@ list_candidates(
/* Fetch the IDL for foo */
/* Later we'll remember to call idl_notin() */
LDAPDebug( LDAP_DEBUG_TRACE,"NOT filter\n", 0, 0, 0 );
- tmp = ava_candidates( pb, be, slapi_filter_list_first(f), LDAP_FILTER_EQUALITY, nextf, range, err, allidslimit );
+ if (filter_is_subtype(slapi_filter_list_first(f))) {
+ /*
+ * If subtype is included in the filter (e.g., !(cn;fr=<CN>)),
+ * we have to give up using the index since the subtype info
+ * is not in the index.
+ */
+ tmp = idl_allids( be );
+ } else {
+ tmp = ava_candidates(pb, be, slapi_filter_list_first(f),
+ LDAP_FILTER_EQUALITY, nextf, range, err, allidslimit);
+ }
} else {
if (fpairs[0] == f)
{
@@ -819,9 +850,13 @@ list_candidates(
break; /* We can exit the loop now, since the candidate list is small already */
}
} else if ( ftype == LDAP_FILTER_AND ) {
- if (isnot) {
+ if (isnot && !idl_is_allids(tmp)) {
IDList *new_idl = NULL;
int notin_result = 0;
+ /*
+ * If the given tmp is ALLIDs (due to subtype in filter),
+ * we cannot use idl_notin.
+ */
notin_result = idl_notin( be, idl, tmp, &new_idl );
if (notin_result) {
idl_free(idl);
| 0 |
26389ff6f960898a1e5cd623a10742c17449f22d
|
389ds/389-ds-base
|
Pull svrcore from sbc
|
commit 26389ff6f960898a1e5cd623a10742c17449f22d
Author: Nathan Kinder <[email protected]>
Date: Thu Mar 17 15:27:43 2005 +0000
Pull svrcore from sbc
diff --git a/components.mk b/components.mk
index ac6e0d138..236ffb115 100644
--- a/components.mk
+++ b/components.mk
@@ -375,8 +375,8 @@ SVRCORE_INCDIR = $(SVRCORE_BUILD_DIR)/include
SVRCORE_INCLUDE = -I$(SVRCORE_INCDIR)
#SVRCORE_LIBNAMES = svrplcy svrcore
SVRCORE_LIBNAMES = svrcore
-#SVRCORE_IMPORT = $(COMPONENTS_DIR)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
-SVRCORE_IMPORT = $(COMPONENTS_DIR_DEV)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
+SVRCORE_IMPORT = $(COMPONENTS_DIR)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
+#SVRCORE_IMPORT = $(COMPONENTS_DIR_DEV)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
ifeq ($(ARCH), WINNT)
SVRCOREOBJNAME = $(addsuffix .lib, $(SVRCORE_LIBNAMES))
| 0 |
06db4a85eb87e9bc7226fd1758307eca3f5f0d24
|
389ds/389-ds-base
|
Issue 4654 Updates to tickets/ticket48234_test.py (#4654)
* IDMDS-1068 Update failing ticket48234_test.py test
* IDMDS-1068 Update failing ticket48234_test.py test
* [INTEROP-4009] CodeReady Studio on OpenShift - Run locally
* [INTEROP-4009] CodeReady Studio on OpenShift - Run locally
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 - Updates to tickets/ticket48234_test.py
Bug Description:
Update to tickets/ticket48234_test.py which are currently failing and using
soon to be obsolete classes
Fix Description:
Updated tickets/ticket48234_test.py and ported to the suites directory
Updated to utilise the DSLDAPObject class methods
relates: <The Issue URL>
Author: Gilbert Kimetto
Reviewed by: ???
IDMDS-1068 Update failing ticket48234_test.py test
[INTEROP-4009] CodeReady Studio on OpenShift - Run locally
[INTEROP-4009] CodeReady Studio on OpenShift - Run locally
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4609 - CVE - info disclosure when authenticating
Description: If you bind as a user that does not exist. Error 49 is returned
instead of error 32. As error 32 discloses that the entry does
not exist. When you bind as an entry that does not have userpassword
set then error 48 (inappropriate auth) is returned, but this
discloses that the entry does indeed exist. Instead we should
always return error 49, even if the password is not set in the
entry. This way we do not disclose to an attacker if the Bind
DN exists or not.
Relates: https://github.com/389ds/389-ds-base/issues/4609
Reviewed by: tbordaz(Thanks!)
* issue 4612 - Fix pytest fourwaymmr_test for non root user (#4613)
* Issue 4591 - RFE - improve openldap_to_ds help and features (#4607)
Bug Description: Improve the --help page, and finish wiring in some
features.
Fix Description: Wire in exclusion of attributes/schema for migration.
fixes: https://github.com/389ds/389-ds-base/issues/4591
Author: William Brown <[email protected]>
Review by: @mreynolds389, @droideck
* Issue 4577 - Add GitHub actions
Description:
* Enable IPv6 support for docker daemon
* Set server.example.com as FQDN for container
Relates: https://github.com/389ds/389-ds-base/issues/4577
Reviewed by: @droideck (Thanks!)
* Issue 4149 - UI - port TreeView and opther components to PF4
Description: This ports all th TreeViews to PF4, and also does some proof
of concept changes for PF3 to PF4 migration. There is much
more needed, but this does not break anything
relates: https://github.com/389ds/389-ds-base/issues/4149
Reviewed by: spichugi(Thanks!)
* Update dscontainer (#4564)
Issue 4564 - RFE - Add suffix to dscontainer rc file
Bug Description: The suffix was not added before, adding a hurdle to
automatic admin of the container instance
Fix Description: If the suffix is set, add it to the created rc file.
fixes: https://github.com/389ds/389-ds-base/pull/4564
Author: @Jackbennett
Review by: @Firstyear
* Issue 4469 - Backend redesign phase 3a - bdb dependency removal from back-ldbm
A massive change (https://directory.fedoraproject.org/docs/389ds/design/backend-redesign-phase3.html) that implements and use the dbimpl API in the backend.
* Issue 4593 - RFE - Print help when nsSSLPersonalitySSL is not found (#4614)
Description: RHDS instance will fail to start if the TLS server
certificate nickname doesn't match the value of the configuration
parameter "nsSSLPersonalitySSL".
The mismatch typically happens when customers copy the NSS DB from
a previous instance or export the certificate's data but forget to set
the "nsSSLPersonalitySSL" value accordingly.
Log an additional message which should help a user to set up
nsSSLPersonalitySSL correctly.
Fixes: #4593
Reviewed by: @Firstyear (Thanks!)
* Issue 4324 - Some architectures the cache line size file does not exist
Bug Description: When optimizing our mutexes we check for a system called
coherency_line_size that contains the size value, but if
the file did not exist the server would crash in PR_Read
(NULL pointer for fd).
Fix Description: Check PR_Open() was successfully before calling PR_Read().
Relates: https://github.com/389ds/389-ds-base/issues/4324
Reviewed by: tbordaz(Thanks!)
* Issue 4469 - Backend redesing phase 3a - implement dbimpl API and use it in back-ldbm (#4618)
see design document https://directory.fedoraproject.org/docs/389ds/design/backend-redesign-phase3.html
* Issue 4615 - log message when psearch first exceeds max threads per conn
Desciption: When a connection hits max threads per conn for the first time
log a message in the error. This will help customers diagnosis
misbehaving clients.
Fixes: https://github.com/389ds/389-ds-base/issues/4615
Reviewed by: progier389(Thanks!)
* Issue 4619 - remove pytest requirement from lib389
Description: Remove the requirement for pytest from lib389, it causes
unneeded package requirements on Fedora/RHEL.
Fixes: https://github.com/389ds/389-ds-base/issues/4619
Reviewed by: mreynolds(one line commit rule)
* Bump version to 2.0.3
* Issue 4513 - CI - make acl ip address tests more robust
Description: The tests aumme the system is using IPv6 loopback address, but it
should still check for IPv4 loopback.
Relates: https://github.com/389ds/389-ds-base/issues/4513
Reviewed by: ?
* Issue 2820 - Fix CI test suite issues
Description:
tickets/ticket48961_test.py was failing in CI nightly runs.
Fixed the failure by changing the code to use DSLdapObject
and moved the code into the config test suite.
Relates: https://github.com/389ds/389-ds-base/issues/2820
Reviewed by: droideck (Thanks!)
* Issue 4169 - UI - port charts to PF4
Description: Ported the charts under the monitor tab to use PF4 sparkline charts
and provide realtime stats on the the caches.
Relates: https://github.com/389ds/389-ds-base/issues/4169
Reviewed by: spichugi(Thanks!)
* Issue 4595 - Paged search lookthroughlimit bug (#4602)
Bug Description: During a paged search with lookthroughlimit enabled,
lookthroughcount is used to keep track of how many entries are
examined. A paged search reads ahead one entry to catch the end of the
search so it doesn't show the prompt when there are no more entries.
lookthroughcount doesn't take read ahead into account when tracking
how many entries have been examined.
Fix Description: Keep lookthroughcount in sync with read ahead by
by decrementing it during read ahead roll back.
Fixes: https://github.com/389ds/389-ds-base/issues/4595
Relates: https://github.com/389ds/389-ds-base/issues/4513
Reviewed by: droideck, mreynolds389, Firstyear, progier389 (Many thanks)
* Issue 4169 - UI - Migrate Accordians to PF4 ExpandableSection
Description: Replace all the CustomCollapse components with PF4
ExpandableSection component.
relates: https://github.com/389ds/389-ds-base/issues/4169
Reviewed by: spichugi(Thanks!)
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4169 - UI - Migrate alerts to PF4
Description: Migrate the toast notifications to PF4 Alerts.
Also fixed a refresh problem on the Tuning page.
relates: https://github.com/389ds/389-ds-base/issues/4169
Reviewed by: spichugi(Thanks!)
* Issue 4649 - crash in sync_repl when a MODRDN create a cenotaph (#4652)
Bug description:
When an operation is flagged OP_FLAG_NOOP, it skips BETXN plugins but calls POST plugins.
For sync_repl, betxn (sync_update_persist_betxn_pre_op) creates an operation extension to be
consumed by the post (sync_update_persist_op). In case of OP_FLAG_NOOP, there is no
operation extension.
Fix description:
Test that the operation is OP_FLAG_NOOP if the operation extension is missing
relates: https://github.com/389ds/389-ds-base/issues/4649
Reviewed by: William Brown (thanks)
Platforms tested: F31
* Issue 4644 - Large updates can reset the CLcache to the beginning of the changelog (#4647)
Bug description:
The replication agreements are using bulk load to load updates.
For bulk load it uses a cursor with DB_MULTIPLE_KEY and DB_NEXT.
Before using the cursor, it must be initialized with DB_SET.
If during the cursor/DB_SET the CSN refers to an update that is larger than
the size of the provided buffer, then the cursor remains not initialized and
c_get returns DB_BUFFER_SMALL.
The consequence is that the next c_get(DB_MULTIPLE_KEY and DB_NEXT) will return the
first record in the changelog DB. This break CLcache.
Fix description:
The fix is to harden cursor initialization so that if DB_SET fails
because of DB_BUFFER_SMALL. It reallocates buf_data and retries a DB_SET.
If DB_SET can not be initialized it logs a warning.
The patch also changes the behaviour of the fix #4492.
#4492 detected a massive (1day) jump prior the starting csn and ended the
replication session. If the jump was systematic, for example
if the CLcache got broken because of a too large updates, then
replication was systematically stopped.
This patch suppress the systematically stop, letting RA doing a big jump.
From #4492 only remains the warning.
relates: https://github.com/389ds/389-ds-base/issues/4644
Reviewed by: Pierre Rogier (Thanks !!!!)
Platforms tested: F31
* Issue 4646 - CLI/UI - revise DNA plugin management
Bug Description:
There was a false assumption that you have to create the shared DNA
server configuration entry, but in fact the server creates and manages
this entry. The only thing you should edit in this entry are the
remote Bind Method and Connection Protocol.
Fix Description:
Remove the options to create the shared config entry, and edit the
core/reserved attributes.
Also fixed some issues where we were not showing CLI plugin output in
proper JSON. This required some changes to the UI as well.
Relates: https://github.com/389ds/389-ds-base/issues/4646
Reviewed by: spichugi(Thanks!)
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4643 - Add a tool that generates Rust dependencies for a specfile (#4645)
Description: The Fedora builds of 389-DS uses the vendored crates
to build the official packages for Rawhide. Vendoring and bundling
dependencies is in violation of Fedora policies. As an upstream project
we are free to ship vendored code. But as a downstream Fedora project
we must not use the vendored code.
Add a tool that will help to generate 'Provides: bundled(crate(foo)) = version'
for Cargo.lock file content.
Replace License field which should contain all of the package licenses
we bundle in the specfile.
Fixes: https://github.com/389ds/389-ds-base/issues/4643
Reviewed by: @Firstyear, @decathorpe, @mreynolds389 (Thanks!)
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin (#4622)
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin
Merge of a fix in cl5_clcache.c (changelog cache restarts from begining if large update)
Rebase with master
* Issue 4469 - Backend redesing phase 3a - implement dbimpl API and use it in back-ldbm - fix test_maxbersize_repl pytest failure
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin - fix indent issue
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin - fix merge issue
manual Merge of fix about changelog cache iteration restarting from beginning in case of large update + automatic rebase to master
* Issue 4552 - Backend redesign phase 3b - fix indent issue + random crash and memory leak in tombstone handling
* Merge pull request #4664 from mreynolds389/issue4663
Issue 4663 - CLI - unable to add objectclass/attribute without x-origin
Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 - Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
Bug Description:
- Update ticket48234_test.py to verify tests on RHEL 7/8 and Fedora
- Update deprecated "*_s" methods to leverage the DSLDAPObject class
- Move test from the current location in ../tickets to appropriate ../suites/aci/* directory
Fix Description:
- Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
relates:
Author: Gilbert Kimetto
Reviewed by: ???
Co-authored-by: Mark Reynolds <[email protected]>
Co-authored-by: progier389 <[email protected]>
Co-authored-by: Firstyear <[email protected]>
Co-authored-by: Viktor Ashirov <[email protected]>
Co-authored-by: Jack <[email protected]>
Co-authored-by: Simon Pichugin <[email protected]>
Co-authored-by: Barbora Simonova <[email protected]>
Co-authored-by: James Chapman <[email protected]>
Co-authored-by: tbordaz <[email protected]>
|
commit 06db4a85eb87e9bc7226fd1758307eca3f5f0d24
Author: Gilbert Kimetto <[email protected]>
Date: Wed Mar 17 10:52:17 2021 -0400
Issue 4654 Updates to tickets/ticket48234_test.py (#4654)
* IDMDS-1068 Update failing ticket48234_test.py test
* IDMDS-1068 Update failing ticket48234_test.py test
* [INTEROP-4009] CodeReady Studio on OpenShift - Run locally
* [INTEROP-4009] CodeReady Studio on OpenShift - Run locally
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* [IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 - Updates to tickets/ticket48234_test.py
Bug Description:
Update to tickets/ticket48234_test.py which are currently failing and using
soon to be obsolete classes
Fix Description:
Updated tickets/ticket48234_test.py and ported to the suites directory
Updated to utilise the DSLDAPObject class methods
relates: <The Issue URL>
Author: Gilbert Kimetto
Reviewed by: ???
IDMDS-1068 Update failing ticket48234_test.py test
[INTEROP-4009] CodeReady Studio on OpenShift - Run locally
[INTEROP-4009] CodeReady Studio on OpenShift - Run locally
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4609 - CVE - info disclosure when authenticating
Description: If you bind as a user that does not exist. Error 49 is returned
instead of error 32. As error 32 discloses that the entry does
not exist. When you bind as an entry that does not have userpassword
set then error 48 (inappropriate auth) is returned, but this
discloses that the entry does indeed exist. Instead we should
always return error 49, even if the password is not set in the
entry. This way we do not disclose to an attacker if the Bind
DN exists or not.
Relates: https://github.com/389ds/389-ds-base/issues/4609
Reviewed by: tbordaz(Thanks!)
* issue 4612 - Fix pytest fourwaymmr_test for non root user (#4613)
* Issue 4591 - RFE - improve openldap_to_ds help and features (#4607)
Bug Description: Improve the --help page, and finish wiring in some
features.
Fix Description: Wire in exclusion of attributes/schema for migration.
fixes: https://github.com/389ds/389-ds-base/issues/4591
Author: William Brown <[email protected]>
Review by: @mreynolds389, @droideck
* Issue 4577 - Add GitHub actions
Description:
* Enable IPv6 support for docker daemon
* Set server.example.com as FQDN for container
Relates: https://github.com/389ds/389-ds-base/issues/4577
Reviewed by: @droideck (Thanks!)
* Issue 4149 - UI - port TreeView and opther components to PF4
Description: This ports all th TreeViews to PF4, and also does some proof
of concept changes for PF3 to PF4 migration. There is much
more needed, but this does not break anything
relates: https://github.com/389ds/389-ds-base/issues/4149
Reviewed by: spichugi(Thanks!)
* Update dscontainer (#4564)
Issue 4564 - RFE - Add suffix to dscontainer rc file
Bug Description: The suffix was not added before, adding a hurdle to
automatic admin of the container instance
Fix Description: If the suffix is set, add it to the created rc file.
fixes: https://github.com/389ds/389-ds-base/pull/4564
Author: @Jackbennett
Review by: @Firstyear
* Issue 4469 - Backend redesign phase 3a - bdb dependency removal from back-ldbm
A massive change (https://directory.fedoraproject.org/docs/389ds/design/backend-redesign-phase3.html) that implements and use the dbimpl API in the backend.
* Issue 4593 - RFE - Print help when nsSSLPersonalitySSL is not found (#4614)
Description: RHDS instance will fail to start if the TLS server
certificate nickname doesn't match the value of the configuration
parameter "nsSSLPersonalitySSL".
The mismatch typically happens when customers copy the NSS DB from
a previous instance or export the certificate's data but forget to set
the "nsSSLPersonalitySSL" value accordingly.
Log an additional message which should help a user to set up
nsSSLPersonalitySSL correctly.
Fixes: #4593
Reviewed by: @Firstyear (Thanks!)
* Issue 4324 - Some architectures the cache line size file does not exist
Bug Description: When optimizing our mutexes we check for a system called
coherency_line_size that contains the size value, but if
the file did not exist the server would crash in PR_Read
(NULL pointer for fd).
Fix Description: Check PR_Open() was successfully before calling PR_Read().
Relates: https://github.com/389ds/389-ds-base/issues/4324
Reviewed by: tbordaz(Thanks!)
* Issue 4469 - Backend redesing phase 3a - implement dbimpl API and use it in back-ldbm (#4618)
see design document https://directory.fedoraproject.org/docs/389ds/design/backend-redesign-phase3.html
* Issue 4615 - log message when psearch first exceeds max threads per conn
Desciption: When a connection hits max threads per conn for the first time
log a message in the error. This will help customers diagnosis
misbehaving clients.
Fixes: https://github.com/389ds/389-ds-base/issues/4615
Reviewed by: progier389(Thanks!)
* Issue 4619 - remove pytest requirement from lib389
Description: Remove the requirement for pytest from lib389, it causes
unneeded package requirements on Fedora/RHEL.
Fixes: https://github.com/389ds/389-ds-base/issues/4619
Reviewed by: mreynolds(one line commit rule)
* Bump version to 2.0.3
* Issue 4513 - CI - make acl ip address tests more robust
Description: The tests aumme the system is using IPv6 loopback address, but it
should still check for IPv4 loopback.
Relates: https://github.com/389ds/389-ds-base/issues/4513
Reviewed by: ?
* Issue 2820 - Fix CI test suite issues
Description:
tickets/ticket48961_test.py was failing in CI nightly runs.
Fixed the failure by changing the code to use DSLdapObject
and moved the code into the config test suite.
Relates: https://github.com/389ds/389-ds-base/issues/2820
Reviewed by: droideck (Thanks!)
* Issue 4169 - UI - port charts to PF4
Description: Ported the charts under the monitor tab to use PF4 sparkline charts
and provide realtime stats on the the caches.
Relates: https://github.com/389ds/389-ds-base/issues/4169
Reviewed by: spichugi(Thanks!)
* Issue 4595 - Paged search lookthroughlimit bug (#4602)
Bug Description: During a paged search with lookthroughlimit enabled,
lookthroughcount is used to keep track of how many entries are
examined. A paged search reads ahead one entry to catch the end of the
search so it doesn't show the prompt when there are no more entries.
lookthroughcount doesn't take read ahead into account when tracking
how many entries have been examined.
Fix Description: Keep lookthroughcount in sync with read ahead by
by decrementing it during read ahead roll back.
Fixes: https://github.com/389ds/389-ds-base/issues/4595
Relates: https://github.com/389ds/389-ds-base/issues/4513
Reviewed by: droideck, mreynolds389, Firstyear, progier389 (Many thanks)
* Issue 4169 - UI - Migrate Accordians to PF4 ExpandableSection
Description: Replace all the CustomCollapse components with PF4
ExpandableSection component.
relates: https://github.com/389ds/389-ds-base/issues/4169
Reviewed by: spichugi(Thanks!)
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4169 - UI - Migrate alerts to PF4
Description: Migrate the toast notifications to PF4 Alerts.
Also fixed a refresh problem on the Tuning page.
relates: https://github.com/389ds/389-ds-base/issues/4169
Reviewed by: spichugi(Thanks!)
* Issue 4649 - crash in sync_repl when a MODRDN create a cenotaph (#4652)
Bug description:
When an operation is flagged OP_FLAG_NOOP, it skips BETXN plugins but calls POST plugins.
For sync_repl, betxn (sync_update_persist_betxn_pre_op) creates an operation extension to be
consumed by the post (sync_update_persist_op). In case of OP_FLAG_NOOP, there is no
operation extension.
Fix description:
Test that the operation is OP_FLAG_NOOP if the operation extension is missing
relates: https://github.com/389ds/389-ds-base/issues/4649
Reviewed by: William Brown (thanks)
Platforms tested: F31
* Issue 4644 - Large updates can reset the CLcache to the beginning of the changelog (#4647)
Bug description:
The replication agreements are using bulk load to load updates.
For bulk load it uses a cursor with DB_MULTIPLE_KEY and DB_NEXT.
Before using the cursor, it must be initialized with DB_SET.
If during the cursor/DB_SET the CSN refers to an update that is larger than
the size of the provided buffer, then the cursor remains not initialized and
c_get returns DB_BUFFER_SMALL.
The consequence is that the next c_get(DB_MULTIPLE_KEY and DB_NEXT) will return the
first record in the changelog DB. This break CLcache.
Fix description:
The fix is to harden cursor initialization so that if DB_SET fails
because of DB_BUFFER_SMALL. It reallocates buf_data and retries a DB_SET.
If DB_SET can not be initialized it logs a warning.
The patch also changes the behaviour of the fix #4492.
#4492 detected a massive (1day) jump prior the starting csn and ended the
replication session. If the jump was systematic, for example
if the CLcache got broken because of a too large updates, then
replication was systematically stopped.
This patch suppress the systematically stop, letting RA doing a big jump.
From #4492 only remains the warning.
relates: https://github.com/389ds/389-ds-base/issues/4644
Reviewed by: Pierre Rogier (Thanks !!!!)
Platforms tested: F31
* Issue 4646 - CLI/UI - revise DNA plugin management
Bug Description:
There was a false assumption that you have to create the shared DNA
server configuration entry, but in fact the server creates and manages
this entry. The only thing you should edit in this entry are the
remote Bind Method and Connection Protocol.
Fix Description:
Remove the options to create the shared config entry, and edit the
core/reserved attributes.
Also fixed some issues where we were not showing CLI plugin output in
proper JSON. This required some changes to the UI as well.
Relates: https://github.com/389ds/389-ds-base/issues/4646
Reviewed by: spichugi(Thanks!)
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
[IDMDS-1068] Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4643 - Add a tool that generates Rust dependencies for a specfile (#4645)
Description: The Fedora builds of 389-DS uses the vendored crates
to build the official packages for Rawhide. Vendoring and bundling
dependencies is in violation of Fedora policies. As an upstream project
we are free to ship vendored code. But as a downstream Fedora project
we must not use the vendored code.
Add a tool that will help to generate 'Provides: bundled(crate(foo)) = version'
for Cargo.lock file content.
Replace License field which should contain all of the package licenses
we bundle in the specfile.
Fixes: https://github.com/389ds/389-ds-base/issues/4643
Reviewed by: @Firstyear, @decathorpe, @mreynolds389 (Thanks!)
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin (#4622)
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin
Merge of a fix in cl5_clcache.c (changelog cache restarts from begining if large update)
Rebase with master
* Issue 4469 - Backend redesing phase 3a - implement dbimpl API and use it in back-ldbm - fix test_maxbersize_repl pytest failure
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin - fix indent issue
* issue 4552 - Backup Redesign phase 3b - use dbimpl in replicatin plugin - fix merge issue
manual Merge of fix about changelog cache iteration restarting from beginning in case of large update + automatic rebase to master
* Issue 4552 - Backend redesign phase 3b - fix indent issue + random crash and memory leak in tombstone handling
* Merge pull request #4664 from mreynolds389/issue4663
Issue 4663 - CLI - unable to add objectclass/attribute without x-origin
Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
* Issue 4654 - Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
Bug Description:
- Update ticket48234_test.py to verify tests on RHEL 7/8 and Fedora
- Update deprecated "*_s" methods to leverage the DSLDAPObject class
- Move test from the current location in ../tickets to appropriate ../suites/aci/* directory
Fix Description:
- Issue 4654 Update ticket48234_test.py and move to suites/acl/aci_excl_filter_test.py
relates:
Author: Gilbert Kimetto
Reviewed by: ???
Co-authored-by: Mark Reynolds <[email protected]>
Co-authored-by: progier389 <[email protected]>
Co-authored-by: Firstyear <[email protected]>
Co-authored-by: Viktor Ashirov <[email protected]>
Co-authored-by: Jack <[email protected]>
Co-authored-by: Simon Pichugin <[email protected]>
Co-authored-by: Barbora Simonova <[email protected]>
Co-authored-by: James Chapman <[email protected]>
Co-authored-by: tbordaz <[email protected]>
diff --git a/dirsrvtests/tests/suites/acl/aci_excl_filter_test.py b/dirsrvtests/tests/suites/acl/aci_excl_filter_test.py
new file mode 100644
index 000000000..04b3172bf
--- /dev/null
+++ b/dirsrvtests/tests/suites/acl/aci_excl_filter_test.py
@@ -0,0 +1,153 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2021 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+import logging
+import os
+import pytest
+from lib389.topologies import topology_st as topo
+from lib389._mapped_object import DSLdapObject
+from lib389.idm.organizationalunit import OrganizationalUnit
+from lib389.idm.user import UserAccounts
+from lib389._constants import DEFAULT_SUFFIX
+from lib389.idm.domain import Domain
+from lib389.idm.account import Accounts
+
+pytestmark = pytest.mark.tier1
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
[email protected](scope="function")
+def add_anon_aci_access(topo, request):
+ # Add anonymous access aci
+ ACI_TARGET = "(targetattr != \"userpassword\")(target = \"ldap:///%s\")" % (DEFAULT_SUFFIX)
+ ACI_ALLOW = "(version 3.0; acl \"Anonymous Read access\"; allow (read,search,compare)"
+ ACI_SUBJECT = "(userdn=\"ldap:///anyone\");)"
+ ANON_ACI = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+ suffix = Domain(topo.standalone, DEFAULT_SUFFIX)
+
+ try:
+ suffix.add('aci', ANON_ACI)
+ except ldap.TYPE_OR_VALUE_EXISTS:
+ pass
+ def fin():
+ suffix.delete()
+ request.addfinalizer(fin)
+
+
+def add_ou_entry(topo, name, myparent):
+
+ ou_dn = 'ou={},{}'.format(name, myparent)
+ ou = OrganizationalUnit(topo.standalone, dn=ou_dn)
+ assert ou.create(properties={'ou': name})
+ log.info('Organisation {} created for ou :{} .'.format(name, ou_dn))
+
+
+def add_user_entry(topo, user, name, pw, myparent):
+
+ dn = 'ou=%s,%s' % (name, myparent)
+ properties = {
+ 'uid': name,
+ 'cn': 'admin',
+ 'sn': name,
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/{}'.format(name),
+ 'telephonenumber': '+1 222 333-4444',
+ 'userpassword': pw,
+ }
+
+ assert user.create(properties=properties)
+ log.info('User created for dn :{} .'.format(dn))
+ return user
+
+
+def test_aci_with_exclude_filter(topo, add_anon_aci_access):
+ """Test an ACI(Access control instruction) which contains an extensible filter.
+
+ :id: 238da674-81d9-11eb-a965-98fa9ba19b65
+ :setup: Standalone instance
+ :steps:
+ 1. Bind to a new Standalone instance
+ 2. Generate text for the Access Control Instruction(ACI) and add to the standalone instance
+ -Create a test user 'admin' with a marker -> deniedattr = 'telephonenumber'
+ 3. Create 2 top Organizational units (ou) under the same root suffix
+ 4. Create 2 test users for each Organizational unit (ou) above with the same username 'admin'
+ 5. Bind to the Standalone instance as the user 'admin' from the ou created in step 4 above
+ - Search for user(s) ' admin in the subtree that satisfy this criteria:
+ DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, cn_filter, [deniedattr, 'dn']
+ 6. The search should return 2 entries with the username 'admin'
+ 7. Verify that the users found do not have the --> deniedattr = 'telephonenumber' marker
+ :expectedresults:
+ 1. Bind should be successful
+ 2. Operation to create 2 Orgs (ou) should be successful
+ 3. Operation to create 2 (admin*) users should be successful
+ 4. Operation should be successful.
+ 5. Operation should be successful
+ 6. Should successfully return 2 users that match "admin*"
+ 7. PASS - users found do not have the --> deniedattr = 'telephonenumber' marker
+
+ """
+
+ log.info('Create an OU for them')
+ ous = OrganizationalUnit(topo.standalone, DEFAULT_SUFFIX)
+ log.info('Create an top org users')
+ users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ log.info('Add aci which contains extensible filter.')
+ ouname = 'outest'
+ username = 'admin'
+ passwd = 'Password'
+ deniedattr = 'telephonenumber'
+ log.info('Add aci which contains extensible filter.')
+
+ aci_text = ('(targetattr = "{}")'.format(deniedattr) +
+ '(target = "ldap:///{}")'.format(DEFAULT_SUFFIX) +
+ '(version 3.0;acl "admin-tel-matching-rule-outest";deny (all)' +
+ '(userdn = "ldap:///{}??sub?(&(cn={})(ou:dn:={}))");)'.format(DEFAULT_SUFFIX, username, ouname))
+
+ suffix = Domain(topo.standalone, DEFAULT_SUFFIX)
+ suffix.add('aci', aci_text)
+ log.info('Adding OU entries ...')
+ for idx in range(0, 2):
+ ou0 = 'OU%d' % idx
+ log.info('Adding "ou" : %s under "dn" : %s...' % (ou0, DEFAULT_SUFFIX))
+ add_ou_entry(topo, ou0, DEFAULT_SUFFIX)
+ parent = 'ou=%s,%s' % (ou0, DEFAULT_SUFFIX)
+ log.info('Adding %s under %s...' % (ouname, parent))
+ add_ou_entry(topo, ouname, parent)
+ user = UserAccounts(topo.standalone, parent, rdn=None)
+
+ for idx in range(0, 2):
+ parent = 'ou=%s,ou=OU%d,%s' % (ouname, idx, DEFAULT_SUFFIX)
+ user = UserAccounts(topo.standalone, parent, rdn=None)
+ username = '{}{}'.format(username, idx)
+ log.info('Adding User: %s under %s...' % (username, parent))
+ user = add_user_entry(topo, user, username, passwd, parent)
+
+ log.info('Bind as user %s' % username)
+ binddn_user = user.get(username)
+
+ conn = binddn_user.bind(passwd)
+ if not conn:
+ log.error(" {} failed to authenticate: ".format(binddn_user))
+ assert False
+
+ cn_filter = '(cn=%s)' % username
+ entries = Accounts(conn, DEFAULT_SUFFIX).filter('(cn=admin*)')
+ log.info('Verify 2 Entries returned for cn {}'.format(cn_filter))
+ assert len(entries) == 2
+ for entry in entries:
+ assert not entry.get_attr_val_utf8('telephonenumber')
+ log.info("Verified the entries do not contain 'telephonenumber' ")
+ log.info('Test complete')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket48234_test.py b/dirsrvtests/tests/tickets/ticket48234_test.py
deleted file mode 100644
index 238a2bd8c..000000000
--- a/dirsrvtests/tests/tickets/ticket48234_test.py
+++ /dev/null
@@ -1,99 +0,0 @@
-import pytest
-from lib389.tasks import *
-from lib389.utils import *
-from lib389.topologies import topology_st
-
-from lib389._constants import DEFAULT_SUFFIX, DN_DM, PASSWORD
-
-pytestmark = pytest.mark.tier2
-
-logging.getLogger(__name__).setLevel(logging.DEBUG)
-log = logging.getLogger(__name__)
-
-
-def add_ou_entry(server, name, myparent):
- dn = 'ou=%s,%s' % (name, myparent)
- server.add_s(Entry((dn, {'objectclass': ['top', 'organizationalunit'],
- 'ou': name})))
-
-
-def add_user_entry(server, name, pw, myparent):
- dn = 'cn=%s,%s' % (name, myparent)
- server.add_s(Entry((dn, {'objectclass': ['top', 'person'],
- 'sn': name,
- 'cn': name,
- 'telephonenumber': '+1 222 333-4444',
- 'userpassword': pw})))
-
-
-def test_ticket48234(topology_st):
- """
- Test aci which contains an extensible filter.
- shutdown
- """
-
- log.info('Bind as root DN')
- try:
- topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
- except ldap.LDAPError as e:
- topology_st.standalone.log.error('Root DN failed to authenticate: ' + e.args[0]['desc'])
- assert False
-
- ouname = 'outest'
- username = 'admin'
- passwd = 'Password'
- deniedattr = 'telephonenumber'
- log.info('Add aci which contains extensible filter.')
- aci_text = ('(targetattr = "%s")' % (deniedattr) +
- '(target = "ldap:///%s")' % (DEFAULT_SUFFIX) +
- '(version 3.0;acl "admin-tel-matching-rule-outest";deny (all)' +
- '(userdn = "ldap:///%s??sub?(&(cn=%s)(ou:dn:=%s))");)' % (DEFAULT_SUFFIX, username, ouname))
-
- try:
- topology_st.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', ensure_bytes(aci_text))])
- except ldap.LDAPError as e:
- log.error('Failed to add aci: (%s) error %s' % (aci_text, e.args[0]['desc']))
- assert False
-
- log.info('Add entries ...')
- for idx in range(0, 2):
- ou0 = 'OU%d' % idx
- log.info('adding %s under %s...' % (ou0, DEFAULT_SUFFIX))
- add_ou_entry(topology_st.standalone, ou0, DEFAULT_SUFFIX)
- parent = 'ou=%s,%s' % (ou0, DEFAULT_SUFFIX)
- log.info('adding %s under %s...' % (ouname, parent))
- add_ou_entry(topology_st.standalone, ouname, parent)
-
- for idx in range(0, 2):
- parent = 'ou=%s,ou=OU%d,%s' % (ouname, idx, DEFAULT_SUFFIX)
- log.info('adding %s under %s...' % (username, parent))
- add_user_entry(topology_st.standalone, username, passwd, parent)
-
- binddn = 'cn=%s,%s' % (username, parent)
- log.info('Bind as user %s' % binddn)
- try:
- topology_st.standalone.simple_bind_s(binddn, passwd)
- except ldap.LDAPError as e:
- topology_st.standalone.log.error(bindn + ' failed to authenticate: ' + e.args[0]['desc'])
- assert False
-
- filter = '(cn=%s)' % username
- try:
- entries = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, filter, [deniedattr, 'dn'])
- assert 2 == len(entries)
- for idx in range(0, 1):
- if entries[idx].hasAttr(deniedattr):
- log.fatal('aci with extensible filter failed -- %s')
- assert False
- except ldap.LDAPError as e:
- topology_st.standalone.log.error('Search (%s, %s) failed: ' % (DEFAULT_SUFFIX, filter) + e.args[0]['desc'])
- assert False
-
- log.info('Test complete')
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
| 0 |
8f3baf3c8f8168d9fdd387eb3a7a774dc05b41db
|
389ds/389-ds-base
|
Issue 4884 - server crashes when dnaInterval attribute is set to zero
Bug Description:
A division by zero crash occurs if the dnaInterval is set to zero
Fix Description:
Validate the config value of dnaInterval and adjust it to the
default/safe value of "1" if needed.
relates: https://github.com/389ds/389-ds-base/issues/4884
Reviewed by: tbordaz(Thanks!)
|
commit 8f3baf3c8f8168d9fdd387eb3a7a774dc05b41db
Author: Mark Reynolds <[email protected]>
Date: Wed Aug 25 16:54:57 2021 -0400
Issue 4884 - server crashes when dnaInterval attribute is set to zero
Bug Description:
A division by zero crash occurs if the dnaInterval is set to zero
Fix Description:
Validate the config value of dnaInterval and adjust it to the
default/safe value of "1" if needed.
relates: https://github.com/389ds/389-ds-base/issues/4884
Reviewed by: tbordaz(Thanks!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 928a3f54a..c983ebdd0 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1025,7 +1025,14 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry *e, int apply)
value = slapi_entry_attr_get_charptr(e, DNA_INTERVAL);
if (value) {
+ errno = 0;
entry->interval = strtoull(value, 0, 0);
+ if (entry->interval == 0 || errno == ERANGE) {
+ slapi_log_err(SLAPI_LOG_WARNING, DNA_PLUGIN_SUBSYSTEM,
+ "dna_parse_config_entry - Invalid value for dnaInterval (%s), "
+ "Using default value of 1\n", value);
+ entry->interval = 1;
+ }
slapi_ch_free_string(&value);
}
| 0 |
d7c4d9b08b8a2974a0e810c2d7349c9df6181f7c
|
389ds/389-ds-base
|
Bug 623507 - fix coverity Defect Type: Incorrect expression issues
https://bugzilla.redhat.com/show_bug.cgi?id=623507
Comment:
readonly_attributes is never NULL so it's not necessary to compare
with NULL.
|
commit d7c4d9b08b8a2974a0e810c2d7349c9df6181f7c
Author: Noriko Hosoi <[email protected]>
Date: Wed Aug 11 18:00:03 2010 -0700
Bug 623507 - fix coverity Defect Type: Incorrect expression issues
https://bugzilla.redhat.com/show_bug.cgi?id=623507
Comment:
readonly_attributes is never NULL so it's not necessary to compare
with NULL.
diff --git a/ldap/servers/slapd/rootdse.c b/ldap/servers/slapd/rootdse.c
index 56382b897..2368a3de1 100644
--- a/ldap/servers/slapd/rootdse.c
+++ b/ldap/servers/slapd/rootdse.c
@@ -89,10 +89,6 @@ rootdse_is_readonly_attr( char *attr )
return 1; /* I guess. It's not really an attribute at all */
}
- if ( NULL == readonly_attributes ) {
- return 0;
- }
-
/*
* optimization: check for attributes we're likely to be writing
* frequently.
| 0 |
43ec9daa67ff67be5c42c280d831fd8ad54be0d8
|
389ds/389-ds-base
|
Ticket #277 - cannot set repl referrals or state
https://fedorahosted.org/389/ticket/277
Resolves: Ticket #277
Bug Description: cannot set repl referrals or state
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Use slapi_sdn_get_udn(root) to get the raw DN string
to pass to slapi_create_dn_string - will save a normalization if
root is not normalized.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit 43ec9daa67ff67be5c42c280d831fd8ad54be0d8
Author: Rich Megginson <[email protected]>
Date: Thu Feb 2 16:20:02 2012 -0700
Ticket #277 - cannot set repl referrals or state
https://fedorahosted.org/389/ticket/277
Resolves: Ticket #277
Bug Description: cannot set repl referrals or state
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Use slapi_sdn_get_udn(root) to get the raw DN string
to pass to slapi_create_dn_string - will save a normalization if
root is not normalized.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index c14c5dbe5..e8e414fc5 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -2910,7 +2910,7 @@ slapi_get_mapping_tree_node_configdn (const Slapi_DN *root)
/* This function converts the old DN style to the new one. */
dn = slapi_create_dn_string("cn=\"%s\",%s",
- slapi_sdn_get_ndn(root), MAPPING_TREE_BASE_DN);
+ slapi_sdn_get_udn(root), MAPPING_TREE_BASE_DN);
if (NULL == dn) {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"slapi_get_mapping_tree_node_configdn: "
@@ -2937,7 +2937,7 @@ slapi_get_mapping_tree_node_configsdn (const Slapi_DN *root)
/* This function converts the old DN style to the new one. */
dn = slapi_create_dn_string("cn=\"%s\",%s",
- slapi_sdn_get_dn(root), MAPPING_TREE_BASE_DN);
+ slapi_sdn_get_udn(root), MAPPING_TREE_BASE_DN);
if (NULL == dn) {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"slapi_get_mapping_tree_node_configsdn: "
| 0 |
d04d3a60d7241c120b788113f059fdd15d8812f2
|
389ds/389-ds-base
|
Issue 6888 - Missing access JSON logging for TLS/Client auth
Description:
TLS/Client auth logging was not converted to JSON (auth.c got missed)
Relates: https://github.com/389ds/389-ds-base/issues/6888
Reviewed by: spichugi(Thanks!)
|
commit d04d3a60d7241c120b788113f059fdd15d8812f2
Author: Mark Reynolds <[email protected]>
Date: Wed Jul 16 20:54:48 2025 -0400
Issue 6888 - Missing access JSON logging for TLS/Client auth
Description:
TLS/Client auth logging was not converted to JSON (auth.c got missed)
Relates: https://github.com/389ds/389-ds-base/issues/6888
Reviewed by: spichugi(Thanks!)
diff --git a/dirsrvtests/tests/suites/logging/access_json_logging_test.py b/dirsrvtests/tests/suites/logging/access_json_logging_test.py
index ae91dc487..f0dc861a7 100644
--- a/dirsrvtests/tests/suites/logging/access_json_logging_test.py
+++ b/dirsrvtests/tests/suites/logging/access_json_logging_test.py
@@ -19,6 +19,8 @@ from lib389.idm.user import UserAccounts
from lib389.dirsrv_log import DirsrvAccessJSONLog
from lib389.index import VLVSearch, VLVIndex
from lib389.tasks import Tasks
+from lib389.config import CertmapLegacy
+from lib389.nss_ssl import NssSsl
from ldap.controls.vlv import VLVRequestControl
from ldap.controls.sss import SSSRequestControl
from ldap.controls import SimplePagedResultsControl
@@ -67,11 +69,11 @@ def get_log_event(inst, op, key=None, val=None, key2=None, val2=None):
if val == str(event[key]).lower() and \
val2 == str(event[key2]).lower():
return event
-
- elif key is not None and key in event:
- val = str(val).lower()
- if val == str(event[key]).lower():
- return event
+ elif key is not None:
+ if key in event:
+ val = str(val).lower()
+ if val == str(event[key]).lower():
+ return event
else:
return event
@@ -163,6 +165,7 @@ def test_access_json_format(topo_m2, setup_test):
14. Test PAGED SEARCH is logged correctly
15. Test PERSISTENT SEARCH is logged correctly
16. Test EXTENDED OP
+ 17. Test TLS_INFO is logged correctly
:expectedresults:
1. Success
2. Success
@@ -180,6 +183,7 @@ def test_access_json_format(topo_m2, setup_test):
14. Success
15. Success
16. Success
+ 17. Success
"""
inst = topo_m2.ms["supplier1"]
@@ -560,6 +564,88 @@ def test_access_json_format(topo_m2, setup_test):
assert event['oid_name'] == "REPL_END_NSDS50_REPLICATION_REQUEST_OID"
assert event['name'] == "replication-multisupplier-extop"
+ #
+ # TLS INFO/TLS CLIENT INFO
+ #
+ RDN_TEST_USER = 'testuser'
+ RDN_TEST_USER_WRONG = 'testuser_wrong'
+ inst.enable_tls()
+ inst.restart()
+
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+ user = users.create(properties={
+ 'uid': RDN_TEST_USER,
+ 'cn': RDN_TEST_USER,
+ 'sn': RDN_TEST_USER,
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': f'/home/{RDN_TEST_USER}'
+ })
+
+ ssca_dir = inst.get_ssca_dir()
+ ssca = NssSsl(dbpath=ssca_dir)
+ ssca.create_rsa_user(RDN_TEST_USER)
+ ssca.create_rsa_user(RDN_TEST_USER_WRONG)
+
+ # Get the details of where the key and crt are.
+ tls_locs = ssca.get_rsa_user(RDN_TEST_USER)
+ tls_locs_wrong = ssca.get_rsa_user(RDN_TEST_USER_WRONG)
+
+ user.enroll_certificate(tls_locs['crt_der_path'])
+
+ # Turn on the certmap.
+ cm = CertmapLegacy(inst)
+ certmaps = cm.list()
+ certmaps['default']['DNComps'] = ''
+ certmaps['default']['FilterComps'] = ['cn']
+ certmaps['default']['VerifyCert'] = 'off'
+ cm.set(certmaps)
+
+ # Check that EXTERNAL is listed in supported mechns.
+ assert (inst.rootdse.supports_sasl_external())
+
+ # Restart to allow certmaps to be re-read: Note, we CAN NOT use post_open
+ # here, it breaks on auth. see lib389/__init__.py
+ inst.restart(post_open=False)
+
+ # Attempt a bind with TLS external
+ inst.open(saslmethod='EXTERNAL', connOnly=True, certdir=ssca_dir,
+ userkey=tls_locs['key'], usercert=tls_locs['crt'])
+ inst.restart()
+
+ event = get_log_event(inst, "TLS_INFO")
+ assert event is not None
+ assert 'tls_version' in event
+ assert 'keysize' in event
+ assert 'cipher' in event
+
+ event = get_log_event(inst, "TLS_CLIENT_INFO",
+ "subject",
+ "CN=testuser,O=testing,L=389ds,ST=Queensland,C=AU")
+ assert event is not None
+ assert 'tls_version' in event
+ assert 'keysize' in event
+ assert 'issuer' in event
+
+ event = get_log_event(inst, "TLS_CLIENT_INFO",
+ "client_dn",
+ "uid=testuser,ou=People,dc=example,dc=com")
+ assert event is not None
+ assert 'tls_version' in event
+ assert event['msg'] == "client bound"
+
+ # Check for failed certmap error
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ inst.open(saslmethod='EXTERNAL', connOnly=True, certdir=ssca_dir,
+ userkey=tls_locs_wrong['key'],
+ usercert=tls_locs_wrong['crt'])
+
+ event = get_log_event(inst, "TLS_CLIENT_INFO", "err", -185)
+ assert event is not None
+ assert 'tls_version' in event
+ assert event['msg'] == "failed to map client certificate to LDAP DN"
+ assert event['err_msg'] == "Certificate couldn't be mapped to an ldap entry"
+
if __name__ == '__main__':
# Run isolated
diff --git a/ldap/servers/slapd/accesslog.c b/ldap/servers/slapd/accesslog.c
index 68022fe38..072ace203 100644
--- a/ldap/servers/slapd/accesslog.c
+++ b/ldap/servers/slapd/accesslog.c
@@ -1147,3 +1147,117 @@ slapd_log_access_sort(slapd_log_pblock *logpb)
return rc;
}
+
+/*
+ * TLS connection
+ *
+ * int32_t log_format
+ * time_t conn_time
+ * uint64_t conn_id
+ * const char *msg
+ * const char *tls_version
+ * int32_t keysize
+ * const char *cipher
+ * int32_t err
+ * const char *err_str
+ */
+int32_t
+slapd_log_access_tls(slapd_log_pblock *logpb)
+{
+ int32_t rc = 0;
+ char *msg = NULL;
+ json_object *json_obj = NULL;
+
+ if ((json_obj = build_base_obj(logpb, "TLS_INFO")) == NULL) {
+ return rc;
+ }
+
+ if (logpb->msg) {
+ json_object_object_add(json_obj, "msg", json_obj_add_str(logpb->msg));
+ }
+ if (logpb->tls_version) {
+ json_object_object_add(json_obj, "tls_version", json_obj_add_str(logpb->tls_version));
+ }
+ if (logpb->cipher) {
+ json_object_object_add(json_obj, "cipher", json_obj_add_str(logpb->cipher));
+ }
+ if (logpb->keysize) {
+ json_object_object_add(json_obj, "keysize", json_object_new_int(logpb->keysize));
+ }
+ if (logpb->err_str) {
+ json_object_object_add(json_obj, "err", json_object_new_int(logpb->err));
+ json_object_object_add(json_obj, "err_msg", json_obj_add_str(logpb->err_str));
+ }
+
+ /* Convert json object to string and log it */
+ msg = (char *)json_object_to_json_string_ext(json_obj, logpb->log_format);
+ rc = slapd_log_access_json(msg);
+
+ /* Done with JSON object - free it */
+ json_object_put(json_obj);
+
+ return rc;
+}
+
+/*
+ * TLS client auth
+ *
+ * int32_t log_format
+ * time_t conn_time
+ * uint64_t conn_id
+ * const char* tls_version
+ * const char* keysize
+ * const char* cipher
+ * const char* msg
+ * const char* subject
+ * const char* issuer
+ * int32_t err
+ * const char* err_str
+ * const char *client_dn
+ */
+int32_t
+slapd_log_access_tls_client_auth(slapd_log_pblock *logpb)
+{
+ int32_t rc = 0;
+ char *msg = NULL;
+ json_object *json_obj = NULL;
+
+ if ((json_obj = build_base_obj(logpb, "TLS_CLIENT_INFO")) == NULL) {
+ return rc;
+ }
+
+ if (logpb->tls_version) {
+ json_object_object_add(json_obj, "tls_version", json_obj_add_str(logpb->tls_version));
+ }
+ if (logpb->cipher) {
+ json_object_object_add(json_obj, "cipher", json_obj_add_str(logpb->cipher));
+ }
+ if (logpb->keysize) {
+ json_object_object_add(json_obj, "keysize", json_object_new_int(logpb->keysize));
+ }
+ if (logpb->subject) {
+ json_object_object_add(json_obj, "subject", json_obj_add_str(logpb->subject));
+ }
+ if (logpb->issuer) {
+ json_object_object_add(json_obj, "issuer", json_obj_add_str(logpb->issuer));
+ }
+ if (logpb->client_dn) {
+ json_object_object_add(json_obj, "client_dn", json_obj_add_str(logpb->client_dn));
+ }
+ if (logpb->msg) {
+ json_object_object_add(json_obj, "msg", json_obj_add_str(logpb->msg));
+ }
+ if (logpb->err_str) {
+ json_object_object_add(json_obj, "err", json_object_new_int(logpb->err));
+ json_object_object_add(json_obj, "err_msg", json_obj_add_str(logpb->err_str));
+ }
+
+ /* Convert json object to string and log it */
+ msg = (char *)json_object_to_json_string_ext(json_obj, logpb->log_format);
+ rc = slapd_log_access_json(msg);
+
+ /* Done with JSON object - free it */
+ json_object_put(json_obj);
+
+ return rc;
+}
diff --git a/ldap/servers/slapd/auth.c b/ldap/servers/slapd/auth.c
index e4231bf45..48e4b7129 100644
--- a/ldap/servers/slapd/auth.c
+++ b/ldap/servers/slapd/auth.c
@@ -1,6 +1,6 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2025 Red Hat, Inc.
* All rights reserved.
*
* License: GPL (version 3 or any later version).
@@ -363,19 +363,32 @@ handle_bad_certificate(void *clientData, PRFileDesc *prfd)
char sbuf[BUFSIZ], ibuf[BUFSIZ];
Connection *conn = (Connection *)clientData;
CERTCertificate *clientCert = slapd_ssl_peerCertificate(prfd);
-
PRErrorCode errorCode = PR_GetError();
char *subject = subject_of(clientCert);
char *issuer = issuer_of(clientCert);
- slapi_log_access(LDAP_DEBUG_STATS,
- "conn=%" PRIu64 " " SLAPI_COMPONENT_NAME_NSPR " error %i (%s); unauthenticated client %s; issuer %s\n",
- conn->c_connid, errorCode, slapd_pr_strerror(errorCode),
- subject ? escape_string(subject, sbuf) : "NULL",
- issuer ? escape_string(issuer, ibuf) : "NULL");
+ int32_t log_format = config_get_accesslog_log_format();
+ slapd_log_pblock logpb = {0};
+
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.msg = "unauthenticated client";
+ logpb.subject = subject ? escape_string(subject, sbuf) : "NULL";
+ logpb.issuer = issuer ? escape_string(issuer, ibuf) : "NULL";
+ logpb.err = errorCode;
+ logpb.err_str = slapd_pr_strerror(errorCode);
+ slapd_log_access_tls_client_auth(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS,
+ "conn=%" PRIu64 " " SLAPI_COMPONENT_NAME_NSPR " error %i (%s); unauthenticated client %s; issuer %s\n",
+ conn->c_connid, errorCode, slapd_pr_strerror(errorCode),
+ subject ? escape_string(subject, sbuf) : "NULL",
+ issuer ? escape_string(issuer, ibuf) : "NULL");
+ }
if (issuer)
- free(issuer);
+ slapi_ch_free_string(&issuer);
if (subject)
- free(subject);
+ slapi_ch_free_string(&subject);
if (clientCert)
CERT_DestroyCertificate(clientCert);
return -1; /* non-zero means reject this certificate */
@@ -394,7 +407,8 @@ handle_handshake_done(PRFileDesc *prfd, void *clientData)
{
Connection *conn = (Connection *)clientData;
CERTCertificate *clientCert = slapd_ssl_peerCertificate(prfd);
-
+ int32_t log_format = config_get_accesslog_log_format();
+ slapd_log_pblock logpb = {0};
char *clientDN = NULL;
int keySize = 0;
char *cipher = NULL;
@@ -403,19 +417,39 @@ handle_handshake_done(PRFileDesc *prfd, void *clientData)
SSLCipherSuiteInfo cipherInfo;
char *subject = NULL;
char sslversion[64];
+ int err = 0;
if ((slapd_ssl_getChannelInfo(prfd, &channelInfo, sizeof(channelInfo))) != SECSuccess) {
PRErrorCode errorCode = PR_GetError();
- slapi_log_access(LDAP_DEBUG_STATS,
- "conn=%" PRIu64 " SSL failed to obtain channel info; " SLAPI_COMPONENT_NAME_NSPR " error %i (%s)\n",
- conn->c_connid, errorCode, slapd_pr_strerror(errorCode));
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.err = errorCode;
+ logpb.err_str = slapd_pr_strerror(errorCode);
+ logpb.msg = "SSL failed to obtain channel info; " SLAPI_COMPONENT_NAME_NSPR;
+ slapd_log_access_tls(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS,
+ "conn=%" PRIu64 " SSL failed to obtain channel info; " SLAPI_COMPONENT_NAME_NSPR " error %i (%s)\n",
+ conn->c_connid, errorCode, slapd_pr_strerror(errorCode));
+ }
goto done;
}
+
if ((slapd_ssl_getCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo, sizeof(cipherInfo))) != SECSuccess) {
PRErrorCode errorCode = PR_GetError();
- slapi_log_access(LDAP_DEBUG_STATS,
- "conn=%" PRIu64 " SSL failed to obtain cipher info; " SLAPI_COMPONENT_NAME_NSPR " error %i (%s)\n",
- conn->c_connid, errorCode, slapd_pr_strerror(errorCode));
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.err = errorCode;
+ logpb.err_str = slapd_pr_strerror(errorCode);
+ logpb.msg = "SSL failed to obtain cipher info; " SLAPI_COMPONENT_NAME_NSPR;
+ slapd_log_access_tls(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS,
+ "conn=%" PRIu64 " SSL failed to obtain cipher info; " SLAPI_COMPONENT_NAME_NSPR " error %i (%s)\n",
+ conn->c_connid, errorCode, slapd_pr_strerror(errorCode));
+ }
goto done;
}
@@ -434,47 +468,84 @@ handle_handshake_done(PRFileDesc *prfd, void *clientData)
if (config_get_SSLclientAuth() == SLAPD_SSLCLIENTAUTH_OFF) {
(void)slapi_getSSLVersion_str(channelInfo.protocolVersion, sslversion, sizeof(sslversion));
- slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " %s %i-bit %s\n",
- conn->c_connid,
- sslversion, keySize, cipher ? cipher : "NULL");
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.tls_version = sslversion;
+ logpb.keysize = keySize;
+ logpb.cipher = cipher ? cipher : "NULL";
+ slapd_log_access_tls(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " %s %i-bit %s\n",
+ conn->c_connid,
+ sslversion, keySize, cipher ? cipher : "NULL");
+ }
goto done;
}
if (clientCert == NULL) {
(void)slapi_getSSLVersion_str(channelInfo.protocolVersion, sslversion, sizeof(sslversion));
- slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " %s %i-bit %s\n",
- conn->c_connid,
- sslversion, keySize, cipher ? cipher : "NULL");
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.tls_version = sslversion;
+ logpb.keysize = keySize;
+ logpb.cipher = cipher ? cipher : "NULL";
+ slapd_log_access_tls(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " %s %i-bit %s\n",
+ conn->c_connid,
+ sslversion, keySize, cipher ? cipher : "NULL");
+ }
} else {
subject = subject_of(clientCert);
if (!subject) {
(void)slapi_getSSLVersion_str(channelInfo.protocolVersion,
sslversion, sizeof(sslversion));
- slapi_log_access(LDAP_DEBUG_STATS,
- "conn=%" PRIu64 " %s %i-bit %s; missing subject\n",
- conn->c_connid,
- sslversion, keySize, cipher ? cipher : "NULL");
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.msg = "missing subject";
+ logpb.tls_version = sslversion;
+ logpb.keysize = keySize;
+ logpb.cipher = cipher ? cipher : "NULL";
+ slapd_log_access_tls_client_auth(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS,
+ "conn=%" PRIu64 " %s %i-bit %s; missing subject\n",
+ conn->c_connid,
+ sslversion, keySize, cipher ? cipher : "NULL");
+ }
goto done;
- }
- {
+ } else {
char *issuer = issuer_of(clientCert);
char sbuf[BUFSIZ], ibuf[BUFSIZ];
(void)slapi_getSSLVersion_str(channelInfo.protocolVersion,
sslversion, sizeof(sslversion));
- slapi_log_access(LDAP_DEBUG_STATS,
- "conn=%" PRIu64 " %s %i-bit %s; client %s; issuer %s\n",
- conn->c_connid,
- sslversion, keySize,
- cipher ? cipher : "NULL",
- escape_string(subject, sbuf),
- issuer ? escape_string(issuer, ibuf) : "NULL");
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.tls_version = sslversion;
+ logpb.keysize = keySize;
+ logpb.cipher = cipher ? cipher : "NULL";
+ logpb.subject = escape_string(subject, sbuf);
+ logpb.issuer = issuer ? escape_string(issuer, ibuf) : "NULL";
+ slapd_log_access_tls_client_auth(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS,
+ "conn=%" PRIu64 " %s %i-bit %s; client %s; issuer %s\n",
+ conn->c_connid,
+ sslversion, keySize,
+ cipher ? cipher : "NULL",
+ escape_string(subject, sbuf),
+ issuer ? escape_string(issuer, ibuf) : "NULL");
+ }
if (issuer)
- free(issuer);
+ slapi_ch_free_string(&issuer);
}
slapi_dn_normalize(subject);
{
LDAPMessage *chain = NULL;
char *basedn = config_get_basedn();
- int err;
err = ldapu_cert_to_ldap_entry(clientCert, internal_ld, basedn ? basedn : "" /*baseDN*/, &chain);
if (err == LDAPU_SUCCESS && chain) {
@@ -505,18 +576,37 @@ handle_handshake_done(PRFileDesc *prfd, void *clientData)
slapi_sdn_free(&sdn);
(void)slapi_getSSLVersion_str(channelInfo.protocolVersion,
sslversion, sizeof(sslversion));
- slapi_log_access(LDAP_DEBUG_STATS,
- "conn=%" PRIu64 " %s client bound as %s\n",
- conn->c_connid,
- sslversion, clientDN);
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.msg = "client bound";
+ logpb.tls_version = sslversion;
+ logpb.client_dn = clientDN;
+ slapd_log_access_tls_client_auth(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS,
+ "conn=%" PRIu64 " %s client bound as %s\n",
+ conn->c_connid,
+ sslversion, clientDN);
+ }
} else if (clientCert != NULL) {
(void)slapi_getSSLVersion_str(channelInfo.protocolVersion,
sslversion, sizeof(sslversion));
- slapi_log_access(LDAP_DEBUG_STATS,
- "conn=%" PRIu64 " %s failed to map client "
- "certificate to LDAP DN (%s)\n",
- conn->c_connid,
- sslversion, extraErrorMsg);
+ if (log_format != LOG_FORMAT_DEFAULT) {
+ slapd_log_pblock_init(&logpb, log_format, NULL);
+ logpb.conn_id = conn->c_connid;
+ logpb.msg = "failed to map client certificate to LDAP DN";
+ logpb.tls_version = sslversion;
+ logpb.err = err;
+ logpb.err_str = extraErrorMsg;
+ slapd_log_access_tls_client_auth(&logpb);
+ } else {
+ slapi_log_access(LDAP_DEBUG_STATS,
+ "conn=%" PRIu64 " %s failed to map client "
+ "certificate to LDAP DN (%s)\n",
+ conn->c_connid,
+ sslversion, extraErrorMsg);
+ }
}
/*
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index eab837166..06792a55a 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -7270,6 +7270,8 @@ slapd_log_pblock_init(slapd_log_pblock *logpb, int32_t log_format, Slapi_PBlock
slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
}
+ memset(logpb, 0, sizeof(slapd_log_pblock));
+
logpb->loginfo = &loginfo;
logpb->level = 256; /* default log level */
logpb->log_format = log_format;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 6438a81fe..da232ae2f 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1549,6 +1549,13 @@ typedef struct slapd_log_pblock {
PRBool using_tls;
PRBool haproxied;
const char *bind_dn;
+ /* TLS */
+ const char *tls_version;
+ int32_t keysize;
+ const char *cipher;
+ const char *subject;
+ const char *issuer;
+ const char *client_dn;
/* Close connection */
const char *close_error;
const char *close_reason;
@@ -1619,6 +1626,7 @@ typedef struct slapd_log_pblock {
const char *oid;
const char *msg;
const char *name;
+ const char *err_str;
LDAPControl **request_controls;
LDAPControl **response_controls;
} slapd_log_pblock;
@@ -1645,6 +1653,8 @@ int32_t slapd_log_access_entry(slapd_log_pblock *logpb);
int32_t slapd_log_access_referral(slapd_log_pblock *logpb);
int32_t slapd_log_access_extop(slapd_log_pblock *logpb);
int32_t slapd_log_access_sort(slapd_log_pblock *logpb);
+int32_t slapd_log_access_tls(slapd_log_pblock *logpb);
+int32_t slapd_log_access_tls_client_auth(slapd_log_pblock *logpb);
#ifdef __cplusplus
}
| 0 |
bb3937ab86febf7ce896788ca0ccf722ac7304f6
|
389ds/389-ds-base
|
Ticket 48983 - Configure and Makefile.in from new default paths work.
Bug Description: At configure time, this is the only time we know all the
resolved paths of a ds installation. However, external tools such as lib389
need to be able to discover and use these paths.
Fix Description: This updates the configure and makefile based on the changes
to create the defaults.inf.
https://fedorahosted.org/389/ticket/48983
Author: wibrown
Review by: tbordaz, mreynolds (Thanks!)
|
commit bb3937ab86febf7ce896788ca0ccf722ac7304f6
Author: William Brown <[email protected]>
Date: Wed Sep 14 13:02:03 2016 +1000
Ticket 48983 - Configure and Makefile.in from new default paths work.
Bug Description: At configure time, this is the only time we know all the
resolved paths of a ds installation. However, external tools such as lib389
need to be able to discover and use these paths.
Fix Description: This updates the configure and makefile based on the changes
to create the defaults.inf.
https://fedorahosted.org/389/ticket/48983
Author: wibrown
Review by: tbordaz, mreynolds (Thanks!)
diff --git a/Makefile.in b/Makefile.in
index 17b8d7383..cd07f40e2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1392,10 +1392,6 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
capbrand = @capbrand@
-
-#------------------------
-# Install Paths
-#------------------------
configdir = $(sysconfdir)@configdir@
datadir = @datadir@
datarootdir = @datarootdir@
@@ -1473,6 +1469,11 @@ perldir = $(libdir)@perldir@
perlexec = @perlexec@
plainldif_opts = @plainldif_opts@
prefix = @prefix@
+
+#------------------------
+# Install Paths
+#------------------------
+prefixdir = @prefixdir@
program_transform_name = @program_transform_name@
propertydir = $(datadir)@propertydir@
psdir = @psdir@
@@ -2142,7 +2143,8 @@ task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
inf_DATA = ldap/admin/src/slapd.inf \
ldap/admin/src/scripts/dscreate.map \
ldap/admin/src/scripts/dsupdate.map \
- ldap/admin/src/scripts/dsorgentries.map
+ ldap/admin/src/scripts/dsorgentries.map \
+ ldap/admin/src/defaults.inf
mib_DATA = ldap/servers/snmp/redhat-directory.mib
pkgconfig_DATA = $(PACKAGE_NAME).pc
@@ -3157,7 +3159,8 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
@BUNDLE_FALSE@ -e 's,@ldaplib_defs\@,$(ldaplib_defs),g' \
@BUNDLE_FALSE@ -e 's,@systemdsystemunitdir\@,$(systemdsystemunitdir),g' \
@BUNDLE_FALSE@ -e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
-@BUNDLE_FALSE@ -e 's,@systemdgroupname\@,$(systemdgroupname),g'
+@BUNDLE_FALSE@ -e 's,@systemdgroupname\@,$(systemdgroupname),g' \
+@BUNDLE_FALSE@ -e 's,@prefixdir\@,$(prefixdir),g'
# these are for the config files and scripts that we need to generate and replace
@@ -3236,7 +3239,8 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
@BUNDLE_TRUE@ -e 's,@ldaplib_defs\@,$(ldaplib_defs),g' \
@BUNDLE_TRUE@ -e 's,@systemdsystemunitdir\@,$(systemdsystemunitdir),g' \
@BUNDLE_TRUE@ -e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
-@BUNDLE_TRUE@ -e 's,@systemdgroupname\@,$(systemdgroupname),g'
+@BUNDLE_TRUE@ -e 's,@systemdgroupname\@,$(systemdgroupname),g' \
+@BUNDLE_TRUE@ -e 's,@prefixdir\@,$(prefixdir),g'
all: $(BUILT_SOURCES) config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
diff --git a/configure b/configure
index a456450aa..8fbd53041 100755
--- a/configure
+++ b/configure
@@ -745,6 +745,7 @@ schemadir
propertydir
sampledatadir
configdir
+prefixdir
with_tmpfiles_d
with_fhs_opt
enable_nunc_stans_FALSE
@@ -18146,6 +18147,7 @@ localrundir='/run'
if test "$with_fhs_opt" = "yes"; then
# Override sysconfdir and localstatedir if FHS optional
# package was requested.
+ prefixdir=$prefix
sysconfdir='/etc/opt'
localstatedir='/var/opt'
localrundir='/var/opt/run'
@@ -18180,6 +18182,7 @@ else
localstatedir='/var'
localrundir='/run'
fi
+ prefixdir=$prefix
# relative to datadir
sampledatadir=/$PACKAGE_NAME/data
# relative to datadir
@@ -18303,6 +18306,7 @@ fi
+
# check for --with-instconfigdir
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-instconfigdir" >&5
$as_echo_n "checking for --with-instconfigdir... " >&6; }
| 0 |
4fa2ee84eb3dfdfd202585a59403195b408bbb8f
|
389ds/389-ds-base
|
Bug 572018 - Upgrading from 1.2.5 to 1.2.6.a2 deletes userRoot
https://bugzilla.redhat.com/show_bug.cgi?id=572018
Resolves: bug 572018
Bug Description: Upgrading from 1.2.5 to 1.2.6.a2 deletes userRoot
Reviewed by: self
Branch: HEAD
Fix Description: According to the error message, the entry id cannot be
found in the id2entry file. The entry id comes from the parentid index,
which has just been created by the dn2rdn upgradedb process. The entryid
is the key in the parentid index. I'm not sure how this can happen -
either the parentid contains the id of an entry that does not exist, or
the entryid was somehow corrupted. I've added some additional debugging
statements to try to narrow this down.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
|
commit 4fa2ee84eb3dfdfd202585a59403195b408bbb8f
Author: Rich Megginson <[email protected]>
Date: Mon Apr 26 17:26:00 2010 -0600
Bug 572018 - Upgrading from 1.2.5 to 1.2.6.a2 deletes userRoot
https://bugzilla.redhat.com/show_bug.cgi?id=572018
Resolves: bug 572018
Bug Description: Upgrading from 1.2.5 to 1.2.6.a2 deletes userRoot
Reviewed by: self
Branch: HEAD
Fix Description: According to the error message, the entry id cannot be
found in the id2entry file. The entry id comes from the parentid index,
which has just been created by the dn2rdn upgradedb process. The entryid
is the key in the parentid index. I'm not sure how this can happen -
either the parentid contains the id of an entry that does not exist, or
the entryid was somehow corrupted. I've added some additional debugging
statements to try to narrow this down.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/back-ldbm/ancestorid.c b/ldap/servers/slapd/back-ldbm/ancestorid.c
index 768dc6e7b..1337e0373 100644
--- a/ldap/servers/slapd/back-ldbm/ancestorid.c
+++ b/ldap/servers/slapd/back-ldbm/ancestorid.c
@@ -464,6 +464,9 @@ static int ldbm_ancestorid_new_idl_create_index(backend *be)
while (1) {
ret = ldbm_parentid(be, txn, id, &parentid);
if (ret != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, sourcefile,
+ "Error: ldbm_parentid on node index [" ID_FMT "] of [" ID_FMT "]\n",
+ nids, nodes->b_nids);
idl_free(children);
goto out;
}
@@ -552,6 +555,9 @@ static int ldbm_parentid(backend *be, DB_TXN *txn, ID id, ID *ppid)
ret = db->get(db, txn, &key, &data, 0);
if (ret != 0) {
ldbm_nasty(sourcefile,13110,ret);
+ slapi_log_error(SLAPI_LOG_FATAL, sourcefile,
+ "Error: unable to find entry id [" ID_FMT "] (original [" ID_FMT "])"
+ " in id2entry\n", stored_id, id);
goto out;
}
| 0 |
542287ce724e4d3bd69d699d3d61c3e640cc1541
|
389ds/389-ds-base
|
Ticket 397 - Add PBKDF2 to Directory Server password storage.
Bug Description: We need to improve the cryptographic quality of hashes
available in DS to prevent attacks on hashes both online and offline.
Fix Description: PBKDF2 is a hash that provides "iterations" of complexity
and work time to ensure complexity on the behalf of an attacker. It makes it
harder to create rainbow tables, bruteforce, or hardware accelerate attacks.
https://fedorahosted.org/389/ticket/397
Author: wibrown
Review by: rrelyea, nhosoi (Thanks!)
|
commit 542287ce724e4d3bd69d699d3d61c3e640cc1541
Author: William Brown <[email protected]>
Date: Tue Aug 2 16:54:08 2016 +1000
Ticket 397 - Add PBKDF2 to Directory Server password storage.
Bug Description: We need to improve the cryptographic quality of hashes
available in DS to prevent attacks on hashes both online and offline.
Fix Description: PBKDF2 is a hash that provides "iterations" of complexity
and work time to ensure complexity on the behalf of an attacker. It makes it
harder to create rainbow tables, bruteforce, or hardware accelerate attacks.
https://fedorahosted.org/389/ticket/397
Author: wibrown
Review by: rrelyea, nhosoi (Thanks!)
diff --git a/Makefile.am b/Makefile.am
index b6ebf925c..546f89e5e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1419,7 +1419,8 @@ libpwdstorage_plugin_la_SOURCES = ldap/servers/plugins/pwdstorage/clear_pwd.c \
ldap/servers/plugins/pwdstorage/pwd_util.c \
ldap/servers/plugins/pwdstorage/sha_pwd.c \
ldap/servers/plugins/pwdstorage/smd5_pwd.c \
- ldap/servers/plugins/pwdstorage/ssha_pwd.c
+ ldap/servers/plugins/pwdstorage/ssha_pwd.c \
+ ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c
libpwdstorage_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS)
libpwdstorage_plugin_la_LIBADD = libslapd.la $(NSS_LINK) $(NSPR_LINK) $(LIBCRYPT)
diff --git a/dirsrvtests/tests/tickets/ticket397_test.py b/dirsrvtests/tests/tickets/ticket397_test.py
new file mode 100644
index 000000000..4bf4eda90
--- /dev/null
+++ b/dirsrvtests/tests/tickets/ticket397_test.py
@@ -0,0 +1,151 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+DEBUGGING = False
+USER_DN = 'uid=user,ou=People,%s' % DEFAULT_SUFFIX
+
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+
+
+log = logging.getLogger(__name__)
+
+
+class TopologyStandalone(object):
+ """The DS Topology Class"""
+ def __init__(self, standalone):
+ """Init"""
+ standalone.open()
+ self.standalone = standalone
+
+
[email protected](scope="module")
+def topology(request):
+ """Create DS Deployment"""
+
+ # Creating standalone instance ...
+ if DEBUGGING:
+ standalone = DirSrv(verbose=True)
+ else:
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ def fin():
+ """If we are debugging just stop the instances, otherwise remove
+ them
+ """
+ if DEBUGGING:
+ standalone.stop()
+ else:
+ standalone.delete()
+
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+def _test_bind(inst, password):
+ result = True
+ userconn = ldap.initialize("ldap://%s:%s" % (HOST_STANDALONE, PORT_STANDALONE))
+ try:
+ userconn.simple_bind_s(USER_DN, password)
+ userconn.unbind_s()
+ except ldap.INVALID_CREDENTIALS:
+ result = False
+ return result
+
+def _test_algo(inst, algo_name):
+ inst.config.set('passwordStorageScheme', algo_name)
+
+ if DEBUGGING:
+ print('Testing %s' % algo_name)
+
+ # Create the user with a password
+ inst.add_s(Entry((
+ USER_DN, {
+ 'objectClass': 'top account simplesecurityobject'.split(),
+ 'uid': 'user',
+ 'userpassword': ['Secret123', ]
+ })))
+
+ # Make sure when we read the userPassword field, it is the correct ALGO
+ pw_field = inst.search_s(USER_DN, ldap.SCOPE_BASE, '(objectClass=*)', ['userPassword'] )[0]
+
+ if DEBUGGING:
+ print(pw_field.getValue('userPassword'))
+
+ if algo_name != 'CLEAR':
+ lalgo_name = algo_name.lower()
+ lpw_algo_name = pw_field.getValue('userPassword').lower()
+ assert(lpw_algo_name.startswith("{%s}" % lalgo_name))
+ # Now make sure a bind works
+ assert(_test_bind(inst, 'Secret123'))
+ # Bind with a wrong shorter password, should fail
+ assert(not _test_bind(inst, 'Wrong'))
+ # Bind with a wrong longer password, should fail
+ assert(not _test_bind(inst, 'This is even more wrong'))
+ # Bind with a password that has the algo in the name
+ assert(not _test_bind(inst, '{%s}SomeValues....' % algo_name))
+ # Bind with a wrong exact length password.
+ assert(not _test_bind(inst, 'Alsowrong'))
+ # Bind with a subset password, should fail
+ assert(not _test_bind(inst, 'Secret'))
+ if algo_name != 'CRYPT':
+ # Bind with a subset password that is 1 char shorter, to detect off by 1 in clear
+ assert(not _test_bind(inst, 'Secret12'))
+ # Bind with a superset password, should fail
+ assert(not _test_bind(inst, 'Secret123456'))
+ # Delete the user
+ inst.delete_s(USER_DN)
+ # done!
+
+def test_397(topology):
+ """
+ Assert that all of our password algorithms correctly PASS and FAIL varying
+ password conditions.
+
+ """
+ if DEBUGGING:
+ # Add debugging steps(if any)...
+ log.info("ATTACH NOW")
+ time.sleep(30)
+
+ # Merge this to the password suite in the future
+
+ for algo in ('PBKDF2_SHA256', ):
+ for i in range(0, 10):
+ _test_algo(topology.standalone, algo)
+
+ log.info('Test PASSED')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
+
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index 8258b70a4..7e519f2a6 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -211,6 +211,15 @@ nsslapd-plugininitfunc: ns_mta_md5_pwd_storage_scheme_init
nsslapd-plugintype: pwdstoragescheme
nsslapd-pluginenabled: on
+dn: cn=PBKDF2_SHA256,cn=Password Storage Schemes,cn=plugins,cn=config
+objectclass: top
+objectclass: nsSlapdPlugin
+cn: PBKDF2_SHA256
+nsslapd-pluginpath: libpwdstorage-plugin
+nsslapd-plugininitfunc: pbkdf2_sha256_pwd_storage_scheme_init
+nsslapd-plugintype: pwdstoragescheme
+nsslapd-pluginenabled: on
+
dn: cn=AES,cn=Password Storage Schemes,cn=plugins,cn=config
objectclass: top
objectclass: nsSlapdPlugin
diff --git a/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c b/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c
new file mode 100644
index 000000000..1b3e5556d
--- /dev/null
+++ b/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c
@@ -0,0 +1,216 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright (C) 2016 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * License: GPL (version 3 or any later version).
+ * See LICENSE for details.
+ * END COPYRIGHT BLOCK **/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/*
+ * slapd hashed password routines
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "pwdstorage.h"
+
+#include <pk11pub.h>
+
+/* Need this for htonl and ntohl */
+#include <arpa/inet.h>
+
+/* WB Nist recommend 128 bits (16 bytes) in 2016, may as well go for more to future proof. */
+/* !!!!!!!! NEVER CHANGE THESE VALUES !!!!!!!! */
+#define PBKDF2_SALT_LENGTH 64
+#define PBKDF2_ITERATIONS_LENGTH 4
+/* If this isn't 256 NSS explodes without setting an error code .... */
+#define PBKDF2_HASH_LENGTH 256
+#define PBKDF2_TOTAL_LENGTH (PBKDF2_ITERATIONS_LENGTH + PBKDF2_SALT_LENGTH + PBKDF2_HASH_LENGTH)
+/* ======== END NEVER CHANGE THESE VALUES ==== */
+
+/*
+ * WB - It's important we keep this private, and we increment it over time.
+ * Administrators are likely to forget to update it, or they will set it too low.
+ * We therfore keep it private, so we can increase it as our security recomendations
+ * change and improve.
+ *
+ * At the same time we MUST increase this with each version of Directory Server
+ * This value is written into the hash, so it's safe to change.
+ */
+#define PBKDF2_ITERATIONS 30000
+
+static const char *schemeName = PBKDF2_SHA256_SCHEME_NAME;
+static const PRUint32 schemeNameLength = PBKDF2_SHA256_NAME_LEN;
+
+/* For requesting the slot which supports these types */
+static CK_MECHANISM_TYPE mechanism_array[] = {CKM_SHA256_HMAC, CKM_PKCS5_PBKD2};
+
+void
+pbkdf2_sha256_extract(char *hash_in, SECItem *salt, PRUint32 *iterations)
+{
+ /*
+ * This will take the input of hash_in (generated from pbkdf2_sha256_hash) and
+ * populate the hash (output of nss pkbdf2), salt, and iterations.
+ * Enough space should be avaliable in these for the values to fit into.
+ */
+
+ memcpy(iterations, hash_in, PBKDF2_ITERATIONS_LENGTH);
+ /* We use ntohl on this value to make sure it's correct endianess. */
+ *iterations = ntohl(*iterations);
+
+ /* warning: pointer targets in assignment differ in signedness [-Wpointer-sign] */
+ salt->data = (unsigned char *)(hash_in + PBKDF2_ITERATIONS_LENGTH);
+ salt->len = PBKDF2_SALT_LENGTH;
+}
+
+SECStatus
+pbkdf2_sha256_hash(char *hash_out, size_t hash_out_len, SECItem *pwd, SECItem *salt, PRUint32 iterations)
+{
+ SECItem *result = NULL;
+ SECAlgorithmID *algid = NULL;
+ PK11SlotInfo *slot = NULL;
+ PK11SymKey *symkey = NULL;
+
+ /* We assume that NSS is already started. */
+ algid = PK11_CreatePBEV2AlgorithmID(SEC_OID_PKCS5_PBKDF2, SEC_OID_HMAC_SHA256, SEC_OID_HMAC_SHA256, hash_out_len, iterations, salt);
+
+ if (algid != NULL) {
+ /* Gets the best slot that provides SHA256HMAC and PBKDF2 (may not be the default!) */
+ slot = PK11_GetBestSlotMultiple(mechanism_array, 2, NULL);
+ if (slot != NULL) {
+ symkey = PK11_PBEKeyGen(slot, algid, pwd, PR_FALSE, NULL);
+ PK11_FreeSlot(slot);
+ if (symkey == NULL) {
+ /* We try to get the Error here but NSS has two or more error interfaces, and sometimes it uses none of them. */
+ PRInt32 status = PORT_GetError();
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to retrieve symkey from NSS. Error code might be %d ???\n", status);
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "The most likely cause is your system has nss 3.21 or lower. PBKDF2 requires nss 3.22 or higher.\n");
+ return SECFailure;
+ }
+ } else {
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to retrieve slot from NSS.\n");
+ return SECFailure;
+ }
+ SECOID_DestroyAlgorithmID(algid, PR_TRUE);
+ } else {
+ /* Uh oh! */
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to generate algorithm ID.\n");
+ return SECFailure;
+ }
+
+ if (PK11_ExtractKeyValue(symkey) == SECSuccess) {
+ result = PK11_GetKeyData(symkey);
+ if (result != NULL && result->len <= hash_out_len) {
+ memcpy(hash_out, result->data, result->len);
+ PK11_FreeSymKey(symkey);
+ } else {
+ PK11_FreeSymKey(symkey);
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to retrieve (get) hash output.\n");
+ return SECFailure;
+ }
+ } else {
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to extract hash output.\n");
+ return SECFailure;
+ }
+
+ return SECSuccess;
+}
+
+char *
+pbkdf2_sha256_pw_enc(const char *pwd)
+{
+ char hash[ PBKDF2_TOTAL_LENGTH ];
+ size_t encsize = 3 + schemeNameLength + LDIF_BASE64_LEN(PBKDF2_TOTAL_LENGTH);
+ char *enc = slapi_ch_calloc(encsize, sizeof(char));
+ PRUint32 iterations = PBKDF2_ITERATIONS;
+
+ SECItem saltItem;
+ SECItem passItem;
+ char salt[PBKDF2_SALT_LENGTH];
+
+ memset(hash, 0, PBKDF2_TOTAL_LENGTH);
+ memset(salt, 0, PBKDF2_SALT_LENGTH);
+ saltItem.data = (unsigned char *)salt;
+ saltItem.len = PBKDF2_SALT_LENGTH;
+ passItem.data = (unsigned char *)pwd;
+ passItem.len = strlen(pwd);
+
+ /* make a new random salt */
+ slapi_rand_array(salt, PBKDF2_SALT_LENGTH);
+
+ /*
+ * Preload the salt and iterations to the output.
+ * memcpy the iterations to the hash_out
+ * We use ntohl on this value to make sure it's correct endianess.
+ */
+ iterations = htonl(iterations);
+ memcpy(hash, &iterations, PBKDF2_ITERATIONS_LENGTH);
+ /* memcpy the salt to the hash_out */
+ memcpy(hash + PBKDF2_ITERATIONS_LENGTH, saltItem.data, PBKDF2_SALT_LENGTH);
+
+ /*
+ * This offset is to make the hash function put the values
+ * In the correct part of the memory.
+ */
+ if ( pbkdf2_sha256_hash(hash + PBKDF2_ITERATIONS_LENGTH + PBKDF2_SALT_LENGTH, PBKDF2_HASH_LENGTH, &passItem, &saltItem, PBKDF2_ITERATIONS) != SECSuccess ) {
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Could not generate pbkdf2_sha256_hash!\n");
+ return NULL;
+ }
+
+ sprintf(enc, "%c%s%c", PWD_HASH_PREFIX_START, schemeName, PWD_HASH_PREFIX_END);
+ (void)PL_Base64Encode( hash, PBKDF2_TOTAL_LENGTH, enc + 2 + schemeNameLength);
+ PR_ASSERT(enc[encsize - 1] == '\0');
+
+ slapi_log_err(SLAPI_LOG_PLUGIN, (char *)schemeName, "Generated hash %s\n", enc);
+
+ return enc;
+}
+
+PRInt32
+pbkdf2_sha256_pw_cmp(const char *userpwd, const char *dbpwd)
+{
+ PRInt32 result = 1; /* Default to fail. */
+ char dbhash[ PBKDF2_TOTAL_LENGTH ];
+ char userhash[ PBKDF2_HASH_LENGTH ];
+ PRUint32 dbpwd_len = strlen(dbpwd);
+ SECItem saltItem;
+ SECItem passItem;
+ PRUint32 iterations = 0;
+
+ /* Our hash value is always at a known offset. */
+ char *hash = dbhash + PBKDF2_ITERATIONS_LENGTH + PBKDF2_SALT_LENGTH;
+
+ slapi_log_err(SLAPI_LOG_PLUGIN, (char *)schemeName, "Comparing password\n");
+
+ memset(dbhash, 0, PBKDF2_TOTAL_LENGTH);
+
+ passItem.data = (unsigned char *)userpwd;
+ passItem.len = strlen(userpwd);
+
+ /* Decode the DBpwd to bytes from b64 */
+ if ( PL_Base64Decode( dbpwd, dbpwd_len, dbhash) == NULL ) {
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to base64 decode dbpwd value\n");
+ return result;
+ }
+ /* extract the fields */
+ pbkdf2_sha256_extract(dbhash, &saltItem, &iterations);
+
+ /* Now send the userpw to the hash function, with the salt + iter. */
+ if ( pbkdf2_sha256_hash(userhash, PBKDF2_HASH_LENGTH, &passItem, &saltItem, iterations) != SECSuccess ) {
+ slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to hash userpwd value\n");
+ return result;
+ }
+ /* Now compare the result of pbkdf2_sha256_hash. */
+ result = memcmp(userhash, hash, PBKDF2_HASH_LENGTH);
+
+ return result;
+}
+
+
diff --git a/ldap/servers/plugins/pwdstorage/pwd_init.c b/ldap/servers/plugins/pwdstorage/pwd_init.c
index 5efd9ca1c..d66bb98cc 100644
--- a/ldap/servers/plugins/pwdstorage/pwd_init.c
+++ b/ldap/servers/plugins/pwdstorage/pwd_init.c
@@ -44,6 +44,8 @@ static Slapi_PluginDesc md5_pdesc = { "md5-password-storage-scheme", VENDOR, DS_
static Slapi_PluginDesc smd5_pdesc = { "smd5-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "Salted MD5 hash algorithm (SMD5)" };
+static Slapi_PluginDesc pbkdf2_sha256_pdesc = { "pbkdf2-sha256-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "Salted PBKDF2 SHA256 hash algorithm (PBKDF2_SHA256)" };
+
static char *plugin_name = "NSPwdStoragePlugin";
int
@@ -336,3 +338,21 @@ smd5_pwd_storage_scheme_init( Slapi_PBlock *pb )
slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "<= smd5_pwd_storage_scheme_init %d\n\n", rc );
return( rc );
}
+
+int
+pbkdf2_sha256_pwd_storage_scheme_init(Slapi_PBlock *pb)
+{
+ int rc;
+
+ slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name, "=> pbkdf2_sha256_pwd_storage_scheme_init\n");
+
+ rc = slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, (void *) SLAPI_PLUGIN_VERSION_01);
+ rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pbkdf2_sha256_pdesc);
+ rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN, (void *)pbkdf2_sha256_pw_enc);
+ rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN, (void *)pbkdf2_sha256_pw_cmp);
+ rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME, PBKDF2_SHA256_SCHEME_NAME);
+
+ slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name, "<= pbkdf2_sha256_pwd_storage_scheme_init %d\n", rc);
+ return rc;
+}
+
diff --git a/ldap/servers/plugins/pwdstorage/pwdstorage.h b/ldap/servers/plugins/pwdstorage/pwdstorage.h
index 1e085c74f..27e708d9c 100644
--- a/ldap/servers/plugins/pwdstorage/pwdstorage.h
+++ b/ldap/servers/plugins/pwdstorage/pwdstorage.h
@@ -54,6 +54,9 @@
#define MD5_NAME_LEN 3
#define SALTED_MD5_SCHEME_NAME "SMD5"
#define SALTED_MD5_NAME_LEN 4
+#define PBKDF2_SHA256_SCHEME_NAME "PBKDF2_SHA256"
+#define PBKDF2_SHA256_NAME_LEN 13
+
SECStatus sha_salted_hash(char *hash_out, const char *pwd, struct berval *salt, unsigned int secOID);
int sha_pw_cmp( const char *userpwd, const char *dbpwd, unsigned int shaLen );
@@ -82,6 +85,10 @@ char *md5_pw_enc( const char *pwd );
int smd5_pw_cmp( const char *userpwd, const char *dbpwd );
char *smd5_pw_enc( const char *pwd );
+SECStatus pbkdf2_sha256_hash(char *hash_out, size_t hash_out_len, SECItem *pwd, SECItem *salt, PRUint32 iterations);
+char * pbkdf2_sha256_pw_enc(const char *pwd);
+int pbkdf2_sha256_pw_cmp(const char *userpwd, const char *dbpwd);
+
/* Utility functions */
PRUint32 pwdstorage_base64_decode_len(const char *encval, PRUint32 enclen);
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 2506a2b91..5af04d216 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -262,6 +262,13 @@ pw_val2scheme( char *val, char **valpwdp, int first_is_default )
if (NULL == val) {
return( NULL );
}
+
+ /*
+ * Future implementors of new password mechanisms may find that this function
+ * is causing them trouble. If your hash ends up as {CLEAR}{NEWMECH}.... it
+ * because NEWMECH > PWD_MAX_NAME_LEN. Update pw.h!
+ */
+
if ( *val != PWD_HASH_PREFIX_START ||
( end = strchr( val, PWD_HASH_PREFIX_END )) == NULL ||
( namelen = end - val - 1 ) > PWD_MAX_NAME_LEN ) {
diff --git a/ldap/servers/slapd/pw.h b/ldap/servers/slapd/pw.h
index 58e744125..8e07582f3 100644
--- a/ldap/servers/slapd/pw.h
+++ b/ldap/servers/slapd/pw.h
@@ -19,7 +19,8 @@
#ifndef _SLAPD_PW_H_
#define _SLAPD_PW_H_
-#define PWD_MAX_NAME_LEN 10
+// Updated to the 13 for PBKDF2_SHA256
+#define PWD_MAX_NAME_LEN 13
#define PWD_HASH_PREFIX_START '{'
#define PWD_HASH_PREFIX_END '}'
| 0 |
87876bca40a08630ccd8ab84c70b0a524235d1a5
|
389ds/389-ds-base
|
Update Source0 URL in rpm/389-ds-base.spec.in
|
commit 87876bca40a08630ccd8ab84c70b0a524235d1a5
Author: Samuel Rakitničan <[email protected]>
Date: Sat Jun 23 07:17:28 2018 +0000
Update Source0 URL in rpm/389-ds-base.spec.in
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index b382d3eb9..d56266be2 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -1,4 +1,3 @@
-
%global pkgname dirsrv
%global srcname 389-ds-base
@@ -160,7 +159,7 @@ Requires: perl-Archive-Tar
# Picks up our systemd deps.
%{?systemd_requires}
-Source0: http://www.port389.org/sources/%{name}-%{version}%{?prerel}.tar.bz2
+Source0: https://releases.pagure.org/%{name}/%{name}-%{version}%{?prerel}.tar.bz2
# 389-ds-git.sh should be used to generate the source tarball from git
Source1: %{name}-git.sh
Source2: %{name}-devel.README
| 0 |
069657f1b3c04390c438066bd9ddc8c6a79f1dd0
|
389ds/389-ds-base
|
Ticket 47510 - 389-ds-base does not compile against MozLDAP libraries
Used #ifdef's to remove openldap specific API calls.
Thanks to mvocu for providing the initial patch.
https://fedorahosted.org/389/ticket/47510
Reviewed by: rmeggins(Thanks!)
|
commit 069657f1b3c04390c438066bd9ddc8c6a79f1dd0
Author: Mark Reynolds <[email protected]>
Date: Fri Sep 27 09:20:51 2013 -0400
Ticket 47510 - 389-ds-base does not compile against MozLDAP libraries
Used #ifdef's to remove openldap specific API calls.
Thanks to mvocu for providing the initial patch.
https://fedorahosted.org/389/ticket/47510
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index ba40f53d9..aed76ed0b 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -2541,8 +2541,9 @@ bail:
void
handle_closed_connection(Connection *conn)
{
- ber_sockbuf_remove_io(conn->c_sb, &openldap_sockbuf_io,
- LBER_SBIOD_LEVEL_PROVIDER);
+#ifdef USE_OPENLDAP
+ ber_sockbuf_remove_io(conn->c_sb, &openldap_sockbuf_io, LBER_SBIOD_LEVEL_PROVIDER);
+#endif
}
/* NOTE: this routine is not reentrant */
@@ -2628,8 +2629,9 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
}
#endif /* !USE_OPENLDAP */
maxbersize = config_get_maxbersize();
+#if defined(USE_OPENLDAP)
ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &maxbersize );
-
+#endif
if( secure && config_get_SSLclientAuth() != SLAPD_SSLCLIENTAUTH_OFF ) {
/* Prepare to handle the client's certificate (if any): */
int rv;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index f9042679c..659bf87fd 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -374,6 +374,11 @@ NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
#define LDAP_MAXINT (2147483647)
#endif
+/* for mozldap builds */
+#ifndef LDAP_CANCELLED
+#define LDAP_CANCELLED 0x76
+#endif
+
/*
* Sequential access types
*/
| 0 |
1c888bf957de4b88734d1796caa338ef944b7c7a
|
389ds/389-ds-base
|
Ticket #47879 - coverity defects in plugins/replication/windows_protocol_util.c
Description:
Defect type: CLANG_WARNING
1. ldap/servers/plugins/replication/windows_protocol_util.c:6024:warning – Value stored to 'rc' is never read
# rc = windows_process_dirsync_entry(prp,e,0);
# ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Removed the unnecessary assignment.
2. ldap/servers/plugins/replication/windows_protocol_util.c:1713:warning – Value stored to 'return_value' is never read
# return_value = windows_conn_send_rename(prp->conn, slapi_sdn_get_dn(remote_dn),
# ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Added return_value checking code.
3. ldap/servers/plugins/replication/windows_protocol_util.c:629:warning – Value stored to 'return_value' is never read
Removed the unnecessary assignment to return_value.
https://fedorahosted.org/389/ticket/47879
Reviewed by [email protected] (Thank you, Mark!!)
|
commit 1c888bf957de4b88734d1796caa338ef944b7c7a
Author: Noriko Hosoi <[email protected]>
Date: Tue Aug 26 11:19:28 2014 -0700
Ticket #47879 - coverity defects in plugins/replication/windows_protocol_util.c
Description:
Defect type: CLANG_WARNING
1. ldap/servers/plugins/replication/windows_protocol_util.c:6024:warning – Value stored to 'rc' is never read
# rc = windows_process_dirsync_entry(prp,e,0);
# ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Removed the unnecessary assignment.
2. ldap/servers/plugins/replication/windows_protocol_util.c:1713:warning – Value stored to 'return_value' is never read
# return_value = windows_conn_send_rename(prp->conn, slapi_sdn_get_dn(remote_dn),
# ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Added return_value checking code.
3. ldap/servers/plugins/replication/windows_protocol_util.c:629:warning – Value stored to 'return_value' is never read
Removed the unnecessary assignment to return_value.
https://fedorahosted.org/389/ticket/47879
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index caeb388f7..c42459033 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -626,7 +626,6 @@ windows_acquire_replica(Private_Repl_Protocol *prp, RUV **ruv, int check_ruv)
slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,
"%s: Remote replica already acquired\n",
agmt_get_long_name(prp->agmt));
- return_value = ACQUIRE_FATAL_ERROR;
LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_acquire_replica\n", 0, 0, 0 );
return ACQUIRE_SUCCESS;
}
@@ -1662,6 +1661,8 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op
{
LDAPMod **mapped_mods = NULL;
char *newrdn = NULL;
+ int ldap_op = 0;
+ int ldap_result_code = 0;
/*
* If the magic objectclass and attributes have been added to the entry
@@ -1707,12 +1708,24 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op
/* Check if a naming attribute is being modified. */
if (windows_check_mods_for_rdn_change(prp, op->p.p_modify.modify_mods, local_entry, remote_dn, &newrdn)) {
/* Issue MODRDN */
+ /*
+ * remote_dn is in GUID format. Thus, this MODRDN does not change the remote_dn but the DN on AD only.
+ * Thus, no need to "rename" remote_dn for the following windows_conn_send_modify.
+ */
slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name, "%s: renaming remote entry \"%s\" with new RDN of \"%s\"\n",
agmt_get_long_name(prp->agmt), slapi_sdn_get_dn(remote_dn), newrdn);
return_value = windows_conn_send_rename(prp->conn, slapi_sdn_get_dn(remote_dn),
newrdn, NULL, 1 /* delete old RDN */,
NULL, NULL /* returned controls */);
slapi_ch_free_string(&newrdn);
+ windows_conn_get_error(prp->conn, &ldap_op, &ldap_result_code);
+ if (return_value != CONN_OPERATION_SUCCESS) {
+ if (!ldap_result_code) {
+ /* op failed but no ldap error code ??? */
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ goto bail_modify;
+ }
}
/* It's possible that the mapping process results in an empty mod list, in which case we don't bother with the replay */
@@ -1721,8 +1734,6 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op
return_value = CONN_OPERATION_SUCCESS;
} else
{
- int ldap_op = 0;
- int ldap_result_code = 0;
if (slapi_is_loglevel_set(SLAPI_LOG_REPL))
{
int i = 0;
@@ -1761,6 +1772,7 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op
windows_conn_set_error(prp->conn, ldap_result_code);
}
}
+bail_modify:
if (mapped_mods)
{
ldap_mods_free(mapped_mods,1);
@@ -6013,7 +6025,7 @@ windows_dirsync_inc_run(Private_Repl_Protocol *prp)
while ( (e = windows_conn_get_search_result(prp->conn) ) != NULL)
{
- rc = windows_process_dirsync_entry(prp,e,0);
+ (void)windows_process_dirsync_entry(prp,e,0);
if (e)
{
slapi_entry_free(e);
| 0 |
4d5915f350478e769ebcc2638508bb2184681064
|
389ds/389-ds-base
|
Issue 4105 - Remove python.six from lib389 (#4456)
Description: We no longer use python 2, we can remove all the python-six
imports and replace code with Python 3 support only.
Fixes: #4105
Reviewed by: @mreynolds389 @Firstyear (Thanks!)
|
commit 4d5915f350478e769ebcc2638508bb2184681064
Author: Simon Pichugin <[email protected]>
Date: Tue Nov 24 17:06:52 2020 +0100
Issue 4105 - Remove python.six from lib389 (#4456)
Description: We no longer use python 2, we can remove all the python-six
imports and replace code with Python 3 support only.
Fixes: #4105
Reviewed by: @mreynolds389 @Firstyear (Thanks!)
diff --git a/dirsrvtests/tests/suites/schema/schema_test.py b/dirsrvtests/tests/suites/schema/schema_test.py
index d590624b6..a0009243f 100644
--- a/dirsrvtests/tests/suites/schema/schema_test.py
+++ b/dirsrvtests/tests/suites/schema/schema_test.py
@@ -15,7 +15,6 @@ import logging
import ldap
import pytest
-import six
from ldap.cidict import cidict
from ldap.schema import SubSchema
from lib389._constants import *
@@ -69,7 +68,7 @@ def mycmp(v1, v2):
if not len(v1ary) == len(v2ary):
return False
for v1, v2 in zip(v1ary, v2ary):
- if isinstance(v1, six.string_types):
+ if isinstance(v1, str):
if not len(v1) == len(v2):
return False
if not v1 == v2:
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index a810690cb..9db02012e 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -123,7 +123,6 @@ BuildRequires: python%{python3_pkgversion}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-ldap
-BuildRequires: python%{python3_pkgversion}-six
BuildRequires: python%{python3_pkgversion}-pyasn1
BuildRequires: python%{python3_pkgversion}-pyasn1-modules
BuildRequires: python%{python3_pkgversion}-dateutil
@@ -272,7 +271,6 @@ Requires: python%{python3_pkgversion}
Requires: python%{python3_pkgversion}-distro
Requires: python%{python3_pkgversion}-pytest
Requires: python%{python3_pkgversion}-ldap
-Requires: python%{python3_pkgversion}-six
Requires: python%{python3_pkgversion}-pyasn1
Requires: python%{python3_pkgversion}-pyasn1-modules
Requires: python%{python3_pkgversion}-dateutil
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 4a383782e..45d80bb27 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -44,7 +44,6 @@ import errno
import uuid
import json
from shutil import copy2
-import six
# Deprecation
import warnings
@@ -1735,14 +1734,14 @@ class DirSrv(SimpleLDAPObject, object):
process_url_schemes=None
):
myfile = input_file
- if isinstance(input_file, six.string_types):
+ if isinstance(input_file, str):
myfile = open(input_file, "r")
self.conn = conn
self.cont = cont
ldif.LDIFParser.__init__(self, myfile, ignored_attr_types,
max_entries, process_url_schemes)
self.parse()
- if isinstance(input_file, six.string_types):
+ if isinstance(input_file, str):
myfile.close()
def handle(self, dn, entry):
@@ -1905,7 +1904,7 @@ class DirSrv(SimpleLDAPObject, object):
for attr in dbattrs:
fmtstr += ' %%(%s)%ds' % (attr, cols[attr][0])
ret += ' %*s' % tuple(cols[attr])
- for dbf in six.itervalues(dbrec):
+ for dbf in dbrec.values():
ret += "\n" + (fmtstr % dbf)
return ret
except Exception as e:
@@ -2488,10 +2487,10 @@ class DirSrv(SimpleLDAPObject, object):
def setDNPwdPolicy(self, dn, pwdpolicy, **pwdargs):
"""input is dict of attr/vals"""
mods = []
- for (attr, val) in six.iteritems(pwdpolicy):
+ for (attr, val) in pwdpolicy.items():
mods.append((ldap.MOD_REPLACE, attr, ensure_bytes(val)))
if pwdargs:
- for (attr, val) in six.iteritems(pwdargs):
+ for (attr, val) in pwdargs.items():
mods.append((ldap.MOD_REPLACE, attr, ensure_bytes(val)))
self.modify_s(dn, mods)
diff --git a/src/lib389/lib389/_entry.py b/src/lib389/lib389/_entry.py
index d24ca0482..52e956542 100644
--- a/src/lib389/lib389/_entry.py
+++ b/src/lib389/lib389/_entry.py
@@ -6,7 +6,7 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
-import six
+import io
import logging
import ldif
import ldap
@@ -68,7 +68,7 @@ class Entry(object):
else:
self.dn = entrydata[0]
self.data = cidict(entrydata[1])
- elif isinstance(entrydata, six.string_types):
+ elif isinstance(entrydata, str):
if '=' not in entrydata:
raise ValueError('Entry dn must contain "="')
self.dn = entrydata
@@ -216,9 +216,9 @@ class Entry(object):
def iterAttrs(self, attrsOnly=False):
if attrsOnly:
- return six.iterkeys(self.data)
+ return self.data.keys()
else:
- return six.iteritems(self.data)
+ return self.data.items()
setValues = setValue
@@ -268,7 +268,7 @@ class Entry(object):
def __repr__(self):
"""Convert the Entry to its LDIF representation"""
- sio = six.StringIO()
+ sio = io.StringIO
"""
what's all this then? the unparse method will currently only accept
a list or a dict, not a class derived from them. self.data is a
diff --git a/src/lib389/lib389/_ldifconn.py b/src/lib389/lib389/_ldifconn.py
index b6ef5a721..6f2048668 100644
--- a/src/lib389/lib389/_ldifconn.py
+++ b/src/lib389/lib389/_ldifconn.py
@@ -7,7 +7,6 @@
# --- END COPYRIGHT BLOCK ---
import ldif
-import six
from lib389._entry import Entry
from lib389.utils import normalizeDN
@@ -30,12 +29,12 @@ class LDIFConn(ldif.LDIFParser):
self.dndict = {} # maps dn to Entry
self.dnlist = [] # contains entries in order read
myfile = input_file
- if isinstance(input_file, six.string_types):
+ if isinstance(input_file, str):
myfile = open(input_file, "r")
ldif.LDIFParser.__init__(self, myfile, ignored_attr_types,
max_entries, process_url_schemes)
self.parse()
- if isinstance(input_file, six.string_types):
+ if isinstance(input_file, str):
myfile.close()
def handle(self, dn, entry):
diff --git a/src/lib389/lib389/agreement.py b/src/lib389/lib389/agreement.py
index ecbe25b4c..d3c15accf 100644
--- a/src/lib389/lib389/agreement.py
+++ b/src/lib389/lib389/agreement.py
@@ -9,7 +9,6 @@
import ldap
import re
import time
-import six
import json
import datetime
from lib389._constants import *
@@ -747,7 +746,7 @@ class AgreementLegacy(object):
# Build the result from the returned attributes
for attr in entry.getAttrs():
# given an attribute name retrieve the property name
- props = [k for k, v in six.iteritems(RA_PROPNAME_TO_ATTRNAME)
+ props = [k for k, v in RA_PROPNAME_TO_ATTRNAME.items()
if v.lower() == attr.lower()]
# If this attribute is present in the RA properties, adds it to
diff --git a/src/lib389/lib389/mappingTree.py b/src/lib389/lib389/mappingTree.py
index 885674d4f..dca0964c9 100644
--- a/src/lib389/lib389/mappingTree.py
+++ b/src/lib389/lib389/mappingTree.py
@@ -8,7 +8,6 @@
import ldap
from ldap.dn import str2dn, dn2str
-import six
from lib389._constants import *
from lib389.properties import *
from lib389.utils import suffixfilt, normalizeDN
@@ -317,7 +316,7 @@ class MappingTreeLegacy(object):
# now look for each attribute from the MT entry
for attr in ent.getAttrs():
# given an attribute name retrieve the property name
- props = [k for k, v in six.iteritems(MT_PROPNAME_TO_ATTRNAME)
+ props = [k for k, v in MT_PROPNAME_TO_ATTRNAME.items()
if v.lower() == attr.lower()]
# If this attribute is present in the MT properties and was
diff --git a/src/lib389/lib389/tests/config.py b/src/lib389/lib389/tests/config.py
index 860fcb4bd..4887b614f 100644
--- a/src/lib389/lib389/tests/config.py
+++ b/src/lib389/lib389/tests/config.py
@@ -1,5 +1,4 @@
import logging
-import six
logging.basicConfig(level=logging.DEBUG)
@@ -37,4 +36,4 @@ def entry_equals(e1, e2):
def dfilter(my_dict, keys):
"""Filter a dict in a 2.4-compatible way"""
- return dict([(k, v) for k, v in six.iteritems(my_dict) if k in keys])
+ return dict([(k, v) for k, v in my_dict.items() if k in keys])
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index c56712b44..b2ab009a9 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -36,7 +36,6 @@ from datetime import datetime
import sys
import filecmp
import pwd
-import six
import shlex
import operator
import subprocess
@@ -83,101 +82,101 @@ searches = {
# Map table for pseudolocalized strings
_chars = {
- " ": six.u("\u2003"),
- "!": six.u("\u00a1"),
- "\"": six.u("\u2033"),
- "#": six.u("\u266f"),
- "$": six.u("\u20ac"),
- "%": six.u("\u2030"),
- "&": six.u("\u214b"),
- "'": six.u("\u00b4"),
- ")": six.u("}"),
- "(": six.u("{"),
- "*": six.u("\u204e"),
- "+": six.u("\u207a"),
- ",": six.u("\u060c"),
- "-": six.u("\u2010"),
- ".": six.u("\u00b7"),
- "/": six.u("\u2044"),
- "0": six.u("\u24ea"),
- "1": six.u("\u2460"),
- "2": six.u("\u2461"),
- "3": six.u("\u2462"),
- "4": six.u("\u2463"),
- "5": six.u("\u2464"),
- "6": six.u("\u2465"),
- "7": six.u("\u2466"),
- "8": six.u("\u2467"),
- "9": six.u("\u2468"),
- ":": six.u("\u2236"),
- ";": six.u("\u204f"),
- "<": six.u("\u2264"),
- "=": six.u("\u2242"),
- ">": six.u("\u2265"),
- "?": six.u("\u00bf"),
- "@": six.u("\u055e"),
- "A": six.u("\u00c5"),
- "B": six.u("\u0181"),
- "C": six.u("\u00c7"),
- "D": six.u("\u00d0"),
- "E": six.u("\u00c9"),
- "F": six.u("\u0191"),
- "G": six.u("\u011c"),
- "H": six.u("\u0124"),
- "I": six.u("\u00ce"),
- "J": six.u("\u0134"),
- "K": six.u("\u0136"),
- "L": six.u("\u013b"),
- "M": six.u("\u1e40"),
- "N": six.u("\u00d1"),
- "O": six.u("\u00d6"),
- "P": six.u("\u00de"),
- "Q": six.u("\u01ea"),
- "R": six.u("\u0154"),
- "S": six.u("\u0160"),
- "T": six.u("\u0162"),
- "U": six.u("\u00db"),
- "V": six.u("\u1e7c"),
- "W": six.u("\u0174"),
- "X": six.u("\u1e8a"),
- "Y": six.u("\u00dd"),
- "Z": six.u("\u017d"),
- "[": six.u("\u2045"),
- "\\": six.u("\u2216"),
- "]": six.u("\u2046"),
- "^": six.u("\u02c4"),
- "_": six.u("\u203f"),
- "`": six.u("\u2035"),
- "a": six.u("\u00e5"),
- "b": six.u("\u0180"),
- "c": six.u("\u00e7"),
- "d": six.u("\u00f0"),
- "e": six.u("\u00e9"),
- "f": six.u("\u0192"),
- "g": six.u("\u011d"),
- "h": six.u("\u0125"),
- "i": six.u("\u00ee"),
- "j": six.u("\u0135"),
- "k": six.u("\u0137"),
- "l": six.u("\u013c"),
- "m": six.u("\u0271"),
- "n": six.u("\u00f1"),
- "o": six.u("\u00f6"),
- "p": six.u("\u00fe"),
- "q": six.u("\u01eb"),
- "r": six.u("\u0155"),
- "s": six.u("\u0161"),
- "t": six.u("\u0163"),
- "u": six.u("\u00fb"),
- "v": six.u("\u1e7d"),
- "w": six.u("\u0175"),
- "x": six.u("\u1e8b"),
- "y": six.u("\u00fd"),
- "z": six.u("\u017e"),
- "{": six.u("("),
- "}": six.u(")"),
- "|": six.u("\u00a6"),
- "~": six.u("\u02de"),
+ " ": u"\u2003",
+ "!": u"\u00a1",
+ "\"": u"\u2033",
+ "#": u"\u266f",
+ "$": u"\u20ac",
+ "%": u"\u2030",
+ "&": u"\u214b",
+ "'": u"\u00b4",
+ ")": u"}",
+ "(": u"{",
+ "*": u"\u204e",
+ "+": u"\u207a",
+ ",": u"\u060c",
+ "-": u"\u2010",
+ ".": u"\u00b7",
+ "/": u"\u2044",
+ "0": u"\u24ea",
+ "1": u"\u2460",
+ "2": u"\u2461",
+ "3": u"\u2462",
+ "4": u"\u2463",
+ "5": u"\u2464",
+ "6": u"\u2465",
+ "7": u"\u2466",
+ "8": u"\u2467",
+ "9": u"\u2468",
+ ":": u"\u2236",
+ ";": u"\u204f",
+ "<": u"\u2264",
+ "=": u"\u2242",
+ ">": u"\u2265",
+ "?": u"\u00bf",
+ "@": u"\u055e",
+ "A": u"\u00c5",
+ "B": u"\u0181",
+ "C": u"\u00c7",
+ "D": u"\u00d0",
+ "E": u"\u00c9",
+ "F": u"\u0191",
+ "G": u"\u011c",
+ "H": u"\u0124",
+ "I": u"\u00ce",
+ "J": u"\u0134",
+ "K": u"\u0136",
+ "L": u"\u013b",
+ "M": u"\u1e40",
+ "N": u"\u00d1",
+ "O": u"\u00d6",
+ "P": u"\u00de",
+ "Q": u"\u01ea",
+ "R": u"\u0154",
+ "S": u"\u0160",
+ "T": u"\u0162",
+ "U": u"\u00db",
+ "V": u"\u1e7c",
+ "W": u"\u0174",
+ "X": u"\u1e8a",
+ "Y": u"\u00dd",
+ "Z": u"\u017d",
+ "[": u"\u2045",
+ "\\": u"\u2216",
+ "]": u"\u2046",
+ "^": u"\u02c4",
+ "_": u"\u203f",
+ "`": u"\u2035",
+ "a": u"\u00e5",
+ "b": u"\u0180",
+ "c": u"\u00e7",
+ "d": u"\u00f0",
+ "e": u"\u00e9",
+ "f": u"\u0192",
+ "g": u"\u011d",
+ "h": u"\u0125",
+ "i": u"\u00ee",
+ "j": u"\u0135",
+ "k": u"\u0137",
+ "l": u"\u013c",
+ "m": u"\u0271",
+ "n": u"\u00f1",
+ "o": u"\u00f6",
+ "p": u"\u00fe",
+ "q": u"\u01eb",
+ "r": u"\u0155",
+ "s": u"\u0161",
+ "t": u"\u0163",
+ "u": u"\u00fb",
+ "v": u"\u1e7d",
+ "w": u"\u0175",
+ "x": u"\u1e8b",
+ "y": u"\u00fd",
+ "z": u"\u017e",
+ "{": u"(",
+ "}": u")",
+ "|": u"\u00a6",
+ "~": u"\u02de",
}
#
@@ -1226,7 +1225,7 @@ def ensure_dict_str(val):
def pseudolocalize(string):
- pseudo_string = six.u("")
+ pseudo_string = u""
for char in string:
try:
pseudo_string += _chars[char]
diff --git a/src/lib389/requirements.txt b/src/lib389/requirements.txt
index 760eaae97..172a627ba 100644
--- a/src/lib389/requirements.txt
+++ b/src/lib389/requirements.txt
@@ -2,7 +2,6 @@ pyasn1
pyasn1-modules
pytest
python-dateutil
-six
argcomplete
argparse-manpage
python-ldap
diff --git a/src/lib389/setup.py b/src/lib389/setup.py
index 10735b9f2..4c348c527 100644
--- a/src/lib389/setup.py
+++ b/src/lib389/setup.py
@@ -81,7 +81,6 @@ setup(
'pyasn1-modules',
'pytest',
'python-dateutil',
- 'six',
'argcomplete',
'argparse-manpage',
'python-ldap',
| 0 |
0d5214d08e6b5b39fb9d5ef5cf3d8834574954f1
|
389ds/389-ds-base
|
Ticket 49296 - Fix race condition in connection code with
anonymous limits
Bug Description: When a connection first comes in we set the anonymous
resource limits (if set) before we do anything else. The
way we check if the connection is "new" was flawed. It
assumed the connection was new if no operations were
completed yet, but there was a small window between sending
the result and setting that the operation completed in the
connection struct.
So on a connection that binds and then does a search, when
the server sends the bind result the client sends the search,
but the search op/activity can be picked up before we set
c_opscompleted. This opens a window where the code thinks
the search op is the first op(new connection), and it incorrectly
sets the anonymous limits for the bind dn.
Fix description: Do not use c_opscompleted to determine if a connection is new,
instead use a new flag to set the connection "initialized",
which prevents the race condition.
https://pagure.io/389-ds-base/issue/49296
Reviewed by: firstyear(Thanks!)
|
commit 0d5214d08e6b5b39fb9d5ef5cf3d8834574954f1
Author: Mark Reynolds <[email protected]>
Date: Mon Feb 19 10:44:36 2018 -0500
Ticket 49296 - Fix race condition in connection code with
anonymous limits
Bug Description: When a connection first comes in we set the anonymous
resource limits (if set) before we do anything else. The
way we check if the connection is "new" was flawed. It
assumed the connection was new if no operations were
completed yet, but there was a small window between sending
the result and setting that the operation completed in the
connection struct.
So on a connection that binds and then does a search, when
the server sends the bind result the client sends the search,
but the search op/activity can be picked up before we set
c_opscompleted. This opens a window where the code thinks
the search op is the first op(new connection), and it incorrectly
sets the anonymous limits for the bind dn.
Fix description: Do not use c_opscompleted to determine if a connection is new,
instead use a new flag to set the connection "initialized",
which prevents the race condition.
https://pagure.io/389-ds-base/issue/49296
Reviewed by: firstyear(Thanks!)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 5d2b64ed2..5ca32a333 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -217,6 +217,7 @@ connection_cleanup(Connection *conn)
conn->c_connid = 0;
conn->c_opsinitiated = 0;
conn->c_opscompleted = 0;
+ conn->c_anonlimits_set = 0;
conn->c_threadnumber = 0;
conn->c_refcnt = 0;
conn->c_idlesince = 0;
@@ -1549,7 +1550,9 @@ connection_threadmain()
g_decr_active_threadcnt();
return;
}
- if (pb_conn->c_opscompleted == 0) {
+
+ PR_EnterMonitor(pb_conn->c_mutex);
+ if (pb_conn->c_anonlimits_set == 0) {
/*
* We have a new connection, set the anonymous reslimit idletimeout
* if applicable.
@@ -1568,7 +1571,14 @@ connection_threadmain()
}
}
slapi_ch_free_string(&anon_dn);
+ /*
+ * Set connection as initialized to avoid setting anonymous limits
+ * multiple times on the same connection
+ */
+ pb_conn->c_anonlimits_set = 1;
}
+ PR_ExitMonitor(pb_conn->c_mutex);
+
if (connection_call_io_layer_callbacks(pb_conn)) {
slapi_log_err(SLAPI_LOG_ERR, "connection_threadmain",
"Could not add/remove IO layers from connection\n");
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 70605f91e..e58f4883c 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1616,6 +1616,7 @@ typedef struct conn
PRUint64 c_maxthreadsblocked; /* # of operations blocked by maxthreads */
int c_opsinitiated; /* # ops initiated/next op id */
PRInt32 c_opscompleted; /* # ops completed */
+ uint64_t c_anonlimits_set; /* default anon limits are set */
PRInt32 c_threadnumber; /* # threads used in this conn */
int c_refcnt; /* # ops refering to this conn */
PRMonitor *c_mutex; /* protect each conn structure; need to be re-entrant */
@@ -1623,10 +1624,8 @@ typedef struct conn
time_t c_idlesince; /* last time of activity on conn */
int c_idletimeout; /* local copy of idletimeout */
int c_idletimeout_handle; /* the resource limits handle */
- Conn_private *c_private; /* data which is not shared outside*/
- /* connection.c */
- int c_flags; /* Misc flags used only for SSL */
- /* status currently */
+ Conn_private *c_private; /* data which is not shared outside connection.c */
+ int c_flags; /* Misc flags used only for SSL status currently */
int c_needpw; /* need new password */
CERTCertificate *c_client_cert; /* Client's Cert */
PRFileDesc *c_prfd; /* NSPR 2.1 FileDesc */
| 0 |
ceb0d93333f8ccf52fcc413c78789d17ff48be82
|
389ds/389-ds-base
|
Resolves: 445775
Summary: Avoid replicating default schema when DESC element is an empty string.
|
commit ceb0d93333f8ccf52fcc413c78789d17ff48be82
Author: Nathan Kinder <[email protected]>
Date: Thu Dec 4 22:33:29 2008 +0000
Resolves: 445775
Summary: Avoid replicating default schema when DESC element is an empty string.
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 5613efb34..e63d9068c 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -1497,9 +1497,13 @@ read_schema_dse(
(oc->oc_oid) ? oc->oc_oid : "",
oc->oc_name);
/* The DESC (description) is OPTIONAL */
- if (oc_description && *oc_description) {
+ if (oc_description) {
strcat(psbObjectClasses->buffer, " DESC '");
- strcat(psbObjectClasses->buffer, oc_description);
+ /* We want to list an empty description
+ * element if it was defined that way. */
+ if (*oc_description) {
+ strcat(psbObjectClasses->buffer, oc_description);
+ }
strcat(psbObjectClasses->buffer, "'");
need_extra_space = 1;
}
| 0 |
b0689cd259875ab828ca2d528bcf6b3e55296bff
|
389ds/389-ds-base
|
Ticket 48118 - At startup, changelog can be erronously rebuilt after a normal shutdown
Problem: There are two problems that can lead to inconsistent database and changelog maxruv:
1] the database ruv is written periodically in th ehouskeeping thread and at shutdown. It
relies on teh ruv_dirty flag, but due to a race condition this can be reset befor writing
the ruv
2] the changelog max ruv is updated whenever an operation is commutted, but in case of internal
operations inside the txn for a client operation, if the operation is aborted the cl maxruv
is not reset. Since it is only written at shutdown this normally is no problem, but if the
aborted operation is the last before shutdown or is aborted by shutdown the cl ruv is incorrect
Fix: the fix is in two parts:
1] remove the use of the dirty flag, ensure that the ruv is always written. The overhead for writing
a database ruv that has not changed is minimal
2] when writing the changelog maxruv check if the macsns it contains are really present in the
changelog. If not the maxruv is not written, it will be reconstructed at the next startup
Reviewed by: William,Thierry - Thanks
|
commit b0689cd259875ab828ca2d528bcf6b3e55296bff
Author: Ludwig Krispenz <[email protected]>
Date: Thu Nov 9 11:28:34 2017 +0100
Ticket 48118 - At startup, changelog can be erronously rebuilt after a normal shutdown
Problem: There are two problems that can lead to inconsistent database and changelog maxruv:
1] the database ruv is written periodically in th ehouskeeping thread and at shutdown. It
relies on teh ruv_dirty flag, but due to a race condition this can be reset befor writing
the ruv
2] the changelog max ruv is updated whenever an operation is commutted, but in case of internal
operations inside the txn for a client operation, if the operation is aborted the cl maxruv
is not reset. Since it is only written at shutdown this normally is no problem, but if the
aborted operation is the last before shutdown or is aborted by shutdown the cl ruv is incorrect
Fix: the fix is in two parts:
1] remove the use of the dirty flag, ensure that the ruv is always written. The overhead for writing
a database ruv that has not changed is minimal
2] when writing the changelog maxruv check if the macsns it contains are really present in the
changelog. If not the maxruv is not written, it will be reconstructed at the next startup
Reviewed by: William,Thierry - Thanks
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index ec648c014..55032dfb0 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -250,6 +250,8 @@ static void _cl5ReadBerval(struct berval *bv, char **buff);
static void _cl5WriteBerval(struct berval *bv, char **buff);
static int _cl5ReadBervals(struct berval ***bv, char **buff, unsigned int size);
static int _cl5WriteBervals(struct berval **bv, char **buff, u_int32_t *size);
+static int64_t _cl5CheckMaxRUV(CL5DBFile *file, RUV *maxruv);
+static int64_t _cl5CheckCSNinCL(const ruv_enum_data *element, void *arg);
/* replay iteration */
#ifdef FOR_DEBUGGING
@@ -2716,6 +2718,36 @@ _cl5WriteBervals(struct berval **bv, char **buff, u_int32_t *size)
return CL5_SUCCESS;
}
+static int64_t
+_cl5CheckCSNinCL(const ruv_enum_data *element, void *arg)
+{
+ CL5DBFile *file = (CL5DBFile *)arg;
+ int rc = 0;
+
+ DBT key = {0}, data = {0};
+ char csnStr[CSN_STRSIZE];
+
+ /* construct the key */
+ key.data = csn_as_string(element->csn, PR_FALSE, csnStr);
+ key.size = CSN_STRSIZE;
+
+ data.flags = DB_DBT_MALLOC;
+
+ rc = file->db->get(file->db, NULL /*txn*/, &key, &data, 0);
+
+ slapi_ch_free(&(data.data));
+ return rc;
+}
+
+static int64_t
+_cl5CheckMaxRUV(CL5DBFile *file, RUV *maxruv)
+{
+ int rc = 0;
+
+ rc = ruv_enumerate_elements(maxruv, _cl5CheckCSNinCL, (void *)file);
+
+ return rc;
+}
/* upgrade from db33 to db41
* 1. Run recovery on the database environment using the DB_ENV->open method
* 2. Remove any Berkeley DB environment using the DB_ENV->remove method
@@ -4010,6 +4042,13 @@ _cl5WriteRUV(CL5DBFile *file, PRBool purge)
rc = ruv_to_bervals(file->maxRUV, &vals);
}
+ if (!purge && _cl5CheckMaxRUV(file, file->maxRUV)) {
+ slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl,
+ "_cl5WriteRUV - changelog maxRUV not found in changelog for file %s\n",
+ file->name);
+ return CL5_DB_ERROR;
+ }
+
key.size = CSN_STRSIZE;
rc = _cl5WriteBervals(vals, &buff, &data.size);
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index c6e79b7e2..4e206a0fc 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -725,7 +725,6 @@ Object *replica_get_for_backend(const char *be_name);
void replica_set_purge_delay(Replica *r, uint32_t purge_delay);
void replica_set_tombstone_reap_interval(Replica *r, long interval);
void replica_update_ruv_consumer(Replica *r, RUV *supplier_ruv);
-void replica_set_ruv_dirty(Replica *r);
Slapi_Entry *get_in_memory_ruv(Slapi_DN *suffix_sdn);
int replica_write_ruv(Replica *r);
char *replica_get_dn(Replica *r);
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index e5296bf1c..77f4f18e4 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -41,7 +41,6 @@ struct replica
ReplicaType repl_type; /* is this replica read-only ? */
ReplicaId repl_rid; /* replicaID */
Object *repl_ruv; /* replica update vector */
- PRBool repl_ruv_dirty; /* Dirty flag for ruv */
CSNPL *min_csn_pl; /* Pending list for minimal CSN */
void *csn_pl_reg_id; /* registration assignment for csn callbacks */
unsigned long repl_state_flags; /* state flags */
@@ -788,7 +787,6 @@ replica_set_ruv(Replica *r, RUV *ruv)
}
r->repl_ruv = object_new((void *)ruv, (FNFree)ruv_destroy);
- r->repl_ruv_dirty = PR_TRUE;
replica_unlock(r->repl_lock);
}
@@ -860,9 +858,6 @@ replica_update_ruv(Replica *r, const CSN *updated_csn, const char *replica_purl)
"to update RUV for replica %s, csn = %s\n",
slapi_sdn_get_dn(r->repl_root),
csn_as_string(updated_csn, PR_FALSE, csn_str));
- } else {
- /* RUV updated - mark as dirty */
- r->repl_ruv_dirty = PR_TRUE;
}
} else {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
@@ -1347,8 +1342,6 @@ replica_dump(Replica *r)
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "\tupdate dn: %s\n",
updatedn_list ? updatedn_list : "not configured");
slapi_ch_free_string(&updatedn_list);
- slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "\truv: %s configured and is %sdirty\n",
- r->repl_ruv ? "" : "not", r->repl_ruv_dirty ? "" : "not ");
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "\tCSN generator: %s configured\n",
r->repl_csngen ? "" : "not");
/* JCMREPL - Dump Referrals */
@@ -1675,7 +1668,6 @@ replica_check_for_data_reload(Replica *r, void *arg __attribute__((unused)))
ruv_force_csn_update_from_ruv(upper_bound_ruv, r_ruv,
"Force update of database RUV (from CL RUV) -> ", SLAPI_LOG_NOTICE);
- replica_set_ruv_dirty(r);
}
} else {
@@ -2778,11 +2770,6 @@ replica_write_ruv(Replica *r)
replica_lock(r->repl_lock);
- if (!r->repl_ruv_dirty) {
- replica_unlock(r->repl_lock);
- return rc;
- }
-
PR_ASSERT(r->repl_ruv);
ruv_to_smod((RUV *)object_get_data(r->repl_ruv), &smod);
@@ -2817,14 +2804,10 @@ replica_write_ruv(Replica *r)
/* ruv does not exist - create one */
replica_lock(r->repl_lock);
- if (rc == LDAP_SUCCESS) {
- r->repl_ruv_dirty = PR_FALSE;
- } else if (rc == LDAP_NO_SUCH_OBJECT) {
+ if (rc == LDAP_NO_SUCH_OBJECT) {
/* this includes an internal operation - but since this only happens
during server startup - its ok that we have lock around it */
rc = _replica_configure_ruv(r, PR_TRUE);
- if (rc == 0)
- r->repl_ruv_dirty = PR_FALSE;
} else /* error */
{
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
@@ -3325,7 +3308,6 @@ replica_create_ruv_tombstone(Replica *r)
if (ruv_init_new(csnstr, r->repl_rid, purl, &ruv) == RUV_SUCCESS) {
r->repl_ruv = object_new((void *)ruv, (FNFree)ruv_destroy);
- r->repl_ruv_dirty = PR_TRUE;
return_value = LDAP_SUCCESS;
} else {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "replica_create_ruv_tombstone - "
@@ -3365,8 +3347,6 @@ replica_create_ruv_tombstone(Replica *r)
slapi_add_internal_pb(pb);
e = NULL; /* add consumes e, upon success or failure */
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
- if (return_value == LDAP_SUCCESS)
- r->repl_ruv_dirty = PR_FALSE;
done:
slapi_entry_free(e);
@@ -3630,7 +3610,6 @@ replica_strip_cleaned_rids(Replica *r)
ruv_get_cleaned_rids(ruv, rid);
while (rid[i] != 0) {
ruv_delete_replica(ruv, rid[i]);
- replica_set_ruv_dirty(r);
if (replica_write_ruv(r)) {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
"replica_strip_cleaned_rids - Failed to write RUV\n");
@@ -3744,15 +3723,6 @@ replica_update_ruv_consumer(Replica *r, RUV *supplier_ruv)
}
}
-void
-replica_set_ruv_dirty(Replica *r)
-{
- PR_ASSERT(r);
- replica_lock(r->repl_lock);
- r->repl_ruv_dirty = PR_TRUE;
- replica_unlock(r->repl_lock);
-}
-
PRBool
replica_is_state_flag_set(Replica *r, int32_t flag)
{
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 9c8d6adbb..e025f34d8 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -937,7 +937,6 @@ replica_config_change_type_and_id(Replica *r, const char *new_type, const char *
replica_reset_csn_pl(r);
}
ruv_delete_replica(ruv, oldrid);
- replica_set_ruv_dirty(r);
cl5CleanRUV(oldrid);
replica_set_csn_assigned(r);
}
@@ -1323,7 +1322,6 @@ replica_execute_cleanruv_task(Object *r, ReplicaId rid, char *returntext __attri
return LDAP_UNWILLING_TO_PERFORM;
}
rc = ruv_delete_replica(local_ruv, rid);
- replica_set_ruv_dirty(replica);
if (replica_write_ruv(replica)) {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "cleanAllRUV_task - Could not write RUV\n");
}
| 0 |
c88c7273a411b88d26370536792530df882524d7
|
389ds/389-ds-base
|
Ticket #48048 - Fix coverity issues - 2015/2/24
Coverity defect 13055 - Identical code for different branches
Description: Removed redundant error check and return statement.
modified: connectToServer in ldclt/ldapfct.c
|
commit c88c7273a411b88d26370536792530df882524d7
Author: Noriko Hosoi <[email protected]>
Date: Tue Feb 24 16:08:53 2015 -0800
Ticket #48048 - Fix coverity issues - 2015/2/24
Coverity defect 13055 - Identical code for different branches
Description: Removed redundant error check and return statement.
modified: connectToServer in ldclt/ldapfct.c
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 110ad7812..2dbad4045 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -1201,8 +1201,7 @@ connectToServer (
fprintf (stderr, "ldclt[%d]: T%03d: cannot ldap_unbind(), error=%d (%s)\n",
mctx.pid, tttctx->thrdNum, ret,strerror (ret));
fflush (stderr);
- if (addErrorStat (ret) < 0)
- return (-1);
+ addErrorStat(ret);
return (-1);
}
tttctx->ldapCtx = NULL;
| 0 |
9687d830b9791d58d6bc8c96f7a99c7f68da9e7e
|
389ds/389-ds-base
|
Bump ws from 7.5.9 to 7.5.10 in /src/cockpit/389-console
Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.5.9...7.5.10)
---
updated-dependencies:
- dependency-name: ws
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <[email protected]>
|
commit 9687d830b9791d58d6bc8c96f7a99c7f68da9e7e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Wed Jun 19 15:27:57 2024 +0000
Bump ws from 7.5.9 to 7.5.10 in /src/cockpit/389-console
Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.5.9...7.5.10)
---
updated-dependencies:
- dependency-name: ws
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <[email protected]>
diff --git a/src/cockpit/389-console/package-lock.json b/src/cockpit/389-console/package-lock.json
index 9da29bf4d..5c7e378af 100644
--- a/src/cockpit/389-console/package-lock.json
+++ b/src/cockpit/389-console/package-lock.json
@@ -6591,9 +6591,9 @@
}
},
"node_modules/ws": {
- "version": "7.5.9",
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
- "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
+ "version": "7.5.10",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
+ "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
"dev": true,
"engines": {
"node": ">=8.3.0"
| 0 |
016b01175b047146cfc2d029d4fda0672cfd391c
|
389ds/389-ds-base
|
move stop and restart to agreement.pause and agreement.unpause
Reviewed by: tbordaz (Thanks!)
|
commit 016b01175b047146cfc2d029d4fda0672cfd391c
Author: Rich Megginson <[email protected]>
Date: Thu Nov 21 09:33:23 2013 -0700
move stop and restart to agreement.pause and agreement.unpause
Reviewed by: tbordaz (Thanks!)
diff --git a/src/lib389/lib389/brooker.py b/src/lib389/lib389/brooker.py
index da3d0c295..935f5dcfe 100644
--- a/src/lib389/lib389/brooker.py
+++ b/src/lib389/lib389/brooker.py
@@ -25,7 +25,8 @@ from lib389._replication import RUV
from lib389._entry import FormatDict
class Agreement(object):
- ALWAYS = None
+ ALWAYS = '0000-2359 0123456'
+ NEVER = '2358-2359 0'
proxied_methods = 'search_s getEntry'.split()
@@ -110,22 +111,18 @@ class Agreement(object):
- def schedule(self, agmtdn, interval='start'):
+ def schedule(self, agmtdn, interval=ALWAYS):
"""Schedule the replication agreement
@param agmtdn - DN of the replica agreement
@param interval - in the form
- - 'ALWAYS'
- - 'NEVER'
+ - Agreement.ALWAYS
+ - Agreement.NEVER
- or 'HHMM-HHMM D+' With D=[0123456]+
@raise ValueError - if interval is not valid
"""
# check the validity of the interval
- if str(interval).lower() == 'start':
- interval = '0000-2359 0123456'
- elif str(interval).lower == 'never':
- interval = '2358-2359 0'
- else:
+ if interval != Agreement.ALWAYS and interval != Agreement.NEVER:
self._check_interval(interval)
# Check if the replica agreement exists
@@ -421,12 +418,42 @@ class Agreement(object):
self.log.info("Starting total init %s" % entry.dn)
mod = [(ldap.MOD_ADD, 'nsds5BeginReplicaRefresh', 'start')]
self.conn.modify_s(entry.dn, mod)
+
+ def pause(self, agmtdn, interval=NEVER):
+ """Pause this replication agreement. This replication agreement
+ will send no more changes. Use the resume() method to "unpause"
+ @param agmtdn - agreement dn
+ @param interval - (default NEVER) replication schedule to use
+ """
+ self.log.info("Pausing replication %s" % agmtdn)
+ mod = [(
+ ldap.MOD_REPLACE, 'nsds5ReplicaEnabled', ['off'])]
+ try:
+ self.conn.modify_s(agmtdn, mod)
+ except LDAPError, e:
+ # before 1.2.11, no support for nsds5ReplicaEnabled
+ # use schedule hack
+ self.schedule(interval)
+
+ def resume(self, agmtdn, interval=ALWAYS):
+ """Resume a paused replication agreement, paused with the "pause" method.
+ @param agmtdn - agreement dn
+ @param interval - (default ALWAYS) replication schedule to use
+ """
+ self.log.info("Resuming replication %s" % agmtdn)
+ mod = [(
+ ldap.MOD_REPLACE, 'nsds5ReplicaEnabled', ['on'])]
+ try:
+ self.conn.modify_s(agmtdn, mod)
+ except LDAPError, e:
+ # before 1.2.11, no support for nsds5ReplicaEnabled
+ # use schedule hack
+ self.schedule(interval)
+
class Replica(object):
proxied_methods = 'search_s getEntry'.split()
- STOP = '2358-2359 0'
- START = '0000-2359 0123456'
def __init__(self, conn):
"""@param conn - a DirSrv instance"""
@@ -593,42 +620,6 @@ class Replica(object):
self.log.info("Setting agreement for continuous replication")
raise NotImplementedError("Check nsds5replicaupdateschedule before writing!")
- def stop(self, agmtdn):
- """Stop replication.
- @param agmtdn - agreement dn
- """
- self.log.info("Stopping replication %s" % agmtdn)
- mod = [(
- ldap.MOD_REPLACE, 'nsds5ReplicaEnabled', ['off'])]
- try:
- self.conn.modify_s(agmtdn, mod)
- except LDAPError, e:
- # before 1.2.11, no support for nsds5ReplicaEnabled
- # use schedule hack
- mod = [(
- ldap.MOD_REPLACE, 'nsds5replicaupdateschedule', [
- Replica.STOP])]
- self.conn.modify_s(agmtdn, mod)
-
- def restart(self, agmtdn, schedule=START):
- """Schedules a new replication.
- @param agmtdn -
- @param schedule - default START
- `schedule` allows to customize the replication instant.
- see 389 documentation for further info
- """
- self.log.info("Restarting replication %s" % agmtdn)
- mod = [(
- ldap.MOD_REPLACE, 'nsds5ReplicaEnabled', ['on'])]
- try:
- self.conn.modify_s(agmtdn, mod)
- except LDAPError, e:
- # before 1.2.11, no support for nsds5ReplicaEnabled
- # use schedule hack
- mod = [(ldap.MOD_REPLACE, 'nsds5replicaupdateschedule', [
- schedule])]
- self.conn.modify_s(agmtdn, mod)
-
def add(self, suffix, binddn, bindpw=None, rtype=REPLICA_RDONLY_TYPE, rid=None, tombstone_purgedelay=None, purgedelay=None, referrals=None, legacy=False):
| 0 |
e6bfeb973c469e216e475b64634e83cf4f444627
|
389ds/389-ds-base
|
Issue 5020 - BUG - improve clarity of posix win sync logging (#5021)
* Issue 5020 - BUG - improve clarity of posix win sync logging
Bug Description: When a user isn't synced from AD due to missing schema,
if the user was a member of a group then posix-winsync would confusingly
report an err=32 (NO_SUCH_OBJECT) which made it "appear" significantly
worse as a problem than it was.
Fix Description: This clarifies the error message to make it easier
for an administrator to understand why this is occuring.
fixes: https://github.com/389ds/389-ds-base/issues/5020
Author: William Brown <[email protected]>
Review by: @tbordaz , @droideck
|
commit e6bfeb973c469e216e475b64634e83cf4f444627
Author: Firstyear <[email protected]>
Date: Fri Nov 26 09:28:28 2021 +1000
Issue 5020 - BUG - improve clarity of posix win sync logging (#5021)
* Issue 5020 - BUG - improve clarity of posix win sync logging
Bug Description: When a user isn't synced from AD due to missing schema,
if the user was a member of a group then posix-winsync would confusingly
report an err=32 (NO_SUCH_OBJECT) which made it "appear" significantly
worse as a problem than it was.
Fix Description: This clarifies the error message to make it easier
for an administrator to understand why this is occuring.
fixes: https://github.com/389ds/389-ds-base/issues/5020
Author: William Brown <[email protected]>
Review by: @tbordaz , @droideck
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index 7bd0b9eec..730e6e5f2 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -89,10 +89,10 @@ getEntry(const char *udn, char **attrs)
return result; /* Must be freed */
} else {
slapi_log_err(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "getEntry: %s not found\n", udn);
+ "getEntry: %s internal search result not found\n", udn);
}
} else {
- slapi_log_err(SLAPI_LOG_ERR, POSIX_WINSYNC_PLUGIN_NAME,
+ slapi_log_err(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
"getEntry: error searching for uid %s: %d\n", udn, rc);
}
@@ -380,8 +380,9 @@ getMembershipFromDownward(Slapi_Entry *entry, Slapi_ValueSet *muid_vs, Slapi_Val
Slapi_Entry *child = getEntry(uid_dn, attrs);
if (!child) {
- slapi_log_err(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "getMembershipFromDownward end: child not found: %s\n", uid_dn);
+ slapi_log_err(SLAPI_LOG_WARNING, POSIX_WINSYNC_PLUGIN_NAME,
+ "getMembershipFromDownward end: local group member %s not found for group %s\n",
+ uid_dn, slapi_entry_get_dn_const(entry));
} else {
/* PosixGroups except for the top one are already fully mapped out */
if ((!hasObjectClass(entry, "posixGroup") || (depth == 0)) &&
@@ -828,9 +829,9 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify, int ne
muid_tempnested = NULL;
}
} else {
- slapi_log_err(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: entry not found for dn: %s\n",
- smod_adduids[j]);
+ slapi_log_err(SLAPI_LOG_WARNING, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership (nested): local group member %s not found for group %s\n",
+ smod_adduids[j], slapi_entry_get_dn_const(entry));
}
}
| 0 |
49e00bfc5c36852107cf427efdb5e51001e85b49
|
389ds/389-ds-base
|
Fix for 157919: perform fractional consumer check after acquiring the replica
|
commit 49e00bfc5c36852107cf427efdb5e51001e85b49
Author: David Boreham <[email protected]>
Date: Tue May 17 18:40:08 2005 +0000
Fix for 157919: perform fractional consumer check after acquiring the replica
diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c
index 2756b77c4..e6d8c957c 100644
--- a/ldap/servers/plugins/replication/repl5_protocol_util.c
+++ b/ldap/servers/plugins/replication/repl5_protocol_util.c
@@ -199,22 +199,6 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
char *retoid = NULL;
Slapi_DN *replarea_sdn;
- /* Check if this is a fractional agreement, we need to
- * verify that the consumer is read-only */
- if (agmt_is_fractional(prp->agmt)) {
- crc = conn_replica_is_readonly(conn);
- if (CONN_IS_NOT_READONLY == crc) {
- /* This is a fatal error */
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "%s: Unable to acquire replica: "
- "the agreement is fractional but the replica is not read-only. Fractional agreements must specify a read-only replica "
- "Replication is aborting.\n",
- agmt_get_long_name(prp->agmt));
- return_value = ACQUIRE_FATAL_ERROR;
- goto error;
- }
- }
-
/* Good to go. Start the protocol. */
/* Obtain a current CSN */
@@ -375,6 +359,25 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
default:
return_value = ACQUIRE_FATAL_ERROR;
}
+ /* Now check for fractional compatibility with the replica
+ * We need to do the check now because prior to acquiring the
+ * replica we do not have sufficient access rights to read the replica id
+ */
+ /* Check if this is a fractional agreement, we need to
+ * verify that the consumer is read-only */
+ if (agmt_is_fractional(prp->agmt)) {
+ crc = conn_replica_is_readonly(conn);
+ if (CONN_IS_NOT_READONLY == crc) {
+ /* This is a fatal error */
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "%s: Unable to acquire replica: "
+ "the agreement is fractional but the replica is not read-only. Fractional agreements must specify a read-only replica "
+ "Replication is aborting.\n",
+ agmt_get_long_name(prp->agmt));
+ return_value = ACQUIRE_FATAL_ERROR;
+ goto error;
+ }
+ }
}
else
{
| 0 |
8c0be3416b699f4df1eecf2265dc270c210b487b
|
389ds/389-ds-base
|
Issue 5162 - BUG - error on importing chain files (#5164)
Bug Description: Nss can't import pem chain files which can
confuse users why they have missing certificates when they try
to import a chain.
Fix Description: Error out on chain files in any of the import
paths since they are ambiguous.
fixes: https://github.com/389ds/389-ds-base/issues/5162
Author: William Brown <[email protected]>
Review by: @droideck
|
commit 8c0be3416b699f4df1eecf2265dc270c210b487b
Author: Firstyear <[email protected]>
Date: Fri Mar 4 09:43:35 2022 +1000
Issue 5162 - BUG - error on importing chain files (#5164)
Bug Description: Nss can't import pem chain files which can
confuse users why they have missing certificates when they try
to import a chain.
Fix Description: Error out on chain files in any of the import
paths since they are ambiguous.
fixes: https://github.com/389ds/389-ds-base/issues/5162
Author: William Brown <[email protected]>
Review by: @droideck
diff --git a/dirsrvtests/tests/data/tls/ca.crt b/dirsrvtests/tests/data/tls/ca.crt
new file mode 100644
index 000000000..3756a15cb
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/ca.crt
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDTjCCAjagAwIBAgIFALr2peswDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExF0ZXN0cy5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU0MzJaFw00MjAyMTEwMjU0MzJaMGAxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEaMBgG
+A1UEAxMRdGVzdHMuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQCr2vsHEGtvlishhWeAU+qhPbdoJ6CBW6Dk7APlvwuOaAls4BA6I7CX
+ZG2tbaK38TuB1rB21/KOciTcy7TaF9X6OW+6Hkb4gGMnpy4sRbw4CKIfkNsCZ5av
+bQ9fsRbgM0q72YPjZlzO6tuvLimOLolhmSiSS00Ll20CteMMWZ/ApGBl163iohD4
+pFWJhtyYG9DnZp5N6T3yHDFsrIyil2+G6ZSTOObRwXUEvHeZcGRiG6Py9t3vDOSg
+IUKYcgyihg9boEHVe76wHfMm6i3ELa7/QeVJNofbiPso6doqD0V+qmGhZsmpjP56
+RcBR85ijo/eprohjDNXHAOUgdZ7K9DqrAgMBAAGjDzANMAsGA1UdDwQEAwICBDAN
+BgkqhkiG9w0BAQsFAAOCAQEASH8xxpue07K1K8T5SLDUT8iaBnCwub6s8atfqPbR
+xb2vdIX0p6WN+kmsNNsafyQYYz+M5LdMSeaTrzj52zvKvZ/5bgc+VqLXx35khaQU
+0RgNgKxDgeY2vGVPFHDSNhJvBTtMxksUK0otW8tF70bTZEp2whkoHCu1nAXuEzaX
+BeglYO6YRtuY71u84gvd8vtq2Zy0sb5vG7uWn2ZTpA5maCK58r9XpUdpjyA4qhFB
+ClwQ45UzkLzTbolioT10N7Xp5clLzqiLYexFuoZhK2HROvgr8EFF7xl17qwVbTkt
+ZsURjsTOrWKVLiVn9AuCHeToPosZr4/pWWjFoweO+yfZEg==
+-----END CERTIFICATE-----
diff --git a/dirsrvtests/tests/data/tls/cert9.db b/dirsrvtests/tests/data/tls/cert9.db
new file mode 100644
index 000000000..8ccb6f021
Binary files /dev/null and b/dirsrvtests/tests/data/tls/cert9.db differ
diff --git a/dirsrvtests/tests/data/tls/int.crt b/dirsrvtests/tests/data/tls/int.crt
new file mode 100644
index 000000000..d74f775c2
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/int.crt
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDTjCCAjagAwIBAgIFALr2ppEwDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExF0ZXN0cy5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU1NThaFw00MjAyMTEwMjU1NThaMGAxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEaMBgG
+A1UEAxMRaW50ZXIuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQDwpvfj98afN43Eo4qwgXJ9wioeyGaX9rmXpQs4bO/muaCzZ4ztONFz
+m7smxOmTNPKFilwC4f0p0KQB5GJgcy9VD10VWIS0iKckKuGzqrPQP9ROawIvlKe7
+k046XnIHfvJKFaikcQfcipqLfDqU5+SXaLXj1sqnEWqXklUDqd6zSB4Ko3blQ3t6
+hh2axcudpHSwvj/gbdqNkX41pSbET2MJY2/025AksWLx3CukzNMRLe7pLoNZ5Ztb
+Id1EsxHK/dFBCtRkke7TAUuai6BfMFj8NTWk8FB3Rd1rx608lo+31/Fq9a7e5jTq
+16JZwJQVlkZGCH6iWB8VynhF+Lw8VZMPAgMBAAGjDzANMAsGA1UdDwQEAwICBDAN
+BgkqhkiG9w0BAQsFAAOCAQEAejpy+M0NsmN/SSlXDMK6Xly0ef8vxGcF2crjdwtT
+BrhEFm0hYmiCrJAmtr67lTdgvxM/lpQ+tOcgPWiE1oPOo+eauf5gj4F6aGYBse8I
+QZ1+WmVyJK+/zRXECo9upFsE76hVhPivqEeq6Z/dsHblnESNxoLjdIRp3JBirUL/
+aifYfLH9UrQ+ZU1nCIufQP3w/jUuB1dPQgaiy3gG9/sA5jEd10ZU6QyWVB2B+UH5
+VKkBg4hu0xJmL79zSZIFnrCxZGxaL9S7BrQcEDB186kQ+++0g1CuncMbZajvlTsg
+3bAtbZQQMe3hwsoHjo1JKWAUTOB7cqEF6LMpotg0jn+Bvg==
+-----END CERTIFICATE-----
diff --git a/dirsrvtests/tests/data/tls/key4.db b/dirsrvtests/tests/data/tls/key4.db
new file mode 100644
index 000000000..ba367ec08
Binary files /dev/null and b/dirsrvtests/tests/data/tls/key4.db differ
diff --git a/dirsrvtests/tests/data/tls/leaf.crt b/dirsrvtests/tests/data/tls/leaf.crt
new file mode 100644
index 000000000..0baa07d35
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/leaf.crt
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDXTCCAkWgAwIBAgIFALr2pxswDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExFpbnRlci5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU3MTFaFw00MjAyMTEwMjU3MTFaMF8xCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEZMBcG
+A1UEAxMQbGVhZi5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
+AQoCggEBAOS672+WBtOa5ehJwCESHjk4HpRdHlCsAQiKpKyykdDZM9kpsZT+becy
+Nc6zHORcduehsjY46vQDXrMN4Q8AjoFFK0qTA0DeZleWeQMa0cBnqt9bCkIJzwCu
+TY8zNHlLiA5iYUhwCvDQNegnjSonLiSm19earxyy75etklFDeiEij+KdHN6MKFlo
+J/0L4u3ckNCHTunnGjIfdNUT92Ignxt5KAN2bT6hbSbf9PCx1A2Cyyt4DsVCSIqj
+IfalkMPXGY2M0a5GvMayhpf1yvRP25uAEQZwn+ahpic+qwk6YXdBXUgsbBcFoT8H
+kG/EmSYrlwAxlroq6FvL3n0RlfcMzf0CAwEAAaMfMB0wGwYDVR0RBBQwEoIQbGVh
+Zi5leGFtcGxlLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEA27IS76HxwAnJH/8tEPjD
+DnJw9zsmkHX6skhVfFYlkpfukl0Lm0DGmfeeqYfTBU1g2x5NTxeUBip104gES0iX
+eq7Yr+7pdvnV6pB42EAeWRDN9DGDpTL/9/aO8Vm+O28SdILYjuGqXnoPbuUgYLPO
+nO/8REbQp7jk6kwje1eJ81JyYINXCwzEEpq0ycwaU6aIcCP3BY5c9PV5DStN+ddV
+esI2SkVABd8b0zmh+aw1zzACpUnBgNX60jfbPIr+UqCwlW8LMKmHuL9NkN/mLEyV
+hH3v8CpSpTWB+cOntmuK7sESgO8c/u/6ohYPyrEsNBTJgmXeHO8rsYNQAiRkpkvQ
+PA==
+-----END CERTIFICATE-----
diff --git a/dirsrvtests/tests/data/tls/pkcs11.txt b/dirsrvtests/tests/data/tls/pkcs11.txt
new file mode 100644
index 000000000..14dec87a3
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/pkcs11.txt
@@ -0,0 +1,5 @@
+library=
+name=NSS Internal PKCS #11 Module
+parameters=configdir='.' certPrefix='' keyPrefix='' secmod='secmod.db' flags= updatedir='' updateCertPrefix='' updateKeyPrefix='' updateid='' updateTokenDescription=''
+NSS=Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={slotFlags=[ECC,RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512] askpw=any timeout=30})
+
diff --git a/dirsrvtests/tests/data/tls/pwdfile.txt b/dirsrvtests/tests/data/tls/pwdfile.txt
new file mode 100644
index 000000000..ee075d376
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/pwdfile.txt
@@ -0,0 +1 @@
+Moo0weeYacaema3ViireX1kee7iedeixigohtooy
diff --git a/dirsrvtests/tests/data/tls/server-export.p12 b/dirsrvtests/tests/data/tls/server-export.p12
new file mode 100644
index 000000000..f756d7594
Binary files /dev/null and b/dirsrvtests/tests/data/tls/server-export.p12 differ
diff --git a/dirsrvtests/tests/data/tls/tls_import_ca_chain.pem b/dirsrvtests/tests/data/tls/tls_import_ca_chain.pem
new file mode 100644
index 000000000..11a55c7b4
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/tls_import_ca_chain.pem
@@ -0,0 +1,40 @@
+-----BEGIN CERTIFICATE-----
+MIIDTjCCAjagAwIBAgIFALr2ppEwDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExF0ZXN0cy5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU1NThaFw00MjAyMTEwMjU1NThaMGAxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEaMBgG
+A1UEAxMRaW50ZXIuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQDwpvfj98afN43Eo4qwgXJ9wioeyGaX9rmXpQs4bO/muaCzZ4ztONFz
+m7smxOmTNPKFilwC4f0p0KQB5GJgcy9VD10VWIS0iKckKuGzqrPQP9ROawIvlKe7
+k046XnIHfvJKFaikcQfcipqLfDqU5+SXaLXj1sqnEWqXklUDqd6zSB4Ko3blQ3t6
+hh2axcudpHSwvj/gbdqNkX41pSbET2MJY2/025AksWLx3CukzNMRLe7pLoNZ5Ztb
+Id1EsxHK/dFBCtRkke7TAUuai6BfMFj8NTWk8FB3Rd1rx608lo+31/Fq9a7e5jTq
+16JZwJQVlkZGCH6iWB8VynhF+Lw8VZMPAgMBAAGjDzANMAsGA1UdDwQEAwICBDAN
+BgkqhkiG9w0BAQsFAAOCAQEAejpy+M0NsmN/SSlXDMK6Xly0ef8vxGcF2crjdwtT
+BrhEFm0hYmiCrJAmtr67lTdgvxM/lpQ+tOcgPWiE1oPOo+eauf5gj4F6aGYBse8I
+QZ1+WmVyJK+/zRXECo9upFsE76hVhPivqEeq6Z/dsHblnESNxoLjdIRp3JBirUL/
+aifYfLH9UrQ+ZU1nCIufQP3w/jUuB1dPQgaiy3gG9/sA5jEd10ZU6QyWVB2B+UH5
+VKkBg4hu0xJmL79zSZIFnrCxZGxaL9S7BrQcEDB186kQ+++0g1CuncMbZajvlTsg
+3bAtbZQQMe3hwsoHjo1JKWAUTOB7cqEF6LMpotg0jn+Bvg==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDTjCCAjagAwIBAgIFALr2peswDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExF0ZXN0cy5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU0MzJaFw00MjAyMTEwMjU0MzJaMGAxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEaMBgG
+A1UEAxMRdGVzdHMuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQCr2vsHEGtvlishhWeAU+qhPbdoJ6CBW6Dk7APlvwuOaAls4BA6I7CX
+ZG2tbaK38TuB1rB21/KOciTcy7TaF9X6OW+6Hkb4gGMnpy4sRbw4CKIfkNsCZ5av
+bQ9fsRbgM0q72YPjZlzO6tuvLimOLolhmSiSS00Ll20CteMMWZ/ApGBl163iohD4
+pFWJhtyYG9DnZp5N6T3yHDFsrIyil2+G6ZSTOObRwXUEvHeZcGRiG6Py9t3vDOSg
+IUKYcgyihg9boEHVe76wHfMm6i3ELa7/QeVJNofbiPso6doqD0V+qmGhZsmpjP56
+RcBR85ijo/eprohjDNXHAOUgdZ7K9DqrAgMBAAGjDzANMAsGA1UdDwQEAwICBDAN
+BgkqhkiG9w0BAQsFAAOCAQEASH8xxpue07K1K8T5SLDUT8iaBnCwub6s8atfqPbR
+xb2vdIX0p6WN+kmsNNsafyQYYz+M5LdMSeaTrzj52zvKvZ/5bgc+VqLXx35khaQU
+0RgNgKxDgeY2vGVPFHDSNhJvBTtMxksUK0otW8tF70bTZEp2whkoHCu1nAXuEzaX
+BeglYO6YRtuY71u84gvd8vtq2Zy0sb5vG7uWn2ZTpA5maCK58r9XpUdpjyA4qhFB
+ClwQ45UzkLzTbolioT10N7Xp5clLzqiLYexFuoZhK2HROvgr8EFF7xl17qwVbTkt
+ZsURjsTOrWKVLiVn9AuCHeToPosZr4/pWWjFoweO+yfZEg==
+-----END CERTIFICATE-----
diff --git a/dirsrvtests/tests/data/tls/tls_import_crt_chain.pem b/dirsrvtests/tests/data/tls/tls_import_crt_chain.pem
new file mode 100644
index 000000000..5c0a607dd
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/tls_import_crt_chain.pem
@@ -0,0 +1,61 @@
+-----BEGIN CERTIFICATE-----
+MIIDXTCCAkWgAwIBAgIFALr2pxswDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExFpbnRlci5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU3MTFaFw00MjAyMTEwMjU3MTFaMF8xCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEZMBcG
+A1UEAxMQbGVhZi5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
+AQoCggEBAOS672+WBtOa5ehJwCESHjk4HpRdHlCsAQiKpKyykdDZM9kpsZT+becy
+Nc6zHORcduehsjY46vQDXrMN4Q8AjoFFK0qTA0DeZleWeQMa0cBnqt9bCkIJzwCu
+TY8zNHlLiA5iYUhwCvDQNegnjSonLiSm19earxyy75etklFDeiEij+KdHN6MKFlo
+J/0L4u3ckNCHTunnGjIfdNUT92Ignxt5KAN2bT6hbSbf9PCx1A2Cyyt4DsVCSIqj
+IfalkMPXGY2M0a5GvMayhpf1yvRP25uAEQZwn+ahpic+qwk6YXdBXUgsbBcFoT8H
+kG/EmSYrlwAxlroq6FvL3n0RlfcMzf0CAwEAAaMfMB0wGwYDVR0RBBQwEoIQbGVh
+Zi5leGFtcGxlLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEA27IS76HxwAnJH/8tEPjD
+DnJw9zsmkHX6skhVfFYlkpfukl0Lm0DGmfeeqYfTBU1g2x5NTxeUBip104gES0iX
+eq7Yr+7pdvnV6pB42EAeWRDN9DGDpTL/9/aO8Vm+O28SdILYjuGqXnoPbuUgYLPO
+nO/8REbQp7jk6kwje1eJ81JyYINXCwzEEpq0ycwaU6aIcCP3BY5c9PV5DStN+ddV
+esI2SkVABd8b0zmh+aw1zzACpUnBgNX60jfbPIr+UqCwlW8LMKmHuL9NkN/mLEyV
+hH3v8CpSpTWB+cOntmuK7sESgO8c/u/6ohYPyrEsNBTJgmXeHO8rsYNQAiRkpkvQ
+PA==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDTjCCAjagAwIBAgIFALr2ppEwDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExF0ZXN0cy5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU1NThaFw00MjAyMTEwMjU1NThaMGAxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEaMBgG
+A1UEAxMRaW50ZXIuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQDwpvfj98afN43Eo4qwgXJ9wioeyGaX9rmXpQs4bO/muaCzZ4ztONFz
+m7smxOmTNPKFilwC4f0p0KQB5GJgcy9VD10VWIS0iKckKuGzqrPQP9ROawIvlKe7
+k046XnIHfvJKFaikcQfcipqLfDqU5+SXaLXj1sqnEWqXklUDqd6zSB4Ko3blQ3t6
+hh2axcudpHSwvj/gbdqNkX41pSbET2MJY2/025AksWLx3CukzNMRLe7pLoNZ5Ztb
+Id1EsxHK/dFBCtRkke7TAUuai6BfMFj8NTWk8FB3Rd1rx608lo+31/Fq9a7e5jTq
+16JZwJQVlkZGCH6iWB8VynhF+Lw8VZMPAgMBAAGjDzANMAsGA1UdDwQEAwICBDAN
+BgkqhkiG9w0BAQsFAAOCAQEAejpy+M0NsmN/SSlXDMK6Xly0ef8vxGcF2crjdwtT
+BrhEFm0hYmiCrJAmtr67lTdgvxM/lpQ+tOcgPWiE1oPOo+eauf5gj4F6aGYBse8I
+QZ1+WmVyJK+/zRXECo9upFsE76hVhPivqEeq6Z/dsHblnESNxoLjdIRp3JBirUL/
+aifYfLH9UrQ+ZU1nCIufQP3w/jUuB1dPQgaiy3gG9/sA5jEd10ZU6QyWVB2B+UH5
+VKkBg4hu0xJmL79zSZIFnrCxZGxaL9S7BrQcEDB186kQ+++0g1CuncMbZajvlTsg
+3bAtbZQQMe3hwsoHjo1JKWAUTOB7cqEF6LMpotg0jn+Bvg==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDTjCCAjagAwIBAgIFALr2peswDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExF0ZXN0cy5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU0MzJaFw00MjAyMTEwMjU0MzJaMGAxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEaMBgG
+A1UEAxMRdGVzdHMuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQCr2vsHEGtvlishhWeAU+qhPbdoJ6CBW6Dk7APlvwuOaAls4BA6I7CX
+ZG2tbaK38TuB1rB21/KOciTcy7TaF9X6OW+6Hkb4gGMnpy4sRbw4CKIfkNsCZ5av
+bQ9fsRbgM0q72YPjZlzO6tuvLimOLolhmSiSS00Ll20CteMMWZ/ApGBl163iohD4
+pFWJhtyYG9DnZp5N6T3yHDFsrIyil2+G6ZSTOObRwXUEvHeZcGRiG6Py9t3vDOSg
+IUKYcgyihg9boEHVe76wHfMm6i3ELa7/QeVJNofbiPso6doqD0V+qmGhZsmpjP56
+RcBR85ijo/eprohjDNXHAOUgdZ7K9DqrAgMBAAGjDzANMAsGA1UdDwQEAwICBDAN
+BgkqhkiG9w0BAQsFAAOCAQEASH8xxpue07K1K8T5SLDUT8iaBnCwub6s8atfqPbR
+xb2vdIX0p6WN+kmsNNsafyQYYz+M5LdMSeaTrzj52zvKvZ/5bgc+VqLXx35khaQU
+0RgNgKxDgeY2vGVPFHDSNhJvBTtMxksUK0otW8tF70bTZEp2whkoHCu1nAXuEzaX
+BeglYO6YRtuY71u84gvd8vtq2Zy0sb5vG7uWn2ZTpA5maCK58r9XpUdpjyA4qhFB
+ClwQ45UzkLzTbolioT10N7Xp5clLzqiLYexFuoZhK2HROvgr8EFF7xl17qwVbTkt
+ZsURjsTOrWKVLiVn9AuCHeToPosZr4/pWWjFoweO+yfZEg==
+-----END CERTIFICATE-----
diff --git a/dirsrvtests/tests/data/tls/tls_import_key.pem b/dirsrvtests/tests/data/tls/tls_import_key.pem
new file mode 100644
index 000000000..37230a5ce
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/tls_import_key.pem
@@ -0,0 +1,32 @@
+Bag Attributes
+ friendlyName: testcrt
+ localKeyID: 19 09 FA 11 4A B4 71 C0 7C 17 AE 64 C0 1C 6C 3F AF 7C D7 5A
+Key Attributes: <No Attributes>
+-----BEGIN PRIVATE KEY-----
+MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDkuu9vlgbTmuXo
+ScAhEh45OB6UXR5QrAEIiqSsspHQ2TPZKbGU/m3nMjXOsxzkXHbnobI2OOr0A16z
+DeEPAI6BRStKkwNA3mZXlnkDGtHAZ6rfWwpCCc8Ark2PMzR5S4gOYmFIcArw0DXo
+J40qJy4kptfXmq8csu+XrZJRQ3ohIo/inRzejChZaCf9C+Lt3JDQh07p5xoyH3TV
+E/diIJ8beSgDdm0+oW0m3/TwsdQNgssreA7FQkiKoyH2pZDD1xmNjNGuRrzGsoaX
+9cr0T9ubgBEGcJ/moaYnPqsJOmF3QV1ILGwXBaE/B5BvxJkmK5cAMZa6Kuhby959
+EZX3DM39AgMBAAECggEABFzUaEpyQuL3c6DEe1z/GpRJcQb9pwhA1MrgLTMSuOsL
+pB65dmAL9Jbuk8yyxmBFHFHnNkWLpa/SxJOFMWYPUcPh+YAoVbpoNU93a2m9im/v
+wGbaITxSqG6qqAqP+6hHJg8WT+1jKAiwnobymFU6+hP8le4rXN7E1x3GZqpkz/Dx
+k3eNkQbuykqKH046iDgZUqSHw4hriieJc3RiVnaThTnRd1qeKnAIUZ/nhSas5nQa
+d/sd6dWCycOb7tvw1Vcm6zTu+uTA8ai1uW6wU7N/vYa4jxZYYsYZYgHQxoK+RSzH
+glWD1n0u9VTUVDqISd+BocHwuRunOvOlZlMonTqhAQKBgQD+moK+5AyQjd3RJnVi
+xv/MYmw7nT+zXufZJ+bgPGJE8mEgCWAMy/8ysDZX77P4ZZuDVXb1mxVetxVo1n6d
+0Ggl/UP/rAqMb3WW86mJfDfGorL6fHg8GzWnQhNWDe6MmGOAPZOJN6UcMWSZshzj
+yuey1cDQpuBe8j0UXwYA+ys84QKBgQDl/BiEXLM9brLOEEUF/9I2JaL6teIqFivP
+fhscTHfng1dgnrq5hkD/jSUT+zeZ43/fXuVEYzpNgfY7sS0n77//xzN7nljk4809
+2KReeIoQqnkaQ75Vo5dhlkfX/J+jvD7MbeuXGIMKEV3PnLXwQYCdC87iH4CI4PtC
+9I+wwd94nQKBgGgsUjjG2HlBArRz9u2+nKVE1CIkOg8rUtPgZq/zJQYu4hyYmWtD
+AJz9yo56bnnBITtAedcOaFUDtkfaE56AykxY7zyqaPqDFGr6MbEmWS/2HCMvUIbP
+X0mbWIwKUUPHilbLWxV25iC9+PqGDRoLSHg8y5LT5NQUa3dtVeiK3GshAoGAKa7F
+Ksg6XDoCAkMEn4+8I8Ayh8oLUaFvE05Bz6E0Yit13LcoFJP2l9qXC8YOT7/h3zQt
+zXVGjeGuJSd5jbFwVQVfmVobtnBrNHhdYhnqvBaJmG8Kwi7CMxevsb/Bl0V5BEgv
+2NTCe0KmhAhdGUxl6RDI0EbxXt2X7IyytlCNFikCgYBysxlYfApfVJKwdNevnV1V
+CI1gGJpIJNZnlX2At7Db2llClxPTQBFRh820k0o+Vaj95VEGDWci/nIUq5odvIzQ
+GjVDHSEPsp699J31dreJYZN6mJR9YOI5f5Hak8TP4mlwJWQr+edBofOql6lUkaQJ
+8muEOzjKY0ty08BdBhC+lQ==
+-----END PRIVATE KEY-----
diff --git a/dirsrvtests/tests/data/tls/tls_import_key_chain.pem b/dirsrvtests/tests/data/tls/tls_import_key_chain.pem
new file mode 100644
index 000000000..865c1c594
--- /dev/null
+++ b/dirsrvtests/tests/data/tls/tls_import_key_chain.pem
@@ -0,0 +1,53 @@
+-----BEGIN CERTIFICATE-----
+MIIDXTCCAkWgAwIBAgIFALr2pxswDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxDjAMBgNVBAcTBTM4OWRzMRAwDgYDVQQK
+Ewd0ZXN0aW5nMRowGAYDVQQDExFpbnRlci5leGFtcGxlLmNvbTAeFw0yMjAyMTEw
+MjU3MTFaFw00MjAyMTEwMjU3MTFaMF8xCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpR
+dWVlbnNsYW5kMQ4wDAYDVQQHEwUzODlkczEQMA4GA1UEChMHdGVzdGluZzEZMBcG
+A1UEAxMQbGVhZi5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
+AQoCggEBAOS672+WBtOa5ehJwCESHjk4HpRdHlCsAQiKpKyykdDZM9kpsZT+becy
+Nc6zHORcduehsjY46vQDXrMN4Q8AjoFFK0qTA0DeZleWeQMa0cBnqt9bCkIJzwCu
+TY8zNHlLiA5iYUhwCvDQNegnjSonLiSm19earxyy75etklFDeiEij+KdHN6MKFlo
+J/0L4u3ckNCHTunnGjIfdNUT92Ignxt5KAN2bT6hbSbf9PCx1A2Cyyt4DsVCSIqj
+IfalkMPXGY2M0a5GvMayhpf1yvRP25uAEQZwn+ahpic+qwk6YXdBXUgsbBcFoT8H
+kG/EmSYrlwAxlroq6FvL3n0RlfcMzf0CAwEAAaMfMB0wGwYDVR0RBBQwEoIQbGVh
+Zi5leGFtcGxlLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEA27IS76HxwAnJH/8tEPjD
+DnJw9zsmkHX6skhVfFYlkpfukl0Lm0DGmfeeqYfTBU1g2x5NTxeUBip104gES0iX
+eq7Yr+7pdvnV6pB42EAeWRDN9DGDpTL/9/aO8Vm+O28SdILYjuGqXnoPbuUgYLPO
+nO/8REbQp7jk6kwje1eJ81JyYINXCwzEEpq0ycwaU6aIcCP3BY5c9PV5DStN+ddV
+esI2SkVABd8b0zmh+aw1zzACpUnBgNX60jfbPIr+UqCwlW8LMKmHuL9NkN/mLEyV
+hH3v8CpSpTWB+cOntmuK7sESgO8c/u/6ohYPyrEsNBTJgmXeHO8rsYNQAiRkpkvQ
+PA==
+-----END CERTIFICATE-----
+Bag Attributes
+ friendlyName: testcrt
+ localKeyID: 19 09 FA 11 4A B4 71 C0 7C 17 AE 64 C0 1C 6C 3F AF 7C D7 5A
+Key Attributes: <No Attributes>
+-----BEGIN PRIVATE KEY-----
+MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDkuu9vlgbTmuXo
+ScAhEh45OB6UXR5QrAEIiqSsspHQ2TPZKbGU/m3nMjXOsxzkXHbnobI2OOr0A16z
+DeEPAI6BRStKkwNA3mZXlnkDGtHAZ6rfWwpCCc8Ark2PMzR5S4gOYmFIcArw0DXo
+J40qJy4kptfXmq8csu+XrZJRQ3ohIo/inRzejChZaCf9C+Lt3JDQh07p5xoyH3TV
+E/diIJ8beSgDdm0+oW0m3/TwsdQNgssreA7FQkiKoyH2pZDD1xmNjNGuRrzGsoaX
+9cr0T9ubgBEGcJ/moaYnPqsJOmF3QV1ILGwXBaE/B5BvxJkmK5cAMZa6Kuhby959
+EZX3DM39AgMBAAECggEABFzUaEpyQuL3c6DEe1z/GpRJcQb9pwhA1MrgLTMSuOsL
+pB65dmAL9Jbuk8yyxmBFHFHnNkWLpa/SxJOFMWYPUcPh+YAoVbpoNU93a2m9im/v
+wGbaITxSqG6qqAqP+6hHJg8WT+1jKAiwnobymFU6+hP8le4rXN7E1x3GZqpkz/Dx
+k3eNkQbuykqKH046iDgZUqSHw4hriieJc3RiVnaThTnRd1qeKnAIUZ/nhSas5nQa
+d/sd6dWCycOb7tvw1Vcm6zTu+uTA8ai1uW6wU7N/vYa4jxZYYsYZYgHQxoK+RSzH
+glWD1n0u9VTUVDqISd+BocHwuRunOvOlZlMonTqhAQKBgQD+moK+5AyQjd3RJnVi
+xv/MYmw7nT+zXufZJ+bgPGJE8mEgCWAMy/8ysDZX77P4ZZuDVXb1mxVetxVo1n6d
+0Ggl/UP/rAqMb3WW86mJfDfGorL6fHg8GzWnQhNWDe6MmGOAPZOJN6UcMWSZshzj
+yuey1cDQpuBe8j0UXwYA+ys84QKBgQDl/BiEXLM9brLOEEUF/9I2JaL6teIqFivP
+fhscTHfng1dgnrq5hkD/jSUT+zeZ43/fXuVEYzpNgfY7sS0n77//xzN7nljk4809
+2KReeIoQqnkaQ75Vo5dhlkfX/J+jvD7MbeuXGIMKEV3PnLXwQYCdC87iH4CI4PtC
+9I+wwd94nQKBgGgsUjjG2HlBArRz9u2+nKVE1CIkOg8rUtPgZq/zJQYu4hyYmWtD
+AJz9yo56bnnBITtAedcOaFUDtkfaE56AykxY7zyqaPqDFGr6MbEmWS/2HCMvUIbP
+X0mbWIwKUUPHilbLWxV25iC9+PqGDRoLSHg8y5LT5NQUa3dtVeiK3GshAoGAKa7F
+Ksg6XDoCAkMEn4+8I8Ayh8oLUaFvE05Bz6E0Yit13LcoFJP2l9qXC8YOT7/h3zQt
+zXVGjeGuJSd5jbFwVQVfmVobtnBrNHhdYhnqvBaJmG8Kwi7CMxevsb/Bl0V5BEgv
+2NTCe0KmhAhdGUxl6RDI0EbxXt2X7IyytlCNFikCgYBysxlYfApfVJKwdNevnV1V
+CI1gGJpIJNZnlX2At7Db2llClxPTQBFRh820k0o+Vaj95VEGDWci/nIUq5odvIzQ
+GjVDHSEPsp699J31dreJYZN6mJR9YOI5f5Hak8TP4mlwJWQr+edBofOql6lUkaQJ
+8muEOzjKY0ty08BdBhC+lQ==
+-----END PRIVATE KEY-----
diff --git a/dirsrvtests/tests/suites/tls/tls_import_ca_chain_test.py b/dirsrvtests/tests/suites/tls/tls_import_ca_chain_test.py
new file mode 100644
index 000000000..947fb8444
--- /dev/null
+++ b/dirsrvtests/tests/suites/tls/tls_import_ca_chain_test.py
@@ -0,0 +1,54 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2022, William Brown <[email protected]>
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+
+import pytest
+import ldap
+import os
+
+from lib389.nss_ssl import NssSsl
+from lib389.topologies import topology_st
+
+pytestmark = pytest.mark.tier1
+
+CA_CHAIN_FILE = os.path.join(os.path.dirname(__file__), '../../data/tls/tls_import_ca_chain.pem')
+CRT_CHAIN_FILE = os.path.join(os.path.dirname(__file__), '../../data/tls/tls_import_crt_chain.pem')
+KEY_CHAIN_FILE = os.path.join(os.path.dirname(__file__), '../../data/tls/tls_import_key_chain.pem')
+KEY_FILE = os.path.join(os.path.dirname(__file__), '../../data/tls/tls_import_key.pem')
+
+def test_tls_import_chain(topology_st):
+ """Test that TLS import will correct report errors when there are multiple
+ files in a chain.
+
+ :id: b7ba71bd-112a-44a1-8a7e-8968249da419
+
+ :steps:
+ 1. Attempt to import a ca chain
+
+ :expectedresults:
+ 1. The chain is rejected
+ """
+ topology_st.standalone.stop()
+ tls = NssSsl(dirsrv=topology_st.standalone)
+ tls.reinit()
+
+ with pytest.raises(ValueError):
+ tls.add_cert(nickname='CA_CHAIN_1', input_file=CA_CHAIN_FILE)
+
+ with pytest.raises(ValueError):
+ tls.add_server_key_and_cert(KEY_FILE, CRT_CHAIN_FILE)
+ with pytest.raises(ValueError):
+ tls.add_server_key_and_cert(KEY_CHAIN_FILE, CRT_CHAIN_FILE)
+ with pytest.raises(ValueError):
+ tls.add_server_key_and_cert(KEY_FILE, KEY_CHAIN_FILE)
+
+ with pytest.raises(ValueError):
+ tls.import_rsa_crt(crt=CRT_CHAIN_FILE)
+ with pytest.raises(ValueError):
+ tls.import_rsa_crt(ca=CA_CHAIN_FILE)
+
diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py
index a1408b3ad..3561597b9 100644
--- a/src/lib389/lib389/nss_ssl.py
+++ b/src/lib389/lib389/nss_ssl.py
@@ -73,6 +73,17 @@ class NssSsl(DSLint):
def lint_uid(cls):
return 'tls'
+ def _assert_not_chain(self, pemfile):
+ # To work this out, we open the file and count how many
+ # begin key and begin cert lines there are. Any more than 1 is bad.
+ count = 0
+ with open(pemfile, 'r') as f:
+ for line in f:
+ if line.startswith('-----BEGIN PRIVATE KEY-----') or line.startswith('-----BEGIN CERTIFICATE-----'):
+ count = count + 1
+ if count > 1:
+ raise ValueError(f"The file {pemfile} may be a chain file. This is not supported. Break out each certificate and key into unique files, and import them individually.")
+
def _lint_certificate_expiration(self):
"""Check all the certificates in the db if they will expire within 30 days
or have already expired.
@@ -668,6 +679,10 @@ only.
assert ca is not None or crt is not None, "At least one parameter should be specified (ca or crt)"
if ca is not None:
+ if not os.path.exists(ca):
+ raise ValueError("The certificate file ({}) does not exist".format(ca))
+ self._assert_not_chain(ca)
+
shutil.copyfile(ca, '%s/ca.crt' % self._certdb)
self.openssl_rehash(self._certdb)
cmd = [
@@ -688,6 +703,9 @@ only.
raise ValueError(e.output.decode('utf-8').rstrip())
if crt is not None:
+ if not os.path.exists(crt):
+ raise ValueError("The certificate file ({}) does not exist".format(crt))
+ self._assert_not_chain(crt)
cmd = [
'/usr/bin/certutil',
'-A',
@@ -991,6 +1009,8 @@ only.
if not os.path.exists(input_file):
raise ValueError("The certificate file ({}) does not exist".format(input_file))
+ self._assert_not_chain(input_file)
+
if ca:
trust_flags = "CT,,"
else:
@@ -1019,6 +1039,9 @@ only.
if not os.path.exists(input_cert):
raise ValueError("The cert file ({}) does not exist".format(input_cert))
+ self._assert_not_chain(input_key)
+ self._assert_not_chain(input_cert)
+
self.log.debug(f"Importing key and cert -> {input_key}, {input_cert}")
p12_bundle = "%s/temp_server_key_cert.p12" % self._certdb
| 0 |
b5d962745c7c323856d7ac3215e62e8be72ec97a
|
389ds/389-ds-base
|
Issue 49624 - modrdn silently fails if DB deadlock occurs
Bug Description:
If a DB Deadlock error occurs during a modrdn operation the entry
cache gets updated (corrupted), but the update is not applied to
the database.
Fix Description:
Looks like there was a copy & paste error, and the wrong attribute
was updated during the retry of the modrdn operation.
relates: https://pagure.io/389-ds-base/issue/49624
Reviewed by: lkrispenz (Thanks!)
|
commit b5d962745c7c323856d7ac3215e62e8be72ec97a
Author: Mark Reynolds <[email protected]>
Date: Thu Aug 22 10:26:24 2019 -0400
Issue 49624 - modrdn silently fails if DB deadlock occurs
Bug Description:
If a DB Deadlock error occurs during a modrdn operation the entry
cache gets updated (corrupted), but the update is not applied to
the database.
Fix Description:
Looks like there was a copy & paste error, and the wrong attribute
was updated during the retry of the modrdn operation.
relates: https://pagure.io/389-ds-base/issue/49624
Reviewed by: lkrispenz (Thanks!)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 65610d613..433ed88fb 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -251,7 +251,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &dn_newsuperiordn);
slapi_sdn_free(&dn_newsuperiordn);
slapi_pblock_set(pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, orig_dn_newsuperiordn);
- orig_dn_newsuperiordn = slapi_sdn_dup(orig_dn_newsuperiordn);
+ dn_newsuperiordn = slapi_sdn_dup(orig_dn_newsuperiordn);
/* must duplicate ec before returning it to cache,
* which could free the entry. */
if ((tmpentry = backentry_dup(original_entry ? original_entry : ec)) == NULL) {
| 0 |
0c94f21919303b85739f77ab77a852bb5edf645d
|
389ds/389-ds-base
|
Issue 50578 - Add SKIP_AUDIT_CI flag for Cockpit builds
Description: Sometimes we need to skip audit-ci check because
we are doing a bisect or just checking older commit.
Process an environment variable SKIP_AUDIT_CI and
if it's set - skip the audit-ci action.
https://pagure.io/389-ds-base/issue/50578
Reviewed by: mreynolds, vashirov (Thanks!)
|
commit 0c94f21919303b85739f77ab77a852bb5edf645d
Author: Simon Pichugin <[email protected]>
Date: Thu Aug 29 17:55:30 2019 +0200
Issue 50578 - Add SKIP_AUDIT_CI flag for Cockpit builds
Description: Sometimes we need to skip audit-ci check because
we are doing a bisect or just checking older commit.
Process an environment variable SKIP_AUDIT_CI and
if it's set - skip the audit-ci action.
https://pagure.io/389-ds-base/issue/50578
Reviewed by: mreynolds, vashirov (Thanks!)
diff --git a/src/cockpit/389-console/node_modules.mk b/src/cockpit/389-console/node_modules.mk
index 307e8e317..e88b994cb 100644
--- a/src/cockpit/389-console/node_modules.mk
+++ b/src/cockpit/389-console/node_modules.mk
@@ -2,7 +2,10 @@ install: package.json
npm ci
build-cockpit-plugin: webpack.config.js
- npm run audit-ci && npm run build && cp -r dist cockpit_dist
+ifndef SKIP_AUDIT_CI
+ npm run audit-ci
+endif
+ npm run build && cp -r dist cockpit_dist
eslint-fix:
npm run eslint:fix
| 0 |
40e0d0f80d6fd1271431e105580293747c43c327
|
389ds/389-ds-base
|
Ticket #48188 - segfault in ns-slapd due to accessing Slapi_DN freed in pre bind plug-in
This patch is based upon the patch provided by Simo Sorce <[email protected]> for
Ticket #48272 - Allow PRE_BIND plugins to mangle DNs
Description:
Allow a pre_bind plugin to map a DN to another
This is useful for plugins that deal with virtual trees or non-standard
clients binding with values that are not proper DNs and similar situations.
Signed-off-by: Simo Sorce <[email protected]>
2 changes are made to the original patch:
1. removed "slapi_sdn_free(&sdn)" with this comment:
* It is a plug-in's responsibility to free the original Slapi_DN.
Note: slapi-nis already freed the original sdn.
2. reset dn from the new sdn.
dn = slapi_sdn_get_dn(sdn);
https://fedorahosted.org/389/ticket/48188
Reviewed by [email protected] and [email protected].
|
commit 40e0d0f80d6fd1271431e105580293747c43c327
Author: Simo Sorce <[email protected]>
Date: Fri Sep 18 11:13:43 2015 -0700
Ticket #48188 - segfault in ns-slapd due to accessing Slapi_DN freed in pre bind plug-in
This patch is based upon the patch provided by Simo Sorce <[email protected]> for
Ticket #48272 - Allow PRE_BIND plugins to mangle DNs
Description:
Allow a pre_bind plugin to map a DN to another
This is useful for plugins that deal with virtual trees or non-standard
clients binding with values that are not proper DNs and similar situations.
Signed-off-by: Simo Sorce <[email protected]>
2 changes are made to the original patch:
1. removed "slapi_sdn_free(&sdn)" with this comment:
* It is a plug-in's responsibility to free the original Slapi_DN.
Note: slapi-nis already freed the original sdn.
2. reset dn from the new sdn.
dn = slapi_sdn_get_dn(sdn);
https://fedorahosted.org/389/ticket/48188
Reviewed by [email protected] and [email protected].
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 1bd604f96..4ec276a34 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -669,7 +669,7 @@ do_bind( Slapi_PBlock *pb )
slapi_pblock_set( pb, SLAPI_BACKEND, be );
- /* not root dn - pass to the backend */
+ /* not root dn - pass to the backend */
if ( be->be_bind != NULL ) {
/*
@@ -677,10 +677,25 @@ do_bind( Slapi_PBlock *pb )
* the backend bind function. then call the post-bind
* plugins.
*/
- if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN )
- == 0 ) {
+ if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) == 0 ) {
rc = 0;
+ /* Check if a pre_bind plugin mapped the DN to another backend */
+ Slapi_DN *pb_sdn;
+ slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &pb_sdn);
+ if (pb_sdn != sdn) {
+ /*
+ * Slapi_DN set in pblock was changed by a pre bind plug-in.
+ * It is a plug-in's responsibility to free the original Slapi_DN.
+ */
+ sdn = pb_sdn;
+ dn = slapi_sdn_get_dn(sdn);
+
+ slapi_be_Unlock(be);
+ be = slapi_be_select(sdn);
+ slapi_be_Rlock(be);
+ }
+
/*
* Is this account locked ?
* could be locked through the account inactivation
| 0 |
3bcba2416c21f2c297ade289f17549ae2bc6b4e9
|
389ds/389-ds-base
|
Bug 615100 - log rotationinfo always recreated at startup,
and corrupted on some platforms
https://bugzilla.redhat.com/show_bug.cgi?id=615100
Description:
1) At startup log__check_prevlogs() verifies that all logs are
referenced in the rotationinfo file. If the rotationinfo file
doesn't reference all the present log files, it will recreate
the rotationinfo file based on the log files that are present.
However, the logic to break out of the loop that performs the
verification is incorrect so it always considers the rotationinfo
file to be bogus and recreates it. I've corrected the logic.
2) Recreating the rotationinfo file isn't bad per se, but the
code that recreates the rotationinfo file is also broken on HP-UX
(and probably Solaris). It tries to use the libc function strptime()
to format a date such as "20100128-153532" into a struct tm, so that
it can create an epoch date from there. The format string being
used for strptime() is "%Y%m%d-%H%M%S", which works on Linux, but
the strptime() function requires whitespace or alpha-numeric
separators between format specifiers on HP-UX (and Solaris according
to their man page), so strptime() fails. My fix here was to convert
the compact date string into a string in ISO8601-like format with
separators so strptime() can parse it.
This patch was provided by Ulf Weltman ([email protected]).
|
commit 3bcba2416c21f2c297ade289f17549ae2bc6b4e9
Author: Noriko Hosoi <[email protected]>
Date: Wed Jan 12 11:27:35 2011 -0800
Bug 615100 - log rotationinfo always recreated at startup,
and corrupted on some platforms
https://bugzilla.redhat.com/show_bug.cgi?id=615100
Description:
1) At startup log__check_prevlogs() verifies that all logs are
referenced in the rotationinfo file. If the rotationinfo file
doesn't reference all the present log files, it will recreate
the rotationinfo file based on the log files that are present.
However, the logic to break out of the loop that performs the
verification is incorrect so it always considers the rotationinfo
file to be bogus and recreates it. I've corrected the logic.
2) Recreating the rotationinfo file isn't bad per se, but the
code that recreates the rotationinfo file is also broken on HP-UX
(and probably Solaris). It tries to use the libc function strptime()
to format a date such as "20100128-153532" into a struct tm, so that
it can create an epoch date from there. The format string being
used for strptime() is "%Y%m%d-%H%M%S", which works on Linux, but
the strptime() function requires whitespace or alpha-numeric
separators between format specifiers on HP-UX (and Solaris according
to their man page), so strptime() fails. My fix here was to convert
the compact date string into a string in ISO8601-like format with
separators so strptime() can parse it.
This patch was provided by Ulf Weltman ([email protected]).
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index e4e98ce8c..98090e8f6 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -33,6 +33,7 @@
*
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
* Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
* All rights reserved.
* END COPYRIGHT BLOCK **/
@@ -2804,14 +2805,16 @@ log__check_prevlogs (FILE *fp, char *pathname)
fseek(fp, 0 ,SEEK_SET);
buf[BUFSIZ-1] = '\0';
+ rval = LOG_ERROR; /* pessmistic default */
while (fgets(buf, BUFSIZ - 1, fp)) {
if (strstr(buf, dirent->name)) {
rval = LOG_CONTINUE; /* found in .rotationinfo */
- continue;
- }
+ break;
+ }
+ }
+ if(LOG_ERROR == rval) {
+ goto done;
}
- rval = LOG_ERROR; /* not found in .rotationinfo */
- break;
}
}
done:
@@ -4101,8 +4104,18 @@ log_reverse_convert_time(char *tbuf)
{
struct tm tm = {0};
- if (strchr(tbuf, '-')) { /* short format */
- strptime(tbuf, "%Y%m%d-%H%M%S", &tm);
+ if (strchr(tbuf, '-') && strlen(tbuf) >= 15) {
+ /* short format: YYYYmmdd-HHMMSS
+ strptime requires whitespace or non-alpha characters between format
+ specifiers on some platforms, so convert to an ISO8601-like format
+ with separators */
+ char tbuf_with_sep[] = "yyyy-mm-dd HH:MM:SS";
+ if( sscanf(tbuf, "%4c%2c%2c-%2c%2c%2c", tbuf_with_sep,
+ tbuf_with_sep+5, tbuf_with_sep+8, tbuf_with_sep+11,
+ tbuf_with_sep+14, tbuf_with_sep+17) != 6 ) {
+ return 0;
+ }
+ strptime(tbuf_with_sep, "%Y-%m-%d %H:%M:%S", &tm);
} else if (strchr(tbuf, '/') && strchr(tbuf, ':')) { /* long format */
strptime(tbuf, "%d/%b/%Y:%H:%M:%S", &tm);
} else {
| 0 |
3cce9f9188a38e1a5043c9659ecbc5955ddb0242
|
389ds/389-ds-base
|
Ticket 48956 ns-accountstatus.pl showing "activated" user even if it is inactivated
Bug Description:
If the account policy DN is long (suffix is long), it is fold on several lines.
So when looking for it, the base DN is invalid and fail to retrieve it and the limit value.
Fix Description:
Change the DSutil search to be in no fold
https://fedorahosted.org/389/ticket/48956
Reviewed by: Noriko Hosoi (Thanks Noriko)
Platforms tested: F23
Flag Day: no
Doc impact: no
|
commit 3cce9f9188a38e1a5043c9659ecbc5955ddb0242
Author: Thierry Bordaz <[email protected]>
Date: Wed Aug 17 16:46:47 2016 +0200
Ticket 48956 ns-accountstatus.pl showing "activated" user even if it is inactivated
Bug Description:
If the account policy DN is long (suffix is long), it is fold on several lines.
So when looking for it, the base DN is invalid and fail to retrieve it and the limit value.
Fix Description:
Change the DSutil search to be in no fold
https://fedorahosted.org/389/ticket/48956
Reviewed by: Noriko Hosoi (Thanks Noriko)
Platforms tested: F23
Flag Day: no
Doc impact: no
diff --git a/dirsrvtests/tests/tickets/ticket48956_test.py b/dirsrvtests/tests/tickets/ticket48956_test.py
new file mode 100644
index 000000000..291dd4e31
--- /dev/null
+++ b/dirsrvtests/tests/tickets/ticket48956_test.py
@@ -0,0 +1,167 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+import subprocess
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+
+DEBUGGING = False
+
+RDN_LONG_SUFFIX = 'this'
+LONG_SUFFIX = "dc=%s,dc=is,dc=a,dc=very,dc=long,dc=suffix,dc=so,dc=long,dc=suffix,dc=extremely,dc=long,dc=suffix" % RDN_LONG_SUFFIX
+LONG_SUFFIX_BE = 'ticket48956'
+
+
+ACCT_POLICY_PLUGIN_DN = 'cn=%s,cn=plugins,cn=config' % PLUGIN_ACCT_POLICY
+ACCT_POLICY_CONFIG_DN = 'cn=config,%s' % ACCT_POLICY_PLUGIN_DN
+
+
+INACTIVITY_LIMIT = '9'
+SEARCHFILTER = '(objectclass=*)'
+
+TEST_USER = 'ticket48956user'
+TEST_USER_PW = '%s' % TEST_USER
+
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+
+class TopologyStandalone(object):
+ """The DS Topology Class"""
+ def __init__(self, standalone):
+ """Init"""
+ standalone.open()
+ self.standalone = standalone
+
+
[email protected](scope="module")
+def topology(request):
+ """Create DS Deployment"""
+
+ # Creating standalone instance ...
+ if DEBUGGING:
+ standalone = DirSrv(verbose=True)
+ else:
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ def fin():
+ """If we are debugging just stop the instances, otherwise remove them
+ """
+ if DEBUGGING:
+ standalone.stop()
+ else:
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ return TopologyStandalone(standalone)
+
+def _check_status(topology, user, expected):
+ nsaccountstatus = '%s/sbin/ns-accountstatus.pl' % topology.standalone.prefix
+ proc = subprocess.Popen([nsaccountstatus, '-Z', 'standalone', '-D', DN_DM, '-w', PASSWORD, '-p', str(topology.standalone.port), '-I', user], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ found = False
+ while True:
+ l = proc.stdout.readline()
+ log.info("output: %s" % l)
+ if l == "":
+ break
+ if expected in l:
+ found = True
+ break
+ return found
+
+def _check_inactivity(topology, mysuffix):
+ ACCT_POLICY_DN = 'cn=Account Inactivation Policy,%s' % mysuffix
+ log.info("\n######################### Adding Account Policy entry: %s ######################\n" % ACCT_POLICY_DN)
+ topology.standalone.add_s(Entry((ACCT_POLICY_DN, {'objectclass': "top ldapsubentry extensibleObject accountpolicy".split(),
+ 'accountInactivityLimit': INACTIVITY_LIMIT})))
+ TEST_USER_DN = 'uid=%s,%s' % (TEST_USER, mysuffix)
+ log.info("\n######################### Adding Test User entry: %s ######################\n" % TEST_USER_DN)
+ topology.standalone.add_s(Entry((TEST_USER_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
+ 'cn': TEST_USER,
+ 'sn': TEST_USER,
+ 'givenname': TEST_USER,
+ 'userPassword': TEST_USER_PW,
+ 'acctPolicySubentry': ACCT_POLICY_DN})))
+
+ # Setting the lastLoginTime
+ try:
+ topology.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW)
+ except ldap.CONSTRAINT_VIOLATION as e:
+ log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+
+
+ assert(_check_status(topology, TEST_USER_DN, '- activated'))
+
+ time.sleep(int(INACTIVITY_LIMIT) + 5)
+ assert(_check_status(topology, TEST_USER_DN, '- inactivated (inactivity limit exceeded'))
+
+def test_ticket48956(topology):
+ """Write your testcase here...
+
+ Also, if you need any testcase initialization,
+ please, write additional fixture for that(include finalizer).
+
+ """
+
+ topology.standalone.modify_s(ACCT_POLICY_PLUGIN_DN, [(ldap.MOD_REPLACE, 'nsslapd-pluginarg0', ACCT_POLICY_CONFIG_DN)])
+
+ topology.standalone.modify_s(ACCT_POLICY_CONFIG_DN, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', 'yes'),
+ (ldap.MOD_REPLACE, 'stateattrname', 'lastLoginTime'),
+ (ldap.MOD_REPLACE, 'altstateattrname', 'createTimestamp'),
+ (ldap.MOD_REPLACE, 'specattrname', 'acctPolicySubentry'),
+ (ldap.MOD_REPLACE, 'limitattrname', 'accountInactivityLimit')])
+
+ # Enable the plugins
+ topology.standalone.plugins.enable(name=PLUGIN_ACCT_POLICY)
+
+ topology.standalone.restart(timeout=10)
+
+ # Check inactivity on standard suffix (short)
+ _check_inactivity(topology, SUFFIX)
+
+ # Check inactivity on a long suffix
+ topology.standalone.backend.create(LONG_SUFFIX, {BACKEND_NAME: LONG_SUFFIX_BE})
+ topology.standalone.mappingtree.create(LONG_SUFFIX, bename=LONG_SUFFIX_BE)
+ topology.standalone.add_s(Entry((LONG_SUFFIX, {
+ 'objectclass': "top domain".split(),
+ 'dc': RDN_LONG_SUFFIX})))
+ _check_inactivity(topology, LONG_SUFFIX)
+
+
+ if DEBUGGING:
+ # Add debugging steps(if any)...
+ pass
+
+ log.info('Test PASSED')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
+
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index f53f0c0e4..756d6eab3 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -1201,8 +1201,10 @@ sub get_info {
my $toollib = `ldapsearch -V 2>&1`;
if ($toollib =~ /OpenLDAP/) {
$info{openldap} = "yes";
+ $info{nofold} = "-o ldif-wrap=no";
} else {
$info{openldap} = "no";
+ $info{nofold} = "-T";
}
#
@@ -1537,10 +1539,10 @@ sub ldapsrch {
print "STARTTLS)\n";
}
if($info{openldap} eq "yes"){
- $search = "ldapsearch -x -LLL -ZZ -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw " .
+ $search = "ldapsearch -x -LLL -ZZ -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} " .
"$info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs}";
} else {
- $search = "ldapsearch -ZZZ -P \"$info{certdir}\" -p $info{port} -h $info{host} -D \"$info{rootdn}\" " .
+ $search = "ldapsearch -ZZZ -P \"$info{certdir}\" -p $info{port} -h $info{host} -D \"$info{rootdn}\" $info{nofold} " .
"-w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs}";
}
} elsif (($info{security} eq "on" && $info{protocol} eq "") || ($info{security} eq "on" && $info{protocol} =~ m/LDAPS/i) ){
@@ -1551,10 +1553,10 @@ sub ldapsrch {
print "LDAPS)\n";
}
if($info{openldap} eq "yes"){
- $search = "ldapsearch -x -LLL -H \"ldaps://$info{host}:$info{secure_port}\" -D \"$info{rootdn}\" " .
+ $search = "ldapsearch -x -LLL -H \"ldaps://$info{host}:$info{secure_port}\" -D \"$info{rootdn}\" $info{nofold} " .
"-w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs}";
} else {
- $search = "ldapsearch -Z -P \"$info{certdir}\" -p $info{secure_port} -h $info{host} -D \"$info{rootdn}\" " .
+ $search = "ldapsearch -Z -P \"$info{certdir}\" -p $info{secure_port} -h $info{host} -D \"$info{rootdn}\" $info{nofold} " .
"-w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs}";
}
} elsif (($info{openldap} eq "yes") && (($info{ldapi} eq "on" && $info{protocol} eq "") || ($info{ldapi} eq "on" && $info{protocol} =~ m/LDAPI/i)) ){
@@ -1562,10 +1564,10 @@ sub ldapsrch {
# LDAPI
#
if ($< == 0 && $info{autobind} eq "on"){
- $search = "ldapsearch -LLL -H \"$info{ldapiURL}\" -Y EXTERNAL " .
+ $search = "ldapsearch -LLL -H \"$info{ldapiURL}\" -Y EXTERNAL $info{nofold} " .
"$info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} 2>/dev/null";
} else {
- $search = "ldapsearch -x -LLL -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw " .
+ $search = "ldapsearch -x -LLL -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} " .
"$info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs}";
}
} else {
@@ -1576,10 +1578,10 @@ sub ldapsrch {
print "LDAP)\n";
}
if($info{openldap} eq "yes"){
- $search = "ldapsearch -x -LLL -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw " .
+ $search = "ldapsearch -x -LLL -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} " .
"$info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs}";
} else {
- $search = "ldapsearch -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw " .
+ $search = "ldapsearch -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} " .
"$info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs}";
}
}
@@ -1611,9 +1613,9 @@ sub ldapsrch_ext {
print "STARTTLS)\n";
}
if($info{openldap} eq "yes"){
- return `ldapsearch -x -LLL -ZZ -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
+ return `ldapsearch -x -LLL -ZZ -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
} else {
- return `ldapsearch -ZZZ -P $info{certdir} -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
+ return `ldapsearch -ZZZ -P $info{certdir} -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
}
} elsif (($info{security} eq "on" && $info{protocol} eq "") || ($info{security} eq "on" && $info{protocol} =~ m/LDAPS/i) ){
#
@@ -1623,18 +1625,18 @@ sub ldapsrch_ext {
print "LDAPS)\n";
}
if($info{openldap} eq "yes"){
- return `ldapsearch -x -LLL -H ldaps://$info{host}:$info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
+ return `ldapsearch -x -LLL -H ldaps://$info{host}:$info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
} else {
- return `ldapsearch -Z -P $info{certdir} -p $info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
+ return `ldapsearch -Z -P $info{certdir} -p $info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
}
} elsif (($info{openldap} eq "yes") && (($info{ldapi} eq "on" && $info{protocol} eq "") || ($info{ldapi} eq "on" && $info{protocol} =~ m/LDAPI/i)) ){
#
# LDAPI
#
if ($< == 0 && $info{autobind} eq "on"){
- return `ldapsearch -LLL -H \"$info{ldapiURL}\" -Y EXTERNAL $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect} 2>/dev/null`;
+ return `ldapsearch -LLL -H \"$info{ldapiURL}\" -Y EXTERNAL $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect} 2>/dev/null`;
} else {
- return `ldapsearch -x -LLL -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
+ return `ldapsearch -x -LLL -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
}
} else {
#
@@ -1644,9 +1646,9 @@ sub ldapsrch_ext {
print "LDAP)\n";
}
if($info{openldap} eq "yes"){
- return `ldapsearch -x -LLL -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
+ return `ldapsearch -x -LLL -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
} else {
- return `ldapsearch -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
+ return `ldapsearch -p $info{port} -h $info{host} -D \"$info{rootdn}\" -w $myrootdnpw $info{nofold} $info{srch_args} -b \"$info{base}\" -s $info{scope} \"$info{filter}\" $info{attrs} $info{redirect}`;
}
}
}
| 0 |
05b00f20f7ec6053b562af2b28820e1e5a3c89bf
|
389ds/389-ds-base
|
Ticket #48081 - Add regression tests for pwpolicy
Description: When troubleshooting TET test failures for RHEL-7.4, we
found couple of issues related to PasswordCheckSyntax attribute. One
of the issue is accepting trivial password and other one is rejecting
Passwords similar to cn, sn and uid attributes. Automated both the
bugs in this patch.
https://pagure.io/389-ds-base/issue/48081
Reviewed by: spichugi
Signed-off-by: Simon Pichugin <[email protected]>
|
commit 05b00f20f7ec6053b562af2b28820e1e5a3c89bf
Author: Sankar Ramalingam <[email protected]>
Date: Wed Aug 9 22:10:46 2017 +0530
Ticket #48081 - Add regression tests for pwpolicy
Description: When troubleshooting TET test failures for RHEL-7.4, we
found couple of issues related to PasswordCheckSyntax attribute. One
of the issue is accepting trivial password and other one is rejecting
Passwords similar to cn, sn and uid attributes. Automated both the
bugs in this patch.
https://pagure.io/389-ds-base/issue/48081
Reviewed by: spichugi
Signed-off-by: Simon Pichugin <[email protected]>
diff --git a/dirsrvtests/tests/suites/password/regression_test.py b/dirsrvtests/tests/suites/password/regression_test.py
new file mode 100644
index 000000000..e2cbeccac
--- /dev/null
+++ b/dirsrvtests/tests/suites/password/regression_test.py
@@ -0,0 +1,137 @@
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import pytest
+from lib389._constants import SUFFIX, PASSWORD
+from lib389.idm.user import UserAccounts
+from lib389.utils import ldap, os, logging
+from lib389.topologies import topology_st as topo
+
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+TEST_PASSWORDS = ('CN12pwtest31', 'SN3pwtest231', 'UID1pwtest123', '[email protected]')
+user_data = {'cn': 'CNpwtest1', 'sn': 'SNpwtest1', 'uid': 'UIDpwtest1', 'mail': '[email protected]'}
+
+
[email protected](scope="module")
+def passw_policy(topo, request):
+ """Configure password policy with PasswordCheckSyntax attribute set to on"""
+
+ log.info('Configure Pwpolicy with PasswordCheckSyntax and nsslapd-pwpolicy-local set to on')
+ topo.standalone.config.set('PasswordExp', 'on')
+ topo.standalone.config.set('PasswordCheckSyntax', 'on')
+ topo.standalone.config.set('nsslapd-pwpolicy-local', 'on')
+
+ subtree = 'ou=people,{}'.format(SUFFIX)
+ log.info('Configure subtree password policy for {}'.format(subtree))
+ topo.standalone.subtreePwdPolicy(subtree, {'passwordchange': 'on', 'passwordCheckSyntax': 'on'})
+
+ def fin():
+ log.info('Reset pwpolicy configuration settings')
+ topo.standalone.config.set('PasswordExp', 'off')
+ topo.standalone.config.set('PasswordCheckSyntax', 'off')
+ topo.standalone.config.set('nsslapd-pwpolicy-local', 'off')
+
+ request.addfinalizer(fin)
+
+
[email protected](scope="module")
+def test_user(topo, request):
+ """Add test users using UserAccounts"""
+
+ log.info('Adding user-uid={},ou=people,{}'.format(user_data['uid'], SUFFIX))
+ users = UserAccounts(topo.standalone, SUFFIX)
+ user_properties = {
+ 'uidNumber': '1001',
+ 'gidNumber': '2001',
+ 'userpassword': PASSWORD,
+ 'homeDirectory': '/home/pwtest1'}
+ user_properties.update(user_data)
+ tuser = users.create(properties=user_properties)
+
+ def fin():
+ log.info('Deleting user-{}'.format(tuser.dn))
+ tuser.delete()
+
+ request.addfinalizer(fin)
+ return tuser
+
+
[email protected]
[email protected]("user_pasw", (user_data.values()))
+def test_trivial_passw_check(topo, passw_policy, test_user, user_pasw):
+ """PasswordCheckSyntax attribute fails to validate cn, sn, uid and mail attributes
+
+ :id: bf9fe1ef-56cb-46a3-a6f8-5530398a06dc
+ :feature: Password policy
+ :setup: Standalone instance.
+ :steps: 1. Configure password policy with PasswordCheckSyntax set to on.
+ 2. Add users with cn, sn, uid, mail and userPassword attributes.
+ 3. Configure subtree password policy for ou=people subtree.
+ 4. Reset userPassword with trivial values like cn, sn, uid and mail.
+ :expectedresults:
+ 1. Enabling PasswordCheckSyntax should PASS.
+ 2. Add users should PASS.
+ 3. Configure subtree password policy should PASS.
+ 4. Resetting userPassword to cn, sn, uid and mail should be rejected.
+ """
+
+ conn = test_user.bind(PASSWORD)
+ try:
+ log.info('Replace userPassword attribute with {}'.format(user_pasw))
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION) as excinfo:
+ conn.modify_s(test_user.dn, [(ldap.MOD_REPLACE, 'userPassword', user_pasw)])
+ log.fatal('Failed: Userpassword with {} is accepted'.format(user_pasw))
+ assert 'password based off of user entry' in str(excinfo.value)
+ finally:
+ conn.unbind_s()
+ test_user.set('userPassword', PASSWORD)
+
+
[email protected]
[email protected]("user_pasw", TEST_PASSWORDS)
+def test_cn_sn_like_passw(topo, passw_policy, test_user, user_pasw):
+ """Passwords rejected if its similar to uid, cn, sn or mail attributes
+
+ :id: dfd6cf5d-8bcd-4895-a691-a43ad9ec1be8
+ :feature: Password policy
+ :setup: Standalone instance
+ :steps: 1. Configure password policy with PasswordCheckSyntax set to on
+ 2. Add users with cn, sn, uid, mail and userPassword attributes
+ 3. Replace userPassword similar to cn, sn, uid and mail attribute
+ :expectedresults:
+ 1. Enabling PasswordCheckSyntax should PASS.
+ 2. Add users should PASS.
+ 3. Resetting userPasswords similar to cn, sn, uid and mail should PASS.
+ """
+
+ log.info('Configure Pwpolicy with PasswordCheckSyntax and nsslapd-pwpolicy-local set to off')
+ topo.standalone.config.set('nsslapd-pwpolicy-local', 'off')
+
+ conn = test_user.bind(PASSWORD)
+ log.info('Replace userPassword attribute with {}'.format(user_pasw))
+ try:
+ try:
+ conn.modify_s(test_user.dn, [(ldap.MOD_REPLACE, 'userPassword', user_pasw)])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to replace userPassword: error {}'.format(e.message['desc']))
+ raise e
+ finally:
+ conn.unbind_s()
+ test_user.set('userPassword', PASSWORD)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s {}".format(CURRENT_FILE))
| 0 |
d723996cfb2af9ec04d92e471c996b0e0cc59893
|
389ds/389-ds-base
|
Fix for #156449 : mangle 'street' attribute to defeat our schema aliasing it with 'streetaddress'
|
commit d723996cfb2af9ec04d92e471c996b0e0cc59893
Author: David Boreham <[email protected]>
Date: Mon May 9 20:34:31 2005 +0000
Fix for #156449 : mangle 'street' attribute to defeat our schema aliasing it with 'streetaddress'
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index f0d414115..db5ba84db 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -523,7 +523,16 @@ windows_LDAPMessage2Entry(LDAP * ld, LDAPMessage * msg, int attrsonly) {
} else
{
struct berval ** aVal = ldap_get_values_len( ld, msg, a);
- slapi_entry_add_values( e, a, aVal);
+ char *type_to_use = NULL;
+ /* Work around the fact that we alias street and streetaddress, while Microsoft do not */
+ if (0 == strcasecmp(a,"streetaddress"))
+ {
+ type_to_use = FAKE_STREET_ATTR_NAME;
+ } else
+ {
+ type_to_use = a;
+ }
+ slapi_entry_add_values( e, type_to_use, aVal);
ldap_memfree(a);
ldap_value_free_len(aVal);
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 562a7c65b..e57bf903a 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -193,8 +193,8 @@ static windows_attribute_map user_attribute_map[] =
{ "maxStorage", "ntUserMaxStorage", bidirectional, always, normal},
{ "profilePath", "ntUserProfile", bidirectional, always, normal},
/* IETF schema has 'street' and 'streetaddress' as aliases, but Microsoft does not */
- { "street", "street", fromwindowsonly, always, normal},
{ "streetAddress", "street", towindowsonly, always, normal},
+ { FAKE_STREET_ATTR_NAME, "street", fromwindowsonly, always, normal},
{ "userParameters", "ntUserParms", bidirectional, always, normal},
{ "userWorkstations", "ntUserWorkstations", bidirectional, always, normal},
{ "sAMAccountName", "ntUserDomainId", bidirectional, always, normal},
@@ -212,8 +212,8 @@ static windows_attribute_map group_attribute_map[] =
{ "groupType", "ntGroupType", bidirectional, createonly, normal},
{ "sAMAccountName", "ntUserDomainId", bidirectional, always, normal},
/* IETF schema has 'street' and 'streetaddress' as aliases, but Microsoft does not */
- { "street", "street", fromwindowsonly, always, normal},
{ "streetAddress", "street", towindowsonly, always, normal},
+ { FAKE_STREET_ATTR_NAME, "street", fromwindowsonly, always, normal},
{ "member", "uniquemember", bidirectional, always, dnmap},
{NULL, NULL, -1}
};
diff --git a/ldap/servers/plugins/replication/windowsrepl.h b/ldap/servers/plugins/replication/windowsrepl.h
index 645c257fc..791f9baf3 100644
--- a/ldap/servers/plugins/replication/windowsrepl.h
+++ b/ldap/servers/plugins/replication/windowsrepl.h
@@ -90,3 +90,6 @@ ConnResult windows_conn_push_schema(Repl_Connection *conn, CSN **remotecsn);
void windows_conn_set_timeout(Repl_Connection *conn, long timeout);
void windows_conn_set_agmt_changed(Repl_Connection *conn);
+/* Used to work around a schema incompatibility between Microsoft and the IETF */
+#define FAKE_STREET_ATTR_NAME "in#place#of#streetaddress"
+
| 0 |
daf4b42389b4cd191752c073d97d4df80b5176c3
|
389ds/389-ds-base
|
Ticket 47781 - CI test - use predefined property name variables
https://fedorahosted.org/389/ticket/47781
Reviewed by: tbordaz(Thanks!)
|
commit daf4b42389b4cd191752c073d97d4df80b5176c3
Author: Mark Reynolds <[email protected]>
Date: Tue Jul 8 09:13:13 2014 -0400
Ticket 47781 - CI test - use predefined property name variables
https://fedorahosted.org/389/ticket/47781
Reviewed by: tbordaz(Thanks!)
diff --git a/dirsrvtests/tickets/ticket47781_test.py b/dirsrvtests/tickets/ticket47781_test.py
index f7bf881ed..8eb68ba37 100644
--- a/dirsrvtests/tickets/ticket47781_test.py
+++ b/dirsrvtests/tickets/ticket47781_test.py
@@ -167,7 +167,7 @@ def test_ticket47781(topology):
# export the replication ldif
#
log.info('Exporting replication ldif...')
- args = {'repl-info': True}
+ args = {EXPORT_REPL_INFO: True}
exportTask = Tasks(topology.standalone)
try:
exportTask.exportLDIF(DEFAULT_SUFFIX, None, "/tmp/export.ldif", args)
@@ -186,7 +186,7 @@ def test_ticket47781(topology):
#
log.info('Import replication LDIF file...')
importTask = Tasks(topology.standalone)
- args = {'wait': True}
+ args = {TASK_WAIT: True}
try:
importTask.importLDIF(DEFAULT_SUFFIX, None, "/tmp/export.ldif", args)
os.remove("/tmp/export.ldif")
| 0 |
20833dee417422c53ac0f88195eba81199b0f37b
|
389ds/389-ds-base
|
Bug 619623 - attr-unique-plugin ignores requiredObjectClass on modrdn operations
The attribute uniqueness plug-in is not checking if renamed entries
meet the requiredObjectClass requirements. In addition, a rename
that uses a new superior is not properly handled.
This patch adds a check for requiredObjectClass for MODRDN ops. I
also added a helper function called slapi_entry_rename() which allows
the caller to apply a MODRDN operation to a Slapi_Entry. My patch
makes use of this to create a renamed dummy entry that is used to
check for any attribute uniqueness conflicts.
|
commit 20833dee417422c53ac0f88195eba81199b0f37b
Author: Nathan Kinder <[email protected]>
Date: Wed Oct 27 11:45:37 2010 -0700
Bug 619623 - attr-unique-plugin ignores requiredObjectClass on modrdn operations
The attribute uniqueness plug-in is not checking if renamed entries
meet the requiredObjectClass requirements. In addition, a rename
that uses a new superior is not properly handled.
This patch adds a check for requiredObjectClass for MODRDN ops. I
also added a helper function called slapi_entry_rename() which allows
the caller to apply a MODRDN operation to a Slapi_Entry. My patch
makes use of this to create a renamed dummy entry that is used to
check for any attribute uniqueness conflicts.
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index b856db0d2..487182334 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -771,6 +771,9 @@ preop_modify(Slapi_PBlock *pb)
err = slapi_pblock_get(pb, SLAPI_MODIFY_TARGET, &dn);
if (err) { result = uid_op_error(11); break; }
+ /*
+ * Check if it has the required object class
+ */
if (requiredObjectClass &&
!(spb = dnHasObjectClass(dn, requiredObjectClass))) { break; }
@@ -823,18 +826,16 @@ preop_modify(Slapi_PBlock *pb)
static int
preop_modrdn(Slapi_PBlock *pb)
{
- int result;
- Slapi_Entry *e;
+ int result = LDAP_SUCCESS;
+ Slapi_Entry *e = NULL;
+ Slapi_DN *sdn = NULL;
+ Slapi_Value *sv_requiredObjectClass = NULL;
#ifdef DEBUG
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
"MODRDN begin\n");
#endif
- /* Init */
- result = LDAP_SUCCESS;
- e = 0;
-
BEGIN
int err;
char *attrName = NULL;
@@ -843,8 +844,9 @@ preop_modrdn(Slapi_PBlock *pb)
char *dn;
char *superior;
char *rdn;
- int isupdatedn;
- Slapi_Attr *attr;
+ int deloldrdn = 0;
+ int isupdatedn;
+ Slapi_Attr *attr;
int argc;
char **argv = NULL;
@@ -879,10 +881,19 @@ preop_modrdn(Slapi_PBlock *pb)
break;
}
+ /* Create a Slapi_Value for the requiredObjectClass to use
+ * for checking the entry. */
+ if (requiredObjectClass) {
+ sv_requiredObjectClass = slapi_value_new_string(requiredObjectClass);
+ }
+
/* Get the DN of the entry being renamed */
err = slapi_pblock_get(pb, SLAPI_MODRDN_TARGET, &dn);
if (err) { result = uid_op_error(31); break; }
+ /* Create a Slapi_DN to use for searching. */
+ sdn = slapi_sdn_new_dn_byref(dn);
+
/* Get superior value - unimplemented in 3.0/4.0/5.0 DS */
err = slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR, &superior);
if (err) { result = uid_op_error(32); break; }
@@ -902,27 +913,18 @@ preop_modrdn(Slapi_PBlock *pb)
"MODRDN newrdn=%s\n", rdn);
#endif
- /*
- * Parse the RDN into attributes by creating a "dummy" entry
- * and setting the attributes from the RDN.
- *
- * The new entry must be freed.
- */
- e = slapi_entry_alloc();
- if (!e) { result = uid_op_error(34); break; }
-
- /* NOTE: strdup on the rdn, since it will be freed when
- * the entry is freed */
+ /* See if the old RDN value is being deleted. */
+ err = slapi_pblock_get(pb, SLAPI_MODRDN_DELOLDRDN, &deloldrdn);
+ if (err) { result = uid_op_error(34); break; }
- slapi_entry_set_dn(e, slapi_ch_strdup(rdn));
+ /* Get the entry that is being renamed so we can make a dummy copy
+ * of what it will look like after the rename. */
+ err = slapi_search_internal_get_entry(sdn, NULL, &e, plugin_identity);
+ if (err != LDAP_SUCCESS) { result = uid_op_error(35); break; }
- err = slapi_entry_add_rdn_values(e);
- if (err)
- {
- slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
- "MODRDN bad rdn value=%s\n", rdn);
- break; /* Bad DN */
- }
+ /* Apply the rename operation to the dummy entry. */
+ err = slapi_entry_rename(e, rdn, deloldrdn, superior);
+ if (err != LDAP_SUCCESS) { result = uid_op_error(36); break; }
/*
* Find any unique attribute data in the new RDN
@@ -930,6 +932,12 @@ preop_modrdn(Slapi_PBlock *pb)
err = slapi_entry_attr_find(e, attrName, &attr);
if (err) break; /* no UID attribute */
+ /*
+ * Check if it has the required object class
+ */
+ if (requiredObjectClass &&
+ !slapi_entry_attr_has_syntax_value(e, SLAPI_ATTR_OBJECTCLASS, sv_requiredObjectClass)) { break; }
+
/*
* Passed all the requirements - this is an operation we
* need to enforce uniqueness on. Now find all parent entries
@@ -938,7 +946,7 @@ preop_modrdn(Slapi_PBlock *pb)
if (NULL != markerObjectClass)
{
/* Subtree defined by location of marker object class */
- result = findSubtreeAndSearch(dn, attrName, attr, NULL,
+ result = findSubtreeAndSearch(slapi_entry_get_dn(e), attrName, attr, NULL,
requiredObjectClass, dn,
markerObjectClass);
} else
@@ -949,6 +957,8 @@ preop_modrdn(Slapi_PBlock *pb)
}
END
/* Clean-up */
+ slapi_sdn_free(&sdn);
+ slapi_value_free(&sv_requiredObjectClass);
if (e) slapi_entry_free(e);
if (result)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 22f4ae0fa..33ac4686b 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3055,6 +3055,92 @@ slapi_entry_has_children(const Slapi_Entry *entry)
return(0);
}
+/*
+ * Renames an entry to simulate a MODRDN operation
+ */
+int
+slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const char *newsuperior)
+{
+ int err = LDAP_SUCCESS;
+ char *newdn = NULL;
+ char *olddn = NULL;
+ Slapi_RDN *oldrdn = NULL;
+ Slapi_Mods *smods = NULL;
+
+ LDAPDebug( LDAP_DEBUG_TRACE, "=> slapi_entry_rename\n", 0, 0, 0 );
+
+ /* Check if entry or newrdn are NULL. */
+ if (!e || !newrdn) {
+ err = LDAP_PARAM_ERROR;
+ goto done;
+ }
+
+ /* Get the old DN. */
+ olddn = slapi_entry_get_dn(e);
+
+ /* If deleteoldrdn, find old RDN values and remove them from the entry. */
+ if (deleteoldrdn) {
+ char *type = NULL;
+ char * val = NULL;
+ int num_rdns = 0;
+ int i = 0;
+
+ oldrdn = slapi_rdn_new_dn(olddn);
+
+ /* Create mods based on the number of rdn elements. */
+ num_rdns = slapi_rdn_get_num_components(oldrdn);
+ smods = slapi_mods_new();
+ slapi_mods_init(smods, num_rdns + 2);
+
+ /* Loop through old rdns and construct a mod to remove the value. */
+ for (i = 0; i < num_rdns; i++) {
+ if (slapi_rdn_get_next(oldrdn, i, &type, &val) != -1) {
+ slapi_mods_add(smods, LDAP_MOD_DELETE, type, strlen(val), val);
+ }
+ }
+
+ /* Apply the mods to the entry. */
+ if ((err = slapi_entry_apply_mods(e, slapi_mods_get_ldapmods_byref(smods))) != LDAP_SUCCESS) {
+ /* A problem was encountered applying the mods. Bail. */
+ goto done;
+ }
+ }
+
+ /* We remove the parentid and entrydn since the backend will change these.
+ * We don't want to give the caller an inconsistent entry. */
+ slapi_entry_attr_delete(e, "parentid");
+ slapi_entry_attr_delete(e, "entrydn");
+
+ /* Build new DN. If newsuperior is set, just use "newrdn,newsuperior". If
+ * newsuperior is not set, need to add newrdn to old superior. */
+ if (newsuperior) {
+ newdn = slapi_ch_smprintf("%s,%s", newrdn, newsuperior);
+ } else {
+ char *oldsuperior = NULL;
+
+ oldsuperior = slapi_dn_parent(olddn);
+ newdn = slapi_ch_smprintf("%s,%s", newrdn, oldsuperior);
+
+ slapi_ch_free_string(&oldsuperior);
+ }
+
+ /* Set the new DN in the entry. This hands off the memory used by newdn to the entry. */
+ slapi_entry_set_dn(e, newdn);
+
+ /* Set the RDN in the entry. */
+ slapi_entry_set_rdn(e, newdn);
+
+ /* Add RDN values to entry. */
+ err = slapi_entry_add_rdn_values(e);
+
+done:
+ slapi_rdn_free(&oldrdn);
+ slapi_mods_free(&smods);
+
+ LDAPDebug( LDAP_DEBUG_TRACE, "<= slapi_entry_rename\n", 0, 0, 0 );
+ return err;
+}
+
/*
* Apply a set of modifications to an entry
*/
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 266fb9314..536809de0 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1979,6 +1979,24 @@ void slapi_entry_diff(Slapi_Mods *smods, Slapi_Entry *e1, Slapi_Entry *e2, int d
*/
int slapi_entry_apply_mods(Slapi_Entry *e, LDAPMod **mods);
+/**
+ * Renames a Slapi_Entry.
+ *
+ * This function will rename an existing \c Slapi_Entry, similar to what
+ * would happen with a \c MODRDN operation. New RDN values will be added
+ * as attributes to the entry and old RDN values will be deleted if requested.
+ *
+ * \param e Entry that you want to rename.
+ * \param newrdn The new RDN value to be used for renaming the entry. This must
+ * not be \c NULL.
+ * \param deleteoldrdn Will delete the old RDN values from the entry if set to \c 1.
+ * \param newsuperior The new superior DN to use when renaming the entry. Set this
+ * to \c NULL if you do not want to move the entry.
+ * \return \c LDAP_SUCCESS if the rename was successful, otherwise an LDAP error
+ * is returned.
+ */
+int slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const char *newsuperior);
+
/*------------------------
* Entry flags.
| 0 |
25e62b69c604ad89ed90349553b96c70a7e658d5
|
389ds/389-ds-base
|
Ticket 49448 - dynamic default pw scheme based on environment.
Bug Description: In some cases the hardcoded default pw scheme
is not available, IE FIPS mode doesn't support pbkdf2. In this
case we need to support returning an appropriate scheme based
on environment.
Fix Description: Add a new scheme name called "DEFAULT" with
a mechanic that pw_name2scheme will use this with environment
information to return an appropriate scheme.
https://pagure.io/389-ds-base/issue/49448
Author: wibrown
Review by: mreynolds, spichugi (Thanks!)
|
commit 25e62b69c604ad89ed90349553b96c70a7e658d5
Author: William Brown <[email protected]>
Date: Tue Nov 14 10:56:55 2017 +1000
Ticket 49448 - dynamic default pw scheme based on environment.
Bug Description: In some cases the hardcoded default pw scheme
is not available, IE FIPS mode doesn't support pbkdf2. In this
case we need to support returning an appropriate scheme based
on environment.
Fix Description: Add a new scheme name called "DEFAULT" with
a mechanic that pw_name2scheme will use this with environment
information to return an appropriate scheme.
https://pagure.io/389-ds-base/issue/49448
Author: wibrown
Review by: mreynolds, spichugi (Thanks!)
diff --git a/dirsrvtests/tests/suites/password/pwd_algo_test.py b/dirsrvtests/tests/suites/password/pwd_algo_test.py
index 84a4485a4..6b466df2c 100644
--- a/dirsrvtests/tests/suites/password/pwd_algo_test.py
+++ b/dirsrvtests/tests/suites/password/pwd_algo_test.py
@@ -12,17 +12,15 @@ from lib389.utils import *
from lib389.topologies import topology_st
from lib389._constants import DEFAULT_SUFFIX, HOST_STANDALONE, DN_DM, PORT_STANDALONE
-USER_DN = 'uid=user,ou=People,%s' % DEFAULT_SUFFIX
+from lib389.idm.user import UserAccounts
logging.getLogger(__name__).setLevel(logging.INFO)
log = logging.getLogger(__name__)
-
-def _test_bind(inst, password):
+def _test_bind(user, password):
result = True
- userconn = ldap.initialize("ldap://%s:%s" % (HOST_STANDALONE, PORT_STANDALONE))
try:
- userconn.simple_bind_s(USER_DN, password)
+ userconn = user.bind(password)
userconn.unbind_s()
except ldap.INVALID_CREDENTIALS:
result = False
@@ -32,64 +30,52 @@ def _test_bind(inst, password):
def _test_algo(inst, algo_name):
inst.config.set('passwordStorageScheme', algo_name)
- # Create the user with a password
- inst.add_s(Entry((
- USER_DN, {
- 'objectClass': 'top account simplesecurityobject'.split(),
- 'uid': 'user',
- 'userpassword': 'Secret123'
- })))
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+
+ user = users.create(properties={
+ 'uid': 'user',
+ 'cn' : 'user',
+ 'sn' : 'user',
+ 'uidNumber' : '1000',
+ 'gidNumber' : '2000',
+ 'homeDirectory' : '/home/user',
+ 'userpassword': 'Secret123'
+ })
# Make sure when we read the userPassword field, it is the correct ALGO
- pw_field = inst.search_s(USER_DN, ldap.SCOPE_BASE, '(objectClass=*)', ['userPassword'])[0]
+ pw_field = user.get_attr_val_utf8('userPassword')
- if algo_name != 'CLEAR':
- assert (algo_name[:5].lower() in pw_field.getValue('userPassword').lower())
+ if algo_name != 'CLEAR' and algo_name != 'DEFAULT':
+ assert (algo_name[:5].lower() in pw_field.lower())
# Now make sure a bind works
- assert (_test_bind(inst, 'Secret123'))
+ assert (_test_bind(user, 'Secret123'))
# Bind with a wrong shorter password, should fail
- assert (not _test_bind(inst, 'Wrong'))
+ assert (not _test_bind(user, 'Wrong'))
# Bind with a wrong longer password, should fail
- assert (not _test_bind(inst, 'This is even more wrong'))
+ assert (not _test_bind(user, 'This is even more wrong'))
# Bind with a wrong exact length password.
- assert (not _test_bind(inst, 'Alsowrong'))
+ assert (not _test_bind(user, 'Alsowrong'))
# Bind with a subset password, should fail
- assert (not _test_bind(inst, 'Secret'))
+ assert (not _test_bind(user, 'Secret'))
if not algo_name.startswith('CRYPT'):
# Bind with a subset password that is 1 char shorter, to detect off by 1 in clear
- assert (not _test_bind(inst, 'Secret12'))
+ assert (not _test_bind(user, 'Secret12'))
# Bind with a superset password, should fail
- assert (not _test_bind(inst, 'Secret123456'))
+ assert (not _test_bind(user, 'Secret123456'))
# Delete the user
- inst.delete_s(USER_DN)
+ user.delete()
# done!
-
-def test_pwd_algo_test(topology_st):
[email protected]("algo",
+ ('CLEAR', 'CRYPT', 'CRYPT-MD5', 'CRYPT-SHA256', 'CRYPT-SHA512',
+ 'MD5', 'SHA', 'SHA256', 'SHA384', 'SHA512', 'SMD5', 'SSHA',
+ 'SSHA256', 'SSHA384', 'SSHA512', 'PBKDF2_SHA256', 'DEFAULT',) )
+def test_pwd_algo_test(topology_st, algo):
"""Assert that all of our password algorithms correctly PASS and FAIL varying
password conditions.
"""
-
- for algo in ('CLEAR',
- 'CRYPT',
- 'CRYPT-MD5',
- 'CRYPT-SHA256',
- 'CRYPT-SHA512',
- 'MD5',
- 'SHA',
- 'SHA256',
- 'SHA384',
- 'SHA512',
- 'SMD5',
- 'SSHA',
- 'SSHA256',
- 'SSHA384',
- 'SSHA512',
- 'PBKDF2_SHA256',
- ):
- _test_algo(topology_st.standalone, algo)
-
- log.info('Test PASSED')
+ _test_algo(topology_st.standalone, algo)
+ log.info('Test %s PASSED' % algo)
if __name__ == '__main__':
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 1ba30002f..770607312 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -359,7 +359,11 @@ static struct config_get_and_set
{CONFIG_PW_STORAGESCHEME_ATTRIBUTE, config_set_pw_storagescheme,
NULL, 0, NULL,
CONFIG_STRING, (ConfigGetFunc)config_get_pw_storagescheme,
- DEFAULT_PASSWORD_SCHEME_NAME},
+ ""},
+ /*
+ * Set this to empty string to allow reset to work, but
+ * the value is actually derived in set_pw_storagescheme.
+ */
{CONFIG_PW_UNLOCK_ATTRIBUTE, config_set_pw_unlock,
NULL, 0,
(void **)&global_slapdFrontendConfig.pw_policy.pw_unlock,
@@ -555,7 +559,11 @@ static struct config_get_and_set
{CONFIG_ROOTPWSTORAGESCHEME_ATTRIBUTE, config_set_rootpwstoragescheme,
NULL, 0, NULL,
CONFIG_STRING, (ConfigGetFunc)config_get_rootpwstoragescheme,
- DEFAULT_PASSWORD_SCHEME_NAME},
+ ""},
+ /*
+ * Set this to empty string to allow reset to work, but
+ * the value is actually derived in set_rootpwstoragescheme.
+ */
{CONFIG_PW_HISTORY_ATTRIBUTE, config_set_pw_history,
NULL, 0,
(void **)&global_slapdFrontendConfig.pw_policy.pw_history,
@@ -2541,9 +2549,10 @@ config_set_pw_storagescheme(const char *attrname, char *value, char *errorbuf, i
return retVal;
} else if (new_scheme->pws_enc == NULL) {
/* For example: the NS-MTA-MD5 password scheme is for comparision only and for backward
- compatibility with an Old Messaging Server that was setting passwords in the
- directory already encrypted. The scheme cannot and don't encrypt password if
- they are in clear. We don't take it */
+ * compatibility with an Old Messaging Server that was setting passwords in the
+ * directory already encrypted. The scheme cannot and don't encrypt password if
+ * they are in clear. We don't take it
+ */
if (scheme_list) {
slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index e625962e8..73c49719e 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -206,23 +206,41 @@ slapi_encode_ext(Slapi_PBlock *pb, const Slapi_DN *sdn, char *value, char *alg)
struct pw_scheme *
pw_name2scheme(char *name)
{
- struct pw_scheme *pwsp;
- struct slapdplugin *p;
+ struct pw_scheme *pwsp = NULL;
+ struct slapdplugin *p = NULL;
- if ((p = plugin_get_pwd_storage_scheme(name, strlen(name), PLUGIN_LIST_PWD_STORAGE_SCHEME)) != NULL) {
- pwsp = (struct pw_scheme *)slapi_ch_malloc(sizeof(struct pw_scheme));
- if (pwsp != NULL) {
- typedef int (*CMPFP)(char *, char *);
- typedef char *(*ENCFP)(char *);
- pwsp->pws_name = slapi_ch_strdup(p->plg_pwdstorageschemename);
- pwsp->pws_cmp = (CMPFP)p->plg_pwdstorageschemecmp;
- pwsp->pws_enc = (ENCFP)p->plg_pwdstorageschemeenc;
- pwsp->pws_len = strlen(pwsp->pws_name);
- return (pwsp);
+ typedef int (*CMPFP)(char *, char *);
+ typedef char *(*ENCFP)(char *);
+
+ if (strcmp(DEFAULT_PASSWORD_SCHEME_NAME, name) == 0) {
+ /*
+ * If the name is DEFAULT, we need to get a scheme based on env and others.
+ */
+ if (slapd_pk11_isFIPS()) {
+ /* Are we in fips mode? This limits algos we have */
+ char *ssha = "SSHA512";
+ p = plugin_get_pwd_storage_scheme(ssha, strlen(ssha), PLUGIN_LIST_PWD_STORAGE_SCHEME);
+ } else {
+ /* if not, let's setup pbkdf2 */
+ char *pbkdf = "PBKDF2_SHA256";
+ p = plugin_get_pwd_storage_scheme(pbkdf, strlen(pbkdf), PLUGIN_LIST_PWD_STORAGE_SCHEME);
}
+ } else {
+ /*
+ * Else, get the scheme "as named".
+ */
+ p = plugin_get_pwd_storage_scheme(name, strlen(name), PLUGIN_LIST_PWD_STORAGE_SCHEME);
+ }
+
+ if (p != NULL) {
+ pwsp = (struct pw_scheme *)slapi_ch_malloc(sizeof(struct pw_scheme));
+ pwsp->pws_name = slapi_ch_strdup(p->plg_pwdstorageschemename);
+ pwsp->pws_cmp = (CMPFP)p->plg_pwdstorageschemecmp;
+ pwsp->pws_enc = (ENCFP)p->plg_pwdstorageschemeenc;
+ pwsp->pws_len = strlen(pwsp->pws_name);
}
- return (NULL);
+ return pwsp;
}
void
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 353f8b503..782631b7b 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2226,7 +2226,14 @@ typedef struct _slapdEntryPoints
#define MAX_ALLOWED_TIME_IN_SECS 2147483647
#define MAX_ALLOWED_TIME_IN_SECS_64 9223372036854775807
-#define DEFAULT_PASSWORD_SCHEME_NAME "PBKDF2_SHA256"
+/*
+ * DO NOT CHANGE THIS VALUE.
+ *
+ * if you want to update the default password hash you need to
+ * edit pw.c pw_name2scheme. This is because we use environment
+ * factors to dynamically determine this.
+ */
+#define DEFAULT_PASSWORD_SCHEME_NAME "DEFAULT"
typedef struct _slapdFrontendConfig
{
| 0 |
30aa91c7a7e3453c714d071c553615b6600f5e12
|
389ds/389-ds-base
|
Ticket 48362: With exhausted range, part of DNA shared configuration is deleted after server restart
Bug Description:
When a config entry (i.e. cn=posix-ids,cn=dna,cn=ipa,cn=etc,SUFFIX) defines an exhausted
range, the config is seen as invalid and the server is not added to dna_global_servers.
When the LDAP server entry dnaHostname=<host_fqdn>+dnaPortNum=389,cn=posix-ids,cn=dna,cn=ipa,cn=etc,SUFFIX
is recreated (startup or shared config entry update), the server being not in dna_global_servers the
entry is created with a minimal set of attributes.
So if for example bindmethod or connection protocol were set to 'dnaHostname=<host_fqdn>+dnaPortNum=389,
cn=posix-ids,cn=dna,cn=ipa,cn=etc,SUFFIX' before restart, they are cleared at startup
Note that if the config entry defines an exhausted range, the recreated shared config entry contains
dnaRemainingValues: 0
Fix Description:
The fix is that dna_get_shared_servers builds a list of all config entries even those with exhausted range.
When dna_get_shared_servers is used to create dna_global_servers, it will allow to recreate the shared config entry
with its previous settings.
When dna_get_shared_servers is used to retrieve all servers to contact to request a new range, the
server is skipped if it contains NULL remaining values.
https://fedorahosted.org/389/ticket/48362
Reviewed by: Mark Reynolds (Thank you Mark !)
Platforms tested: F17,F23
Flag Day: no
Doc impact: no
|
commit 30aa91c7a7e3453c714d071c553615b6600f5e12
Author: Thierry Bordaz <[email protected]>
Date: Mon Nov 30 16:47:12 2015 +0100
Ticket 48362: With exhausted range, part of DNA shared configuration is deleted after server restart
Bug Description:
When a config entry (i.e. cn=posix-ids,cn=dna,cn=ipa,cn=etc,SUFFIX) defines an exhausted
range, the config is seen as invalid and the server is not added to dna_global_servers.
When the LDAP server entry dnaHostname=<host_fqdn>+dnaPortNum=389,cn=posix-ids,cn=dna,cn=ipa,cn=etc,SUFFIX
is recreated (startup or shared config entry update), the server being not in dna_global_servers the
entry is created with a minimal set of attributes.
So if for example bindmethod or connection protocol were set to 'dnaHostname=<host_fqdn>+dnaPortNum=389,
cn=posix-ids,cn=dna,cn=ipa,cn=etc,SUFFIX' before restart, they are cleared at startup
Note that if the config entry defines an exhausted range, the recreated shared config entry contains
dnaRemainingValues: 0
Fix Description:
The fix is that dna_get_shared_servers builds a list of all config entries even those with exhausted range.
When dna_get_shared_servers is used to create dna_global_servers, it will allow to recreate the shared config entry
with its previous settings.
When dna_get_shared_servers is used to retrieve all servers to contact to request a new range, the
server is skipped if it contains NULL remaining values.
https://fedorahosted.org/389/ticket/48362
Reviewed by: Mark Reynolds (Thank you Mark !)
Platforms tested: F17,F23
Flag Day: no
Doc impact: no
diff --git a/dirsrvtests/tickets/ticket48362_test.py b/dirsrvtests/tickets/ticket48362_test.py
new file mode 100644
index 000000000..1b5651f7c
--- /dev/null
+++ b/dirsrvtests/tickets/ticket48362_test.py
@@ -0,0 +1,278 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+PEOPLE_OU='people'
+PEOPLE_DN = "ou=%s,%s" % (PEOPLE_OU, SUFFIX)
+MAX_ACCOUNTS=5
+
+BINDMETHOD_ATTR = 'dnaRemoteBindMethod'
+BINDMETHOD_VALUE = "SASL/GSSAPI"
+PROTOCOLE_ATTR = 'dnaRemoteConnProtocol'
+PROTOCOLE_VALUE = 'LDAP'
+
+class TopologyReplication(object):
+ def __init__(self, master1, master2):
+ master1.open()
+ self.master1 = master1
+ master2.open()
+ self.master2 = master2
+
+
+#@pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating master 1...
+ master1 = DirSrv(verbose=False)
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+ args_instance[SER_HOST] = HOST_MASTER_1
+ args_instance[SER_PORT] = PORT_MASTER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master1.allocate(args_master)
+ instance_master1 = master1.exists()
+ if instance_master1:
+ master1.delete()
+ master1.create()
+ master1.open()
+ master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
+
+ # Creating master 2...
+ master2 = DirSrv(verbose=False)
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+ args_instance[SER_HOST] = HOST_MASTER_2
+ args_instance[SER_PORT] = PORT_MASTER_2
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master2.allocate(args_master)
+ instance_master2 = master2.exists()
+ if instance_master2:
+ master2.delete()
+ master2.create()
+ master2.open()
+ master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
+
+ #
+ # Create all the agreements
+ #
+ # Creating agreement from master 1 to master 2
+ properties = {RA_NAME: r'meTo_$host:$port',
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m1_m2_agmt = master1.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
+ if not m1_m2_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("%s created" % m1_m2_agmt)
+
+ # Creating agreement from master 2 to master 1
+ properties = {RA_NAME: r'meTo_$host:$port',
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m2_m1_agmt = master2.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
+ if not m2_m1_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("%s created" % m2_m1_agmt)
+
+ # Allow the replicas to get situated with the new agreements...
+ time.sleep(5)
+
+ #
+ # Initialize all the agreements
+ #
+ master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
+ master1.waitForReplInit(m1_m2_agmt)
+
+ # Check replication is working...
+ if master1.testReplication(DEFAULT_SUFFIX, master2):
+ log.info('Replication is working.')
+ else:
+ log.fatal('Replication is not working.')
+ assert False
+
+ # Delete each instance in the end
+ def fin():
+ master1.delete()
+ master2.delete()
+ #request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ master1.clearTmpDir(__file__)
+
+ return TopologyReplication(master1, master2)
+
+
+def _dna_config(server, nextValue=500, maxValue=510):
+ log.info("Add dna plugin config entry...%s" % server)
+
+ cfg_base_dn = 'cn=dna config,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config'
+
+ try:
+ server.add_s(Entry((cfg_base_dn, {
+ 'objectclass': 'top dnaPluginConfig'.split(),
+ 'dnaType': 'description',
+ 'dnaMagicRegen': '-1',
+ 'dnaFilter': '(objectclass=posixAccount)',
+ 'dnaScope': 'ou=people,%s' % SUFFIX,
+ 'dnaNextValue': str(nextValue),
+ 'dnaMaxValue' : str(nextValue+maxValue),
+ 'dnaSharedCfgDN': 'ou=ranges,%s' % SUFFIX
+ })))
+
+ except ldap.LDAPError as e:
+ log.error('Failed to add DNA config entry: error ' + e.message['desc'])
+ assert False
+
+ log.info("Enable the DNA plugin...")
+ try:
+ server.plugins.enable(name=PLUGIN_DNA)
+ except e:
+ log.error("Failed to enable DNA Plugin: error " + e.message['desc'])
+ assert False
+
+ log.info("Restarting the server...")
+ server.stop(timeout=120)
+ time.sleep(1)
+ server.start(timeout=120)
+ time.sleep(3)
+
+
+SHARE_CFG_BASE = 'ou=ranges,' + SUFFIX
+
+def _wait_shared_cfg_servers(server, expected):
+ attempts = 0
+ ents = []
+ try:
+ ents = server.search_s(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(objectclass=*)")
+ except ldap.NO_SUCH_OBJECT:
+ pass
+ except lib389.NoSuchEntryError:
+ pass
+ while (len(ents) != expected):
+ assert attempts < 10
+ time.sleep(5)
+ try:
+ ents = server.search_s(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(objectclass=*)")
+ except ldap.NO_SUCH_OBJECT:
+ pass
+ except lib389.NoSuchEntryError:
+ pass
+
+def _shared_cfg_server_update(server, method=BINDMETHOD_VALUE, transport=PROTOCOLE_VALUE):
+ log.info('\n======================== Update dnaPortNum=%d ============================\n'% server.port)
+ try:
+ ent = server.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % server.port)
+ mod = [(ldap.MOD_REPLACE, BINDMETHOD_ATTR, method),
+ (ldap.MOD_REPLACE, PROTOCOLE_ATTR, transport)]
+ server.modify_s(ent.dn, mod)
+
+ log.info('\n======================== Update done\n')
+ ent = server.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % server.port)
+ except ldap.NO_SUCH_OBJECT:
+ log.fatal("Unknown host")
+ assert False
+
+
+def test_ticket48362(topology):
+ """Write your replication testcase here.
+
+ To access each DirSrv instance use: topology.master1, topology.master2,
+ ..., topology.hub1, ..., topology.consumer1, ...
+
+ Also, if you need any testcase initialization,
+ please, write additional fixture for that(include finalizer).
+ """
+
+ try:
+ topology.master1.add_s(Entry((PEOPLE_DN, {
+ 'objectclass': "top extensibleObject".split(),
+ 'ou': 'people'})))
+ except ldap.ALREADY_EXISTS:
+ pass
+
+ topology.master1.add_s(Entry((SHARE_CFG_BASE, {
+ 'objectclass': 'top organizationalunit'.split(),
+ 'ou': 'ranges'
+ })))
+ # master 1 will have a valid remaining range (i.e. 101)
+ # master 2 will not have a valid remaining range (i.e. 0) so dna servers list on master2
+ # will not contain master 2. So at restart, master 2 is recreated without the method/protocol attribute
+ _dna_config(topology.master1, nextValue=1000, maxValue=100)
+ _dna_config(topology.master2, nextValue=2000, maxValue=-1)
+
+ # check we have all the servers available
+ _wait_shared_cfg_servers(topology.master1, 2)
+ _wait_shared_cfg_servers(topology.master2, 2)
+
+ # now force the method/transport on the servers entry
+ _shared_cfg_server_update(topology.master1)
+ _shared_cfg_server_update(topology.master2)
+
+
+
+ log.info('\n======================== BEFORE RESTART ============================\n')
+ ent = topology.master1.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % topology.master1.port)
+ log.info('\n======================== BEFORE RESTART ============================\n')
+ assert(ent.hasAttr(BINDMETHOD_ATTR) and ent.getValue(BINDMETHOD_ATTR) == BINDMETHOD_VALUE)
+ assert(ent.hasAttr(PROTOCOLE_ATTR) and ent.getValue(PROTOCOLE_ATTR) == PROTOCOLE_VALUE)
+
+
+ ent = topology.master1.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % topology.master2.port)
+ log.info('\n======================== BEFORE RESTART ============================\n')
+ assert(ent.hasAttr(BINDMETHOD_ATTR) and ent.getValue(BINDMETHOD_ATTR) == BINDMETHOD_VALUE)
+ assert(ent.hasAttr(PROTOCOLE_ATTR) and ent.getValue(PROTOCOLE_ATTR) == PROTOCOLE_VALUE)
+ topology.master1.restart(10)
+ topology.master2.restart(10)
+
+ # to allow DNA plugin to recreate the local host entry
+ time.sleep(40)
+
+ log.info('\n=================== AFTER RESTART =================================\n')
+ ent = topology.master1.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % topology.master1.port)
+ log.info('\n=================== AFTER RESTART =================================\n')
+ assert(ent.hasAttr(BINDMETHOD_ATTR) and ent.getValue(BINDMETHOD_ATTR) == BINDMETHOD_VALUE)
+ assert(ent.hasAttr(PROTOCOLE_ATTR) and ent.getValue(PROTOCOLE_ATTR) == PROTOCOLE_VALUE)
+
+ ent = topology.master1.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % topology.master2.port)
+ log.info('\n=================== AFTER RESTART =================================\n')
+ assert(ent.hasAttr(BINDMETHOD_ATTR) and ent.getValue(BINDMETHOD_ATTR) == BINDMETHOD_VALUE)
+ assert(ent.hasAttr(PROTOCOLE_ATTR) and ent.getValue(PROTOCOLE_ATTR) == PROTOCOLE_VALUE)
+ log.info('Test complete')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ global installation1_prefix
+ installation1_prefix='/home/tbordaz/install_1.3.4'
+ topo = topology(True)
+ test_ticket48362(topo)
+# CURRENT_FILE = os.path.realpath(__file__)
+# pytest.main("-s %s" % CURRENT_FILE)
\ No newline at end of file
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 5bd1cd66e..b0ea2f407 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1630,7 +1630,10 @@ static int dna_fix_maxval(struct configEntry *config_entry,
* values, or we hit the end of the list. */
server = PR_LIST_HEAD(servers);
while (server != servers) {
- if (dna_request_range(config_entry, (struct dnaServer *)server,
+ if (((struct dnaServer *)server)->remaining == 0) {
+ /* This server has no values left, no need to ping it */
+ server = PR_NEXT_LINK(server);
+ } else if (dna_request_range(config_entry, (struct dnaServer *)server,
&lower, &upper) != 0) {
server = PR_NEXT_LINK(server);
} else {
@@ -1783,7 +1786,7 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers, int
DNA_REMOTE_CONN_PROT);
/* validate the entry */
- if (!server->host || (server->port == 0 && server->secureport == 0) || server->remaining == 0)
+ if (!server->host || (server->port == 0 && server->secureport == 0))
{
/* free and skip this one */
slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
| 0 |
6175d376258d2e5e819b82e88464127ccd9bcdfd
|
389ds/389-ds-base
|
Bump version to 1.4.0.10
|
commit 6175d376258d2e5e819b82e88464127ccd9bcdfd
Author: Mark Reynolds <[email protected]>
Date: Fri Jun 8 15:21:21 2018 -0400
Bump version to 1.4.0.10
diff --git a/VERSION.sh b/VERSION.sh
index 6cfd8636c..365018bc8 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
# PACKAGE_VERSION is constructed from these
VERSION_MAJOR=1
VERSION_MINOR=4
-VERSION_MAINT=0.9
+VERSION_MAINT=0.10
# NOTE: VERSION_PREREL is automatically set for builds made out of a git tree
VERSION_PREREL=
VERSION_DATE=$(date -u +%Y%m%d)
| 0 |
d7828f54c12f0c50e7165f8d7e849f8ffa3ff167
|
389ds/389-ds-base
|
Initialize smods in ldmb_back_modify
To avoid unnecessary ldap_mods_free for the early error_returns
which could be called before mods are set to smods.
|
commit d7828f54c12f0c50e7165f8d7e849f8ffa3ff167
Author: Noriko Hosoi <[email protected]>
Date: Mon Jun 1 11:09:53 2009 -0700
Initialize smods in ldmb_back_modify
To avoid unnecessary ldap_mods_free for the early error_returns
which could be called before mods are set to smods.
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index 1cbe92de1..e85443d70 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -188,7 +188,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
struct backentry *e, *ec = NULL;
Slapi_Entry *postentry = NULL;
LDAPMod **mods;
- Slapi_Mods smods;
+ Slapi_Mods smods = {0};
back_txn txn;
back_txnid parent_txn;
int retval = -1;
| 0 |
111b807923989ad003798e3d49f74d0f27af4be0
|
389ds/389-ds-base
|
Ticket #381 Recognize compressed log files
https://fedorahosted.org/389/ticket/381
Reviewed by: mreynolds, tbordaz (Thanks!)
Branch: master
Fix Description: Add support for gzip, bzip2, and xz compressed files, based
on the file extension (.gz, .bz2, .xz). Uses the perl module
IO::Uncompress and the IO::Uncompress::AnyUncompress class.
This also adds support for TAR archives and compressed TAR archives - any file
ending in .tar, .tar.bz2, .tar.gz, .tar.xz, .tgz, .tbz, and .txz. This
uses the perl module Archive::Tar to unpack and read the files.
Caveats:
1) Assumes all of the regular files in the TAR archive are access logs -
archive members which are not plain files are skipped - results are
undefined if non-access log plain files are processed
2) Assumes the TAR archive members are in the correct order - that is,
the access logs are in date sequential order, with the file "access" last
3) No support for .zip files
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes
|
commit 111b807923989ad003798e3d49f74d0f27af4be0
Author: Rich Megginson <[email protected]>
Date: Fri Oct 25 09:35:50 2013 -0600
Ticket #381 Recognize compressed log files
https://fedorahosted.org/389/ticket/381
Reviewed by: mreynolds, tbordaz (Thanks!)
Branch: master
Fix Description: Add support for gzip, bzip2, and xz compressed files, based
on the file extension (.gz, .bz2, .xz). Uses the perl module
IO::Uncompress and the IO::Uncompress::AnyUncompress class.
This also adds support for TAR archives and compressed TAR archives - any file
ending in .tar, .tar.bz2, .tar.gz, .tar.xz, .tgz, .tbz, and .txz. This
uses the perl module Archive::Tar to unpack and read the files.
Caveats:
1) Assumes all of the regular files in the TAR archive are access logs -
archive members which are not plain files are skipped - results are
undefined if non-access log plain files are processed
2) Assumes the TAR archive members are in the correct order - that is,
the access logs are in date sequential order, with the file "access" last
3) No support for .zip files
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index 38a84af76..7da46e0aa 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -51,6 +51,8 @@ use IO::File;
use Getopt::Long;
use DB_File;
use sigtrap qw(die normal-signals);
+use Archive::Tar;
+use IO::Uncompress::AnyUncompress qw($AnyUncompressError);
Getopt::Long::Configure ("bundling");
Getopt::Long::Configure ("permute");
@@ -367,9 +369,10 @@ my %monthname = (
my $linesProcessed;
my $lineBlockCount;
my $cursize = 0;
+my $LOGFH;
sub statusreport {
if ($lineBlockCount > $limit) {
- my $curpos = tell(LOG);
+ my $curpos = tell($LOGFH);
my $percent = $curpos/$cursize*100.0;
print sprintf "%10d Lines Processed %12d of %12d bytes (%.3f%%)\n",--$linesProcessed,$curpos,$cursize,$percent;
$lineBlockCount = 0;
@@ -400,50 +403,100 @@ $logCount = $file_count;
my $logline;
my $totalLineCount = 0;
+sub isTarArchive {
+ my $_ = shift;
+ return /\.tar$/ || /\.tar\.bz2$/ || /\.tar.gz$/ || /\.tar.xz$/ || /\.tgz$/ || /\.tbz$/ || /\.txz$/;
+}
+
+sub isCompressed {
+ my $_ = shift;
+ return /\.gz$/ || /\.bz2$/ || /\.xz$/;
+}
+
+$Archive::Tar::WARN = 0; # so new will shut up when reading a regular file
for (my $count=0; $count < $file_count; $count++){
+ my $logname = $files[$count];
# we moved access to the end of the list, so if its the first file skip it
- if($file_count > 1 && $count == 0 && $skipFirstFile == 1){
- next;
- }
- $linesProcessed = 0; $lineBlockCount = 0;
+ if($file_count > 1 && $count == 0 && $skipFirstFile == 1){
+ next;
+ }
+ $linesProcessed = 0; $lineBlockCount = 0;
$logCount--;
- my $logCountStr;
- if($logCount < 10 ){
- # add a zero for formatting purposes
- $logCountStr = "0" . $logCount;
- } else {
- $logCountStr = $logCount;
- }
- my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$atime,$mtime,$ctime,$blksize,$blocks);
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$cursize,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($files[$count]);
- print sprintf "[%s] %-30s\tsize (bytes): %12s\n",$logCountStr, $files[$count], $cursize;
-
- open(LOG,"$files[$count]") or do { openFailed($!, $files[$count]) };
- my $firstline = "yes";
- while(<LOG>){
- unless ($endFlag) {
- if ($firstline eq "yes"){
- if (/^\[/) {
- $logline = $_;
- $firstline = "no";
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$atime,$mtime,$ctime,$blksize,$blocks);
+ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$cursize,
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($logname);
+ print sprintf "[%03d] %-30s\tsize (bytes): %12s\n",$logCount, $logname, $cursize;
+
+ my $tar = 0;
+ my $tariter = 0;
+ my $tarfile = 0;
+ my $comp = 0;
+ if (isTarArchive($logname)) {
+ $tar = Archive::Tar->new();
+ $tariter = Archive::Tar->iter($logname);
+ if (!$tariter) {
+ print "$logname is not a valid tar archive, or compression is unrecognized: $!\n";
+ next;
+ }
+ } elsif (isCompressed($logname)) {
+ $comp = 1;
+ }
+
+ while (!$tariter or ($tarfile = $tariter->())) {
+ if ($tarfile) {
+ if ($tarfile->is_file) {
+ print sprintf "\t%-30s\tsize (bytes): %12s\n",$tarfile->name, $tarfile->size;
+ $cursize = $tarfile->size;
+ } else {
+ print "\tskipping non-file $tarfile->name\n";
+ next;
+ }
+ if (isCompressed($tarfile->name)) {
+ $LOGFH = new IO::Uncompress::AnyUncompress \$tarfile->name or
+ do { openFailed($AnyUncompressError, $logname); next };
+ # no way in general to know how big the uncompressed file is - so
+ # assume a factor of 10 inflation - only used for progress reporting
+ $cursize *= 10;
+ } else {
+ open(LOG,"<",\$tarfile->data) or do { openFailed($!, $tarfile->name) ; next };
+ $LOGFH = \*LOG;
+ }
+ } elsif ($comp) {
+ $LOGFH = new IO::Uncompress::AnyUncompress $logname or
+ do { openFailed($AnyUncompressError, $logname); next };
+ # no way in general to know how big the uncompressed file is - so
+ # assume a factor of 10 inflation - only used for progress reporting
+ $cursize *= 10;
+ } else {
+ open(LOG,$logname) or do { openFailed($!, $logname); next };
+ $LOGFH = \*LOG;
+ }
+ my $firstline = "yes";
+ while(<$LOGFH>){
+ unless ($endFlag) {
+ if ($firstline eq "yes"){
+ if (/^\[/) {
+ $logline = $_;
+ $firstline = "no";
+ }
+ $linesProcessed++;$lineBlockCount++;
+ } elsif (/^\[/ && $firstline eq "no"){
+ &parseLine();
+ $logline = $_;
+ } else {
+ $logline = $logline . $_;
+ $logline =~ s/\n//;
}
- $linesProcessed++;$lineBlockCount++;
- } elsif (/^\[/ && $firstline eq "no"){
- &parseLine();
- $logline = $_;
- } else {
- $logline = $logline . $_;
- $logline =~ s/\n//;
- }
- }
- }
- &parseLine();
- close (LOG);
- print_stats_block( $s_stats );
- print_stats_block( $m_stats );
- $totalLineCount = $totalLineCount + $linesProcessed;
+ }
+ }
+ &parseLine();
+ close ($LOGFH);
+ print_stats_block( $s_stats );
+ print_stats_block( $m_stats );
+ $totalLineCount = $totalLineCount + $linesProcessed;
statusreport();
+ last if (!$tariter);
+ }
}
print "\n\nTotal Log Lines Analysed: " . ($totalLineCount - 1) . "\n";
| 0 |
bc6dbf15c160ac7e6c553133b2b936a981cfb7b6
|
389ds/389-ds-base
|
Ticket 49402 - Adding a database entry with the same database name that was deleted hangs server at shutdown
Bug Description: At shutdown, after a backend was deleted, which also had a import
task run, the server hangs at shutdown. The issue is that the
import task destructor used the ldbm inst struct to see if it was
busy, but the inst was freed and the destructor was checking invalid
memory which caused a false positive on the "busy" check.
Fix Description: Do not check if the instance is busy to tell if it's okay to remove
the task, instead just check the task's state.
https://pagure.io/389-ds-base/issue/49402
Reviewed by: lkrispen(Thanks!)
|
commit bc6dbf15c160ac7e6c553133b2b936a981cfb7b6
Author: Mark Reynolds <[email protected]>
Date: Mon Oct 16 12:52:46 2017 -0400
Ticket 49402 - Adding a database entry with the same database name that was deleted hangs server at shutdown
Bug Description: At shutdown, after a backend was deleted, which also had a import
task run, the server hangs at shutdown. The issue is that the
import task destructor used the ldbm inst struct to see if it was
busy, but the inst was freed and the destructor was checking invalid
memory which caused a false positive on the "busy" check.
Fix Description: Do not check if the instance is busy to tell if it's okay to remove
the task, instead just check the task's state.
https://pagure.io/389-ds-base/issue/49402
Reviewed by: lkrispen(Thanks!)
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index e8f4a5615..42e2696d3 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -244,7 +244,7 @@ import_task_destroy(Slapi_Task *task)
return;
}
- while (is_instance_busy(job->inst)) {
+ while (task->task_state == SLAPI_TASK_RUNNING) {
/* wait for the job to finish before freeing it */
DS_Sleep(PR_SecondsToInterval(1));
}
| 0 |
4b465355402071e9f234cf9a371a83271c499eb0
|
389ds/389-ds-base
|
fix coverity reports
|
commit 4b465355402071e9f234cf9a371a83271c499eb0
Author: Ludwig Krispenz <[email protected]>
Date: Thu Jun 18 17:26:09 2015 +0200
fix coverity reports
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index b97f073f9..bec899215 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -61,6 +61,7 @@ static PLHashNumber acl_ht_hash( const void *key);
static PRIntn acl_ht_display_entry(PLHashEntry *he, PRIntn i, void *arg);
#endif
+int acl_match_substr_prefix( char *macro_prefix, const char *ndn, int *exact_match);
/***************************************************************************/
/* UTILITY FUNCTIONS */
/***************************************************************************/
@@ -991,9 +992,9 @@ acl_match_substr_prefix( char *macro_prefix, const char *ndn, int *exact_match)
tmp_str = slapi_ch_strdup(macro_prefix);
any = acl_strstr(tmp_str, "*");
tmp_str[any] = '\0';
- initial = acl_strstr(ndn, tmp_str);
+ initial = acl_strstr((char *)ndn, tmp_str);
if (initial >= 0) {
- final = acl_strstr(&ndn[initial+strlen(tmp_str)],&tmp_str[any+1]);
+ final = acl_strstr((char *)&ndn[initial+strlen(tmp_str)],&tmp_str[any+1]);
if (final > 0) ret_code = initial + strlen(tmp_str) +final + strlen(&tmp_str[any+1]);
}
slapi_ch_free_string(&tmp_str);
| 0 |
d97835969db3e957032c52ac317699354299c07c
|
389ds/389-ds-base
|
Ticket 517 - crash in DNA if no dnaMagicRegen is specified
Bug Description: There are several places where we deference config_entry->generate
Fix Description: Properly check for NULL, and allow the update of dnaType.
https://fedorahosted.org/389/ticket/517
Reviewed by: richm(Thanks Rich)
|
commit d97835969db3e957032c52ac317699354299c07c
Author: Mark Reynolds <[email protected]>
Date: Wed Nov 14 15:18:57 2012 -0500
Ticket 517 - crash in DNA if no dnaMagicRegen is specified
Bug Description: There are several places where we deference config_entry->generate
Fix Description: Properly check for NULL, and allow the update of dnaType.
https://fedorahosted.org/389/ticket/517
Reviewed by: richm(Thanks Rich)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 2b5696795..66d4a0510 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -804,10 +804,9 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
value = slapi_entry_attr_get_charptr(e, DNA_GENERATE);
if (value) {
entry->generate = value;
- }
-
- slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
+ slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
"----------> %s [%s]\n", DNA_GENERATE, entry->generate);
+ }
value = slapi_entry_attr_get_charptr(e, DNA_FILTER);
if (value) {
@@ -2809,8 +2808,7 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
/* does the entry match the filter? */
if (config_entry->slapi_filter) {
- ret = slapi_vattr_filter_test(pb, e, config_entry->slapi_filter,
- 0);
+ ret = slapi_vattr_filter_test(pb, e, config_entry->slapi_filter, 0);
if (LDAP_SUCCESS != ret) {
goto next;
}
@@ -2820,28 +2818,23 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
/* For a multi-type range, we only generate a value
* for types where the magic value is set. We do not
* generate a value for missing types. */
- for (i = 0; config_entry->types && config_entry->types[i];
- i++) {
- value = slapi_entry_attr_get_charptr(e,
- config_entry->types[i]);
-
- if (value &&
- !slapi_UTF8CASECMP(config_entry->generate, value)) {
- slapi_ch_array_add(&types_to_generate,
- slapi_ch_strdup(config_entry->types[i]));
+ for (i = 0; config_entry->types && config_entry->types[i]; i++) {
+ value = slapi_entry_attr_get_charptr(e, config_entry->types[i]);
+ if (value){
+ if(config_entry->generate == NULL || !slapi_UTF8CASECMP(config_entry->generate, value)){
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(config_entry->types[i]));
+ }
+ slapi_ch_free_string(&value);
}
- slapi_ch_free_string(&value);
}
} else {
/* For a single type range, we generate the value if
* the magic value is set or if the type is missing. */
value = slapi_entry_attr_get_charptr(e, config_entry->types[0]);
- if ((value &&
- !slapi_UTF8CASECMP(config_entry->generate, value)) ||
- (0 == value)) {
- slapi_ch_array_add(&types_to_generate,
- slapi_ch_strdup(config_entry->types[0]));
+ if((config_entry->generate == NULL) || (0 == value) ||
+ (value && !slapi_UTF8CASECMP(config_entry->generate, value))){
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(config_entry->types[0]));
}
slapi_ch_free_string(&value);
}
@@ -3062,13 +3055,15 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
/* If we have a value, see if it's the magic value. */
if (bv) {
- len = strlen(config_entry->generate);
- if (len == bv->bv_len) {
- if (!slapi_UTF8NCASECMP(bv->bv_val,
- config_entry->generate,
- len)) {
- slapi_ch_array_add(&types_to_generate,
- slapi_ch_strdup(type));
+ if(config_entry->generate == NULL){
+ /* we don't have a magic number set, so apply the update */
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(type));
+ } else {
+ len = strlen(config_entry->generate);
+ if (len == bv->bv_len) {
+ if (!slapi_UTF8NCASECMP(bv->bv_val, config_entry->generate,len)){
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(type));
+ }
}
}
} else if (!dna_is_multitype_range(config_entry)) {
| 0 |
52e15071bc98cc66edc47838d986c9803e1479bf
|
389ds/389-ds-base
|
Misc Coverity Fixes
Reviewed by: richm(Thanks Rich!)
|
commit 52e15071bc98cc66edc47838d986c9803e1479bf
Author: Mark Reynolds <[email protected]>
Date: Fri Aug 3 15:02:46 2012 -0400
Misc Coverity Fixes
Reviewed by: richm(Thanks Rich!)
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index a69dd16f2..2ca4d2f62 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -1113,17 +1113,29 @@ memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config,
Slapi_Entry *e = 0;
memberofstringll *ll = 0;
char *op_str = 0;
- const char *op_to = slapi_sdn_get_ndn(op_to_sdn);
- const char *op_this = slapi_sdn_get_ndn(op_this_sdn);
- Slapi_Value *to_dn_val = slapi_value_new_string(op_to);
- Slapi_Value *this_dn_val = slapi_value_new_string(op_this);
+ const char *op_to;
+ const char *op_this;
+ Slapi_Value *to_dn_val;
+ Slapi_Value *this_dn_val;
+
+ op_to = slapi_sdn_get_ndn(op_to_sdn);
+ op_this = slapi_sdn_get_ndn(op_this_sdn);
+ to_dn_val = slapi_value_new_string(op_to);
+ this_dn_val = slapi_value_new_string(op_this);
+
+ if(this_dn_val == NULL || to_dn_val == NULL){
+ slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_modop_one_replace_r: failed to get DN values (NULL)\n");
+ goto bail;
+ }
+
/* op_this and op_to are both case-normalized */
slapi_value_set_flags(this_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS);
slapi_value_set_flags(to_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS);
if (config == NULL) {
slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
- "memberof_modop_one_replace_r: NULL config parameter");
+ "memberof_modop_one_replace_r: NULL config parameter\n");
goto bail;
}
@@ -1184,8 +1196,7 @@ memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config,
int res = 0;
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
- "memberof_modop_one_replace_r: error searching for members: "
- "%d", res);
+ "memberof_modop_one_replace_r: error searching for members: %d\n", res);
} else {
slapi_pblock_get(search_pb, SLAPI_NENTRIES, &n_entries);
if(n_entries > 0)
@@ -1885,8 +1896,10 @@ int memberof_test_membership_callback(Slapi_Entry *e, void *callback_data)
entry_sdn = slapi_entry_get_sdn(e);
entry_dn = slapi_value_new_string(slapi_entry_get_ndn(e));
+ if(entry_dn == NULL){
+ goto bail;
+ }
slapi_value_set_flags(entry_dn, SLAPI_ATTR_FLAG_NORMALIZED_CIS);
-
if(0 == entry_dn)
{
goto bail;
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index c3f3593e7..fc399e764 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -258,7 +258,6 @@ filter_stuff_func(void *arg, const char *val, PRUint32 slen)
char *buf = (char *)val;
int extra_space;
int filter_len = slen;
- int free_buf = 0;
/* look at val - if val is one of our special keywords, and make a note of it for the next pass */
if (strcmp(val, ESC_NEXT_VAL) == 0){
@@ -342,7 +341,6 @@ filter_stuff_func(void *arg, const char *val, PRUint32 slen)
}
#else
buf = slapi_ch_calloc(sizeof(char), filter_len*3 + 1);
- free_buf = 1;
if(do_escape_string(val, filter_len, buf, special_filter) == NULL){
LDAPDebug(LDAP_DEBUG_TRACE, "slapi_filter_sprintf: failed to escape filter value(%s)\n",val,0,0);
ctx->next_arg_needs_esc_norm = 0;
@@ -360,7 +358,7 @@ filter_stuff_func(void *arg, const char *val, PRUint32 slen)
if (ctx->buf_size + filter_len >= ctx->buf_len){
/* increase buffer for this filter */
extra_space = (ctx->buf_len + filter_len + BUF_INCR);
- slapi_ch_realloc(ctx->buf, sizeof(char) * extra_space);
+ ctx->buf = slapi_ch_realloc(ctx->buf, sizeof(char) * extra_space);
ctx->buf_len = extra_space;
}
@@ -373,9 +371,7 @@ filter_stuff_func(void *arg, const char *val, PRUint32 slen)
ctx->attr_found = 0;
ctx->attr_position = 0;
memset(ctx->attr, '\0', ATTRSIZE);
- if(free_buf){
- slapi_ch_free_string(&buf);
- }
+ slapi_ch_free_string(&buf);
return filter_len;
} else { /* process arg as is */
@@ -446,7 +442,7 @@ slapi_filter_sprintf(const char *fmt, ...)
char*
slapi_escape_filter_value(char* filter_str, int len)
{
- struct berval *escaped_filter = NULL;
+ struct berval escaped_filter;
struct berval raw_filter;
int filter_len;
@@ -469,11 +465,11 @@ slapi_escape_filter_value(char* filter_str, int len)
*/
raw_filter.bv_val = filter_str;
raw_filter.bv_len = filter_len;
- if(ldap_bv2escaped_filter_value(&raw_filter, escaped_filter) != 0){
+ if(ldap_bv2escaped_filter_value(&raw_filter, &escaped_filter) != 0){
LDAPDebug(LDAP_DEBUG_TRACE, "slapi_escape_filter_value: failed to escape filter value(%s)\n",filter_str,0,0);
return NULL;
} else {
- return slapi_ch_strdup(escaped_filter->bv_val);
+ return escaped_filter.bv_val;
}
#else
char *buf = slapi_ch_calloc(sizeof(char), filter_len*3+1);
| 0 |
ea39a99ebd0f33628c3269f164ddf4acff98e61d
|
389ds/389-ds-base
|
Issue 51233 - ds-replcheck crashes in offline mode
Bug Description: When processing all the DN's found in the Master LDIF
it is possible that the LDIF is not in the expected
order and ldifsearch fails (crashing the tool).
Fix Description: If ldifsearch does not find an entry, start from the
beginning of the LDIF and try again.
relates: https://pagure.io/389-ds-base/issue/51233
Reviewed by: spichugi(Thanks!)
|
commit ea39a99ebd0f33628c3269f164ddf4acff98e61d
Author: Mark Reynolds <[email protected]>
Date: Thu Aug 6 14:50:19 2020 -0400
Issue 51233 - ds-replcheck crashes in offline mode
Bug Description: When processing all the DN's found in the Master LDIF
it is possible that the LDIF is not in the expected
order and ldifsearch fails (crashing the tool).
Fix Description: If ldifsearch does not find an entry, start from the
beginning of the LDIF and try again.
relates: https://pagure.io/389-ds-base/issue/51233
Reviewed by: spichugi(Thanks!)
diff --git a/ldap/admin/src/scripts/ds-replcheck b/ldap/admin/src/scripts/ds-replcheck
index 5bb7dfce3..1c133f4dd 100755
--- a/ldap/admin/src/scripts/ds-replcheck
+++ b/ldap/admin/src/scripts/ds-replcheck
@@ -725,6 +725,10 @@ def do_offline_report(opts, output_file=None):
missing = False
for dn in master_dns:
mresult = ldif_search(MLDIF, dn)
+ if mresult['entry'] is None and mresult['conflict'] is None and not mresult['tombstone']:
+ # Try from the beginning
+ MLDIF.seek(0)
+ mresult = ldif_search(MLDIF, dn)
rresult = ldif_search(RLDIF, dn)
if dn in replica_dns:
| 0 |
9a7c2da4a9117d0f03dbcfe2895961c80b99f4f6
|
389ds/389-ds-base
|
Bug 750625 - Fix Coverity (12196) Dereference before null check
https://bugzilla.redhat.com/show_bug.cgi?id=750625
slapd/back-ldbm/ldbm_entryrdn.c (entryrdn_lookup_dn)
Bug Description: Dreferencing "db" before a null check.
Fix Description: Adding a check if the variable "db" returned
from _entryrdn_open_index is NULL or not. If NULL, it returns
or goto bail there.
|
commit 9a7c2da4a9117d0f03dbcfe2895961c80b99f4f6
Author: Noriko Hosoi <[email protected]>
Date: Thu Nov 3 11:32:52 2011 -0700
Bug 750625 - Fix Coverity (12196) Dereference before null check
https://bugzilla.redhat.com/show_bug.cgi?id=750625
slapd/back-ldbm/ldbm_entryrdn.c (entryrdn_lookup_dn)
Bug Description: Dreferencing "db" before a null check.
Fix Description: Adding a check if the variable "db" returned
from _entryrdn_open_index is NULL or not. If NULL, it returns
or goto bail there.
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index 1573f1f49..2b9115ad9 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -205,7 +205,7 @@ entryrdn_index_entry(backend *be,
int flags, /* BE_INDEX_ADD or BE_INDEX_DEL */
back_txn *txn)
{
- int rc = 0;
+ int rc = -1;
struct attrinfo *ai = NULL;
DB *db = NULL;
DBC *cursor = NULL;
@@ -219,12 +219,11 @@ entryrdn_index_entry(backend *be,
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
"entryrdn_index_entry: Param error: Empty %s\n",
NULL==be?"backend":NULL==e?"entry":"unknown");
- rc = -1;
- goto bail;
+ return rc;
}
/* Open the entryrdn index */
rc = _entryrdn_open_index(be, &ai, &db);
- if (rc) {
+ if (rc || (NULL == db)) {
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
"entryrdn_index_entry: Opening the index failed: "
"%s(%d)\n",
@@ -347,11 +346,12 @@ entryrdn_index_read(backend *be,
/* Open the entryrdn index */
rc = _entryrdn_open_index(be, &ai, &db);
- if (rc) {
+ if (rc || (NULL == db)) {
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
"entryrdn_index_read: Opening the index failed: "
"%s(%d)\n",
rc<0?dblayer_strerror(rc):"Invalid parameter", rc);
+ db = NULL;
goto bail;
}
@@ -508,11 +508,12 @@ entryrdn_rename_subtree(backend *be,
/* Open the entryrdn index */
rc = _entryrdn_open_index(be, &ai, &db);
- if (rc) {
+ if (rc || (NULL == db)) {
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
"entryrdn_rename_subtree: Opening the index failed: "
"%s(%d)\n",
rc<0?dblayer_strerror(rc):"Invalid parameter", rc);
+ db = NULL;
return rc;
}
@@ -915,11 +916,12 @@ entryrdn_get_subordinates(backend *be,
/* Open the entryrdn index */
rc = _entryrdn_open_index(be, &ai, &db);
- if (rc) {
+ if (rc || (NULL == db)) {
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
"entryrdn_get_subordinates: Opening the index failed: "
"%s(%d)\n",
rc<0?dblayer_strerror(rc):"Invalid parameter", rc);
+ db = NULL;
goto bail;
}
@@ -1003,7 +1005,7 @@ entryrdn_lookup_dn(backend *be,
char **dn,
back_txn *txn)
{
- int rc = 0;
+ int rc = -1;
struct attrinfo *ai = NULL;
DB *db = NULL;
DBC *cursor = NULL;
@@ -1032,7 +1034,7 @@ entryrdn_lookup_dn(backend *be,
*dn = NULL;
/* Open the entryrdn index */
rc = _entryrdn_open_index(be, &ai, &db);
- if (rc) {
+ if (rc || (NULL == db)) {
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
"entryrdn_lookup_dn: Opening the index failed: "
"%s(%d)\n",
@@ -1146,9 +1148,8 @@ bail:
dblayer_strerror(myrc), myrc);
}
}
- if (db) {
- dblayer_release_index_file(be, ai, db);
- }
+ /* it is guaranteed that db is not NULL. */
+ dblayer_release_index_file(be, ai, db);
slapi_rdn_free(&srdn);
slapi_ch_free_string(&nrdn);
slapi_ch_free_string(&keybuf);
@@ -1173,7 +1174,7 @@ entryrdn_get_parent(backend *be,
ID *pid,
back_txn *txn)
{
- int rc = 0;
+ int rc = -1;
struct attrinfo *ai = NULL;
DB *db = NULL;
DBC *cursor = NULL;
@@ -1197,14 +1198,14 @@ entryrdn_get_parent(backend *be,
NULL==be?"backend":NULL==rdn?"rdn":0==id?"id":
NULL==rdn?"rdn container":
NULL==pid?"pid":"unknown");
- goto bail;
+ return rc;
}
*prdn = NULL;
*pid = 0;
/* Open the entryrdn index */
rc = _entryrdn_open_index(be, &ai, &db);
- if (rc) {
+ if (rc || (NULL == db)) {
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
"entryrdn_get_parent: Opening the index failed: "
"%s(%d)\n",
@@ -1294,9 +1295,8 @@ bail:
dblayer_strerror(rc), rc);
}
}
- if (db) {
- dblayer_release_index_file(be, ai, db);
- }
+ /* it is guaranteed that db is not NULL. */
+ dblayer_release_index_file(be, ai, db);
slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"<-- entryrdn_get_parent\n");
return rc;
@@ -1414,6 +1414,8 @@ _entryrdn_open_index(backend *be, struct attrinfo **ai, DB **dbp)
NULL==dbp?"db container":"unknown");
goto bail;
}
+ *ai = NULL;
+ *dbp = NULL;
/* Open the entryrdn index */
ainfo_get(be, LDBM_ENTRYRDN_STR, ai);
if (NULL == *ai) {
| 0 |
950c0c6bf7515e02f88543e8f477ec717725849f
|
389ds/389-ds-base
|
Trac Ticket #409 - Report during startup if nsslapd-cachememsize is too small
https://fedorahosted.org/389/ticket/409
Fix description: adding a code to compare the entry cache size with
the main db file (id2entry.db) size. If the entry cache size is
less than the db file size, it logs the warning in the error log.
|
commit 950c0c6bf7515e02f88543e8f477ec717725849f
Author: Noriko Hosoi <[email protected]>
Date: Wed Jul 25 10:19:14 2012 -0700
Trac Ticket #409 - Report during startup if nsslapd-cachememsize is too small
https://fedorahosted.org/389/ticket/409
Fix description: adding a code to compare the entry cache size with
the main db file (id2entry.db) size. If the entry cache size is
less than the db file size, it logs the warning in the error log.
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index eb3270965..5452d6b8c 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1892,6 +1892,30 @@ check_and_set_import_cache(struct ldbminfo *li)
return 0;
}
+size_t
+dblayer_get_id2entry_size(ldbm_instance *inst)
+{
+ struct ldbminfo *li = NULL;
+ char *id2entry_file = NULL;
+ PRFileInfo info;
+ int rc;
+ char inst_dir[MAXPATHLEN], *inst_dirp;
+
+ if (NULL == inst) {
+ return 0;
+ }
+ li = inst->inst_li;
+ inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
+ id2entry_file = slapi_ch_smprintf("%s/%s", inst_dirp,
+ ID2ENTRY LDBM_FILENAME_SUFFIX);
+ rc = PR_GetFileInfo(id2entry_file, &info);
+ slapi_ch_free_string(&id2entry_file);
+ if (rc) {
+ return 0;
+ }
+ return info.size;
+}
+
/* mode is one of
* DBLAYER_NORMAL_MODE,
* DBLAYER_INDEX_MODE,
@@ -2254,7 +2278,7 @@ int dblayer_instance_start(backend *be, int mode)
dbp->set_cache_priority(dbp, DB_PRIORITY_LOW);
#endif
out:
- slapi_ch_free((void**)&id2entry_file);
+ slapi_ch_free_string(&id2entry_file);
}
if (0 == return_value) {
@@ -2511,16 +2535,17 @@ err:
(*ppEnv)->close(*ppEnv, 0);
*ppEnv = NULL;
}
- if (id2entry_file) {
- slapi_ch_free_string(&id2entry_file);
- }
if (priv->dblayer_home_directory) {
ldbm_delete_dirs(priv->dblayer_home_directory);
}
done:
- if ((0 == rval) && path) { /* only when successfull */
- *path = slapi_ch_smprintf("%s/%s",
- inst->inst_parent_dir_name, id2entry_file);
+ if (path) {
+ if (0 == rval) { /* return the path only when successfull */
+ *path = slapi_ch_smprintf("%s/%s", inst->inst_parent_dir_name,
+ id2entry_file);
+ } else {
+ *path = NULL;
+ }
}
slapi_ch_free_string(&id2entry_file);
if (priv) {
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 03e0b112a..be4120ab9 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -174,6 +174,7 @@ int dblayer_db_uses_mpool(DB_ENV *db_env);
int dblayer_db_uses_logging(DB_ENV *db_env);
int dblayer_bt_compare(DB *db, const DBT *dbt1, const DBT *dbt2);
int dblayer_remove_env(struct ldbminfo *li);
+size_t dblayer_get_id2entry_size(ldbm_instance *inst);
int ldbm_back_get_info(Slapi_Backend *be, int cmd, void **info);
int ldbm_back_set_info(Slapi_Backend *be, int cmd, void *info);
diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c
index 61146fe20..0f42bed32 100644
--- a/ldap/servers/slapd/back-ldbm/start.c
+++ b/ldap/servers/slapd/back-ldbm/start.c
@@ -135,9 +135,7 @@ ldbm_back_start( Slapi_PBlock *pb )
(li->li_cache_autosize + li->li_import_cache_autosize > 100))) {
LDAPDebug( LDAP_DEBUG_ANY, "cache autosizing: bad settings, "
"value or sum of values can not larger than 100.\n", 0, 0, 0 );
- } else
- /* if cache autosize was selected, select the cache sizes now */
- if ((li->li_cache_autosize > 0) || (li->li_import_cache_autosize > 0)) {
+ } else {
size_t pagesize, pages, procpages, availpages;
dblayer_sys_pages(&pagesize, &pages, &procpages, &availpages);
@@ -147,6 +145,38 @@ ldbm_back_start( Slapi_PBlock *pb )
int zone_pages, db_pages, entry_pages, import_pages;
Object *inst_obj;
ldbm_instance *inst;
+ size_t cache_size;
+ size_t db_size;
+ size_t total_cache_size = 0;
+ size_t memsize = pages * pagesize;
+ size_t extra = 0; /* e.g., dncache size */
+
+ for (inst_obj = objset_first_obj(li->li_instance_set); inst_obj;
+ inst_obj = objset_next_obj(li->li_instance_set, inst_obj)) {
+ inst = (ldbm_instance *)object_get_data(inst_obj);
+ cache_size = cache_get_max_size(&(inst->inst_cache));
+ db_size = dblayer_get_id2entry_size(inst);
+ if (cache_size < db_size) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "WARNING: %s: entry cache size %luB is "
+ "less than db size %luB; "
+ "We recommend to increase the entry cache size "
+ "nsslapd-cachememsize.\n",
+ inst->inst_name, cache_size, db_size);
+ } else {
+ LDAPDebug(LDAP_DEBUG_BACKLDBM,
+ "%s: entry cache size: %luB; db size: %luB\n",
+ inst->inst_name, cache_size, db_size);
+ }
+ total_cache_size += cache_size;
+ /* estimated overhead: dncache size * 2 */
+ extra += cache_get_max_size(&(inst->inst_dncache)) * 2;
+ }
+ LDAPDebug(LDAP_DEBUG_BACKLDBM,
+ "Total entry cache size: %luB; "
+ "dbcache size: %luB; "
+ "available memory size: %luB\n",
+ total_cache_size, li->li_dbcachesize, memsize - extra);
/* autosizing dbCache and entryCache */
if (li->li_cache_autosize > 0) {
zone_pages = (li->li_cache_autosize * pages) / 100;
| 0 |
fb390315e3ea49a3bae6fb508333347f8c3a6807
|
389ds/389-ds-base
|
Ticket #47819 - RFE - improve tombstone purging performance
Description: Initialize replica->precise_purging with slapi_counter_new().
https://fedorahosted.org/389/ticket/47819
Reviewed by [email protected] (Thanks, Mark!!)
|
commit fb390315e3ea49a3bae6fb508333347f8c3a6807
Author: Noriko Hosoi <[email protected]>
Date: Tue May 17 12:58:09 2016 -0700
Ticket #47819 - RFE - improve tombstone purging performance
Description: Initialize replica->precise_purging with slapi_counter_new().
https://fedorahosted.org/389/ticket/47819
Reviewed by [email protected] (Thanks, Mark!!)
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 6562b3bf0..f935b9c83 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -204,6 +204,7 @@ replica_new_from_entry (Slapi_Entry *e, char *errortext, PRBool is_add_operation
r->protocol_timeout = slapi_counter_new();
r->backoff_min = slapi_counter_new();
r->backoff_max = slapi_counter_new();
+ r->precise_purging = slapi_counter_new();
/* read parameters from the replica config entry */
rc = _replica_init_from_config (r, e, errortext);
@@ -411,6 +412,7 @@ replica_destroy(void **arg)
slapi_counter_destroy(&r->protocol_timeout);
slapi_counter_destroy(&r->backoff_min);
slapi_counter_destroy(&r->backoff_max);
+ slapi_counter_destroy(&r->precise_purging);
slapi_ch_free((void **)arg);
}
| 0 |
ffbbae3572d96ece6dced70620d213b610f45709
|
389ds/389-ds-base
|
Bump version to 1.4.0.6
|
commit ffbbae3572d96ece6dced70620d213b610f45709
Author: Mark Reynolds <[email protected]>
Date: Tue Mar 6 14:10:01 2018 -0500
Bump version to 1.4.0.6
diff --git a/VERSION.sh b/VERSION.sh
index 375860a51..f53adf96c 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
# PACKAGE_VERSION is constructed from these
VERSION_MAJOR=1
VERSION_MINOR=4
-VERSION_MAINT=0.5
+VERSION_MAINT=0.6
# NOTE: VERSION_PREREL is automatically set for builds made out of a git tree
VERSION_PREREL=
VERSION_DATE=$(date -u +%Y%m%d)
| 0 |
b1c658eb1e1e43d2b278badc3e0c7aeea4348182
|
389ds/389-ds-base
|
Resolves: #470084
Summary: Problems migrating from libdb-4.4 to libdb-4.7
Description: Removed the code to remove transaction logs for the db version
upgrade.
|
commit b1c658eb1e1e43d2b278badc3e0c7aeea4348182
Author: Noriko Hosoi <[email protected]>
Date: Thu Nov 20 17:30:58 2008 +0000
Resolves: #470084
Summary: Problems migrating from libdb-4.4 to libdb-4.7
Description: Removed the code to remove transaction logs for the db version
upgrade.
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 5a1075e47..0c9d9e39a 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1620,15 +1620,6 @@ int dblayer_start(struct ldbminfo *li, int dbmode)
dblayer_strerror(return_value), 0);
return return_value;
}
- /* remove transaction logs */
- return_value = dblayer_delete_transaction_logs(log_dir);
- if (return_value)
- {
- LDAPDebug(LDAP_DEBUG_ANY,
- "dblayer_start: failed to remove old transaction logs (%d)\n",
- return_value, 0, 0);
- return return_value;
- }
dbmode = DBLAYER_NORMAL_MODE;
if ((return_value = dblayer_make_env(&pEnv, li)) != 0)
| 0 |
e0492360eefa11242509cd78da28f2be015bbdc6
|
389ds/389-ds-base
|
Ticket 50632 - Add ensure attr state so that diffs are easier from 389-ds-portal
Bug Description: We did not have a stateful attribute update system.
Fix Description: Add a stateful attribute update that asserts attributes
and values are in a known state, and updates in a single modification if not.
https://pagure.io/389-ds-base/pull-request/50632
Author: William Brown <[email protected]>
Review by: mreynolds (Thanks!)
|
commit e0492360eefa11242509cd78da28f2be015bbdc6
Author: William Brown <[email protected]>
Date: Tue Oct 1 14:40:18 2019 +1000
Ticket 50632 - Add ensure attr state so that diffs are easier from 389-ds-portal
Bug Description: We did not have a stateful attribute update system.
Fix Description: Add a stateful attribute update that asserts attributes
and values are in a known state, and updates in a single modification if not.
https://pagure.io/389-ds-base/pull-request/50632
Author: William Brown <[email protected]>
Review by: mreynolds (Thanks!)
diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py
index 010d964b1..578dda026 100644
--- a/src/lib389/lib389/_mapped_object.py
+++ b/src/lib389/lib389/_mapped_object.py
@@ -196,6 +196,8 @@ class DSLdapObject(DSLogging):
int_name = name.replace('_json', '')
pfunc = partial(self._jsonify, getattr(self, int_name))
return pfunc
+ else:
+ getattr(self, name)
# We make this a property so that we can over-ride dynamically if needed
@property
@@ -342,6 +344,55 @@ class DSLdapObject(DSLogging):
if self.present(attr, value):
self.remove(attr, value)
+ def ensure_attr_state(self, state):
+ """
+ Given a dict of attr-values, ensure they are in the same state on the entry. This is
+ a stateful assertion, generally used by things like PATCH in a REST api.
+
+ The format is:
+ {
+ 'attr_1': ['value', 'value'],
+ 'attr_2': [],
+ }
+
+ If a value is present in the list, but not in the entry it is ADDED.
+ If a value is NOT present in the list, and is on the entry, it is REMOVED.
+ If a value is an empty list [], the attr is REMOVED from the entry.
+ If an attr is not named in the dictionary, it is not altered.
+
+ This function is atomic - all changes are applied or none are. There are no
+ partial updates.
+
+ This function is idempotent - submitting the same request twice will cause no
+ action to be taken as we are ensuring a state, not listing actions to take.
+
+ :param state: The entry ava state
+ :type state: dict
+ """
+ self._log.debug('ensure_state')
+ # Get all our entry/attrs in a single batch
+ entry_state = self.get_attrs_vals_utf8(state.keys())
+
+ # Check what is present/is not present to work out what has to change.
+ modlist = []
+ for (attr, values) in state.items():
+ value_set = set(values)
+ entry_set = set(entry_state.get(attr, []))
+
+ # Set difference, is "all items in s but not t".
+ value_add = value_set - entry_set
+ value_rem = entry_set - value_set
+
+ for value in value_add:
+ modlist.append((ldap.MOD_ADD, attr, value))
+ for value in value_rem:
+ modlist.append((ldap.MOD_DELETE, attr, value))
+
+ self._log.debug('Applying modlist: %s' % modlist)
+ # Apply it!
+ if len(modlist) > 0:
+ self.apply_mods(modlist)
+
# maybe this could be renamed?
def set(self, key, value, action=ldap.MOD_REPLACE):
"""Perform a specified action on a key with value
| 0 |
23a094c535d5d4ce7fc94b74359697c666a19426
|
389ds/389-ds-base
|
Issue i6057 - Fix3 - Fix covscan issues (#6127)
Fix two minor issues reported by covscan after the previews fix:
CID 1540758: Null pointer dereferences - NULL_RETURNS
/ldap/servers/slapd/back-ldbm/vlv.c: 412 in vlv_list_filenames
Generate Null pointer exception if vlv config entry is not compliant to the schema
Added a ternary test to harden the code.
CID 1540757: Null pointer dereferences - FORWARD_NULL
/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c: 377 in dbmdb_open_all_files
covscan complain that be may be null (which is true but not in the case database context is also NULL)
Added a test to avoid the warning
Issue #6057
Reviewed by: @tbordaz, @droideck Thanks!
|
commit 23a094c535d5d4ce7fc94b74359697c666a19426
Author: progier389 <[email protected]>
Date: Mon Mar 25 11:22:41 2024 +0100
Issue i6057 - Fix3 - Fix covscan issues (#6127)
Fix two minor issues reported by covscan after the previews fix:
CID 1540758: Null pointer dereferences - NULL_RETURNS
/ldap/servers/slapd/back-ldbm/vlv.c: 412 in vlv_list_filenames
Generate Null pointer exception if vlv config entry is not compliant to the schema
Added a ternary test to harden the code.
CID 1540757: Null pointer dereferences - FORWARD_NULL
/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c: 377 in dbmdb_open_all_files
covscan complain that be may be null (which is true but not in the case database context is also NULL)
Added a test to avoid the warning
Issue #6057
Reviewed by: @tbordaz, @droideck Thanks!
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
index 4b508f8b3..f97bf6d2a 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
@@ -383,8 +383,17 @@ dbmdb_open_all_files(dbmdb_ctx_t *ctx, backend *be)
int i;
if (!ctx) {
- struct ldbminfo *li = (struct ldbminfo *)(be->be_database->plg_private);
- ctx = MDB_CONFIG(li);
+ if (!be) {
+ /* Testing for "be" to avoid a covscan warning although
+ * dbmdb_open_all_files is never called with both parameters NULL
+ */
+ slapi_log_err(SLAPI_LOG_ERR, "dbmdb_open_all_files",
+ "Unable to open the database environment witout either the database context or a backend.\n");
+ return DBI_RC_INVALID;
+ } else {
+ struct ldbminfo *li = (struct ldbminfo *)(be->be_database->plg_private);
+ ctx = MDB_CONFIG(li);
+ }
}
ctxflags = ctx->readonly ? MDB_RDONLY: MDB_CREATE;
if (does_vlv_need_init(inst)) {
diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
index 60422ba9e..4c4d0f8ca 100644
--- a/ldap/servers/slapd/back-ldbm/vlv.c
+++ b/ldap/servers/slapd/back-ldbm/vlv.c
@@ -409,7 +409,7 @@ vlv_list_filenames(ldbm_instance *inst)
slapi_pblock_get(tmp_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
for (size_t i = 0; entries && entries[i] != NULL; i++) {
const char *name = slapi_entry_attr_get_ref(entries[i], type_vlvName);
- char *filename = vlvIndex_build_filename(name);
+ char *filename = name ? vlvIndex_build_filename(name) : NULL;
if (filename) {
charray_add(&names, filename);
}
| 0 |
3dca85ec629be641f07ae2ecfef59609d4dc88e2
|
389ds/389-ds-base
|
Ticket 47597 - Convert retro changelog plug-in to betxn
Retro cl plugin is already betxn aware. The template and 20betxn.pl script
needed to be updated to reflect the new default.
https://fedorahosted.org/389/ticket/47597
Reviewed by: richm(Thanks!)
|
commit 3dca85ec629be641f07ae2ecfef59609d4dc88e2
Author: Mark Reynolds <[email protected]>
Date: Mon Nov 18 12:49:48 2013 -0500
Ticket 47597 - Convert retro changelog plug-in to betxn
Retro cl plugin is already betxn aware. The template and 20betxn.pl script
needed to be updated to reflect the new default.
https://fedorahosted.org/389/ticket/47597
Reviewed by: richm(Thanks!)
diff --git a/ldap/admin/src/scripts/20betxn.pl b/ldap/admin/src/scripts/20betxn.pl
index 2c567071a..6f9b5e1de 100644
--- a/ldap/admin/src/scripts/20betxn.pl
+++ b/ldap/admin/src/scripts/20betxn.pl
@@ -12,10 +12,12 @@ sub runinst {
# cn=Multimaster Replication Plugin
# cn=Roles Plugin,cn=plugins,cn=config
# cn=USN,cn=plugins,cn=config
+ # cn=Retro Changelog Plugin,cn=plugins,cn=config
my @objplugins = (
"cn=Multimaster Replication Plugin,cn=plugins,cn=config",
"cn=Roles Plugin,cn=plugins,cn=config",
- "cn=USN,cn=plugins,cn=config"
+ "cn=USN,cn=plugins,cn=config",
+ "cn=Retro Changelog Plugin,cn=plugins,cn=config"
);
foreach my $plugin (@objplugins) {
my $ent = $conn->search($plugin, "base", "(cn=*)");
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index 084aacbb3..9a52bc55e 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -565,6 +565,7 @@ cn: Retro Changelog Plugin
nsslapd-pluginpath: libretrocl-plugin
nsslapd-plugininitfunc: retrocl_plugin_init
nsslapd-plugintype: object
+nsslapd-pluginbetxn: on
nsslapd-pluginenabled: off
nsslapd-pluginprecedence: 25
nsslapd-plugin-depends-on-type: database
| 0 |
d46f51df503e85e2f8c9f9516598bdb79a8fd06c
|
389ds/389-ds-base
|
Bug 189985 - Improve attribute uniqueness error message
This patch improves the error sent back to the client when there
is an attribute value collision. The error message now reports
which attribute has a collision.
|
commit d46f51df503e85e2f8c9f9516598bdb79a8fd06c
Author: Nathan Kinder <[email protected]>
Date: Thu Oct 28 13:05:53 2010 -0700
Bug 189985 - Improve attribute uniqueness error message
This patch improves the error sent back to the client when there
is an attribute value collision. The error message now reports
which attribute has a collision.
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index 487182334..8316afa52 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -105,7 +105,7 @@ static void* plugin_identity = NULL;
* More information about constraint failure
*/
static char *moreInfo =
- "Another entry with the same attribute value already exists";
+ "Another entry with the same attribute value already exists (attribute: \"%s\")";
static void
freePblock( Slapi_PBlock *spb ) {
@@ -540,6 +540,8 @@ static int
preop_add(Slapi_PBlock *pb)
{
int result;
+ char *errtext = NULL;
+ char *attrName = NULL;
#ifdef DEBUG
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name, "ADD begin\n");
@@ -553,13 +555,12 @@ preop_add(Slapi_PBlock *pb)
BEGIN
int err;
- char *attrName = NULL;
char *markerObjectClass = NULL;
char *requiredObjectClass = NULL;
char *dn;
- int isupdatedn;
- Slapi_Entry *e;
- Slapi_Attr *attr;
+ int isupdatedn;
+ Slapi_Entry *e;
+ Slapi_Attr *attr;
int argc;
char **argv = NULL;
@@ -651,8 +652,12 @@ preop_add(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
"ADD result %d\n", result);
+ errtext = slapi_ch_smprintf(moreInfo, attrName);
+
/* Send failure to the client */
- slapi_send_ldap_result(pb, result, 0, moreInfo, 0, 0);
+ slapi_send_ldap_result(pb, result, 0, errtext, 0, 0);
+
+ slapi_ch_free_string(&errtext);
}
return (result==LDAP_SUCCESS)?0:-1;
@@ -685,6 +690,8 @@ preop_modify(Slapi_PBlock *pb)
Slapi_PBlock *spb = NULL;
LDAPMod **checkmods = NULL;
int checkmodsCapacity = 0;
+ char *errtext = NULL;
+ char *attrName = NULL;
#ifdef DEBUG
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
@@ -693,7 +700,6 @@ preop_modify(Slapi_PBlock *pb)
BEGIN
int err;
- char *attrName = NULL;
char *markerObjectClass=NULL;
char *requiredObjectClass=NULL;
LDAPMod **mods;
@@ -809,7 +815,11 @@ preop_modify(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
"MODIFY result %d\n", result);
- slapi_send_ldap_result(pb, result, 0, moreInfo, 0, 0);
+ errtext = slapi_ch_smprintf(moreInfo, attrName);
+
+ slapi_send_ldap_result(pb, result, 0, errtext, 0, 0);
+
+ slapi_ch_free_string(&errtext);
}
return (result==LDAP_SUCCESS)?0:-1;
@@ -830,6 +840,8 @@ preop_modrdn(Slapi_PBlock *pb)
Slapi_Entry *e = NULL;
Slapi_DN *sdn = NULL;
Slapi_Value *sv_requiredObjectClass = NULL;
+ char *errtext = NULL;
+ char *attrName = NULL;
#ifdef DEBUG
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
@@ -838,7 +850,6 @@ preop_modrdn(Slapi_PBlock *pb)
BEGIN
int err;
- char *attrName = NULL;
char *markerObjectClass=NULL;
char *requiredObjectClass=NULL;
char *dn;
@@ -966,7 +977,11 @@ preop_modrdn(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
"MODRDN result %d\n", result);
- slapi_send_ldap_result(pb, result, 0, moreInfo, 0, 0);
+ errtext = slapi_ch_smprintf(moreInfo, attrName);
+
+ slapi_send_ldap_result(pb, result, 0, errtext, 0, 0);
+
+ slapi_ch_free_string(&errtext);
}
return (result==LDAP_SUCCESS)?0:-1;
| 0 |
b53ba00f552fe6f66f3568e1025713ede0556b85
|
389ds/389-ds-base
|
reduce calls to csn_as_string and slapi_log_error
csn_as_string is an expensive operation - we should reduce calls to it
many of these calls are in calls to slapi_log_error at the
REPL log level where we want to print the csn string to the error log
When we call slapi_log_error(REPL,...), any nested functions are called
first, which means that even if the log level is REPL and nothing is logged,
a lot of computation may occur for nothing. We should protect these calls
using slapi_is_loglevel_set().
Reviewed by: nkinder (Thanks!)
|
commit b53ba00f552fe6f66f3568e1025713ede0556b85
Author: Rich Megginson <[email protected]>
Date: Tue Nov 15 20:26:46 2011 -0700
reduce calls to csn_as_string and slapi_log_error
csn_as_string is an expensive operation - we should reduce calls to it
many of these calls are in calls to slapi_log_error at the
REPL log level where we want to print the csn string to the error log
When we call slapi_log_error(REPL,...), any nested functions are called
first, which means that even if the log level is REPL and nothing is logged,
a lot of computation may occur for nothing. We should protect these calls
using slapi_is_loglevel_set().
Reviewed by: nkinder (Thanks!)
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 2a834d777..0ea90d1db 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -3532,9 +3532,11 @@ static void _cl5TrimFile (Object *obj, long *numToTrim)
}
else
{
- slapi_log_error (SLAPI_LOG_REPL, NULL,
- "Changelog purge skipped anchor csn %s\n",
- csn_as_string (maxcsn, PR_FALSE, strCSN));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error (SLAPI_LOG_REPL, NULL,
+ "Changelog purge skipped anchor csn %s\n",
+ csn_as_string (maxcsn, PR_FALSE, strCSN));
+ }
/* extra read to skip the current record */
cl5_operation_parameters_done (&op);
@@ -5020,10 +5022,13 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
PR_ASSERT (supplierRuv);
agmt_name = get_thread_private_agmtname();
- slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Consumer RUV:\n", agmt_name);
- ruv_dump (consumerRuv, agmt_name, NULL);
- slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Supplier RUV:\n", agmt_name);
- ruv_dump (supplierRuv, agmt_name, NULL);
+
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Consumer RUV:\n", agmt_name);
+ ruv_dump (consumerRuv, agmt_name, NULL);
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Supplier RUV:\n", agmt_name);
+ ruv_dump (supplierRuv, agmt_name, NULL);
+ }
/*
* get the sorted list of SupplierMinCSN (if no ConsumerMaxCSN)
@@ -5054,7 +5059,6 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
continue;
startCSN = csns[i];
- csn_as_string(startCSN, PR_FALSE, csnStr);
rc = clcache_get_buffer ( &clcache, file->db, consumerRID, consumerRuv, supplierRuv );
if ( rc != 0 ) goto done;
@@ -5085,23 +5089,28 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
if ((RUV_SUCCESS == ruv_get_min_csn(supplierRuv, &startCSN)) &&
startCSN)
{ /* must now free startCSN */
- csn_as_string(startCSN, PR_FALSE, csnStr);
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
- "%s: CSN %s not found and no purging, probably a reinit\n",
- agmt_name, csnStr);
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
- "%s: Will try to use supplier min CSN %s to load changelog\n",
- agmt_name, csnStr);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ csn_as_string(startCSN, PR_FALSE, csnStr);
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "%s: CSN %s not found and no purging, probably a reinit\n",
+ agmt_name, csnStr);
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "%s: Will try to use supplier min CSN %s to load changelog\n",
+ agmt_name, csnStr);
+ }
rc = clcache_load_buffer (clcache, startCSN, DB_SET);
}
else
{
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "%s: CSN %s not found and no purging, probably a reinit\n",
- agmt_name, csnStr);
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "%s: Could not get the min csn from the supplier RUV\n",
- agmt_name);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ csn_as_string(startCSN, PR_FALSE, csnStr);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "%s: CSN %s not found and no purging, probably a reinit\n",
+ agmt_name, csnStr);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "%s: Could not get the min csn from the supplier RUV\n",
+ agmt_name);
+ }
rc = CL5_RUV_ERROR;
goto done;
}
@@ -5110,8 +5119,11 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
if (rc == 0) {
haveChanges = PR_TRUE;
rc = CL5_SUCCESS;
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
- "%s: CSN %s found, position set for replay\n", agmt_name, csnStr);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ csn_as_string(startCSN, PR_FALSE, csnStr);
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "%s: CSN %s found, position set for replay\n", agmt_name, csnStr);
+ }
if (startCSN != csns[i]) {
csn_free(&startCSN);
}
@@ -5121,33 +5133,44 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
{
/* check whether this csn should be present */
rc = _cl5CheckMissingCSN (startCSN, supplierRuv, file);
+ if (rc == CL5_MISSING_DATA) /* we should have had the change but we don't */
+ {
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ csn_as_string(startCSN, PR_FALSE, csnStr);
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "%s: CSN %s not found, seems to be missing\n", agmt_name, csnStr);
+ }
+ }
+ else /* we are not as up to date or we purged */
+ {
+ csn_as_string(startCSN, PR_FALSE, csnStr);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "%s: CSN %s not found, we aren't as up to date, or we purged\n",
+ agmt_name, csnStr);
+ }
if (startCSN != csns[i]) {
csn_free(&startCSN);
}
if (rc == CL5_MISSING_DATA) /* we should have had the change but we don't */
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
- "%s: CSN %s not found, seems to be missing\n", agmt_name, csnStr);
break;
}
else /* we are not as up to date or we purged */
{
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "%s: CSN %s not found, we aren't as up to date, or we purged\n",
- agmt_name, csnStr);
continue;
}
}
else
{
- if (startCSN != csns[i]) {
- csn_free(&startCSN);
- }
-
+ csn_as_string(startCSN, PR_FALSE, csnStr);
/* db error */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
"%s: Failed to retrieve change with CSN %s; db error - %d %s\n",
agmt_name, csnStr, rc, db_strerror(rc));
+ if (startCSN != csns[i]) {
+ csn_free(&startCSN);
+ }
+
rc = CL5_DB_ERROR;
break;
}
@@ -5369,9 +5392,11 @@ static int _cl5CheckMissingCSN (const CSN *csn, const RUV *supplierRuv, CL5DBFil
{
/* we have not seen any changes from this replica so it is
ok not to have this csn */
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
- "can't locate %s csn: we have not seen any changes for replica %d\n",
- csn_as_string (csn, PR_FALSE, csnStr), rid);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
+ "can't locate %s csn: we have not seen any changes for replica %d\n",
+ csn_as_string (csn, PR_FALSE, csnStr), rid);
+ }
return CL5_SUCCESS;
}
@@ -5381,18 +5406,22 @@ static int _cl5CheckMissingCSN (const CSN *csn, const RUV *supplierRuv, CL5DBFil
/* changelog never contained any changes for this replica */
if (csn_compare (csn, supplierCsn) <= 0)
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
- "the change with %s csn was never logged because it was imported "
- "during replica initialization\n", csn_as_string (csn, PR_FALSE, csnStr));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
+ "the change with %s csn was never logged because it was imported "
+ "during replica initialization\n", csn_as_string (csn, PR_FALSE, csnStr));
+ }
rc = CL5_PURGED_DATA; /* XXXggood is that the correct return value? */
}
else
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
- "change with %s csn has not yet been seen by this server; "
- " last csn seen from that replica is %s\n",
- csn_as_string (csn, PR_FALSE, csnStr),
- csn_as_string (supplierCsn, PR_FALSE, csnStr));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
+ "change with %s csn has not yet been seen by this server; "
+ " last csn seen from that replica is %s\n",
+ csn_as_string (csn, PR_FALSE, csnStr),
+ csn_as_string (supplierCsn, PR_FALSE, csnStr));
+ }
rc = CL5_SUCCESS;
}
}
@@ -5406,20 +5435,24 @@ static int _cl5CheckMissingCSN (const CSN *csn, const RUV *supplierRuv, CL5DBFil
{
if (csn_compare (csn, supplierCsn) <= 0) /* we should have the data but we don't */
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
- "change with %s csn has been purged by this server; "
- "the current purge point for that replica is %s\n",
- csn_as_string (csn, PR_FALSE, csnStr),
- csn_as_string (purgeCsn, PR_FALSE, csnStr));
- rc = CL5_MISSING_DATA;
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
+ "change with %s csn has been purged by this server; "
+ "the current purge point for that replica is %s\n",
+ csn_as_string (csn, PR_FALSE, csnStr),
+ csn_as_string (purgeCsn, PR_FALSE, csnStr));
+ }
+ rc = CL5_MISSING_DATA;
}
else
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
- "change with %s csn has not yet been seen by this server; "
- " last csn seen from that replica is %s\n",
- csn_as_string (csn, PR_FALSE, csnStr),
- csn_as_string (supplierCsn, PR_FALSE, csnStr));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: "
+ "change with %s csn has not yet been seen by this server; "
+ " last csn seen from that replica is %s\n",
+ csn_as_string (csn, PR_FALSE, csnStr),
+ csn_as_string (supplierCsn, PR_FALSE, csnStr));
+ }
rc = CL5_SUCCESS;
}
}
@@ -6065,8 +6098,10 @@ static int _cl5ExportFile (PRFileDesc *prFile, Object *obj)
file = (CL5DBFile*)object_get_data (obj);
PR_ASSERT (file);
- ruv_dump (file->purgeRUV, "clpurgeruv", prFile);
- ruv_dump (file->maxRUV, "clmaxruv", prFile);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ ruv_dump (file->purgeRUV, "clpurgeruv", prFile);
+ ruv_dump (file->maxRUV, "clmaxruv", prFile);
+ }
slapi_write_buffer (prFile, "\n", strlen("\n"));
entry.op = &op;
diff --git a/ldap/servers/plugins/replication/csnpl.c b/ldap/servers/plugins/replication/csnpl.c
index 70bc85356..62f4fc402 100644
--- a/ldap/servers/plugins/replication/csnpl.c
+++ b/ldap/servers/plugins/replication/csnpl.c
@@ -172,8 +172,10 @@ int csnplInsert (CSNPL *csnpl, const CSN *csn)
if (rc != 0)
{
char s[CSN_STRSIZE];
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "csnplInsert: failed to insert csn (%s) into pending list\n", csn_as_string(csn,PR_FALSE,s));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "csnplInsert: failed to insert csn (%s) into pending list\n", csn_as_string(csn,PR_FALSE,s));
+ }
return -1;
}
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
index 274a06967..c9ad6fc70 100644
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
@@ -57,6 +57,7 @@ Stuff to do:
Perhaps these events should be properties of the main protocol.
*/
+#include <plstr.h>
#include "repl.h"
#include "repl5.h"
@@ -80,12 +81,16 @@ typedef struct repl5_inc_private
/* Structures used to communicate with the result reading thread */
+#ifndef UIDSTR_SIZE
+#define UIDSTR_SIZE 35 /* size of the string representation of the id */
+#endif
+
typedef struct repl5_inc_operation
{
int ldap_message_id;
unsigned long operation_type;
- char *csn_str;
- char *uniqueid;
+ char csn_str[CSN_STRSIZE];
+ char uniqueid[UIDSTR_SIZE+1];
ReplicaId replica_id;
struct repl5_inc_operation *next;
} repl5_inc_operation;
@@ -214,15 +219,6 @@ static repl5_inc_operation *repl5_inc_pop_operation(result_data *rd)
static void
repl5_inc_op_free(repl5_inc_operation *op)
{
- /* First free any payload */
- if (op->csn_str)
- {
- slapi_ch_free((void **)&(op->csn_str));
- }
- if (op->uniqueid)
- {
- slapi_ch_free((void **)&(op->uniqueid));
- }
slapi_ch_free((void**)&op);
}
@@ -1389,8 +1385,6 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m
LDAPMod **modrdn_mods = NULL;
char csn_str[CSN_STRSIZE]; /* For logging only */
- csn_as_string(op->csn, PR_FALSE, csn_str);
-
/* Construct the replication info control that accompanies the operation */
if (SLAPI_OPERATION_ADD == op->operation_type)
{
@@ -1416,14 +1410,17 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: replay_update: Unable to create NSDS50ReplUpdateInfoControl "
"for operation with csn %s. Skipping update.\n",
- agmt_get_long_name(prp->agmt), csn_str);
+ agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str));
}
else
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "%s: replay_update: Sending %s operation (dn=\"%s\" csn=%s)\n",
- agmt_get_long_name(prp->agmt),
- op2string(op->operation_type), REPL_GET_DN(&op->target_address), csn_str);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "%s: replay_update: Sending %s operation (dn=\"%s\" csn=%s)\n",
+ agmt_get_long_name(prp->agmt),
+ op2string(op->operation_type), REPL_GET_DN(&op->target_address),
+ csn_as_string(op->csn, PR_FALSE, csn_str));
+ }
/* What type of operation is it? */
switch (op->operation_type)
{
@@ -1486,15 +1483,19 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m
if (CONN_OPERATION_SUCCESS == return_value)
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "%s: replay_update: Consumer successfully sent operation with csn %s\n",
- agmt_get_long_name(prp->agmt), csn_str);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "%s: replay_update: Consumer successfully sent operation with csn %s\n",
+ agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str));
+ }
}
else
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "%s: replay_update: Consumer could not replay operation with csn %s\n",
- agmt_get_long_name(prp->agmt), csn_str);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "%s: replay_update: Consumer could not replay operation with csn %s\n",
+ agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str));
+ }
}
return return_value;
}
@@ -1884,11 +1885,11 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
/* Queue the details for pickup later in the response thread */
repl5_inc_operation *sop = NULL;
sop = repl5_inc_operation_new();
- sop->csn_str = slapi_ch_strdup(csn_str);
+ PL_strncpyz(sop->csn_str, csn_str, sizeof(sop->csn_str));
sop->ldap_message_id = message_id;
sop->operation_type = entry.op->operation_type;
sop->replica_id = replica_id;
- sop->uniqueid = slapi_ch_strdup(uniqueid);
+ PL_strncpyz(sop->uniqueid, uniqueid, sizeof(sop->uniqueid));
repl5_int_push_operation(rd,sop);
}
}
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index a0d45fba7..c806c0876 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -674,13 +674,15 @@ purge_entry_state_information (Slapi_PBlock *pb)
}
if (NULL != e)
{
- char csn_str[CSN_STRSIZE];
entry_purge_state_information(e, purge_csn);
/* conntion is always null */
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "Purged state information from entry %s up to "
- "CSN %s\n", slapi_entry_get_dn(e),
- csn_as_string(purge_csn, PR_FALSE, csn_str));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ char csn_str[CSN_STRSIZE];
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "Purged state information from entry %s up to "
+ "CSN %s\n", slapi_entry_get_dn(e),
+ csn_as_string(purge_csn, PR_FALSE, csn_str));
+ }
}
csn_free(&purge_csn);
}
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index acb7d1fa0..295ea7259 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -2542,21 +2542,25 @@ int process_reap_entry (Slapi_Entry *entry, void *cb_data)
if ((NULL == deletion_csn || csn_compare(deletion_csn, purge_csn) < 0) &&
(!is_ruv_tombstone_entry(entry))) {
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "_replica_reap_tombstones: removing tombstone %s "
- "because its deletion csn (%s) is less than the "
- "purge csn (%s).\n",
- escape_string(slapi_entry_get_dn(entry), ebuf),
- csn_as_string(deletion_csn, PR_FALSE, deletion_csn_str),
- csn_as_string(purge_csn, PR_FALSE, purge_csn_str));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "_replica_reap_tombstones: removing tombstone %s "
+ "because its deletion csn (%s) is less than the "
+ "purge csn (%s).\n",
+ escape_string(slapi_entry_get_dn(entry), ebuf),
+ csn_as_string(deletion_csn, PR_FALSE, deletion_csn_str),
+ csn_as_string(purge_csn, PR_FALSE, purge_csn_str));
+ }
_delete_tombstone(slapi_entry_get_dn(entry),
slapi_entry_get_uniqueid(entry), 0);
(*num_purged_entriesp)++;
}
else {
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "_replica_reap_tombstones: NOT removing tombstone "
- "%s\n", escape_string(slapi_entry_get_dn(entry),ebuf));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "_replica_reap_tombstones: NOT removing tombstone "
+ "%s\n", escape_string(slapi_entry_get_dn(entry),ebuf));
+ }
}
(*num_entriesp)++;
@@ -2939,10 +2943,12 @@ assign_csn_callback(const CSN *csn, void *data)
char ebuf[BUFSIZ];
char csn_str[CSN_STRSIZE]; /* For logging only */
/* Ack, we can't keep track of min csn. Punt. */
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "assign_csn_callback: "
- "failed to insert csn %s for replica %s\n",
- csn_as_string(csn, PR_FALSE, csn_str),
- escape_string(slapi_sdn_get_dn(r->repl_root), ebuf));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "assign_csn_callback: "
+ "failed to insert csn %s for replica %s\n",
+ csn_as_string(csn, PR_FALSE, csn_str),
+ escape_string(slapi_sdn_get_dn(r->repl_root), ebuf));
+ }
csnplFree(&r->min_csn_pl);
}
}
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index 2e4af8712..e5ddb3900 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -1343,6 +1343,9 @@ ruv_dump(const RUV *ruv, char *ruv_name, PRFileDesc *prFile)
int len = sizeof (buff);
PR_ASSERT(NULL != ruv);
+ if (!slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ return;
+ }
slapi_rwlock_rdlock (ruv->lock);
@@ -1406,8 +1409,10 @@ int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn)
replica = ruvAddReplicaNoCSN (ruv, csn_get_replicaid (csn), NULL/*purl*/);
if (replica == NULL)
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to add replica"
- " that created csn %s\n", csn_as_string (csn, PR_FALSE, csn_str));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to add replica"
+ " that created csn %s\n", csn_as_string (csn, PR_FALSE, csn_str));
+ }
rc = RUV_MEMORY_ERROR;
goto done;
}
@@ -1416,9 +1421,11 @@ int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn)
/* check first that this csn is not already covered by this RUV */
if (ruv_covers_csn_internal(ruv, csn, PR_FALSE))
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: "
- "the csn %s has already be seen - ignoring\n",
- csn_as_string (csn, PR_FALSE, csn_str));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: "
+ "the csn %s has already be seen - ignoring\n",
+ csn_as_string (csn, PR_FALSE, csn_str));
+ }
rc = RUV_COVERS_CSN;
goto done;
}
@@ -1426,21 +1433,27 @@ int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn)
rc = csnplInsert (replica->csnpl, csn);
if (rc == 1) /* we already seen this csn */
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: "
- "the csn %s has already be seen - ignoring\n",
- csn_as_string (csn, PR_FALSE, csn_str));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: "
+ "the csn %s has already be seen - ignoring\n",
+ csn_as_string (csn, PR_FALSE, csn_str));
+ }
rc = RUV_COVERS_CSN;
}
else if(rc != 0)
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to insert csn %s"
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to insert csn %s"
" into pending list\n", csn_as_string (csn, PR_FALSE, csn_str));
+ }
rc = RUV_UNKNOWN_ERROR;
}
else
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: successfully inserted csn %s"
- " into pending list\n", csn_as_string (csn, PR_FALSE, csn_str));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: successfully inserted csn %s"
+ " into pending list\n", csn_as_string (csn, PR_FALSE, csn_str));
+ }
rc = RUV_SUCCESS;
}
@@ -1508,8 +1521,10 @@ int ruv_update_ruv (RUV *ruv, const CSN *csn, const char *replica_purl, PRBool i
}
else
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_update_ruv: "
- "successfully committed csn %s\n", csn_as_string(csn, PR_FALSE, csn_str));
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_update_ruv: "
+ "successfully committed csn %s\n", csn_as_string(csn, PR_FALSE, csn_str));
+ }
}
if ((max_csn = csnplRollUp(replica->csnpl, &first_csn)) != NULL)
| 0 |
9efd0ba775b82174921e70706090a0cea5e9830a
|
389ds/389-ds-base
|
bump version to 1.2.6.a5
|
commit 9efd0ba775b82174921e70706090a0cea5e9830a
Author: Rich Megginson <[email protected]>
Date: Wed May 26 15:32:42 2010 -0600
bump version to 1.2.6.a5
diff --git a/VERSION.sh b/VERSION.sh
index 14cef0631..014c49e06 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -14,7 +14,7 @@ VERSION_MAINT=6
# if this is a PRERELEASE, set VERSION_PREREL
# otherwise, comment it out
# be sure to include the dot prefix in the prerel
-VERSION_PREREL=.a4
+VERSION_PREREL=.a5
# NOTES on VERSION_PREREL
# use aN for an alpha release e.g. a1, a2, etc.
# use rcN for a release candidate e.g. rc1, rc2, etc.
| 0 |
e6a65c895e400cefbf8994ecd281b2a16711d1de
|
389ds/389-ds-base
|
Ticket #48194 - CI test: added test cases for ticket 48194
Description: nsSSL3Ciphers preference not enforced server side
|
commit e6a65c895e400cefbf8994ecd281b2a16711d1de
Author: Noriko Hosoi <[email protected]>
Date: Fri Jun 12 14:14:53 2015 -0700
Ticket #48194 - CI test: added test cases for ticket 48194
Description: nsSSL3Ciphers preference not enforced server side
diff --git a/dirsrvtests/tickets/ticket47838_test.py b/dirsrvtests/tickets/ticket47838_test.py
index 19a5ababc..c765525d8 100644
--- a/dirsrvtests/tickets/ticket47838_test.py
+++ b/dirsrvtests/tickets/ticket47838_test.py
@@ -326,7 +326,7 @@ def test_ticket47838_run_4(topology):
Default ciphers are enabled.
default allowWeakCipher
"""
- _header(topology, 'Test Case 5 - Check no nssSSL3Chiphers (default setting) with default allowWeakCipher')
+ _header(topology, 'Test Case 5 - Check no nsSSL3Ciphers (default setting) with default allowWeakCipher')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'nsSSL3Ciphers', '-all')])
@@ -362,7 +362,7 @@ def test_ticket47838_run_5(topology):
Default ciphers are enabled.
default allowWeakCipher
"""
- _header(topology, 'Test Case 6 - Check default nssSSL3Chiphers (default setting) with default allowWeakCipher')
+ _header(topology, 'Test Case 6 - Check default nsSSL3Ciphers (default setting) with default allowWeakCipher')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default')])
@@ -394,11 +394,11 @@ def test_ticket47838_run_5(topology):
def test_ticket47838_run_6(topology):
"""
- Check nssSSL3Chiphers: +all,-rsa_rc4_128_md5
+ Check nsSSL3Ciphers: +all,-rsa_rc4_128_md5
All ciphers are disabled.
default allowWeakCipher
"""
- _header(topology, 'Test Case 7 - Check nssSSL3Chiphers: +all,-tls_dhe_rsa_aes_128_gcm_sha with default allowWeakCipher')
+ _header(topology, 'Test Case 7 - Check nsSSL3Ciphers: +all,-tls_dhe_rsa_aes_128_gcm_sha with default allowWeakCipher')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+all,-tls_dhe_rsa_aes_128_gcm_sha')])
@@ -428,11 +428,11 @@ def test_ticket47838_run_6(topology):
def test_ticket47838_run_7(topology):
"""
- Check nssSSL3Chiphers: -all,+rsa_rc4_128_md5
+ Check nsSSL3Ciphers: -all,+rsa_rc4_128_md5
All ciphers are disabled.
default allowWeakCipher
"""
- _header(topology, 'Test Case 8 - Check nssSSL3Chiphers: -all,+rsa_rc4_128_md5 with default allowWeakCipher')
+ _header(topology, 'Test Case 8 - Check nsSSL3Ciphers: -all,+rsa_rc4_128_md5 with default allowWeakCipher')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '-all,+rsa_rc4_128_md5')])
@@ -463,7 +463,7 @@ def test_ticket47838_run_8(topology):
Check nsSSL3Ciphers: default + allowWeakCipher: off
Strong Default ciphers are enabled.
"""
- _header(topology, 'Test Case 9 - Check default nssSSL3Chiphers (default setting + allowWeakCipher: off)')
+ _header(topology, 'Test Case 9 - Check default nsSSL3Ciphers (default setting + allowWeakCipher: off)')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default'),
@@ -501,7 +501,7 @@ def test_ticket47838_run_9(topology):
allowWeakCipher: on
nsslapd-errorlog-level: 0
"""
- _header(topology, 'Test Case 10 - Check no nssSSL3Chiphers (default setting) with no errorlog-level & allowWeakCipher on')
+ _header(topology, 'Test Case 10 - Check no nsSSL3Ciphers (default setting) with no errorlog-level & allowWeakCipher on')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', None),
@@ -533,7 +533,7 @@ def test_ticket47838_run_9(topology):
def test_ticket47838_run_10(topology):
"""
- Check nssSSL3Chiphers: -TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,
+ Check nsSSL3Ciphers: -TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,
+TLS_RSA_EXPORT_WITH_RC4_40_MD5,+TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5,
+TLS_DHE_RSA_WITH_DES_CBC_SHA,+SSL_RSA_FIPS_WITH_DES_CBC_SHA,
+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,+SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA,
@@ -544,7 +544,7 @@ def test_ticket47838_run_10(topology):
allowWeakCipher: on
nsslapd-errorlog-level: 0
"""
- _header(topology, 'Test Case 11 - Check nssSSL3Chiphers: long list using the NSS Cipher Suite name with allowWeakCipher on')
+ _header(topology, 'Test Case 11 - Check nsSSL3Ciphers: long list using the NSS Cipher Suite name with allowWeakCipher on')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers',
@@ -578,10 +578,10 @@ def test_ticket47838_run_10(topology):
def test_ticket47838_run_11(topology):
"""
- Check nssSSL3Chiphers: +fortezza
+ Check nsSSL3Ciphers: +fortezza
SSL_GetImplementedCiphers does not return this as a secuire cipher suite
"""
- _header(topology, 'Test Case 12 - Check nssSSL3Chiphers: +fortezza, which is not supported')
+ _header(topology, 'Test Case 12 - Check nsSSL3Ciphers: +fortezza, which is not supported')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+fortezza')])
@@ -760,10 +760,10 @@ def test_ticket47928_run_3(topology):
def test_ticket47838_run_last(topology):
"""
- Check nssSSL3Chiphers: all <== invalid value
+ Check nsSSL3Ciphers: all <== invalid value
All ciphers are disabled.
"""
- _header(topology, 'Test Case 17 - Check nssSSL3Chiphers: all, which is invalid')
+ _header(topology, 'Test Case 17 - Check nsSSL3Ciphers: all, which is invalid')
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', None)])
diff --git a/dirsrvtests/tickets/ticket48194_test.py b/dirsrvtests/tickets/ticket48194_test.py
new file mode 100644
index 000000000..4e800eefe
--- /dev/null
+++ b/dirsrvtests/tickets/ticket48194_test.py
@@ -0,0 +1,491 @@
+import os
+import sys
+import subprocess
+import time
+import ldap
+import logging
+import pytest
+import shutil
+from lib389 import DirSrv, Entry, tools
+from lib389 import DirSrvTools
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+
+log = logging.getLogger(__name__)
+
+installation_prefix = None
+
+CONFIG_DN = 'cn=config'
+ENCRYPTION_DN = 'cn=encryption,%s' % CONFIG_DN
+RSA = 'RSA'
+RSA_DN = 'cn=%s,%s' % (RSA, ENCRYPTION_DN)
+LDAPSPORT = '10636'
+SERVERCERT = 'Server-Cert'
+plus_all_ecount = 0
+plus_all_dcount = 0
+plus_all_ecount_noweak = 0
+plus_all_dcount_noweak = 0
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
[email protected](scope="module")
+def topology(request):
+ '''
+ This fixture is used to standalone topology for the 'module'.
+ '''
+ global installation_prefix
+
+ if installation_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation_prefix
+
+ standalone = DirSrv(verbose=False)
+
+ # Args for the standalone instance
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+
+ # Get the status of the instance and restart it if it exists
+ instance_standalone = standalone.exists()
+
+ # Remove the instance
+ if instance_standalone:
+ standalone.delete()
+
+ # Create the instance
+ standalone.create()
+
+ # Used to retrieve configuration information (dbdir, confdir...)
+ standalone.open()
+
+ # clear the tmp directory
+ standalone.clearTmpDir(__file__)
+
+ # Here we have standalone instance up and running
+ return TopologyStandalone(standalone)
+
+
+def _header(topology, label):
+ topology.standalone.log.info("\n\n###############################################")
+ topology.standalone.log.info("####### %s" % label)
+ topology.standalone.log.info("###############################################")
+
+
+def test_ticket48194_init(topology):
+ """
+ Generate self signed cert and import it to the DS cert db.
+ Enable SSL
+ """
+ _header(topology, 'Testing Ticket 48194 - harden the list of ciphers available by default')
+
+ conf_dir = topology.standalone.confdir
+
+ log.info("\n######################### Checking existing certs ######################\n")
+ os.system('certutil -L -d %s -n "CA certificate"' % conf_dir)
+ os.system('certutil -L -d %s -n "%s"' % (conf_dir, SERVERCERT))
+
+ log.info("\n######################### Create a password file ######################\n")
+ pwdfile = '%s/pwdfile.txt' % (conf_dir)
+ opasswd = os.popen("(ps -ef ; w ) | sha1sum | awk '{print $1}'", "r")
+ passwd = opasswd.readline()
+ pwdfd = open(pwdfile, "w")
+ pwdfd.write(passwd)
+ pwdfd.close()
+
+ log.info("\n######################### Create a noise file ######################\n")
+ noisefile = '%s/noise.txt' % (conf_dir)
+ noise = os.popen("(w ; ps -ef ; date ) | sha1sum | awk '{print $1}'", "r")
+ noisewdfd = open(noisefile, "w")
+ noisewdfd.write(noise.readline())
+ noisewdfd.close()
+
+ log.info("\n######################### Create key3.db and cert8.db database ######################\n")
+ os.system("ls %s" % pwdfile)
+ os.system("cat %s" % pwdfile)
+ os.system('certutil -N -d %s -f %s' % (conf_dir, pwdfile))
+
+ log.info("\n######################### Creating encryption key for CA ######################\n")
+ os.system('certutil -G -d %s -z %s -f %s' % (conf_dir, noisefile, pwdfile))
+
+ log.info("\n######################### Creating self-signed CA certificate ######################\n")
+ os.system('( echo y ; echo ; echo y ) | certutil -S -n "CA certificate" -s "cn=CAcert" -x -t "CT,," -m 1000 -v 120 -d %s -z %s -f %s -2' % (conf_dir, noisefile, pwdfile))
+
+ log.info("\n######################### Exporting the CA certificate to cacert.asc ######################\n")
+ cafile = '%s/cacert.asc' % conf_dir
+ catxt = os.popen('certutil -L -d %s -n "CA certificate" -a' % conf_dir)
+ cafd = open(cafile, "w")
+ while True:
+ line = catxt.readline()
+ if (line == ''):
+ break
+ cafd.write(line)
+ cafd.close()
+
+ log.info("\n######################### Generate the server certificate ######################\n")
+ ohostname = os.popen('hostname --fqdn', "r")
+ myhostname = ohostname.readline()
+ os.system('certutil -S -n "%s" -s "cn=%s,ou=389 Directory Server" -c "CA certificate" -t "u,u,u" -m 1001 -v 120 -d %s -z %s -f %s' % (SERVERCERT, myhostname.rstrip(), conf_dir, noisefile, pwdfile))
+
+ log.info("\n######################### create the pin file ######################\n")
+ pinfile = '%s/pin.txt' % (conf_dir)
+ pintxt = 'Internal (Software) Token:%s' % passwd
+ pinfd = open(pinfile, "w")
+ pinfd.write(pintxt)
+ pinfd.close()
+
+ log.info("\n######################### enable SSL in the directory server with all ciphers ######################\n")
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3', 'off'),
+ (ldap.MOD_REPLACE, 'nsTLS1', 'on'),
+ (ldap.MOD_REPLACE, 'nsSSLClientAuth', 'allowed'),
+ (ldap.MOD_REPLACE, 'allowWeakCipher', 'on'),
+ (ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+all')])
+
+ topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-security', 'on'),
+ (ldap.MOD_REPLACE, 'nsslapd-ssl-check-hostname', 'off'),
+ (ldap.MOD_REPLACE, 'nsslapd-secureport', LDAPSPORT)])
+
+ topology.standalone.add_s(Entry((RSA_DN, {'objectclass': "top nsEncryptionModule".split(),
+ 'cn': RSA,
+ 'nsSSLPersonalitySSL': SERVERCERT,
+ 'nsSSLToken': 'internal (software)',
+ 'nsSSLActivation': 'on'})))
+
+def connectWithOpenssl(topology, cipher, expect):
+ """
+ Connect with the given cipher
+ Condition:
+ If expect is True, the handshake should be successful.
+ If expect is False, the handshake should be refused with
+ access log: "Cannot communicate securely with peer:
+ no common encryption algorithm(s)."
+ """
+ log.info("Testing %s -- expect to handshake %s", cipher,"successfully" if expect else "failed")
+
+ myurl = 'localhost:%s' % LDAPSPORT
+ cmdline = ['/usr/bin/openssl', 's_client', '-connect', myurl, '-cipher', cipher]
+
+ strcmdline = '/usr/bin/openssl s_client -connect localhost:%s -cipher %s' % (LDAPSPORT, cipher)
+ log.info("Running cmdline: %s", strcmdline)
+
+ try:
+ proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
+ except ValueError:
+ log.info("%s failed: %s", cmdline, ValueError)
+ proc.kill()
+
+ while True:
+ l = proc.stdout.readline()
+ if l == "":
+ break
+ if 'Cipher is' in l:
+ log.info("Found: %s", l)
+ if expect:
+ if '(NONE)' in l:
+ assert False
+ else:
+ proc.stdin.close()
+ assert True
+ else:
+ if '(NONE)' in l:
+ assert True
+ else:
+ proc.stdin.close()
+ assert False
+
+def test_ticket48194_run_0(topology):
+ """
+ Check nsSSL3Ciphers: +all
+ All ciphers are enabled except null.
+ Note: allowWeakCipher: on
+ """
+ _header(topology, 'Test Case 1 - Check the ciphers availability for "+all"; allowWeakCipher: on')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.restart(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', True)
+ connectWithOpenssl(topology, 'AES256-SHA256', True)
+
+def test_ticket48194_run_1(topology):
+ """
+ Check nsSSL3Ciphers: +all
+ All ciphers are enabled except null.
+ Note: default allowWeakCipher (i.e., off) for +all
+ """
+ _header(topology, 'Test Case 2 - Check the ciphers availability for "+all" with default allowWeakCiphers')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')])
+ # Make sure allowWeakCipher is not set.
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'allowWeakCipher', None)])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_0' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', True)
+
+def test_ticket48194_run_2(topology):
+ """
+ Check nsSSL3Ciphers: +rsa_aes_128_sha,+rsa_aes_256_sha
+ rsa_aes_128_sha, tls_rsa_aes_128_sha, rsa_aes_256_sha, tls_rsa_aes_256_sha are enabled.
+ default allowWeakCipher
+ """
+ _header(topology, 'Test Case 3 - Check the ciphers availability for "+rsa_aes_128_sha,+rsa_aes_256_sha" with default allowWeakCipher')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+rsa_aes_128_sha,+rsa_aes_256_sha')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_1' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', False)
+ connectWithOpenssl(topology, 'AES128-SHA', True)
+ connectWithOpenssl(topology, 'AES256-SHA', True)
+
+def test_ticket48194_run_3(topology):
+ """
+ Check nsSSL3Ciphers: -all
+ All ciphers are disabled.
+ default allowWeakCipher
+ """
+ _header(topology, 'Test Case 4 - Check the ciphers availability for "-all"')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '-all')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_2' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', False)
+
+def test_ticket48194_run_4(topology):
+ """
+ Check no nsSSL3Ciphers
+ Default ciphers are enabled.
+ default allowWeakCipher
+ """
+ _header(topology, 'Test Case 5 - Check no nsSSL3Ciphers (default setting) with default allowWeakCipher')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'nsSSL3Ciphers', '-all')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_3' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', True)
+
+def test_ticket48194_run_5(topology):
+ """
+ Check nsSSL3Ciphers: default
+ Default ciphers are enabled.
+ default allowWeakCipher
+ """
+ _header(topology, 'Test Case 6 - Check default nsSSL3Ciphers (default setting) with default allowWeakCipher')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_4' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', True)
+ connectWithOpenssl(topology, 'AES256-SHA256', True)
+
+def test_ticket48194_run_6(topology):
+ """
+ Check nsSSL3Ciphers: +all,-TLS_RSA_WITH_AES_256_CBC_SHA256
+ All ciphers are disabled.
+ default allowWeakCipher
+ """
+ _header(topology, 'Test Case 7 - Check nsSSL3Ciphers: +all,-TLS_RSA_WITH_AES_256_CBC_SHA256 with default allowWeakCipher')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+all,-TLS_RSA_WITH_AES_256_CBC_SHA256 ')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_5' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', False)
+ connectWithOpenssl(topology, 'AES128-SHA', True)
+
+def test_ticket48194_run_7(topology):
+ """
+ Check nsSSL3Ciphers: -all,+rsa_rc4_128_md5
+ All ciphers are disabled.
+ default allowWeakCipher
+ """
+ _header(topology, 'Test Case 8 - Check nsSSL3Ciphers: -all,+rsa_rc4_128_md5 with default allowWeakCipher')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '-all,+rsa_rc4_128_md5')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_6' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', False)
+ connectWithOpenssl(topology, 'RC4-MD5', True)
+
+def test_ticket48194_run_8(topology):
+ """
+ Check nsSSL3Ciphers: default + allowWeakCipher: off
+ Strong Default ciphers are enabled.
+ """
+ _header(topology, 'Test Case 9 - Check default nsSSL3Ciphers (default setting + allowWeakCipher: off)')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default'),
+ (ldap.MOD_REPLACE, 'allowWeakCipher', 'off')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_7' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', True)
+
+def test_ticket48194_run_9(topology):
+ """
+ Check no nsSSL3Ciphers
+ Default ciphers are enabled.
+ allowWeakCipher: on
+ nsslapd-errorlog-level: 0
+ """
+ _header(topology, 'Test Case 10 - Check no nsSSL3Ciphers (default setting) with no errorlog-level & allowWeakCipher on')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', None),
+ (ldap.MOD_REPLACE, 'allowWeakCipher', 'on')])
+ topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', None)])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_8' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', True)
+ connectWithOpenssl(topology, 'AES256-SHA256', True)
+
+def test_ticket48194_run_10(topology):
+ """
+ Check nsSSL3Ciphers: -TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,
+ +TLS_RSA_EXPORT_WITH_RC4_40_MD5,+TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5,
+ +TLS_DHE_RSA_WITH_DES_CBC_SHA,+SSL_RSA_FIPS_WITH_DES_CBC_SHA,
+ +TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,+SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA,
+ +TLS_RSA_EXPORT1024_WITH_RC4_56_SHA,+TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA,
+ -SSL_CK_RC4_128_WITH_MD5,-SSL_CK_RC4_128_EXPORT40_WITH_MD5,
+ -SSL_CK_RC2_128_CBC_WITH_MD5,-SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5,
+ -SSL_CK_DES_64_CBC_WITH_MD5,-SSL_CK_DES_192_EDE3_CBC_WITH_MD5
+ allowWeakCipher: on
+ nsslapd-errorlog-level: 0
+ """
+ _header(topology, 'Test Case 11 - Check nsSSL3Ciphers: long list using the NSS Cipher Suite name with allowWeakCipher on')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers',
+ '-TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,+TLS_RSA_EXPORT_WITH_RC4_40_MD5,+TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5,+TLS_DHE_RSA_WITH_DES_CBC_SHA,+SSL_RSA_FIPS_WITH_DES_CBC_SHA,+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,+SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA,+TLS_RSA_EXPORT1024_WITH_RC4_56_SHA,+TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA,-SSL_CK_RC4_128_WITH_MD5,-SSL_CK_RC4_128_EXPORT40_WITH_MD5,-SSL_CK_RC2_128_CBC_WITH_MD5,-SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5,-SSL_CK_DES_64_CBC_WITH_MD5,-SSL_CK_DES_192_EDE3_CBC_WITH_MD5')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_9' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'RC4-MD5', True)
+ connectWithOpenssl(topology, 'AES256-SHA256', False)
+
+def test_ticket48194_run_11(topology):
+ """
+ Check nsSSL3Ciphers: +fortezza
+ SSL_GetImplementedCiphers does not return this as a secuire cipher suite
+ """
+ _header(topology, 'Test Case 12 - Check nsSSL3Ciphers: +fortezza, which is not supported')
+
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+fortezza')])
+
+ log.info("\n######################### Restarting the server ######################\n")
+ topology.standalone.stop(timeout=10)
+ os.system('mv %s %s.48194_10' % (topology.standalone.errlog, topology.standalone.errlog))
+ os.system('touch %s' % (topology.standalone.errlog))
+ topology.standalone.start(timeout=120)
+
+ connectWithOpenssl(topology, 'RC4-SHA', False)
+ connectWithOpenssl(topology, 'AES256-SHA256', False)
+
+def test_ticket48194_final(topology):
+ topology.standalone.delete()
+ log.info('Testcase PASSED')
+
+def run_isolated():
+ '''
+ run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
+ To run isolated without py.test, you need to
+ - edit this file and comment '@pytest.fixture' line before 'topology' function.
+ - set the installation prefix
+ - run this program
+ '''
+ global installation_prefix
+ installation_prefix = None
+
+ topo = topology(True)
+ test_ticket48194_init(topo)
+
+ test_ticket48194_run_0(topo)
+ test_ticket48194_run_1(topo)
+ test_ticket48194_run_2(topo)
+ test_ticket48194_run_3(topo)
+ test_ticket48194_run_4(topo)
+ test_ticket48194_run_5(topo)
+ test_ticket48194_run_6(topo)
+ test_ticket48194_run_7(topo)
+ test_ticket48194_run_8(topo)
+ test_ticket48194_run_9(topo)
+ test_ticket48194_run_10(topo)
+ test_ticket48194_run_11(topo)
+
+ test_ticket48194_final(topo)
+
+if __name__ == '__main__':
+ run_isolated()
| 0 |
dcec32787a8ba87f8a9e15324cc789acbac7426f
|
389ds/389-ds-base
|
Ticket 48799 - Test cases for objectClass values being dropped.
Bug Description: During replication, not all objectClasses were added to
the consumer.
Fix Description: This test case proves the issue and fix.
https://fedorahosted.org/389/ticket/48799
Author: wibrown
Review by: nhosoi
|
commit dcec32787a8ba87f8a9e15324cc789acbac7426f
Author: William Brown <[email protected]>
Date: Wed Apr 20 11:16:59 2016 +1000
Ticket 48799 - Test cases for objectClass values being dropped.
Bug Description: During replication, not all objectClasses were added to
the consumer.
Fix Description: This test case proves the issue and fix.
https://fedorahosted.org/389/ticket/48799
Author: wibrown
Review by: nhosoi
diff --git a/dirsrvtests/tests/tickets/ticket48799_test.py b/dirsrvtests/tests/tickets/ticket48799_test.py
new file mode 100644
index 000000000..e92b5fd47
--- /dev/null
+++ b/dirsrvtests/tests/tickets/ticket48799_test.py
@@ -0,0 +1,170 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+class TopologyReplication(object):
+ def __init__(self, master1, consumer1):
+ master1.open()
+ self.master1 = master1
+ consumer1.open()
+ self.consumer1 = consumer1
+
+
[email protected](scope="module")
+def topology(request):
+ # Creating master 1...
+ master1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_1
+ args_instance[SER_PORT] = PORT_MASTER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master1.allocate(args_master)
+ instance_master1 = master1.exists()
+ if instance_master1:
+ master1.delete()
+ master1.create()
+ master1.open()
+ master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
+
+ # Creating consumer 1...
+ consumer1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_CONSUMER_1
+ args_instance[SER_PORT] = PORT_CONSUMER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_consumer = args_instance.copy()
+ consumer1.allocate(args_consumer)
+ instance_consumer1 = consumer1.exists()
+ if instance_consumer1:
+ consumer1.delete()
+ consumer1.create()
+ consumer1.open()
+ consumer1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_CONSUMER, replicaId=CONSUMER_REPLICAID)
+
+ #
+ # Create all the agreements
+ #
+ # Creating agreement from master 1 to consumer 1
+ properties = {RA_NAME: r'meTo_$host:$port',
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m1_c1_agmt = master1.agreement.create(suffix=SUFFIX, host=consumer1.host, port=consumer1.port, properties=properties)
+ if not m1_c1_agmt:
+ log.fatal("Fail to create a hub -> consumer replica agreement")
+ sys.exit(1)
+ log.debug("%s created" % m1_c1_agmt)
+
+ # Allow the replicas to get situated with the new agreements...
+ time.sleep(5)
+
+ #
+ # Initialize all the agreements
+ #
+ master1.agreement.init(SUFFIX, HOST_CONSUMER_1, PORT_CONSUMER_1)
+ master1.waitForReplInit(m1_c1_agmt)
+
+ # Check replication is working...
+ if master1.testReplication(DEFAULT_SUFFIX, consumer1):
+ log.info('Replication is working.')
+ else:
+ log.fatal('Replication is not working.')
+ assert False
+
+ # Delete each instance in the end
+ def fin():
+ master1.delete()
+ consumer1.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ master1.clearTmpDir(__file__)
+
+ return TopologyReplication(master1, consumer1)
+
+def _add_custom_schema(server):
+ attr_value = "( 10.0.9.2342.19200300.100.1.1 NAME 'customManager' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 X-ORIGIN 'user defined' )"
+ mod = [(ldap.MOD_ADD, 'attributeTypes', attr_value)]
+ server.modify_s('cn=schema', mod)
+
+ oc_value = "( 1.3.6.1.4.1.4843.2.1 NAME 'customPerson' SUP inetorgperson STRUCTURAL MAY (customManager) X-ORIGIN 'user defined' )"
+ mod = [(ldap.MOD_ADD, 'objectclasses', oc_value)]
+ server.modify_s('cn=schema', mod)
+
+def _create_user(server):
+ server.add_s(Entry((
+ "uid=testuser,ou=People,%s" % DEFAULT_SUFFIX,
+ {
+ 'objectClass' : "top account posixaccount".split(),
+ 'uid' : 'testuser',
+ 'gecos' : 'Test User',
+ 'cn' : 'testuser',
+ 'homedirectory' : '/home/testuser',
+ 'passwordexpirationtime' : '20160710184141Z',
+ 'userpassword' : '!',
+ 'uidnumber' : '1111212',
+ 'gidnumber' : '1111212',
+ 'loginshell' : '/bin/bash'
+ }
+ )))
+
+def _modify_user(server):
+ mod = [
+ (ldap.MOD_ADD, 'objectClass', ['customPerson']),
+ (ldap.MOD_ADD, 'sn', ['User']),
+ (ldap.MOD_ADD, 'customManager', ['cn=manager']),
+ ]
+ server.modify("uid=testuser,ou=People,%s" % DEFAULT_SUFFIX, mod)
+
+def test_ticket48799(topology):
+ """Write your replication testcase here.
+
+ To access each DirSrv instance use: topology.master1, topology.master2,
+ ..., topology.hub1, ..., topology.consumer1,...
+
+ Also, if you need any testcase initialization,
+ please, write additional fixture for that(include finalizer).
+ """
+
+ # Add the new schema element.
+ _add_custom_schema(topology.master1)
+ _add_custom_schema(topology.consumer1)
+
+ # Add a new user on the master.
+ _create_user(topology.master1)
+ # Modify the user on the master.
+ _modify_user(topology.master1)
+
+ # We need to wait for replication here.
+ time.sleep(15)
+
+ # Now compare the master vs consumer, and see if the objectClass was dropped.
+
+ master_entry = topology.master1.search_s("uid=testuser,ou=People,%s" % DEFAULT_SUFFIX, ldap.SCOPE_BASE, '(objectclass=*)', ['objectClass'])
+ consumer_entry = topology.consumer1.search_s("uid=testuser,ou=People,%s" % DEFAULT_SUFFIX, ldap.SCOPE_BASE, '(objectclass=*)', ['objectClass'])
+
+ assert(master_entry == consumer_entry)
+
+
+ log.info('Test complete')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
| 0 |
5724e02c7f30ef1130764c79b30edd04954663a7
|
389ds/389-ds-base
|
Ticket 47427 - Overflow in nsslapd-disk-monitoring-threshold
Bug Description: The threshold setting was being stored as an "int" instead
of a PRUint64. Config setting validation was also incomplete.
Fix Description: Fix build warning caused by previous commit.
https://fedorahosted.org/389/ticket/47427
|
commit 5724e02c7f30ef1130764c79b30edd04954663a7
Author: Rich Megginson <[email protected]>
Date: Thu Jul 11 10:58:07 2013 -0600
Ticket 47427 - Overflow in nsslapd-disk-monitoring-threshold
Bug Description: The threshold setting was being stored as an "int" instead
of a PRUint64. Config setting validation was also incomplete.
Fix Description: Fix build warning caused by previous commit.
https://fedorahosted.org/389/ticket/47427
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index c1f92ee44..5219f8ccb 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1679,7 +1679,7 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in
if ( *endp != '\0' || threshold <= 4096 || errno == ERANGE ) {
PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid, threshold must be greater than 4096 and less then %llu",
+ "%s: \"%s\" is invalid, threshold must be greater than 4096 and less then %lu",
attrname, value, LONG_MAX );
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
| 0 |
4845ffc48517bd2c938129a40c4e4f29c1efcc5a
|
389ds/389-ds-base
|
Bug 571514 - upgrade to 1.2.6 should upgrade 05rfc4523.ldif (cert schema)
https://bugzilla.redhat.com/show_bug.cgi?id=571514
Resolves: bug 571514
Bug Description: upgrade to 1.2.6 should upgrade 05rfc4523.ldif (cert schema)
Reviewed by: nhosoi (Thanks!)
Branch: HEAD
Fix Description: Added 05rfc4523.ldif to the list of schema to upgrade.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
|
commit 4845ffc48517bd2c938129a40c4e4f29c1efcc5a
Author: Rich Megginson <[email protected]>
Date: Mon Mar 8 12:36:56 2010 -0700
Bug 571514 - upgrade to 1.2.6 should upgrade 05rfc4523.ldif (cert schema)
https://bugzilla.redhat.com/show_bug.cgi?id=571514
Resolves: bug 571514
Bug Description: upgrade to 1.2.6 should upgrade 05rfc4523.ldif (cert schema)
Reviewed by: nhosoi (Thanks!)
Branch: HEAD
Fix Description: Added 05rfc4523.ldif to the list of schema to upgrade.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/admin/src/scripts/60upgradeschemafiles.pl b/ldap/admin/src/scripts/60upgradeschemafiles.pl
index ebc71268c..97d6a94e6 100644
--- a/ldap/admin/src/scripts/60upgradeschemafiles.pl
+++ b/ldap/admin/src/scripts/60upgradeschemafiles.pl
@@ -11,7 +11,7 @@ sub runinst {
# these schema files are obsolete, or we want to replace
# them with newer versions
- my @toremove = qw(00core.ldif 01core389.ldif 01common.ldif 02common.ldif 05rfc2247.ldif 10presence.ldif 28pilot.ldif 30ns-common.ldif 50ns-directory.ldif 60mozilla.ldif);
+ my @toremove = qw(00core.ldif 01core389.ldif 01common.ldif 02common.ldif 05rfc2247.ldif 05rfc4523.ldif 10presence.ldif 28pilot.ldif 30ns-common.ldif 50ns-directory.ldif 60mozilla.ldif);
# these hashes will be used to check for obsolete schema
# in 99user.ldif
| 0 |
d4eadaefa652a2251afde5bff1166bdb267ac581
|
389ds/389-ds-base
|
Ticket 47662 - Better input argument validation and error messages for cli tools
Description: Improved usage errors for CLI tools, and also made the usage errors
consistent.
https://fedorahosted.org/389/ticket/47662
Reviewed by: nhosoi(Thanks!)
|
commit d4eadaefa652a2251afde5bff1166bdb267ac581
Author: Mark Reynolds <[email protected]>
Date: Fri Dec 9 15:16:38 2016 -0500
Ticket 47662 - Better input argument validation and error messages for cli tools
Description: Improved usage errors for CLI tools, and also made the usage errors
consistent.
https://fedorahosted.org/389/ticket/47662
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index ab7c6b3ec..cb5ef14f2 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -57,6 +57,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/bak2db.pl.in b/ldap/admin/src/scripts/bak2db.pl.in
index cc9864496..28f1c9837 100644
--- a/ldap/admin/src/scripts/bak2db.pl.in
+++ b/ldap/admin/src/scripts/bak2db.pl.in
@@ -62,6 +62,7 @@ while ($i <= $#ARGV) {
} elsif ("$ARGV[$i]" eq "-v") { # verbose
$verbose = 1;
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/cleanallruv.pl.in b/ldap/admin/src/scripts/cleanallruv.pl.in
index 8970b7ef0..f6e5477f8 100644
--- a/ldap/admin/src/scripts/cleanallruv.pl.in
+++ b/ldap/admin/src/scripts/cleanallruv.pl.in
@@ -71,6 +71,7 @@ while ($i <= $#ARGV)
# help
&usage; exit(0);
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index adbe30bf6..e773b2809 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -53,6 +53,13 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
diff --git a/ldap/admin/src/scripts/db2bak.pl.in b/ldap/admin/src/scripts/db2bak.pl.in
index 479e54181..2e9538333 100644
--- a/ldap/admin/src/scripts/db2bak.pl.in
+++ b/ldap/admin/src/scripts/db2bak.pl.in
@@ -65,6 +65,7 @@ while ($i <= $#ARGV) {
} elsif ("$ARGV[$i]" eq "-v") { # verbose
$verbose = 1;
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 748c58bcb..fec082e96 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -52,6 +52,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/db2index.pl.in b/ldap/admin/src/scripts/db2index.pl.in
index 178a9acd8..847e67e5e 100644
--- a/ldap/admin/src/scripts/db2index.pl.in
+++ b/ldap/admin/src/scripts/db2index.pl.in
@@ -68,6 +68,7 @@ while ($i <= $#ARGV) {
} elsif ("$ARGV[$i]" eq "-v") { # verbose
$verbose = 1;
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index b31159063..85854b352 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -130,6 +130,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
if [ "$required_param" != "yes" ]
then
usage
diff --git a/ldap/admin/src/scripts/db2ldif.pl.in b/ldap/admin/src/scripts/db2ldif.pl.in
index b82ea41c9..e8ff2295f 100644
--- a/ldap/admin/src/scripts/db2ldif.pl.in
+++ b/ldap/admin/src/scripts/db2ldif.pl.in
@@ -153,6 +153,7 @@ while ($i <= $#ARGV) {
} elsif ("$ARGV[$i]" eq "-c") { # cwd
$i++; $cwd = $ARGV[$i];
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index b98e9b2c3..601f726f0 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -46,6 +46,15 @@ do
esac
done
+
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 762e63a4c..53efd210b 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -38,6 +38,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/fixup-linkedattrs.pl.in b/ldap/admin/src/scripts/fixup-linkedattrs.pl.in
index 76a7d3fb0..b9a455e96 100644
--- a/ldap/admin/src/scripts/fixup-linkedattrs.pl.in
+++ b/ldap/admin/src/scripts/fixup-linkedattrs.pl.in
@@ -65,6 +65,7 @@ while ($i <= $#ARGV)
# protocol preference
$i++; $protocol = $ARGV[$i];
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/fixup-memberof.pl.in b/ldap/admin/src/scripts/fixup-memberof.pl.in
index bf7b5f514..f3d6447dd 100644
--- a/ldap/admin/src/scripts/fixup-memberof.pl.in
+++ b/ldap/admin/src/scripts/fixup-memberof.pl.in
@@ -69,6 +69,7 @@ while ($i <= $#ARGV)
# verbose
$verbose = 1;
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index 3aed4697e..03a241b70 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -81,23 +81,31 @@ do
esac
done
-initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $# -lt 4 ]
then
usage
- echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
- echo "Available instances: $initfile"
exit 1
fi
-. $initfile
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
-if [ $# -lt 4 ]
+initfile=$(get_init_file "@initconfigdir@" $servid)
+if [ $? -eq 1 ]
then
usage
+ echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
+ echo "Available instances: $initfile"
exit 1
fi
+. $initfile
+
handleopts $@
quiet=$?
if [ $quiet -eq 0 ]; then
diff --git a/ldap/admin/src/scripts/ldif2db.pl.in b/ldap/admin/src/scripts/ldif2db.pl.in
index 540e52b2c..bdb311e27 100644
--- a/ldap/admin/src/scripts/ldif2db.pl.in
+++ b/ldap/admin/src/scripts/ldif2db.pl.in
@@ -138,6 +138,7 @@ while ($i <= $#ARGV) {
} elsif ("$ARGV[$i]" eq "-P") { # protocol preference
$i++; $protocol = $ARGV[$i];
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/ldif2ldap.in b/ldap/admin/src/scripts/ldif2ldap.in
index 1e871bede..eaaba7a9b 100755
--- a/ldap/admin/src/scripts/ldif2ldap.in
+++ b/ldap/admin/src/scripts/ldif2ldap.in
@@ -40,6 +40,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
if [ -z "$input_file" ]
then
usage
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index e9265a126..7edd254b3 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -40,6 +40,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/ns-accountstatus.pl.in b/ldap/admin/src/scripts/ns-accountstatus.pl.in
index a20d2df96..2b94051d9 100644
--- a/ldap/admin/src/scripts/ns-accountstatus.pl.in
+++ b/ldap/admin/src/scripts/ns-accountstatus.pl.in
@@ -761,7 +761,7 @@ while( $arg = shift){
} elsif ($arg eq "-P") {
$protocol = shift @ARGV;
} else {
- print "$arg: Unknown command line argument.\n";
+ print "ERROR - Unknown option: $ARGV[$i]\n";
usage();
exit 1
}
diff --git a/ldap/admin/src/scripts/ns-activate.pl.in b/ldap/admin/src/scripts/ns-activate.pl.in
index 6e5ecc71f..5922c9aab 100644
--- a/ldap/admin/src/scripts/ns-activate.pl.in
+++ b/ldap/admin/src/scripts/ns-activate.pl.in
@@ -481,7 +481,7 @@ while( $arg = shift)
} elsif ($arg eq "-P") {
$protocol = shift @ARGV;
} else {
- print "$arg: Unknown command line argument.\n";
+ print "ERROR - Unknown option: $ARGV[$i]\n";
usage();
exit(1);
}
diff --git a/ldap/admin/src/scripts/ns-inactivate.pl.in b/ldap/admin/src/scripts/ns-inactivate.pl.in
index af7e09bf7..ef37527d0 100644
--- a/ldap/admin/src/scripts/ns-inactivate.pl.in
+++ b/ldap/admin/src/scripts/ns-inactivate.pl.in
@@ -354,7 +354,7 @@ while( $arg = shift)
} elsif ($arg eq "-P") {
$protocol = shift @ARGV;
} else {
- print "$arg: Unknown command line argument.\n";
+ print "ERROR - Unknown option: $ARGV[$i]\n";
usage();
exit(1);
}
diff --git a/ldap/admin/src/scripts/restoreconfig.in b/ldap/admin/src/scripts/restoreconfig.in
index 56c9e4339..bdb1ebd3c 100755
--- a/ldap/admin/src/scripts/restoreconfig.in
+++ b/ldap/admin/src/scripts/restoreconfig.in
@@ -30,6 +30,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/saveconfig.in b/ldap/admin/src/scripts/saveconfig.in
index 16e3efc57..85334e58f 100755
--- a/ldap/admin/src/scripts/saveconfig.in
+++ b/ldap/admin/src/scripts/saveconfig.in
@@ -30,6 +30,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/schema-reload.pl.in b/ldap/admin/src/scripts/schema-reload.pl.in
index 307100bc1..d88033739 100644
--- a/ldap/admin/src/scripts/schema-reload.pl.in
+++ b/ldap/admin/src/scripts/schema-reload.pl.in
@@ -63,6 +63,7 @@ while ($i <= $#ARGV)
# protocol preference
$i++; $protocol = $ARGV[$i];
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage;
exit(1);
}
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index d7c666104..88b031cfc 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -38,6 +38,20 @@ then
exit 1
fi
+if [ $# -lt 2 ]
+then
+ echo Usage: suffix2instance [-Z serverID] {-s includesuffix}*
+ exit 1
+fi
+
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
@@ -49,10 +63,6 @@ fi
. $initfile
-if [ $# -lt 2 ]
-then
- echo Usage: suffix2instance [-Z serverID] {-s includesuffix}*
- exit 1
-fi
+
eval @sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
diff --git a/ldap/admin/src/scripts/syntax-validate.pl.in b/ldap/admin/src/scripts/syntax-validate.pl.in
index 05dc9380f..5f5247557 100644
--- a/ldap/admin/src/scripts/syntax-validate.pl.in
+++ b/ldap/admin/src/scripts/syntax-validate.pl.in
@@ -70,6 +70,7 @@ while ($i <= $#ARGV)
# verbose
$verbose = 1;
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage;
exit(1);
}
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index 2b7c79daf..5f9ff8f9f 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -38,6 +38,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 9de60eaec..e4f9dbe56 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -49,6 +49,14 @@ do
esac
done
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
+
if [ -z "$be" ] || [ -z "$dir" ]; then
usage
exit 1
diff --git a/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in b/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in
index bafdb1a9f..c14bcd82c 100644
--- a/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in
+++ b/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in
@@ -71,6 +71,7 @@ while ($i <= $#ARGV)
# verbose
$verbose = 1;
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage;
exit(1);
}
diff --git a/ldap/admin/src/scripts/verify-db.pl.in b/ldap/admin/src/scripts/verify-db.pl.in
index d481ecbef..fcc93d7de 100644
--- a/ldap/admin/src/scripts/verify-db.pl.in
+++ b/ldap/admin/src/scripts/verify-db.pl.in
@@ -128,6 +128,7 @@ while ($i <= $#ARGV) {
} elsif ("$ARGV[$i]" eq "-h") { # help
&usage; exit(0);
} else {
+ print "ERROR - Unknown option: $ARGV[$i]\n";
&usage; exit(1);
}
$i++;
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index a1696bc0f..ba2a2b39b 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -44,21 +44,29 @@ do
esac
done
-initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $# -lt 4 ]
then
usage
- echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
- echo "Available instances: $initfile"
exit 1
fi
-. $initfile
+shift $(($OPTIND - 1))
+if [ $1 ]
+then
+ echo "ERROR - Unknown option: $1"
+ usage
+ exit 1
+fi
-if [ $# -lt 4 ]
+initfile=$(get_init_file "@initconfigdir@" $servid)
+if [ $? -eq 1 ]
then
usage
+ echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
+ echo "Available instances: $initfile"
exit 1
fi
+. $initfile
+
eval @sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
| 0 |
5e9c4f1f09596dd076a6c3a0bb419580e8fd705e
|
389ds/389-ds-base
|
Ticket #48146 - async simple paged results issue; need to close a small window for a pr index competed among multiple threads.
Description: If multiple async simple paged results requests come in via one
connection simultaneously, the same slot in the paged results array in the
connection could be shared. If one of them has to do paging, the search
request object stashed in the paged result array slot could be freed by the
other request if it has the shorter life cycle.
These 3 reqs use the same paged results array slot.
req0: <--------------><----x
page1 page2
req1: <----->
req2: <------->
frees search result object of req0
Reviewed by [email protected] (Thank you, Rich!!)
(cherry picked from commit 3cf85d1ad6cbc0feac5578dee5ce259c0f65055f)
|
commit 5e9c4f1f09596dd076a6c3a0bb419580e8fd705e
Author: Noriko Hosoi <[email protected]>
Date: Fri May 1 12:01:13 2015 -0700
Ticket #48146 - async simple paged results issue; need to close a small window for a pr index competed among multiple threads.
Description: If multiple async simple paged results requests come in via one
connection simultaneously, the same slot in the paged results array in the
connection could be shared. If one of them has to do paging, the search
request object stashed in the paged result array slot could be freed by the
other request if it has the shorter life cycle.
These 3 reqs use the same paged results array slot.
req0: <--------------><----x
page1 page2
req1: <----->
req2: <------->
frees search result object of req0
Reviewed by [email protected] (Thank you, Rich!!)
(cherry picked from commit 3cf85d1ad6cbc0feac5578dee5ce259c0f65055f)
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 272e55068..1d454b75d 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -408,6 +408,51 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
*/
operation_set_target_spec (pb->pb_op, basesdn);
+ if (be_name == NULL)
+ {
+ /* no specific backend was requested, use the mapping tree
+ */
+ err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf);
+ if (((err_code != LDAP_SUCCESS) && (err_code != LDAP_OPERATIONS_ERROR) && (err_code != LDAP_REFERRAL))
+ || ((err_code == LDAP_OPERATIONS_ERROR) && (be_list[0] == NULL)))
+ {
+ send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
+ rc = -1;
+ goto free_and_return;
+ }
+ if (be_list[0] != NULL)
+ {
+ index = 0;
+ if (pr_be) { /* PAGED RESULT: be is found from the previous paging. */
+ /* move the index in the be_list which matches pr_be */
+ while (be_list[index] && be_list[index+1] && pr_be != be_list[index])
+ index++;
+ } else {
+ while (be_list[index] && be_list[index+1])
+ index++;
+ }
+ /* "be" is either pr_be or the last backend */
+ be = be_list[index];
+ }
+ else
+ be = pr_be?pr_be:NULL;
+ }
+ else
+ {
+ /* specific backend be_name was requested, use slapi_be_select_by_instance_name
+ */
+ if (pr_be) {
+ be_single = be = pr_be;
+ } else {
+ be_single = be = slapi_be_select_by_instance_name(be_name);
+ }
+ if (be_single)
+ slapi_be_Rlock(be_single);
+ be_list[0] = NULL;
+ referral_list[0] = NULL;
+ referral = NULL;
+ }
+
/* this is time to check if mapping tree specific control
* was used to specify that we want to parse only
* one backend
@@ -478,8 +523,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
if ( slapi_control_present (ctrlp, LDAP_CONTROL_PAGEDRESULTS,
&ctl_value, &iscritical) )
{
- rc = pagedresults_parse_control_value(pb, ctl_value,
- &pagesize, &pr_idx);
+ rc = pagedresults_parse_control_value(pb, ctl_value, &pagesize, &pr_idx, be);
/* Let's set pr_idx even if it fails; in case, pr_idx == -1. */
slapi_pblock_set(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
if ((LDAP_SUCCESS == rc) ||
@@ -520,51 +564,6 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
}
- if (be_name == NULL)
- {
- /* no specific backend was requested, use the mapping tree
- */
- err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf);
- if (((err_code != LDAP_SUCCESS) && (err_code != LDAP_OPERATIONS_ERROR) && (err_code != LDAP_REFERRAL))
- || ((err_code == LDAP_OPERATIONS_ERROR) && (be_list[0] == NULL)))
- {
- send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
- rc = -1;
- goto free_and_return;
- }
- if (be_list[0] != NULL)
- {
- index = 0;
- if (pr_be) { /* PAGED RESULT: be is found from the previous paging. */
- /* move the index in the be_list which matches pr_be */
- while (be_list[index] && be_list[index+1] && pr_be != be_list[index])
- index++;
- } else {
- while (be_list[index] && be_list[index+1])
- index++;
- }
- /* "be" is either pr_be or the last backend */
- be = be_list[index];
- }
- else
- be = pr_be?pr_be:NULL;
- }
- else
- {
- /* specific backend be_name was requested, use slapi_be_select_by_instance_name
- */
- if (pr_be) {
- be_single = be = pr_be;
- } else {
- be_single = be = slapi_be_select_by_instance_name(be_name);
- }
- if (be_single)
- slapi_be_Rlock(be_single);
- be_list[0] = NULL;
- referral_list[0] = NULL;
- referral = NULL;
- }
-
slapi_pblock_set(pb, SLAPI_BACKEND_COUNT, &index);
if (be)
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index e61c0008e..a3a5fc4fc 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -58,7 +58,7 @@
int
pagedresults_parse_control_value( Slapi_PBlock *pb,
struct berval *psbvp, ber_int_t *pagesize,
- int *index )
+ int *index, Slapi_Backend *be )
{
int rc = LDAP_SUCCESS;
struct berval cookie = {0};
@@ -119,6 +119,7 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
} else {
for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) {
if (!conn->c_pagedresults.prl_list[i].pr_current_be) {
+ conn->c_pagedresults.prl_list[i].pr_current_be = be;
*index = i;
break;
}
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 408543efe..ee32bd028 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1487,7 +1487,7 @@ int slapd_do_all_nss_ssl_init(int slapd_exemode, int importexport_encrypt,
* pagedresults.c
*/
int pagedresults_parse_control_value(Slapi_PBlock *pb, struct berval *psbvp,
- ber_int_t *pagesize, int *index);
+ ber_int_t *pagesize, int *index, Slapi_Backend *be);
void pagedresults_set_response_control(Slapi_PBlock *pb, int iscritical,
ber_int_t estimate,
int curr_search_count, int index);
| 0 |
a25be51e417e3c7b31333edeff861fede376798f
|
389ds/389-ds-base
|
Bug 611790 - fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
https://bugzilla.redhat.com/show_bug.cgi?id=611790
Resolves: bug 611790
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
Fix description: Catch possible NULL pointer in:
- cl5CreateReplayIteratorEx()
- cl5CreateReplayIterator()
- _cl5GetRUV2Purge2()
- _cl5GetOperation()
- _cl5PositionCursorForReplay()
- _cl5NewDBFile()
|
commit a25be51e417e3c7b31333edeff861fede376798f
Author: Endi S. Dewata <[email protected]>
Date: Wed Jul 7 14:58:59 2010 -0500
Bug 611790 - fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
https://bugzilla.redhat.com/show_bug.cgi?id=611790
Resolves: bug 611790
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
Fix description: Catch possible NULL pointer in:
- cl5CreateReplayIteratorEx()
- cl5CreateReplayIterator()
- _cl5GetRUV2Purge2()
- _cl5GetOperation()
- _cl5PositionCursorForReplay()
- _cl5NewDBFile()
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index ece4d2737..33536086c 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -1805,17 +1805,12 @@ int cl5CreateReplayIteratorEx (Private_Repl_Protocol *prp, const RUV *consumerRu
rc = _cl5GetDBFile (replica, &obj);
- if (rc == CL5_SUCCESS)
+ if (rc == CL5_SUCCESS && obj)
{
/* iterate through the ruv in csn order to find first master for which
we can replay changes */
rc = _cl5PositionCursorForReplay (consumerRID, consumerRuv, replica, obj, iterator);
- if (rc != CL5_SUCCESS)
- {
- if (obj)
- object_release (obj);
- }
}
else
{
@@ -1825,6 +1820,8 @@ int cl5CreateReplayIteratorEx (Private_Repl_Protocol *prp, const RUV *consumerRu
if (rc != CL5_SUCCESS)
{
+ if (obj) object_release (obj);
+
/* release the thread */
_cl5RemoveThread ();
}
@@ -1869,17 +1866,12 @@ int cl5CreateReplayIterator (Private_Repl_Protocol *prp, const RUV *consumerRuv,
rc = _cl5GetDBFile (replica, &obj);
- if (rc == CL5_SUCCESS)
+ if (rc == CL5_SUCCESS && obj)
{
/* iterate through the ruv in csn order to find first master for which
we can replay changes */
ReplicaId consumerRID = agmt_get_consumer_rid ( prp->agmt, prp->conn );
rc = _cl5PositionCursorForReplay (consumerRID, consumerRuv, replica, obj, iterator);
- if (rc != CL5_SUCCESS)
- {
- if (obj)
- object_release (obj);
- }
}
else
{
@@ -1889,6 +1881,8 @@ int cl5CreateReplayIterator (Private_Repl_Protocol *prp, const RUV *consumerRuv,
if (rc != CL5_SUCCESS)
{
+ if (obj) object_release (obj);
+
/* release the thread */
_cl5RemoveThread ();
}
@@ -4785,11 +4779,22 @@ static int _cl5GetRUV2Purge2 (Object *fileObj, RUV **ruv)
PR_ASSERT (fileObj && ruv);
+ if (!ruv) {
+ rc = CL5_UNKNOWN_ERROR;
+ goto done;
+ }
+
dbFile = (CL5DBFile*)object_get_data (fileObj);
PR_ASSERT (dbFile);
rObj = replica_get_by_name (dbFile->replName);
PR_ASSERT (rObj);
+
+ if (!rObj) {
+ rc = CL5_NOTFOUND;
+ goto done;
+ }
+
r = (Replica*)object_get_data (rObj);
PR_ASSERT (r);
@@ -4840,7 +4845,7 @@ static int _cl5GetRUV2Purge2 (Object *fileObj, RUV **ruv)
{
csn_free (&csn);
}
-
+done:
if (rObj)
object_release (rObj);
@@ -5664,9 +5669,9 @@ static int _cl5GetOperation (Object *replica, slapi_operation_parameters *op)
char csnStr[CSN_STRSIZE];
rc = _cl5GetDBFile (replica, &obj);
- if (rc != CL5_SUCCESS)
+ if (rc != CL5_SUCCESS || !obj)
{
- return rc;
+ goto done;
}
file = (CL5DBFile*)object_get_data (obj);
@@ -5711,7 +5716,7 @@ static int _cl5GetOperation (Object *replica, slapi_operation_parameters *op)
goto done;
}
-done:;
+done:
if (obj)
object_release (obj);
@@ -5799,6 +5804,12 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
/* get supplier's RUV */
supplierRuvObj = replica_get_ruv((Replica*)object_get_data(replica));
PR_ASSERT (supplierRuvObj);
+
+ if (!supplierRuvObj) {
+ rc = CL5_UNKNOWN_ERROR;
+ goto done;
+ }
+
supplierRuv = (RUV*)object_get_data (supplierRuvObj);
PR_ASSERT (supplierRuv);
@@ -6478,6 +6489,12 @@ static int _cl5NewDBFile (const char *replName, const char *replGen, CL5DBFile**
PR_ASSERT (replName && replGen && dbFile);
+ if (!dbFile) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5NewDBFile: NULL dbFile\n");
+ return CL5_UNKNOWN_ERROR;
+ }
+
(*dbFile) = (CL5DBFile *)slapi_ch_calloc (1, sizeof (CL5DBFile));
if (*dbFile == NULL)
{
@@ -6626,8 +6643,7 @@ out:
done:
if (rc != CL5_SUCCESS)
{
- if (dbFile)
- _cl5DBCloseFile ((void**)dbFile);
+ _cl5DBCloseFile ((void**)dbFile);
/* slapi_ch_free accepts NULL pointer */
slapi_ch_free ((void**)&name);
| 0 |
370a70c431d5f235d4371e4cb080215ac4500b6c
|
389ds/389-ds-base
|
Bugzilla: 1368956 man page of ns-accountstatus.pl shows redundant entries for -p port option
Bug Description:
Description of problem:
man page of ns-accountstatus.pl contain redundant entries for -p option
-p port
Port number of the Directory Server.
-p port
Port number of the Directory Server.
-p port
Port number of the Directory Server.
Fix Description:
Delete the redundant entrys
Platforms tested: RHEL7.3
Flag Day: no
Doc impact: yes
Signed-off-by: kamlesh <[email protected]>
|
commit 370a70c431d5f235d4371e4cb080215ac4500b6c
Author: kamlesh <[email protected]>
Date: Mon Aug 22 14:20:27 2016 +0530
Bugzilla: 1368956 man page of ns-accountstatus.pl shows redundant entries for -p port option
Bug Description:
Description of problem:
man page of ns-accountstatus.pl contain redundant entries for -p option
-p port
Port number of the Directory Server.
-p port
Port number of the Directory Server.
-p port
Port number of the Directory Server.
Fix Description:
Delete the redundant entrys
Platforms tested: RHEL7.3
Flag Day: no
Doc impact: yes
Signed-off-by: kamlesh <[email protected]>
diff --git a/man/man8/ns-accountstatus.pl.8 b/man/man8/ns-accountstatus.pl.8
index be3a8e900..9ffc4d3e6 100644
--- a/man/man8/ns-accountstatus.pl.8
+++ b/man/man8/ns-accountstatus.pl.8
@@ -57,12 +57,6 @@ Host name of the Directory Server.
.B \fB\-p\fR \fIport\fR
Port number of the Directory Server.
.TP
-.B \fB\-p\fR \fIport\fR
-Port number of the Directory Server.
-.TP
-.B \fB\-p\fR \fIport\fR
-Port number of the Directory Server.
-.TP
.B \fB\-b\fR \fIbasedn\fR
The suffix DN from which to search from.
.TP
| 0 |
5e383c8152d1273ff3df11578d4c9a94850ca60a
|
389ds/389-ds-base
|
Ticket 46918 - Fix compiler warnings on arm
Description: On "arm" architecture there were many compiler warnings
and after fixing some it also adressed a crash in replication
when trying to update the agreement maxcsn.
All updatream architectures build without compilar warnings,
and coverity scan did not report any regressions.
https://pagure.io/389-ds-base/issue/49618
Reviewed by: simon(Thanks!)
|
commit 5e383c8152d1273ff3df11578d4c9a94850ca60a
Author: Mark Reynolds <[email protected]>
Date: Wed Mar 28 14:28:42 2018 -0400
Ticket 46918 - Fix compiler warnings on arm
Description: On "arm" architecture there were many compiler warnings
and after fixing some it also adressed a crash in replication
when trying to update the agreement maxcsn.
All updatream architectures build without compilar warnings,
and coverity scan did not report any regressions.
https://pagure.io/389-ds-base/issue/49618
Reviewed by: simon(Thanks!)
diff --git a/ldap/servers/plugins/posix-winsync/posix-winsync.c b/ldap/servers/plugins/posix-winsync/posix-winsync.c
index 07e48048c..8e5ca4fff 100644
--- a/ldap/servers/plugins/posix-winsync/posix-winsync.c
+++ b/ldap/servers/plugins/posix-winsync/posix-winsync.c
@@ -318,7 +318,7 @@ sync_acct_disable(void *cbdata __attribute__((unused)), /* the usual domain conf
mask = 0x2;
adval |= mask; /* set the 0x2 disable bit */
}
- PR_snprintf(acctvalstr, sizeof(acctvalstr), "%lu", adval);
+ PR_snprintf(acctvalstr, sizeof(acctvalstr), "%" PRIu64, adval);
slapi_ch_free_string(&mod_bval->bv_val);
mod_bval->bv_val = slapi_ch_strdup(acctvalstr);
mod_bval->bv_len = strlen(acctvalstr);
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c
index d71d3f38b..9c88d58bb 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -182,25 +182,25 @@ agmt_is_valid(Repl_Agmt *ra)
}
if (ra->port <= 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid port number %ld.\n",
+ "is malformed: invalid port number %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->port);
return_value = 0;
}
if (ra->timeout < 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid timeout %ld.\n",
+ "is malformed: invalid timeout %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->timeout);
return_value = 0;
}
if (ra->busywaittime < 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid busy wait time %ld.\n",
+ "is malformed: invalid busy wait time %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->busywaittime);
return_value = 0;
}
if (ra->pausetime < 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid pausetime %ld.\n",
+ "is malformed: invalid pausetime %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->pausetime);
return_value = 0;
}
@@ -468,7 +468,7 @@ agmt_new_from_entry(Slapi_Entry *e)
if (dot) {
*dot = '\0';
}
- ra->long_name = slapi_ch_smprintf("agmt=\"%s\" (%s:%ld)", agmtname, hostname, ra->port);
+ ra->long_name = slapi_ch_smprintf("agmt=\"%s\" (%s:%" PRId64 ")", agmtname, hostname, ra->port);
}
/* DBDB: review this code */
@@ -791,10 +791,10 @@ agmt_start(Repl_Agmt *ra)
char buf[BUFSIZ];
char unavail_buf[BUFSIZ];
- PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%ld;", slapi_sdn_get_dn(repl_sdn),
+ PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";", slapi_sdn_get_dn(repl_sdn),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
- PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%ld;unavailable", slapi_sdn_get_dn(repl_sdn),
+ PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";unavailable", slapi_sdn_get_dn(repl_sdn),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
if (strstr(maxcsns[i], buf) || strstr(maxcsns[i], unavail_buf)) {
@@ -3029,11 +3029,11 @@ agmt_update_maxcsn(Replica *r, Slapi_DN *sdn, int op, LDAPMod **mods, CSN *csn)
* temporarily mark it as "unavailable".
*/
slapi_ch_free_string(&agmt->maxcsn);
- agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%ld;unavailable", slapi_sdn_get_dn(agmt->replarea),
+ agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%" PRId64 ";unavailable", slapi_sdn_get_dn(agmt->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(agmt->rdn)), agmt->hostname, agmt->port);
} else if (rid == oprid) {
slapi_ch_free_string(&agmt->maxcsn);
- agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%ld;%d;%s", slapi_sdn_get_dn(agmt->replarea),
+ agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%" PRId64 ";%" PRIu16 ";%s", slapi_sdn_get_dn(agmt->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(agmt->rdn)), agmt->hostname,
agmt->port, agmt->consumerRID, maxcsn);
}
@@ -3227,10 +3227,10 @@ agmt_remove_maxcsn(Repl_Agmt *ra)
char unavail_buf[BUFSIZ];
struct berval val;
- PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%ld;", slapi_sdn_get_dn(ra->replarea),
+ PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";", slapi_sdn_get_dn(ra->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
- PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%ld;unavailable",
+ PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";unavailable",
slapi_sdn_get_dn(ra->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 5473d5b6c..2738b7a12 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -72,8 +72,8 @@ struct replica
typedef struct reap_callback_data
{
int rc;
- unsigned long num_entries;
- unsigned long num_purged_entries;
+ uint64_t num_entries;
+ uint64_t num_purged_entries;
CSN *purge_csn;
PRBool *tombstone_reap_stop;
} reap_callback_data;
@@ -1897,7 +1897,7 @@ _replica_init_from_config(Replica *r, Slapi_Entry *e, char *errortext)
/* Verify backoff min and max work together */
if (backoff_min > backoff_max) {
PR_snprintf(errormsg, SLAPI_DSE_RETURNTEXT_SIZE,
- "Backoff minimum (%ld) can not be greater than the backoff maximum (%ld).",
+ "Backoff minimum (%" PRId64 ") can not be greater than the backoff maximum (%" PRId64 ").",
backoff_min, backoff_max);
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_replica_init_from_config - "
"%s\n", errormsg);
@@ -2996,8 +2996,8 @@ process_reap_entry(Slapi_Entry *entry, void *cb_data)
{
char deletion_csn_str[CSN_STRSIZE];
char purge_csn_str[CSN_STRSIZE];
- unsigned long *num_entriesp = &((reap_callback_data *)cb_data)->num_entries;
- unsigned long *num_purged_entriesp = &((reap_callback_data *)cb_data)->num_purged_entries;
+ uint64_t *num_entriesp = &((reap_callback_data *)cb_data)->num_entries;
+ uint64_t *num_purged_entriesp = &((reap_callback_data *)cb_data)->num_purged_entries;
CSN *purge_csn = ((reap_callback_data *)cb_data)->purge_csn;
/* this is a pointer into the actual value in the Replica object - so that
if the value is set in the replica, we will know about it immediately */
@@ -3181,14 +3181,14 @@ _replica_reap_tombstones(void *arg)
if (LDAP_SUCCESS != oprc) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
"_replica_reap_tombstones - Failed when searching for "
- "tombstones in replica %s: %s. Will try again in %ld "
+ "tombstones in replica %s: %s. Will try again in %" PRId64 " "
"seconds.\n",
slapi_sdn_get_dn(replica->repl_root),
ldap_err2string(oprc), replica->tombstone_reap_interval);
} else {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "_replica_reap_tombstones - Purged %ld of %ld tombstones "
- "in replica %s. Will try again in %ld "
+ "_replica_reap_tombstones - Purged %" PRIu64 " of %" PRIu64 " tombstones "
+ "in replica %s. Will try again in %" PRId64 " "
"seconds.\n",
cb_data.num_purged_entries, cb_data.num_entries,
slapi_sdn_get_dn(replica->repl_root),
@@ -3617,7 +3617,7 @@ replica_set_tombstone_reap_interval(Replica *r, long interval)
found = slapi_eq_cancel(r->repl_eqcxt_tr);
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%ld) was %s\n",
+ "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%" PRId64 ") was %s\n",
r->tombstone_reap_interval, (found ? "cancelled" : "not found"));
r->repl_eqcxt_tr = NULL;
}
@@ -3627,7 +3627,7 @@ replica_set_tombstone_reap_interval(Replica *r, long interval)
slapi_current_utc_time() + r->tombstone_reap_interval,
1000 * r->tombstone_reap_interval);
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%ld) was %s\n",
+ "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%" PRId64 ") was %s\n",
r->tombstone_reap_interval, (r->repl_eqcxt_tr ? "scheduled" : "not scheduled successfully"));
}
replica_unlock(r->repl_lock);
diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c
index 7cc132362..a852f241b 100644
--- a/ldap/servers/plugins/replication/replutil.c
+++ b/ldap/servers/plugins/replication/replutil.c
@@ -1076,7 +1076,7 @@ repl_config_valid_num(const char *config_attr, char *config_attr_value, int64_t
*returncode = LDAP_UNWILLING_TO_PERFORM;
if (errortext){
PR_snprintf(errortext, SLAPI_DSE_RETURNTEXT_SIZE,
- "Attribute %s value (%s) is invalid, must be a number between %ld and %ld.",
+ "Attribute %s value (%s) is invalid, must be a number between %" PRId64 " and %" PRId64 ".",
config_attr, config_attr_value, min, max);
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "repl_config_valid_num - %s\n",
errortext);
diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c
index e2237e5fc..3f7bef018 100644
--- a/ldap/servers/slapd/abandon.c
+++ b/ldap/servers/slapd/abandon.c
@@ -148,7 +148,7 @@ do_abandon(Slapi_PBlock *pb)
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d ABANDON"
" targetop=%d msgid=%d nentries=%d etime=%" PRId64 ".%010" PRId64 "\n",
pb_conn->c_connid, pb_op->o_opid, o->o_opid, id,
- o->o_results.r.r_search.nentries, o_hr_time_end.tv_sec, o_hr_time_end.tv_nsec);
+ o->o_results.r.r_search.nentries, (int64_t)o_hr_time_end.tv_sec, (int64_t)o_hr_time_end.tv_nsec);
}
PR_ExitMonitor(pb_conn->c_mutex);
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h
index d2b25a7ea..ffc803e89 100644
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
@@ -351,7 +351,7 @@ struct backdn
ID ep_id; /* entry id */
char ep_state; /* state in the cache; share ENTRY_STATE_* */
int ep_refcnt; /* entry reference cnt */
- size_t ep_size; /* for cache tracking */
+ uint64_t ep_size; /* for cache tracking */
Slapi_DN *dn_sdn;
void *dn_id_link; /* for hash table */
};
@@ -359,10 +359,10 @@ struct backdn
/* for the in-core cache of entries */
struct cache
{
- size_t c_maxsize; /* max size in bytes */
+ uint64_t c_maxsize; /* max size in bytes */
Slapi_Counter *c_cursize; /* size in bytes */
- long c_maxentries; /* max entries allowed (-1: no limit) */
- long c_curentries; /* current # entries in cache */
+ uint64_t c_maxentries; /* max entries allowed (-1: no limit) */
+ uint64_t c_curentries; /* current # entries in cache */
Hashtable *c_dntable;
Hashtable *c_idtable;
#ifdef UUIDCACHE_ON
@@ -551,63 +551,45 @@ struct ldbminfo
int li_allidsthreshold;
char *li_directory;
int li_reslimit_lookthrough_handle;
- size_t li_dbcachesize;
+ uint64_t li_dbcachesize;
int li_dblock;
int li_dbncache;
- int li_import_cache_autosize; /* % of free memory to use
- * for the import caches
- * (-1=default, 80% on cmd import)
- * (0 = off) -- overrides
- * import cache size settings */
- int li_cache_autosize; /* % of free memory to use
- * for the combined caches
- * (0 = off) -- overrides
- * other cache size settings */
- int li_cache_autosize_split; /* % of li_cache_autosize to
- * use for the libdb cache.
- * the rest is split up among
- * the instance entry caches */
- uint64_t li_cache_autosize_ec; /* new instances created while
- * the server is up, should
- * use this as the entry cache
- * size (0 = autosize off) */
+ int li_import_cache_autosize; /* % of free memory to use for the import caches
+ * (-1=default, 80% on cmd import)
+ * (0 = off) -- overrides import cache size settings */
+ int li_cache_autosize; /* % of free memory to use for the combined caches
+ * (0 = off) -- overrides other cache size settings */
+ int li_cache_autosize_split; /* % of li_cache_autosize to use for the libdb cache.
+ * the rest is split up among the instance entry caches */
+ uint64_t li_cache_autosize_ec; /* new instances created while the server is up, should
+ * use this as the entry cache size (0 = autosize off) */
uint64_t li_dncache_autosize_ec; /* Same as above, but dncache. */
- size_t li_import_cachesize; /* size of the mpool for
- * imports */
+ uint64_t li_import_cachesize; /* size of the mpool for imports */
PRLock *li_dbcache_mutex;
PRCondVar *li_dbcache_cv;
- int li_shutdown; /* flag to tell any BE threads
- * to end */
+ int li_shutdown; /* flag to tell any BE threads to end */
PRLock *li_shutdown_mutex; /* protect shutdown flag */
dblayer_private *li_dblayer_private; /* session ptr for databases */
- int li_noparentcheck; /* check if parent exists on
- * add */
+ int li_noparentcheck; /* check if parent exists on add */
/* the next 3 fields are for the params that don't get changed until
* the server is restarted (used by the admin console)
*/
char *li_new_directory;
- size_t li_new_dbcachesize;
+ uint64_t li_new_dbcachesize;
int li_new_dblock;
int li_new_dbncache;
db_upgrade_info *upgrade_info;
- int li_filter_bypass; /* bypass filter testing,
- * when possible */
- int li_filter_bypass_check; /* check that filter bypass
- * is doing the right thing */
- int li_use_vlv; /* use vlv indexes to short-
- * circuit matches when
- * possible */
- void *li_identity; /* The ldbm plugin needs to keep
- * track of its identity so it can
- * perform internal ops. Its
- * identity is given to it when
- * its init function is called. */
-
- Objset *li_instance_set; /* A set containing the ldbm
- * instances. */
+ int li_filter_bypass; /* bypass filter testing, when possible */
+ int li_filter_bypass_check; /* check that filter bypass is doing the right thing */
+ int li_use_vlv; /* use vlv indexes to short-circuit matches when possible */
+ void *li_identity; /* The ldbm plugin needs to keep track of its identity so it can
+ * perform internal ops. Its identity is given to it when
+ * its init function is called. */
+
+ Objset *li_instance_set; /* A set containing the ldbm instances. */
PRLock *li_config_mutex;
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
index ee20dc312..77757c2ac 100644
--- a/ldap/servers/slapd/back-ldbm/cache.c
+++ b/ldap/servers/slapd/back-ldbm/cache.c
@@ -183,7 +183,7 @@ new_hash(u_long size, u_long offset, HashFn hfn, HashTestFn tfn)
* already there (filled into 'alt' if 'alt' is not NULL)
*/
int
-add_hash(Hashtable *ht, void *key, size_t keylen, void *entry, void **alt)
+add_hash(Hashtable *ht, void *key, uint32_t keylen, void *entry, void **alt)
{
u_long val, slot;
void *e;
@@ -209,7 +209,7 @@ add_hash(Hashtable *ht, void *key, size_t keylen, void *entry, void **alt)
/* returns 1 if the item was found, and puts a ptr to it in 'entry' */
int
-find_hash(Hashtable *ht, const void *key, size_t keylen, void **entry)
+find_hash(Hashtable *ht, const void *key, uint32_t keylen, void **entry)
{
u_long val, slot;
void *e;
@@ -231,7 +231,7 @@ find_hash(Hashtable *ht, const void *key, size_t keylen, void **entry)
/* returns 1 if the item was found and removed */
int
-remove_hash(Hashtable *ht, const void *key, size_t keylen)
+remove_hash(Hashtable *ht, const void *key, uint32_t keylen)
{
u_long val, slot;
void *e, *laste = NULL;
@@ -494,7 +494,7 @@ cache_make_hashes(struct cache *cache, int type)
/* initialize the cache */
int
-cache_init(struct cache *cache, size_t maxsize, long maxentries, int type)
+cache_init(struct cache *cache, uint64_t maxsize, uint64_t maxentries, int type)
{
slapi_log_err(SLAPI_LOG_TRACE, "cache_init", "-->\n");
cache->c_maxsize = maxsize;
@@ -598,7 +598,7 @@ entrycache_clear_int(struct cache *cache)
cache->c_maxsize = size;
if (cache->c_curentries > 0) {
slapi_log_err(SLAPI_LOG_WARNING,
- "entrycache_clear_int", "There are still %ld entries "
+ "entrycache_clear_int", "There are still %" PRIu64 " entries "
"in the entry cache.\n",
cache->c_curentries);
#ifdef LDAP_CACHE_DEBUG
@@ -648,7 +648,7 @@ cache_destroy_please(struct cache *cache, int type)
}
void
-cache_set_max_size(struct cache *cache, size_t bytes, int type)
+cache_set_max_size(struct cache *cache, uint64_t bytes, int type)
{
if (CACHE_TYPE_ENTRY == type) {
entrycache_set_max_size(cache, bytes);
@@ -773,7 +773,7 @@ cache_entry_size(struct backentry *e)
* these u_long *'s to a struct
*/
void
-cache_get_stats(struct cache *cache, PRUint64 *hits, PRUint64 *tries, long *nentries, long *maxentries, size_t *size, size_t *maxsize)
+cache_get_stats(struct cache *cache, PRUint64 *hits, PRUint64 *tries, uint64_t *nentries, uint64_t *maxentries, uint64_t *size, uint64_t *maxsize)
{
cache_lock(cache);
if (hits)
@@ -1580,7 +1580,7 @@ dncache_clear_int(struct cache *cache)
cache->c_maxsize = size;
if (cache->c_curentries > 0) {
slapi_log_err(SLAPI_LOG_WARNING,
- "dncache_clear_int", "There are still %ld dn's "
+ "dncache_clear_int", "There are still %" PRIu64 " dn's "
"in the dn cache. :/\n",
cache->c_curentries);
}
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 5d870e364..5ab2211ac 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -822,10 +822,10 @@ dblayer_dump_config_tracing(dblayer_private *priv)
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "dbhome_directory=%s\n", priv->dblayer_dbhome_directory);
}
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "trickle_percentage=%d\n", priv->dblayer_trickle_percentage);
- slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "page_size=%lu\n", priv->dblayer_page_size);
- slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "index_page_size=%lu\n", priv->dblayer_index_page_size);
- slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "cachesize=%lu\n", priv->dblayer_cachesize);
- slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "previous_cachesize=%lu\n", priv->dblayer_previous_cachesize);
+ slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "page_size=%" PRIu32 "\n", priv->dblayer_page_size);
+ slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "index_page_size=%" PRIu32 "\n", priv->dblayer_index_page_size);
+ slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "cachesize=%" PRIu64 "\n", priv->dblayer_cachesize);
+ slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "previous_cachesize=%" PRIu64 "\n", priv->dblayer_previous_cachesize);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "ncache=%d\n", priv->dblayer_ncache);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "previous_ncache=%d\n", priv->dblayer_previous_ncache);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "recovery_required=%d\n", priv->dblayer_recovery_required);
@@ -834,8 +834,8 @@ dblayer_dump_config_tracing(dblayer_private *priv)
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "transaction_batch_val=%d\n", trans_batch_limit);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "circular_logging=%d\n", priv->dblayer_circular_logging);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "idl_divisor=%d\n", priv->dblayer_idl_divisor);
- slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logfile_size=%lu\n", priv->dblayer_logfile_size);
- slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logbuf_size=%lu\n", priv->dblayer_logbuf_size);
+ slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logfile_size=%" PRIu64 "\n", priv->dblayer_logfile_size);
+ slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logbuf_size=%" PRIu64 "\n", priv->dblayer_logbuf_size);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "file_mode=%d\n", priv->dblayer_file_mode);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "cache_config=%d\n", priv->dblayer_cache_config);
slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "lib_version=%d\n", priv->dblayer_lib_version);
@@ -1203,8 +1203,8 @@ no_diskspace(struct ldbminfo *li, int dbenv_flags)
/* Check if we have enough space */
if (fsiz < expected_siz) {
slapi_log_err(SLAPI_LOG_ERR,
- "no_diskspace", "No enough space left on device (%s) (%lu bytes); "
- "at least %lu bytes space is needed for db region files\n",
+ "no_diskspace", "No enough space left on device (%s) (%" PRIu64 " bytes); "
+ "at least %" PRIu64 " bytes space is needed for db region files\n",
region_dir, fsiz, expected_siz);
return 1;
}
@@ -1322,9 +1322,9 @@ dblayer_start(struct ldbminfo *li, int dbmode)
priv->dblayer_cachesize = MINCACHESIZE;
}
/* Oops---looks like the admin misconfigured, let's warn them */
- slapi_log_err(SLAPI_LOG_WARNING, "dblayer_start", "Likely CONFIGURATION ERROR - dbcachesize is configured to use more than the available "
- "memory, decreased to (%" PRIu64 " bytes).\n",
- priv->dblayer_cachesize);
+ slapi_log_err(SLAPI_LOG_WARNING, "dblayer_start",
+ "Likely CONFIGURATION ERROR - dbcachesize is configured to use more than the available "
+ "memory, decreased to (%" PRIu64 " bytes).\n", priv->dblayer_cachesize);
li->li_dbcachesize = priv->dblayer_cachesize;
}
spal_meminfo_destroy(mi);
@@ -1406,7 +1406,7 @@ dblayer_start(struct ldbminfo *li, int dbmode)
(priv->dblayer_lock_config != priv->dblayer_previous_lock_config)) &&
!(dbmode & (DBLAYER_ARCHIVE_MODE | DBLAYER_EXPORT_MODE))) {
if (priv->dblayer_cachesize != priv->dblayer_previous_cachesize) {
- slapi_log_err(SLAPI_LOG_INFO, "dblayer_start", "Resizing db cache size: %lu -> %lu\n",
+ slapi_log_err(SLAPI_LOG_INFO, "dblayer_start", "Resizing db cache size: %" PRIu64 " -> %" PRIu64 "\n",
priv->dblayer_previous_cachesize, priv->dblayer_cachesize);
}
if (priv->dblayer_ncache != priv->dblayer_previous_ncache) {
@@ -1448,8 +1448,9 @@ dblayer_start(struct ldbminfo *li, int dbmode)
if (priv->dblayer_logbuf_size >= 32768) {
pEnv->dblayer_DB_ENV->set_lg_bsize(pEnv->dblayer_DB_ENV, priv->dblayer_logbuf_size);
} else {
- slapi_log_err(SLAPI_LOG_NOTICE, "dblayer_start", "Using default value for log bufsize because configured value (%lu) is too small.\n",
- priv->dblayer_logbuf_size);
+ slapi_log_err(SLAPI_LOG_NOTICE, "dblayer_start",
+ "Using default value for log bufsize because configured value (%" PRIu64 ") is too small.\n",
+ priv->dblayer_logbuf_size);
}
}
@@ -1499,7 +1500,7 @@ dblayer_start(struct ldbminfo *li, int dbmode)
*/
slapi_log_err(SLAPI_LOG_CRIT,
"dblayer_start", "mmap in opening database environment (recovery mode) "
- "failed trying to allocate %lu bytes. (OS err %d - %s)\n",
+ "failed trying to allocate %" PRIu64 " bytes. (OS err %d - %s)\n",
li->li_dbcachesize, return_value, dblayer_strerror(return_value));
dblayer_free_env(&priv->dblayer_env);
priv->dblayer_env = CATASTROPHIC;
@@ -1509,7 +1510,7 @@ dblayer_start(struct ldbminfo *li, int dbmode)
return_value, dblayer_strerror(return_value));
slapi_log_err(SLAPI_LOG_CRIT,
"dblayer_start", "Please make sure there is enough disk space for "
- "dbcache (%lu bytes) and db region files\n",
+ "dbcache (%" PRIu64 " bytes) and db region files\n",
li->li_dbcachesize);
}
return return_value;
@@ -1588,7 +1589,7 @@ dblayer_start(struct ldbminfo *li, int dbmode)
*/
slapi_log_err(SLAPI_LOG_CRIT,
"dblayer_start", "mmap in opening database environment "
- "failed trying to allocate %lu bytes. (OS err %d - %s)\n",
+ "failed trying to allocate %" PRIu64 " bytes. (OS err %d - %s)\n",
li->li_dbcachesize, return_value, dblayer_strerror(return_value));
dblayer_free_env(&priv->dblayer_env);
priv->dblayer_env = CATASTROPHIC;
@@ -1949,7 +1950,7 @@ dblayer_instance_start(backend *be, int mode)
(priv->dblayer_page_size == 0) ? DBLAYER_PAGESIZE : priv->dblayer_page_size);
if (0 != return_value) {
slapi_log_err(SLAPI_LOG_ERR,
- "dblayer_instance_start", "dbp->set_pagesize(%lu or %lu) failed %d\n",
+ "dblayer_instance_start", "dbp->set_pagesize(%" PRIu32 " or %" PRIu32 ") failed %d\n",
priv->dblayer_page_size, DBLAYER_PAGESIZE,
return_value);
goto out;
@@ -1976,7 +1977,7 @@ dblayer_instance_start(backend *be, int mode)
(priv->dblayer_page_size == 0) ? DBLAYER_PAGESIZE : priv->dblayer_page_size);
if (0 != return_value) {
slapi_log_err(SLAPI_LOG_ERR,
- "dblayer_instance_start", "dbp->set_pagesize(%lu or %lu) failed %d\n",
+ "dblayer_instance_start", "dbp->set_pagesize(%" PRIu32 " or %" PRIu32 ") failed %d\n",
priv->dblayer_page_size, DBLAYER_PAGESIZE,
return_value);
goto out;
@@ -2223,7 +2224,7 @@ dblayer_get_aux_id2entry_ext(backend *be, DB **ppDB, DB_ENV **ppEnv, char **path
rval = dbp->set_pagesize(dbp, (priv->dblayer_page_size == 0) ? DBLAYER_PAGESIZE : priv->dblayer_page_size);
if (rval) {
slapi_log_err(SLAPI_LOG_ERR,
- "dblayer_get_aux_id2entry_ext", "dbp->set_pagesize(%lu or %lu) failed %d\n",
+ "dblayer_get_aux_id2entry_ext", "dbp->set_pagesize(%" PRIu32 " or %" PRIu32 ") failed %d\n",
priv->dblayer_page_size, DBLAYER_PAGESIZE, rval);
goto err;
}
@@ -3495,11 +3496,11 @@ dblayer_txn_abort_all(struct ldbminfo *li, back_txn *txn)
return (dblayer_txn_abort_ext(li, txn, PR_TRUE));
}
-size_t
+uint32_t
dblayer_get_optimal_block_size(struct ldbminfo *li)
{
dblayer_private *priv = NULL;
- size_t page_size = 0;
+ uint32_t page_size = 0;
PR_ASSERT(NULL != li);
@@ -3650,7 +3651,7 @@ typedef struct txn_test_iter
DBC *cur;
uint64_t cnt;
const char *attr;
- u_int32_t flags;
+ uint32_t flags;
backend *be;
} txn_test_iter;
@@ -3658,14 +3659,14 @@ typedef struct txn_test_cfg
{
PRUint32 hold_msec;
PRUint32 loop_msec;
- u_int32_t flags;
+ uint32_t flags;
int use_txn;
char **indexes;
int verbose;
} txn_test_cfg;
static txn_test_iter *
-new_txn_test_iter(DB *db, const char *attr, backend *be, u_int32_t flags)
+new_txn_test_iter(DB *db, const char *attr, backend *be, uint32_t flags)
{
txn_test_iter *tti = (txn_test_iter *)slapi_ch_malloc(sizeof(txn_test_iter));
tti->db = db;
@@ -3702,7 +3703,7 @@ free_txn_test_iter(txn_test_iter *tti)
}
static void
-free_ttilist(txn_test_iter ***ttilist, size_t *tticnt)
+free_ttilist(txn_test_iter ***ttilist, uint64_t *tticnt)
{
if (!ttilist || !*ttilist || !**ttilist) {
return;
@@ -3715,7 +3716,7 @@ free_ttilist(txn_test_iter ***ttilist, size_t *tticnt)
}
static void
-init_ttilist(txn_test_iter **ttilist, size_t tticnt)
+init_ttilist(txn_test_iter **ttilist, uint64_t tticnt)
{
if (!ttilist || !*ttilist) {
return;
@@ -3727,12 +3728,12 @@ init_ttilist(txn_test_iter **ttilist, size_t tticnt)
}
static void
-print_ttilist(txn_test_iter **ttilist, size_t tticnt)
+print_ttilist(txn_test_iter **ttilist, uint64_t tticnt)
{
while (tticnt > 0) {
tticnt--;
slapi_log_err(SLAPI_LOG_ERR,
- "txn_test_threadmain", "attr [%s] cnt [%lu]\n",
+ "txn_test_threadmain", "attr [%s] cnt [%" PRIu64 "]\n",
ttilist[tticnt]->attr, ttilist[tticnt]->cnt);
}
}
@@ -3903,7 +3904,7 @@ wait_for_init:
/* phase 1 - open a cursor to each db */
if (cfg.verbose) {
slapi_log_err(SLAPI_LOG_ERR,
- "txn_test_threadmain", "Starting [%lu] indexes\n", tticnt);
+ "txn_test_threadmain", "Starting [%" PRIu64 "] indexes\n", tticnt);
}
for (ii = 0; ii < tticnt; ++ii) {
txn_test_iter *tti = ttilist[ii];
@@ -4015,7 +4016,7 @@ wait_for_init:
init_ttilist(ttilist, tticnt);
if (cfg.verbose) {
slapi_log_err(SLAPI_LOG_ERR,
- "txn_test_threadmain", "Finished [%lu] indexes [%lu] records\n", tticnt, cnt);
+ "txn_test_threadmain", "Finished [%" PRIu64 "] indexes [%" PRIu64 "] records\n", tticnt, cnt);
}
TXN_TEST_LOOP_WAIT(cfg.loop_msec);
} else {
@@ -4612,10 +4613,10 @@ db_atoi(char *str, int *err)
return db_atol(str, err);
}
-unsigned long
+uint32_t
db_strtoul(const char *str, int *err)
{
- unsigned long val = 0, result, multiplier = 1;
+ uint32_t val = 0, result, multiplier = 1;
char *p;
errno = 0;
@@ -4678,6 +4679,72 @@ db_strtoul(const char *str, int *err)
return result;
}
+uint64_t
+db_strtoull(const char *str, int *err)
+{
+ uint64_t val = 0, result, multiplier = 1;
+ char *p;
+ errno = 0;
+
+ /*
+ * manpage of strtoull: Negative values are considered valid input and
+ * are silently converted to the equivalent unsigned long int value.
+ */
+ /* We don't want to make it happen. */
+ for (p = (char *)str; p && *p && (*p == ' ' || *p == '\t'); p++)
+ ;
+ if ('-' == *p) {
+ if (err) {
+ *err = ERANGE;
+ }
+ return val;
+ }
+ val = strtoull(str, &p, 10);
+ if (errno != 0) {
+ if (err) {
+ *err = errno;
+ }
+ return val;
+ }
+
+ switch (*p) {
+ case 'g':
+ case 'G':
+ multiplier *= 1024 * 1024 * 1024;
+ break;
+ case 'm':
+ case 'M':
+ multiplier *= 1024 * 1024;
+ break;
+ case 'k':
+ case 'K':
+ multiplier *= 1024;
+ p++;
+ if (*p == 'b' || *p == 'B') {
+ p++;
+ }
+ if (err) {
+ /* extra chars? */
+ *err = (*p != '\0') ? EINVAL : 0;
+ }
+ break;
+ case '\0':
+ if (err) {
+ *err = 0;
+ }
+ break;
+ default:
+ if (err) {
+ *err = EINVAL;
+ }
+ return val;
+ }
+
+ result = val * multiplier;
+
+ return result;
+}
+
/* functions called directly by the plugin interface from the front-end */
/* Begin transaction */
@@ -7200,9 +7267,9 @@ ldbm_back_get_info(Slapi_Backend *be, int cmd, void **info)
if (li) {
dblayer_private *prv = (dblayer_private *)li->li_dblayer_private;
if (prv && prv->dblayer_index_page_size) {
- *(size_t *)info = prv->dblayer_index_page_size;
+ *(uint32_t *)info = prv->dblayer_index_page_size;
} else {
- *(size_t *)info = DBLAYER_INDEX_PAGESIZE;
+ *(uint32_t *)info = DBLAYER_INDEX_PAGESIZE;
}
rc = 0;
}
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.h b/ldap/servers/slapd/back-ldbm/dblayer.h
index 6fe28d168..5e4433e02 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.h
+++ b/ldap/servers/slapd/back-ldbm/dblayer.h
@@ -28,8 +28,8 @@
#endif /* solaris: mmap */
#endif /* DB_USE_64LFS */
-#define DBLAYER_PAGESIZE (size_t)8 * 1024
-#define DBLAYER_INDEX_PAGESIZE (size_t)8 * 1024 /* With the new idl design, \
+#define DBLAYER_PAGESIZE (uint32_t)8 * 1024
+#define DBLAYER_INDEX_PAGESIZE (uint32_t)8 * 1024 /* With the new idl design, \
the large 8Kbyte pages we use are not optimal. The page pool churns very \
quickly as we add new IDs under a sustained add load. Smaller pages stop \
this happening so much and consequently make us spend less time flushing \
@@ -103,9 +103,9 @@ struct dblayer_private
int dblayer_durable_transactions;
int dblayer_checkpoint_interval;
int dblayer_circular_logging;
- uint64_t dblayer_page_size; /* db page size if configured,
+ uint32_t dblayer_page_size; /* db page size if configured,
* otherwise default to DBLAYER_PAGESIZE */
- uint64_t dblayer_index_page_size; /* db index page size if configured,
+ uint32_t dblayer_index_page_size; /* db index page size if configured,
* otherwise default to
* DBLAYER_INDEX_PAGESIZE */
int dblayer_idl_divisor; /* divide page size by this to get IDL
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c
index e8c3c2008..9a6d33ffd 100644
--- a/ldap/servers/slapd/back-ldbm/filterindex.c
+++ b/ldap/servers/slapd/back-ldbm/filterindex.c
@@ -974,7 +974,7 @@ keys2idl(
IDList *idl = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "keys2idl", "=> type %s indextype %s\n", type, indextype);
- for (size_t i = 0; ivals[i] != NULL; i++) {
+ for (uint32_t i = 0; ivals[i] != NULL; i++) {
IDList *idl2 = NULL;
idl2 = index_read_ext_allids(pb, be, type, indextype, slapi_value_get_berval(ivals[i]), txn, err, unindexed, allidslimit);
@@ -985,8 +985,8 @@ keys2idl(
char buf[BUFSIZ];
slapi_log_err(SLAPI_LOG_TRACE, "keys2idl",
- " ival[%lu] = \"%s\" => %lu IDs\n", i,
- encode(slapi_value_get_berval(ivals[i]), buf), (u_long)IDL_NIDS(idl2));
+ " ival[%" PRIu32 "] = \"%s\" => %" PRIu32 " IDs\n", i,
+ encode(slapi_value_get_berval(ivals[i]), buf), (uint32_t)IDL_NIDS(idl2));
}
#endif
if (idl2 == NULL) {
diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c
index 6c4abc235..7d56d195d 100644
--- a/ldap/servers/slapd/back-ldbm/idl_new.c
+++ b/ldap/servers/slapd/back-ldbm/idl_new.c
@@ -83,10 +83,10 @@ idl_new_get_allidslimit(struct attrinfo *a, int allidslimit)
}
int
-idl_new_exceeds_allidslimit(size_t count, struct attrinfo *a, int allidslimit)
+idl_new_exceeds_allidslimit(uint64_t count, struct attrinfo *a, int allidslimit)
{
- size_t limit = idl_new_get_allidslimit(a, allidslimit);
- return (limit != (size_t)-1) && (count > limit);
+ uint64_t limit = idl_new_get_allidslimit(a, allidslimit);
+ return (limit != (uint64_t)-1) && (count > limit);
}
@@ -138,7 +138,7 @@ idl_new_fetch(
DBT key;
DBT data;
ID id = 0;
- size_t count = 0;
+ uint64_t count = 0;
/* beware that a large buffer on the stack might cause a stack overflow on some platforms */
char buffer[BULK_FETCH_BUFFER_SIZE];
void *ptr;
@@ -245,7 +245,7 @@ idl_new_fetch(
count++;
}
- slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "bulk fetch buffer nids=%lu\n", count);
+ slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "bulk fetch buffer nids=%" PRIu64 "\n", count);
#if defined(DB_ALLIDS_ON_READ)
/* enforce the allids read limit */
if ((NEW_IDL_NO_ALLID != *flag_err) && (NULL != a) &&
@@ -254,7 +254,7 @@ idl_new_fetch(
idl->b_ids[0] = ALLID;
ret = DB_NOTFOUND; /* fool the code below into thinking that we finished the dups */
slapi_log_err(SLAPI_LOG_BACKLDBM, "idl_new_fetch", "Search for key for attribute index %s "
- "exceeded allidslimit %d - count is %lu\n",
+ "exceeded allidslimit %d - count is %" PRIu64 "\n",
a->ai_type, allidslimit, count);
break;
}
@@ -348,7 +348,7 @@ idl_new_range_fetch(
DBT cur_key = {0};
DBT data = {0};
ID id = 0;
- size_t count = 0;
+ uint64_t count = 0;
/* beware that a large buffer on the stack might cause a stack overflow on some platforms */
char buffer[BULK_FETCH_BUFFER_SIZE];
void *ptr;
@@ -522,7 +522,7 @@ idl_new_range_fetch(
}
slapi_log_err(SLAPI_LOG_TRACE, "idl_new_range_fetch",
- "Bulk fetch buffer nids=%lu\n", count);
+ "Bulk fetch buffer nids=%" PRIu64 "\n", count);
#if defined(DB_ALLIDS_ON_READ)
/* enforce the allids read limit */
if ((NEW_IDL_NO_ALLID != *flag_err) && ai && (idl != NULL) &&
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 0419865c9..1be15a42a 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -3563,7 +3563,7 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
slapi_search_internal_pb(srch_pb);
slapi_pblock_get(srch_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
for (ep = entries; ep != NULL && *ep != NULL; ep++) {
- size_t l = strlen(slapi_entry_get_dn_const(*ep)) + 5 /* "dn: \n" */;
+ int32_t l = strlen(slapi_entry_get_dn_const(*ep)) + 5 /* "dn: \n" */;
slapi_log_err(SLAPI_LOG_TRACE, "dse_conf_backup_core",
"dn: %s\n", slapi_entry_get_dn_const(*ep));
@@ -3573,9 +3573,9 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
tp = (char *)slapi_ch_malloc(l); /* should be very rare ... */
sprintf(tp, "dn: %s\n", slapi_entry_get_dn_const(*ep));
prrval = PR_Write(prfd, tp, l);
- if ((size_t)prrval != l) {
+ if (prrval != l) {
slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core",
- "(%s): write %lu failed: %d (%s)\n",
+ "(%s): write %" PRId32 " failed: %d (%s)\n",
filter, l, PR_GetError(), slapd_pr_strerror(PR_GetError()));
rval = -1;
if (l > sizeof(tmpbuf))
@@ -3609,9 +3609,9 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
tp = (char *)slapi_ch_malloc(l);
sprintf(tp, "%s: %s\n", attr_name, attr_val->bv_val);
prrval = PR_Write(prfd, tp, l);
- if ((size_t)prrval != l) {
+ if (prrval != l) {
slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core",
- "(%s): write %lu failed: %d (%s)\n",
+ "(%s): write %" PRId32 " failed: %d (%s)\n",
filter, l, PR_GetError(), slapd_pr_strerror(PR_GetError()));
rval = -1;
if (l > sizeof(tmpbuf))
@@ -3624,9 +3624,9 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
}
if (ep + 1 != NULL && *(ep + 1) != NULL) {
prrval = PR_Write(prfd, "\n", 1);
- if ((int)prrval != 1) {
+ if (prrval != 1) {
slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core",
- "(%s): write %lu failed: %d (%s)\n",
+ "(%s): write %" PRId32 " failed: %d (%s)\n",
filter, l, PR_GetError(), slapd_pr_strerror(PR_GetError()));
rval = -1;
goto out;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 412e1d394..32c8e71ff 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -857,7 +857,7 @@ ldbm_back_add(Slapi_PBlock *pb)
}
retval = parent_update_on_childchange(&parent_modify_c, op, NULL);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add",
- "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, retval);
/* The modify context now contains info needed later */
if (retval) {
@@ -1053,7 +1053,7 @@ ldbm_back_add(Slapi_PBlock *pb)
/* Push out the db modifications from the parent entry */
retval = modify_update_all(be, pb, &parent_modify_c, &txn);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add",
- "conn=%lu op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, retval);
if (DB_LOCK_DEADLOCK == retval) {
slapi_log_err(SLAPI_LOG_ARGS, "ldbm_back_add", "add 6 DEADLOCK\n");
@@ -1177,7 +1177,7 @@ ldbm_back_add(Slapi_PBlock *pb)
/* switch the parent entry copy into play */
myrc = modify_switch_entries(&parent_modify_c, be);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add",
- "conn=%lu op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc);
if (0 == myrc) {
parent_switched = 1;
@@ -1257,7 +1257,7 @@ error_return:
*/
myrc = modify_unswitch_entries(&parent_modify_c, be);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add",
- "conn=%lu op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc);
}
diskfull_return:
@@ -1394,7 +1394,7 @@ common_return:
modify_term(&ruv_c, be);
}
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add",
- "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n",
+ "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry);
myrc = modify_term(&parent_modify_c, be);
done_with_pblock_entry(pb, SLAPI_ADD_EXISTING_DN_ENTRY);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index feb993366..67a647540 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -413,7 +413,7 @@ ldbm_config_dbcachesize_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)(li->li_new_dbcachesize);
+ return (void *)((uintptr_t)li->li_new_dbcachesize);
}
static int
@@ -724,7 +724,7 @@ ldbm_config_db_logbuf_size_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)li->li_dblayer_private->dblayer_logbuf_size;
+ return (void *)((uintptr_t)li->li_dblayer_private->dblayer_logbuf_size);
}
static int
@@ -736,7 +736,7 @@ ldbm_config_db_logbuf_size_set(void *arg,
{
struct ldbminfo *li = (struct ldbminfo *)arg;
int retval = LDAP_SUCCESS;
- size_t val = (size_t)value;
+ uint64_t val = (uint64_t)((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_logbuf_size = val;
@@ -802,7 +802,7 @@ ldbm_config_db_page_size_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)li->li_dblayer_private->dblayer_page_size;
+ return (void *)((uintptr_t)li->li_dblayer_private->dblayer_page_size);
}
static int
@@ -814,7 +814,7 @@ ldbm_config_db_page_size_set(void *arg,
{
struct ldbminfo *li = (struct ldbminfo *)arg;
int retval = LDAP_SUCCESS;
- size_t val = (size_t)value;
+ uint32_t val = (uint32_t)((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_page_size = val;
@@ -828,7 +828,7 @@ ldbm_config_db_index_page_size_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)li->li_dblayer_private->dblayer_index_page_size;
+ return (void *)((uintptr_t)li->li_dblayer_private->dblayer_index_page_size);
}
static int
@@ -840,7 +840,7 @@ ldbm_config_db_index_page_size_set(void *arg,
{
struct ldbminfo *li = (struct ldbminfo *)arg;
int retval = LDAP_SUCCESS;
- size_t val = (size_t)value;
+ uint32_t val = (uint32_t)((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_index_page_size = val;
@@ -913,7 +913,7 @@ ldbm_config_db_logfile_size_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)li->li_dblayer_private->dblayer_logfile_size;
+ return (void *)((uintptr_t)li->li_dblayer_private->dblayer_logfile_size);
}
static int
@@ -925,7 +925,7 @@ ldbm_config_db_logfile_size_set(void *arg,
{
struct ldbminfo *li = (struct ldbminfo *)arg;
int retval = LDAP_SUCCESS;
- size_t val = (size_t)value;
+ uint64_t val = (uint64_t)((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_logfile_size = val;
@@ -1218,12 +1218,12 @@ ldbm_config_db_lock_set(void *arg, void *value, char *errorbuf, int phase, int a
{
struct ldbminfo *li = (struct ldbminfo *)arg;
int retval = LDAP_SUCCESS;
- size_t val = (size_t)value;
+ uint64_t val = (uint64_t)((uintptr_t)value);
if (val < BDB_LOCK_NB_MIN) {
slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: Invalid value for %s (%d). Must be greater than %d\n",
CONFIG_DB_LOCK, val, BDB_LOCK_NB_MIN);
- slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_db_lock_set", "Invalid value for %s (%lu)\n",
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_db_lock_set", "Invalid value for %s (%" PRIu64 ")\n",
CONFIG_DB_LOCK, val);
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -1439,7 +1439,7 @@ ldbm_config_import_cachesize_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)(li->li_import_cachesize);
+ return (void *)((uintptr_t)li->li_import_cachesize);
}
static int
@@ -1450,8 +1450,8 @@ ldbm_config_import_cachesize_set(void *arg,
int apply)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- size_t val = (size_t)value;
- uint64_t delta = (size_t)value;
+ uint64_t val = (uint64_t)((uintptr_t)value);
+ uint64_t delta;
/* There is an error here. We check the new val against our current mem-alloc
* Issue is that we already are using system pages, so while our value *might*
* be valid, we may reject it here due to the current procs page usage.
@@ -1819,7 +1819,7 @@ static config_info ldbm_config[] = {
{CONFIG_MODE, CONFIG_TYPE_INT_OCTAL, "0600", &ldbm_config_mode_get, &ldbm_config_mode_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_IDLISTSCANLIMIT, CONFIG_TYPE_INT, "4000", &ldbm_config_allidsthreshold_get, &ldbm_config_allidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_directory_get, &ldbm_config_directory_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE | CONFIG_FLAG_SKIP_DEFAULT_SETTING},
- {CONFIG_DBCACHESIZE, CONFIG_TYPE_SIZE_T, DEFAULT_CACHE_SIZE_STR, &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_DBCACHESIZE, CONFIG_TYPE_UINT64, DEFAULT_CACHE_SIZE_STR, &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_DBNCACHE, CONFIG_TYPE_INT, "0", &ldbm_config_dbncache_get, &ldbm_config_dbncache_set, CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_MAXPASSBEFOREMERGE, CONFIG_TYPE_INT, "100", &ldbm_config_maxpassbeforemerge_get, &ldbm_config_maxpassbeforemerge_set, 0},
@@ -1839,7 +1839,7 @@ static config_info ldbm_config[] = {
{CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0},
{CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0},
{CONFIG_DB_OLD_IDL_MAXIDS, CONFIG_TYPE_INT, "0", &ldbm_config_db_old_idl_maxids_get, &ldbm_config_db_old_idl_maxids_set, 0},
- {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0},
+ {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_UINT64, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0},
{CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0},
{CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0},
{CONFIG_DB_VERBOSE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_verbose_get, &ldbm_config_db_verbose_set, 0},
@@ -1856,7 +1856,7 @@ static config_info ldbm_config[] = {
{CONFIG_IMPORT_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "-1", &ldbm_config_import_cache_autosize_get, &ldbm_config_import_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "10", &ldbm_config_cache_autosize_get, &ldbm_config_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "25", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "16777216", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_UINT64, "16777216", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
{CONFIG_IDL_UPDATE, CONFIG_TYPE_ONOFF, "on", &ldbm_config_idl_get_update, &ldbm_config_idl_set_update, 0},
{CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
@@ -2118,7 +2118,11 @@ ldbm_config_get(void *arg, config_info *config, char *buf)
break;
case CONFIG_TYPE_SIZE_T:
val = (size_t)config->config_get_fn(arg);
- sprintf(buf, "%lu", (long unsigned int)val);
+ sprintf(buf, "%" PRIu32, (uint32_t)val);
+ break;
+ case CONFIG_TYPE_UINT64:
+ val = (uint64_t)((uintptr_t)config->config_get_fn(arg));
+ sprintf(buf, "%" PRIu64, (uint64_t)val);
break;
case CONFIG_TYPE_STRING:
/* Remember the get function for strings returns memory
@@ -2371,6 +2375,34 @@ ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struct be
}
retval = config->config_set_fn(arg, (void *)sz_val, err_buf, phase, apply_mod);
break;
+
+
+ case CONFIG_TYPE_UINT64:
+ if (use_default) {
+ str_val = config->config_default_value;
+ } else {
+ str_val = bval->bv_val;
+ }
+ /* get the value as a size_t value */
+ sz_val = db_strtoull(str_val, &err);
+
+ /* check for parsing error (e.g. not a number) */
+ if (err == EINVAL) {
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
+ str_val, attr_name);
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_set", "Value %s for attr %s is not a number\n",
+ str_val, attr_name);
+ return LDAP_UNWILLING_TO_PERFORM;
+ /* check for overflow */
+ } else if (err == ERANGE) {
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is outside the range of representable values\n",
+ str_val, attr_name);
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_set", "Value %s for attr %s is outside the range of representable values\n",
+ str_val, attr_name);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
+ retval = config->config_set_fn(arg, (void *)sz_val, err_buf, phase, apply_mod);
+ break;
case CONFIG_TYPE_STRING:
if (use_default) {
retval = config->config_set_fn(arg, config->config_default_value, err_buf, phase, apply_mod);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h
index c0f5d3139..29fb7a779 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.h
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h
@@ -18,19 +18,17 @@ struct config_info;
typedef struct config_info config_info;
typedef int config_set_fn_t(void *arg, void *value, char *errorbuf, int phase, int apply);
-typedef void *config_get_fn_t(void *arg);
-/* The value for these is passed around as a
- * void *, the actual value should be gotten
- * by casting the void * as shown below. */
+typedef void *config_get_fn_t(void *arg); /* The value for these is passed around as a
+ * void *, the actual value should be gotten
+ * by casting the void * as shown below. */
#define CONFIG_TYPE_ONOFF 1 /* val = (int) value */
-#define CONFIG_TYPE_STRING 2 /* val = (char *) value - The get functions \
- * for this type must return alloced memory \
- * that should be freed by the caller. */
+#define CONFIG_TYPE_STRING 2 /* val = (char *) value - The get functions for this type
+ * must return alloced memory that should be freed by the caller. */
#define CONFIG_TYPE_INT 3 /* val = (int) value */
#define CONFIG_TYPE_LONG 4 /* val = (long) value */
-#define CONFIG_TYPE_INT_OCTAL 5 /* Same as CONFIG_TYPE_INT, but shown in \
- * octal */
+#define CONFIG_TYPE_INT_OCTAL 5 /* Same as CONFIG_TYPE_INT, but shown in octal */
#define CONFIG_TYPE_SIZE_T 6 /* val = (size_t) value */
+#define CONFIG_TYPE_UINT64 7 /* val = (uint64_t) value */
/* How changes to some config attributes are handled depends on what
* "phase" the server is in. Initialization, reading the config
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index bc0a3654e..3a27fd071 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -211,7 +211,7 @@ ldbm_back_delete(Slapi_PBlock *pb)
CACHE_RETURN(&inst->inst_cache, &tombstone);
if (tombstone) {
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete",
- "conn=%lu op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n",
+ "conn=%" PRIu64 " op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n",
conn_id, op_id, retry_count, slapi_entry_get_dn(tombstone->ep_entry),
tombstone->ep_refcnt, tombstone->ep_state);
}
@@ -220,7 +220,7 @@ ldbm_back_delete(Slapi_PBlock *pb)
tmptombstone = NULL;
} else {
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete",
- "conn=%lu op=%d [retry: %d] No original_tombstone for %s!!\n",
+ "conn=%" PRIu64 " op=%d [retry: %d] No original_tombstone for %s!!\n",
conn_id, op_id, retry_count, slapi_entry_get_dn(e->ep_entry));
}
}
@@ -294,11 +294,11 @@ replace_entry:
if (slapi_entry_has_conflict_children(e->ep_entry, (void *)li->li_identity) > 0) {
ldap_result_message = "Entry has replication conflicts as children";
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete",
- "conn=%lu op=%d Deleting entry %s has replication conflicts as children.\n",
+ "conn=%" PRIu64 " op=%d Deleting entry %s has replication conflicts as children.\n",
conn_id, op_id, slapi_entry_get_dn(e->ep_entry));
} else {
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete",
- "conn=%lu op=%d Deleting entry %s has %d children.\n",
+ "conn=%" PRIu64 " op=%d Deleting entry %s has %d children.\n",
conn_id, op_id, slapi_entry_get_dn(e->ep_entry), retval);
}
retval = -1;
@@ -566,7 +566,7 @@ replace_entry:
/* The modify context now contains info needed later */
if (0 != retval) {
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete",
- "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, retval);
ldap_result_code = LDAP_OPERATIONS_ERROR;
slapi_sdn_done(&parentsdn);
@@ -604,7 +604,7 @@ replace_entry:
if (slapi_entry_attr_hasvalue(e->ep_entry, SLAPI_ATTR_OBJECTCLASS, SLAPI_ATTR_VALUE_TOMBSTONE) &&
slapi_is_special_rdn(edn, RDN_IS_TOMBSTONE)) {
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete",
- "conn=%lu op=%d Turning a tombstone into a tombstone! \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n",
+ "conn=%" PRIu64 " op=%d Turning a tombstone into a tombstone! \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n",
conn_id, op_id, edn, e, e->ep_state, e->ep_refcnt);
ldap_result_code = LDAP_OPERATIONS_ERROR;
retval = -1;
@@ -612,7 +612,7 @@ replace_entry:
}
if (!childuniqueid) {
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete",
- "conn=%lu op=%d No nsUniqueId in the entry \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n",
+ "conn=%" PRIu64 " op=%d No nsUniqueId in the entry \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n",
conn_id, op_id, edn, e, e->ep_state, e->ep_refcnt);
ldap_result_code = LDAP_OPERATIONS_ERROR;
retval = -1;
@@ -743,7 +743,7 @@ replace_entry:
retval = cache_add_tentative(&inst->inst_cache, tombstone, NULL);
if (0 > retval) {
slapi_log_err(SLAPI_LOG_CACHE, "ldbm_back_delete",
- "conn=%lu op=%d tombstone entry %s failed to add to the cache: %d\n",
+ "conn=%" PRIu64 " op=%d tombstone entry %s failed to add to the cache: %d\n",
conn_id, op_id, slapi_entry_get_dn(tombstone->ep_entry), retval);
if (LDBM_OS_ERR_IS_DISKFULL(retval))
disk_full = 1;
@@ -844,7 +844,7 @@ replace_entry:
}
if (0 != retval) {
slapi_log_err(SLAPI_LOG_ERR,
- "ldbm_back_delete", "delete tombsone csn(adding %s) failed, err=%d %s\n",
+ "ldbm_back_delete", "delete tombstone csn(adding %s) failed, err=%d %s\n",
deletion_csn_str,
retval,
(msg = dblayer_strerror(retval)) ? msg : "");
@@ -1148,7 +1148,7 @@ replace_entry:
/* Push out the db modifications from the parent entry */
retval = modify_update_all(be, pb, &parent_modify_c, &txn);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete",
- "conn=%lu op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, retval);
if (DB_LOCK_DEADLOCK == retval) {
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete", "4 DEADLOCK\n");
@@ -1276,7 +1276,7 @@ replace_entry:
/* Replace the old parent entry with the newly modified one */
myrc = modify_switch_entries(&parent_modify_c, be);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete",
- "conn=%lu op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc);
if (myrc == 0) {
parent_switched = 1;
@@ -1435,7 +1435,7 @@ error_return:
*/
myrc = modify_unswitch_entries(&parent_modify_c, be);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete",
- "conn=%lu op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc);
}
@@ -1514,7 +1514,7 @@ diskfull_return:
}
}
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete",
- "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p, in_cache=%d\n",
+ "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p, in_cache=%d\n",
conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry,
cache_is_in_cache(&inst->inst_cache, parent_modify_c.new_entry));
myrc = modify_term(&parent_modify_c, be);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index eb2603897..6f4f4e292 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -110,7 +110,7 @@ ldbm_instance_config_cachememsize_set(void *arg,
{
ldbm_instance *inst = (ldbm_instance *)arg;
int retval = LDAP_SUCCESS;
- size_t val = (size_t)value;
+ uint64_t val = (uint64_t)((uintptr_t)value);
uint64_t delta = 0;
uint64_t delta_original = 0;
@@ -194,7 +194,7 @@ ldbm_instance_config_dncachememsize_set(void *arg,
{
ldbm_instance *inst = (ldbm_instance *)arg;
int retval = LDAP_SUCCESS;
- size_t val = (size_t)value;
+ uint64_t val = (uint64_t)((uintptr_t)value);
uint64_t delta = 0;
/* Do whatever we can to make sure the data is ok. */
@@ -366,11 +366,11 @@ ldbm_instance_config_require_index_set(void *arg,
*----------------------------------------------------------------------*/
static config_info ldbm_instance_config[] = {
{CONFIG_INSTANCE_CACHESIZE, CONFIG_TYPE_LONG, "-1", &ldbm_instance_config_cachesize_get, &ldbm_instance_config_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_INSTANCE_CACHEMEMSIZE, CONFIG_TYPE_SIZE_T, DEFAULT_CACHE_SIZE_STR, &ldbm_instance_config_cachememsize_get, &ldbm_instance_config_cachememsize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_INSTANCE_CACHEMEMSIZE, CONFIG_TYPE_LONG, DEFAULT_CACHE_SIZE_STR, &ldbm_instance_config_cachememsize_get, &ldbm_instance_config_cachememsize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_INSTANCE_READONLY, CONFIG_TYPE_ONOFF, "off", &ldbm_instance_config_readonly_get, &ldbm_instance_config_readonly_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_INSTANCE_REQUIRE_INDEX, CONFIG_TYPE_ONOFF, "off", &ldbm_instance_config_require_index_get, &ldbm_instance_config_require_index_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_INSTANCE_DIR, CONFIG_TYPE_STRING, NULL, &ldbm_instance_config_instance_dir_get, &ldbm_instance_config_instance_dir_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_INSTANCE_DNCACHEMEMSIZE, CONFIG_TYPE_SIZE_T, DEFAULT_DNCACHE_SIZE_STR, &ldbm_instance_config_dncachememsize_get, &ldbm_instance_config_dncachememsize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_INSTANCE_DNCACHEMEMSIZE, CONFIG_TYPE_LONG, DEFAULT_DNCACHE_SIZE_STR, &ldbm_instance_config_dncachememsize_get, &ldbm_instance_config_dncachememsize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{NULL, 0, NULL, NULL, NULL, 0}};
void
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 5b4ea053e..71e2a8fe0 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -713,7 +713,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
ldap_result_code = LDAP_ALREADY_EXISTS;
if (is_resurect_operation) {
slapi_log_err(SLAPI_LOG_CACHE, "ldbm_back_modrdn",
- "conn=%lu op=%d cache_add_tentative failed: %s\n",
+ "conn=%" PRIu64 " op=%d cache_add_tentative failed: %s\n",
conn_id, op_id, slapi_entry_get_dn(ec->ep_entry));
}
goto error_return;
@@ -845,7 +845,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
retval = parent_update_on_childchange(&parent_modify_context,
PARENTUPDATE_DEL, NULL);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, retval);
/* The parent modify context now contains info needed later */
@@ -857,7 +857,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
retval = parent_update_on_childchange(&newparent_modify_context,
PARENTUPDATE_ADD, NULL);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, retval);
/* The newparent modify context now contains info needed later */
if (retval) {
@@ -870,7 +870,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
retval = parent_update_on_childchange(&parent_modify_context, PARENTUPDATE_RESURECT, NULL);
if (retval) {
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d parent_update_on_childchange parent %s of %s failed, rc=%d\n",
+ "conn=%" PRIu64 " op=%d parent_update_on_childchange parent %s of %s failed, rc=%d\n",
conn_id, op_id,
slapi_entry_get_dn_const(parent_modify_context.old_entry->ep_entry),
slapi_entry_get_dn_const(ec->ep_entry), retval);
@@ -1053,7 +1053,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
{
retval = modify_update_all(be, pb, &newparent_modify_context, &txn);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, retval);
if (DB_LOCK_DEADLOCK == retval) {
/* Retry txn */
@@ -1178,7 +1178,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
if (newparententry != NULL) {
myrc = modify_switch_entries(&newparent_modify_context, be);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
+ "conn=%" PRIu64 " op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n",
conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, myrc);
}
@@ -1455,13 +1455,13 @@ common_return:
slapi_sdn_done(&dn_newrdn);
slapi_sdn_done(&dn_parentdn);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n",
+ "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n",
conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry);
myrc = modify_term(&parent_modify_context, be);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d modify_term: rc=%d\n", conn_id, op_id, myrc);
+ "conn=%" PRIu64 " op=%d modify_term: rc=%d\n", conn_id, op_id, myrc);
slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn",
- "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n",
+ "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n",
conn_id, op_id, newparent_modify_context.old_entry, newparent_modify_context.new_entry);
myrc = modify_term(&newparent_modify_context, be);
if (free_modrdn_existing_entry) {
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index f912dca2a..06f2b27c5 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -47,10 +47,9 @@ ldbm_back_monitor_instance_search(Slapi_PBlock *pb __attribute__((unused)),
struct berval val;
struct berval *vals[2];
char buf[BUFSIZ];
- PRUint64 hits, tries;
- int64_t nentries;
- int64_t maxentries;
- size_t size, maxsize;
+ uint64_t hits, tries;
+ uint64_t nentries, maxentries;
+ uint64_t size, maxsize;
/* NPCTE fix for bugid 544365, esc 0. <P.R> <04-Jul-2001> */
struct stat astat;
/* end of NPCTE fix for bugid 544365 */
@@ -89,19 +88,19 @@ ldbm_back_monitor_instance_search(Slapi_PBlock *pb __attribute__((unused)),
/* fetch cache statistics */
cache_get_stats(&(inst->inst_cache), &hits, &tries,
&nentries, &maxentries, &size, &maxsize);
- sprintf(buf, "%lu", (long unsigned int)hits);
+ sprintf(buf, "%" PRIu64, hits);
MSET("entryCacheHits");
- sprintf(buf, "%lu", (long unsigned int)tries);
+ sprintf(buf, "%" PRIu64, tries);
MSET("entryCacheTries");
- sprintf(buf, "%lu", (long unsigned int)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1)));
+ sprintf(buf, "%" PRIu64, (uint64_t)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1)));
MSET("entryCacheHitRatio");
- sprintf(buf, "%lu", (long unsigned int)size);
+ sprintf(buf, "%" PRIu64, size);
MSET("currentEntryCacheSize");
- sprintf(buf, "%lu", (long unsigned int)maxsize);
+ sprintf(buf, "%" PRIu64, maxsize);
MSET("maxEntryCacheSize");
- sprintf(buf, "%" PRId64, nentries);
+ sprintf(buf, "%" PRIu64, nentries);
MSET("currentEntryCacheCount");
- sprintf(buf, "%" PRId64, maxentries);
+ sprintf(buf, "%" PRIu64, maxentries);
MSET("maxEntryCacheCount");
if (entryrdn_get_switch()) {
@@ -112,15 +111,15 @@ ldbm_back_monitor_instance_search(Slapi_PBlock *pb __attribute__((unused)),
MSET("dnCacheHits");
sprintf(buf, "%" PRIu64, tries);
MSET("dnCacheTries");
- sprintf(buf, "%lu", (unsigned long)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1)));
+ sprintf(buf, "%" PRIu64, (uint64_t)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1)));
MSET("dnCacheHitRatio");
- sprintf(buf, "%lu", (long unsigned int)size);
+ sprintf(buf, "%" PRIu64, size);
MSET("currentDnCacheSize");
- sprintf(buf, "%lu", (long unsigned int)maxsize);
+ sprintf(buf, "%" PRIu64, maxsize);
MSET("maxDnCacheSize");
- sprintf(buf, "%" PRId64, nentries);
+ sprintf(buf, "%" PRIu64, nentries);
MSET("currentDnCacheCount");
- sprintf(buf, "%" PRId64, maxentries);
+ sprintf(buf, "%" PRIu64, maxentries);
MSET("maxDnCacheCount");
}
@@ -204,8 +203,8 @@ ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAft
char buf[BUFSIZ];
DB_MPOOL_STAT *mpstat = NULL;
DB_MPOOL_FSTAT **mpfstat = NULL;
- uintmax_t cache_tries;
- int64_t count;
+ uint64_t cache_tries;
+ uint64_t count;
uint64_t hits;
uint64_t tries;
uint64_t size;
@@ -233,7 +232,7 @@ ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAft
/* cache tries*/
cache_tries = (mpstat->st_cache_miss + mpstat->st_cache_hit);
- sprintf(buf, "%lu", cache_tries);
+ sprintf(buf, "%" PRIu64, cache_tries);
MSET("dbCacheTries");
/* cache hit ratio*/
@@ -274,7 +273,7 @@ ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAft
MSET("NormalizedDnCacheThreadSize");
sprintf(buf, "%" PRIu64, slots);
MSET("NormalizedDnCacheThreadSlots");
- sprintf(buf, "%" PRId64, count);
+ sprintf(buf, "%" PRIu64, count);
MSET("currentNormalizedDnCacheCount");
}
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 3327faa16..2898a3529 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -32,14 +32,14 @@ void attr_create_empty(backend *be, char *type, struct attrinfo **ai);
/*
* cache.c
*/
-int cache_init(struct cache *cache, size_t maxsize, long maxentries, int type);
+int cache_init(struct cache *cache, uint64_t maxsize, uint64_t maxentries, int type);
void cache_clear(struct cache *cache, int type);
void cache_destroy_please(struct cache *cache, int type);
-void cache_set_max_size(struct cache *cache, size_t bytes, int type);
+void cache_set_max_size(struct cache *cache, uint64_t bytes, int type);
void cache_set_max_entries(struct cache *cache, long entries);
size_t cache_get_max_size(struct cache *cache);
long cache_get_max_entries(struct cache *cache);
-void cache_get_stats(struct cache *cache, PRUint64 *hits, PRUint64 *tries, long *entries, long *maxentries, size_t *size, size_t *maxsize);
+void cache_get_stats(struct cache *cache, uint64_t *hits, uint64_t *tries, uint64_t *entries, uint64_t *maxentries, uint64_t *size, uint64_t *maxsize);
void cache_debug_hash(struct cache *cache, char **out);
int cache_remove(struct cache *cache, void *e);
void cache_return(struct cache *cache, void **bep);
@@ -61,9 +61,9 @@ void check_entry_cache(struct cache *cache, struct backentry *e);
#endif
Hashtable *new_hash(u_long size, u_long offset, HashFn hfn, HashTestFn tfn);
-int add_hash(Hashtable *ht, void *key, size_t keylen, void *entry, void **alt);
-int find_hash(Hashtable *ht, const void *key, size_t keylen, void **entry);
-int remove_hash(Hashtable *ht, const void *key, size_t keylen);
+int add_hash(Hashtable *ht, void *key, uint32_t keylen, void *entry, void **alt);
+int find_hash(Hashtable *ht, const void *key, uint32_t keylen, void **entry);
+int remove_hash(Hashtable *ht, const void *key, uint32_t keylen);
struct backdn *dncache_find_id(struct cache *cache, ID id);
@@ -99,7 +99,7 @@ int dblayer_read_txn_commit(backend *be, back_txn *txn);
int dblayer_txn_begin_all(struct ldbminfo *li, back_txnid parent_txn, back_txn *txn);
int dblayer_txn_commit_all(struct ldbminfo *li, back_txn *txn);
int dblayer_txn_abort_all(struct ldbminfo *li, back_txn *txn);
-size_t dblayer_get_optimal_block_size(struct ldbminfo *li);
+uint32_t dblayer_get_optimal_block_size(struct ldbminfo *li);
void dblayer_unlock_backend(backend *be);
void dblayer_lock_backend(backend *be);
int dblayer_plugin_begin(Slapi_PBlock *pb);
@@ -126,7 +126,8 @@ int dblayer_get_instance_data_dir(backend *be);
char *dblayer_strerror(int error);
PRInt64 db_atol(char *str, int *err);
PRInt64 db_atoi(char *str, int *err);
-unsigned long db_strtoul(const char *str, int *err);
+uint32_t db_strtoul(const char *str, int *err);
+uint64_t db_strtoull(const char *str, int *err);
int dblayer_set_batch_transactions(void *arg, void *value, char *errorbuf, int phase, int apply);
int dblayer_set_batch_txn_min_sleep(void *arg, void *value, char *errorbuf, int phase, int apply);
int dblayer_set_batch_txn_max_sleep(void *arg, void *value, char *errorbuf, int phase, int apply);
diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c
index 45ed09117..7d0cd2296 100644
--- a/ldap/servers/slapd/back-ldbm/start.c
+++ b/ldap/servers/slapd/back-ldbm/start.c
@@ -177,8 +177,8 @@ ldbm_back_start_autotune(struct ldbminfo *li)
}
}
- slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk physical memory\n", mi->system_total_bytes / 1024);
- slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk available\n", mi->system_available_bytes / 1024);
+ slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %" PRIu64 "k physical memory\n", mi->system_total_bytes / 1024);
+ slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %" PRIu64 "k available\n", mi->system_available_bytes / 1024);
/* We've now calculated the autotuning values. Do we need to apply it?
* we use the logic of "if size is 0, or autosize is > 0. This way three
@@ -193,7 +193,7 @@ ldbm_back_start_autotune(struct ldbminfo *li)
/* First, check the dbcache */
if (li->li_dbcachesize == 0 || li->li_cache_autosize > 0) {
- slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: db cache: %luk\n", db_size / 1024);
+ slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: db cache: %" PRIu64 "k\n", db_size / 1024);
if (db_size < (500 * MEGABYTE)) {
db_size = db_size / 1.25;
}
@@ -223,12 +223,12 @@ ldbm_back_start_autotune(struct ldbminfo *li)
* it's highly unlikely.
*/
if (cache_size == 0 || cache_size == MINCACHESIZE || li->li_cache_autosize > 0) {
- slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s entry cache (%lu total): %luk\n", inst->inst_name, backend_count, entry_size / 1024);
+ slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s entry cache (%" PRIu64 " total): %" PRIu64 "k\n", inst->inst_name, backend_count, entry_size / 1024);
cache_set_max_entries(&(inst->inst_cache), -1);
cache_set_max_size(&(inst->inst_cache), li->li_cache_autosize_ec, CACHE_TYPE_ENTRY);
}
if (dncache_size == 0 || dncache_size == MINCACHESIZE || li->li_cache_autosize > 0) {
- slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s dn cache (%lu total): %luk\n", inst->inst_name, backend_count, dn_size / 1024);
+ slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s dn cache (%" PRIu64 " total): %" PRIu64 "k\n", inst->inst_name, backend_count, dn_size / 1024);
cache_set_max_entries(&(inst->inst_dncache), -1);
cache_set_max_size(&(inst->inst_dncache), li->li_dncache_autosize_ec, CACHE_TYPE_DN);
}
@@ -389,7 +389,7 @@ ldbm_back_start(Slapi_PBlock *pb)
return return_on_disk_full(li);
else {
if ((li->li_cache_autosize > 0) && (li->li_cache_autosize <= 100)) {
- slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_start", "Failed to allocate %lu byte dbcache. "
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_start", "Failed to allocate %" PRIu64 " byte dbcache. "
"Please reduce the value of %s and restart the server.\n",
li->li_dbcachesize, CONFIG_CACHE_AUTOSIZE);
}
diff --git a/ldap/servers/slapd/ch_malloc.c b/ldap/servers/slapd/ch_malloc.c
index ef436b3e8..75e791135 100644
--- a/ldap/servers/slapd/ch_malloc.c
+++ b/ldap/servers/slapd/ch_malloc.c
@@ -109,21 +109,16 @@ slapi_ch_malloc(
/* See slapi-plugin.h */
char *
-slapi_ch_memalign(size_t size, size_t alignment)
+slapi_ch_memalign(uint32_t size, uint32_t alignment)
{
char *newmem;
- if (size <= 0) {
- log_negative_alloc_msg("memalign", "bytes", size);
- return 0;
- }
-
if (posix_memalign((void **)&newmem, alignment, size) != 0) {
int oserr = errno;
oom_occurred();
slapi_log_err(SLAPI_LOG_ERR, SLAPD_MODULE,
- "malloc of %lu bytes failed; OS error %d (%s)%s\n",
+ "malloc of %" PRIu32 " bytes failed; OS error %d (%s)%s\n",
size, oserr, slapd_system_strerror(oserr), oom_advice);
exit(1);
}
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index f2f763dfa..4fae1741d 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -416,7 +416,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
bufptr = newbuf;
}
- sprintf(bufptr, "%d:%s:%d:%d:%s%s:%s:%s:%lu:ip=%s",
+ sprintf(bufptr, "%d:%s:%d:%d:%s%s:%s:%s:%" PRIu64 ":ip=%s",
i,
buf2,
ct->c[i].c_opsinitiated,
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index c245a4d4e..3358f34d7 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1087,7 +1087,7 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp)
/* we have exited from ns_thrpool_wait. This means we are shutting down! */
/* Please see https://firstyear.fedorapeople.org/nunc-stans/md_docs_job-safety.html */
/* tldr is shutdown needs to run first to allow job_done on an ARMED job */
- for (size_t i = 0; i < listeners; i++) {
+ for (uint64_t i = 0; i < listeners; i++) {
PRStatus shutdown_status = ns_job_done(listener_idxs[i].ns_job);
if (shutdown_status != PR_SUCCESS) {
slapi_log_err(SLAPI_LOG_CRIT, "ns_set_shutdown", "Failed to shutdown listener idx %" PRIu64 " !\n", i);
@@ -1203,7 +1203,7 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp)
threads = g_get_active_threadcnt();
if (threads > 0) {
slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon",
- "slapd shutting down - waiting for %lu thread%s to terminate\n",
+ "slapd shutting down - waiting for %" PRIu64 " thread%s to terminate\n",
threads, (threads > 1) ? "s" : "");
}
@@ -1240,7 +1240,7 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp)
DS_Sleep(PR_INTERVAL_NO_WAIT);
if (threads != g_get_active_threadcnt()) {
slapi_log_err(SLAPI_LOG_TRACE, "slapd_daemon",
- "slapd shutting down - waiting for %lu threads to terminate\n",
+ "slapd shutting down - waiting for %" PRIu64 " threads to terminate\n",
g_get_active_threadcnt());
threads = g_get_active_threadcnt();
}
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index abc155533..2af3f38fc 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -41,14 +41,14 @@ struct ndn_cache_stats {
Slapi_Counter *cache_count;
Slapi_Counter *cache_size;
Slapi_Counter *cache_evicts;
- size_t max_size;
- size_t thread_max_size;
- size_t slots;
+ uint64_t max_size;
+ uint64_t thread_max_size;
+ uint64_t slots;
};
struct ndn_cache_value {
- size_t size;
- size_t slot;
+ uint64_t size;
+ uint64_t slot;
char *dn;
char *ndn;
struct ndn_cache_value *next;
@@ -64,23 +64,22 @@ struct ndn_cache {
/*
* We keep per thread stats and flush them occasionally
*/
- size_t max_size;
+ uint64_t max_size;
/* Need to track this because we need to provide diffs to counter */
- size_t last_count;
- size_t count;
+ uint64_t last_count;
+ uint64_t count;
/* Number of ops */
- size_t tries;
+ uint64_t tries;
/* hit vs miss. in theroy miss == tries - hits.*/
- size_t hits;
+ uint64_t hits;
/* How many values we kicked out */
- size_t evicts;
+ uint64_t evicts;
/* Need to track this because we need to provide diffs to counter */
- size_t last_size;
- size_t size;
-
- size_t slots;
+ uint64_t last_size;
+ uint64_t size;
+ uint64_t slots;
/*
- * This is used by siphash to prevent hash bugket attacks
+ * This is used by siphash to prevent hash bucket attacks
*/
char key[16];
@@ -3260,7 +3259,7 @@ ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len)
/* stats for monitor */
void
-ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, size_t *thread_size, size_t *evicts, size_t *slots, long *count)
+ndn_cache_get_stats(uint64_t *hits, uint64_t *tries, uint64_t *size, uint64_t *max_size, uint64_t *thread_size, uint64_t *evicts, uint64_t *slots, uint64_t *count)
{
*max_size = t_cache_stats.max_size;
*thread_size = t_cache_stats.thread_max_size;
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index d0865e1b3..4ec447bb8 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -5966,10 +5966,10 @@ config_set_maxsasliosize(const char *attrname, char *value, char *errorbuf, int
return retVal;
}
-size_t
+int32_t
config_get_maxsasliosize()
{
- size_t maxsasliosize;
+ int32_t maxsasliosize;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
maxsasliosize = slapdFrontendConfig->maxsasliosize;
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 521d314a1..1108ad20f 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -688,7 +688,7 @@ main(int argc, char **argv)
} else if (secs > 3600) {
secs = 3600;
}
- printf("slapd pid is %d - sleeping for %ld\n", getpid(), secs);
+ printf("slapd pid is %d - sleeping for %" PRId64 "\n", getpid(), secs);
sleep(secs);
}
}
diff --git a/ldap/servers/slapd/monitor.c b/ldap/servers/slapd/monitor.c
index a281608ec..68c4864c1 100644
--- a/ldap/servers/slapd/monitor.c
+++ b/ldap/servers/slapd/monitor.c
@@ -59,7 +59,7 @@ monitor_info(Slapi_PBlock *pb __attribute__((unused)),
attrlist_replace(&e->e_attrs, "version", vals);
slapi_ch_free((void **)&val.bv_val);
- val.bv_len = snprintf(buf, sizeof(buf), "%lu", g_get_active_threadcnt());
+ val.bv_len = snprintf(buf, sizeof(buf), "%" PRIu64, g_get_active_threadcnt());
val.bv_val = buf;
attrlist_replace(&e->e_attrs, "threads", vals);
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index b13334ad1..4a6b8f0ae 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -491,7 +491,7 @@ char *config_get_referral_mode(void);
int config_get_conntablesize(void);
int config_check_referral_mode(void);
ber_len_t config_get_maxbersize(void);
-size_t config_get_maxsasliosize(void);
+int32_t config_get_maxsasliosize(void);
char *config_get_versionstring(void);
char *config_get_buildnum(void);
int config_get_enquote_sup_oc(void);
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index 6892ccfdc..d9f431cc5 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -1920,7 +1920,7 @@ log_result(Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag, int nentries
struct timespec o_hr_time_end;
slapi_operation_time_elapsed(op, &o_hr_time_end);
- snprintf(etime, ETIME_BUFSIZ, "%" PRId64 ".%010" PRId64 "", o_hr_time_end.tv_sec, o_hr_time_end.tv_nsec);
+ snprintf(etime, ETIME_BUFSIZ, "%" PRId64 ".%010" PRId64 "", (int64_t)o_hr_time_end.tv_sec, (int64_t)o_hr_time_end.tv_nsec);
slapi_pblock_get(pb, SLAPI_OPERATION_NOTES, &operation_notes);
diff --git a/ldap/servers/slapd/sasl_io.c b/ldap/servers/slapd/sasl_io.c
index 5fe37dcb1..751832b12 100644
--- a/ldap/servers/slapd/sasl_io.c
+++ b/ldap/servers/slapd/sasl_io.c
@@ -46,13 +46,13 @@ MOZLDAP is newer than expected, if the ber structure has not changed(see ldap /
struct PRFilePrivate
{
char *decrypted_buffer;
- size_t decrypted_buffer_size;
- size_t decrypted_buffer_count;
- size_t decrypted_buffer_offset;
+ uint32_t decrypted_buffer_size;
+ uint32_t decrypted_buffer_count;
+ uint32_t decrypted_buffer_offset;
char *encrypted_buffer;
- size_t encrypted_buffer_size;
- size_t encrypted_buffer_count;
- size_t encrypted_buffer_offset;
+ uint32_t encrypted_buffer_size;
+ uint32_t encrypted_buffer_count;
+ uint32_t encrypted_buffer_offset;
Connection *conn; /* needed for connid and sasl_conn context */
PRBool send_encrypted; /* can only send encrypted data after the first read -
that is, we cannot send back an encrypted response
@@ -130,7 +130,7 @@ sasl_io_init_buffers(sasl_io_private *sp)
static void
-sasl_io_resize_encrypted_buffer(sasl_io_private *sp, size_t requested_size)
+sasl_io_resize_encrypted_buffer(sasl_io_private *sp, uint32_t requested_size)
{
if (requested_size > sp->encrypted_buffer_size) {
sp->encrypted_buffer = slapi_ch_realloc(sp->encrypted_buffer, requested_size);
@@ -139,7 +139,7 @@ sasl_io_resize_encrypted_buffer(sasl_io_private *sp, size_t requested_size)
}
static void
-sasl_io_resize_decrypted_buffer(sasl_io_private *sp, size_t requested_size)
+sasl_io_resize_decrypted_buffer(sasl_io_private *sp, uint32_t requested_size)
{
if (requested_size > sp->decrypted_buffer_size) {
sp->decrypted_buffer = slapi_ch_realloc(sp->decrypted_buffer, requested_size);
@@ -189,10 +189,10 @@ sasl_io_start_packet(PRFileDesc *fd, PRIntn flags, PRIntervalTime timeout, PRInt
unsigned char buffer[SASL_IO_BUFFER_START_SIZE];
sasl_io_private *sp = sasl_get_io_private(fd);
Connection *c = sp->conn;
- PRInt32 amount = sizeof(buffer);
- PRInt32 ret = 0;
- size_t packet_length = 0;
- size_t saslio_limit;
+ uint32_t amount = sizeof(buffer);
+ uint32_t ret = 0;
+ uint32_t packet_length = 0;
+ int32_t saslio_limit;
*err = 0;
debug_print_layers(fd);
@@ -404,15 +404,15 @@ sasl_io_start_packet(PRFileDesc *fd, PRIntn flags, PRIntervalTime timeout, PRInt
packet_length += sizeof(uint32_t);
slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_start_packet",
- "read sasl packet length %ld on connection %" PRIu64 "\n",
+ "read sasl packet length %" PRIu32 " on connection %" PRIu64 "\n",
packet_length, c->c_connid);
/* Check if the packet length is larger than our max allowed. A
* setting of -1 means that we allow any size SASL IO packet. */
saslio_limit = config_get_maxsasliosize();
- if (((long)saslio_limit != -1) && (packet_length > saslio_limit)) {
+ if ((saslio_limit != -1) && (packet_length > saslio_limit)) {
slapi_log_err(SLAPI_LOG_ERR, "sasl_io_start_packet",
- "SASL encrypted packet length exceeds maximum allowed limit (length=%ld, limit=%ld)."
+ "SASL encrypted packet length exceeds maximum allowed limit (length=%" PRIu32 ", limit=%" PRIu32")."
" Change the nsslapd-maxsasliosize attribute in cn=config to increase limit.\n",
packet_length, config_get_maxsasliosize());
PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);
@@ -434,10 +434,10 @@ sasl_io_read_packet(PRFileDesc *fd, PRIntn flags, PRIntervalTime timeout, PRInt3
PRInt32 ret = 0;
sasl_io_private *sp = sasl_get_io_private(fd);
Connection *c = sp->conn;
- size_t bytes_remaining_to_read = sp->encrypted_buffer_count - sp->encrypted_buffer_offset;
+ uint32_t bytes_remaining_to_read = sp->encrypted_buffer_count - sp->encrypted_buffer_offset;
slapi_log_err(SLAPI_LOG_CONNS,
- "sasl_io_read_packet", "Reading %lu bytes for connection %" PRIu64 "\n",
+ "sasl_io_read_packet", "Reading %" PRIu32" bytes for connection %" PRIu64 "\n",
bytes_remaining_to_read, c->c_connid);
ret = PR_Recv(fd->lower, sp->encrypted_buffer + sp->encrypted_buffer_offset, bytes_remaining_to_read, flags, timeout);
if (ret <= 0) {
@@ -461,17 +461,17 @@ sasl_io_recv(PRFileDesc *fd, void *buf, PRInt32 len, PRIntn flags, PRIntervalTim
{
sasl_io_private *sp = sasl_get_io_private(fd);
Connection *c = sp->conn;
- PRInt32 ret = 0;
- size_t bytes_in_buffer = 0;
- PRInt32 err = 0;
+ int32_t ret = 0;
+ uint32_t bytes_in_buffer = 0;
+ int32_t err = 0;
/* Do we have decrypted data buffered from 'before' ? */
bytes_in_buffer = sp->decrypted_buffer_count - sp->decrypted_buffer_offset;
slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_recv",
- "Connection %" PRIu64 " len %d bytes_in_buffer %lu\n",
+ "Connection %" PRIu64 " len %d bytes_in_buffer %" PRIu32 "\n",
c->c_connid, len, bytes_in_buffer);
slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_recv",
- "Connection %" PRIu64 " len %d encrypted buffer count %lu\n",
+ "Connection %" PRIu64 " len %d encrypted buffer count %" PRIu32 "\n",
c->c_connid, len, sp->encrypted_buffer_count);
if (0 == bytes_in_buffer) {
/* If there wasn't buffered decrypted data, we need to get some... */
@@ -546,7 +546,7 @@ sasl_io_recv(PRFileDesc *fd, void *buf, PRInt32 len, PRIntn flags, PRIntervalTim
}
/* Finally, return data from the buffer to the caller */
{
- size_t bytes_to_return = sp->decrypted_buffer_count - sp->decrypted_buffer_offset;
+ uint32_t bytes_to_return = sp->decrypted_buffer_count - sp->decrypted_buffer_offset;
if (bytes_to_return > len) {
bytes_to_return = len;
}
@@ -560,7 +560,7 @@ sasl_io_recv(PRFileDesc *fd, void *buf, PRInt32 len, PRIntn flags, PRIntervalTim
} else {
sp->decrypted_buffer_offset += bytes_to_return;
slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_recv",
- "Returning %lu bytes to caller %lu bytes left to return for connection %" PRIu64 "\n",
+ "Returning %" PRIu32 " bytes to caller %" PRIu32 " bytes left to return for connection %" PRIu64 "\n",
bytes_to_return, sp->decrypted_buffer_count - sp->decrypted_buffer_offset, c->c_connid);
}
ret = bytes_to_return;
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index e58f4883c..bbaa7a4a5 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2435,7 +2435,7 @@ typedef struct _slapdFrontendConfig
int localssf; /* the security strength factor to assign to local conns (ldapi) */
int minssf; /* minimum security strength factor (for SASL and SSL/TLS) */
slapi_onoff_t minssf_exclude_rootdse; /* ON: minssf is ignored when searching rootdse */
- size_t maxsasliosize; /* limit incoming SASL IO packet size */
+ int32_t maxsasliosize; /* limit incoming SASL IO packet size */
char *anon_limits_dn; /* template entry for anonymous resource limits */
slapi_int_t listen_backlog_size; /* size of backlog parameter to PR_Listen */
struct passwd *localuserinfo; /* userinfo of localuser */
@@ -2450,7 +2450,7 @@ typedef struct _slapdFrontendConfig
/* disk monitoring */
slapi_onoff_t disk_monitoring;
- PRInt64 disk_threshold;
+ uint64_t disk_threshold;
int disk_grace_period;
slapi_onoff_t disk_logging_critical;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 33e2b95cd..e862382fa 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -29,7 +29,6 @@ extern "C" {
/* Provides our int types and platform specific requirements. */
#include "slapi_pal.h"
-
#include "prtypes.h"
#include "ldap.h"
#include "prprf.h"
@@ -5834,7 +5833,7 @@ char *slapi_ch_malloc(unsigned long size);
* \param alignment The alignment. MUST be a power of 2!
* \return Pointer to the allocated memory aligned by alignment.
*/
-char *slapi_ch_memalign(size_t size, size_t alignment);
+char *slapi_ch_memalign(uint32_t size, uint32_t alignment);
char *slapi_ch_realloc(char *block, unsigned long size);
char *slapi_ch_calloc(unsigned long nelem, unsigned long size);
char *slapi_ch_strdup(const char *s);
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index c28c6e733..9c90dfb58 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -376,7 +376,7 @@ char *slapi_dn_normalize_case_original(char *dn);
int32_t ndn_cache_init(void);
void ndn_cache_destroy(void);
int ndn_cache_started(void);
-void ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, size_t *thread_size, size_t *evicts, size_t *slots, long *count);
+void ndn_cache_get_stats(uint64_t *hits, uint64_t *tries, uint64_t *size, uint64_t *max_size, uint64_t *thread_size, uint64_t *evicts, uint64_t *slots, uint64_t *count);
#define NDN_DEFAULT_SIZE 20971520 /* 20mb - size of normalized dn cache */
/* filter.c */
diff --git a/ldap/servers/slapd/tools/dbscan.c b/ldap/servers/slapd/tools/dbscan.c
index f4001d2ea..53cdb8985 100644
--- a/ldap/servers/slapd/tools/dbscan.c
+++ b/ldap/servers/slapd/tools/dbscan.c
@@ -81,13 +81,13 @@
#include <getopt.h>
#endif
-typedef PRUint32 ID;
+typedef uint32_t ID;
typedef struct
{
- PRUint32 max;
- PRUint32 used;
- PRUint32 id[1];
+ uint32_t max;
+ uint32_t used;
+ uint32_t id[1];
} IDL;
#define RDN_BULK_FETCH_BUFFER_SIZE (8 * 1024)
@@ -109,9 +109,9 @@ static void display_entryrdn_self(DB *db, ID id, const char *nrdn, int indent);
static void display_entryrdn_children(DB *db, ID id, const char *nrdn, int indent);
static void display_entryrdn_item(DB *db, DBC *cursor, DBT *key);
-PRUint32 file_type = 0;
-PRUint32 min_display = 0;
-PRUint32 display_mode = 0;
+uint32_t file_type = 0;
+uint32_t min_display = 0;
+uint32_t display_mode = 0;
int truncatesiz = 0;
long pres_cnt = 0;
long eq_cnt = 0;
@@ -145,15 +145,15 @@ db_printfln(char *fmt, ...)
fprintf(stdout, "\n");
}
-size_t MAX_BUFFER = 4096;
-size_t MIN_BUFFER = 20;
+uint32_t MAX_BUFFER = 4096;
+uint32_t MIN_BUFFER = 20;
static IDL *
idl_make(DBT *data)
{
IDL *idl = NULL, *xidl;
- if (data->size < 2 * sizeof(PRUint32)) {
+ if (data->size < 2 * sizeof(uint32_t)) {
idl = (IDL *)malloc(sizeof(IDL) + 64 * sizeof(ID));
if (!idl)
return NULL;
@@ -283,7 +283,7 @@ idl_format(IDL *idl, int isfirsttime, int *done)
for (; i < idl->used; i++) {
sprintf((char *)buf + strlen(buf), "%d ", idl->id[i]);
- if (strlen(buf) > (size_t)MAX_BUFFER - MIN_BUFFER) {
+ if (strlen(buf) > MAX_BUFFER - MIN_BUFFER) {
i++;
done = 0;
return (char *)buf;
@@ -360,7 +360,7 @@ _cl5ReadMods(char **buff)
{
char *pos = *buff;
ID i;
- PRUint32 mod_count;
+ uint32_t mod_count;
/* need to copy first, to skirt around alignment problems on certain
architectures */
@@ -384,7 +384,7 @@ void
print_ber_attr(char *attrname, char **buff)
{
char *val = NULL;
- PRUint32 bv_len;
+ uint32_t bv_len;
memcpy((char *)&bv_len, *buff, sizeof(bv_len));
bv_len = ntohl(bv_len);
@@ -447,8 +447,8 @@ void
_cl5ReadMod(char **buff)
{
char *pos = *buff;
- PRUint32 i;
- PRUint32 val_count;
+ uint32_t i;
+ uint32_t val_count;
char *type = NULL;
pos++;
@@ -458,7 +458,7 @@ _cl5ReadMod(char **buff)
certain architectures */
memcpy((char *)&val_count, pos, sizeof(val_count));
val_count = ntohl(val_count);
- pos += sizeof(PRUint32);
+ pos += sizeof(uint32_t);
for (i = 0; i < val_count; i++) {
print_ber_attr(type, &pos);
@@ -473,14 +473,14 @@ void
print_ruv(unsigned char *buff)
{
char *pos = (char *)buff;
- PRUint32 i;
- PRUint32 val_count;
+ uint32_t i;
+ uint32_t val_count;
/* need to do the copy first, to skirt around alignment problems on
certain architectures */
memcpy((char *)&val_count, pos, sizeof(val_count));
val_count = ntohl(val_count);
- pos += sizeof(PRUint32);
+ pos += sizeof(uint32_t);
for (i = 0; i < val_count; i++) {
print_ber_attr(NULL, &pos);
@@ -491,11 +491,11 @@ print_ruv(unsigned char *buff)
*** Copied from cl5_api:cl5DBData2Entry ***
Data in db format:
------------------
- <1 byte version><1 byte change_type><sizeof PRUint32 time><null terminated dbid>
+ <1 byte version><1 byte change_type><sizeof uint32_t time><null terminated dbid>
<null terminated csn><null terminated uniqueid><null terminated targetdn>
[<null terminated newrdn><1 byte deleteoldrdn>][<4 byte mod count><mod1><mod2>....]
-Note: the length of time is set PRUint32 instead of time_t. Regardless of the
+Note: the length of time is set uint32_t instead of time_t. Regardless of the
width of long (32-bit or 64-bit), it's stored using 4bytes by the server [153306].
mod format:
@@ -509,9 +509,9 @@ print_changelog(unsigned char *data, int len __attribute__((unused)))
uint8_t version;
unsigned long operation_type;
char *pos = (char *)data;
- PRUint32 thetime32;
+ uint32_t thetime32;
time_t thetime;
- PRUint32 replgen;
+ uint32_t replgen;
/* read byte of version */
version = *((uint8_t *)pos);
@@ -530,7 +530,7 @@ print_changelog(unsigned char *data, int len __attribute__((unused)))
memcpy((char *)&thetime32, pos, sizeof(thetime32));
replgen = ntohl(thetime32);
- pos += sizeof(PRUint32);
+ pos += sizeof(uint32_t);
thetime = (time_t)replgen;
db_printf("\treplgen: %ld %s", replgen, ctime((time_t *)&thetime));
@@ -608,7 +608,7 @@ display_index_item(DBC *cursor, DBT *key, DBT *data, unsigned char *buf, int buf
while (ret == 0) {
ret = cursor->c_get(cursor, key, data, DB_NEXT_DUP);
if (ret == 0)
- idl = idl_append(idl, *(PRUint32 *)(data->data));
+ idl = idl_append(idl, *(uint32_t *)(data->data));
}
if (ret == DB_NOTFOUND)
ret = 0;
@@ -944,7 +944,7 @@ display_entryrdn_item(DB *db, DBC *cursor, DBT *key)
int indent = 2;
DBT data;
int rc;
- PRUint32 flags = 0;
+ uint32_t flags = 0;
char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
DBT dataret;
int find_key_flag = 0;
@@ -1102,7 +1102,7 @@ usage(char *argv0)
printf(" index file options:\n");
printf(" -k <key> lookup only a specific key\n");
printf(" -l <size> max length of dumped id list\n");
- printf(" (default %lu; 40 bytes <= size <= 1048576 bytes)\n", MAX_BUFFER);
+ printf(" (default %" PRIu32 "; 40 bytes <= size <= 1048576 bytes)\n", MAX_BUFFER);
printf(" -G <n> only display index entries with more than <n> ids\n");
printf(" -n display ID list lengths\n");
printf(" -r display the conents of ID list\n");
@@ -1132,7 +1132,7 @@ main(int argc, char **argv)
DBT key = {0}, data = {0};
int ret;
char *find_key = NULL;
- PRUint32 entry_id = 0xffffffff;
+ uint32_t entry_id = 0xffffffff;
int c;
key.flags = DB_DBT_REALLOC;
@@ -1146,7 +1146,7 @@ main(int argc, char **argv)
display_mode |= RAWDATA;
break;
case 'l': {
- PRUint32 tmpmaxbufsz = atoi(optarg);
+ uint32_t tmpmaxbufsz = atoi(optarg);
if (tmpmaxbufsz > ONEMEG) {
tmpmaxbufsz = ONEMEG;
printf("WARNING: max length of dumped id list too long, "
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 95cc26148..1e6470521 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -71,7 +71,7 @@ main(int argc, char *argv[])
} else if (secs > 3600) {
secs = 3600;
}
- printf("%s pid is %d - sleeping for %ld\n", argv[0], getpid(), secs);
+ printf("%s pid is %d - sleeping for %" PRId64 "\n", argv[0], getpid(), secs);
sleep(secs);
}
}
diff --git a/src/libsds/sds/bpt/map.c b/src/libsds/sds/bpt/map.c
index 096a38bcc..ae528f342 100644
--- a/src/libsds/sds/bpt/map.c
+++ b/src/libsds/sds/bpt/map.c
@@ -294,8 +294,8 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n
// Given the node write it out as:
fprintf(fp, "subgraph c%" PRIu32 " { \n rank=\"same\";\n", node->level);
fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%" PRIu64 " parent=%p | { <f0> ", node, node, node->item_count, node->txn_id, node->parent);
- for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) {
- fprintf(fp, "| %" PRIu64 " | <f%" PRIu64 "> ", (uint64_t)node->keys[i], i + 1);
+ for (uint64_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) {
+ fprintf(fp, "| %" PRIu64 " | <f%" PRIu64 "> ", (uint64_t)((uintptr_t)node->keys[i]), i + 1);
}
fprintf(fp, "}}\"]; \n}\n");
return SDS_SUCCESS;
@@ -312,7 +312,7 @@ sds_node_ptrs_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bpt
fprintf(fp, "\"node_%p\" -> \"node_%p\"; \n", node, node->values[SDS_BPTREE_DEFAULT_CAPACITY]);
}
} else {
- for (size_t i = 0; i < SDS_BPTREE_BRANCH; i++) {
+ for (uint64_t i = 0; i < SDS_BPTREE_BRANCH; i++) {
if (node->values[i] != NULL) {
if (i == SDS_BPTREE_DEFAULT_CAPACITY) {
// Work around a graphviz display issue, with Left and Right pointers
@@ -332,7 +332,7 @@ sds_bptree_display(sds_bptree_instance *binst)
{
sds_result result = SDS_SUCCESS;
- char *path = malloc(sizeof(char) * 20);
+ char *path = malloc(sizeof(char) * 21);
#ifdef SDS_DEBUG
sds_log("sds_bptree_display", "Writing step %03d\n", binst->print_iter);
#endif
diff --git a/src/libsds/sds/bpt_cow/bpt_cow.c b/src/libsds/sds/bpt_cow/bpt_cow.c
index 0b6f229af..c2ab60729 100644
--- a/src/libsds/sds/bpt_cow/bpt_cow.c
+++ b/src/libsds/sds/bpt_cow/bpt_cow.c
@@ -527,8 +527,8 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n
// Given the node write it out as:
fprintf(fp, "subgraph c%" PRIu32 " { \n rank=\"same\";\n", node->level);
fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%" PRIu64 " parent=%p | { <f0> ", node, node, node->item_count, node->txn_id, node->parent);
- for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) {
- fprintf(fp, "| %" PRIu64 " | <f%" PRIu64 "> ", (uint64_t)node->keys[i], i + 1);
+ for (uint64_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) {
+ fprintf(fp, "| %" PRIu64 " | <f%" PRIu64 "> ", (uint64_t)((uintptr_t)node->keys[i]), i + 1);
}
fprintf(fp, "}}\"]; \n}\n");
return SDS_SUCCESS;
@@ -545,7 +545,7 @@ sds_node_ptrs_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bpt
fprintf(fp, "\"node_%p\" -> \"node_%p\"; \n", node, node->values[SDS_BPTREE_DEFAULT_CAPACITY]);
}
} else {
- for (size_t i = 0; i < SDS_BPTREE_BRANCH; i++) {
+ for (uint64_t i = 0; i < SDS_BPTREE_BRANCH; i++) {
if (node->values[i] != NULL) {
if (i == SDS_BPTREE_DEFAULT_CAPACITY) {
// Work around a graphviz display issue, with Left and Right pointers
@@ -566,7 +566,7 @@ sds_bptree_cow_display(sds_bptree_transaction *btxn)
{
sds_result result = SDS_SUCCESS;
- char *path = malloc(sizeof(char) * 20);
+ char *path = malloc(sizeof(char) * 36);
print_iter += 1;
#ifdef SDS_DEBUG
sds_log("sds_bptree_cow_display", "Writing step %03d\n", print_iter);
| 0 |
61a4a328709e7237fc1de05e85e33e38de596218
|
389ds/389-ds-base
|
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
description: Catch possible NULL pointer in _dblayer_delete_instance_dir().
|
commit 61a4a328709e7237fc1de05e85e33e38de596218
Author: Endi S. Dewata <[email protected]>
Date: Fri Jul 9 20:33:22 2010 -0500
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
description: Catch possible NULL pointer in _dblayer_delete_instance_dir().
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 25bd83d70..41f7c266c 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4331,26 +4331,31 @@ static int _dblayer_delete_instance_dir(ldbm_instance *inst, int startdb)
char *inst_dirp = NULL;
int rval = 0;
- if (NULL != li)
+ if (NULL == li)
{
- if (startdb)
- {
- /* close immediately; no need to run db threads */
- rval = dblayer_start(li, DBLAYER_NORMAL_MODE|DBLAYER_NO_DBTHREADS_MODE);
- if (rval)
- {
- LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_start failed! %s (%d)\n",
- dblayer_strerror(rval), rval, 0);
- goto done;
- }
- }
- priv = (dblayer_private*)li->li_dblayer_private;
- if (NULL != priv)
+ LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: NULL LDBM info\n", 0, 0, 0);
+ rval = -1;
+ goto done;
+ }
+
+ if (startdb)
+ {
+ /* close immediately; no need to run db threads */
+ rval = dblayer_start(li, DBLAYER_NORMAL_MODE|DBLAYER_NO_DBTHREADS_MODE);
+ if (rval)
{
- pEnv = priv->dblayer_env;
+ LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_start failed! %s (%d)\n",
+ dblayer_strerror(rval), rval, 0);
+ goto done;
}
}
+ priv = (dblayer_private*)li->li_dblayer_private;
+ if (NULL != priv)
+ {
+ pEnv = priv->dblayer_env;
+ }
+
if (inst->inst_dir_name == NULL)
dblayer_get_instance_data_dir(inst->inst_be);
| 0 |
d2c5b35e20578043117f84e928d96d296bdfc046
|
389ds/389-ds-base
|
Ticket #47431 - Duplicate values for the attribute nsslapd-pluginarg are not handled correctly
Fix description: Added the attributes nsslapd-pluginarg0 to
nsslapd-pluginarg15 in the schema file with the condition that
they must be singlevalued. This solves the issue of incorrect
handling of duplicate and multiple values of these attributes.
This fix also solves the problem of non-continuous numbers in
the nsslapd-pluginarg attributes and makes them continuous if
they are not.
https://fedorahosted.org/389/ticket/47431
Reviewed by nhosoi.
|
commit d2c5b35e20578043117f84e928d96d296bdfc046
Author: Anupam Jain <[email protected]>
Date: Tue Jul 16 18:16:27 2013 -0700
Ticket #47431 - Duplicate values for the attribute nsslapd-pluginarg are not handled correctly
Fix description: Added the attributes nsslapd-pluginarg0 to
nsslapd-pluginarg15 in the schema file with the condition that
they must be singlevalued. This solves the issue of incorrect
handling of duplicate and multiple values of these attributes.
This fix also solves the problem of non-continuous numbers in
the nsslapd-pluginarg attributes and makes them continuous if
they are not.
https://fedorahosted.org/389/ticket/47431
Reviewed by nhosoi.
diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif
index 8ef702d02..8c49918f2 100644
--- a/ldap/schema/01core389.ldif
+++ b/ldap/schema/01core389.ldif
@@ -153,6 +153,22 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2152 NAME 'nsds5ReplicaProtocolTimeout'
attributeTypes: ( 2.16.840.1.113730.3.1.2154 NAME 'nsds5ReplicaBackoffMin' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2155 NAME 'nsds5ReplicaBackoffMax' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2156 NAME 'nsslapd-sasl-max-buffer-size' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2161 NAME 'nsslapd-pluginArg0' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2162 NAME 'nsslapd-pluginArg1' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2163 NAME 'nsslapd-pluginArg2' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2164 NAME 'nsslapd-pluginArg3' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2165 NAME 'nsslapd-pluginArg4' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2166 NAME 'nsslapd-pluginArg5' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2167 NAME 'nsslapd-pluginArg6' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2168 NAME 'nsslapd-pluginArg7' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2169 NAME 'nsslapd-pluginArg8' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2170 NAME 'nsslapd-pluginArg9' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2171 NAME 'nsslapd-pluginArg10' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2172 NAME 'nsslapd-pluginArg11' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2173 NAME 'nsslapd-pluginArg12' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2174 NAME 'nsslapd-pluginArg13' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2175 NAME 'nsslapd-pluginArg14' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2176 NAME 'nsslapd-pluginArg15' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
#
# objectclasses
#
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 52b9c3c5b..d9b925c8d 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -54,6 +54,11 @@
#define ROOT_BIND "directory manager"
#define ANONYMOUS_BIND "anonymous"
+/* This defines the maximum number that an nsslapd-pluginArg attribute can have.
+ * A plugin can have 16 arguments nsslapd-pluginArg0 to nsslapd-pluginArg15
+ */
+#define MAX_PLUGINARG_NUM 15
+
/* Forward Declarations */
static int plugin_call_list (struct slapdplugin *list, int operation, Slapi_PBlock *pb);
static int plugin_call_one (struct slapdplugin *list, int operation, Slapi_PBlock *pb);
@@ -2097,8 +2102,19 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group,
int status = 0;
int enabled = 1;
char *configdir = 0;
+ int diff = 0;
+ int index_prev = 0;
+ char attr_prev[BUFSIZ];
+ int rc = 0;
+ int num_args = 0;
+ Slapi_Attr *newattr = 0;
+ int arg_length = 0;
+ char *attrnamenum = NULL;
+ char *attr_prevnum = NULL;
+ int numsize = 0;
attrname[0] = '\0';
+ attr_prev[0] = '\0';
if (!slapi_entry_get_sdn_const(plugin_entry))
{
@@ -2278,15 +2294,78 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group,
}
/* add the plugin arguments */
+ rc = 0;
+ arg_length = strlen(ATTR_PLUGIN_ARG);
+
+ for (rc = slapi_entry_first_attr(plugin_entry, &newattr); !rc && newattr; rc = slapi_entry_next_attr(plugin_entry, newattr, &newattr))
+ {
+ char *type = NULL;
+ slapi_attr_get_type(newattr, &type);
+ if (strncasecmp(type, ATTR_PLUGIN_ARG, arg_length) == 0)
+ {
+ char *ptr = type;
+ ptr += arg_length;
+ int numdigits = 0;
+ char *ptr_num = ptr;
+ if ((*ptr == '\0') || ((*ptr == '0') && (*(ptr+1) != '\0')))
+ {
+ slapi_log_error( SLAPI_LOG_FATAL, plugin->plg_dn, "Invalid Plugin argument: %s. Argument ignored\n", type);
+ continue;
+ }
+ while(*ptr != '\0')
+ {
+ if (!isdigit(*ptr))
+ {
+ slapi_log_error( SLAPI_LOG_FATAL, plugin->plg_dn, "Invalid Plugin argument: %s. Argument ignored\n", type);
+ break;
+ }
+ numdigits++;
+ ptr++;
+ }
+ if (*ptr == '\0')
+ {
+ if ((numdigits < 3) && (atoi(ptr_num) <= MAX_PLUGINARG_NUM))
+ num_args++;
+ else
+ {
+ slapi_log_error( SLAPI_LOG_FATAL, plugin->plg_dn, "Plugin argument value nsslapd-pluginArg%s exceeded maximum allowed value nsslapd-pluginArg%d\n", ptr_num, MAX_PLUGINARG_NUM);
+ status = -1;
+ goto PLUGIN_CLEANUP;
+ }
+ }
+ }
+ }
+
+ PR_snprintf(attrname, sizeof(attrname), "%s", ATTR_PLUGIN_ARG);
+ PR_snprintf(attr_prev, sizeof(attr_prev), "%s", ATTR_PLUGIN_ARG);
+ attrnamenum = attrname + sizeof(ATTR_PLUGIN_ARG) -1;
+ attr_prevnum = attr_prev + sizeof(ATTR_PLUGIN_ARG) -1;
+ numsize = sizeof(attrname) - sizeof(ATTR_PLUGIN_ARG);
value = 0;
ii = 0;
- PR_snprintf(attrname, sizeof(attrname), "%s%d", ATTR_PLUGIN_ARG, ii);
- while ((value = slapi_entry_attr_get_charptr(plugin_entry, attrname)) != NULL)
+ while (plugin->plg_argc < num_args)
{
+ PR_snprintf(attrnamenum, numsize, "%d", ii);
+ if (diff == 0)
+ {
+ strcpy(attr_prev, attrname);
+ index_prev = ii;
+ }
+ while ((value = slapi_entry_attr_get_charptr(plugin_entry, attrname)) == NULL)
+ {
+ PR_snprintf(attrnamenum, numsize, "%d", ++ii);
+ }
+
+ if(strcmp(attrname, attr_prev) != 0)
+ {
+ slapi_entry_add_string(plugin_entry, attr_prev, value);
+ slapi_entry_attr_delete(plugin_entry, attrname);
+ diff = 1;
+ PR_snprintf(attr_prevnum, numsize, "%d", ++index_prev);
+ }
charray_add(&plugin->plg_argv, value);
plugin->plg_argc++;
++ii;
- PR_snprintf(attrname, sizeof(attrname), "%s%d", ATTR_PLUGIN_ARG, ii);
}
memset((char *)&pb, '\0', sizeof(pb));
@@ -3233,4 +3312,4 @@ slapi_disordely_shutdown(PRBool set)
is_disordely_shutdown = PR_TRUE;
}
return (is_disordely_shutdown);
-}
\ No newline at end of file
+}
| 0 |
ff94e562a0c3e10c05fbead70e27215ace47b1d2
|
389ds/389-ds-base
|
Ticket 50197 - Container integration improvements
Bug Description: During the container integration process
I have noticed a small number of remaining issues.
Fix Description:
* dm password is left as randomised in container install
* nss_ssl only removes dir content, not the directory itself
* basic tests rely on incorrect assumptions about file perms,
hostnames and ports.
https://pagure.io/389-ds-base/issue/50197
Author: William Brown <[email protected]>
Review by: spichugi (Thanks!)
|
commit ff94e562a0c3e10c05fbead70e27215ace47b1d2
Author: William Brown <[email protected]>
Date: Mon Feb 4 16:34:28 2019 +1000
Ticket 50197 - Container integration improvements
Bug Description: During the container integration process
I have noticed a small number of remaining issues.
Fix Description:
* dm password is left as randomised in container install
* nss_ssl only removes dir content, not the directory itself
* basic tests rely on incorrect assumptions about file perms,
hostnames and ports.
https://pagure.io/389-ds-base/issue/50197
Author: William Brown <[email protected]>
Review by: spichugi (Thanks!)
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py
index 50b5dc049..652129f4f 100644
--- a/dirsrvtests/tests/suites/basic/basic_test.py
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
@@ -21,6 +21,9 @@ from lib389.dbgen import dbgen
from lib389.idm.organizationalunit import OrganizationalUnits
from lib389._constants import DN_DM, PASSWORD, PW_DM
from lib389.topologies import topology_st
+from lib389.paths import Paths
+
+default_paths = Paths()
log = logging.getLogger(__name__)
@@ -1143,6 +1146,8 @@ def test_ticketldbm_audit(topology_st):
assert audit_pattern_found(inst, regex)
[email protected](not get_user_is_root() or not default_paths.perl_enabled,
+ reason="This test is only required if perl is enabled, and requires root.")
def test_dscreate(request):
"""Test that dscreate works, we need this for now until setup-ds.pl is
fully discontinued.
@@ -1157,16 +1162,26 @@ def test_dscreate(request):
2. Should succeeds
"""
- template_file = "dssetup.inf"
+ template_file = "/tmp/dssetup.inf"
template_text = """[general]
config_version = 2
+# This invalid hostname ...
full_machine_name = localhost.localdomain
-
+# Means we absolutely require this.
+strict_host_checking = False
+# In tests, we can be run in containers, NEVER trust
+# that systemd is there, or functional in any capacity
+systemd = False
[slapd]
instance_name = test_dscreate
root_dn = cn=directory manager
root_password = someLongPassword_123
+# We do not have access to high ports in containers,
+# so default to something higher.
+port = 38999
+secure_port = 63699
+
[backend-userroot]
suffix = dc=example,dc=com
@@ -1175,10 +1190,13 @@ sample_entries = yes
with open(template_file, "w") as template_fd:
template_fd.write(template_text)
- cmd = 'dscreate from-file ' + template_file
try:
- subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
+ subprocess.check_call([
+ 'dscreate',
+ 'from-file',
+ template_file
+ ])
except subprocess.CalledProcessError as e:
log.fatal("dscreate failed! Error ({}) {}".format(e.returncode, e.output))
assert False
@@ -1186,7 +1204,7 @@ sample_entries = yes
def fin():
os.remove(template_file)
try:
- subprocess.check_output('dsctl test_dscreate remove --do-it', shell=True)
+ subprocess.check_call(['dsctl', 'test_dscreate', 'remove', '--do-it'])
except subprocess.CalledProcessError as e:
log.fatal("Failed to remove test instance Error ({}) {}".format(e.returncode, e.output))
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
index c0aa6083e..423a1dbe1 100644
--- a/src/lib389/lib389/instance/setup.py
+++ b/src/lib389/lib389/instance/setup.py
@@ -896,6 +896,7 @@ class SetupDs(object):
ds_instance.config.set('nsslapd-ldapiautobind', 'on')
ds_instance.config.set('nsslapd-ldapimaprootdn', slapd['root_dn'])
+
# Create all required sasl maps: if we have a single backend ...
# our default maps are really really bad, and we should feel bad.
# they basically only work with a single backend, and they'll break
@@ -921,14 +922,11 @@ class SetupDs(object):
self.log.debug("Skipping default SASL maps - no backend found!")
# Complete.
- # Change the root password finally
- ds_instance.config.set('nsslapd-rootpw',
- ensure_str(slapd['root_password']))
-
if self.containerised:
# In a container build we need to stop DirSrv at the end
ds_instance.stop()
else:
+ # If we are not a container, change the root password finally
+ ds_instance.config.set('nsslapd-rootpw', slapd['root_password'])
# Restart for changes to take effect - this could be removed later
ds_instance.restart(post_open=False)
-
diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py
index ccd15d00b..5f225c0f8 100644
--- a/src/lib389/lib389/nss_ssl.py
+++ b/src/lib389/lib389/nss_ssl.py
@@ -165,9 +165,6 @@ class NssSsl(object):
except FileNotFoundError:
pass
- if os.path.isdir(self._certdb) and not os.listdir(self._certdb):
- os.removedirs(self._certdb)
-
assert not self._db_exists()
return True
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index de3c5b741..afc895175 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -1215,6 +1215,13 @@ def get_user_is_ds_owner():
return True
return False
+def get_user_is_root():
+ cur_uid = os.getuid()
+ if cur_uid == 0:
+ # We are root, we have permission
+ return True
+ return False
+
def basedn_to_ldap_dns_uri(basedn):
# ldap:///dc%3Dexample%2Cdc%3Dcom
return "ldaps:///" + basedn.replace("=", "%3D").replace(",", "%2C")
| 0 |
36381c120773872d3d4d2cb2417f155e6ac790a6
|
389ds/389-ds-base
|
Ticket #47912 - Proper handling of "No original_tombstone for changenumber" errors
Bug Description: As analyzed by Ludwig Krispen in
https://fedorahosted.org/389/ticket/47912#comment:1,
an error message "No original_tombstone for ..." is always logged
if original_tombstone does not exist. It should be just for the
case create_tombstone_entry.
Fix Description: This patch place the original_tombstone handling
in "if (create_tombstone_entry)" clause.
https://fedorahosted.org/389/ticket/47912
Reviewed by [email protected] (Thank you, Ludwig!!)
|
commit 36381c120773872d3d4d2cb2417f155e6ac790a6
Author: Noriko Hosoi <[email protected]>
Date: Tue Oct 7 14:02:20 2014 -0700
Ticket #47912 - Proper handling of "No original_tombstone for changenumber" errors
Bug Description: As analyzed by Ludwig Krispen in
https://fedorahosted.org/389/ticket/47912#comment:1,
an error message "No original_tombstone for ..." is always logged
if original_tombstone does not exist. It should be just for the
case create_tombstone_entry.
Fix Description: This patch place the original_tombstone handling
in "if (create_tombstone_entry)" clause.
https://fedorahosted.org/389/ticket/47912
Reviewed by [email protected] (Thank you, Ludwig!!)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 5f12ea338..9c19f0887 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -225,33 +225,33 @@ ldbm_back_delete( Slapi_PBlock *pb )
free_delete_existing_entry = 1; /* must free the dup */
if (create_tombstone_entry) {
slapi_sdn_set_ndn_byval(&nscpEntrySDN, slapi_sdn_get_ndn(slapi_entry_get_sdn(e->ep_entry)));
- }
- /* reset tombstone entry */
- if (original_tombstone) {
- /* must duplicate tombstone before returning it to cache,
- * which could free the entry. */
- if ( (tmptombstone = backentry_dup( original_tombstone )) == NULL ) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
- if (cache_is_in_cache(&inst->inst_cache, tombstone)) {
- CACHE_REMOVE(&inst->inst_cache, tombstone);
- }
- CACHE_RETURN(&inst->inst_cache, &tombstone);
- if (tombstone) {
+ /* reset tombstone entry */
+ if (original_tombstone) {
+ /* must duplicate tombstone before returning it to cache,
+ * which could free the entry. */
+ if ( (tmptombstone = backentry_dup( original_tombstone )) == NULL ) {
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
+ goto error_return;
+ }
+ if (cache_is_in_cache(&inst->inst_cache, tombstone)) {
+ CACHE_REMOVE(&inst->inst_cache, tombstone);
+ }
+ CACHE_RETURN(&inst->inst_cache, &tombstone);
+ if (tombstone) {
+ slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
+ "conn=%lu op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n",
+ conn_id, op_id, retry_count, slapi_entry_get_dn(tombstone->ep_entry),
+ tombstone->ep_refcnt, tombstone->ep_state);
+ }
+ tombstone = original_tombstone;
+ original_tombstone = tmptombstone;
+ tmptombstone = NULL;
+ } else {
slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
- "conn=%lu op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n",
- conn_id, op_id, retry_count, slapi_entry_get_dn(tombstone->ep_entry),
- tombstone->ep_refcnt, tombstone->ep_state);
+ "conn=%lu op=%d [retry: %d] No original_tombstone for %s!!\n",
+ conn_id, op_id, retry_count, slapi_entry_get_dn(e->ep_entry));
}
- tombstone = original_tombstone;
- original_tombstone = tmptombstone;
- tmptombstone = NULL;
- } else {
- slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
- "conn=%lu op=%d [retry: %d] No original_tombstone for %s!!\n",
- conn_id, op_id, retry_count, slapi_entry_get_dn(e->ep_entry));
}
if (ruv_c_init) {
/* reset the ruv txn stuff */
| 0 |
1838c0bf04a4ffcf1d98f332f98855e69626b966
|
389ds/389-ds-base
|
Ticket 205 - Fix compiler warning
https://fedorahosted.org/389/ticket/205
Reviewed by: nhosoi(Thanks Noriko!)
|
commit 1838c0bf04a4ffcf1d98f332f98855e69626b966
Author: Mark Reynolds <[email protected]>
Date: Wed Apr 24 14:21:49 2013 -0400
Ticket 205 - Fix compiler warning
https://fedorahosted.org/389/ticket/205
Reviewed by: nhosoi(Thanks Noriko!)
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index d3a3497c4..675c08c7f 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -2011,7 +2011,7 @@ config_set_snmp_index(const char *attrname, char *value, char *errorbuf, int app
snmp_index = strtol(value, &endp, 10);
if (*endp != '\0' || errno == ERANGE || snmp_index < snmp_index_disable) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", %s must be greater or equal to %d (%d means disabled)",
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", %s must be greater or equal to %lu (%lu means disabled)",
attrname, value, CONFIG_SNMP_INDEX_ATTRIBUTE, snmp_index_disable, snmp_index_disable);
retVal = LDAP_OPERATIONS_ERROR;
}
| 0 |
8a754337756c31ae30eee959145bf58bdcac9251
|
389ds/389-ds-base
|
Fixed the brand and version mistakenly put in the previous check-in.
|
commit 8a754337756c31ae30eee959145bf58bdcac9251
Author: Noriko Hosoi <[email protected]>
Date: Mon Oct 1 06:02:33 2007 +0000
Fixed the brand and version mistakenly put in the previous check-in.
diff --git a/configure b/configure
index 3f8a4fe2b..8261fda7c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for dirsrv 8.0.0.
+# Generated by GNU Autoconf 2.59 for dirsrv 1.1.0b1.
#
# Report bugs to <http://bugzilla.redhat.com/>.
#
@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='dirsrv'
PACKAGE_TARNAME='dirsrv'
-PACKAGE_VERSION='8.0.0'
-PACKAGE_STRING='dirsrv 8.0.0'
+PACKAGE_VERSION='1.1.0b1'
+PACKAGE_STRING='dirsrv 1.1.0b1'
PACKAGE_BUGREPORT='http://bugzilla.redhat.com/'
# Factoring default headers for most tests.
@@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dirsrv 8.0.0 to adapt to many kinds of systems.
+\`configure' configures dirsrv 1.1.0b1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1020,7 +1020,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dirsrv 8.0.0:";;
+ short | recursive ) echo "Configuration of dirsrv 1.1.0b1:";;
esac
cat <<\_ACEOF
@@ -1201,7 +1201,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-dirsrv configure 8.0.0
+dirsrv configure 1.1.0b1
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1215,7 +1215,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dirsrv $as_me 8.0.0, which was
+It was created by dirsrv $as_me 1.1.0b1, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1861,7 +1861,7 @@ fi
# Define the identity of the package.
PACKAGE='dirsrv'
- VERSION='8.0.0'
+ VERSION='1.1.0b1'
cat >>confdefs.h <<_ACEOF
@@ -22954,9 +22954,9 @@ fi
# the default prefix - override with --prefix or --with-fhs
-brand=redhat
-capbrand='Red Hat'
-vendor="Red Hat"
+brand=fedora
+capbrand=Fedora
+vendor="Fedora Project"
# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2006 Red Hat, Inc.
@@ -25603,7 +25603,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by dirsrv $as_me 8.0.0, which was
+This file was extended by dirsrv $as_me 1.1.0b1, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -25666,7 +25666,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-dirsrv config.status 8.0.0
+dirsrv config.status 1.1.0b1
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
| 0 |
b70739589cfaa7a8da3faffcc13465d521e7ad20
|
389ds/389-ds-base
|
Bug 584156 - Remove ldapi socket file during upgrade
The ldapi socket file is only removed when ns-slapd is started
since the server does not have permission to remove it at shutdown.
The causes issues when upgrading to a recetn version that has
SELinux policy since the newly confined ns-slapd daemon will not
be allowed to remove the old ldapi socket file since it doesn't
have a dirsrv specific label. To deal with this, I've added an
upgrade scriptlet that will remove the ldapi socket file. When
the newly confined ns-slapd starts up, it will create a new
socket file with the proper label.
|
commit b70739589cfaa7a8da3faffcc13465d521e7ad20
Author: Nathan Kinder <[email protected]>
Date: Wed Apr 21 13:55:33 2010 -0700
Bug 584156 - Remove ldapi socket file during upgrade
The ldapi socket file is only removed when ns-slapd is started
since the server does not have permission to remove it at shutdown.
The causes issues when upgrading to a recetn version that has
SELinux policy since the newly confined ns-slapd daemon will not
be allowed to remove the old ldapi socket file since it doesn't
have a dirsrv specific label. To deal with this, I've added an
upgrade scriptlet that will remove the ldapi socket file. When
the newly confined ns-slapd starts up, it will create a new
socket file with the proper label.
diff --git a/Makefile.am b/Makefile.am
index 6cfbef8f1..9d1bee6b3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -407,6 +407,7 @@ dist_man_MANS = man/man1/dbscan.1 \
#------------------------
update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
ldap/admin/src/scripts/exampleupdate.ldif \
+ ldap/admin/src/scripts/10cleanupldapi.pl \
ldap/admin/src/scripts/10delautodnsuffix.pl \
ldap/admin/src/scripts/10fixrundir.pl \
ldap/admin/src/scripts/50addchainingsaslpwroles.ldif \
diff --git a/Makefile.in b/Makefile.in
index f7c82fbea..4ecd1c5c3 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -1489,6 +1489,7 @@ dist_man_MANS = man/man1/dbscan.1 \
#------------------------
update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
ldap/admin/src/scripts/exampleupdate.ldif \
+ ldap/admin/src/scripts/10cleanupldapi.pl \
ldap/admin/src/scripts/10delautodnsuffix.pl \
ldap/admin/src/scripts/10fixrundir.pl \
ldap/admin/src/scripts/50addchainingsaslpwroles.ldif \
@@ -9685,7 +9686,7 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
- -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+ -find $(distdir) -type d ! -perm -755 -exec chmod a+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
diff --git a/ldap/admin/src/scripts/10cleanupldapi.pl b/ldap/admin/src/scripts/10cleanupldapi.pl
new file mode 100644
index 000000000..a09abe673
--- /dev/null
+++ b/ldap/admin/src/scripts/10cleanupldapi.pl
@@ -0,0 +1,23 @@
+use Mozilla::LDAP::Conn;
+use Mozilla::LDAP::Utils qw(normalizeDN);
+use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn);
+
+sub runinst {
+ my ($inf, $inst, $dseldif, $conn) = @_;
+
+ my @errs;
+ my $ldapifile;
+
+ # see if nsslapd-rundir is defined
+ my $ent = $conn->search("cn=config", "base", "(objectclass=*)");
+ if (!$ent) {
+ return ('error_finding_config_entry', 'cn=config', $conn->getErrorString());
+ }
+
+ $ldapifile = $ent->getValues('nsslapd-ldapifilepath');
+ if ($ldapifile) {
+ unlink($ldapifile);
+ }
+
+ return ();
+}
| 0 |
db655bbe57cdb18a8ea53f8303d7047c30c17f7f
|
389ds/389-ds-base
|
Issue 4403 RFE - OpenLDAP pw hash migration tests (#4408)
Bug Description: As we want to support openldap to 389 password migration,
we should check if we allow accounts to continue to bind. This involves
testing different openldap authentication schemes to determine if they
work.
Fix Description: Add tests for different password and contrib password
types that are supported in openldap.
fixes: #4403
Author: William Brown <[email protected]>
Review by: @droideck, @progier389 (Thanks!)
|
commit db655bbe57cdb18a8ea53f8303d7047c30c17f7f
Author: Firstyear <[email protected]>
Date: Mon Nov 2 09:14:25 2020 +1000
Issue 4403 RFE - OpenLDAP pw hash migration tests (#4408)
Bug Description: As we want to support openldap to 389 password migration,
we should check if we allow accounts to continue to bind. This involves
testing different openldap authentication schemes to determine if they
work.
Fix Description: Add tests for different password and contrib password
types that are supported in openldap.
fixes: #4403
Author: William Brown <[email protected]>
Review by: @droideck, @progier389 (Thanks!)
diff --git a/Makefile.am b/Makefile.am
index 916b43958..513a8b256 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1205,6 +1205,14 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \
libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) @db_inc@ $(KERBEROS_CFLAGS) $(PCRE_CFLAGS) $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES)
libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LIBS) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LIBS) libsds.la libsvrcore.la
+# If asan is enabled, it creates special libcrypt interceptors. However, they are
+# detected by the first load of libasan at runtime, and what is in the linked lib
+# so we need libcrypt to be present as soon as libasan is loaded for the interceptors
+# to function. Since ns-slapd links libslapd, this is pulled at startup, which allows
+# pwdstorage to be asan checked with libcrypt.
+if enable_asan
+libslapd_la_LIBADD += $(LIBCRYPT)
+endif
libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS)
if RUST_ENABLE
diff --git a/configure.ac b/configure.ac
index fcd439c13..9ecc5f7f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,7 +164,7 @@ else
fi
AC_SUBST([asan_cflags])
AC_SUBST([asan_rust_defs])
-AM_CONDITIONAL(enable_asan,test "$enable_asan" = "yes")
+AM_CONDITIONAL(enable_asan,[test "$enable_asan" = yes])
AC_MSG_CHECKING(for --enable-msan)
AC_ARG_ENABLE(msan, AS_HELP_STRING([--enable-msan], [Enable gcc/clang memory sanitizer options (default: no)]),
diff --git a/dirsrvtests/tests/suites/openldap_2_389/password_migrate_test.py b/dirsrvtests/tests/suites/openldap_2_389/password_migrate_test.py
new file mode 100644
index 000000000..a818dc26b
--- /dev/null
+++ b/dirsrvtests/tests/suites/openldap_2_389/password_migrate_test.py
@@ -0,0 +1,73 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2020 William Brown <[email protected]>
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import pytest
+import os
+from lib389.topologies import topology_st
+from lib389.utils import ds_is_older
+from lib389.idm.user import nsUserAccounts
+from lib389._constants import DEFAULT_SUFFIX
+
+pytestmark = pytest.mark.tier1
+
[email protected](ds_is_older('1.4.3'), reason="Not implemented")
+def test_migrate_openldap_password_hash(topology_st):
+ """Test import of an openldap password value into the directory and assert
+ it can bind.
+
+ :id: e4898e0d-5d18-4765-9249-84bcbf862fde
+ :setup: Standalone Instance
+ :steps:
+ 1. Import a hash
+ 2. Attempt a bind
+ 3. Goto 1
+
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ """
+ inst = topology_st.standalone
+ inst.config.set('nsslapd-allow-hashed-passwords', 'on')
+
+ # You generate these with:
+ # slappasswd -s password -o module-load=/usr/lib64/openldap/pw-argon2.so -h {ARGON2}
+ pwds = [
+ '{CRYPT}ZZKRwXSu3tt8s',
+ '{SSHA}jdALDtX0+MVMkRsX0ilHz0O6Uos95D4s',
+ '{MD5}X03MO1qnZdYdgyfeuILPmQ==',
+ '{SMD5}RnexgcsjdBHMQ1yhB7+sD+a+qDI=',
+ '{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=',
+ '{SHA256}XohImNooBHFR0OVvjcYpJ3NgPQ1qq73WKhHvch0VQtg=',
+ '{SSHA256}covFryM35UrKB3gMYxtYpQYTHbTn5kFphjcNHewfj581SLJwjA9jew==',
+ '{SHA384}qLZLq9CsqRpZvbt3YbQh1PK7OCgNOnW6DyHyvrxFWD1EbFmGYMlM5oDEfRnDB4On',
+ '{SSHA384}kNjTWdmyy2G1IgJF8WrOpq0N//Yc2Ec5TIQYceuiuHQXRXpC1bfnMqyOx0NxrSREjBWDwUpqXjo=',
+ '{SHA512}sQnzu7wkTrgkQZF+0G1hi5AI3Qmzvv0bXgc5THBqi7mAsdd4Xll27ASbRt9fEyavWi6m0QP9B8lThf+rDKy8hg==',
+ '{SSHA512}+7A8kA32q4mCBao4Cbatdyzl5imVwJ62ZAE7UOTP4pfrF90E9R2LabOfJFzx6guaYhTmUEVK2wRKC8bToqspdeTluX2d1BX2',
+ # Need to check --
+ # '{PBKDF2}10000$IlfapjA351LuDSwYC0IQ8Q$saHqQTuYnjJN/tmAndT.8mJt.6w',
+ # '{PBKDF2-SHA1}10000$ZBEH6B07rgQpJSikyvMU2w$TAA03a5IYkz1QlPsbJKvUsTqNV',
+ # '{PBKDF2-SHA256}10000$henZGfPWw79Cs8ORDeVNrQ$1dTJy73v6n3bnTmTZFghxHXHLsAzKaAy8SksDfZBPIw',
+ # '{PBKDF2-SHA512}10000$Je1Uw19Bfv5lArzZ6V3EPw$g4T/1sqBUYWl9o93MVnyQ/8zKGSkPbKaXXsT8WmysXQJhWy8MRP2JFudSL.N9RklQYgDPxPjnfum/F2f/TrppA',
+ # '{ARGON2}$argon2id$v=19$m=65536,t=2,p=1$IyTQMsvzB2JHDiWx8fq7Ew$VhYOA7AL0kbRXI5g2kOyyp8St1epkNj7WZyUY4pAIQQ',
+ ]
+
+ accounts = nsUserAccounts(inst, basedn=DEFAULT_SUFFIX)
+ account = accounts.create(properties={
+ 'uid': 'pw_migrate_test_user',
+ 'cn': 'pw_migrate_test_user',
+ 'displayName': 'pw_migrate_test_user',
+ 'uidNumber': '12345',
+ 'gidNumber': '12345',
+ 'homeDirectory': '/var/empty',
+ })
+
+ for pwhash in pwds:
+ inst.log.debug(f"Attempting -> {pwhash}")
+ account.set('userPassword', pwhash)
+ nconn = account.bind('password')
| 0 |
8672c1fddb51e72329618ae07c2af1cf1b577176
|
389ds/389-ds-base
|
610281 - fix coverity Defect Type: Control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=610281
11803 DEADCODE Triaged Unassigned Bug Minor Fix Required
_cl5GetFirstEntry() ds/ldap/servers/plugins/replication/cl5_api.c
11804 DEADCODE Triaged Unassigned Bug Minor Fix Required
_cl5GetNextEntry() ds/ldap/servers/plugins/replication/cl5_api.c
Comment:
Eliminated unnecessary codes.
|
commit 8672c1fddb51e72329618ae07c2af1cf1b577176
Author: Noriko Hosoi <[email protected]>
Date: Fri Jul 2 13:35:53 2010 -0700
610281 - fix coverity Defect Type: Control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=610281
11803 DEADCODE Triaged Unassigned Bug Minor Fix Required
_cl5GetFirstEntry() ds/ldap/servers/plugins/replication/cl5_api.c
11804 DEADCODE Triaged Unassigned Bug Minor Fix Required
_cl5GetNextEntry() ds/ldap/servers/plugins/replication/cl5_api.c
Comment:
Eliminated unnecessary codes.
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index f61bd0aa9..6aec7b255 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -5538,22 +5538,11 @@ static int _cl5GetFirstEntry (Object *obj, CL5Entry *entry, void **iterator, DB_
}
/* db error occured while iterating */
- if (rc != 0)
- {
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5GetFirstEntry: failed to get entry; db error - %d %s\n", rc, db_strerror(rc));
- rc = CL5_DB_ERROR;
- goto done;
- }
-
- /* successfully retrieved next entry but it was out of range */
- if (rc == CL5_SUCCESS)
- {
- slapi_ch_free (&(key.data));
- slapi_ch_free (&(data.data));
- rc = CL5_NOTFOUND;
- goto done;
- }
+ /* On this path, the condition "rc != 0" cannot be false */
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5GetFirstEntry: failed to get entry; db error - %d %s\n",
+ rc, db_strerror(rc));
+ rc = CL5_DB_ERROR;
done:;
/* error occured */
@@ -5621,15 +5610,11 @@ static int _cl5GetNextEntry (CL5Entry *entry, void *iterator)
}
/* cursor operation failed */
- if (rc != 0)
- {
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5GetNextEntry: failed to get entry; db error - %d %s\n", rc, db_strerror(rc));
-
- return CL5_DB_ERROR;
- }
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5GetNextEntry: failed to get entry; db error - %d %s\n",
+ rc, db_strerror(rc));
- return rc;
+ return CL5_DB_ERROR;
}
static int _cl5CurrentDeleteEntry (void *iterator)
| 0 |
c973e63964761c3ac16958f7afbffa7049ae2f7e
|
389ds/389-ds-base
|
Ticket 49064 - RFE allow to enable MemberOf plugin in dedicated consumer
Bug Description:
memberof triggers some internal updates to add/del 'memberof' values.
on a readonly consumer, those updates selects a REFERRAL_ON_UPDATE backend
and that is not followed by internal updates.
At the end of the day, the update is rejected and if memberof plugin is enabled
replication will stuck on that rejected update
Fix Description:
internal updates from memberof need to bypassing referrals.
So they flag internal updates SLAPI_OP_FLAG_BYPASS_REFERRALS, so that mtn_get_be
(mapping tree selection) will not return the referrals.
https://pagure.io/389-ds-base/issue/49064
Reviewed by: Ludwig Krispenz, William Brown (thanks a LOT !)
Platforms tested: F23 (all tickets + basic suite)
Flag Day: no
Doc impact: no
|
commit c973e63964761c3ac16958f7afbffa7049ae2f7e
Author: Thierry Bordaz <[email protected]>
Date: Mon Oct 16 11:21:51 2017 +0200
Ticket 49064 - RFE allow to enable MemberOf plugin in dedicated consumer
Bug Description:
memberof triggers some internal updates to add/del 'memberof' values.
on a readonly consumer, those updates selects a REFERRAL_ON_UPDATE backend
and that is not followed by internal updates.
At the end of the day, the update is rejected and if memberof plugin is enabled
replication will stuck on that rejected update
Fix Description:
internal updates from memberof need to bypassing referrals.
So they flag internal updates SLAPI_OP_FLAG_BYPASS_REFERRALS, so that mtn_get_be
(mapping tree selection) will not return the referrals.
https://pagure.io/389-ds-base/issue/49064
Reviewed by: Ludwig Krispenz, William Brown (thanks a LOT !)
Platforms tested: F23 (all tickets + basic suite)
Flag Day: no
Doc impact: no
diff --git a/dirsrvtests/tests/tickets/ticket49064_test.py b/dirsrvtests/tests/tickets/ticket49064_test.py
new file mode 100644
index 000000000..b4b6de4b9
--- /dev/null
+++ b/dirsrvtests/tests/tickets/ticket49064_test.py
@@ -0,0 +1,259 @@
+import logging
+import pytest
+import os
+import time
+import ldap
+import subprocess
+from lib389.utils import ds_is_older
+from lib389.topologies import topology_m1h1c1 as topo
+from lib389._constants import *
+from lib389 import Entry
+
+# Skip on older versions
+pytestmark = pytest.mark.skipif(ds_is_older('1.3.7'), reason="Not implemented")
+
+USER_CN='user_'
+GROUP_CN='group_'
+FIXUP_FILTER = '(objectClass=*)'
+FIXUP_CMD = 'fixup-memberof.pl'
+
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+def memberof_fixup_task(server):
+ sbin_dir = server.get_sbin_dir()
+ memof_task = os.path.join(sbin_dir, FIXUP_CMD)
+ try:
+ output = subprocess.check_output(
+ [memof_task, '-D', DN_DM, '-w', PASSWORD, '-b', SUFFIX, '-Z', SERVERID_CONSUMER_1, '-f', FIXUP_FILTER])
+ except subprocess.CalledProcessError as err:
+ output = err.output
+ log.info('output: {}'.format(output))
+ expected = "Successfully added task entry"
+ assert expected in output
+
+def config_memberof(server):
+
+ server.plugins.enable(name=PLUGIN_MEMBER_OF)
+ MEMBEROF_PLUGIN_DN = ('cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config')
+ server.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_REPLACE,
+ 'memberOfAllBackends',
+ 'on'),
+ (ldap.MOD_REPLACE, 'memberOfAutoAddOC', 'nsMemberOf')])
+ # Configure fractional to prevent total init to send memberof
+ ents = server.agreement.list(suffix=DEFAULT_SUFFIX)
+ for ent in ents:
+ log.info('update %s to add nsDS5ReplicatedAttributeListTotal' % ent.dn)
+ server.modify_s(ent.dn,
+ [(ldap.MOD_REPLACE,
+ 'nsDS5ReplicatedAttributeListTotal',
+ '(objectclass=*) $ EXCLUDE '),
+ (ldap.MOD_REPLACE,
+ 'nsDS5ReplicatedAttributeList',
+ '(objectclass=*) $ EXCLUDE memberOf')])
+
+
+def send_updates_now(server):
+
+ ents = server.agreement.list(suffix=DEFAULT_SUFFIX)
+ for ent in ents:
+ server.agreement.pause(ent.dn)
+ server.agreement.resume(ent.dn)
+
+def add_user(server, no, desc='dummy', sleep=True):
+ cn = '%s%d' % (USER_CN, no)
+ dn = 'cn=%s,ou=people,%s' % (cn, SUFFIX)
+ log.fatal('Adding user (%s): ' % dn)
+ server.add_s(Entry((dn, {'objectclass': ['top', 'person', 'inetuser'],
+ 'sn': ['_%s' % cn],
+ 'description': [desc]})))
+ if sleep:
+ time.sleep(2)
+
+def add_group(server, nr, sleep=True):
+ cn = '%s%d' % (GROUP_CN, nr)
+ dn = 'cn=%s,ou=groups,%s' % (cn, SUFFIX)
+ server.add_s(Entry((dn, {'objectclass': ['top', 'groupofnames'],
+ 'description': 'group %d' % nr})))
+ if sleep:
+ time.sleep(2)
+
+def update_member(server, member_dn, group_dn, op, sleep=True):
+ mod = [(op, 'member', member_dn)]
+ server.modify_s(group_dn, mod)
+ if sleep:
+ time.sleep(2)
+
+def _find_memberof(server, member_dn, group_dn, find_result=True):
+ ent = server.getEntry(member_dn, ldap.SCOPE_BASE, "(objectclass=*)", ['memberof'])
+ found = False
+ if ent.hasAttr('memberof'):
+
+ for val in ent.getValues('memberof'):
+ server.log.info("!!!!!!! %s: memberof->%s" % (member_dn, val))
+ server.log.info("!!!!!!! %s" % (val))
+ server.log.info("!!!!!!! %s" % (group_dn))
+ if val.lower() == group_dn.lower():
+ found = True
+ break
+
+ if find_result:
+ assert (found)
+ else:
+ assert (not found)
+
+
+def test_ticket49064(topo):
+ """Specify a test case purpose or name here
+
+ :id: 60c11636-55a1-4704-9e09-2c6bcc828de4
+ :setup: 1 Master - 1 Hub - 1 Consumer
+ :steps:
+ 1. Configure replication to EXCLUDE memberof
+ 2. Enable memberof plugin
+ 3. Create users/groups
+ 4. make user_1 member of group_1
+ 5. Checks that user_1 is memberof group_1 on M,H,C
+ 6. make group_1 member of group_2 (nest group)
+ 7. Checks that user_1 is memberof group_1 and group_2 on M,H,C
+ 8. Check group_1 is memberof group_2 on M,H,C
+ 9. remove group_1 from group_2
+ 10. Check group_1 and user_1 are NOT memberof group_2 on M,H,C
+ 11. remove user_1 from group_1
+ 12. Check user_1 is NOT memberof group_1 and group_2 on M,H,C
+ 13. Disable memberof on C1
+ 14. make user_1 member of group_1
+ 15. Checks that user is memberof group_1 on M,H but not on C
+ 16. Enable memberof on C1
+ 17. Checks that user is memberof group_1 on M,H but not on C
+ 18. Run memberof fixup task
+ 19. Checks that user is memberof group_1 on M,H,C
+
+
+ :expectedresults:
+ no assert for membership check
+ """
+
+
+ M1 = topo.ms["master1"]
+ H1 = topo.hs["hub1"]
+ C1 = topo.cs["consumer1"]
+
+ # Step 1 & 2
+ M1.config.enable_log('audit')
+ config_memberof(M1)
+ M1.restart()
+
+ H1.config.enable_log('audit')
+ config_memberof(H1)
+ H1.restart()
+
+ C1.config.enable_log('audit')
+ config_memberof(C1)
+ C1.restart()
+
+ # Step 3
+ for i in range(10):
+ add_user(M1, i, desc='add on m1')
+ for i in range(3):
+ add_group(M1, i)
+
+ # Step 4
+ member_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
+ group_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
+ update_member(M1, member_dn, group_dn, ldap.MOD_ADD, sleep=True)
+
+ # Step 5
+ for i in [M1, H1, C1]:
+ _find_memberof(i, member_dn, group_dn, find_result=True)
+
+
+ # Step 6
+ user_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
+ grp1_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
+ grp2_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 2, SUFFIX)
+ update_member(M1, grp1_dn, grp2_dn, ldap.MOD_ADD, sleep=True)
+
+ # Step 7
+ for i in [grp1_dn, grp2_dn]:
+ for inst in [M1, H1, C1]:
+ _find_memberof(inst, user_dn, i, find_result=True)
+
+ # Step 8
+ for i in [M1, H1, C1]:
+ _find_memberof(i, grp1_dn, grp2_dn, find_result=True)
+
+ # Step 9
+ user_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
+ grp1_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
+ grp2_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 2, SUFFIX)
+ update_member(M1, grp1_dn, grp2_dn, ldap.MOD_DELETE, sleep=True)
+
+ # Step 10
+ for inst in [M1, H1, C1]:
+ for i in [grp1_dn, user_dn]:
+ _find_memberof(inst, i, grp2_dn, find_result=False)
+
+ # Step 11
+ member_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
+ group_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
+ update_member(M1, member_dn, group_dn, ldap.MOD_DELETE, sleep=True)
+
+ # Step 12
+ for inst in [M1, H1, C1]:
+ for grp in [grp1_dn, grp2_dn]:
+ _find_memberof(inst, member_dn, grp, find_result=False)
+
+ # Step 13
+ C1.plugins.disable(name=PLUGIN_MEMBER_OF)
+ C1.restart()
+
+ # Step 14
+ member_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
+ group_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
+ update_member(M1, member_dn, group_dn, ldap.MOD_ADD, sleep=True)
+
+ # Step 15
+ for i in [M1, H1]:
+ _find_memberof(i, member_dn, group_dn, find_result=True)
+ _find_memberof(C1, member_dn, group_dn, find_result=False)
+
+ # Step 16
+ C1.plugins.enable(name=PLUGIN_MEMBER_OF)
+ C1.restart()
+
+ # Step 17
+ for i in [M1, H1]:
+ _find_memberof(i, member_dn, group_dn, find_result=True)
+ _find_memberof(C1, member_dn, group_dn, find_result=False)
+
+ # Step 18
+ memberof_fixup_task(C1)
+ time.sleep(5)
+
+ # Step 19
+ for i in [M1, H1, C1]:
+ _find_memberof(i, member_dn, group_dn, find_result=True)
+
+ # If you need any test suite initialization,
+ # please, write additional fixture for that (including finalizer).
+ # Topology for suites are predefined in lib389/topologies.py.
+
+ # If you need host, port or any other data about instance,
+ # Please, use the instance object attributes for that (for example, topo.ms["master1"].serverid)
+
+ if DEBUGGING:
+ # Add debugging steps(if any)...
+ pass
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
+
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index bae242c81..44b52edbb 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -609,7 +609,7 @@ memberof_del_dn_type_callback(Slapi_Entry *e, void *callback_data)
slapi_modify_internal_set_pb_ext(
mod_pb, slapi_entry_get_sdn(e),
mods, 0, 0,
- memberof_get_plugin_id(), 0);
+ memberof_get_plugin_id(), SLAPI_OP_FLAG_BYPASS_REFERRALS);
slapi_modify_internal_pb(mod_pb);
@@ -3224,7 +3224,7 @@ memberof_add_memberof_attr(LDAPMod **mods, const char *dn, char *add_oc)
mod_pb = slapi_pblock_new();
slapi_modify_internal_set_pb(
mod_pb, dn, mods, 0, 0,
- memberof_get_plugin_id(), 0);
+ memberof_get_plugin_id(), SLAPI_OP_FLAG_BYPASS_REFERRALS);
slapi_modify_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
@@ -3279,7 +3279,7 @@ memberof_add_objectclass(char *auto_add_oc, const char *dn)
slapi_modify_internal_set_pb(
mod_pb, dn, mods, 0, 0,
- memberof_get_plugin_id(), 0);
+ memberof_get_plugin_id(), SLAPI_OP_FLAG_BYPASS_REFERRALS);
slapi_modify_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
| 0 |
476af053a60003c4c017f320d55860d7ecb29ac9
|
389ds/389-ds-base
|
Ticket 48384 - Fix dblayer_is_cachesize_sane and dblayer_sys_pages for linux
Bug Description:
At this point in time, the current algorithm to determine if
the cachesizing is sane is based on:
issane = (int)((*cachesize / pagesize) <= (pages - procpages));
However, the values of pages and procpages are suspect:
Consider:
dblayer_is_cachesize_sane pages=3050679 / procpages=268505910
This isn't a type: procpages often exceeds pages. This is because procpages is
derived from /proc/pid/status, vmsize, which is the maximum amount of ram a
process *could* allocate.
Additionally, the value of pages may exceed out vmsize, so we may be over
eagerly allocating memory, that we don't actually have access to. Vmsize also
includes swap space, so we might be trying to alloc memory into swap too.
dblayer_is_cachesize_sane also only takes into account pages (total on system)
and the current process' allocation: This makes no regard to:
* How much ram is *actually* free on the system with respect to other processes
* The value of getrlimit via availpages.
The first condition is especially bad, because our system may be approaching an
OOM condition, and we blazenly allocate a swathe of pages which triggers this.
Fix Description:
First, this fix corrects procpages to be based on vmrss, which
is the actual working set size of the process, rather than the maximum possible
allocation in vmsize.
The value of pages is taken from the smaller of:
* vmsize
* systeminfo total ram (excluding swap)
The value of availpages is derived from the smallest of:
* pages
* getrlimit
* freepages (with consideration of all processes on system)
The check for issane now checks that the cachepage request is smaller than
availpages, which guarantees:
* Our system actually has the ram free to accomodate them without swapping or
triggering an OOM condition.
* We respect rlimits in the allocation.
Next, this moves the cachesize_is_sane and sys_pages utilities to util.c. This
way we can begin to reference these checks in other areas of the code.
We also change the way that we calculate free and total memory. Linux as it seems
does not offer a complete API for sysinfo, so the only way to really get these
is to read /proc/meminfo.
This fixes the live calls from cn=config to only checkmemory allocation based on
the difference, due to the fact the current allocation is already passed and may
be consuming ram.
https://fedorahosted.org/389/ticket/48384
Author: wibrown
Review by: nhosoi, tbordaz, lkrispen (Thanks!)
|
commit 476af053a60003c4c017f320d55860d7ecb29ac9
Author: William Brown <[email protected]>
Date: Wed Jan 13 12:21:25 2016 +1000
Ticket 48384 - Fix dblayer_is_cachesize_sane and dblayer_sys_pages for linux
Bug Description:
At this point in time, the current algorithm to determine if
the cachesizing is sane is based on:
issane = (int)((*cachesize / pagesize) <= (pages - procpages));
However, the values of pages and procpages are suspect:
Consider:
dblayer_is_cachesize_sane pages=3050679 / procpages=268505910
This isn't a type: procpages often exceeds pages. This is because procpages is
derived from /proc/pid/status, vmsize, which is the maximum amount of ram a
process *could* allocate.
Additionally, the value of pages may exceed out vmsize, so we may be over
eagerly allocating memory, that we don't actually have access to. Vmsize also
includes swap space, so we might be trying to alloc memory into swap too.
dblayer_is_cachesize_sane also only takes into account pages (total on system)
and the current process' allocation: This makes no regard to:
* How much ram is *actually* free on the system with respect to other processes
* The value of getrlimit via availpages.
The first condition is especially bad, because our system may be approaching an
OOM condition, and we blazenly allocate a swathe of pages which triggers this.
Fix Description:
First, this fix corrects procpages to be based on vmrss, which
is the actual working set size of the process, rather than the maximum possible
allocation in vmsize.
The value of pages is taken from the smaller of:
* vmsize
* systeminfo total ram (excluding swap)
The value of availpages is derived from the smallest of:
* pages
* getrlimit
* freepages (with consideration of all processes on system)
The check for issane now checks that the cachepage request is smaller than
availpages, which guarantees:
* Our system actually has the ram free to accomodate them without swapping or
triggering an OOM condition.
* We respect rlimits in the allocation.
Next, this moves the cachesize_is_sane and sys_pages utilities to util.c. This
way we can begin to reference these checks in other areas of the code.
We also change the way that we calculate free and total memory. Linux as it seems
does not offer a complete API for sysinfo, so the only way to really get these
is to read /proc/meminfo.
This fixes the live calls from cn=config to only checkmemory allocation based on
the difference, due to the fact the current allocation is already passed and may
be consuming ram.
https://fedorahosted.org/389/ticket/48384
Author: wibrown
Review by: nhosoi, tbordaz, lkrispen (Thanks!)
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
index 65439e795..f6a9cf5cc 100644
--- a/ldap/servers/slapd/back-ldbm/cache.c
+++ b/ldap/servers/slapd/back-ldbm/cache.c
@@ -678,7 +678,10 @@ static void entrycache_set_max_size(struct cache *cache, size_t bytes)
cache_make_hashes(cache, CACHE_TYPE_ENTRY);
}
cache_unlock(cache);
- if (! dblayer_is_cachesize_sane(&bytes)) {
+ /* This may already have been called by one of the functions in
+ * ldbm_instance_config
+ */
+ if (! util_is_cachesize_sane(&bytes)) {
LDAPDebug(LDAP_DEBUG_ANY,
"WARNING -- Possible CONFIGURATION ERROR -- cachesize "
"(%lu) may be configured to use more than the available "
@@ -1613,7 +1616,10 @@ dncache_set_max_size(struct cache *cache, size_t bytes)
cache_make_hashes(cache, CACHE_TYPE_DN);
}
cache_unlock(cache);
- if (! dblayer_is_cachesize_sane(&bytes)) {
+ /* This may already have been called by one of the functions in
+ * ldbm_instance_config
+ */
+ if (! util_is_cachesize_sane(&bytes)) {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"WARNING -- Possible CONFIGURATION ERROR -- cachesize "
"(%lu) may be configured to use more than the available "
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index e65f3cfd8..bc290cb2e 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -68,7 +68,6 @@
#include <prclist.h>
#include <sys/types.h>
#include <sys/statvfs.h>
-#include <sys/resource.h>
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4100
#define DB_OPEN(oflags, db, txnid, file, database, type, flags, mode, rval) \
@@ -869,190 +868,6 @@ static void dblayer_init_dbenv(DB_ENV *pEnv, dblayer_private *priv)
#endif
}
-/* returns system pagesize (in bytes) and the number of pages of physical
- * RAM this machine has.
- * as a bonus, if 'procpages' is non-NULL, it will be filled in with the
- * approximate number of pages this process is using!
- * on platforms that we haven't figured out how to do this yet, both fields
- * are filled with zero and you're on your own.
- *
- * platforms supported so far:
- * Solaris, Linux, Windows
- */
-#ifdef OS_solaris
-#include <sys/procfs.h>
-#endif
-#ifdef LINUX
-#include <linux/kernel.h>
-#include <sys/sysinfo.h> /* undocumented (?) */
-#endif
-#if defined ( hpux )
-#include <sys/pstat.h>
-#endif
-
-static size_t dblayer_getvirtualmemsize()
-{
- struct rlimit rl;
-
- /* the maximum size of a process's total available memory, in bytes */
- getrlimit(RLIMIT_AS, &rl);
- return rl.rlim_cur;
-}
-
-/* pages = number of pages of physical ram on the machine (corrected for 32-bit build on 64-bit machine).
- * procpages = pages currently used by this process (or working set size, sometimes)
- * availpages = some notion of the number of pages 'free'. Typically this number is not useful.
- */
-void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_t *availpages)
-{
- *pagesize = *pages = *availpages = 0;
- if (procpages)
- *procpages = 0;
-
-#ifdef OS_solaris
- *pagesize = (int)sysconf(_SC_PAGESIZE);
- *pages = (int)sysconf(_SC_PHYS_PAGES);
- *availpages = dblayer_getvirtualmemsize() / *pagesize;
- /* solaris has THE most annoying way to get this info */
- if (procpages) {
- struct prpsinfo psi;
- char fn[40];
- int fd;
-
- sprintf(fn, "/proc/%d", getpid());
- fd = open(fn, O_RDONLY);
- if (fd >= 0) {
- memset(&psi, 0, sizeof(psi));
- if (ioctl(fd, PIOCPSINFO, (void *)&psi) == 0)
- *procpages = psi.pr_size;
- close(fd);
- }
- }
-#endif
-
-#ifdef LINUX
- {
- struct sysinfo si;
- size_t pages_per_mem_unit = 0;
- size_t mem_units_per_page = 0; /* We don't know if these units are really pages */
-
- sysinfo(&si);
- *pagesize = getpagesize();
- if (si.mem_unit > *pagesize) {
- pages_per_mem_unit = si.mem_unit / *pagesize;
- *pages = si.totalram * pages_per_mem_unit;
- } else {
- mem_units_per_page = *pagesize / si.mem_unit;
- *pages = si.totalram / mem_units_per_page;
- }
- *availpages = dblayer_getvirtualmemsize() / *pagesize;
- /* okay i take that back, linux's method is more retarded here.
- * hopefully linux doesn't have the FILE* problem that solaris does
- * (where you can't use FILE if you have more than 256 fd's open)
- */
- if (procpages) {
- FILE *f;
- char fn[40], s[80];
-
- sprintf(fn, "/proc/%d/status", getpid());
- f = fopen(fn, "r");
- if (!f) /* fopen failed */
- return;
- while (! feof(f)) {
- fgets(s, 79, f);
- if (feof(f))
- break;
- if (strncmp(s, "VmSize:", 7) == 0) {
- sscanf(s+7, "%lu", (long unsigned int *)procpages);
- break;
- }
- }
- fclose(f);
- /* procpages is now in 1k chunks, not pages... */
- *procpages /= (*pagesize / 1024);
- }
- }
-#endif
-
-#if defined ( hpux )
- {
- struct pst_static pst;
- int rval = pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0);
- if (rval < 0) /* pstat_getstatic failed */
- return;
- *pagesize = pst.page_size;
- *pages = pst.physical_memory;
- *availpages = dblayer_getvirtualmemsize() / *pagesize;
- if (procpages)
- {
-#define BURST (size_t)32 /* get BURST proc info at one time... */
- struct pst_status psts[BURST];
- int i, count;
- int idx = 0; /* index within the context */
- int mypid = getpid();
-
- *procpages = 0;
- /* loop until count == 0, will occur all have been returned */
- while ((count = pstat_getproc(psts, sizeof(psts[0]), BURST, idx)) > 0) {
- /* got count (max of BURST) this time. process them */
- for (i = 0; i < count; i++) {
- if (psts[i].pst_pid == mypid)
- {
- *procpages = (size_t)(psts[i].pst_dsize + psts[i].pst_tsize + psts[i].pst_ssize);
- break;
- }
- }
- if (i < count)
- break;
-
- /*
- * now go back and do it again, using the next index after
- * the current 'burst'
- */
- idx = psts[count-1].pst_idx + 1;
- }
- }
- }
-#endif
- /* If this is a 32-bit build, it might be running on a 64-bit machine,
- * in which case, if the box has tons of ram, we can end up telling
- * the auto cache code to use more memory than the process can address.
- * so we cap the number returned here.
- */
-#if defined(__LP64__) || defined (_LP64)
-#else
- {
- size_t one_gig_pages = GIGABYTE / *pagesize;
- if (*pages > (2 * one_gig_pages) ) {
- LDAPDebug(LDAP_DEBUG_TRACE,"More than 2Gbytes physical memory detected. Since this is a 32-bit process, truncating memory size used for auto cache calculations to 2Gbytes\n",
- 0, 0, 0);
- *pages = (2 * one_gig_pages);
- }
- }
-#endif
-}
-
-
-int dblayer_is_cachesize_sane(size_t *cachesize)
-{
- size_t pages = 0, pagesize = 0, procpages = 0, availpages = 0;
- int issane = 1;
-
- dblayer_sys_pages(&pagesize, &pages, &procpages, &availpages);
- if (!pagesize || !pages)
- return 1; /* do nothing when we can't get the avail mem */
- /* If the requested cache size is larger than the remaining pysical memory
- * after the current working set size for this process has been subtracted,
- * then we say that's insane and try to correct.
- */
- issane = (int)((*cachesize / pagesize) <= (pages - procpages));
- if (!issane) {
- *cachesize = (size_t)((pages - procpages) * pagesize);
- }
-
- return issane;
-}
-
static void dblayer_dump_config_tracing(dblayer_private *priv)
{
@@ -1567,7 +1382,7 @@ dblayer_start(struct ldbminfo *li, int dbmode)
/* Sanity check on cache size on platforms which allow us to figure out
* the available phys mem */
- if (!dblayer_is_cachesize_sane(&(priv->dblayer_cachesize))) {
+ if (!util_is_cachesize_sane(&(priv->dblayer_cachesize))) {
/* Oops---looks like the admin misconfigured, let's warn them */
LDAPDebug(LDAP_DEBUG_ANY,"WARNING---Likely CONFIGURATION ERROR---"
"dbcachesize is configured to use more than the available "
@@ -1887,8 +1702,7 @@ check_and_set_import_cache(struct ldbminfo *li)
size_t page_delta = 0;
char s[64]; /* big enough to hold %ld */
- dblayer_sys_pages(&pagesize, &pages, &procpages, &availpages);
- if (0 == pagesize || 0 == pages) {
+ if (util_info_sys_pages(&pagesize, &pages, &procpages, &availpages) != 0 || 0 == pagesize || 0 == pages) {
LDAPDebug2Args(LDAP_DEBUG_ANY, "check_and_set_import_cache: "
"Failed to get pagesize: %ld or pages: %ld\n",
pagesize, pages);
@@ -1928,7 +1742,12 @@ check_and_set_import_cache(struct ldbminfo *li)
} else {
/* autosizing importCache */
/* ./125 instead of ./100 is for adjusting the BDB overhead. */
+#ifdef LINUX
+ /* On linux, availpages is correct so we should use it! */
+ import_pages = (li->li_import_cache_autosize * availpages) / 125;
+#else
import_pages = (li->li_import_cache_autosize * pages) / 125;
+#endif
}
page_delta = pages - import_pages;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index e265bb979..341fdff41 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -402,6 +402,17 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
size_t val = (size_t)value;
+ size_t delta = (size_t)value;
+
+ /* There is an error here. We check the new val against our current mem-alloc
+ * Issue is that we already are using system pages, so while our value *might*
+ * be valid, we may reject it here due to the current procs page usage.
+ *
+ * So how do we solve this? If we are setting a SMALLER value than we
+ * currently have ALLOW it, because we already passed the cache sanity.
+ * If we are setting a LARGER value, we check the delta of the two, and make
+ * sure that it is sane.
+ */
if (apply) {
/* Stop the user configuring a stupidly small cache */
@@ -411,12 +422,15 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
LDAPDebug( LDAP_DEBUG_ANY,"WARNING: cache too small, increasing to %dK bytes\n",
DBDEFMINSIZ/1000, 0, 0);
val = DBDEFMINSIZ;
- } else if (!dblayer_is_cachesize_sane(&val)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: dbcachememsize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: dbcachememsize value is too large.\n",
- 0, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
+ } else if (val > li->li_dbcachesize) {
+ delta = val - li->li_dbcachesize;
+ if (!util_is_cachesize_sane(&delta)){
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Error: dbcachememsize value is too large.");
+ LDAPDebug( LDAP_DEBUG_ANY,"Error: dbcachememsize value is too large.\n",
+ 0, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
}
if (CONFIG_PHASE_RUNNING == phase) {
li->li_new_dbcachesize = val;
@@ -469,14 +483,28 @@ static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
size_t val = (size_t) ((uintptr_t)value);
+ size_t delta = 0;
+
+ /* There is an error here. We check the new val against our current mem-alloc
+ * Issue is that we already are using system pages, so while our value *might*
+ * be valid, we may reject it here due to the current procs page usage.
+ *
+ * So how do we solve this? If we are setting a SMALLER value than we
+ * currently have ALLOW it, because we already passed the cache sanity.
+ * If we are setting a LARGER value, we check the delta of the two, and make
+ * sure that it is sane.
+ */
if (apply) {
- if (!dblayer_is_cachesize_sane(&val)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: dbncache size value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: dbncache size value is too large.\n",
- val, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
+ if (val > li->li_dbncache) {
+ delta = val - li->li_dbncache;
+ if (!util_is_cachesize_sane(&delta)){
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Error: dbncache size value is too large.");
+ LDAPDebug( LDAP_DEBUG_ANY,"Error: dbncache size value is too large.\n",
+ val, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
}
if (CONFIG_PHASE_RUNNING == phase) {
@@ -1037,14 +1065,28 @@ static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
size_t val = (size_t) ((uintptr_t)value);
+ size_t delta = 0;
+
+ /* There is an error here. We check the new val against our current mem-alloc
+ * Issue is that we already are using system pages, so while our value *might*
+ * be valid, we may reject it here due to the current procs page usage.
+ *
+ * So how do we solve this? If we are setting a SMALLER value than we
+ * currently have ALLOW it, because we already passed the cache sanity.
+ * If we are setting a LARGER value, we check the delta of the two, and make
+ * sure that it is sane.
+ */
if (apply) {
- if (!dblayer_is_cachesize_sane(&val)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: db cachesize value is too large");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: db cachesize value is too large.\n",
- val, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
+ if (val > li->li_dblayer_private->dblayer_cache_config) {
+ delta = val - li->li_dblayer_private->dblayer_cache_config;
+ if (!util_is_cachesize_sane(&delta)){
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Error: db cachesize value is too large");
+ LDAPDebug( LDAP_DEBUG_ANY,"Error: db cachesize value is too large.\n",
+ val, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
}
li->li_dblayer_private->dblayer_cache_config = val;
}
@@ -1158,13 +1200,26 @@ static int ldbm_config_import_cachesize_set(void *arg, void *value, char *errorb
{
struct ldbminfo *li = (struct ldbminfo *)arg;
size_t val = (size_t)value;
+ size_t delta = (size_t)value;
+ /* There is an error here. We check the new val against our current mem-alloc
+ * Issue is that we already are using system pages, so while our value *might*
+ * be valid, we may reject it here due to the current procs page usage.
+ *
+ * So how do we solve this? If we are setting a SMALLER value than we
+ * currently have ALLOW it, because we already passed the cache sanity.
+ * If we are setting a LARGER value, we check the delta of the two, and make
+ * sure that it is sane.
+ */
if (apply){
- if (!dblayer_is_cachesize_sane(&val)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: import cachesize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: import cachesize value is too large.\n",
- 0, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
+ if (val > li->li_import_cachesize) {
+ delta = val - li->li_import_cachesize;
+ if (!util_is_cachesize_sane(&delta)){
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Error: import cachesize value is too large.");
+ LDAPDebug( LDAP_DEBUG_ANY,"Error: import cachesize value is too large.\n",
+ 0, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
}
li->li_import_cachesize = val;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index e9db22b9e..1f750d431 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -92,17 +92,29 @@ ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, in
ldbm_instance *inst = (ldbm_instance *) arg;
int retval = LDAP_SUCCESS;
size_t val = (size_t) value;
- size_t chkval = val;
+ size_t delta = 0;
/* Do whatever we can to make sure the data is ok. */
+ /* There is an error here. We check the new val against our current mem-alloc
+ * Issue is that we already are using system pages, so while our value *might*
+ * be valid, we may reject it here due to the current procs page usage.
+ *
+ * So how do we solve this? If we are setting a SMALLER value than we
+ * currently have ALLOW it, because we already passed the cache sanity.
+ * If we are setting a LARGER value, we check the delta of the two, and make
+ * sure that it is sane.
+ */
if (apply) {
- if (!dblayer_is_cachesize_sane(&chkval)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: cachememsize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: cachememsize value is too large.\n",
- 0, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
+ if (val > inst->inst_cache.c_maxsize) {
+ delta = val - inst->inst_cache.c_maxsize;
+ if (!util_is_cachesize_sane(&delta)){
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Error: cachememsize value is too large.");
+ LDAPDebug( LDAP_DEBUG_ANY,"Error: cachememsize value is too large.\n",
+ 0, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
}
cache_set_max_size(&(inst->inst_cache), val, CACHE_TYPE_ENTRY);
}
@@ -124,17 +136,29 @@ ldbm_instance_config_dncachememsize_set(void *arg, void *value, char *errorbuf,
ldbm_instance *inst = (ldbm_instance *) arg;
int retval = LDAP_SUCCESS;
size_t val = (size_t)value;
- size_t chkval = val;
+ size_t delta = 0;
/* Do whatever we can to make sure the data is ok. */
+ /* There is an error here. We check the new val against our current mem-alloc
+ * Issue is that we already are using system pages, so while our value *might*
+ * be valid, we may reject it here due to the current procs page usage.
+ *
+ * So how do we solve this? If we are setting a SMALLER value than we
+ * currently have ALLOW it, because we already passed the cache sanity.
+ * If we are setting a LARGER value, we check the delta of the two, and make
+ * sure that it is sane.
+ */
if (apply) {
- if (!dblayer_is_cachesize_sane(&chkval)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: dncachememsize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: dncachememsize value is too large.\n",
- 0, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
+ if (val > inst->inst_dncache.c_maxsize) {
+ delta = val - inst->inst_dncache.c_maxsize;
+ if (!util_is_cachesize_sane(&delta)){
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Error: dncachememsize value is too large.");
+ LDAPDebug( LDAP_DEBUG_ANY,"Error: dncachememsize value is too large.\n",
+ 0, 0, 0);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
}
cache_set_max_size(&(inst->inst_dncache), val, CACHE_TYPE_DN);
}
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 37f9f2078..86e2237ff 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -131,8 +131,6 @@ int dblayer_terminate(struct ldbminfo *li);
int dblayer_close_indexes(backend *be);
int dblayer_open_file(backend *be, char* indexname, int create, struct attrinfo *ai, DB **ppDB);
int dblayer_close_file(DB **db);
-void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_t *availpages);
-int dblayer_is_cachesize_sane(size_t *cachesize);
void dblayer_remember_disk_filled(struct ldbminfo *li);
int dblayer_open_huge_file(const char *path, int oflag, int mode);
int dblayer_instance_start(backend *be, int normal_mode);
diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c
index 53c47bd23..5058942ae 100644
--- a/ldap/servers/slapd/back-ldbm/start.c
+++ b/ldap/servers/slapd/back-ldbm/start.c
@@ -118,7 +118,11 @@ ldbm_back_start( Slapi_PBlock *pb )
} else {
size_t pagesize, pages, procpages, availpages;
- dblayer_sys_pages(&pagesize, &pages, &procpages, &availpages);
+ if (util_info_sys_pages(&pagesize, &pages, &procpages, &availpages) != 0) {
+ LDAPDebug( LDAP_DEBUG_ANY, "start: Unable to determine system page limits\n",
+ 0, 0, 0 );
+ return SLAPI_FAIL_GENERAL;
+ }
if (pagesize) {
char s[32]; /* big enough to hold %ld */
unsigned long cache_size_to_configure = 0;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 63fe8cc1a..fb7b5f864 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1334,6 +1334,27 @@ char *slapi_getSSLVersion_str(PRUint16 vnum, char *buf, size_t bufsize);
time_t slapi_parse_duration(const char *value);
int slapi_is_duration_valid(const char *value);
+/**
+ * Populate the pointers with the system memory information.
+ * At this time, Linux is the only "reliable" system for returning these values
+ *
+ * \param pagesize Will return the system page size in bytes.
+ * \param pages The total number of memory pages on the system. May include swap pages depending on OS.
+ * \param procpages Number of memory pages our current process is consuming. May not be accurate on all platforms as this could be the VMSize rather than the actual number of consumed pages.
+ * \param availpages Number of available pages of memory on the system. Not all operating systems set this correctly.
+ *
+ * \return 0 on success, non-zero on failure to determine memory sizings.
+ */
+int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_t *availpages);
+
+/**
+ * Determine if the requested cachesize will exceed the system memory limits causing an out of memory condition
+ *
+ * \param cachesize. The requested allocation. If this value is greater than the memory available, this value will be REDUCED to be valid.
+ *
+ * \return 0 if the size is "sane". 1 if the value will cause OOM and has been REDUCED
+ */
+int util_is_cachesize_sane(size_t *cachesize);
#ifdef __cplusplus
}
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index dbe69f0e9..b7ecde130 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -25,6 +25,7 @@
#include "prinrval.h"
#include "snmp_collator.h"
#include <sys/time.h>
+#include <sys/resource.h>
#define UTIL_ESCAPE_NONE 0
#define UTIL_ESCAPE_HEX 1
@@ -39,6 +40,24 @@
#define FILTER_BUF 128 /* initial buffer size for attr value */
#define BUF_INCR 16 /* the amount to increase the FILTER_BUF once it fills up */
+/* Used by our util_info_sys_pages function
+ *
+ * platforms supported so far:
+ * Solaris, Linux, Windows
+ */
+#ifdef OS_solaris
+#include <sys/procfs.h>
+#endif
+#ifdef LINUX
+#include <linux/kernel.h>
+#endif
+#if defined ( hpux )
+#include <sys/pstat.h>
+#endif
+
+
+
+
static int special_np(unsigned char c)
{
if (c == '\\') {
@@ -1432,3 +1451,349 @@ slapi_uniqueIDRdnSize()
}
return util_uniqueidlen;
}
+
+
+/**
+ * Get the virtual memory size as defined by system rlimits.
+ *
+ * \return size_t bytes available
+ */
+static size_t util_getvirtualmemsize()
+{
+ struct rlimit rl;
+ /* the maximum size of a process's total available memory, in bytes */
+ if (getrlimit(RLIMIT_AS, &rl) != 0) {
+ /* We received an error condition. There are a number of possible
+ * reasons we have have gotten here, but most likely is EINVAL, where
+ * rlim->rlim_cur was greater than rlim->rlim_max.
+ * As a result, we should return a 0, to tell the system we can't alloc
+ * memory.
+ */
+ int errsrv = errno;
+ slapi_log_error(SLAPI_LOG_FATAL,"util_getvirtualmemsize", "ERROR: getrlimit returned non-zero. errno=%u\n", errsrv);
+ return 0;
+ }
+ return rl.rlim_cur;
+}
+
+/* pages = number of pages of physical ram on the machine (corrected for 32-bit build on 64-bit machine).
+ * procpages = pages currently used by this process (or working set size, sometimes)
+ * availpages = some notion of the number of pages 'free'. Typically this number is not useful.
+ */
+int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_t *availpages)
+{
+ *pagesize = 0;
+ *pages = 0;
+ *availpages = 0;
+ if (procpages)
+ *procpages = 0;
+
+#ifdef OS_solaris
+ *pagesize = (int)sysconf(_SC_PAGESIZE);
+ *pages = (int)sysconf(_SC_PHYS_PAGES);
+ *availpages = util_getvirtualmemsize() / *pagesize;
+ /* solaris has THE most annoying way to get this info */
+ if (procpages) {
+ struct prpsinfo psi;
+ char fn[40];
+ int fd;
+
+ sprintf(fn, "/proc/%d", getpid());
+ fd = open(fn, O_RDONLY);
+ if (fd >= 0) {
+ memset(&psi, 0, sizeof(psi));
+ if (ioctl(fd, PIOCPSINFO, (void *)&psi) == 0)
+ *procpages = psi.pr_size;
+ close(fd);
+ }
+ }
+#endif
+
+#ifdef LINUX
+ {
+ /*
+ * On linux because of the way that the virtual memory system works, we
+ * don't really need to think about other processes, or fighting them.
+ * But that's not without quirks.
+ *
+ * We are given a virtual memory space, represented by vsize (man 5 proc)
+ * This space is a "funny number". It's a best effort based system
+ * where linux instead of telling us how much memory *actually* exists
+ * for us to use, gives us a virtual memory allocation which is the
+ * value of ram + swap.
+ *
+ * But none of these pages even exist or belong to us on the real system
+ * until will malloc them AND write a non-zero to them.
+ *
+ * The biggest issue with this is that vsize does NOT consider the
+ * effect other processes have on the system. So a process can malloc
+ * 2 Gig from the host, and our vsize doesn't reflect that until we
+ * suddenly can't malloc anything.
+ *
+ * We can see exactly what we are using inside of the vmm by
+ * looking at rss (man 5 proc). This shows us the current actual
+ * allocation of memory we are using. This is a good thing.
+ *
+ * We obviously don't want to have any pages in swap, but sometimes we
+ * can't help that: And there is also no guarantee that while we have
+ * X bytes in vsize, that we can even allocate any of them. Plus, we
+ * don't know if we are about to allocate to swap or not .... or get us
+ * killed in a blaze of oom glory.
+ *
+ * So there are now two strategies avaliable in this function.
+ * The first is to blindly accept what the VMM tells us about vsize
+ * while we hope and pray that we don't get nailed because we used
+ * too much.
+ *
+ * The other is a more conservative approach: We check vsize from
+ * proc/pid/status, and we check /proc/meminfo for freemem
+ * Which ever value is "lower" is the upper bound on pages we could
+ * potentially allocate: generally, this will be MemAvailable.
+ */
+
+ size_t vmsize = 0;
+ size_t freesize = 0;
+
+ *pagesize = getpagesize();
+
+ /* Get the amount of freeram, rss, and the vmsize */
+
+ FILE *f;
+ char fn[40], s[80];
+
+ sprintf(fn, "/proc/%d/status", getpid());
+ f = fopen(fn, "r");
+ if (!f) { /* fopen failed */
+ /* We should probably make noise here! */
+ int errsrv = errno;
+ slapi_log_error(SLAPI_LOG_FATAL,"util_info_sys_pages", "ERROR: Unable to open file /proc/%d/status. errno=%u\n", getpid(), errsrv);
+ return 1;
+ }
+ while (! feof(f)) {
+ fgets(s, 79, f);
+ if (feof(f)) {
+ break;
+ }
+ /* VmRSS shows us what we are ACTUALLY using for proc pages
+ * Rather than "funny" pages.
+ */
+ if (strncmp(s, "VmSize:", 7) == 0) {
+ sscanf(s+7, "%lu", (long unsigned int *)&vmsize);
+ }
+ if (strncmp(s, "VmRSS:", 6) == 0) {
+ sscanf(s+6, "%lu", (long unsigned int *)procpages);
+ }
+ }
+ fclose(f);
+
+ FILE *fm;
+ char *fmn = "/proc/meminfo";
+ fm = fopen(fmn, "r");
+ if (!fm) {
+ int errsrv = errno;
+ slapi_log_error(SLAPI_LOG_FATAL,"util_info_sys_pages", "ERROR: Unable to open file /proc/meminfo. errno=%u\n", errsrv);
+ return 1;
+ }
+ while (! feof(fm)) {
+ fgets(s, 79, fm);
+ /* Is this really needed? */
+ if (feof(fm)) {
+ break;
+ }
+ if (strncmp(s, "MemTotal:", 9) == 0) {
+ sscanf(s+9, "%lu", (long unsigned int *)pages);
+ }
+ if (strncmp(s, "MemAvailable:", 13) == 0) {
+ sscanf(s+13, "%lu", (long unsigned int *)&freesize);
+ }
+ }
+ fclose(fm);
+
+
+ *pages /= (*pagesize / 1024);
+ freesize /= (*pagesize / 1024);
+ /* procpages is now in kb not pages... */
+ *procpages /= (*pagesize / 1024);
+ /* This is in bytes, make it pages */
+ *availpages = util_getvirtualmemsize() / *pagesize;
+ /* Now we have vmsize, the availpages from getrlimit, our freesize */
+ vmsize /= (*pagesize / 1024);
+
+ /* Pages is the total ram on the system. We should smaller of:
+ * - vmsize
+ * - pages
+ */
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages pages=%lu, vmsize=%lu, \n",
+ (unsigned long) *pages, (unsigned long) vmsize,0);
+ if (vmsize < *pages) {
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using vmsize for pages \n",0,0,0);
+ *pages = vmsize;
+ } else {
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using pages for pages \n",0,0,0);
+ }
+
+ /* Availpages is how much we *could* alloc. We should take the smallest:
+ * - pages
+ * - getrlimit (availpages)
+ * - freesize
+ */
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages pages=%lu, getrlim=%lu, freesize=%lu\n",
+ (unsigned long)*pages, (unsigned long)*availpages, (unsigned long)freesize);
+ if (*pages < *availpages && *pages < freesize) {
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using pages for availpages \n",0,0,0);
+ *availpages = *pages;
+ } else if ( freesize < *pages && freesize < *availpages ) {
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using freesize for availpages \n",0,0,0);
+ *availpages = freesize;
+ } else {
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using getrlim for availpages \n",0,0,0);
+ }
+
+
+ }
+#endif /* linux */
+
+
+
+#if defined ( hpux )
+ {
+ struct pst_static pst;
+ int rval = pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0);
+ if (rval < 0) { /* pstat_getstatic failed */
+ return 1;
+ }
+ *pagesize = pst.page_size;
+ *pages = pst.physical_memory;
+ *availpages = util_getvirtualmemsize() / *pagesize;
+ if (procpages)
+ {
+#define BURST (size_t)32 /* get BURST proc info at one time... */
+ struct pst_status psts[BURST];
+ int i, count;
+ int idx = 0; /* index within the context */
+ int mypid = getpid();
+
+ *procpages = 0;
+ /* loop until count == 0, will occur all have been returned */
+ while ((count = pstat_getproc(psts, sizeof(psts[0]), BURST, idx)) > 0) {
+ /* got count (max of BURST) this time. process them */
+ for (i = 0; i < count; i++) {
+ if (psts[i].pst_pid == mypid)
+ {
+ *procpages = (size_t)(psts[i].pst_dsize + psts[i].pst_tsize + psts[i].pst_ssize);
+ break;
+ }
+ }
+ if (i < count)
+ break;
+
+ /*
+ * now go back and do it again, using the next index after
+ * the current 'burst'
+ */
+ idx = psts[count-1].pst_idx + 1;
+ }
+ }
+ }
+#endif
+ /* If this is a 32-bit build, it might be running on a 64-bit machine,
+ * in which case, if the box has tons of ram, we can end up telling
+ * the auto cache code to use more memory than the process can address.
+ * so we cap the number returned here.
+ */
+#if defined(__LP64__) || defined (_LP64)
+#else
+ {
+ size_t one_gig_pages = GIGABYTE / *pagesize;
+ if (*pages > (2 * one_gig_pages) ) {
+ LDAPDebug(LDAP_DEBUG_TRACE,"More than 2Gbytes physical memory detected. Since this is a 32-bit process, truncating memory size used for auto cache calculations to 2Gbytes\n",
+ 0, 0, 0);
+ *pages = (2 * one_gig_pages);
+ }
+ }
+#endif
+
+ /* This is stupid. If you set %u to %zu to print a size_t, you get literal %zu in your logs
+ * So do the filthy cast instead.
+ */
+ slapi_log_error(SLAPI_LOG_FATAL,"util_info_sys_pages", "USING pages=%lu, procpages=%lu, availpages=%lu \n",
+ (unsigned long)*pages, (unsigned long)*procpages, (unsigned long)*availpages);
+ return 0;
+
+}
+
+int util_is_cachesize_sane(size_t *cachesize)
+{
+ size_t pages = 0;
+ size_t pagesize = 0;
+ size_t procpages = 0;
+ size_t availpages = 0;
+
+ size_t cachepages = 0;
+
+ int issane = 1;
+
+ if (util_info_sys_pages(&pagesize, &pages, &procpages, &availpages) != 0) {
+ goto out;
+ }
+#ifdef LINUX
+ /* Linux we calculate availpages correctly, so USE IT */
+ if (!pagesize || !availpages) {
+ goto out;
+ }
+#else
+ if (!pagesize || !pages) {
+ goto out;
+ }
+#endif
+ /* do nothing when we can't get the avail mem */
+
+
+ /* If the requested cache size is larger than the remaining physical memory
+ * after the current working set size for this process has been subtracted,
+ * then we say that's insane and try to correct.
+ */
+
+ cachepages = *cachesize / pagesize;
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_is_cachesize_sane cachesize=%lu / pagesize=%lu \n",
+ (unsigned long)*cachesize,(unsigned long)pagesize,0);
+
+#ifdef LINUX
+ /* Linux we calculate availpages correctly, so USE IT */
+ issane = (int)(cachepages <= availpages);
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_is_cachesize_sane cachepages=%lu <= availpages=%lu\n",
+ (unsigned long)cachepages,(unsigned long)availpages,0);
+
+ if (!issane) {
+ /* Since we are ask for more than what's available, we give half of
+ * the remaining system mem to the cachesize instead, and log a warning
+ */
+ *cachesize = (size_t)((availpages / 2) * pagesize);
+ slapi_log_error(SLAPI_LOG_FATAL, "util_is_cachesize_sane", "WARNING adjusted cachesize to %lu\n", (unsigned long)*cachesize);
+ }
+#else
+ size_t freepages = 0;
+ freepages = pages - procpages;
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_is_cachesize_sane pages=%lu - procpages=%lu\n",
+ (unsigned long)pages,(unsigned long)procpages,0);
+
+ issane = (int)(cachepages <= freepages);
+ LDAPDebug(LDAP_DEBUG_TRACE,"util_is_cachesize_sane cachepages=%lu <= freepages=%lu\n",
+ (unsigned long)cachepages,(unsigned long)freepages,0);
+
+ if (!issane) {
+ *cachesize = (size_t)((pages - procpages) * pagesize);
+ slapi_log_error(SLAPI_LOG_FATAL, "util_is_cachesize_sane", "util_is_cachesize_sane WARNING adjusted cachesize to %lu\n",
+ (unsigned long )*cachesize);
+ }
+#endif
+out:
+ if (!issane) {
+ slapi_log_error(SLAPI_LOG_FATAL,"util_is_cachesize_sane", "WARNING: Cachesize not sane \n");
+ }
+
+ return issane;
+}
+
+
+
| 0 |
73638d68cc213a533b165bfab99df881ebcc8c7e
|
389ds/389-ds-base
|
Issue 49560 - Add a test case for extract-pemfiles
Description: Add a test case to existing test suite:
replication/tls_client_auth_repl_test.py
It should test that replication works with 'on' and 'off'
values and the default vaue is right.
https://pagure.io/389-ds-base/issue/49560
Reviewed by: wibrown (Thanks!)
|
commit 73638d68cc213a533b165bfab99df881ebcc8c7e
Author: Simon Pichugin <[email protected]>
Date: Tue Feb 20 19:49:35 2018 +0100
Issue 49560 - Add a test case for extract-pemfiles
Description: Add a test case to existing test suite:
replication/tls_client_auth_repl_test.py
It should test that replication works with 'on' and 'off'
values and the default vaue is right.
https://pagure.io/389-ds-base/issue/49560
Reviewed by: wibrown (Thanks!)
diff --git a/dirsrvtests/tests/suites/replication/tls_client_auth_repl_test.py b/dirsrvtests/tests/suites/replication/tls_client_auth_repl_test.py
index a27ee1138..07a9948ad 100644
--- a/dirsrvtests/tests/suites/replication/tls_client_auth_repl_test.py
+++ b/dirsrvtests/tests/suites/replication/tls_client_auth_repl_test.py
@@ -6,38 +6,33 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
#
+import logging
+import os
import pytest
-from lib389.topologies import topology_m2 as topo_m2
-
-from lib389.idm.organisationalunit import OrganisationalUnits
-from lib389.idm.group import Groups
+from lib389.utils import ds_is_older
from lib389.idm.services import ServiceAccounts
-from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES
-
-from lib389.nss_ssl import NssSsl
-
from lib389.config import CertmapLegacy
-
from lib389._constants import DEFAULT_SUFFIX
-
from lib389.replica import ReplicationManager, Replicas
+from lib389.topologies import topology_m2 as topo_m2
-def test_tls_client_auth(topo_m2):
- """Test TLS client authentication between two masters operates
- as expected.
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
- :id: 922d16f8-662a-4915-a39e-0aecd7c8e6e6
- :steps:
- 1. Enable TLS on both masters
- 2. Reconfigure both agreements to use TLS Client auth
- 3. Ensure replication events work
- :expectedresults:
- 1. Tls is setup
- 2. The configuration works, and authentication works
- 3. Replication ... replicates.
+
[email protected](scope="module")
+def tls_client_auth(topo_m2):
+ """Enable TLS on both masters and reconfigure
+ both agreements to use TLS Client auth
"""
+
m1 = topo_m2.ms['master1']
m2 = topo_m2.ms['master2']
+
# Create the certmap before we restart for enable_tls
cm_m1 = CertmapLegacy(m1)
cm_m2 = CertmapLegacy(m2)
@@ -85,8 +80,40 @@ def test_tls_client_auth(topo_m2):
)
agmt_m2.remove_all('nsDS5ReplicaBindDN')
- repl.test_replication(m1, m2)
- repl.test_replication(m2, m1)
+ repl.test_replication_topology(topo_m2)
+
+ return topo_m2
+
+
+def test_extract_pemfiles(tls_client_auth):
+ """Test TLS client authentication between two masters operates
+ as expected with 'on' and 'off' options of nsslapd-extract-pemfiles
+ :id: 922d16f8-662a-4915-a39e-0aecd7c8e6e1
+ :setup: Two master replication, enabled TLS client auth
+ :steps:
+ 1. Check that nsslapd-extract-pemfiles default value is right
+ 2. Check that replication works with both 'on' and 'off' values
+ :expectedresults:
+ 1. Success
+ 2. Replication works
+ """
+
+ m1 = tls_client_auth.ms['master1']
+ m2 = tls_client_auth.ms['master2']
+ repl = ReplicationManager(DEFAULT_SUFFIX)
+ if ds_is_older('1.3.7'):
+ default_val = 'off'
+ else:
+ default_val = 'on'
+ attr_val = m1.config.get_attr_val_utf8('nsslapd-extract-pemfiles')
+ log.info("Check that nsslapd-extract-pemfiles is {}".format(default_val))
+ assert attr_val == default_val
+
+ for extract_pemfiles in ('on', 'off'):
+ log.info("Set nsslapd-extract-pemfiles = '{}' and check replication works)")
+ m1.config.set('nsslapd-extract-pemfiles', extract_pemfiles)
+ m2.config.set('nsslapd-extract-pemfiles', extract_pemfiles)
+ repl.test_replication_topology(tls_client_auth)
| 0 |
6a1d7851364d6c5655c2f4f1d0260a91b36afb0f
|
389ds/389-ds-base
|
Issue 50975 - Revise UI branding with new minimized build
Description: We can no longer use the previous method of text replacement
to brand the UI for downstream vs upstream builds. Instead
we can use css files to set the branding, and the specfile
can do a text replacement on the non-miminized css file.
fixes: https://pagure.io/389-ds-base/issue/50975
Reviewed by: firstyear & mhonek (Thanks!!)
|
commit 6a1d7851364d6c5655c2f4f1d0260a91b36afb0f
Author: Mark Reynolds <[email protected]>
Date: Tue Mar 24 11:44:10 2020 -0400
Issue 50975 - Revise UI branding with new minimized build
Description: We can no longer use the previous method of text replacement
to brand the UI for downstream vs upstream builds. Instead
we can use css files to set the branding, and the specfile
can do a text replacement on the non-miminized css file.
fixes: https://pagure.io/389-ds-base/issue/50975
Reviewed by: firstyear & mhonek (Thanks!!)
diff --git a/src/cockpit/389-console/src/css/branding.css b/src/cockpit/389-console/src/css/branding.css
new file mode 100644
index 000000000..0f6c4095e
--- /dev/null
+++ b/src/cockpit/389-console/src/css/branding.css
@@ -0,0 +1,3 @@
+#main-banner::before {
+ content: "389 Directory Server Management";
+}
diff --git a/src/cockpit/389-console/src/ds.jsx b/src/cockpit/389-console/src/ds.jsx
index c003d1690..f83ce5576 100644
--- a/src/cockpit/389-console/src/ds.jsx
+++ b/src/cockpit/389-console/src/ds.jsx
@@ -35,6 +35,7 @@ import {
Button
} from "patternfly-react";
import "./css/ds.css";
+import "./css/branding.css";
const staticStates = {
noPackage: (
@@ -532,7 +533,6 @@ export class DSInstance extends React.Component {
pageLoadingState.state !== "noPackage" ? (
<div className="ds-logo" hidden={pageLoadingState.state === "loading"}>
<h2 className="ds-logo-style" id="main-banner">
- 389 Directory Server Management
<div className="dropdown ds-server-action">
<select
className="btn btn-default dropdown"
diff --git a/src/cockpit/389-console/src/index.html b/src/cockpit/389-console/src/index.html
index a243e1e56..1278844fc 100644
--- a/src/cockpit/389-console/src/index.html
+++ b/src/cockpit/389-console/src/index.html
@@ -1,13 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <title>389 Directory Server</title>
+ <title>Directory Server Management</title>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="../base1/cockpit.js"></script>
<link rel="stylesheet" href="../base1/patternfly.css">
<link href="css/ds.css" type="text/css" rel="stylesheet">
+ <link href="css/branding.css" type="text/css" rel="stylesheet">
</head>
@@ -16,4 +17,3 @@
<script src="index.js"></script>
</body>
</html>
-
| 0 |
101cce51e6f5a000f283da35cce957e38d8900e6
|
389ds/389-ds-base
|
Ticket 47747 - Add topology_i2 and topology_i3
Description: Add two more topologies with two and three standalone
instances. It would be more logical to call it "instance1", etc.,
but we areforced to use "standalone1" terminology for the compatibility
and efficiency.
You can refer to the instances with topology_i2.ins["standalon1"] dict.
Also you can enable a replication using REPLICAID_STANDALONE_* constants.
https://fedorahosted.org/389/ticket/47747
Reviewed by: lkrispen (Thanks!)
|
commit 101cce51e6f5a000f283da35cce957e38d8900e6
Author: Simon Pichugin <[email protected]>
Date: Fri Jan 13 16:20:45 2017 +0100
Ticket 47747 - Add topology_i2 and topology_i3
Description: Add two more topologies with two and three standalone
instances. It would be more logical to call it "instance1", etc.,
but we areforced to use "standalone1" terminology for the compatibility
and efficiency.
You can refer to the instances with topology_i2.ins["standalon1"] dict.
Also you can enable a replication using REPLICAID_STANDALONE_* constants.
https://fedorahosted.org/389/ticket/47747
Reviewed by: lkrispen (Thanks!)
diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py
index 628959b0c..0e7c742b1 100644
--- a/src/lib389/lib389/_constants.py
+++ b/src/lib389/lib389/_constants.py
@@ -249,6 +249,7 @@ for i in range(port_start, port_start + number_of_instances):
exec("PORT_STANDALONE{0} = {1}".format(N, i))
exec("SECUREPORT_STANDALONE{0} = {1}".format(N, i + 24700))
exec("SERVERID_STANDALONE{0} = {1}".format(N, "\"standalone_{0}\"".format(N)))
+ exec("REPLICAID_STANDALONE_{0} = {1}".format(N, 65535))
# For compatibility
HOST_STANDALONE = HOST_STANDALONE1
diff --git a/src/lib389/lib389/topologies.py b/src/lib389/lib389/topologies.py
index 7880fb6d2..56a8169c7 100644
--- a/src/lib389/lib389/topologies.py
+++ b/src/lib389/lib389/topologies.py
@@ -6,11 +6,12 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
#
-import os
+import logging
import sys
import time
-import logging
+
import pytest
+
from lib389 import DirSrv
from lib389._constants import *
from lib389.properties import *
@@ -24,10 +25,13 @@ log = logging.getLogger(__name__)
class TopologyMain(object):
- def __init__(self, standalone=None, masters=None,
+ def __init__(self, standalones=None, masters=None,
consumers=None, hubs=None):
- if standalone:
- self.standalone = standalone
+ if standalones:
+ if isinstance(standalones, dict):
+ self.ins = standalones
+ else:
+ self.standalone = standalones
if masters:
self.ms = masters
if consumers:
@@ -44,9 +48,9 @@ def topology_st(request):
standalone = DirSrv(verbose=True)
else:
standalone = DirSrv(verbose=False)
- args_instance[SER_HOST] = HOST_STANDALONE
- args_instance[SER_PORT] = PORT_STANDALONE
- args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_HOST] = HOST_STANDALONE1
+ args_instance[SER_PORT] = PORT_STANDALONE1
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE1
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_standalone = args_instance.copy()
standalone.allocate(args_standalone)
@@ -64,7 +68,125 @@ def topology_st(request):
request.addfinalizer(fin)
- return TopologyMain(standalone=standalone)
+ return TopologyMain(standalones=standalone)
+
+
[email protected](scope="module")
+def topology_i2(request):
+ """Create two instance DS deployment"""
+
+ if DEBUGGING:
+ standalone1 = DirSrv(verbose=True)
+ else:
+ standalone1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE1
+ args_instance[SER_PORT] = PORT_STANDALONE1
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone1 = args_instance.copy()
+ standalone1.allocate(args_standalone1)
+ instance_standalone1 = standalone1.exists()
+ if instance_standalone1:
+ standalone1.delete()
+ standalone1.create()
+ standalone1.open()
+
+ if DEBUGGING:
+ standalone2 = DirSrv(verbose=True)
+ else:
+ standalone2 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE2
+ args_instance[SER_PORT] = PORT_STANDALONE2
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE2
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone2 = args_instance.copy()
+ standalone2.allocate(args_standalone2)
+ instance_standalone2 = standalone2.exists()
+ if instance_standalone2:
+ standalone2.delete()
+ standalone2.create()
+ standalone2.open()
+
+ def fin():
+ if DEBUGGING:
+ standalone1.stop()
+ standalone2.stop()
+ else:
+ standalone1.delete()
+ standalone2.delete()
+
+ request.addfinalizer(fin)
+
+ return TopologyMain(standalones={"standalone1": standalone1, "standalone2": standalone2})
+
+
[email protected](scope="module")
+def topology_i3(request):
+ """Create three instance DS deployment"""
+
+ if DEBUGGING:
+ standalone1 = DirSrv(verbose=True)
+ else:
+ standalone1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE1
+ args_instance[SER_PORT] = PORT_STANDALONE1
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone1 = args_instance.copy()
+ standalone1.allocate(args_standalone1)
+ instance_standalone1 = standalone1.exists()
+ if instance_standalone1:
+ standalone1.delete()
+ standalone1.create()
+ standalone1.open()
+
+ if DEBUGGING:
+ standalone2 = DirSrv(verbose=True)
+ else:
+ standalone2 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE2
+ args_instance[SER_PORT] = PORT_STANDALONE2
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE2
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone2 = args_instance.copy()
+ standalone2.allocate(args_standalone2)
+ instance_standalone2 = standalone2.exists()
+ if instance_standalone2:
+ standalone2.delete()
+ standalone2.create()
+ standalone2.open()
+
+ if DEBUGGING:
+ standalone3 = DirSrv(verbose=True)
+ else:
+ standalone3 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE3
+ args_instance[SER_PORT] = PORT_STANDALONE3
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE3
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone3 = args_instance.copy()
+ standalone3.allocate(args_standalone3)
+ instance_standalone3 = standalone3.exists()
+ if instance_standalone3:
+ standalone3.delete()
+ standalone3.create()
+ standalone3.open()
+
+ def fin():
+ if DEBUGGING:
+ standalone1.stop()
+ standalone2.stop()
+ standalone3.stop()
+ else:
+ standalone1.delete()
+ standalone2.delete()
+ standalone3.delete()
+
+ request.addfinalizer(fin)
+
+ return TopologyMain(standalones={"standalone1": standalone1,
+ "standalone2": standalone2,
+ "standalone3": standalone3})
@pytest.fixture(scope="module")
| 0 |
9cf26213804c3788c92fc1638b4555615d4c1d20
|
389ds/389-ds-base
|
Ticket 48820 - Begin to test compatability with py.test3, and the new orm
Bug Description: We should convert our existing python tests to py.test-3 and
they should work with the new ldap mapping types.
Fix Description:
* move all the random data genteration to passwd.py.
* Fix some backend handling data
* Fix broken self.conn calls in config
* Add some ldap filter injection defence to the DSLdapObject types
* Convert the test -k test_list lib389/lib389/tests/backend_test.py to the new backend type
* many more fixes for python 3 compatability
https://fedorahosted.org/389/ticket/48820
Author: wibrown
Review by: spichigi, mreynolds (Thanks!)
|
commit 9cf26213804c3788c92fc1638b4555615d4c1d20
Author: William Brown <[email protected]>
Date: Thu Jun 2 13:54:21 2016 +1000
Ticket 48820 - Begin to test compatability with py.test3, and the new orm
Bug Description: We should convert our existing python tests to py.test-3 and
they should work with the new ldap mapping types.
Fix Description:
* move all the random data genteration to passwd.py.
* Fix some backend handling data
* Fix broken self.conn calls in config
* Add some ldap filter injection defence to the DSLdapObject types
* Convert the test -k test_list lib389/lib389/tests/backend_test.py to the new backend type
* many more fixes for python 3 compatability
https://fedorahosted.org/389/ticket/48820
Author: wibrown
Review by: spichigi, mreynolds (Thanks!)
diff --git a/src/lib389/Makefile b/src/lib389/Makefile
index 0a24a31e5..66427a9e6 100644
--- a/src/lib389/Makefile
+++ b/src/lib389/Makefile
@@ -1,14 +1,15 @@
.PHONY: build install test rpms srpms
LIB389_VERS ?= $(shell cat ./VERSION | head -n 1)
+PYTHON ?= /usr/bin/python
all: build
build:
- python setup.py build
+ $(PYTHON) setup.py build
install:
- python setup.py install --force --root=/
+ $(PYTHON) setup.py install --force --root=/
rpmbuild-prep:
mkdir -p ./dist/
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 3e762dc0b..d8a9d8bb0 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -242,8 +242,8 @@ class DirSrv(SimpleLDAPObject):
# parse the lib dir, and so set the plugin dir
self.instdir = instdir
### THIS NEEDS TO BE FIXED .... There is no guarantee this is correct.
- self.libdir = self.instdir.replace(u'slapd-%s' % self.serverid, u'')
- self.plugindir = self.libdir + 'plugins'
+ self.libdir = self.instdir.replace(ensure_bytes('slapd-%s' % self.serverid), ensure_bytes(''))
+ self.plugindir = self.libdir + ensure_bytes('plugins')
#if self.verbose:
# log.debug("instdir=%r" % instdir)
@@ -2922,3 +2922,12 @@ class DirSrv(SimpleLDAPObject):
if rc != 0:
raise ValueError(status)
return status
+
+
+ # This could be made to delete by filter ....
+ def delete_branch_s(self, basedn, scope):
+ ents = self.search_s(basedn, scope)
+ for ent in ents:
+ self.log.debug("Delete entry children %s" % (ent.dn))
+ self.delete_s(ent.dn)
+
diff --git a/src/lib389/lib389/_entry.py b/src/lib389/lib389/_entry.py
index 22a422edd..5e9c40820 100644
--- a/src/lib389/lib389/_entry.py
+++ b/src/lib389/lib389/_entry.py
@@ -19,6 +19,7 @@ MAJOR, MINOR, _, _, _ = sys.version_info
from lib389._constants import *
from lib389.properties import *
+from lib389.utils import ensure_str, ensure_bytes
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
@@ -227,7 +228,7 @@ class Entry(object):
for l in lt:
vals = []
for v in l[1]:
- vals.append(v.encode())
+ vals.append(ensure_bytes(v))
ltnew.append((l[0], vals ))
lt = ltnew
return lt
@@ -368,7 +369,7 @@ class Entry(object):
# There should be a better way to do this? Perhaps
# self search for the aci attr?
return []
- self.acis = [EntryAci(self, a) for a in self.getValues('aci')]
+ self.acis = [EntryAci(self, a, verbose=False) for a in self.getValues('aci')]
return self.acis
@@ -415,14 +416,15 @@ class EntryAci(object):
'groupdn',
'roledn']
- def __init__(self, entry, rawaci):
+ def __init__(self, entry, rawaci, verbose=False):
"""
Breaks down an aci attribute string from 389, into a dictionary
of terms and values. These values can then be manipulated, and
subsequently rebuilt into an aci string.
"""
+ self.verbose = verbose
self.entry = entry
- self._rawaci = rawaci
+ self._rawaci = ensure_str(rawaci)
self.acidata = self._parse_aci(self._rawaci)
def __eq__(self, other):
@@ -451,6 +453,8 @@ class EntryAci(object):
rawaci += "%s || " % value
rawaci += values[-1]
rawaci += '"'
+ if self.verbose:
+ print("_format_term: %s" % rawaci)
return rawaci
def getRawAci(self):
@@ -484,6 +488,9 @@ class EntryAci(object):
return rawaci
def _find_terms(self, aci):
+ if self.verbose:
+ print("_find_terms aci: %s" % aci)
+ print("_find_terms aci: %s" % type(aci))
lbr_list = []
rbr_list = []
depth = 0
@@ -498,8 +505,13 @@ class EntryAci(object):
depth -= 1
# Now build a set of terms.
terms = []
+ if self.verbose:
+ print("_find_terms lbr_list" % lbr_list)
+ print("_find_terms rbr_list" % rbr_list)
for lb, rb in zip(lbr_list, rbr_list):
terms.append(aci[lb + 1:rb])
+ if self.verbose:
+ print("_find_terms terms: %s" % terms)
return terms
def _parse_term(self, key, term):
@@ -519,6 +531,8 @@ class EntryAci(object):
for x in wdict['values']])
wdict['values'] = [x.strip() for x in wdict['values']]
+ if self.verbose:
+ print("_parse_term: %s" % wdict)
return wdict
def _parse_bind_rules(self, subterm):
@@ -534,6 +548,9 @@ class EntryAci(object):
the human do it. It comes down to cost versus reward.
"""
+ if self.verbose:
+ print("_parse_bind_rules: %s" % subterm)
+
return [subterm]
def _parse_version_3_0(self, rawacipart, data):
@@ -560,6 +577,8 @@ class EntryAci(object):
'values': self._parse_bind_rules(subterm)
})
+ if self.verbose:
+ print("_parse_version_3_0: %s" % terms)
return terms
def _parse_aci(self, rawaci):
@@ -589,4 +608,6 @@ class EntryAci(object):
continue
data[k].append(self._parse_term(k, aci))
break
+ if self.verbose:
+ print("_parse_aci: %s" % data )
return data
diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py
index 011baa1d1..f147ab2c4 100644
--- a/src/lib389/lib389/_mapped_object.py
+++ b/src/lib389/lib389/_mapped_object.py
@@ -7,10 +7,11 @@
# --- END COPYRIGHT BLOCK ---
import ldap
+from ldap import filter as ldap_filter
import logging
from lib389._constants import *
-from lib389.utils import ensure_bytes, ensure_str
+from lib389.utils import ensure_bytes, ensure_str, ensure_list_bytes
from lib389._entry import Entry
@@ -45,7 +46,7 @@ def _gen_filter(attrtypes, values, extra=None):
filt = ''
for attr, value in zip(attrtypes, values):
if attr is not None and value is not None:
- filt += '(%s=%s)' % (attr, value)
+ filt += '(%s=%s)' % (attr, ldap_filter.escape_filter_chars(value))
if extra is not None:
filt += '{FILT}'.format(FILT=extra)
return filt
@@ -80,7 +81,6 @@ class DSLdapObject(DSLogging):
self._create_objectclasses = []
self._rdn_attribute = None
self._must_attributes = None
- self._basedn = ""
def __unicode__(self):
val = self._dn
@@ -91,14 +91,34 @@ class DSLdapObject(DSLogging):
def __str__(self):
return self.__unicode__()
- def set(self, key, value):
+ # We make this a property so that we can over-ride dynamically if needed
+ @property
+ def dn(self):
+ return self._dn
+
+ def add(self, key, value):
+ self.set(key, value, action=ldap.MOD_ADD)
+
+ # Basically what it means;
+ def replace(self, key, value):
+ self.set(key, value, action=ldap.MOD_REPLACE)
+
+ # maybe this could be renamed?
+ def set(self, key, value, action=ldap.MOD_REPLACE):
self._log.debug("%s set(%r, %r)" % (self._dn, key, value))
if self._instance.state != DIRSRV_STATE_ONLINE:
raise ValueError("Invalid state. Cannot set properties on instance that is not ONLINE.")
+
+ if isinstance(value, list):
+ # value = map(lambda x: ensure_bytes(x), value)
+ value = ensure_list_bytes(value)
+ else:
+ value = [ensure_bytes(value)]
+
if self._batch:
pass
else:
- return self._instance.modify_s(self._dn, [(ldap.MOD_REPLACE, key, value)])
+ return self._instance.modify_s(self._dn, [(action, key, value)])
def get(self, key):
"""Get an attribute under dn"""
@@ -111,6 +131,7 @@ class DSLdapObject(DSLogging):
else:
return self._instance.getEntry(self._dn).getValues(key)
+ # This needs to work on key + val, and key
def remove(self, key):
"""Remove a value defined by key"""
self._log.debug("%s get(%r, %r)" % (self._dn, key, value))
@@ -120,6 +141,17 @@ class DSLdapObject(DSLogging):
# Do a mod_delete on the value.
pass
+ # Duplicate, but with many values. IE a dict api.
+ # This
+ def add_values(self, values):
+ pass
+
+ def replace_values(self, values):
+ pass
+
+ def set_values(self, values, action=ldap.MOD_REPLACE):
+ pass
+
def delete(self):
"""
Deletes the object defined by self._dn.
@@ -127,9 +159,10 @@ class DSLdapObject(DSLogging):
"""
self._log.debug("%s delete" % (self._dn))
if not self._protected:
- pass
+ # Is there a way to mark this as offline and kill it
+ self._instance.delete_s(self._dn)
- def _validate(self, tdn, properties):
+ def _validate(self, rdn, properties, basedn):
"""
Used to validate a create request.
This way, it can be over-ridden without affecting
@@ -141,6 +174,8 @@ class DSLdapObject(DSLogging):
It has the useful trick of returning the dn, so subtypes
can use extra properties to create the dn's here for this.
"""
+ if basedn is None:
+ raise ldap.UNWILLING_TO_PERFORM('Invalid request to create. basedn cannot be None')
if properties is None:
raise ldap.UNWILLING_TO_PERFORM('Invalid request to create. Properties cannot be None')
if type(properties) != dict:
@@ -151,25 +186,44 @@ class DSLdapObject(DSLogging):
for attr in self._must_attributes:
if properties.get(attr, None) is None:
raise ldap.UNWILLING_TO_PERFORM('Attribute %s must not be None' % attr)
+ # Make sure the naming attribute is present
+ if properties.get(self._rdn_attribute, None) is None and rdn is None:
+ raise ldap.UNWILLING_TO_PERFORM('Attribute %s must not be None or rdn provided' % self._rdn_attribute)
+ elif properties.get(self._rdn_attribute, None) is not None:
+ # Favour the value in the properties dictionary
+ v = properties.get(self._rdn_attribute)
+ if isinstance(v, list):
+ rdn = ensure_str(v[0])
+ else:
+ rdn = ensure_str(v)
+
+ tdn = '%s=%s,%s' % (self._rdn_attribute, rdn, basedn)
# We may need to map over the data in the properties dict to satisfy python-ldap
+ str_props = {}
+ for k, v in properties.items():
+ if isinstance(v, list):
+ # str_props[k] = map(lambda v1: ensure_bytes(v1), v)
+ str_props[k] = ensure_list_bytes(v)
+ else:
+ str_props[k] = ensure_bytes(v)
#
# Do we need to do extra dn validation here?
- return (tdn, properties)
+ return (tdn, str_props)
- def create(self, dn, properties=None):
+ def create(self, rdn, properties=None, basedn=None):
assert(len(self._create_objectclasses) > 0)
- self._log.debug('Creating %s : %s' % (dn, properties))
- # Make sure these aren't none.
- # Create the dn based on the various properties.
- (dn, valid_props) = self._validate(dn, properties)
+ self._log.debug('Creating %s %s : %s' % (rdn, basedn, properties))
+ # Add the objectClasses to the properties
+ (dn, valid_props) = self._validate(rdn, properties, basedn)
# Check if the entry exists or not? .add_s is going to error anyway ...
- self._log.debug('Validated %s : %s' % (dn, properties))
+ self._log.debug('Validated %s : %s' % (dn, valid_props))
e = Entry(dn)
- e.update({'objectclass' : self._create_objectclasses})
+ e.update({'objectclass' : ensure_list_bytes(self._create_objectclasses)})
e.update(valid_props)
# We rely on exceptions here to indicate failure to the parent.
+ self._log.debug('Creating entry %s : %s' % (dn, e))
self._instance.add_s(e)
# If it worked, we need to fix our instance dn
self._dn = dn
@@ -185,6 +239,7 @@ class DSLdapObjects(DSLogging):
self._objectclasses = []
self._filterattrs = []
self._list_attrlist = ['dn']
+ # Copy this from the child if we need.
self._basedn = ""
self._batch = batch
self._scope = ldap.SCOPE_SUBTREE
@@ -201,13 +256,39 @@ class DSLdapObjects(DSLogging):
attrlist=self._list_attrlist,
)
# def __init__(self, instance, dn=None, batch=False):
- insts = map(lambda r: self._childobject(instance=self._instance, dn=r.dn, batch=self._batch), results)
+ # insts = map(lambda r: self._childobject(instance=self._instance, dn=r.dn, batch=self._batch), results)
+ insts = [self._childobject(instance=self._instance, dn=r.dn, batch=self._batch) for r in results]
+ print(insts)
return insts
- def get(self, selector):
+ def get(self, selector=[], dn=None):
+ results = []
+ if dn is not None:
+ results = self._get_dn(dn)
+ else:
+ results = self._get_selector(selector)
+
+ if len(results) == 0:
+ raise ldap.NO_SUCH_OBJECT("No object exists given the filter criteria %s" % selector)
+ if len(results) > 1:
+ raise ldap.UNWILLING_TO_PERFORM("Too many objects matched selection criteria %s" % selector)
+ return self._childobject(instance=self._instance, dn=results[0].dn, batch=self._batch)
+
+ def _get_dn(self, dn):
+ return self._instance.search_s(
+ base=dn,
+ scope=ldap.SCOPE_BASE,
+ # This will yield and & filter for objectClass with as many terms as needed.
+ filterstr=_gen_and(
+ _gen_filter(_term_gen('objectclass'), self._objectclasses,)
+ ),
+ attrlist=self._list_attrlist,
+ )
+
+ def _get_selector(self, selector):
# Filter based on the objectclasses and the basedn
# Based on the selector, we should filter on that too.
- results = self._instance.search_s(
+ return self._instance.search_s(
base=self._basedn,
scope=self._scope,
# This will yield and & filter for objectClass with as many terms as needed.
@@ -223,16 +304,9 @@ class DSLdapObjects(DSLogging):
attrlist=self._list_attrlist,
)
- if len(results) == 0:
- raise ldap.NO_SUCH_OBJECT("No object exists given the filter criteria %s" % selector)
- if len(results) > 1:
- raise ldap.UNWILLING_TO_PERFORM("Too many objects matched selection criteria %s" % selector)
- return self._childobject(instance=self._instance, dn=results[0].dn, batch=self._batch)
-
-
def _validate(self, rdn, properties):
"""
- Validate the factor part of the creation
+ Validate the factory part of the creation
"""
if properties is None:
raise ldap.UNWILLING_TO_PERFORM('Invalid request to create. Properties cannot be None')
@@ -242,15 +316,14 @@ class DSLdapObjects(DSLogging):
# Get the rdn out of the properties if it's unset???
if rdn is None and self._rdn_attribute in properties:
# First see if we can get it from the properties.
- trdn = properties.get(self._rdn_attribute)
+ trdn = str_properties.get(self._rdn_attribute)
if type(trdn) != list:
raise ldap.UNWILLING_TO_PERFORM("rdn %s from properties is not in a list" % self._rdn_attribute)
if len(trdn) != 1:
raise ldap.UNWILLING_TO_PERFORM("Cannot determine rdn %s from properties. Too many choices" % (self._rdn_attribute))
rdn = trdn[0]
- if type(rdn) != str:
- raise ldap.UNWILLING_TO_PERFORM("rdn %s must be a utf8 string (str)", rdn)
+ return (rdn, properties)
def create(self, rdn=None, properties=None):
# Create the object
@@ -259,8 +332,6 @@ class DSLdapObjects(DSLogging):
# Make the rdn naming attr avaliable
self._rdn_attribute = co._rdn_attribute
(rdn, properties) = self._validate(rdn, properties)
- # Do we need to fix anything here in the rdn_attribute?
- dn = '%s=%s,%s' % (co._rdn_attribute, rdn, self._basedn)
# Now actually commit the creation req
- return co.create(dn, properties)
+ return co.create(rdn, properties, self._basedn)
diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py
index 9ed2a0422..5f5f817e8 100644
--- a/src/lib389/lib389/backend.py
+++ b/src/lib389/lib389/backend.py
@@ -382,11 +382,13 @@ class Backend(DSLdapObject):
super(Backend, self).__init__(instance, dn, batch)
self._rdn_attribute = 'cn'
self._must_attributes = ['nsslapd-suffix', 'cn']
+ self._create_objectclasses = ['top', 'extensibleObject', BACKEND_OBJECTCLASS_VALUE ]
+ self._protected = False
def create_sample_entries(self):
self._log.debug('Creating sample entries ....')
- def _validate(self, rdn, properties):
+ def _validate(self, rdn, properties, basedn):
# We always need to call the super validate first. This way we can
# guarantee that properties is a dictionary.
# However, backend can take different properties. One is
@@ -401,17 +403,41 @@ class Backend(DSLdapObject):
# This is converting the BACKEND_ types to the DS nsslapd- attribute values
nprops = {}
for key, value in properties.items():
- nprops[BACKEND_PROPNAME_TO_ATTRNAME[key]] = [value,]
+ try:
+ nprops[BACKEND_PROPNAME_TO_ATTRNAME[key]] = [value,]
+ except KeyError:
+ # This means, it's not a mapped value, so continue
+ pass
- (dn, rdn, valid_props) = super(Backends, self)._validate(rdn, nprops)
+ (dn, valid_props) = super(Backend, self)._validate(rdn, nprops, basedn)
- return (dn, rdn, nprops)
+ return (dn, valid_props)
- def create(self, rdn=None, properties=None):
+ def create(self, dn=None, properties=None, basedn=None):
sample_entries = properties.pop(BACKEND_SAMPLE_ENTRIES, False)
- super(Backend, self).create(rdn, properties)
+ super(Backend, self).create(dn, properties, basedn)
if sample_entries is True:
- be_inst.create_sample_entries()
+ self.create_sample_entries()
+
+ def delete(self):
+ if self._protected:
+ raise ldap.UNWILLING_TO_PERFORM("This is a protected backend!")
+ # First check if the mapping tree has our suffix still.
+ suffix = self.get('nsslapd-suffix')[0]
+ bename = self.get('cn')[0]
+ # TODO: This is the old api, change it!!!!
+ mt_ents = self._instance.mappingtree.list(suffix=suffix)
+ if len(mt_ents) > 0:
+ raise ldap.UNWILLING_TO_PERFORM(
+ "It still exists a mapping tree (%s) for that backend (%s)" %
+ (mt_ents[0].dn, self.dn))
+
+ self._instance.index.delete_all(bename)
+
+ # Now remove the children
+ self._instance.delete_branch_s(self._dn, ldap.SCOPE_ONELEVEL)
+ # The super will actually delete ourselves.
+ super(Backend, self).delete()
# This only does ldbm backends. Chaining backends are a special case
# of this, so they can be subclassed off.
@@ -419,10 +445,9 @@ class Backends(DSLdapObjects):
def __init__(self, instance, batch=False):
super(Backends, self).__init__(instance=instance, batch=False)
self._objectclasses = [BACKEND_OBJECTCLASS_VALUE]
- self._create_objectclasses = self._objectclasses + ['top', 'extensibleObject' ]
self._filterattrs = ['cn', 'nsslapd-suffix', 'nsslapd-directory']
- self._basedn = DN_LDBM
self._childobject = Backend
+ self._basedn = DN_LDBM
diff --git a/src/lib389/lib389/dirsrv_log.py b/src/lib389/lib389/dirsrv_log.py
index 1032e4e46..7f4cf71b2 100644
--- a/src/lib389/lib389/dirsrv_log.py
+++ b/src/lib389/lib389/dirsrv_log.py
@@ -16,6 +16,7 @@ from dateutil.parser import parse as dt_parse
from glob import glob
from lib389._constants import DN_CONFIG
from lib389.properties import LOG_ACCESS_PATH, LOG_ERROR_PATH
+from lib389.utils import ensure_bytes, ensure_str
# Because many of these settings can change live, we need to check for certain
# attributes all the time.
@@ -59,7 +60,7 @@ class DirsrvLog(object):
lines = []
for log in self._get_all_log_paths():
# Open the log
- if log.endswith('.gz'):
+ if log.endswith(ensure_bytes('.gz')):
with gzip.open(log, 'r') as lf:
lines += lf.readlines()
else:
@@ -84,7 +85,7 @@ class DirsrvLog(object):
results = []
prog = re.compile(pattern)
for log in self._get_all_log_paths():
- if log.endswith('.gz'):
+ if log.endswith(ensure_bytes('.gz')):
with gzip.open(log, 'r') as lf:
for line in lf:
mres = prog.match(line)
@@ -123,7 +124,7 @@ class DirsrvLog(object):
TZ=timedata['tz'],
)
dt = dt_parse(dt_str)
- dt = dt.replace(microsecond= int(timedata['nanosecond']) / 1000)
+ dt = dt.replace(microsecond= int(int(timedata['nanosecond']) / 1000))
return dt
class DirsrvAccessLog(DirsrvLog):
diff --git a/src/lib389/lib389/index.py b/src/lib389/lib389/index.py
index 1b3541408..f3f49d5a3 100644
--- a/src/lib389/lib389/index.py
+++ b/src/lib389/lib389/index.py
@@ -16,6 +16,7 @@ if MAJOR >= 3 or (MAJOR == 2 and MINOR >= 7):
from lib389._constants import *
from lib389.properties import *
from lib389 import Entry
+from lib389.utils import ensure_str, ensure_bytes
class Index(object):
@@ -26,13 +27,11 @@ class Index(object):
self.log = conn.log
def delete_all(self, benamebase):
+ benamebase = ensure_str(benamebase)
dn = "cn=index,cn=" + benamebase + "," + DN_LDBM
# delete each defined index
- ents = self.conn.search_s(dn, ldap.SCOPE_ONELEVEL)
- for ent in ents:
- self.log.debug("Delete index entry %s" % (ent.dn))
- self.conn.delete_s(ent.dn)
+ self.conn.delete_branch_s(dn, ldap.SCOPE_ONELEVEL)
# Then delete the top index entry
self.log.debug("Delete head index entry %s" % (dn))
diff --git a/src/lib389/lib389/mit_krb5.py b/src/lib389/lib389/mit_krb5.py
index 6b5308cd9..b1d2335a2 100644
--- a/src/lib389/lib389/mit_krb5.py
+++ b/src/lib389/lib389/mit_krb5.py
@@ -14,6 +14,7 @@ integration with 389ds.
"""
# In the future we might add support for an ldap-backed krb realm
from subprocess import Popen, PIPE
+
import os
import signal
import string
@@ -24,6 +25,7 @@ from lib389._constants import *
from socket import getfqdn
from lib389.utils import getdomainname
from lib389.tools import DirSrvTools
+from lib389.passwd import password_generate
class MitKrb5(object):
@@ -44,9 +46,7 @@ class MitKrb5(object):
(self.krb_prefix,
self.realm.lower().replace('.', '-')))
- secure_password = [random.choice(string.letters) for x in xrange(64)]
- secure_password = "".join(secure_password)
- self.krb_master_password = secure_password
+ self.krb_master_password = password_generate()
# Should we write this to a file?
diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py
index 9402caa58..119c0cb58 100644
--- a/src/lib389/lib389/nss_ssl.py
+++ b/src/lib389/lib389/nss_ssl.py
@@ -18,6 +18,8 @@ from nss import nss
from nss import error as nss_error
from subprocess import check_call
+from lib389.passwd import password_generate
+
KEYBITS=4096
CA_NAME='Self-Signed-CA'
CERT_NAME='Server-Cert'
@@ -38,15 +40,12 @@ class NssSsl(object):
self.dirsrv = dirsrv
self.log = self.dirsrv.log
if dbpassword is None:
- secure_password = [random.choice(string.letters) for x in xrange(64)]
- secure_password = "".join(secure_password)
- self.dbpassword = secure_password
+ self.dbpassword = password_generate()
else:
self.dbpassword = dbpassword
def _generate_noise(self, fpath):
- noise = [random.choice(string.letters) for x in xrange(256)]
- noise = "".join(noise)
+ noise = password_generate(256)
with open(fpath, 'w') as f:
f.write(noise)
@@ -239,14 +238,3 @@ class NssSsl(object):
else:
return True
-def nss_create_new_database(path, pin=None, force=False):
- ## How do we manage this safely? Cli isn't ... safe.
- # And writing to pin.txt isn't either.
- # Can we enter no password?
-
- cmd = ['/usr/bin/certutil', '-N', '-d', path, '-f', '/dev/null']
- p = Popen(cmd)
- returncode = p.wait()
- if returncode == 0:
- return True
- return False
diff --git a/src/lib389/lib389/passwd.py b/src/lib389/lib389/passwd.py
new file mode 100644
index 000000000..9d981d4a4
--- /dev/null
+++ b/src/lib389/lib389/passwd.py
@@ -0,0 +1,48 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2016 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+"""
+This file contains helpers to generate password hashes compatible for
+Directory Server.
+"""
+
+import subprocess
+import random
+import string
+import os
+import sys
+
+BESTSCHEME = 'SSHA512'
+MAJOR, MINOR, _, _, _ = sys.version_info
+
+# We need a dict of the schemes I think ....
+PWSCHEMES = [
+ 'SHA1',
+ 'SHA256',
+ 'SHA512',
+ 'SSHA',
+ 'SSHA256',
+ 'SSHA512',
+]
+
+# How do we feed our prefix into this?
+def password_hash(pw, scheme=BESTSCHEME, prefix='/'):
+ # Check that the binary exists
+ assert(scheme in PWSCHEMES)
+ pwdhashbin = os.path.join(prefix, 'bin', 'pwdhash-bin')
+ assert(os.path.isfile(pwdhashbin))
+ h = subprocess.check_output([pwdhashbin, '-s', scheme, pw]).strip()
+ return h.decode('utf-8')
+
+def password_generate(length=64):
+ pw = None
+ if MAJOR >= 3:
+ pw = [random.choice(string.ascii_letters) for x in range(length)]
+ else:
+ pw = [random.choice(string.letters) for x in xrange(length)]
+ return "".join(pw)
diff --git a/src/lib389/lib389/properties.py b/src/lib389/lib389/properties.py
index 9f5175dcd..9bfe4fe45 100644
--- a/src/lib389/lib389/properties.py
+++ b/src/lib389/lib389/properties.py
@@ -108,6 +108,8 @@ BACKEND_CHAIN_BIND_DN = 'chain-bind-dn'
BACKEND_CHAIN_BIND_PW = 'chain-bind-pw'
BACKEND_CHAIN_URLS = 'chain-urls'
BACKEND_STATS = 'stats'
+BACKEND_SUFFIX = 'suffix'
+BACKEND_SAMPLE_ENTRIES = 'sample_entries'
BACKEND_OBJECTCLASS_VALUE = 'nsBackendInstance'
diff --git a/src/lib389/lib389/tests/aci_test.py b/src/lib389/lib389/tests/aci_test.py
index d94476234..555d32a4c 100644
--- a/src/lib389/lib389/tests/aci_test.py
+++ b/src/lib389/lib389/tests/aci_test.py
@@ -10,6 +10,10 @@ from lib389._constants import *
from lib389 import DirSrv, Entry
import pytest
+import sys
+MAJOR, MINOR, _, _, _ = sys.version_info
+from lib389.utils import ensure_bytes, ensure_str
+
INSTANCE_PORT = 54321
INSTANCE_SERVERID = 'aciparseds'
# INSTANCE_PREFIX = None
@@ -62,7 +66,7 @@ def complex_aci(topology):
topology.standalone.add_s(gentry)
- return ACI_BODY
+ return ensure_str(ACI_BODY)
def test_aci(topology, complex_aci):
@@ -71,6 +75,7 @@ def test_aci(topology, complex_aci):
acis = topology.standalone.aci.list('cn=testgroup,%s' % DEFAULT_SUFFIX)
assert len(acis) == 1
aci = acis[0]
+ print(aci.acidata)
assert aci.acidata == {
'allow': [{'values': ['read', 'search', 'write']}],
'target': [], 'targetattr': [{'values': ['uniqueMember', 'member'],
diff --git a/src/lib389/lib389/tests/backend_test.py b/src/lib389/lib389/tests/backend_test.py
index cdf9159d1..c55ca5fbc 100644
--- a/src/lib389/lib389/tests/backend_test.py
+++ b/src/lib389/lib389/tests/backend_test.py
@@ -69,69 +69,76 @@ def test_list(topology):
- filter with invalid suffix/bename
"""
- ents = topology.standalone.backend.list()
+ ents = topology.standalone.backends.list()
nb_backend = len(ents)
for ent in ents:
topology.standalone.log.info("List(%d): backend %s" %
(nb_backend, ent.dn))
log.info("Create a first backend and check list all backends")
- topology.standalone.backend.create(suffix=NEW_SUFFIX_1,
- properties={BACKEND_NAME:
- NEW_BACKEND_1})
- ents = topology.standalone.backend.list()
+ topology.standalone.backends.create(None,
+ properties={
+ BACKEND_NAME: NEW_BACKEND_1,
+ 'suffix':NEW_SUFFIX_1,
+ })
+ ents = topology.standalone.backends.list()
for ent in ents:
topology.standalone.log.info("List(%d): backend %s" %
(nb_backend + 1, ent.dn))
assert len(ents) == (nb_backend + 1)
log.info("Create a second backend and check list all backends")
- topology.standalone.backend.create(suffix=NEW_SUFFIX_2,
- properties={BACKEND_NAME:
- NEW_BACKEND_2})
- ents = topology.standalone.backend.list()
+ topology.standalone.backends.create(None,
+ properties={
+ BACKEND_NAME: NEW_BACKEND_2,
+ 'suffix': NEW_SUFFIX_2,
+ })
+ ents = topology.standalone.backends.list()
for ent in ents:
topology.standalone.log.info("List(%d): backend %s" %
(nb_backend + 2, ent.dn))
assert len(ents) == (nb_backend + 2)
log.info("Check list a backend per suffix")
- ents = topology.standalone.backend.list(suffix=NEW_SUFFIX_1)
- for ent in ents:
- topology.standalone.log.info("List suffix (%d): backend %s" %
- (1, ent.dn))
- assert len(ents) == 1
+ # In the new api this becomes a get over the selector type
+ # In the case this fails, this actually throws exception
+ ent = topology.standalone.backends.get(NEW_SUFFIX_1)
+ topology.standalone.log.info("List suffix (%d): backend %s" %
+ (1, ent.dn))
+ assert ent is not None
log.info("Check list a backend by its name")
- ents = topology.standalone.backend.list(bename=NEW_BACKEND_2)
- for ent in ents:
- topology.standalone.log.info("List name (%d): backend %s" %
- (1, ent.dn))
- assert len(ents) == 1
-
- log.info("Check list backends by their DN")
- all = topology.standalone.backend.list()
- for ent in all:
- ents = topology.standalone.backend.list(backend_dn=ent.dn)
- for bck in ents:
- topology.standalone.log.info("List DN (%d): backend %s" %
- (1, bck.dn))
- assert len(ents) == 1
-
- log.info("Check list with valid backend DN but invalid suffix/bename")
- all = topology.standalone.backend.list()
- for ent in all:
- ents = topology.standalone.backend.list(suffix="o=dummy",
- backend_dn=ent.dn,
- bename="dummydb")
- for bck in ents:
- topology.standalone.log.info("List invalid suffix+bename "
- "(%d): backend %s" % (1, bck.dn))
- assert len(ents) == 1
+ ent = topology.standalone.backends.get(NEW_BACKEND_2)
+ topology.standalone.log.info("List name (%d): backend %s" %
+ (1, ent.dn))
+ assert ent is not None
+
+ log.info("Check get backends by their DN")
+ ents = topology.standalone.backends.get(dn=ent.dn)
+ topology.standalone.log.info("List DN (%d): backend %s" %
+ (1, ents.dn))
+ assert ents is not None
+
+ # The new backends api just does selection on a single attr, and
+ # You would then validate the other attributes on retrival.
+ # But what would really be a case for this? If you know the suffix, get
+ # that. If you know the name, get that. Why both?
+ #log.info("Check list with valid backend DN but invalid suffix/bename")
+ #all = topology.standalone.backend.list()
+ #for ent in all:
+ # ents = topology.standalone.backend.list(suffix="o=dummy",
+ # backend_dn=ent.dn,
+ # bename="dummydb")
+ # for bck in ents:
+ # topology.standalone.log.info("List invalid suffix+bename "
+ # "(%d): backend %s" % (1, bck.dn))
+ # assert len(ents) == 1
log.info("Just to make it clean in the end")
- topology.standalone.backend.delete(suffix=NEW_SUFFIX_1)
- topology.standalone.backend.delete(suffix=NEW_SUFFIX_2)
+ b1 = topology.standalone.backends.get(NEW_SUFFIX_1)
+ b2 = topology.standalone.backends.get(NEW_SUFFIX_2)
+ b1.delete()
+ b2.delete()
def test_create(topology):
diff --git a/src/lib389/lib389/tests/conftest.py b/src/lib389/lib389/tests/conftest.py
index caf507c0c..edd64fcc4 100644
--- a/src/lib389/lib389/tests/conftest.py
+++ b/src/lib389/lib389/tests/conftest.py
@@ -13,12 +13,16 @@ import pytest
from tempfile import mkdtemp
from shutil import rmtree
+MAJOR, MINOR, _, _, _ = sys.version_info
def ldrop(numchar, inputstr):
"""
Drop numchar characters from the beginning of each line in inputstring.
"""
- return "\n".join([x[numchar:] for x in string.split(inputstr, "\n")])
+ if MAJOR >= 3:
+ return "\n".join(map(lambda x: x[numchar:], inputstr.split("\n") ))
+ else:
+ return "\n".join([x[numchar:] for x in string.split(inputstr, "\n")])
@pytest.fixture
diff --git a/src/lib389/lib389/tests/dirsrv_log_test.py b/src/lib389/lib389/tests/dirsrv_log_test.py
index 00c76c020..f2add85bf 100644
--- a/src/lib389/lib389/tests/dirsrv_log_test.py
+++ b/src/lib389/lib389/tests/dirsrv_log_test.py
@@ -7,6 +7,7 @@
# --- END COPYRIGHT BLOCK ---
#
from lib389._constants import *
+from lib389.utils import ensure_bytes, ensure_str
from lib389 import DirSrv, Entry
import pytest
import time
@@ -53,7 +54,7 @@ def test_access_log_rotation(topology):
# Artificially rotate the log.
lpath = topology.standalone.ds_access_log._get_log_path()
- shutil.copyfile(lpath, '%s.20160515-104822' % lpath )
+ shutil.copyfile(lpath, lpath + ensure_bytes('.20160515-104822'))
# check we have the right number of lines.
access_lines = topology.standalone.ds_access_log.readlines_archive()
assert(len(access_lines) > 0)
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index c2c66fb1e..2beedf737 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -757,3 +757,7 @@ def ensure_str(val):
return val.decode('utf-8')
return val
+def ensure_list_bytes(val):
+ if MAJOR >= 3:
+ return [ensure_bytes(v) for v in val]
+ return val
| 0 |
a48be7b2b389a336e3f48a775e466c71f2eb2b31
|
389ds/389-ds-base
|
Issue 6386 - backup/restore broken after db log rotation (#6406)
Restore does fail if the db log file have rotated since the backup. The reason is that the current log files are not removed mixing old and new log file which confuse the database.
Solution is to remove all existing log files before copying the backuped files.
Note: the number of db region should not change and having an extra db file should not be a problem so only the log files must be removed.
Issue: #6386
Reviewed by: @mreynolds389, @tbordaz (Thanks!)
|
commit a48be7b2b389a336e3f48a775e466c71f2eb2b31
Author: progier389 <[email protected]>
Date: Fri Nov 15 12:43:30 2024 +0100
Issue 6386 - backup/restore broken after db log rotation (#6406)
Restore does fail if the db log file have rotated since the backup. The reason is that the current log files are not removed mixing old and new log file which confuse the database.
Solution is to remove all existing log files before copying the backuped files.
Note: the number of db region should not change and having an extra db file should not be a problem so only the log files must be removed.
Issue: #6386
Reviewed by: @mreynolds389, @tbordaz (Thanks!)
diff --git a/dirsrvtests/tests/suites/backups/backup_test.py b/dirsrvtests/tests/suites/backups/backup_test.py
index f1c34947e..431dfea0f 100644
--- a/dirsrvtests/tests/suites/backups/backup_test.py
+++ b/dirsrvtests/tests/suites/backups/backup_test.py
@@ -12,8 +12,9 @@ import os
import shutil
import time
import glob
+import subprocess
from datetime import datetime
-from lib389._constants import DEFAULT_SUFFIX, INSTALL_LATEST_CONFIG
+from lib389._constants import DN_DM, PASSWORD, DEFAULT_SUFFIX, INSTALL_LATEST_CONFIG
from lib389.properties import BACKEND_SAMPLE_ENTRIES, TASK_WAIT
from lib389.topologies import topology_st as topo, topology_m2 as topo_m2
from lib389.backend import Backends, Backend
@@ -221,6 +222,51 @@ def test_replication(topo_m2):
repl.wait_for_replication(S1, S2)
+def test_after_db_log_rotation(topo):
+ """Test that off line backup restore works as expected.
+
+ :id: 8a091d92-a1cf-11ef-823a-482ae39447e5
+ :setup: One standalone instance
+ :steps:
+ 1. Stop instance
+ 2. Perform off line backup on instance
+ 3. Start instance
+ 4. Perform modify operation until db log file rotates
+ 5. Stop instance
+ 6. Restore instance from backup
+ 7. Start instance
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ """
+ inst = topo.standalone
+ with tempfile.TemporaryDirectory(dir=inst.ds_paths.backup_dir) as backup_dir:
+ # repl.wait_for_replication perform some changes and wait until they get replicated
+ inst.stop()
+ assert inst.db2bak(backup_dir)
+ inst.start()
+ cmd = [ 'ldclt', '-h', 'localhost', '-b', DEFAULT_SUFFIX,
+ '-p', str(inst.port), '-t', '60', '-N', '2',
+ '-D', DN_DM, '-w', PASSWORD, '-f', "ou=People",
+ '-e', 'attreplace=description:XXXXXX' ]
+ log.info(f'Running {cmd}')
+ # Perform modify operations until log file rolls
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
+ log.info(f'STDOUT: {result.stdout}')
+ log.info(f'STDERR: {result.stderr}')
+ if get_default_db_lib() == 'bdb':
+ while os.path.isfile(f'{inst.ds_paths.db_dir}/log.0000000001'):
+ subprocess.run(cmd, capture_output=True, text=True, check=True)
+ inst.stop()
+ assert inst.bak2db(backup_dir)
+ inst.start()
+
+
def test_backup_task_after_failure(mytopo):
"""Test that new backup task is successful after a failure.
backend that is no longer present.
diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
index a7cb3ede3..1f508c4e8 100644
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
@@ -5591,6 +5591,28 @@ bdb_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task)
/* Otherwise use the src_dir from the caller */
real_src_dir = src_dir;
+ /* Lets remove existing log files before copying the new ones (See issue #6386) */
+ prefix = BDB_CONFIG(li)->bdb_log_directory;
+ if (prefix == NULL) {
+ prefix = home_dir;
+ }
+ dirhandle = PR_OpenDir(prefix);
+ if (NULL != dirhandle) {
+ while (NULL !=
+ (direntry = PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT))) {
+ if (NULL == direntry->name) {
+ /* NSPR doesn't behave like the docs say it should */
+ break;
+ }
+ if (bdb_is_logfilename(direntry->name)) {
+ PR_snprintf(filename1, sizeof(filename2), "%s/%s",
+ prefix, direntry->name);
+ unlink(filename1);
+ }
+ }
+ }
+ PR_CloseDir(dirhandle);
+
/* We copy the files over from the staging area */
/* We want to treat the logfiles specially: if there's
* a log file directory configured, copy the logfiles there
| 0 |
75c9dcdaefea463e66e35b0eae2c5a9da54b7dfd
|
389ds/389-ds-base
|
Issue 4596 - Build with clang/lld fails when LTO enabled
Bug Description:
Build with clang/lld fails with undefined reference error.
```
ld.lld: error: ./.libs/libslapd.so: undefined reference to __rust_probestack [--no-allow-shlib-undefined]
ld.lld: error: ./.libs/libslapd.so: undefined reference to __muloti4 [--no-allow-shlib-undefined]
```
Fix Description:
* Disabled GCC security flags when building with clang.
* lld by default uses xxhash for build ids, which is too small for rpm
(it requires it between 16 and 64 bytes in size), use sha1 instead.
* Switch debug CFLAGS and LDFLAGS to use DWARF4 instead of DWARF5.
* Disable LTO for clang rpm build.
Fixes: https://github.com/389ds/389-ds-base/issues/4596
Reviewed by: @droideck (Thanks!)
|
commit 75c9dcdaefea463e66e35b0eae2c5a9da54b7dfd
Author: Viktor Ashirov <[email protected]>
Date: Tue Sep 21 23:31:27 2021 +0200
Issue 4596 - Build with clang/lld fails when LTO enabled
Bug Description:
Build with clang/lld fails with undefined reference error.
```
ld.lld: error: ./.libs/libslapd.so: undefined reference to __rust_probestack [--no-allow-shlib-undefined]
ld.lld: error: ./.libs/libslapd.so: undefined reference to __muloti4 [--no-allow-shlib-undefined]
```
Fix Description:
* Disabled GCC security flags when building with clang.
* lld by default uses xxhash for build ids, which is too small for rpm
(it requires it between 16 and 64 bytes in size), use sha1 instead.
* Switch debug CFLAGS and LDFLAGS to use DWARF4 instead of DWARF5.
* Disable LTO for clang rpm build.
Fixes: https://github.com/389ds/389-ds-base/issues/4596
Reviewed by: @droideck (Thanks!)
diff --git a/Makefile.am b/Makefile.am
index a37c2c8cb..b4424ea10 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,6 @@ NQBUILDNUM := $(subst \,,$(subst $(QUOTE),,$(BUILDNUM)))
DEBUG_DEFINES = @debug_defs@
DEBUG_CFLAGS = @debug_cflags@
DEBUG_CXXFLAGS = @debug_cxxflags@
-GCCSEC_CFLAGS = @gccsec_cflags@
if CLANG_ENABLE
ASAN_CFLAGS = @asan_cflags@
else
@@ -32,6 +31,7 @@ ASAN_CFLAGS = @asan_cflags@ -lasan
else
ASAN_CFLAGS = @asan_cflags@
endif
+GCCSEC_CFLAGS = @gccsec_cflags@
endif
MSAN_CFLAGS = @msan_cflags@
TSAN_CFLAGS = @tsan_cflags@
@@ -77,7 +77,7 @@ endif
if CLANG_ENABLE
CLANG_ON = 1
-CLANG_LDFLAGS = -latomic -fuse-ld=lld
+CLANG_LDFLAGS = -latomic -fuse-ld=lld -Wl,--build-id=sha1
EXPORT_LDFLAGS =
else
CLANG_ON = 0
diff --git a/configure.ac b/configure.ac
index 4ab64c733..fa12a781e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,8 +124,8 @@ AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [Enable debug features (de
AC_MSG_RESULT($enable_debug)
if test "$enable_debug" = yes ; then
debug_defs="-DDEBUG -DMCC_DEBUG"
- debug_cflags="-g3 -ggdb -gdwarf-5 -O0"
- debug_cxxflags="-g3 -ggdb -gdwarf-5 -O0"
+ debug_cflags="-g3 -ggdb -gdwarf-4 -O0"
+ debug_cxxflags="-g3 -ggdb -gdwarf-4 -O0"
debug_rust_defs="-C debuginfo=2 -Z macro-backtrace"
cargo_defs=""
rust_target_dir="debug"
@@ -252,7 +252,7 @@ AC_ARG_ENABLE(profiling, AS_HELP_STRING([--enable-profiling], [Enable gcov profi
[], [ enable_profiling=no ])
AC_MSG_RESULT($enable_profiling)
if test "$enable_profiling" = yes ; then
- profiling_defs="-fprofile-arcs -ftest-coverage -g3 -ggdb -gdwarf-5 -O0"
+ profiling_defs="-fprofile-arcs -ftest-coverage -g3 -ggdb -gdwarf-4 -O0"
profiling_links="-lgcov --coverage"
else
profiling_defs=""
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index e5ba057cb..1b408be0f 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -43,7 +43,7 @@
%if %{with clang}
%global toolchain clang
-%global _missing_build_ids_terminate_build 0
+%global _lto_cflags %nil
%endif
# Build cockpit plugin
| 0 |
a16da9c70e64b59f145aa5a01fadbfe8430f8265
|
389ds/389-ds-base
|
Ticket 48818 - In docker, no one can hear your process hang.
Bug Description: Docker starts the first process as pid 1. But pid 1 is
special. It's meant to clean up zombies (defunct) processes.
However, our perl code in setup-ds.pl, when we called $startcmd, the
start-dirsrv process was being left defucnt.
Issue is, that because it's defunct, the pid exists, as do the fds. Perl never
returns. Our tests all fail, and setup-ds.pl hangs.
Fix Description: To fix this, we need to implement the process reaping
capability of pid 1 into part of our perl code.
https://fedorahosted.org/389/ticket/48818
Author: wibrown
Review by: nhosoi (Thank you!)
|
commit a16da9c70e64b59f145aa5a01fadbfe8430f8265
Author: William Brown <[email protected]>
Date: Wed May 4 11:49:53 2016 +1000
Ticket 48818 - In docker, no one can hear your process hang.
Bug Description: Docker starts the first process as pid 1. But pid 1 is
special. It's meant to clean up zombies (defunct) processes.
However, our perl code in setup-ds.pl, when we called $startcmd, the
start-dirsrv process was being left defucnt.
Issue is, that because it's defunct, the pid exists, as do the fds. Perl never
returns. Our tests all fail, and setup-ds.pl hangs.
Fix Description: To fix this, we need to implement the process reaping
capability of pid 1 into part of our perl code.
https://fedorahosted.org/389/ticket/48818
Author: wibrown
Review by: nhosoi (Thank you!)
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index 55ecf45f7..8c3fd0472 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -34,6 +34,8 @@ use Mozilla::LDAP::Utils qw(normalizeDN);
use Mozilla::LDAP::API qw(ldap_explode_dn);
use Mozilla::LDAP::LDIF;
+use POSIX ":sys_wait_h";
+
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts
@@ -713,14 +715,20 @@ sub startServer {
$timeout = time + $timeout;
debug(1, "Starting the server: $startcmd\n");
- $? = 0; # clear error condition
- my $output = `$startcmd 2>&1`;
- $code = $?;
- debug(1, "Started the server: code $code\n");
+
+ # We have to do this because docker is incapable of sane process management
+ # Sadly we have to sacrifice output collection, because of perl issues
+ my $cpid = open(my $output, "-|", "$startcmd 2>&1");
+ if ($cpid) {
+ # Parent process
+ waitpid($cpid,0);
+ }
+ close($output);
+ my $code = $?;
if ($code) {
- debug(0, $output);
+ debug(0, "Process returned $code");
} else {
- debug(1, $output);
+ debug(1, "Process returned $code");
}
# try to open the server error log
| 0 |
d73b14a1c877982bf23b9261facd82caf50d32f0
|
389ds/389-ds-base
|
Issue:CI test - automember_plugin (Long Duration test)
CI test - automember_plugin (Long Duration test)
Relates: https://pagure.io/389-ds-base/issue/48055
Author: aborah
Reviewed by: Viktor Ashirov
|
commit d73b14a1c877982bf23b9261facd82caf50d32f0
Author: Anuj Borah <[email protected]>
Date: Tue Sep 17 14:12:48 2019 +0530
Issue:CI test - automember_plugin (Long Duration test)
CI test - automember_plugin (Long Duration test)
Relates: https://pagure.io/389-ds-base/issue/48055
Author: aborah
Reviewed by: Viktor Ashirov
diff --git a/dirsrvtests/tests/longduration/automembers_long_test.py b/dirsrvtests/tests/longduration/automembers_long_test.py
new file mode 100644
index 000000000..c8b4fbabb
--- /dev/null
+++ b/dirsrvtests/tests/longduration/automembers_long_test.py
@@ -0,0 +1,728 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2019 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+"""
+Will do stress testing of automember plugin
+"""
+
+import os
+import pytest
+
+from lib389.tasks import DEFAULT_SUFFIX
+from lib389.topologies import topology_m4 as topo_m4
+from lib389.idm.nscontainer import nsContainers, nsContainer
+from lib389.idm.organizationalunit import OrganizationalUnits
+from lib389.idm.domain import Domain
+from lib389.idm.posixgroup import PosixGroups
+from lib389.plugins import AutoMembershipPlugin, AutoMembershipDefinitions, \
+ MemberOfPlugin, AutoMembershipRegexRules
+from lib389.backend import Backends
+from lib389.config import Config
+from lib389.replica import ReplicationManager
+from lib389.tasks import AutomemberRebuildMembershipTask
+from lib389.idm.group import Groups, Group, nsAdminGroups, nsAdminGroup
+
+
+SUBSUFFIX = f'dc=SubSuffix,{DEFAULT_SUFFIX}'
+REPMANDN = "cn=ReplManager"
+REPMANSFX = "dc=replmangr,dc=com"
+CACHE_SIZE = '-1'
+CACHEMEM_SIZE = '10485760'
+
+
+pytestmark = pytest.mark.tier3
+
+
[email protected](scope="module")
+def _create_entries(topo_m4):
+ """
+ Will act as module .Will set up required user/entries for the test cases.
+ """
+ for instance in [topo_m4.ms['master1'], topo_m4.ms['master2'],
+ topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ assert instance.status()
+
+ for org in ['autouserGroups', 'Employees', 'TaskEmployees']:
+ OrganizationalUnits(topo_m4.ms['master1'], DEFAULT_SUFFIX).create(properties={'ou': org})
+
+ Backends(topo_m4.ms['master1']).create(properties={
+ 'cn': 'SubAutoMembers',
+ 'nsslapd-suffix': SUBSUFFIX,
+ 'nsslapd-CACHE_SIZE': CACHE_SIZE,
+ 'nsslapd-CACHEMEM_SIZE': CACHEMEM_SIZE
+ })
+
+ Domain(topo_m4.ms['master1'], SUBSUFFIX).create(properties={
+ 'dc': SUBSUFFIX.split('=')[1].split(',')[0],
+ 'aci': [
+ f'(targetattr="userPassword")(version 3.0;aci "Replication Manager Access";'
+ f'allow (write,compare) userdn="ldap:///{REPMANDN},cn=config";)',
+ f'(target ="ldap:///{SUBSUFFIX}")(targetattr !="cn||sn||uid")(version 3.0;'
+ f'acl "Group Permission";allow (write)(groupdn = "ldap:///cn=GroupMgr,{SUBSUFFIX}");)',
+ f'(target ="ldap:///{SUBSUFFIX}")(targetattr !="userPassword")(version 3.0;'
+ f'acl "Anonym-read access"; allow (read,search,compare) (userdn="ldap:///anyone");)']
+ })
+
+ for suff, grp in [(DEFAULT_SUFFIX, 'SubDef1'),
+ (DEFAULT_SUFFIX, 'SubDef2'),
+ (DEFAULT_SUFFIX, 'SubDef3'),
+ (DEFAULT_SUFFIX, 'SubDef4'),
+ (DEFAULT_SUFFIX, 'SubDef5'),
+ (DEFAULT_SUFFIX, 'Employees'),
+ (DEFAULT_SUFFIX, 'NewEmployees'),
+ (DEFAULT_SUFFIX, 'testuserGroups'),
+ (SUBSUFFIX, 'subsuffGroups'),
+ (SUBSUFFIX, 'Employees'),
+ (DEFAULT_SUFFIX, 'autoMembersPlugin'),
+ (DEFAULT_SUFFIX, 'replsubGroups'),
+ ("cn=replsubGroups,{}".format(DEFAULT_SUFFIX), 'Managers'),
+ ("cn=replsubGroups,{}".format(DEFAULT_SUFFIX), 'Contractors'),
+ ("cn=replsubGroups,{}".format(DEFAULT_SUFFIX), 'Interns'),
+ ("cn=replsubGroups,{}".format(DEFAULT_SUFFIX), 'Visitors'),
+ ("ou=autouserGroups,{}".format(DEFAULT_SUFFIX), 'SuffDef1'),
+ ("ou=autouserGroups,{}".format(DEFAULT_SUFFIX), 'SuffDef2'),
+ ("ou=autouserGroups,{}".format(DEFAULT_SUFFIX), 'SuffDef3'),
+ ("ou=autouserGroups,{}".format(DEFAULT_SUFFIX), 'SuffDef4'),
+ ("ou=autouserGroups,{}".format(DEFAULT_SUFFIX), 'SuffDef5'),
+ ("ou=autouserGroups,{}".format(DEFAULT_SUFFIX), 'Contractors'),
+ ("ou=autouserGroups,{}".format(DEFAULT_SUFFIX), 'Managers'),
+ ("CN=testuserGroups,{}".format(DEFAULT_SUFFIX), 'TestDef1'),
+ ("CN=testuserGroups,{}".format(DEFAULT_SUFFIX), 'TestDef2'),
+ ("CN=testuserGroups,{}".format(DEFAULT_SUFFIX), 'TestDef3'),
+ ("CN=testuserGroups,{}".format(DEFAULT_SUFFIX), 'TestDef4'),
+ ("CN=testuserGroups,{}".format(DEFAULT_SUFFIX), 'TestDef5')]:
+ Groups(topo_m4.ms['master1'], suff, rdn=None).create(properties={'cn': grp})
+
+ for suff, grp, gid in [(SUBSUFFIX, 'SubDef1', '111'),
+ (SUBSUFFIX, 'SubDef2', '222'),
+ (SUBSUFFIX, 'SubDef3', '333'),
+ (SUBSUFFIX, 'SubDef4', '444'),
+ (SUBSUFFIX, 'SubDef5', '555'),
+ ('cn=subsuffGroups,{}'.format(SUBSUFFIX), 'Managers', '666'),
+ ('cn=subsuffGroups,{}'.format(SUBSUFFIX), 'Contractors', '999')]:
+ PosixGroups(topo_m4.ms['master1'], suff, rdn=None).create(properties={
+ 'cn': grp,
+ 'gidNumber': gid})
+
+ for master in [topo_m4.ms['master1'], topo_m4.ms['master2'],
+ topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ AutoMembershipPlugin(master).add("nsslapd-pluginConfigArea",
+ "cn=autoMembersPlugin,{}".format(DEFAULT_SUFFIX))
+ MemberOfPlugin(master).enable()
+
+ automembers = AutoMembershipDefinitions(topo_m4.ms['master1'],
+ f'cn=autoMembersPlugin,{DEFAULT_SUFFIX}')
+ automember1 = automembers.create(properties={
+ 'cn': 'replsubGroups',
+ 'autoMemberScope': f'ou=Employees,{DEFAULT_SUFFIX}',
+ 'autoMemberFilter': "objectclass=posixAccount",
+ 'autoMemberDefaultGroup': [f'cn=SubDef1,{DEFAULT_SUFFIX}',
+ f'cn=SubDef2,{DEFAULT_SUFFIX}',
+ f'cn=SubDef3,{DEFAULT_SUFFIX}',
+ f'cn=SubDef4,{DEFAULT_SUFFIX}',
+ f'cn=SubDef5,{DEFAULT_SUFFIX}'],
+ 'autoMemberGroupingAttr': 'member:dn'
+ })
+
+ automembers = AutoMembershipRegexRules(topo_m4.ms['master1'], automember1.dn)
+ automembers.create(properties={
+ 'cn': 'Managers',
+ 'description': f'Group placement for Managers',
+ 'autoMemberTargetGroup': [f'cn=Managers,cn=replsubGroups,{DEFAULT_SUFFIX}'],
+ 'autoMemberInclusiveRegex': ['uidNumber=^5..5$', 'gidNumber=^[1-4]..3$',
+ 'nsAdminGroupName=^Manager$|^Supervisor$'],
+ "autoMemberExclusiveRegex": ['uidNumber=^999$',
+ 'gidNumber=^[6-8].0$',
+ 'nsAdminGroupName=^Junior$'],
+ })
+ automembers.create(properties={
+ 'cn': 'Contractors',
+ 'description': f'Group placement for Contractors',
+ 'autoMemberTargetGroup': [f'cn=Contractors,cn=replsubGroups,{DEFAULT_SUFFIX}'],
+ 'autoMemberInclusiveRegex': ['uidNumber=^8..5$',
+ 'gidNumber=^[5-9]..3$',
+ 'nsAdminGroupName=^Contract|^Temporary$'],
+ "autoMemberExclusiveRegex": ['uidNumber=^[1,3,8]99$',
+ 'gidNumber=^[2-4]00$',
+ 'nsAdminGroupName=^Employee$'],
+ })
+ automembers.create(properties={
+ 'cn': 'Interns',
+ 'description': f'Group placement for Interns',
+ 'autoMemberTargetGroup': [f'cn=Interns,cn=replsubGroups,{DEFAULT_SUFFIX}'],
+ 'autoMemberInclusiveRegex': ['uidNumber=^1..6$',
+ 'gidNumber=^[1-9]..3$',
+ 'nsAdminGroupName=^Interns$|^Trainees$'],
+ "autoMemberExclusiveRegex": ['uidNumber=^[1-9]99$',
+ 'gidNumber=^[1-9]00$',
+ 'nsAdminGroupName=^Students$'],})
+ automembers.create(properties={
+ 'cn': 'Visitors',
+ 'description': f'Group placement for Visitors',
+ 'autoMemberTargetGroup': [f'cn=Visitors,cn=replsubGroups,{DEFAULT_SUFFIX}'],
+ 'autoMemberInclusiveRegex': ['uidNumber=^1..6$',
+ 'gidNumber=^[1-5]6.3$',
+ 'nsAdminGroupName=^Visitors$'],
+ "autoMemberExclusiveRegex": ['uidNumber=^[7-9]99$',
+ 'gidNumber=^[7-9]00$',
+ 'nsAdminGroupName=^Inter'],
+ })
+ for instance in [topo_m4.ms['master1'], topo_m4.ms['master2'],
+ topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ instance.restart()
+
+
+def delete_users_and_wait(topo_m4, automem_scope):
+ """
+ Deletes entries after test and waits for replication.
+ """
+ for user in nsAdminGroups(topo_m4.ms['master1'], automem_scope, rdn=None).list():
+ user.delete()
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+
+
+def create_entry(topo_m4, user_id, suffix, uid_no, gid_no, role_usr):
+ """
+ Will create entries with nsAdminGroup objectclass
+ """
+ user = nsAdminGroups(topo_m4.ms['master1'], suffix, rdn=None).create(properties={
+ 'cn': user_id,
+ 'sn': user_id,
+ 'uid': user_id,
+ 'homeDirectory': '/home/{}'.format(user_id),
+ 'loginShell': '/bin/bash',
+ 'uidNumber': uid_no,
+ 'gidNumber': gid_no,
+ 'objectclass': ['top', 'person', 'posixaccount', 'inetuser',
+ 'nsMemberOf', 'nsAccount', 'nsAdminGroup'],
+ 'nsAdminGroupName': role_usr,
+ 'seeAlso': 'uid={},{}'.format(user_id, suffix),
+ 'entrydn': 'uid={},{}'.format(user_id, suffix)
+ })
+ return user
+
+
+def test_adding_300_user(topo_m4, _create_entries):
+ """
+ Adding 300 user entries matching the inclusive regex rules for
+ all targetted groups at M1 and checking the same created in M2 & M3
+ :id: fcd867bc-be57-11e9-9842-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 300 user entries matching the inclusive regex rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ """
+ user_rdn = "long01usr"
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef1,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef2,{}".format(DEFAULT_SUFFIX)
+ # Adding BulkUsers
+ for number in range(300):
+ create_entry(topo_m4, f'{user_rdn}{number}', automem_scope, '5795', '5693', 'Contractor')
+ try:
+ # Check to sync the entries
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master2'], 'Managers'),
+ (topo_m4.ms['master3'], 'Contractors'),
+ (topo_m4.ms['master4'], 'Interns')]:
+ assert len(nsAdminGroup(
+ instance, f'cn={grp},{grp_container}').get_attr_vals_utf8('member')) == 300
+ for grp in [default_group1, default_group2]:
+ assert not Group(topo_m4.ms['master4'], grp).get_attr_vals_utf8('member')
+ assert not Group(topo_m4.ms['master3'], grp).get_attr_vals_utf8('member')
+
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_adding_1000_users(topo_m4, _create_entries):
+ """
+ Adding 1000 users matching inclusive regex for Managers/Contractors
+ and exclusive regex for Interns/Visitors
+ :id: f641e612-be57-11e9-94e6-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 1000 user entries matching the inclusive/exclusive
+ regex rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ """
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef1,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef2,{}".format(DEFAULT_SUFFIX)
+ # Adding 1000 users
+ for number in range(1000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '799', '5693', 'Manager')
+ try:
+ # Check to sync the entries
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master1'], 'Managers'),
+ (topo_m4.ms['master3'], 'Contractors')]:
+ assert len(nsAdminGroup(
+ instance, "cn={},{}".format(grp,
+ grp_container)).get_attr_vals_utf8('member')) == 1000
+ for instance, grp in [(topo_m4.ms['master2'], 'Interns'),
+ (topo_m4.ms['master4'], 'Visitors')]:
+ assert not nsAdminGroup(
+ instance, "cn={},{}".format(grp, grp_container)).get_attr_vals_utf8('member')
+ for grp in [default_group1, default_group2]:
+ assert not Group(topo_m4.ms['master2'], grp).get_attr_vals_utf8('member')
+ assert not Group(topo_m4.ms['master3'], grp).get_attr_vals_utf8('member')
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_adding_3000_users(topo_m4, _create_entries):
+ """
+ Adding 3000 users matching all inclusive regex rules and no matching exclusive regex rules
+ :id: ee54576e-be57-11e9-b536-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 3000 user entries matching the inclusive/exclusive regex
+ rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ """
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef3,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef5,{}".format(DEFAULT_SUFFIX)
+ # Adding 3000 users
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '5995', '5693', 'Manager')
+ try:
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master1'], 'Managers'),
+ (topo_m4.ms['master3'], 'Contractors'),
+ (topo_m4.ms['master2'], 'Interns'),
+ (topo_m4.ms['master4'], 'Visitors')
+ ]:
+ assert len(
+ nsAdminGroup(instance,
+ "cn={},{}".format(grp,
+ grp_container)).get_attr_vals_utf8('member')) == 3000
+ for grp in [default_group1, default_group2]:
+ assert not Group(topo_m4.ms['master2'], grp).get_attr_vals_utf8('member')
+ assert not Group(topo_m4.ms['master3'], grp).get_attr_vals_utf8('member')
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_3000_users_matching_all_exclusive_regex(topo_m4, _create_entries):
+ """
+ Adding 3000 users matching all exclusive regex rules and no matching inclusive regex rules
+ :id: e789331e-be57-11e9-b298-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 3000 user entries matching the inclusive/exclusive regex
+ rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ """
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef1,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef2,{}".format(DEFAULT_SUFFIX)
+ default_group4 = "cn=SubDef4,{}".format(DEFAULT_SUFFIX)
+ # Adding 3000 users
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '399', '700', 'Manager')
+ try:
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+
+ for instance, grp in [(topo_m4.ms['master1'], default_group4),
+ (topo_m4.ms['master2'], default_group1),
+ (topo_m4.ms['master3'], default_group2),
+ (topo_m4.ms['master4'], default_group2)]:
+ assert len(nsAdminGroup(instance, grp).get_attr_vals_utf8('member')) == 3000
+ for grp, instance in [('Managers', topo_m4.ms['master3']),
+ ('Contractors', topo_m4.ms['master2'])]:
+ assert not nsAdminGroup(
+ instance, "cn={},{}".format(grp, grp_container)).get_attr_vals_utf8('member')
+
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_no_matching_inclusive_regex_rules(topo_m4, _create_entries):
+ """
+ Adding 3000 users matching all exclusive regex rules and no matching inclusive regex rules
+ :id: e0cc0e16-be57-11e9-9c0f-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 3000 user entries matching the inclusive/exclusive regex
+ rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ """
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef1,{}".format(DEFAULT_SUFFIX)
+ # Adding 3000 users
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '399', '700', 'Manager')
+ try:
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master1'], "cn=SubDef4,{}".format(DEFAULT_SUFFIX)),
+ (topo_m4.ms['master2'], default_group1),
+ (topo_m4.ms['master3'], "cn=SubDef2,{}".format(DEFAULT_SUFFIX)),
+ (topo_m4.ms['master4'], "cn=SubDef3,{}".format(DEFAULT_SUFFIX))]:
+ assert len(nsAdminGroup(instance, grp).get_attr_vals_utf8('member')) == 3000
+ for grp, instance in [('Managers', topo_m4.ms['master3']),
+ ('Contractors', topo_m4.ms['master2'])]:
+ assert not nsAdminGroup(
+ instance, "cn={},{}".format(grp, grp_container)).get_attr_vals_utf8('member')
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_adding_deleting_and_re_adding_the_same_3000(topo_m4, _create_entries):
+ """
+ Adding, Deleting and re-adding the same 3000 users matching all
+ exclusive regex rules and no matching inclusive regex rules
+ :id: d939247c-be57-11e9-825d-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 3000 user entries matching the inclusive/exclusive regex
+ rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ 3. Delete 3000 users
+ 4. Again add 3000 users
+ 5. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ 3. Pass
+ 4. Pass
+ 5. Pass
+ """
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef1,{}".format(DEFAULT_SUFFIX)
+ # Adding
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '399', '700', 'Manager')
+ try:
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ assert len(nsAdminGroup(topo_m4.ms['master2'],
+ default_group1).get_attr_vals_utf8('member')) == 3000
+ # Deleting
+ for user in nsAdminGroups(topo_m4.ms['master2'], automem_scope, rdn=None).list():
+ user.delete()
+ for master in [topo_m4.ms['master1'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master2'],
+ master, timeout=30000)
+ # Again adding
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '399', '700', 'Manager')
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master1'], "cn=SubDef4,{}".format(DEFAULT_SUFFIX)),
+ (topo_m4.ms['master3'], "cn=SubDef5,{}".format(DEFAULT_SUFFIX)),
+ (topo_m4.ms['master4'], "cn=SubDef3,{}".format(DEFAULT_SUFFIX))]:
+ assert len(nsAdminGroup(instance, grp).get_attr_vals_utf8('member')) == 3000
+ for grp, instance in [('Interns', topo_m4.ms['master3']),
+ ('Contractors', topo_m4.ms['master2'])]:
+ assert not nsAdminGroup(
+ instance, "cn={},{}".format(grp, grp_container)).get_attr_vals_utf8('member')
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_re_adding_the_same_3000_users(topo_m4, _create_entries):
+ """
+ Adding, Deleting and re-adding the same 3000 users matching all inclusive
+ regex rules and no matching exclusive regex rules
+ :id: d2f5f112-be57-11e9-b164-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 3000 user entries matching the inclusive/exclusive regex
+ rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ 3. Delete 3000 users
+ 4. Again add 3000 users
+ 5. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ 3. Pass
+ 4. Pass
+ 5. Pass
+ """
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef3,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef5,{}".format(DEFAULT_SUFFIX)
+ # Adding
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '5995', '5693', 'Manager')
+ try:
+ for master in [topo_m4.ms['master1'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master2'],
+ master, timeout=30000)
+ assert len(nsAdminGroup(
+ topo_m4.ms['master2'],
+ f'cn=Contractors,{grp_container}').get_attr_vals_utf8('member')) == 3000
+ # Deleting
+ delete_users_and_wait(topo_m4, automem_scope)
+
+ # re-adding
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '5995', '5693', 'Manager')
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master1'], "cn=Managers,{}".format(grp_container)),
+ (topo_m4.ms['master3'], "cn=Contractors,{}".format(grp_container)),
+ (topo_m4.ms['master4'], "cn=Visitors,{}".format(grp_container)),
+ (topo_m4.ms['master2'], "cn=Interns,{}".format(grp_container))]:
+ assert len(nsAdminGroup(instance, grp).get_attr_vals_utf8('member')) == 3000
+ for grp, instance in [(default_group2, topo_m4.ms['master4']),
+ (default_group1, topo_m4.ms['master3'])]:
+ assert not nsAdminGroup(instance, grp).get_attr_vals_utf8('member')
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_users_with_different_uid_and_gid_nos(topo_m4, _create_entries):
+ """
+ Adding, Deleting and re-adding the same 3000 users with
+ different uid and gid nos, with different inclusive/exclusive matching regex rules
+ :id: cc595a1a-be57-11e9-b053-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Add 3000 user entries matching the inclusive/exclusive regex
+ rules at topo_m4.ms['master1']
+ 2. Check the same created in rest masters
+ 3. Delete 3000 users
+ 4. Again add 3000 users
+ 5. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ 3. Pass
+ 4. Pass
+ 5. Pass
+ """
+ automem_scope = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef3,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef5,{}".format(DEFAULT_SUFFIX)
+ # Adding
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope, '3994', '5695', 'OnDeputation')
+ try:
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for intstance, grp in [(topo_m4.ms['master2'], default_group1),
+ (topo_m4.ms['master3'], default_group2)]:
+ assert len(nsAdminGroup(intstance, grp).get_attr_vals_utf8('member')) == 3000
+ for grp, instance in [('Contractors', topo_m4.ms['master3']),
+ ('Managers', topo_m4.ms['master1'])]:
+ assert not nsAdminGroup(
+ instance, "cn={},{}".format(grp, grp_container)).get_attr_vals_utf8('member')
+ # Deleting
+ for user in nsAdminGroups(topo_m4.ms['master1'], automem_scope, rdn=None).list():
+ user.delete()
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ # re-adding
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope,
+ '5995', '5693', 'OnDeputation')
+
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for grp, instance in [('Contractors', topo_m4.ms['master3']),
+ ('Managers', topo_m4.ms['master1']),
+ ('Interns', topo_m4.ms['master2']),
+ ('Visitors', topo_m4.ms['master4'])]:
+ assert len(nsAdminGroup(
+ instance, f'cn={grp},{grp_container}').get_attr_vals_utf8('member')) == 3000
+
+ for instance, grp in [(topo_m4.ms['master2'], default_group1),
+ (topo_m4.ms['master3'], default_group2)]:
+ assert not nsAdminGroup(instance, grp).get_attr_vals_utf8('member')
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+
+
+def test_bulk_users_to_non_automemscope(topo_m4, _create_entries):
+ """
+ Adding bulk users to non-automem_scope and then running modrdn
+ operation to change the ou to automem_scope
+ :id: c532dc0c-be57-11e9-bcca-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Running modrdn operation to change the ou to automem_scope
+ 2. Add 3000 user entries to non-automem_scope at topo_m4.ms['master1']
+ 3. Run AutomemberRebuildMembershipTask
+ 4. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ 3. Pass
+ 4. Pass
+ """
+ automem_scope = "cn=EmployeesNew,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef3,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef5,{}".format(DEFAULT_SUFFIX)
+ nsContainers(topo_m4.ms['master1'], DEFAULT_SUFFIX).create(properties={'cn': 'ChangeThisCN'})
+ Group(topo_m4.ms['master1'],
+ f'cn=replsubGroups,cn=autoMembersPlugin,{DEFAULT_SUFFIX}').replace('autoMemberScope',
+ automem_scope)
+ for instance in [topo_m4.ms['master1'], topo_m4.ms['master2'],
+ topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ instance.restart()
+ # Adding BulkUsers
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', f'cn=ChangeThisCN,{DEFAULT_SUFFIX}',
+ '5995', '5693', 'Supervisor')
+ try:
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master2'], default_group1),
+ (topo_m4.ms['master1'], "cn=Managers,{}".format(grp_container))]:
+ assert not nsAdminGroup(instance, grp).get_attr_vals_utf8('member')
+ # Deleting BulkUsers "User_Name" Suffix "Nof_Users"
+ topo_m4.ms['master3'].rename_s(f"CN=ChangeThisCN,{DEFAULT_SUFFIX}",
+ f'cn=EmployeesNew', newsuperior=DEFAULT_SUFFIX, delold=1)
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ AutomemberRebuildMembershipTask(topo_m4.ms['master1']).create(properties={
+ 'basedn': automem_scope,
+ 'filter': "objectClass=posixAccount"
+ })
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master1'], 'Managers'),
+ (topo_m4.ms['master2'], 'Interns'),
+ (topo_m4.ms['master3'], 'Contractors'),
+ (topo_m4.ms['master4'], 'Visitors')]:
+ assert len(nsAdminGroup(
+ instance, f'cn={grp},{grp_container}').get_attr_vals_utf8('member')) == 3000
+ for grp, instance in [(default_group1, topo_m4.ms['master2']),
+ (default_group2, topo_m4.ms['master3'])]:
+ assert not nsAdminGroup(instance, grp).get_attr_vals_utf8('member')
+ finally:
+ delete_users_and_wait(topo_m4, automem_scope)
+ nsContainer(topo_m4.ms['master1'], "CN=EmployeesNew,{}".format(DEFAULT_SUFFIX)).delete()
+
+
+def test_automemscope_and_running_modrdn(topo_m4, _create_entries):
+ """
+ Adding bulk users to non-automem_scope and running modrdn operation
+ with new superior to automem_scope
+ :id: bf60f958-be57-11e9-945d-8c16451d917b
+ :setup: Instance with 4 masters
+ :steps:
+ 1. Running modrdn operation to change the ou to automem_scope
+ 2. Add 3000 user entries to non-automem_scope at topo_m4.ms['master1']
+ 3. Run AutomemberRebuildMembershipTask
+ 4. Check the same created in rest masters
+ :expected results:
+ 1. Pass
+ 2. Pass
+ 3. Pass
+ 4. Pass
+ """
+ user_rdn = "long09usr"
+ automem_scope1 = "ou=Employees,{}".format(DEFAULT_SUFFIX)
+ automem_scope2 = "cn=NewEmployees,{}".format(DEFAULT_SUFFIX)
+ grp_container = "cn=replsubGroups,{}".format(DEFAULT_SUFFIX)
+ default_group1 = "cn=SubDef3,{}".format(DEFAULT_SUFFIX)
+ default_group2 = "cn=SubDef5,{}".format(DEFAULT_SUFFIX)
+ OrganizationalUnits(topo_m4.ms['master1'],
+ DEFAULT_SUFFIX).create(properties={'ou': 'NewEmployees'})
+ Group(topo_m4.ms['master1'],
+ f'cn=replsubGroups,cn=autoMembersPlugin,{DEFAULT_SUFFIX}').replace('autoMemberScope',
+ automem_scope2)
+ for instance in [topo_m4.ms['master1'], topo_m4.ms['master2'],
+ topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ Config(instance).replace('nsslapd-errorlog-level', '73728')
+ instance.restart()
+ # Adding bulk users
+ for number in range(3000):
+ create_entry(topo_m4, f'automemusrs{number}', automem_scope1,
+ '3994', '5695', 'OnDeputation')
+ try:
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for grp, instance in [(default_group2, topo_m4.ms['master3']),
+ ("cn=Managers,{}".format(grp_container), topo_m4.ms['master1']),
+ ("cn=Contractors,{}".format(grp_container), topo_m4.ms['master3'])]:
+ assert not nsAdminGroup(instance, grp).get_attr_vals_utf8('member')
+ count = 0
+ for user in nsAdminGroups(topo_m4.ms['master3'], automem_scope1, rdn=None).list():
+ topo_m4.ms['master1'].rename_s(user.dn,
+ f'cn=New{user_rdn}{count}',
+ newsuperior=automem_scope2, delold=1)
+ count += 1
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ AutomemberRebuildMembershipTask(topo_m4.ms['master1']).create(properties={
+ 'basedn': automem_scope2,
+ 'filter': "objectClass=posixAccount"
+ })
+ for master in [topo_m4.ms['master2'], topo_m4.ms['master3'], topo_m4.ms['master4']]:
+ ReplicationManager(DEFAULT_SUFFIX).wait_for_replication(topo_m4.ms['master1'],
+ master, timeout=30000)
+ for instance, grp in [(topo_m4.ms['master3'], default_group2),
+ (topo_m4.ms['master3'], default_group1)]:
+ assert len(nsAdminGroup(instance, grp).get_attr_vals_utf8('member')) == 3000
+ for instance, grp in [(topo_m4.ms['master1'], 'Managers'),
+ (topo_m4.ms['master3'], 'Contractors'),
+ (topo_m4.ms['master2'], 'Interns'),
+ (topo_m4.ms['master4'], 'Visitors')]:
+ assert not nsAdminGroup(
+ instance, "cn={},{}".format(grp, grp_container)).get_attr_vals_utf8('member')
+ finally:
+ for scope in [automem_scope1, automem_scope2]:
+ delete_users_and_wait(topo_m4, scope)
+
+
+if __name__ == '__main__':
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
| 0 |
9b38ac3b5d27014c072cffb5a83e5888689c411b
|
389ds/389-ds-base
|
Clean up assert for entrydn
Use entryrdn instead
|
commit 9b38ac3b5d27014c072cffb5a83e5888689c411b
Author: Rich Megginson <[email protected]>
Date: Mon Jan 25 18:05:38 2010 -0700
Clean up assert for entrydn
Use entryrdn instead
diff --git a/ldap/servers/slapd/back-ldbm/misc.c b/ldap/servers/slapd/back-ldbm/misc.c
index 137c93433..802370b9f 100644
--- a/ldap/servers/slapd/back-ldbm/misc.c
+++ b/ldap/servers/slapd/back-ldbm/misc.c
@@ -155,7 +155,7 @@ compute_entry_tombstone_rdn(const char *entryrdn, const char *uniqueid)
{
char *tombstone_rdn;
- PR_ASSERT(NULL != entrydn);
+ PR_ASSERT(NULL != entryrdn);
PR_ASSERT(NULL != uniqueid);
tombstone_rdn = slapi_ch_smprintf("%s=%s, %s",
| 0 |
0c51de739bce822abcee5d868730c68d59e307ec
|
389ds/389-ds-base
|
Issue 3585 - LDAP server returning controltype in different sequence
Description:
Added a test to check sequence of ldap controlType returned
when there are remaining or exhausted grace login.
Automation was not possible until now because of bug 1757699 in python-ldap
where no controls were returned in the error message after exception was raised
with exhausted grace login. The bug is fixed now.
Relates: https://github.com/389ds/389-ds-base/issues/3585
Reviewed by: droideck (Thanks!)
|
commit 0c51de739bce822abcee5d868730c68d59e307ec
Author: Barbora Simonova <[email protected]>
Date: Mon Mar 29 15:54:43 2021 +0200
Issue 3585 - LDAP server returning controltype in different sequence
Description:
Added a test to check sequence of ldap controlType returned
when there are remaining or exhausted grace login.
Automation was not possible until now because of bug 1757699 in python-ldap
where no controls were returned in the error message after exception was raised
with exhausted grace login. The bug is fixed now.
Relates: https://github.com/389ds/389-ds-base/issues/3585
Reviewed by: droideck (Thanks!)
diff --git a/dirsrvtests/tests/suites/password/pwdPolicy_controls_sequence_test.py b/dirsrvtests/tests/suites/password/pwdPolicy_controls_sequence_test.py
new file mode 100644
index 000000000..ec85b61f4
--- /dev/null
+++ b/dirsrvtests/tests/suites/password/pwdPolicy_controls_sequence_test.py
@@ -0,0 +1,133 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2021 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+
+import logging
+import pytest
+import os
+import ldap
+import time
+import ast
+
+from ldap.controls.ppolicy import PasswordPolicyControl
+from ldap.controls.pwdpolicy import PasswordExpiredControl
+from lib389.topologies import topology_st as topo
+from lib389.idm.user import UserAccounts
+from lib389._constants import (DN_DM, PASSWORD, DEFAULT_SUFFIX)
+
+pytestmark = pytest.mark.tier1
+
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+
+USER_DN = 'uid=test entry,ou=people,dc=example,dc=com'
+USER_PW = b'password123'
+
+
[email protected]
+def init_user(topo, request):
+ users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ user_data = {'uid': 'test entry',
+ 'cn': 'test entry',
+ 'sn': 'test entry',
+ 'uidNumber': '3000',
+ 'gidNumber': '4000',
+ 'homeDirectory': '/home/test_entry',
+ 'userPassword': USER_PW}
+ test_user = users.create(properties=user_data)
+
+ def fin():
+ log.info('Delete test user')
+ if test_user.exists():
+ test_user.delete()
+
+ request.addfinalizer(fin)
+
+
+def bind_and_get_control(topo):
+ log.info('Bind as the user, and return any controls')
+ res_type = res_data = res_msgid = res_ctrls = None
+ result_id = ''
+
+ try:
+ result_id = topo.standalone.simple_bind(USER_DN, USER_PW,
+ serverctrls=[PasswordPolicyControl()])
+ res_type, res_data, res_msgid, res_ctrls = topo.standalone.result3(result_id)
+ except ldap.LDAPError as e:
+ log.info('Got expected error: {}'.format(str(e)))
+ res_ctrls = ast.literal_eval(str(e))
+ pass
+
+ topo.standalone.simple_bind(DN_DM, PASSWORD)
+ return res_ctrls
+
+
+def change_passwd(topo):
+ log.info('Reset user password as the user, then re-bind as Directory Manager')
+ users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ user = users.get('test entry')
+ user.rebind(USER_PW)
+ user.reset_password(USER_PW)
+ topo.standalone.simple_bind(DN_DM, PASSWORD)
+
+
[email protected]
[email protected]
+def test_controltype_expired_grace_limit(topo, init_user):
+ """Test for expiration control when password is expired with available and exhausted grace login
+
+ :id: 0392a73c-6467-49f9-bdb6-3648f6971896
+ :setup: Standalone instance, a user for testing
+ :steps:
+ 1. Configure password policy, reset password and allow it to expire
+ 2. Bind and check sequence of controlType
+ 3. Bind (one grace login remaining) and check sequence of controlType
+ 4. Bind (grace login exhausted) and check sequence of controlType
+ :expectedresults:
+ 1. Config update and password reset are successful
+ 2. ControlType sequence is in correct order
+ 3. ControlType sequence is in correct order
+ 4. ControlType sequence is in correct order
+ """
+
+ log.info('Configure password policy with grace limit set to 2')
+ topo.standalone.config.set('passwordExp', 'on')
+ topo.standalone.config.set('passwordMaxAge', '5')
+ topo.standalone.config.set('passwordGraceLimit', '2')
+
+ log.info('Change password and wait for it to expire')
+ change_passwd(topo)
+ time.sleep(6)
+
+ log.info('Bind and use up one grace login (only one left)')
+ controls = bind_and_get_control(topo)
+ assert (controls[0].controlType == "1.3.6.1.4.1.42.2.27.8.5.1")
+ assert (controls[1].controlType == "2.16.840.1.113730.3.4.4")
+
+ log.info('Bind again and check the sequence')
+ controls = bind_and_get_control(topo)
+ assert (controls[0].controlType == "1.3.6.1.4.1.42.2.27.8.5.1")
+ assert (controls[1].controlType == "2.16.840.1.113730.3.4.4")
+
+ log.info('Bind with expired grace login and check the sequence')
+ # No grace login available, bind should fail, controls will be returned in error message
+ controls = bind_and_get_control(topo)
+ assert (controls['ctrls'][0][0] == "1.3.6.1.4.1.42.2.27.8.5.1")
+ assert (controls['ctrls'][1][0] == "2.16.840.1.113730.3.4.4")
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
| 0 |
56055da0fde15d199d8d2c48e934c44444f42ea6
|
389ds/389-ds-base
|
Issue 49159 - test_schema_comparewithfiles fails with python-ldap>=2.4.26
Bug Description:
comparewithfiles test from Schema test suite fails on 99user.ldif
with newer versions of python-ldap (2.4.26 and higher).
Fix Description:
Handle exception gracefully.
https://pagure.io/389-ds-base/issue/49159
Reviewed by: mreynolds (Thanks!)
|
commit 56055da0fde15d199d8d2c48e934c44444f42ea6
Author: Viktor Ashirov <[email protected]>
Date: Tue Mar 7 03:32:11 2017 +0100
Issue 49159 - test_schema_comparewithfiles fails with python-ldap>=2.4.26
Bug Description:
comparewithfiles test from Schema test suite fails on 99user.ldif
with newer versions of python-ldap (2.4.26 and higher).
Fix Description:
Handle exception gracefully.
https://pagure.io/389-ds-base/issue/49159
Reviewed by: mreynolds (Thanks!)
diff --git a/dirsrvtests/tests/suites/schema/test_schema.py b/dirsrvtests/tests/suites/schema/test_schema.py
index 123d6fcc2..10838f19b 100644
--- a/dirsrvtests/tests/suites/schema/test_schema.py
+++ b/dirsrvtests/tests/suites/schema/test_schema.py
@@ -127,11 +127,10 @@ def test_schema_comparewithfiles(topology_st):
ldschema = schemainst.schema.get_subschema()
assert ldschema
for fn in schemainst.schema.list_files():
- fschema = schemainst.schema.file_to_subschema(fn)
- if not fschema:
+ try:
+ fschema = schemainst.schema.file_to_subschema(fn)
+ except:
log.warn("Unable to parse %s as a schema file - skipping" % fn)
- continue
- assert fschema
for oid in fschema.listall(occlass):
se = fschema.get_obj(occlass, oid)
assert se
| 0 |
9a08654534dc89e537b8012dfb27d0791a572bac
|
389ds/389-ds-base
|
Ticket 48237 - Add lib389 helper to enable and disable logging services.
From: William Brown <[email protected]>
Date: Mon, 3 Aug 2015 10:05:06 +0930
Subject: [PATCH] Add log service enable and disable commands to
lib389/brooker.py
https://fedorahosted.org/389/ticket/48237
Reviewed by: mreynolds
|
commit 9a08654534dc89e537b8012dfb27d0791a572bac
Author: Mark Reynolds <[email protected]>
Date: Wed Aug 5 15:12:30 2015 -0400
Ticket 48237 - Add lib389 helper to enable and disable logging services.
From: William Brown <[email protected]>
Date: Mon, 3 Aug 2015 10:05:06 +0930
Subject: [PATCH] Add log service enable and disable commands to
lib389/brooker.py
https://fedorahosted.org/389/ticket/48237
Reviewed by: mreynolds
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index e40acddef..10bf0df04 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -1980,7 +1980,7 @@ class DirSrv(SimpleLDAPObject):
def setAccessLogLevel(self, *vals):
"""Set nsslapd-accesslog-level and return its value."""
- return self.config.loglevel(vals, level='access')
+ return self.config.loglevel(vals, service='access')
def configSSL(self, secport=636, secargs=None):
"""Configure SSL support into cn=encryption,cn=config.
diff --git a/src/lib389/lib389/brooker.py b/src/lib389/lib389/brooker.py
index 34453ccd6..f7a5fc848 100644
--- a/src/lib389/lib389/brooker.py
+++ b/src/lib389/lib389/brooker.py
@@ -53,29 +53,54 @@ class Config(object):
"""Get an attribute under cn=config"""
return self.conn.getEntry(DN_CONFIG).__getattr__(key)
- def loglevel(self, vals=(LOG_DEFAULT,), level='error', update=False):
+ def _alter_log_enabled(self, service, state):
+ if service not in ('access', 'error', 'audit'):
+ self.log.error('Attempted to enable invalid log service "%s"' % service)
+ service = 'nsslapd-%slog-logging-enabled' % service
+ self.log.debug('Setting log %s to %s' % (service, state))
+ self.set(service, state)
+
+ def enable_log(self, service):
+ """Enable a logging service in the 389ds instance.
+ @param service - The logging service to enable. Can be one of 'access', 'error' or 'audit'.
+
+ ex. enable_log('audit')
+ """
+ self._alter_log_enabled(service, 'on')
+
+ def disable_log(self, service):
+ """Disable a logging service in the 389ds instance.
+ @param service - The logging service to Disable. Can be one of 'access', 'error' or 'audit'.
+
+ ex. disable_log('audit')
+ """
+ self._alter_log_enabled(service, 'off')
+
+ def loglevel(self, vals=(LOG_DEFAULT,), service='error', update=False):
"""Set the access or error log level.
@param vals - a list of log level codes (eg. lib389.LOG_*)
defaults to LOG_DEFAULT
- @param level - 'access' or 'error'
+ @param service - 'access' or 'error'. There is no 'audit' log level. use enable_log or disable_log.
@param update - False for replace (default), True for update
-
+
ex. loglevel([lib389.LOG_DEFAULT, lib389.LOG_ENTRY_PARSER])
"""
- level = 'nsslapd-%slog-level' % level
+ if service not in ('access', 'error'):
+ self.log.error('Attempted to set level on invalid log service "%s"' % service)
+ service = 'nsslapd-%slog-level' % service
assert len(vals) > 0, "set at least one log level"
tot = 0
for v in vals:
tot |= v
if update:
- old = int(self.get(level))
+ old = int(self.get(service))
tot |= old
- self.log.debug("Update %s value: %r -> %r" % (level, old, tot))
+ self.log.debug("Update %s value: %r -> %r" % (service, old, tot))
else:
- self.log.debug("Replace %s with value: %r" % (level, tot))
+ self.log.debug("Replace %s with value: %r" % (service, tot))
- self.set(level, str(tot))
+ self.set(service, str(tot))
return tot
def enable_ssl(self, secport=636, secargs=None):
diff --git a/src/lib389/tests/config_test.py b/src/lib389/tests/config_test.py
index e4eaefdbb..bcec4b335 100644
--- a/src/lib389/tests/config_test.py
+++ b/src/lib389/tests/config_test.py
@@ -51,7 +51,7 @@ def setup():
def teardown():
global conn
conn.config.loglevel([lib389.LOG_CACHE])
- conn.config.loglevel([256], level='access')
+ conn.config.loglevel([256], service='access')
"""
drop_added_entries(conn)
@@ -79,5 +79,5 @@ def loglevel_update_test():
def access_loglevel_test():
vals = [lib389.LOG_CACHE, lib389.LOG_REPLICA, lib389.LOG_CONNECT]
- assert conn.config.loglevel(vals, level='access') == sum(vals)
+ assert conn.config.loglevel(vals, service='access') == sum(vals)
diff --git a/src/lib389/tests/dsadmin_basic_test.py b/src/lib389/tests/dsadmin_basic_test.py
index 422c1c289..5d57dfb0e 100644
--- a/src/lib389/tests/dsadmin_basic_test.py
+++ b/src/lib389/tests/dsadmin_basic_test.py
@@ -34,7 +34,7 @@ def tearDown():
# reduce log level
conn.config.loglevel([lib389.LOG_CACHE])
- conn.config.loglevel([256], level='access')
+ conn.config.loglevel([256], service='access')
for e in conn.added_entries:
try:
diff --git a/src/lib389/tests/dsadmin_test.py b/src/lib389/tests/dsadmin_test.py
index 251617d39..8f28d0370 100644
--- a/src/lib389/tests/dsadmin_test.py
+++ b/src/lib389/tests/dsadmin_test.py
@@ -22,7 +22,7 @@ added_backends = None
def harn_nolog():
conn.config.loglevel([lib389.LOG_DEFAULT])
- conn.config.loglevel([lib389.LOG_DEFAULT], level='access')
+ conn.config.loglevel([lib389.LOG_DEFAULT], service='access')
def setup():
| 0 |
d341b7734648e71c1b1ded398971c23b6fbdc1fb
|
389ds/389-ds-base
|
Ticket 47792 - code cleanup
https://fedorahosted.org/389/ticket/47792
Reviewed by: rmeggins(Thanks!)
|
commit d341b7734648e71c1b1ded398971c23b6fbdc1fb
Author: Mark Reynolds <[email protected]>
Date: Tue Apr 29 18:29:41 2014 -0400
Ticket 47792 - code cleanup
https://fedorahosted.org/389/ticket/47792
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/plugins/chainingdb/cb_add.c b/ldap/servers/plugins/chainingdb/cb_add.c
index 07b90facb..03d0fc9e5 100644
--- a/ldap/servers/plugins/chainingdb/cb_add.c
+++ b/ldap/servers/plugins/chainingdb/cb_add.c
@@ -54,23 +54,22 @@
int
chaining_back_add ( Slapi_PBlock *pb )
{
-
- Slapi_Backend *be;
- Slapi_Entry *e;
- cb_backend_instance *cb;
- LDAPControl **serverctrls=NULL;
- LDAPControl **ctrls=NULL;
- int rc,parse_rc,msgid,i;
- LDAP *ld=NULL;
- char **referrals=NULL;
- LDAPMod ** mods;
- LDAPMessage * res;
- char * matched_msg, *error_msg;
- const char *dn = NULL;
- Slapi_DN *sdn = NULL;
- char *cnxerrbuf=NULL;
- time_t endtime = 0;
- cb_outgoing_conn *cnx;
+ cb_outgoing_conn *cnx;
+ Slapi_Backend *be;
+ Slapi_Entry *e;
+ cb_backend_instance *cb;
+ LDAPControl **serverctrls = NULL;
+ LDAPControl **ctrls = NULL;
+ LDAPMod **mods;
+ LDAPMessage *res;
+ LDAP *ld = NULL;
+ Slapi_DN *sdn = NULL;
+ const char *dn = NULL;
+ char **referrals = NULL;
+ char *matched_msg, *error_msg;
+ char *cnxerrbuf = NULL;
+ time_t endtime = 0;
+ int rc, parse_rc, msgid, i;
if ( (rc=cb_forward_operation(pb)) != LDAP_SUCCESS ) {
cb_send_ldap_result( pb, rc, NULL, "Remote data access disabled", 0, NULL );
@@ -85,7 +84,7 @@ chaining_back_add ( Slapi_PBlock *pb )
/* Check wether the chaining BE is available or not */
if ( cb_check_availability( cb, pb ) == FARMSERVER_UNAVAILABLE ){
- return -1;
+ return -1;
}
slapi_pblock_get( pb, SLAPI_ADD_TARGET_SDN, &sdn );
@@ -108,8 +107,8 @@ chaining_back_add ( Slapi_PBlock *pb )
cb_eliminate_illegal_attributes(cb,e);
if ((rc = slapi_entry2mods ((const Slapi_Entry *)e, NULL, &mods)) != LDAP_SUCCESS) {
- cb_send_ldap_result( pb, rc,NULL,NULL, 0, NULL);
- return -1;
+ cb_send_ldap_result( pb, rc,NULL,NULL, 0, NULL);
+ return -1;
}
/* Grab a connection handle */
@@ -118,12 +117,11 @@ chaining_back_add ( Slapi_PBlock *pb )
static int warned_get_conn = 0;
if (!warned_get_conn) {
slapi_log_error(SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "cb_get_connection failed (%d) %s\n",
- rc, ldap_err2string(rc));
+ "cb_get_connection failed (%d) %s\n",
+ rc, ldap_err2string(rc));
warned_get_conn = 1;
}
- cb_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,
- cnxerrbuf, 0, NULL);
+ cb_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, cnxerrbuf, 0, NULL);
ldap_mods_free(mods, 1);
slapi_ch_free_string(&cnxerrbuf);
/* ping the farm.
@@ -135,23 +133,23 @@ chaining_back_add ( Slapi_PBlock *pb )
/* Control management */
if ( (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH)) != LDAP_SUCCESS ) {
- cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
+ cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
ldap_mods_free(mods,1);
- return -1;
+ return -1;
}
- if ( slapi_op_abandoned( pb )) {
- cb_release_op_connection(cb->pool,ld,0);
+ if ( slapi_op_abandoned( pb )) {
+ cb_release_op_connection(cb->pool,ld,0);
ldap_mods_free(mods,1);
if ( NULL != ctrls)
ldap_controls_free(ctrls);
- return -1;
- }
+ return -1;
+ }
/* heart-beat management */
if (cb->max_idle_time>0)
- endtime=current_time() + cb->max_idle_time;
+ endtime=current_time() + cb->max_idle_time;
/* Send LDAP operation to the remote host */
rc = ldap_add_ext( ld, dn, mods, ctrls, NULL, &msgid );
@@ -161,10 +159,9 @@ chaining_back_add ( Slapi_PBlock *pb )
if ( rc != LDAP_SUCCESS ) {
slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "ldap_add_ext failed -- %s\n", ldap_err2string(rc) );
+ "ldap_add_ext failed -- %s\n", ldap_err2string(rc) );
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ENDUSERMSG, 0, NULL );
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, ENDUSERMSG, 0, NULL );
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
ldap_mods_free(mods,1);
return -1;
@@ -183,31 +180,31 @@ chaining_back_add ( Slapi_PBlock *pb )
return -1;
}
- rc = ldap_result( ld, msgid, 0, &cb->abandon_timeout, &res );
- switch ( rc ) {
- case -1:
- cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string(rc), 0, NULL);
+ rc = ldap_result( ld, msgid, 0, &cb->abandon_timeout, &res );
+ switch ( rc ) {
+ case -1:
+ cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL, ldap_err2string(rc), 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
ldap_mods_free(mods,1);
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
case 0:
if ((rc=cb_ping_farm(cb,cnx,endtime)) != LDAP_SUCCESS) {
+ /*
+ * does not respond. give up and return a
+ * error to the client.
+ */
- /* does not respond. give up and return a*/
- /* error to the client. */
-
- /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
+ /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
ldap_err2string(rc), 0, NULL);*/
- cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL, "FARM SERVER TEMPORARY UNAVAILABLE", 0, NULL);
+ cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL, "FARM SERVER TEMPORARY UNAVAILABLE", 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
ldap_mods_free(mods,1);
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
}
#ifdef CB_YIELD
DS_Sleep(PR_INTERVAL_NO_WAIT);
@@ -219,20 +216,19 @@ chaining_back_add ( Slapi_PBlock *pb )
referrals=NULL;
parse_rc = ldap_parse_result( ld, res, &rc, &matched_msg,
- &error_msg, &referrals, &serverctrls, 1 );
+ &error_msg, &referrals, &serverctrls, 1 );
if ( parse_rc != LDAP_SUCCESS ) {
static int warned_parse_rc = 0;
if (!warned_parse_rc) {
slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- ldap_err2string(parse_rc));
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ ldap_err2string(parse_rc));
warned_parse_rc = 1;
}
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ENDUSERMSG, 0, NULL );
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, ENDUSERMSG, 0, NULL );
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(parse_rc));
ldap_mods_free(mods,1);
slapi_ch_free((void **)&matched_msg);
@@ -250,10 +246,10 @@ chaining_back_add ( Slapi_PBlock *pb )
static int warned_rc = 0;
if (!warned_rc && error_msg) {
slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- error_msg );
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ error_msg );
warned_rc = 1;
}
cb_send_ldap_result( pb, rc, matched_msg, ENDUSERMSG, 0, refs);
@@ -276,22 +272,20 @@ chaining_back_add ( Slapi_PBlock *pb )
/* Add control response sent by the farm server */
for (i=0; serverctrls && serverctrls[i];i++)
- slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
+ slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
if (serverctrls)
- ldap_controls_free(serverctrls);
+ ldap_controls_free(serverctrls);
/* jarnou: free matched_msg, error_msg, and referrals if necessary */
- slapi_ch_free((void **)&matched_msg);
- slapi_ch_free((void **)&error_msg);
- if (referrals)
- charray_free(referrals);
- cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
-
+ slapi_ch_free((void **)&matched_msg);
+ slapi_ch_free((void **)&error_msg);
+ if (referrals)
+ charray_free(referrals);
+ cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
slapi_entry_free(e);
- slapi_pblock_set( pb, SLAPI_ADD_ENTRY, NULL );
+ slapi_pblock_set( pb, SLAPI_ADD_ENTRY, NULL );
return 0;
}
}
-
/* Never reached */
}
diff --git a/ldap/servers/plugins/chainingdb/cb_delete.c b/ldap/servers/plugins/chainingdb/cb_delete.c
index 09972b261..97807ef9c 100644
--- a/ldap/servers/plugins/chainingdb/cb_delete.c
+++ b/ldap/servers/plugins/chainingdb/cb_delete.c
@@ -54,20 +54,19 @@
int
chaining_back_delete ( Slapi_PBlock *pb )
{
-
- Slapi_Backend * be;
- cb_backend_instance *cb;
- LDAPControl **ctrls, **serverctrls;
- int rc,parse_rc,msgid,i;
- LDAP *ld=NULL;
- char **referrals=NULL;
- LDAPMessage * res;
- const char *dn = NULL;
- Slapi_DN *sdn = NULL;
- char *matched_msg, *error_msg;
- char *cnxerrbuf=NULL;
- time_t endtime = 0;
- cb_outgoing_conn *cnx;
+ cb_outgoing_conn *cnx;
+ Slapi_Backend *be;
+ cb_backend_instance *cb;
+ LDAPControl **ctrls, **serverctrls;
+ LDAPMessage *res;
+ LDAP *ld = NULL;
+ Slapi_DN *sdn = NULL;
+ const char *dn = NULL;
+ char **referrals = NULL;
+ char *matched_msg, *error_msg;
+ char *cnxerrbuf = NULL;
+ time_t endtime = 0;
+ int rc, parse_rc, msgid, i;
if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
cb_send_ldap_result( pb, rc, NULL, "Chaining forbidden", 0, NULL );
@@ -94,6 +93,7 @@ chaining_back_delete ( Slapi_PBlock *pb )
if (cb->local_acl && !cb->associated_be_is_disabled) {
char * errbuf=NULL;
Slapi_Entry *te = slapi_entry_alloc();
+
slapi_entry_set_sdn(te, sdn); /* sdn: copied */
rc = cb_access_allowed (pb, te, NULL, NULL, SLAPI_ACL_DELETE,&errbuf);
slapi_entry_free(te);
@@ -127,25 +127,24 @@ chaining_back_delete ( Slapi_PBlock *pb )
}
/*
- * Control management
- */
-
- if ( (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH )) != LDAP_SUCCESS ) {
- cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
- cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- return -1;
- }
+ * Control management
+ */
+ if ( (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH )) != LDAP_SUCCESS ) {
+ cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
+ cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
+ return -1;
+ }
- if ( slapi_op_abandoned( pb )) {
- cb_release_op_connection(cb->pool,ld,0);
- if ( NULL != ctrls)
- ldap_controls_free(ctrls);
- return -1;
- }
+ if ( slapi_op_abandoned( pb )) {
+ cb_release_op_connection(cb->pool,ld,0);
+ if ( NULL != ctrls)
+ ldap_controls_free(ctrls);
+ return -1;
+ }
/* heart-beat management */
if (cb->max_idle_time>0)
- endtime=current_time() + cb->max_idle_time;
+ endtime=current_time() + cb->max_idle_time;
/*
* Send LDAP operation to the remote host
@@ -153,43 +152,39 @@ chaining_back_delete ( Slapi_PBlock *pb )
rc = ldap_delete_ext( ld, dn, ctrls, NULL, &msgid );
if ( NULL != ctrls)
- ldap_controls_free(ctrls);
+ ldap_controls_free(ctrls);
if ( rc != LDAP_SUCCESS ) {
-
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string(rc), 0, NULL);
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
+ ldap_err2string(rc), 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- return -1;
+ return -1;
}
while ( 1 ) {
-
- if (cb_check_forward_abandon(cb,pb,ld,msgid)) {
- return -1;
+ if (cb_check_forward_abandon(cb,pb,ld,msgid)) {
+ return -1;
}
- rc = ldap_result( ld, msgid, 0, &cb->abandon_timeout, &res );
- switch ( rc ) {
- case -1:
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string(rc), 0, NULL);
+ rc = ldap_result( ld, msgid, 0, &cb->abandon_timeout, &res );
+ switch ( rc ) {
+ case -1:
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
+ ldap_err2string(rc), 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
case 0:
if ((rc=cb_ping_farm(cb,cnx,endtime)) != LDAP_SUCCESS) {
+ /* does not respond. give up and return a error to the client. */
- /* does not respond. give up and return a*/
- /* error to the client. */
-
- /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
+ /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
ldap_err2string(rc), 0, NULL);*/
- cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL, "FARM SERVER TEMPORARY UNAVAILABLE", 0, NULL);
+ cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,"FARM SERVER TEMPORARY UNAVAILABLE", 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
}
#ifdef CB_YIELD
DS_Sleep(PR_INTERVAL_NO_WAIT);
@@ -198,15 +193,15 @@ chaining_back_delete ( Slapi_PBlock *pb )
default:
matched_msg=error_msg=NULL;
parse_rc = ldap_parse_result( ld, res, &rc, &matched_msg,
- &error_msg, &referrals, &serverctrls, 1 );
+ &error_msg, &referrals, &serverctrls, 1 );
if ( parse_rc != LDAP_SUCCESS ) {
static int warned_parse_rc = 0;
if (!warned_parse_rc) {
slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- ldap_err2string(parse_rc) );
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ ldap_err2string(parse_rc) );
warned_parse_rc = 1;
}
cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
@@ -227,10 +222,10 @@ chaining_back_delete ( Slapi_PBlock *pb )
static int warned_rc = 0;
if (!warned_rc && error_msg) {
slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- error_msg );
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ error_msg );
warned_rc = 1;
}
cb_send_ldap_result( pb, rc, matched_msg, ENDUSERMSG, 0, refs);
@@ -248,18 +243,18 @@ chaining_back_delete ( Slapi_PBlock *pb )
cb_release_op_connection(cb->pool,ld,0);
- /* Add control response sent by the farm server */
-
- for (i=0; serverctrls && serverctrls[i];i++)
- slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
- if (serverctrls)
- ldap_controls_free(serverctrls);
+ /* Add control response sent by the farm server */
+ for (i=0; serverctrls && serverctrls[i];i++)
+ slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
+ if (serverctrls)
+ ldap_controls_free(serverctrls);
/* jarnou: free matched_msg, error_msg, and referrals if necessary */
- slapi_ch_free((void **)&matched_msg);
- slapi_ch_free((void **)&error_msg);
- if (referrals)
- charray_free(referrals);
- cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
+ slapi_ch_free((void **)&matched_msg);
+ slapi_ch_free((void **)&error_msg);
+ if (referrals)
+ charray_free(referrals);
+ cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
+
return 0;
}
}
diff --git a/ldap/servers/plugins/chainingdb/cb_modify.c b/ldap/servers/plugins/chainingdb/cb_modify.c
index 65acb58f1..12d36da55 100644
--- a/ldap/servers/plugins/chainingdb/cb_modify.c
+++ b/ldap/servers/plugins/chainingdb/cb_modify.c
@@ -56,21 +56,20 @@ static void cb_remove_illegal_mods(cb_backend_instance * inst, LDAPMod **mods);
int
chaining_back_modify ( Slapi_PBlock *pb )
{
-
- Slapi_Backend *be;
- cb_backend_instance *cb;
- LDAPControl **ctrls, **serverctrls;
- int rc,parse_rc,msgid,i;
- LDAP *ld=NULL;
- char **referrals=NULL;
- LDAPMod ** mods;
- LDAPMessage * res;
- const char *dn = NULL;
- Slapi_DN *sdn = NULL;
- char *matched_msg, *error_msg;
- char *cnxerrbuf=NULL;
- time_t endtime = 0;
- cb_outgoing_conn *cnx;
+ cb_outgoing_conn *cnx;
+ Slapi_Backend *be;
+ cb_backend_instance *cb;
+ LDAPControl **ctrls, **serverctrls;
+ LDAPMod ** mods;
+ LDAPMessage *res;
+ LDAP *ld = NULL;
+ Slapi_DN *sdn = NULL;
+ const char *dn = NULL;
+ char **referrals=NULL;
+ char *matched_msg, *error_msg;
+ char *cnxerrbuf=NULL;
+ time_t endtime = 0;
+ int rc, parse_rc, msgid, i;
if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
cb_send_ldap_result( pb, rc, NULL, "Chaining forbidden", 0, NULL );
@@ -79,7 +78,6 @@ chaining_back_modify ( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_BACKEND, &be );
cb = cb_get_instance(be);
-
cb_update_monitor_info(pb,cb,SLAPI_OPERATION_MODIFY);
/* Check wether the chaining BE is available or not */
@@ -94,13 +92,11 @@ chaining_back_modify ( Slapi_PBlock *pb )
slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,"modify: target:<%s>\n",dn);
}
-
- ctrls=serverctrls=NULL;
+ ctrls = serverctrls = NULL;
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
slapi_pblock_get( pb, SLAPI_REQCONTROLS, &ctrls );
/* Check acls */
-
if ( cb->local_acl && !cb->associated_be_is_disabled ) {
char * errbuf=NULL;
Slapi_Entry *te = slapi_entry_alloc();
@@ -126,8 +122,7 @@ chaining_back_modify ( Slapi_PBlock *pb )
rc, ldap_err2string(rc));
warned_get_conn = 1;
}
- cb_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,
- cnxerrbuf, 0, NULL);
+ cb_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, cnxerrbuf, 0, NULL);
slapi_ch_free_string(&cnxerrbuf);
/* ping the farm.
* If the farm is unreachable, we increment the counter */
@@ -136,91 +131,88 @@ chaining_back_modify ( Slapi_PBlock *pb )
}
/* Control management */
- if ( (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH )) != LDAP_SUCCESS ) {
- cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
- cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- /* Don't free mods here: are freed at the do_modify level */
- return -1;
- }
-
- if ( slapi_op_abandoned( pb )) {
- cb_release_op_connection(cb->pool,ld,0);
- /* Don't free mods here: are freed at the do_modify level */
+ if ( (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH )) != LDAP_SUCCESS ) {
+ cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
+ cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
+ /* Don't free mods here: are freed at the do_modify level */
+ return -1;
+ }
+
+ if ( slapi_op_abandoned( pb )) {
+ cb_release_op_connection(cb->pool,ld,0);
+ /* Don't free mods here: are freed at the do_modify level */
if ( NULL != ctrls)
- ldap_controls_free(ctrls);
- return -1;
- }
+ ldap_controls_free(ctrls);
+ return -1;
+ }
/* Remove illegal attributes from the mods */
cb_remove_illegal_mods(cb,mods);
/* heart-beat management */
if (cb->max_idle_time>0)
- endtime=current_time() + cb->max_idle_time;
+ endtime=current_time() + cb->max_idle_time;
/* Send LDAP operation to the remote host */
rc = ldap_modify_ext( ld, dn, mods, ctrls, NULL, &msgid );
if ( NULL != ctrls)
- ldap_controls_free(ctrls);
+ ldap_controls_free(ctrls);
if ( rc != LDAP_SUCCESS ) {
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, ldap_err2string(rc), 0, NULL);
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, ldap_err2string(rc), 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- return -1;
+ return -1;
}
while ( 1 ) {
-
- if (cb_check_forward_abandon(cb,pb,ld,msgid)) {
+ if (cb_check_forward_abandon(cb,pb,ld,msgid)) {
/* connection handle released */
- return -1;
+ return -1;
}
- rc = ldap_result( ld, msgid, 0, &cb->abandon_timeout, &res );
- switch ( rc ) {
- case -1:
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string(rc), 0, NULL);
+ rc = ldap_result( ld, msgid, 0, &cb->abandon_timeout, &res );
+ switch ( rc ) {
+ case -1:
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
+ ldap_err2string(rc), 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
case 0:
if ((rc=cb_ping_farm(cb,cnx,endtime)) != LDAP_SUCCESS) {
+ /* does not respond. give up and return a error to the client. */
- /* does not respond. give up and return a*/
- /* error to the client. */
-
- /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
+ /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
ldap_err2string(rc), 0, NULL);*/
- cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL, "FARM SERVER TEMPORARY UNAVAILABLE", 0, NULL);
+ cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL, "FARM SERVER TEMPORARY UNAVAILABLE", 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
}
#ifdef CB_YIELD
- DS_Sleep(PR_INTERVAL_NO_WAIT);
+ DS_Sleep(PR_INTERVAL_NO_WAIT);
#endif
- break;
- default:
+ break;
+ default:
matched_msg=error_msg=NULL;
serverctrls=NULL;
parse_rc = ldap_parse_result( ld, res, &rc, &matched_msg,
- &error_msg, &referrals, &serverctrls, 1 );
+ &error_msg, &referrals, &serverctrls, 1 );
if ( parse_rc != LDAP_SUCCESS ) {
static int warned_parse_rc = 0;
if (!warned_parse_rc) {
slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- ldap_err2string(parse_rc));
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ ldap_err2string(parse_rc));
warned_parse_rc = 1;
}
cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ENDUSERMSG, 0, NULL );
+ ENDUSERMSG, 0, NULL );
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(parse_rc));
slapi_ch_free((void **)&matched_msg);
slapi_ch_free((void **)&error_msg);
@@ -237,10 +229,10 @@ chaining_back_modify ( Slapi_PBlock *pb )
static int warned_rc = 0;
if (!warned_rc && error_msg) {
slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- error_msg );
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ error_msg );
warned_rc = 1;
}
cb_send_ldap_result( pb, rc, matched_msg, ENDUSERMSG, 0, refs);
@@ -261,20 +253,20 @@ chaining_back_modify ( Slapi_PBlock *pb )
/* Add control response sent by the farm server */
for (i=0; serverctrls && serverctrls[i];i++)
- slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
+ slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
/* SLAPI_ADD_RESCONTROL dups controls */
if (serverctrls)
- ldap_controls_free(serverctrls);
+ ldap_controls_free(serverctrls);
/* jarnou: free matched_msg, error_msg, and referrals if necessary */
- slapi_ch_free((void **)&matched_msg);
- slapi_ch_free((void **)&error_msg);
- if (referrals)
- charray_free(referrals);
- cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
+ slapi_ch_free((void **)&matched_msg);
+ slapi_ch_free((void **)&error_msg);
+ if (referrals)
+ charray_free(referrals);
+ cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
+
return 0;
}
}
-
/* Never reached */
/* return 0; */
}
@@ -283,30 +275,28 @@ chaining_back_modify ( Slapi_PBlock *pb )
static void
cb_remove_illegal_mods(cb_backend_instance *inst, LDAPMod **mods)
{
- int i, j;
- LDAPMod *tmp;
+ int i, j;
+ LDAPMod *tmp;
if ( inst->illegal_attributes != NULL ) { /* Unlikely to happen */
-
- slapi_rwlock_wrlock(inst->rwl_config_lock);
+ slapi_rwlock_wrlock(inst->rwl_config_lock);
for (j=0; inst->illegal_attributes[j]; j++) {
- for ( i = 0; mods && mods[i] != NULL; i++ ) {
+ for ( i = 0; mods && mods[i] != NULL; i++ ) {
if (slapi_attr_types_equivalent(inst->illegal_attributes[j],mods[i]->mod_type)) {
- tmp = mods[i];
- for ( j = i; mods[j] != NULL; j++ ) {
- mods[j] = mods[j + 1];
- }
- slapi_ch_free( (void**)&(tmp->mod_type) );
- if ( tmp->mod_bvalues != NULL ) {
- ber_bvecfree( tmp->mod_bvalues );
- }
- slapi_ch_free( (void**)&tmp );
- i--;
+ tmp = mods[i];
+ for ( j = i; mods[j] != NULL; j++ ) {
+ mods[j] = mods[j + 1];
+ }
+ slapi_ch_free( (void**)&(tmp->mod_type) );
+ if ( tmp->mod_bvalues != NULL ) {
+ ber_bvecfree( tmp->mod_bvalues );
+ }
+ slapi_ch_free( (void**)&tmp );
+ i--;
}
}
}
-
- slapi_rwlock_unlock(inst->rwl_config_lock);
+ slapi_rwlock_unlock(inst->rwl_config_lock);
}
}
diff --git a/ldap/servers/plugins/chainingdb/cb_modrdn.c b/ldap/servers/plugins/chainingdb/cb_modrdn.c
index 1ce6c601d..21903f787 100644
--- a/ldap/servers/plugins/chainingdb/cb_modrdn.c
+++ b/ldap/servers/plugins/chainingdb/cb_modrdn.c
@@ -54,46 +54,47 @@
int
chaining_back_modrdn ( Slapi_PBlock *pb )
{
- Slapi_Backend * be;
- cb_backend_instance *cb;
- LDAPControl **ctrls, **serverctrls;
- int rc,parse_rc,msgid,i;
- LDAP *ld=NULL;
- char **referrals=NULL;
- LDAPMessage *res;
- char *matched_msg, *error_msg;
- char *ndn = NULL;
- Slapi_DN *sdn = NULL;
- int deleteoldrdn = 0;
- Slapi_DN *newsuperior = NULL;
- char *newrdn = NULL;
- char * cnxerrbuf=NULL;
- time_t endtime = 0;
- cb_outgoing_conn *cnx;
-
- if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
- cb_send_ldap_result( pb, rc, NULL, "Chaining forbidden", 0, NULL );
- return -1;
- }
+ cb_outgoing_conn *cnx;
+ Slapi_Backend *be;
+ cb_backend_instance *cb;
+ LDAPControl **ctrls, **serverctrls;
+ LDAPMessage *res;
+ LDAP *ld = NULL;
+ Slapi_DN *newsuperior = NULL;
+ Slapi_DN *sdn = NULL;
+ char **referrals = NULL;
+ char *matched_msg, *error_msg;
+ char *ndn = NULL;
+ char *newrdn = NULL;
+ char *cnxerrbuf = NULL;
+ time_t endtime = 0;
+ int deleteoldrdn = 0;
+ int rc, parse_rc, msgid, i;
+
+
+ if ( LDAP_SUCCESS != (rc=cb_forward_operation(pb) )) {
+ cb_send_ldap_result( pb, rc, NULL, "Chaining forbidden", 0, NULL );
+ return -1;
+ }
- slapi_pblock_get( pb, SLAPI_BACKEND, &be );
- cb = cb_get_instance(be);
+ slapi_pblock_get( pb, SLAPI_BACKEND, &be );
+ cb = cb_get_instance(be);
- cb_update_monitor_info(pb,cb,SLAPI_OPERATION_MODRDN);
+ cb_update_monitor_info(pb,cb,SLAPI_OPERATION_MODRDN);
- /* Check wether the chaining BE is available or not */
- if ( cb_check_availability( cb, pb ) == FARMSERVER_UNAVAILABLE ){
- return -1;
- }
+ /* Check wether the chaining BE is available or not */
+ if ( cb_check_availability( cb, pb ) == FARMSERVER_UNAVAILABLE ){
+ return -1;
+ }
- slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &sdn );
- /* newrdn is passed to ldap_rename, which does not require case-ignored
- * newrdn. */
- slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn );
- slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior );
- slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, &deleteoldrdn );
+ slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &sdn );
+ /* newrdn is passed to ldap_rename, which does not require case-ignored
+ * newrdn. */
+ slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn );
+ slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior );
+ slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, &deleteoldrdn );
- ndn = (char *)slapi_sdn_get_ndn(sdn);
+ ndn = (char *)slapi_sdn_get_ndn(sdn);
if (cb->local_acl && !cb->associated_be_is_disabled) {
/*
* Check local acls
@@ -111,7 +112,7 @@ chaining_back_modrdn ( Slapi_PBlock *pb )
slapi_ch_free((void **)&errbuf);
return -1;
}
- }
+ }
/*
* Grab a connection handle
@@ -135,80 +136,77 @@ chaining_back_modrdn ( Slapi_PBlock *pb )
}
/*
- * Control management
- */
-
- if ( (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH )) != LDAP_SUCCESS ) {
- cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
- cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- return -1;
- }
+ * Control management
+ */
+ if ( (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH )) != LDAP_SUCCESS ) {
+ cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
+ cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
+ return -1;
+ }
- if ( slapi_op_abandoned( pb )) {
- cb_release_op_connection(cb->pool,ld,0);
- if ( NULL != ctrls)
- ldap_controls_free(ctrls);
- return -1;
- }
+ if ( slapi_op_abandoned( pb )) {
+ cb_release_op_connection(cb->pool,ld,0);
+ if ( NULL != ctrls)
+ ldap_controls_free(ctrls);
+ return -1;
+ }
/* heart-beat management */
if (cb->max_idle_time>0)
- endtime=current_time() + cb->max_idle_time;
+ endtime=current_time() + cb->max_idle_time;
/*
* Send LDAP operation to the remote host
*/
-
rc = ldap_rename ( ld, ndn, newrdn, slapi_sdn_get_dn(newsuperior),
deleteoldrdn, ctrls, NULL, &msgid );
if ( NULL != ctrls)
- ldap_controls_free(ctrls);
+ ldap_controls_free(ctrls);
if ( rc != LDAP_SUCCESS ) {
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string(rc), 0, NULL);
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
+ ldap_err2string(rc), 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- return -1;
+ return -1;
}
while ( 1 ) {
-
- if (cb_check_forward_abandon(cb,pb,ld,msgid)) {
- return -1;
+ if (cb_check_forward_abandon(cb,pb,ld,msgid)) {
+ return -1;
}
rc = ldap_result( ld, msgid, 0, &cb->abandon_timeout, &res );
switch ( rc ) {
case -1:
- cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string(rc), 0, NULL);
+ cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL,
+ ldap_err2string(rc), 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
+
case 0:
if ((rc=cb_ping_farm(cb,cnx,endtime)) != LDAP_SUCCESS) {
+ /* does not respond. give up and return a error to the client. */
- /* does not respond. give up and return a*/
- /* error to the client. */
-
- /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
+ /*cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
ldap_err2string(rc), 0, NULL);*/
cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL, "FARM SERVER TEMPORARY UNAVAILABLE", 0, NULL);
cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
if (res)
ldap_msgfree(res);
- return -1;
+ return -1;
}
#ifdef CB_YIELD
- DS_Sleep(PR_INTERVAL_NO_WAIT);
+ DS_Sleep(PR_INTERVAL_NO_WAIT);
#endif
break;
+
default:
matched_msg=error_msg=NULL;
parse_rc = ldap_parse_result( ld, res, &rc, &matched_msg,
- &error_msg, &referrals, &serverctrls, 1 );
+ &error_msg, &referrals, &serverctrls, 1 );
if ( parse_rc != LDAP_SUCCESS ) {
static int warned_parse_rc = 0;
@@ -259,18 +257,18 @@ chaining_back_modrdn ( Slapi_PBlock *pb )
cb_release_op_connection(cb->pool,ld,0);
- /* Add control response sent by the farm server */
-
- for (i=0; serverctrls && serverctrls[i];i++)
- slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
- if (serverctrls)
- ldap_controls_free(serverctrls);
+ /* Add control response sent by the farm server */
+ for (i=0; serverctrls && serverctrls[i]; i++)
+ slapi_pblock_set( pb, SLAPI_ADD_RESCONTROL, serverctrls[i]);
+ if (serverctrls)
+ ldap_controls_free(serverctrls);
/* jarnou: free matched_msg, error_msg, and referrals if necessary */
- slapi_ch_free((void **)&matched_msg);
- slapi_ch_free((void **)&error_msg);
- if (referrals)
- charray_free(referrals);
- cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
+ slapi_ch_free((void **)&matched_msg);
+ slapi_ch_free((void **)&error_msg);
+ if (referrals)
+ charray_free(referrals);
+ cb_send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
+
return 0;
}
}
diff --git a/ldap/servers/plugins/chainingdb/cb_search.c b/ldap/servers/plugins/chainingdb/cb_search.c
index a27e7673f..faca2e32f 100644
--- a/ldap/servers/plugins/chainingdb/cb_search.c
+++ b/ldap/servers/plugins/chainingdb/cb_search.c
@@ -54,31 +54,30 @@
int
chainingdb_build_candidate_list ( Slapi_PBlock *pb )
-{
-
- Slapi_Backend * be;
- Slapi_Operation * op;
- char *filter;
- const char *target = NULL;
- Slapi_DN *target_sdn = NULL;
- int scope,attrsonly,sizelimit,timelimit,rc,searchreferral;
- char **attrs=NULL;
- LDAPControl **controls=NULL;
- LDAPControl **ctrls=NULL;
- LDAP *ld=NULL;
- cb_backend_instance *cb = NULL;
- cb_searchContext *ctx=NULL;
- struct timeval timeout;
- time_t optime;
- int doit,parse_rc;
- LDAPMessage *res=NULL;
- char *matched_msg,*error_msg;
- LDAPControl **serverctrls=NULL;
- char **referrals=NULL;
- char *cnxerrbuf=NULL;
- time_t endbefore=0;
- time_t endtime = 0;
- cb_outgoing_conn *cnx;
+{
+ cb_backend_instance *cb = NULL;
+ cb_outgoing_conn *cnx;
+ cb_searchContext *ctx = NULL;
+ Slapi_Backend *be;
+ Slapi_Operation *op;
+ LDAPControl **serverctrls = NULL;
+ LDAPControl **controls = NULL;
+ LDAPControl **ctrls = NULL;
+ LDAPMessage *res = NULL;
+ LDAP *ld = NULL;
+ Slapi_DN *target_sdn = NULL;
+ const char *target = NULL;
+ char *filter;
+ char **attrs = NULL;
+ struct timeval timeout;
+ time_t optime;
+ time_t endbefore = 0;
+ time_t endtime = 0;
+ char *matched_msg, *error_msg;
+ char **referrals = NULL;
+ char *cnxerrbuf = NULL;
+ int scope, attrsonly, sizelimit, timelimit, searchreferral;
+ int rc, parse_rc, doit;
slapi_pblock_get( pb, SLAPI_BACKEND, &be );
cb = cb_get_instance(be);
@@ -92,53 +91,50 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
target = slapi_sdn_get_dn(target_sdn);
if ( LDAP_SUCCESS != (parse_rc=cb_forward_operation(pb) )) {
-
/* Don't return errors */
-
if (cb_debug_on()) {
slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
"local search: base:<%s> scope:<%s> filter:<%s>\n",target,
scope==LDAP_SCOPE_SUBTREE?"SUBTREE":scope==LDAP_SCOPE_ONELEVEL ? "ONE-LEVEL" : "BASE" , filter);
}
- ctx = (cb_searchContext *)slapi_ch_calloc(1,sizeof(cb_searchContext));
- ctx->type = CB_SEARCHCONTEXT_ENTRY;
- ctx->data=NULL;
-
- slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,ctx);
- return 0;
- }
+ ctx = (cb_searchContext *)slapi_ch_calloc(1,sizeof(cb_searchContext));
+ ctx->type = CB_SEARCHCONTEXT_ENTRY;
+ ctx->data=NULL;
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,ctx);
+
+ return 0;
+ }
- cb_update_monitor_info(pb,cb,SLAPI_OPERATION_SEARCH);
+ cb_update_monitor_info(pb,cb,SLAPI_OPERATION_SEARCH);
/* Check wether the chaining BE is available or not */
- if ( cb_check_availability( cb, pb ) == FARMSERVER_UNAVAILABLE ){
- return -1;
- }
+ if ( cb_check_availability( cb, pb ) == FARMSERVER_UNAVAILABLE ){
+ return -1;
+ }
if (cb_debug_on()) {
- slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
- "chained search: base:<%s> scope:<%s> filter:<%s>\n",target,
- scope==LDAP_SCOPE_SUBTREE?"SUBTREE":scope==LDAP_SCOPE_ONELEVEL ? "ONE-LEVEL" : "BASE" , filter);
+ slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
+ "chained search: base:<%s> scope:<%s> filter:<%s>\n",target,
+ scope==LDAP_SCOPE_SUBTREE ? "SUBTREE": scope==LDAP_SCOPE_ONELEVEL ? "ONE-LEVEL" : "BASE",
+ filter);
}
- slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, &attrs );
- slapi_pblock_get( pb, SLAPI_SEARCH_ATTRSONLY, &attrsonly );
- slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
- slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &timelimit );
- slapi_pblock_get( pb, SLAPI_SEARCH_SIZELIMIT, &sizelimit );
- slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,NULL);
-
+ slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, &attrs );
+ slapi_pblock_get( pb, SLAPI_SEARCH_ATTRSONLY, &attrsonly );
+ slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
+ slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &timelimit );
+ slapi_pblock_get( pb, SLAPI_SEARCH_SIZELIMIT, &sizelimit );
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,NULL);
if ((scope != LDAP_SCOPE_BASE) && (scope != LDAP_SCOPE_ONELEVEL) && (scope != LDAP_SCOPE_SUBTREE)) {
- cb_send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL, "Bad scope", 0, NULL );
+ cb_send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL, "Bad scope", 0, NULL );
return 1;
}
searchreferral=cb->searchreferral;
if (( scope != LDAP_SCOPE_BASE ) && ( searchreferral )) {
-
int i;
struct berval bv,*bvals[2];
Slapi_Entry ** aciArray=(Slapi_Entry **) slapi_ch_malloc(2*sizeof(Slapi_Entry *));
@@ -168,9 +164,8 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
ctx = (cb_searchContext *)slapi_ch_calloc(1,sizeof(cb_searchContext));
ctx->type = CB_SEARCHCONTEXT_ENTRY;
ctx->data=aciArray;
-
- slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,ctx);
- return 0;
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,ctx);
+ return 0;
}
/*
@@ -184,9 +179,9 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
time_t now=current_time();
endbefore=optime + timelimit;
if (now >= endbefore) {
- cb_send_ldap_result( pb, LDAP_TIMELIMIT_EXCEEDED, NULL,NULL, 0, NULL);
- slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, NULL );
- return 1;
+ cb_send_ldap_result( pb, LDAP_TIMELIMIT_EXCEEDED, NULL,NULL, 0, NULL);
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, NULL );
+ return 1;
}
timeout.tv_sec=(time_t)timelimit-(now-optime);
timeout.tv_usec=0;
@@ -200,20 +195,15 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
if ( (attrs == NULL) && operation_is_flag_set(op, OP_FLAG_INTERNAL) ) {
attrs = cb->every_attribute;
-
- }
- else
- {
+ } else {
int i;
- if ( attrs != NULL )
- {
+ if ( attrs != NULL ) {
for ( i = 0; attrs[i] != NULL; i++ ) {
- if ( strcasecmp( "nsrole", attrs[i] ) == 0 )
- {
+ if ( strcasecmp( "nsrole", attrs[i] ) == 0 ){
attrs = cb->every_attribute;
break;
}
- }
+ }
}
}
@@ -245,19 +235,19 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
*/
if ( LDAP_SUCCESS != (rc = cb_update_controls( pb,ld,&ctrls,CB_UPDATE_CONTROLS_ADDAUTH ))) {
- cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
- cb_release_op_connection(cb->pool,ld,0);
- return 1;
- }
-
- if ( slapi_op_abandoned( pb )) {
- cb_release_op_connection(cb->pool,ld,0);
- if ( NULL != ctrls)
- ldap_controls_free(ctrls);
- return 1;
+ cb_send_ldap_result( pb, rc, NULL,NULL, 0, NULL);
+ cb_release_op_connection(cb->pool,ld,0);
+ return 1;
+ }
+
+ if ( slapi_op_abandoned( pb )) {
+ cb_release_op_connection(cb->pool,ld,0);
+ if ( NULL != ctrls)
+ ldap_controls_free(ctrls);
+ return 1;
}
- ctx = (cb_searchContext *) slapi_ch_calloc(1,sizeof(cb_searchContext));
+ ctx = (cb_searchContext *) slapi_ch_calloc(1,sizeof(cb_searchContext));
/*
** We need to store the connection handle in the search context
@@ -276,14 +266,14 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
timeout.tv_sec=timeout.tv_usec=-1;
/* heart-beat management */
- if (cb->max_idle_time>0)
- endtime=current_time() + cb->max_idle_time;
+ if (cb->max_idle_time>0)
+ endtime=current_time() + cb->max_idle_time;
- rc=ldap_search_ext(ld ,target,scope,filter,attrs,attrsonly,
- ctrls, NULL, &timeout,sizelimit, &(ctx->msgid) );
+ rc = ldap_search_ext(ld ,target,scope,filter,attrs,attrsonly,
+ ctrls, NULL, &timeout,sizelimit, &(ctx->msgid) );
- if ( NULL != ctrls)
- ldap_controls_free(ctrls);
+ if ( NULL != ctrls)
+ ldap_controls_free(ctrls);
if ( LDAP_SUCCESS != rc ) {
cb_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, ldap_err2string(rc), 0, NULL);
@@ -299,136 +289,131 @@ chainingdb_build_candidate_list ( Slapi_PBlock *pb )
doit=1;
while (doit) {
+ if (cb_check_forward_abandon(cb,pb,ctx->ld,ctx->msgid)) {
+ slapi_ch_free((void **) &ctx);
+ return 1;
+ }
- if (cb_check_forward_abandon(cb,pb,ctx->ld,ctx->msgid)) {
- slapi_ch_free((void **) &ctx);
- return 1;
- }
+ rc = ldap_result(ld,ctx->msgid,LDAP_MSG_ONE,&cb->abandon_timeout,&res);
+ switch ( rc ) {
+ case -1:
+ /* An error occurred. return now */
+ rc = slapi_ldap_get_lderrno(ld,NULL,NULL);
+ /* tuck away some errors in a OPERATION_ERROR */
+ if (CB_LDAP_CONN_ERROR(rc)) {
+ cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
+ ldap_err2string( rc ), 0, NULL);
+ } else {
+ cb_send_ldap_result(pb,rc, NULL, NULL,0,NULL);
+ }
+ cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
+ if (res)
+ ldap_msgfree(res);
+ slapi_ch_free((void **)&ctx);
+ return 1;
- rc=ldap_result(ld,ctx->msgid,LDAP_MSG_ONE,&cb->abandon_timeout,&res);
- switch ( rc ) {
- case -1:
- /* An error occurred. return now */
- rc = slapi_ldap_get_lderrno(ld,NULL,NULL);
- /* tuck away some errors in a OPERATION_ERROR */
- if (CB_LDAP_CONN_ERROR(rc)) {
- cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string( rc ), 0, NULL);
- } else {
- cb_send_ldap_result(pb,rc, NULL, NULL,0,NULL);
- }
- cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- if (res)
- ldap_msgfree(res);
- slapi_ch_free((void **)&ctx);
- return 1;
- case 0:
-
- /* Local timeout management */
- if (timelimit != -1) {
- if (current_time() > endbefore) {
-
- slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
- "Local timeout expiration\n");
-
- cb_send_ldap_result(pb,LDAP_TIMELIMIT_EXCEEDED,
- NULL,NULL, 0, NULL);
- /* Force connection close */
- cb_release_op_connection(cb->pool,ld,1);
- if (res)
- ldap_msgfree(res);
- slapi_ch_free((void **)&ctx);
- return 1;
- }
- }
- /* heart-beat management */
- if ((rc=cb_ping_farm(cb,cnx,endtime)) != LDAP_SUCCESS) {
- cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
- ldap_err2string(rc), 0, NULL);
- cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
- if (res)
- ldap_msgfree(res);
- slapi_ch_free((void **)&ctx);
- return 1;
+ case 0:
+ /* Local timeout management */
+ if (timelimit != -1) {
+ if (current_time() > endbefore) {
+ slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
+ "Local timeout expiration\n");
+ cb_send_ldap_result(pb,LDAP_TIMELIMIT_EXCEEDED,
+ NULL,NULL, 0, NULL);
+ /* Force connection close */
+ cb_release_op_connection(cb->pool,ld,1);
+ if (res)
+ ldap_msgfree(res);
+ slapi_ch_free((void **)&ctx);
+ return 1;
}
+ }
+ /* heart-beat management */
+ if ((rc=cb_ping_farm(cb,cnx,endtime)) != LDAP_SUCCESS) {
+ cb_send_ldap_result(pb,LDAP_OPERATIONS_ERROR, NULL,
+ ldap_err2string(rc), 0, NULL);
+ cb_release_op_connection(cb->pool,ld,CB_LDAP_CONN_ERROR(rc));
+ if (res)
+ ldap_msgfree(res);
+ slapi_ch_free((void **)&ctx);
+ return 1;
+ }
#ifdef CB_YIELD
- DS_Sleep(PR_INTERVAL_NO_WAIT);
+ DS_Sleep(PR_INTERVAL_NO_WAIT);
#endif
- break;
- case LDAP_RES_SEARCH_ENTRY:
- case LDAP_RES_SEARCH_REFERENCE:
- /* Some results received */
- /* don't parse result here */
- ctx->pending_result=res;
- ctx->pending_result_type=rc;
- doit=0;
- break;
- case LDAP_RES_SEARCH_RESULT:
+ break;
+
+ case LDAP_RES_SEARCH_ENTRY:
+ case LDAP_RES_SEARCH_REFERENCE:
+ /* Some results received */
+ /* don't parse result here */
+ ctx->pending_result=res;
+ ctx->pending_result_type=rc;
+ doit = 0;
+ break;
+
+ case LDAP_RES_SEARCH_RESULT:
+ matched_msg=NULL;
+ error_msg=NULL;
+ referrals=NULL;
+ serverctrls=NULL;
+ parse_rc=ldap_parse_result(ld,res,&rc,&matched_msg,
+ &error_msg,&referrals, &serverctrls, 0 );
+ if ( parse_rc != LDAP_SUCCESS ) {
+ static int warned_parse_rc = 0;
+ if (!warned_parse_rc && error_msg) {
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ error_msg );
+ warned_parse_rc = 1;
+ }
+ cb_send_ldap_result( pb, parse_rc, NULL, ENDUSERMSG, 0, NULL );
+ rc=-1;
+ } else if ( rc != LDAP_SUCCESS ) {
+ static int warned_rc = 0;
+ if (!warned_rc) {
+ slapi_ldap_get_lderrno( ctx->ld, &matched_msg, &error_msg );
+ slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
+ "%s%s%s\n",
+ matched_msg?matched_msg:"",
+ (matched_msg&&(*matched_msg!='\0'))?": ":"",
+ error_msg );
+ warned_rc = 1;
+ }
+ cb_send_ldap_result( pb, rc, NULL, ENDUSERMSG, 0, NULL);
+ /* BEWARE: matched_msg and error_msg points */
+ /* to ld fields. */
matched_msg=NULL;
error_msg=NULL;
- referrals=NULL;
- serverctrls=NULL;
- parse_rc=ldap_parse_result(ld,res,&rc,&matched_msg,
- &error_msg,&referrals, &serverctrls, 0 );
- if ( parse_rc != LDAP_SUCCESS ) {
- static int warned_parse_rc = 0;
- if (!warned_parse_rc && error_msg) {
- slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- error_msg );
- warned_parse_rc = 1;
- }
- cb_send_ldap_result( pb, parse_rc, NULL,
- ENDUSERMSG, 0, NULL );
- rc=-1;
- } else if ( rc != LDAP_SUCCESS ) {
- static int warned_rc = 0;
- if (!warned_rc) {
- slapi_ldap_get_lderrno( ctx->ld,
- &matched_msg, &error_msg );
- slapi_log_error( SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "%s%s%s\n",
- matched_msg?matched_msg:"",
- (matched_msg&&(*matched_msg!='\0'))?": ":"",
- error_msg );
- warned_rc = 1;
- }
- cb_send_ldap_result( pb, rc, NULL, ENDUSERMSG, 0, NULL);
- /* BEWARE: matched_msg and error_msg points */
- /* to ld fields. */
- matched_msg=NULL;
- error_msg=NULL;
- rc=-1;
- }
+ rc = -1;
+ }
+
+ slapi_ch_free((void **)&matched_msg);
+ slapi_ch_free((void **)&error_msg);
+ if (serverctrls)
+ ldap_controls_free(serverctrls);
+ if (referrals)
+ charray_free(referrals);
+ if (rc != LDAP_SUCCESS) {
+ cb_release_op_connection(cb->pool,ld,
+ CB_LDAP_CONN_ERROR(rc));
+ ldap_msgfree(res);
+ slapi_ch_free((void **)&ctx);
+ return -1;
+ }
- slapi_ch_free((void **)&matched_msg);
- slapi_ch_free((void **)&error_msg);
- if (serverctrls)
- ldap_controls_free(serverctrls);
- if (referrals)
- charray_free(referrals);
-
- if (rc!=LDAP_SUCCESS) {
- cb_release_op_connection(cb->pool,ld,
- CB_LDAP_CONN_ERROR(rc));
- ldap_msgfree(res);
- slapi_ch_free((void **)&ctx);
- return -1;
- }
-
- /* Store the msg in the ctx */
- /* Parsed in iterate. */
-
- ctx->pending_result=res;
- ctx->pending_result_type=LDAP_RES_SEARCH_RESULT;
- doit=0;
+ /* Store the msg in the ctx */
+ /* Parsed in iterate. */
+ ctx->pending_result = res;
+ ctx->pending_result_type = LDAP_RES_SEARCH_RESULT;
+ doit = 0;
}
}
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,ctx);
- slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET,ctx);
return 0;
}
| 0 |
33db32a3e14b849d2be82d2562be0d6fc18fb96e
|
389ds/389-ds-base
|
Ticket 49336 - SECURITY: Locked account provides different return code
Bug Description: The directory server password lockout policy prevents binds
from operating once a threshold of failed passwords has been met. During
this lockout, if you bind with a successful password, a different error code
is returned. This means that an attacker has no ratelimit or penalty during
an account lock, and can continue to attempt passwords via bruteforce, using
the change in return code to ascertain a sucessful password auth.
Fix Description: Move the account lock check *before* the password bind
check. If the account is locked, we do not mind disclosing this as the
attacker will either ignore it (and will not bind anyway), or they will
be forced to back off as the attack is not working preventing the
bruteforce.
https://pagure.io/389-ds-base/issue/49336
Author: wibrown
Review by: tbordaz (Thanks!)
|
commit 33db32a3e14b849d2be82d2562be0d6fc18fb96e
Author: William Brown <[email protected]>
Date: Mon Jul 31 14:13:49 2017 +1000
Ticket 49336 - SECURITY: Locked account provides different return code
Bug Description: The directory server password lockout policy prevents binds
from operating once a threshold of failed passwords has been met. During
this lockout, if you bind with a successful password, a different error code
is returned. This means that an attacker has no ratelimit or penalty during
an account lock, and can continue to attempt passwords via bruteforce, using
the change in return code to ascertain a sucessful password auth.
Fix Description: Move the account lock check *before* the password bind
check. If the account is locked, we do not mind disclosing this as the
attacker will either ignore it (and will not bind anyway), or they will
be forced to back off as the attack is not working preventing the
bruteforce.
https://pagure.io/389-ds-base/issue/49336
Author: wibrown
Review by: tbordaz (Thanks!)
diff --git a/dirsrvtests/tests/suites/password/pwd_lockout_bypass_test.py b/dirsrvtests/tests/suites/password/pwd_lockout_bypass_test.py
new file mode 100644
index 000000000..e4add728e
--- /dev/null
+++ b/dirsrvtests/tests/suites/password/pwd_lockout_bypass_test.py
@@ -0,0 +1,55 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import pytest
+from lib389.tasks import *
+from lib389.utils import *
+from lib389.topologies import topology_st
+from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES
+import ldap
+
+# The irony of these names is not lost on me.
+GOOD_PASSWORD = 'password'
+BAD_PASSWORD = 'aontseunao'
+
+logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+def test_lockout_bypass(topology_st):
+ inst = topology_st.standalone
+
+ # Configure the lock policy
+ inst.config.set('passwordMaxFailure', '1')
+ inst.config.set('passwordLockoutDuration', '99999')
+ inst.config.set('passwordLockout', 'on')
+
+ # Create the account
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+ testuser = users.create(properties=TEST_USER_PROPERTIES)
+ testuser.set('userPassword', GOOD_PASSWORD)
+
+ conn = testuser.bind(GOOD_PASSWORD)
+ assert conn != None
+ conn.unbind_s()
+
+ # Bind with bad creds twice
+ # This is the failure.
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ conn = testuser.bind(BAD_PASSWORD)
+ # Now we should not be able to ATTEMPT the bind. It doesn't matter that
+ # we disclose that we have hit the rate limit here, what matters is that
+ # it exists.
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ conn = testuser.bind(BAD_PASSWORD)
+
+ # now bind with good creds
+ # Should be error 19 still.
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ conn = testuser.bind(GOOD_PASSWORD)
+
+
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index c37dec1d7..91f721134 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -656,12 +656,14 @@ do_bind(Slapi_PBlock *pb)
/* We could be serving multiple database backends. Select the appropriate one */
/* pw_verify_be_dn will select the backend we need for us. */
- if (auto_bind) {
- /* We have no password material. We should just check who we are binding as. */
- rc = pw_validate_be_dn(pb, &referral);
- } else {
- rc = pw_verify_be_dn(pb, &referral);
- }
+ /*
+ * WARNING: We have to validate *all* other conditions *first* before
+ * we attempt the bind!
+ *
+ * this is because ldbm_bind.c will SEND THE FAILURE.
+ */
+
+ rc = pw_validate_be_dn(pb, &referral);
if (rc == SLAPI_BIND_NO_BACKEND) {
send_nobackend_ldap_result(pb);
@@ -730,6 +732,16 @@ do_bind(Slapi_PBlock *pb)
myrc = 0;
}
if (!auto_bind) {
+ /*
+ * Okay, we've made it here. FINALLY check if the entry really
+ * can bind or not. THIS IS THE PASSWORD CHECK.
+ */
+ rc = pw_verify_be_dn(pb, &referral);
+ if (rc != SLAPI_BIND_SUCCESS) {
+ /* Invalid pass - lets bail ... */
+ goto bind_failed;
+ }
+
/*
* There could be a race that bind_target_entry was not added
* when bind_target_entry was retrieved before be_bind, but it
@@ -780,6 +792,7 @@ do_bind(Slapi_PBlock *pb)
}
}
} else { /* if auto_bind || rc == slapi_bind_success | slapi_bind_anonymous */
+ bind_failed:
if (rc == LDAP_OPERATIONS_ERROR) {
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL, "Function not implemented", 0, NULL);
goto free_and_return;
diff --git a/ldap/servers/slapd/pw_verify.c b/ldap/servers/slapd/pw_verify.c
index d24fdaa21..ab0355a40 100644
--- a/ldap/servers/slapd/pw_verify.c
+++ b/ldap/servers/slapd/pw_verify.c
@@ -55,7 +55,7 @@ pw_verify_root_dn(const char *dn, const Slapi_Value *cred)
int
pw_verify_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral)
{
- int rc = 0;
+ int rc = SLAPI_BIND_SUCCESS;
Slapi_Backend *be = NULL;
if (slapi_mapping_tree_select(pb, &be, referral, NULL, 0) != LDAP_SUCCESS) {
@@ -109,14 +109,10 @@ pw_validate_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral)
slapi_pblock_get(pb, SLAPI_BIND_CREDENTIALS, &cred);
slapi_pblock_get(pb, SLAPI_BIND_METHOD, &method);
- if (pb_sdn != NULL || cred != NULL) {
+ if (pb_sdn == NULL) {
return LDAP_OPERATIONS_ERROR;
}
- if (*referral) {
- return SLAPI_BIND_REFERRAL;
- }
-
/* We need a slapi_sdn_isanon? */
if (method == LDAP_AUTH_SIMPLE && (cred == NULL || cred->bv_len == 0)) {
return SLAPI_BIND_ANONYMOUS;
@@ -130,7 +126,11 @@ pw_validate_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral)
if (slapi_mapping_tree_select(pb, &be, referral, NULL, 0) != LDAP_SUCCESS) {
return SLAPI_BIND_NO_BACKEND;
}
- slapi_be_Unlock(be);
+
+ if (*referral) {
+ slapi_be_Unlock(be);
+ return SLAPI_BIND_REFERRAL;
+ }
slapi_pblock_set(pb, SLAPI_BACKEND, be);
slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);
@@ -138,6 +138,7 @@ pw_validate_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral)
set_db_default_result_handlers(pb);
/* The backend associated with this identity is real. */
+ slapi_be_Unlock(be);
return SLAPI_BIND_SUCCESS;
}
| 0 |
718dcd9473b5a4e58e06b82a503c82a60f3d085e
|
389ds/389-ds-base
|
Issue 2893 - CLI - dscreate - add options for setting up replication
Description:
Add options for setting up replication to dscreate
relates: https://github.com/389ds/389-ds-base/issues/2893
Reviewed by: firstyear & spichugi(Thanks!!)
|
commit 718dcd9473b5a4e58e06b82a503c82a60f3d085e
Author: Mark Reynolds <[email protected]>
Date: Mon Apr 18 16:07:46 2022 -0400
Issue 2893 - CLI - dscreate - add options for setting up replication
Description:
Add options for setting up replication to dscreate
relates: https://github.com/389ds/389-ds-base/issues/2893
Reviewed by: firstyear & spichugi(Thanks!!)
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py
index 05e4f675b..da5cc8e30 100644
--- a/dirsrvtests/tests/suites/basic/basic_test.py
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
@@ -16,7 +16,7 @@ from lib389.utils import *
from lib389.topologies import topology_st
from lib389.dbgen import dbgen_users
from lib389.idm.organizationalunit import OrganizationalUnits
-from lib389._constants import DN_DM, PASSWORD, PW_DM
+from lib389._constants import DN_DM, PASSWORD, PW_DM, ReplicaRole
from lib389.paths import Paths
from lib389.idm.directorymanager import DirectoryManager
from lib389.config import LDBMConfig
@@ -24,6 +24,7 @@ from lib389.dseldif import DSEldif
from lib389.rootdse import RootDSE
from ....conftest import get_rpm_version
from lib389._mapped_object import DSLdapObjects
+from lib389.replica import Replicas, Changelog
pytestmark = pytest.mark.tier0
@@ -1466,12 +1467,8 @@ def test_ldbm_modification_audit_log(topology_st):
assert conn.searchAuditLog('replace: %s' % attr)
assert conn.searchAuditLog('%s: %s' % (attr, VALUE))
-
[email protected](not get_user_is_root() or ds_is_older('1.4.0.0'),
- reason="This test is only required if perl is enabled, and requires root.")
def test_dscreate(request):
- """Test that dscreate works, we need this for now until setup-ds.pl is
- fully discontinued.
+ """Test that dscreate works
:id: 5bf75c47-a283-430e-a65c-3c5fd8dbadb9
:setup: None
@@ -1536,6 +1533,133 @@ sample_entries = yes
request.addfinalizer(fin)
+def test_dscreate_with_replication(request):
+ """Test dscreate works with replication shortcuts
+
+ :id: 8391ffc4-5158-4141-9312-0f47ae56f1ed
+ :setup: Standalone Instance
+ :steps:
+ 1. Create instance and prepare DirSrv object
+ 2. Check replication is enabled
+ 3. Check repl role
+ 4. Check rid
+ 5. Check bind dn
+ 6. Changelog trimming settings
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ """
+ template_file = "/tmp/dssetup.inf"
+ template_text = """[general]
+config_version = 2
+# This invalid hostname ...
+full_machine_name = localhost.localdomain
+# Means we absolutely require this.
+strict_host_checking = False
+# In tests, we can be run in containers, NEVER trust
+# that systemd is there, or functional in any capacity
+systemd = False
+
+[slapd]
+instance_name = dscreate_repl
+root_dn = cn=directory manager
+root_password = someLongPassword_123
+# We do not have access to high ports in containers,
+# so default to something higher.
+port = 38999
+secure_port = 63699
+
+[backend-userroot]
+suffix = dc=example,dc=com
+sample_entries = yes
+enable_replication = True
+replica_binddn = cn=replication manager,cn=config
+replica_bindpw = password
+replica_id = 111
+replica_role = supplier
+changelog_max_age = 8d
+changelog_max_entries = 200000
+"""
+
+ with open(template_file, "w") as template_fd:
+ template_fd.write(template_text)
+
+ # Unset PYTHONPATH to avoid mixing old CLI tools and new lib389
+ tmp_env = os.environ
+ if "PYTHONPATH" in tmp_env:
+ del tmp_env["PYTHONPATH"]
+ try:
+ subprocess.check_call([
+ 'dscreate',
+ 'from-file',
+ template_file
+ ], env=tmp_env)
+ except subprocess.CalledProcessError as e:
+ log.fatal("dscreate failed! Error ({}) {}".format(e.returncode, e.output))
+ assert False
+
+ def fin():
+ os.remove(template_file)
+ try:
+ subprocess.check_call(['dsctl', 'dscreate_repl', 'remove', '--do-it'])
+ except subprocess.CalledProcessError as e:
+ log.fatal("Failed to remove test instance Error ({}) {}".format(e.returncode, e.output))
+
+ request.addfinalizer(fin)
+
+ # Prepare Dirsrv instance
+ from lib389 import DirSrv
+ container_result = subprocess.run(["systemd-detect-virt", "-c"], stdout=subprocess.PIPE)
+ if container_result.returncode == 0:
+ ds_instance = DirSrv(False, containerised=True)
+ else:
+ ds_instance = DirSrv(False)
+ args = {
+ SER_HOST: "localhost.localdomain",
+ SER_PORT: 38999,
+ SER_SECURE_PORT: 63699,
+ SER_SERVERID_PROP: 'dscreate_repl',
+ SER_ROOT_DN: 'cn=directory manager',
+ SER_ROOT_PW: 'someLongPassword_123',
+ SER_LDAPI_ENABLED: 'on',
+ SER_LDAPI_AUTOBIND: 'on'
+ }
+ ds_instance.allocate(args)
+ ds_instance.start(timeout=60)
+
+ dse_ldif = DSEldif(ds_instance, serverid="dscreate_repl")
+ socket_path = dse_ldif.get("cn=config", "nsslapd-ldapifilepath")
+ ldapiuri=f"ldapi://{socket_path[0].replace('/', '%2f')}"
+ ds_instance.open(uri=ldapiuri)
+
+ # Check replication is enabled
+ replicas = Replicas(ds_instance)
+ replica = replicas.get(DEFAULT_SUFFIX)
+ assert replica
+
+ # Check role
+ assert replica.get_role() == ReplicaRole.SUPPLIER
+
+ # Check rid
+ assert replica.get_rid() == '111'
+
+ # Check bind dn is in config
+ assert replica.get_attr_val_utf8('nsDS5ReplicaBindDN') == 'cn=replication manager,cn=config'
+
+ # Check repl manager entry was created
+ repl_mgr = UserAccount(ds_instance, 'cn=replication manager,cn=config')
+ assert repl_mgr.exists()
+
+ # Changelog trimming settings
+ cl = Changelog(ds_instance, DEFAULT_SUFFIX)
+ assert cl.get_attr_val_utf8('nsslapd-changelogmaxage') == '8d'
+ assert cl.get_attr_val_utf8('nsslapd-changelogmaxentries') == '200000'
+
+
@pytest.fixture(scope="function")
def dscreate_long_instance(request):
template_file = "/tmp/dssetup.inf"
@@ -1583,8 +1707,7 @@ sample_entries = yes
assert False
inst = DirSrv(verbose=True, external_log=log)
- dse_ldif = DSEldif(inst,
- serverid=longname_serverid)
+ dse_ldif = DSEldif(inst, serverid=longname_serverid)
socket_path = dse_ldif.get("cn=config", "nsslapd-ldapifilepath")
inst.local_simple_allocate(
diff --git a/src/lib389/lib389/instance/options.py b/src/lib389/lib389/instance/options.py
index 64c699ee1..0ecade2b2 100644
--- a/src/lib389/lib389/instance/options.py
+++ b/src/lib389/lib389/instance/options.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2021 Red Hat, Inc.
+# Copyright (C) 2022 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -335,6 +335,7 @@ class Backend2Base(Options2):
super(Backend2Base, self).__init__(log)
self._section = section
+ # Suffix settings
self._options['suffix'] = ''
self._type['suffix'] = str
self._helptext['suffix'] = ("Sets the root suffix stored in this database. If you do not uncomment and set the suffix " +
@@ -357,4 +358,39 @@ class Backend2Base(Options2):
self._type['require_index'] = bool
self._helptext['require_index'] = "Set this parameter to \"True\" to refuse unindexed searches in this database."
- # TODO - Add other backend settings
+ # Replication settings
+ self._options['enable_replication'] = False
+ self._type['enable_replication'] = bool
+ self._helptext['enable_replication'] = ("Enable replication for this backend. By default it will setup the backend as " +
+ "a supplier, with replica ID 1, and \"cn=replication manager,cn=config\" as the " +
+ "replication binddn.")
+
+ self._options['replica_role'] = "supplier"
+ self._type['replica_role'] = str
+ self._helptext['replica_role'] = "Set the replication role. Choose either 'supplier', 'hub', or 'consumer'"
+
+ self._options['replica_id'] = "1"
+ self._type['replica_id'] = str
+ self._helptext['replica_id'] = "Set the unique replication identifier for this replica's database (suppliers only)"
+
+ self._options['replica_binddn'] = "cn=replication manager,cn=config"
+ self._type['replica_binddn'] = str
+ self._helptext['replica_binddn'] = "Set the replication manager DN"
+
+ self._options['replica_bindpw'] = ""
+ self._type['replica_bindpw'] = str
+ self._helptext['replica_bindpw'] = ("Sets the password of the Replication Manager account (\"replica_binddn\" parameter)." +
+ "Note that setting a plain text password can be a security risk if unprivileged " +
+ "users can read this INF file!")
+
+ self._options['replica_bindgroup'] = ""
+ self._type['replica_bindgroup'] = str
+ self._helptext['replica_bindgroup'] = "Set the replication bind group DN"
+
+ self._options['changelog_max_age'] = "7d"
+ self._type['changelog_max_age'] = str
+ self._helptext['changelog_max_age'] = ("How long an entry should remain in the replication changelog. The default is 7 days, or '7d'. (requires that replication is enabled).")
+
+ self._options['changelog_max_entries'] = "-1"
+ self._type['changelog_max_entries'] = str
+ self._helptext['changelog_max_entries'] = ("The maximum number of entries to keep in the replication changelog. The default is '-1', which means unlimited. (requires that replication is enabled).")
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
index c2c61a73b..6d013661c 100644
--- a/src/lib389/lib389/instance/setup.py
+++ b/src/lib389/lib389/instance/setup.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2020 Red Hat, Inc.
+# Copyright (C) 2022 Red Hat, Inc.
# Copyright (C) 2019 William Brown <[email protected]>
# All rights reserved.
#
@@ -35,6 +35,7 @@ from lib389.paths import Paths
from lib389.saslmap import SaslMappings
from lib389.instance.remove import remove_ds_instance
from lib389.index import Indexes
+from lib389.replica import Replicas, BootstrapReplicationManager, Changelog
from lib389.utils import (
assert_c,
is_a_dn,
@@ -196,6 +197,25 @@ class SetupDs(object):
if req_idx:
be[BACKEND_REQ_INDEX] = "on"
+ # Replication settings
+ be[BACKEND_REPL_ENABLED] = False
+ if config.get(section, BACKEND_REPL_ENABLED, fallback=False):
+ be[BACKEND_REPL_ENABLED] = True
+ role = config.get(section, BACKEND_REPL_ROLE, fallback="supplier")
+ be[BACKEND_REPL_ROLE] = role
+ rid = config.get(section, BACKEND_REPL_ID, fallback="1")
+ be[BACKEND_REPL_ID] = rid
+ binddn = config.get(section, BACKEND_REPL_BINDDN, fallback=None)
+ be[BACKEND_REPL_BINDDN] = binddn
+ bindpw = config.get(section, BACKEND_REPL_BINDPW, fallback=None)
+ be[BACKEND_REPL_BINDPW] = bindpw
+ bindgrp = config.get(section, BACKEND_REPL_BINDGROUP, fallback=None)
+ be[BACKEND_REPL_BINDGROUP] = bindgrp
+ cl_max_entries = config.get(section, BACKEND_REPL_CL_MAX_ENTRIES, fallback="-1")
+ be[BACKEND_REPL_CL_MAX_ENTRIES] = cl_max_entries
+ cl_max_age = config.get(section, BACKEND_REPL_CL_MAX_AGE, fallback="7d")
+ be[BACKEND_REPL_CL_MAX_AGE] = cl_max_age
+
# Add this backend to the list
backends.append(be)
@@ -980,6 +1000,15 @@ class SetupDs(object):
self.log.info(f"Create database backend: {backend['nsslapd-suffix']} ...")
is_sample_entries_in_props = "sample_entries" in backend
create_suffix_entry_in_props = backend.pop('create_suffix_entry', False)
+ repl_enabled = backend.pop(BACKEND_REPL_ENABLED, False)
+ rid = backend.pop(BACKEND_REPL_ID, False)
+ role = backend.pop(BACKEND_REPL_ROLE, False)
+ binddn = backend.pop(BACKEND_REPL_BINDDN, False)
+ bindpw = backend.pop(BACKEND_REPL_BINDPW, False)
+ bindgrp = backend.pop(BACKEND_REPL_BINDGROUP, False)
+ cl_maxage = backend.pop(BACKEND_REPL_CL_MAX_AGE, False)
+ cl_maxentries = backend.pop(BACKEND_REPL_CL_MAX_ENTRIES, False)
+
ds_instance.backends.create(properties=backend)
if not is_sample_entries_in_props and create_suffix_entry_in_props:
# Set basic ACIs
@@ -1008,6 +1037,74 @@ class SetupDs(object):
# Unsupported rdn
raise ValueError("Suffix RDN '{}' in '{}' is not supported. Supported RDN's are: 'c', 'cn', 'dc', 'o', and 'ou'".format(suffix_rdn_attr, backend['nsslapd-suffix']))
+ if repl_enabled:
+ # Okay enable replication....
+ self.log.info(f"Enable replication for: {backend['nsslapd-suffix']} ...")
+ repl_root = backend['nsslapd-suffix']
+ if role == "supplier":
+ repl_type = '3'
+ repl_flag = '1'
+ elif role == "hub":
+ repl_type = '2'
+ repl_flag = '1'
+ elif role == "consumer":
+ repl_type = '2'
+ repl_flag = '0'
+ else:
+ # error - unknown type
+ raise ValueError("Unknown replication role ({}), you must use \"supplier\", \"hub\", or \"consumer\"".format(role))
+
+ # Start the propeties and update them as needed
+ repl_properties = {
+ 'cn': 'replica',
+ 'nsDS5ReplicaRoot': repl_root,
+ 'nsDS5Flags': repl_flag,
+ 'nsDS5ReplicaType': repl_type,
+ 'nsDS5ReplicaId': '65535'
+ }
+
+ # Validate supplier settings
+ if role == "supplier":
+ try:
+ rid_num = int(rid)
+ if rid_num < 1 or rid_num > 65534:
+ raise ValueError
+ repl_properties['nsDS5ReplicaId'] = rid
+ except ValueError:
+ raise ValueError("replica_id expects a number between 1 and 65534")
+
+ # rid is good add it to the props
+ repl_properties['nsDS5ReplicaId'] = rid
+
+ # Bind DN & Group
+ if binddn:
+ repl_properties['nsDS5ReplicaBindDN'] = binddn
+ if bindgrp:
+ repl_properties['nsDS5ReplicaBindDNGroup'] = bindgrp
+
+ # Enable replication
+ replicas = Replicas(ds_instance)
+ replicas.create(properties=repl_properties)
+
+ # Create replication manager if password was provided
+ if binddn is not None and bindpw:
+ rdn = binddn.split(",", 1)[0]
+ rdn_attr, rdn_val = rdn.split("=", 1)
+ manager = BootstrapReplicationManager(ds_instance, dn=binddn, rdn_attr=rdn_attr)
+ manager.create(properties={
+ 'cn': rdn_val,
+ 'uid': rdn_val,
+ 'userPassword': bindpw
+ })
+
+ # Changelog settings
+ if role != "consumer":
+ cl = Changelog(ds_instance, repl_root)
+ cl.set_max_age(cl_maxage)
+ if cl_maxentries != "-1":
+ cl.set_max_entries(cl_maxentries)
+
+
# Create all required sasl maps: if we have a single backend ...
# our default maps are really really bad, and we should feel bad.
# they basically only work with a single backend, and they'll break
diff --git a/src/lib389/lib389/properties.py b/src/lib389/lib389/properties.py
index 667bce9fd..729845098 100644
--- a/src/lib389/lib389/properties.py
+++ b/src/lib389/lib389/properties.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2020 Red Hat, Inc.
+# Copyright (C) 2022 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -108,8 +108,15 @@ BACKEND_CHAIN_BIND_PW = 'chain-bind-pw'
BACKEND_CHAIN_URLS = 'chain-urls'
BACKEND_STATS = 'stats'
BACKEND_SAMPLE_ENTRIES = 'sample_entries'
-
BACKEND_OBJECTCLASS_VALUE = 'nsBackendInstance'
+BACKEND_REPL_ENABLED = 'enable_replication'
+BACKEND_REPL_ROLE = 'replica_role'
+BACKEND_REPL_ID = 'replica_id'
+BACKEND_REPL_BINDDN = 'replica_binddn'
+BACKEND_REPL_BINDPW = 'replica_bindpw'
+BACKEND_REPL_BINDGROUP = 'replica_bindgroup'
+BACKEND_REPL_CL_MAX_ENTRIES = "changelog_max_entries"
+BACKEND_REPL_CL_MAX_AGE = "changelog_max_age"
# THIS NEEDS TO BE REMOVED. HACKS!!!!
BACKEND_PROPNAME_TO_ATTRNAME = {BACKEND_SUFFIX: 'nsslapd-suffix',
| 0 |
e84564fedab62009763981d24525fcbadee95099
|
389ds/389-ds-base
|
Issue 5894 - lmdb import error fails with Could not store the entry (#5895)
|
commit e84564fedab62009763981d24525fcbadee95099
Author: progier389 <[email protected]>
Date: Fri Aug 11 16:13:11 2023 +0200
Issue 5894 - lmdb import error fails with Could not store the entry (#5895)
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
index 97ac96016..6da707630 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
@@ -1187,7 +1187,7 @@ dbmdb_import_producer(void *param)
wait_for_starting(info);
wqelmt.winfo.job = job;
wqelmt.wait_id = id;
- wqelmt.lineno = curr_lineno;
+ wqelmt.lineno = curr_lineno + 1; /* Human tends to start counting from 1 rather than 0 */
wqelmt.data = dbmdb_import_get_entry(&c, fd, &curr_lineno);
wqelmt.nblines = curr_lineno - wqelmt.lineno;
wqelmt.datalen = 0;
@@ -2735,11 +2735,12 @@ int dbmdb_import_add_id2entry_add(ImportJob *job, backend *be, struct backentry
{
int encrypt = job->encrypt;
WriterQueueData_t wqd = {0};
- int len, rc;
+ int len = 0;
+ int rc = 0;
char temp_id[sizeof(ID)];
struct backentry *encrypted_entry = NULL;
ImportCtx_t *ctx = job->writer_ctx;
- uint32_t esize;
+ uint32_t esize = 0;
slapi_log_err(SLAPI_LOG_TRACE, "dbmdb_import_add_id2entry_add", "=> ( %lu, \"%s\" )\n",
(u_long)e->ep_id, backentry_get_ndn(e));
| 0 |
48d76ace7e1387242b21e21be810c46145c0feee
|
389ds/389-ds-base
|
Ticket 48273 - Improve valgrind functions
Description: The previous valgrind functions were very limited in what you could do.
Now, you can get the resutls file,m adn check it mulitple times, as
well as pass in multiple pattern strings to check for in a single stack
trace.
Also added some helper constants for the memory leak or invalid access
stacks.
https://fedorahosted.org/389/ticket/48273
Reviewed by: nhosoi(Thanks!)
|
commit 48d76ace7e1387242b21e21be810c46145c0feee
Author: Mark Reynolds <[email protected]>
Date: Tue Sep 15 18:14:59 2015 -0400
Ticket 48273 - Improve valgrind functions
Description: The previous valgrind functions were very limited in what you could do.
Now, you can get the resutls file,m adn check it mulitple times, as
well as pass in multiple pattern strings to check for in a single stack
trace.
Also added some helper constants for the memory leak or invalid access
stacks.
https://fedorahosted.org/389/ticket/48273
Reviewed by: nhosoi(Thanks!)
diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py
index 02072e447..895edbca6 100644
--- a/src/lib389/lib389/_constants.py
+++ b/src/lib389/lib389/_constants.py
@@ -170,6 +170,8 @@ DEFAULT_USER_COMMENT = "lib389 DS user"
DATA_DIR = "data"
TMP_DIR = "tmp"
VALGRIND_WRAPPER = "ns-slapd.valgrind"
+VALGRIND_LEAK_STR = " blocks are definitely lost in loss record "
+VALGRIND_INVALID_STR = " Invalid (free|read|write)"
DISORDERLY_SHUTDOWN = 'Detected Disorderly Shutdown last time Directory Server was running, recovering database'
#
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index 18933369a..cde48f714 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -162,13 +162,15 @@ def get_plugin_dir(prefix=None):
def valgrind_enable(sbin_dir, wrapper=None):
'''
Copy the valgrind ns-slapd wrapper into the /sbin directory
- (making a backup of the original ns-slapd binary). The server instance(s)
- should be stopped prior to calling this function.
+ (making a backup of the original ns-slapd binary).
+ The server instance(s) should be stopped prior to calling this function.
Then after calling valgrind_enable():
- Start the server instance(s) with a timeout of 60 (valgrind takes a while to startup)
- Run the tests
- - Run valgrind_check_leak(instance, "leak test") - this also stops the instance
+ - Stop the server
+ - Get the results file
+ - Run valgrind_check_file(result_file, "pattern", "pattern", ...)
- Run valgrind_disable()
@param sbin_dir - the location of the ns-slapd binary (e.g. /usr/sbin)
@@ -242,44 +244,66 @@ def valgrind_disable(sbin_dir):
log.info('Valgrind is now disabled.')
-def valgrind_check_leak(dirsrv_inst, pattern):
- '''
- Check the valgrind results file for the "leak_str"
- @param dirsrv_inst - DirSrv object for the instance we want the result file from
- @param pattern - A plain text or regex pattern string that should be searched for
- @return True/False - Return true of "leak_str" is in the valgrind output file
- @raise IOError
- '''
-
- cmd = ("ps -ef | grep valgrind | grep 'slapd-" + dirsrv_inst.serverid +
- " ' | awk '{ print $14 }' | sed -e 's/\-\-log\-file=//'")
+def valgrind_get_results_file(dirsrv_inst):
+ """
+ Return the valgrind results file for the dirsrv instance.
+ """
- '''
+ """
The "ps -ef | grep valgrind" looks like:
nobody 26239 1 10 14:33 ? 00:00:06 valgrind -q --tool=memcheck --leak-check=yes
--leak-resolution=high --num-callers=50 --log-file=/var/tmp/slapd.vg.26179
/usr/sbin/ns-slapd.orig -D /etc/dirsrv/slapd-localhost
-i /var/run/dirsrv/slapd-localhost.pid -w /var/run/dirsrv/slapd-localhost.startpid
- '''
+
+ We need to extract the "--log-file" value
+ """
+ cmd = ("ps -ef | grep valgrind | grep 'slapd-" + dirsrv_inst.serverid +
+ " ' | awk '{ print $14 }' | sed -e 's/\-\-log\-file=//'")
# Run the command and grab the output
p = os.popen(cmd)
- result_file = p.readline()
+ results_file = p.readline()
p.close()
- # We need to stop the server next
- dirsrv_inst.stop(timeout=30)
- time.sleep(1)
+ return results_file
+
+
+def valgrind_check_file(results_file, *patterns):
+ '''
+ Check the valgrind results file for the all the patterns
+ @param result_file - valgrind results file (must be read after server is stopped)
+ @param patterns - A plain text or regex pattern string args that should be searched for
+ @return True/False - Return true if one if the patterns match a stack trace
+ @raise IOError
+ '''
+
+ # Verify results file
+ if not results_file:
+ assert False
# Check the result file fo the leak text
- result_file = result_file.replace('\n', '')
+ results_file = results_file.replace('\n', '')
found = False
- vlog = open(result_file)
+ pattern_count = len(patterns)
+ matched_count = 0
+
+ vlog = open(results_file)
for line in vlog:
- if re.search(pattern, line):
- found = True
- break
+ for match_txt in patterns:
+ if re.search(match_txt, line):
+ matched_count += 1
+ break
+
+ if len(line.split()) == 1:
+ # Check if this stack stack matched all the patterns
+ if pattern_count == matched_count:
+ found = True
+ print('valgrind: match found in results file: %s' % (results_file))
+ break
+ else:
+ matched_count = 0
vlog.close()
return found
| 0 |
bb5df9d474d9cf9f224c90d8171b95e5042bedf5
|
389ds/389-ds-base
|
Issue 5545 - A random crash in import over lmdb (#5546)
* Issue 5545 - A random crash in import over lmdb
* Issue 5545 - Fix reviews remarks
Random crash due to an accelerator that bypass lock while dequeueing worker thread entry but that cause synchronization issue around the hardware memory cache)
Solution: lock systematically to perform a membar that ensure proper synchronization.
(It does not impact the performances because the provider -> worker queue is not the performance bottleneck.
(that is the writer thread database operation that limits the throughput)
Also added 2 improvements:
Use MDB_NOSYNC flags during off-line import (Anyway if the process is interrupted the import must be rerun)
Log regularly some statistics about import writer thread (to help determining if the import bottleneck is because
the thread is waiting for input data or waiting that the lmdb operation complete
|
commit bb5df9d474d9cf9f224c90d8171b95e5042bedf5
Author: progier389 <[email protected]>
Date: Fri Dec 16 16:18:40 2022 +0100
Issue 5545 - A random crash in import over lmdb (#5546)
* Issue 5545 - A random crash in import over lmdb
* Issue 5545 - Fix reviews remarks
Random crash due to an accelerator that bypass lock while dequeueing worker thread entry but that cause synchronization issue around the hardware memory cache)
Solution: lock systematically to perform a membar that ensure proper synchronization.
(It does not impact the performances because the provider -> worker queue is not the performance bottleneck.
(that is the writer thread database operation that limits the throughput)
Also added 2 improvements:
Use MDB_NOSYNC flags during off-line import (Anyway if the process is interrupted the import must be rerun)
Log regularly some statistics about import writer thread (to help determining if the import bottleneck is because
the thread is waiting for input data or waiting that the lmdb operation complete
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
index 0328abf42..97ac96016 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
@@ -26,6 +26,8 @@
#include <assert.h>
#include "mdb_import.h"
#include "../vlv_srch.h"
+#include <sys/time.h>
+#include <time.h>
#define CV_TIMEOUT 10000000 /* 10 milli seconds timeout */
@@ -54,6 +56,42 @@
#define LMDB_MIN_DB_SIZE (1024*1024*1024)
+
+/* import thread usage statistics */
+#define MDB_STAT_INIT(stats) { mdb_stat_collect(&stats, MDB_STAT_RUN, 1); }
+#define MDB_STAT_END(stats) { mdb_stat_collect(&stats, MDB_STAT_RUN, 0); }
+#define MDB_STAT_STEP(stats, step) { mdb_stat_collect(&stats, (step), 0); }
+
+typedef enum {
+ MDB_STAT_RUN,
+ MDB_STAT_READ,
+ MDB_STAT_WRITE,
+ MDB_STAT_PAUSE,
+ MDB_STAT_TXNSTART,
+ MDB_STAT_TXNSTOP,
+ MDB_STAT_LAST_STEP /* Last item in this enum */
+} mdb_stat_step_t;
+
+/* Should be kept in sync with mdb_stat_step_t */
+#define MDB_STAT_STEP_NAMES { "run", "read", "write", "pause", "txnbegin", "txncommit" }
+
+/* Per thread per step statistics */
+typedef struct {
+ struct timespec realtime; /* Cumulated time spend in this step */
+ /* Possible improvment: aggregate here some statistic from getrusage(RUSAGE_THREAD,stats) syscall */
+} mdb_stat_slot_t;
+
+/* Per thread statistics */
+typedef struct {
+ mdb_stat_step_t last_step;
+ mdb_stat_slot_t last;
+ mdb_stat_slot_t steps[MDB_STAT_LAST_STEP];
+} mdb_stat_info_t;
+
+void mdb_stat_collect(mdb_stat_info_t *sinfo, mdb_stat_step_t step, int init);
+char *mdb_stat_summarize(mdb_stat_info_t *sinfo, char *buf, size_t bufsize);
+
+
/* The private db records data (i.e entry_info) format is:
* ID: entry ID
* ID: nb ancestors
@@ -3139,13 +3177,11 @@ dbmdb_import_worker(void *param)
wait_for_starting(info);
/* Wait until data get queued */
- if (wqelmnt->wait_id == 0) {
- pthread_mutex_lock(&ctx->workerq.mutex);
- while (wqelmnt->wait_id == 0 && !info_is_finished(info) && ctx->producer.state != FINISHED) {
- safe_cond_wait(&ctx->workerq.cv, &ctx->workerq.mutex);
- }
- pthread_mutex_unlock(&ctx->workerq.mutex);
+ pthread_mutex_lock(&ctx->workerq.mutex);
+ while (wqelmnt->wait_id == 0 && !info_is_finished(info) && ctx->producer.state != FINISHED) {
+ safe_cond_wait(&ctx->workerq.cv, &ctx->workerq.mutex);
}
+ pthread_mutex_unlock(&ctx->workerq.mutex);
if (wqelmnt->wait_id == 0) {
break;
}
@@ -3711,10 +3747,15 @@ dbmdb_import_writer(void*param)
MDB_txn *txn = NULL;
int count = 0;
int rc = 0;
+ mdb_stat_info_t stats = {0};
+ MDB_STAT_INIT(stats);
while (!rc && !info_is_finished(info)) {
+ MDB_STAT_STEP(stats, MDB_STAT_PAUSE);
wait_for_starting(info);
+ MDB_STAT_STEP(stats, MDB_STAT_READ);
slot = dbmdb_import_q_getall(&ctx->writerq);
+ MDB_STAT_STEP(stats, MDB_STAT_RUN);
if (info_is_finished(info)) {
dbmdb_import_q_flush(&ctx->writerq);
break;
@@ -3725,11 +3766,14 @@ dbmdb_import_writer(void*param)
for (; slot; slot = nextslot) {
if (!txn) {
+ MDB_STAT_STEP(stats, MDB_STAT_TXNSTART);
rc = TXN_BEGIN(ctx->ctx->env, NULL, 0, &txn);
}
if (!rc) {
+ MDB_STAT_STEP(stats, MDB_STAT_WRITE);
rc = MDB_PUT(txn, slot->dbi->dbi, &slot->key, &slot->data, 0);
}
+ MDB_STAT_STEP(stats, MDB_STAT_RUN);
nextslot = slot->next;
slapi_ch_free((void**)&slot);
}
@@ -3737,7 +3781,9 @@ dbmdb_import_writer(void*param)
break;
}
if (count++ >= WRITER_MAX_OPS_IN_TXN) {
+ MDB_STAT_STEP(stats, MDB_STAT_TXNSTOP);
rc = TXN_COMMIT(txn);
+ MDB_STAT_STEP(stats, MDB_STAT_RUN);
if (rc) {
break;
}
@@ -3746,20 +3792,38 @@ dbmdb_import_writer(void*param)
}
}
if (txn && !rc) {
+ MDB_STAT_STEP(stats, MDB_STAT_TXNSTOP);
rc = TXN_COMMIT(txn);
+ MDB_STAT_STEP(stats, MDB_STAT_RUN);
if (!rc) {
txn = NULL;
}
}
if (txn) {
+ MDB_STAT_STEP(stats, MDB_STAT_TXNSTOP);
TXN_ABORT(txn);
+ MDB_STAT_STEP(stats, MDB_STAT_RUN);
txn = NULL;
}
+ MDB_STAT_STEP(stats, MDB_STAT_WRITE);
+ if (!rc) {
+ /* Ensure that all data are written on disk */
+ rc = mdb_env_sync(ctx->ctx->env, 1);
+ }
+ MDB_STAT_END(stats);
+
if (rc) {
slapi_log_err(SLAPI_LOG_ERR, "dbmdb_import_writer",
"Failed to write in the database. Error is 0x%x: %s.\n",
rc, mdb_strerror(rc));
thread_abort(info);
+ } else {
+ char buf[200];
+ char *summary = mdb_stat_summarize(&stats, buf, sizeof buf);
+ if (summary) {
+ import_log_notice(job, SLAPI_LOG_INFO, "dbmdb_import_monitor_threads",
+ "Import writer thread usage: %s", summary);
+ }
}
info_set_state(info);
}
@@ -4108,3 +4172,88 @@ dbmdb_free_import_ctx(ImportJob *job)
slapi_ch_free((void**)&ctx);
}
}
+
+/***************************************************************************/
+/******************** Performance statistics functions *********************/
+/***************************************************************************/
+
+static inline void __attribute__((always_inline))
+_add_delta_time(struct timespec *cumul, struct timespec *now, struct timespec *last)
+{
+ struct timespec tmp1;
+ struct timespec tmp2;
+ #define NSINS 1000000000
+
+ /* tmp1 = now -last */
+ if (now->tv_nsec < last->tv_nsec) {
+ now->tv_sec--;
+ now->tv_nsec += NSINS;
+ }
+ tmp1.tv_sec = now->tv_sec - last->tv_sec;
+ tmp1.tv_nsec = now->tv_nsec - last->tv_nsec;
+ /* tmp2 = cumul + tmp1 */
+ tmp2.tv_sec = cumul->tv_sec + tmp1.tv_sec;
+ tmp2.tv_nsec = cumul->tv_nsec + tmp1.tv_nsec;
+ if (tmp2.tv_nsec > NSINS) {
+ tmp2.tv_nsec -= NSINS;
+ tmp2.tv_sec++;
+ }
+ /* cumul = tmp2 */
+ *cumul = tmp2;
+}
+
+static inline double __attribute__((always_inline))
+_time_to_double(struct timespec *t)
+{
+ double res = t->tv_sec;
+ res += t->tv_nsec / 1000000000.0;
+ return res;
+}
+
+void
+mdb_stat_collect(mdb_stat_info_t *sinfo, mdb_stat_step_t step, int init)
+{
+ struct timespec now;
+
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &now);
+ if (!init) {
+ _add_delta_time(&sinfo->steps[sinfo->last_step].realtime, &now, &sinfo->last.realtime);
+ }
+ sinfo->last.realtime = now;
+ sinfo->last_step = step;
+}
+
+char *
+mdb_stat_summarize(mdb_stat_info_t *sinfo, char *buf, size_t bufsize)
+{
+ static const char *names[MDB_STAT_LAST_STEP] = MDB_STAT_STEP_NAMES;
+ double v[MDB_STAT_LAST_STEP];
+ double total = 0.0;
+ char tmp[50];
+ int pos = 0;
+ int len = 0;
+
+ if (!sinfo) {
+ return NULL;
+ }
+
+ for (size_t i=0; i<MDB_STAT_LAST_STEP; i++) {
+ v[i] = _time_to_double(&sinfo->steps[i].realtime);
+ total += v[i];
+ }
+ if (total > 0.0) {
+ for (size_t i=0; i<MDB_STAT_LAST_STEP; i++) {
+ double percent = 100.0 * v[i] / total;
+ PR_snprintf(tmp, (sizeof tmp), "%s: %.2f%% ", names[i], percent);
+ len = strlen(tmp);
+ if (pos+len+4 < bufsize) {
+ strcpy(buf+pos, tmp);
+ pos += len;
+ } else {
+ strcpy(buf+pos, "...");
+ break;
+ }
+ }
+ }
+ return buf;
+}
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_ldif2db.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_ldif2db.c
index df8a4da7e..e14968801 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_ldif2db.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_ldif2db.c
@@ -111,6 +111,7 @@ dbmdb_ldif2db(Slapi_PBlock *pb)
char *instance_name;
Slapi_Task *task = NULL;
int ret, task_flags;
+ dbmdb_ctx_t *ctx = NULL;
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li);
slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_name);
@@ -226,6 +227,15 @@ dbmdb_ldif2db(Slapi_PBlock *pb)
}
goto fail;
}
+
+ ctx = MDB_CONFIG(li);
+ ret = mdb_env_set_flags(ctx->env, MDB_NOSYNC, 1);
+ if (0 != ret) {
+ slapi_log_err(SLAPI_LOG_ALERT, "dbmdb_ldif2db", "Failed to set MDB_NOSYNC flags on database environment. "
+ "(error %d: %s)\n",
+ ret, dblayer_strerror(ret));
+ goto fail;
+ }
}
/* Delete old database files */
@@ -1204,6 +1214,7 @@ dbmdb_db2index(Slapi_PBlock *pb)
backend *be;
int return_value = -1;
Slapi_Task *task;
+ dbmdb_ctx_t *ctx = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "dbmdb_db2index", "=>\n");
if (g_get_shutdown() || c_get_shutdown()) {
@@ -1239,6 +1250,14 @@ dbmdb_db2index(Slapi_PBlock *pb)
"ldbm2index", "Failed to init database: %s\n", instance_name);
return return_value;
}
+ ctx = MDB_CONFIG(li);
+ return_value = mdb_env_set_flags(ctx->env, MDB_NOSYNC, 1);
+ if (0 != return_value) {
+ slapi_log_err(SLAPI_LOG_ALERT, "dbmdb_ldif2db", "Failed to set MDB_NOSYNC flags on database environment. "
+ "(error %d: %s)\n",
+ return_value, dblayer_strerror(return_value));
+ return -1;
+ }
/* vlv_init should be called before dbmdb_instance_start
* so the vlv dbi get created by dbmdb_instance_start
| 0 |
d2aa131f8af38f79a16f55a70add81e829056cd0
|
389ds/389-ds-base
|
Bump version to 1.4.0.18
|
commit d2aa131f8af38f79a16f55a70add81e829056cd0
Author: Mark Reynolds <[email protected]>
Date: Wed Oct 10 12:32:17 2018 -0400
Bump version to 1.4.0.18
diff --git a/VERSION.sh b/VERSION.sh
index cd050c413..a7efca9cc 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
# PACKAGE_VERSION is constructed from these
VERSION_MAJOR=1
VERSION_MINOR=4
-VERSION_MAINT=0.17
+VERSION_MAINT=0.18
# NOTE: VERSION_PREREL is automatically set for builds made out of a git tree
VERSION_PREREL=
VERSION_DATE=$(date -u +%Y%m%d)
| 0 |
d1023d843c69abbe72e7759ab738c3ab661205bc
|
389ds/389-ds-base
|
Ticket #48822 - (389-ds-base-1.3.5) Fixing coverity issues.
Description: Buffer Overflow
BAD_SIZEOF -- slapd/ssl.c:3021: bad_sizeof: Taking the size of "randomPassword",
which is the address of an object, is suspicious. Removed unnecessary cast.
SIZEOF_MISMATCH -- slapd/mapping_tree.c:2229: suspicious_sizeof: Passing
argument "errorbuf" of type "char *" and argument "8U /* sizeof (errorbuf) */"
to function "PL_strncpyz" is suspicious.
A pointer of an array is passed to a function, in which it tried to get the the
array size with sizeof, which does not work. Changed the API to pass the size
of the array.
https://fedorahosted.org/389/ticket/48822
Reviewed by [email protected] (Thank you, William!!)
|
commit d1023d843c69abbe72e7759ab738c3ab661205bc
Author: Noriko Hosoi <[email protected]>
Date: Wed May 4 19:05:07 2016 -0700
Ticket #48822 - (389-ds-base-1.3.5) Fixing coverity issues.
Description: Buffer Overflow
BAD_SIZEOF -- slapd/ssl.c:3021: bad_sizeof: Taking the size of "randomPassword",
which is the address of an object, is suspicious. Removed unnecessary cast.
SIZEOF_MISMATCH -- slapd/mapping_tree.c:2229: suspicious_sizeof: Passing
argument "errorbuf" of type "char *" and argument "8U /* sizeof (errorbuf) */"
to function "PL_strncpyz" is suspicious.
A pointer of an array is passed to a function, in which it tried to get the the
array size with sizeof, which does not work. Changed the API to pass the size
of the array.
https://fedorahosted.org/389/ticket/48822
Reviewed by [email protected] (Thank you, William!!)
diff --git a/ldap/servers/plugins/retrocl/retrocl.c b/ldap/servers/plugins/retrocl/retrocl.c
index 427448ae6..0b336d541 100644
--- a/ldap/servers/plugins/retrocl/retrocl.c
+++ b/ldap/servers/plugins/retrocl/retrocl.c
@@ -203,7 +203,7 @@ static int retrocl_select_backend(void)
slapi_pblock_set(pb,SLAPI_OPERATION, op);
- err = slapi_mapping_tree_select(pb,&be,&referral,errbuf);
+ err = slapi_mapping_tree_select(pb, &be, &referral, errbuf, sizeof(errbuf));
slapi_entry_free(referral);
if (err != LDAP_SUCCESS || be == NULL || be == defbackend_get_backend()) {
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 1d34d95c8..629017e95 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -152,7 +152,7 @@ do_add( Slapi_PBlock *pb )
if ( !normtype || !*normtype ) {
char ebuf[SLAPI_DSE_RETURNTEXT_SIZE];
rc = LDAP_INVALID_SYNTAX;
- slapi_create_errormsg(ebuf, 0, "invalid type '%s'", type);
+ slapi_create_errormsg(ebuf, sizeof(ebuf), "invalid type '%s'", type);
op_shared_log_error_access (pb, "ADD", slapi_sdn_get_dn (slapi_entry_get_sdn_const(e)), ebuf);
send_ldap_result( pb, rc, NULL, ebuf, 0, NULL );
slapi_ch_free_string(&type);
@@ -487,7 +487,7 @@ static void op_shared_add (Slapi_PBlock *pb)
* We could be serving multiple database backends. Select the
* appropriate one.
*/
- if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf)) != LDAP_SUCCESS) {
+ if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf, sizeof(errorbuf))) != LDAP_SUCCESS) {
send_ldap_result(pb, err, NULL, errorbuf, 0, NULL);
be = NULL;
goto done;
diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c
index 06fa6a437..7da1bab8e 100644
--- a/ldap/servers/slapd/attr.c
+++ b/ldap/servers/slapd/attr.c
@@ -938,7 +938,7 @@ int attr_replace(Slapi_Attr *a, Slapi_Value **vals)
}
int
-attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf )
+attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen )
{
int retVal = LDAP_SUCCESS;
@@ -948,7 +948,7 @@ attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval,
strcasecmp ( value, "0" ) != 0 &&
strcasecmp ( value, "true" ) != 0 &&
strcasecmp ( value, "false" ) != 0 ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\".", attr_name, value);
+ slapi_create_errormsg(errorbuf, ebuflen, "%s: invalid value \"%s\".", attr_name, value);
retVal = LDAP_CONSTRAINT_VIOLATION;
}
@@ -956,7 +956,7 @@ attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval,
}
int
-attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf )
+attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen )
{
int retVal = LDAP_SUCCESS;
long val;
@@ -964,7 +964,7 @@ attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval
val = strtol(value, NULL, 0);
if ( (minval != -1 ? (val < minval ? 1 : 0) : 0) ||
(maxval != -1 ? (val > maxval ? 1 : 0) : 0) ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\".", attr_name, value);
+ slapi_create_errormsg(errorbuf, ebuflen, "%s: invalid value \"%s\".", attr_name, value);
retVal = LDAP_CONSTRAINT_VIOLATION;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 58ab9a0c7..37ce02d66 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -425,7 +425,7 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
} else if (val > li->li_dbcachesize) {
delta = val - li->li_dbcachesize;
if (!util_is_cachesize_sane(&delta)){
- slapi_create_errormsg(errorbuf, 0, "Error: dbcachememsize value is too large.");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: dbcachememsize value is too large.");
LDAPDebug0Args(LDAP_DEBUG_ANY,"Error: dbcachememsize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -497,7 +497,7 @@ static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int
if (val > li->li_dbncache) {
delta = val - li->li_dbncache;
if (!util_is_cachesize_sane(&delta)){
- slapi_create_errormsg(errorbuf, 0, "Error: dbncache size value is too large.");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: dbncache size value is too large.");
LDAPDebug1Arg(LDAP_DEBUG_ANY,"Error: dbncache size value is too large.\n", val);
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -780,7 +780,7 @@ static int ldbm_config_db_old_idl_maxids_set(void *arg, void *value, char *error
if(val >= 0){
li->li_old_idl_maxids = val;
} else {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"Error: Invalid value for %s (%d). Value must be equal or greater than zero.",
CONFIG_DB_OLD_IDL_MAXIDS, val);
return LDAP_UNWILLING_TO_PERFORM;
@@ -844,7 +844,7 @@ static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *e
int val = (int) ((uintptr_t)value);
if (val < 0 || val > 100) {
- slapi_create_errormsg(errorbuf, 0, "Error: Invalid value for %s (%d). Must be between 0 and 100\n",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: Invalid value for %s (%d). Must be between 0 and 100\n",
CONFIG_DB_TRICKLE_PERCENTAGE, val);
LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: Invalid value for %s (%d). Must be between 0 and 100\n",
CONFIG_DB_TRICKLE_PERCENTAGE, val);
@@ -1078,7 +1078,7 @@ static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int
if (val > li->li_dblayer_private->dblayer_cache_config) {
delta = val - li->li_dblayer_private->dblayer_cache_config;
if (!util_is_cachesize_sane(&delta)){
- slapi_create_errormsg(errorbuf, 0, "Error: db cachesize value is too large");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: db cachesize value is too large");
LDAPDebug1Arg(LDAP_DEBUG_ANY,"Error: db cachesize value is too large.\n", val);
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -1209,7 +1209,7 @@ static int ldbm_config_import_cachesize_set(void *arg, void *value, char *errorb
if (val > li->li_import_cachesize) {
delta = val - li->li_import_cachesize;
if (!util_is_cachesize_sane(&delta)){
- slapi_create_errormsg(errorbuf, 0, "Error: import cachesize value is too large.");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: import cachesize value is too large.");
LDAPDebug0Args(LDAP_DEBUG_ANY,"Error: import cachesize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -1471,7 +1471,7 @@ static int ldbm_config_db_deadlock_policy_set(void *arg, void *value, char *erro
u_int32_t val = (u_int32_t) ((uintptr_t)value);
if (val > DB_LOCK_YOUNGEST) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"Error: Invalid value for %s (%d). Must be between %d and %d inclusive",
CONFIG_DB_DEADLOCK_POLICY, val, DB_LOCK_DEFAULT, DB_LOCK_YOUNGEST);
LDAPDebug(LDAP_DEBUG_ANY, "Error: Invalid value for deadlock policy (%d). Must be between %d and %d inclusive",
@@ -1479,7 +1479,7 @@ static int ldbm_config_db_deadlock_policy_set(void *arg, void *value, char *erro
return LDAP_UNWILLING_TO_PERFORM;
}
if (val == DB_LOCK_NORUN) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"Warning: Setting value for %s to (%d) will disable deadlock detection",
CONFIG_DB_DEADLOCK_POLICY, val);
LDAPDebug2Args(LDAP_DEBUG_ANY, "Warning: Setting value for %s to (%d) will disable deadlock detection",
@@ -1902,7 +1902,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
config = get_config_info(config_array, attr_name);
if (NULL == config) {
LDAPDebug(LDAP_DEBUG_CONFIG, "Unknown config attribute %s\n", attr_name, 0, 0);
- slapi_create_errormsg(err_buf, 0, "Unknown config attribute %s\n", attr_name);
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown config attribute %s\n", attr_name);
return LDAP_SUCCESS; /* Ignore unknown attributes */
}
@@ -1910,7 +1910,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
if (phase == CONFIG_PHASE_RUNNING &&
!(config->config_flags & CONFIG_FLAG_ALLOW_RUNNING_CHANGE)) {
LDAPDebug1Arg(LDAP_DEBUG_ANY, "%s can't be modified while the server is running.\n", attr_name);
- slapi_create_errormsg(err_buf, 0, "%s can't be modified while the server is running.\n", attr_name);
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "%s can't be modified while the server is running.\n", attr_name);
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -1928,7 +1928,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
previously set to a non-default value */
if (SLAPI_IS_MOD_ADD(mod_op) && apply_mod &&
(config->config_flags & CONFIG_FLAG_PREVIOUSLY_SET)) {
- slapi_create_errormsg(err_buf, 0, "cannot add a value to single valued attribute %s.\n", attr_name);
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "cannot add a value to single valued attribute %s.\n", attr_name);
return LDAP_OBJECT_CLASS_VIOLATION;
}
}
@@ -1939,7 +1939,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
char buf[BUFSIZ];
ldbm_config_get(arg, config, buf);
if (PL_strncmp(buf, bval->bv_val, bval->bv_len)) {
- slapi_create_errormsg(err_buf, 0,
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE,
"value [%s] for attribute %s does not match existing value [%s].\n", bval->bv_val, attr_name, buf);
return LDAP_NO_SUCH_ATTRIBUTE;
}
@@ -1956,19 +1956,19 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
llval = db_atoi(str_val, &err);
/* check for parsing error (e.g. not a number) */
if (err) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is not a number\n", str_val, attr_name);
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n", str_val, attr_name);
LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is not a number\n", str_val, attr_name);
return LDAP_UNWILLING_TO_PERFORM;
/* check for overflow */
} else if (LL_CMP(llval, >, llmaxint)) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is greater than the maximum %d\n",
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
str_val, attr_name, maxint);
LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is greater than the maximum %d\n",
str_val, attr_name, maxint);
return LDAP_UNWILLING_TO_PERFORM;
/* check for underflow */
} else if (LL_CMP(llval, <, llminint)) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is less than the minimum %d\n",
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
str_val, attr_name, minint);
LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is less than the minimum %d\n",
str_val, attr_name, minint);
@@ -1996,21 +1996,21 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
llval = db_atoi(str_val, &err);
/* check for parsing error (e.g. not a number) */
if (err) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is not a number\n",
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
str_val, attr_name);
LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is not a number\n",
str_val, attr_name);
return LDAP_UNWILLING_TO_PERFORM;
/* check for overflow */
} else if (LL_CMP(llval, >, llmaxint)) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is greater than the maximum %d\n",
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
str_val, attr_name, maxint);
LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is greater than the maximum %d\n",
str_val, attr_name, maxint);
return LDAP_UNWILLING_TO_PERFORM;
/* check for underflow */
} else if (LL_CMP(llval, <, llminint)) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is less than the minimum %d\n",
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
str_val, attr_name, minint);
LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is less than the minimum %d\n",
str_val, attr_name, minint);
@@ -2032,14 +2032,14 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
/* check for parsing error (e.g. not a number) */
if (err == EINVAL) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is not a number\n",
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
str_val, attr_name);
LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is not a number\n",
str_val, attr_name);
return LDAP_UNWILLING_TO_PERFORM;
/* check for overflow */
} else if (err == ERANGE) {
- slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is outside the range of representable values\n",
+ slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is outside the range of representable values\n",
str_val, attr_name);
LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is outside the range of representable values\n",
str_val, attr_name);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
index 42c8ffe6e..3e59e7261 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
@@ -146,7 +146,7 @@ ldbm_instance_index_config_delete_callback(Slapi_PBlock *pb, Slapi_Entry* e, Sla
if ((slapi_counter_get_value(inst->inst_ref_count) > 0) ||
/* check if the backend is ON or not.
* If offline or being deleted, non SUCCESS is returned. */
- (slapi_mapping_tree_select(pb, &be, NULL, returntext) != LDAP_SUCCESS)) {
+ (slapi_mapping_tree_select(pb, &be, NULL, returntext, SLAPI_DSE_RETURNTEXT_SIZE) != LDAP_SUCCESS)) {
*returncode = LDAP_UNAVAILABLE;
rc = SLAPI_DSE_CALLBACK_ERROR;
goto bail;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index 2506261e4..930241060 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -109,7 +109,7 @@ ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, in
if (val > inst->inst_cache.c_maxsize) {
delta = val - inst->inst_cache.c_maxsize;
if (!util_is_cachesize_sane(&delta)){
- slapi_create_errormsg(errorbuf, 0, "Error: cachememsize value is too large.");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: cachememsize value is too large.");
LDAPDebug0Args(LDAP_DEBUG_ANY, "Error: cachememsize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -151,7 +151,7 @@ ldbm_instance_config_dncachememsize_set(void *arg, void *value, char *errorbuf,
if (val > inst->inst_dncache.c_maxsize) {
delta = val - inst->inst_dncache.c_maxsize;
if (!util_is_cachesize_sane(&delta)){
- slapi_create_errormsg(errorbuf, 0, "Error: dncachememsize value is too large.");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: dncachememsize value is too large.");
LDAPDebug0Args(LDAP_DEBUG_ANY,"Error: dncachememsize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 00795c432..1ffec4e2b 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -655,7 +655,7 @@ do_bind( Slapi_PBlock *pb )
}
/* We could be serving multiple database backends. Select the appropriate one */
- if (slapi_mapping_tree_select(pb, &be, &referral, NULL) != LDAP_SUCCESS) {
+ if (slapi_mapping_tree_select(pb, &be, &referral, NULL, 0) != LDAP_SUCCESS) {
send_nobackend_ldap_result( pb );
be = NULL;
goto free_and_return;
@@ -685,7 +685,7 @@ do_bind( Slapi_PBlock *pb )
Slapi_DN *pb_sdn;
slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &pb_sdn);
if (!pb_sdn) {
- slapi_create_errormsg(errorbuf, 0, "Pre-bind plug-in set NULL dn\n");
+ slapi_create_errormsg(errorbuf, sizeof(errorbuf), "Pre-bind plug-in set NULL dn\n");
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
goto free_and_return;
} else if ((pb_sdn != sdn) || (sdn_updated = slapi_sdn_compare(original_sdn, pb_sdn))) {
@@ -696,7 +696,7 @@ do_bind( Slapi_PBlock *pb )
sdn = pb_sdn;
dn = slapi_sdn_get_dn(sdn);
if (!dn) {
- slapi_create_errormsg(errorbuf, 0, "Pre-bind plug-in set corrupted dn\n");
+ slapi_create_errormsg(errorbuf, sizeof(errorbuf), "Pre-bind plug-in set corrupted dn\n");
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
goto free_and_return;
}
@@ -710,7 +710,7 @@ do_bind( Slapi_PBlock *pb )
slapi_be_Rlock(be);
slapi_pblock_set( pb, SLAPI_BACKEND, be );
} else {
- slapi_create_errormsg(errorbuf, 0, "No matching backend for %s\n", dn);
+ slapi_create_errormsg(errorbuf, sizeof(errorbuf), "No matching backend for %s\n", dn);
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
goto free_and_return;
}
diff --git a/ldap/servers/slapd/compare.c b/ldap/servers/slapd/compare.c
index 36a5be89d..39774528d 100644
--- a/ldap/servers/slapd/compare.c
+++ b/ldap/servers/slapd/compare.c
@@ -119,7 +119,7 @@ do_compare( Slapi_PBlock *pb )
* We could be serving multiple database backends. Select the
* appropriate one.
*/
- if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf)) != LDAP_SUCCESS) {
+ if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf, sizeof(errorbuf))) != LDAP_SUCCESS) {
send_ldap_result(pb, err, NULL, errorbuf, 0, NULL);
be = NULL;
goto free_and_return;
diff --git a/ldap/servers/slapd/delete.c b/ldap/servers/slapd/delete.c
index b2d840894..6b7488d81 100644
--- a/ldap/servers/slapd/delete.c
+++ b/ldap/servers/slapd/delete.c
@@ -290,7 +290,7 @@ static void op_shared_delete (Slapi_PBlock *pb)
* We could be serving multiple database backends. Select the
* appropriate one.
*/
- if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf)) != LDAP_SUCCESS) {
+ if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf, sizeof(errorbuf))) != LDAP_SUCCESS) {
send_ldap_result(pb, err, NULL, errorbuf, 0, NULL);
be = NULL;
goto free_and_return;
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index dffd67e6d..a9334e48f 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1814,7 +1814,7 @@ config_value_is_null( const char *attrname, const char *value, char *errorbuf,
int or_zero_length )
{
if ( NULL == value || ( or_zero_length && *value == '\0' )) {
- slapi_create_errormsg(errorbuf, 0, "%s: deleting the value is not allowed.", attrname);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: deleting the value is not allowed.", attrname);
return 1;
}
@@ -1869,7 +1869,7 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in
errno = 0;
threshold = strtoll(value, &endp, 10);
if ( *endp != '\0' || threshold <= 4096 || errno == ERANGE ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid, threshold must be greater than 4096 and less then %lld",
attrname, value, (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
@@ -1910,7 +1910,7 @@ config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf,
period = strtol(value, &endp, 10);
if ( *endp != '\0' || period < 1 || errno == ERANGE ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid, grace period must be at least 1 minute", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -1947,7 +1947,7 @@ config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf,
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
retVal = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) is invalid\n", attrname, value);
return retVal;
}
@@ -1955,7 +1955,7 @@ config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf,
size = 0; /* same as -1 */
}
if(size > 0 && size < 1024000){
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"ndn_cache_max_size too low(%d), changing to %d bytes.\n",(int)size, NDN_DEFAULT_SIZE);
size = NDN_DEFAULT_SIZE;
}
@@ -1980,12 +1980,12 @@ config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, in
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
retVal = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) is invalid\n", attrname, value);
return retVal;
}
if(size < default_size){
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"nsslapd-sasl-max-buffer-size is too low (%ld), setting to default value (%ld).\n",
size, default_size);
size = default_size;
@@ -2025,7 +2025,7 @@ config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
nPort = strtol(port, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort < 0 ) {
retVal = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid, ports must range from 0 to %d", attrname, port, LDAP_PORT_MAX);
return retVal;
}
@@ -2060,7 +2060,7 @@ config_set_secureport( const char *attrname, char *port, char *errorbuf, int app
nPort = strtol(port, &endp, 10);
if (*endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort <= 0 ) {
retVal = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid, ports must range from 1 to %d", attrname, port, LDAP_PORT_MAX);
}
@@ -2089,7 +2089,7 @@ config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int
strcasecmp (value, "allowed") != 0 &&
strcasecmp (value, "required")!= 0 ) {
retVal = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0, "%s: unsupported value: %s", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: unsupported value: %s", attrname, value);
return retVal;
}
else if ( !apply ) {
@@ -2110,7 +2110,7 @@ config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int
}
else {
retVal = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0, "%s: unsupported value: %s", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: unsupported value: %s", attrname, value);
}
CFG_UNLOCK_WRITE(slapdFrontendConfig);
@@ -2190,7 +2190,7 @@ config_set_snmp_index(const char *attrname, char *value, char *errorbuf, int app
snmp_index = strtol(value, &endp, 10);
if (*endp != '\0' || errno == ERANGE || snmp_index < snmp_index_disable) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", %s must be greater or equal to %lu (%lu means disabled)",
attrname, value, CONFIG_SNMP_INDEX_ATTRIBUTE, snmp_index_disable, snmp_index_disable);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2454,7 +2454,7 @@ config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int app
sizelimit = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || sizelimit < -1 ) {
- slapi_create_errormsg(errorbuf, 0, "%s: \"%s\" is invalid, sizelimit must range from -1 to %lld",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, sizelimit must range from -1 to %lld",
attrname, value, (long long int)LONG_MAX );
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -2498,7 +2498,7 @@ config_set_pagedsizelimit( const char *attrname, char *value, char *errorbuf, in
pagedsizelimit = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || pagedsizelimit < -1 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid, pagedsizelimit must range from -1 to %lld",
attrname, value, (long long int)LONG_MAX );
retVal = LDAP_OPERATIONS_ERROR;
@@ -2540,10 +2540,10 @@ config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf,
new_scheme = pw_name2scheme(value);
if ( new_scheme == NULL) {
if ( scheme_list != NULL ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid scheme - %s. Valid schemes are: %s",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid scheme - %s. Valid schemes are: %s",
attrname, value, scheme_list );
} else {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid scheme - %s (no pwdstorage scheme plugin loaded)",
attrname, value);
}
@@ -2559,7 +2559,7 @@ config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf,
they are in clear. We don't take it */
if (scheme_list) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list);
}
retVal = LDAP_UNWILLING_TO_PERFORM;
@@ -2720,7 +2720,7 @@ config_set_pw_minlength( const char *attrname, char *value, char *errorbuf, int
minLength = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minLength < 2 || minLength > 512 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum length \"%s\" is invalid. The minimum length must range from 2 to 512.", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -2753,7 +2753,7 @@ config_set_pw_mindigits( const char *attrname, char *value, char *errorbuf, int
minDigits = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minDigits < 0 || minDigits > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum number of digits \"%s\" is invalid. "
"The minimum number of digits must range from 0 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2787,7 +2787,7 @@ config_set_pw_minalphas( const char *attrname, char *value, char *errorbuf, int
minAlphas = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minAlphas < 0 || minAlphas > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum number of alphas \"%s\" is invalid. "
"The minimum number of alphas must range from 0 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2821,7 +2821,7 @@ config_set_pw_minuppers( const char *attrname, char *value, char *errorbuf, int
minUppers = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minUppers < 0 || minUppers > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum number of uppercase characters \"%s\" is invalid. "
"The minimum number of uppercase characters must range from 0 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2855,7 +2855,7 @@ config_set_pw_minlowers( const char *attrname, char *value, char *errorbuf, int
minLowers = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minLowers < 0 || minLowers > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum number of lowercase characters \"%s\" is invalid. "
"The minimum number of lowercase characters must range from 0 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2889,7 +2889,7 @@ config_set_pw_minspecials( const char *attrname, char *value, char *errorbuf, in
minSpecials = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minSpecials < 0 || minSpecials > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum number of special characters \"%s\" is invalid. "
"The minimum number of special characters must range from 0 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2923,7 +2923,7 @@ config_set_pw_min8bit( const char *attrname, char *value, char *errorbuf, int ap
min8bit = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || min8bit < 0 || min8bit > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum number of 8-bit characters \"%s\" is invalid. "
"The minimum number of 8-bit characters must range from 0 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2957,7 +2957,7 @@ config_set_pw_maxrepeats( const char *attrname, char *value, char *errorbuf, int
maxRepeats = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || maxRepeats < 0 || maxRepeats > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password maximum number of repeated characters \"%s\" is invalid. "
"The maximum number of repeated characters must range from 0 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -2991,7 +2991,7 @@ config_set_pw_mincategories( const char *attrname, char *value, char *errorbuf,
minCategories = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minCategories < 1 || minCategories > 5 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum number of categories \"%s\" is invalid. "
"The minimum number of categories must range from 1 to 5.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -3025,7 +3025,7 @@ config_set_pw_mintokenlength( const char *attrname, char *value, char *errorbuf,
minTokenLength = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || minTokenLength < 1 || minTokenLength > 64 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password minimum token length \"%s\" is invalid. "
"The minimum token length must range from 1 to 64.", value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -3059,7 +3059,7 @@ config_set_pw_maxfailure( const char *attrname, char *value, char *errorbuf, int
maxFailure = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || maxFailure <= 0 || maxFailure > 32767 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password maximum retry \"%s\" is invalid. Password maximum failure must range from 1 to 32767", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -3094,7 +3094,7 @@ config_set_pw_inhistory( const char *attrname, char *value, char *errorbuf, int
history = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || history < 1 || history > 24 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password history length \"%s\" is invalid. The password history must range from 1 to 24", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -3128,7 +3128,7 @@ config_set_pw_lockduration( const char *attrname, char *value, char *errorbuf, i
duration = parse_duration(value);
if ( errno == ERANGE || duration <= 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- slapi_create_errormsg(errorbuf, 0, "password lockout duration \"%s\" is invalid. ", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "password lockout duration \"%s\" is invalid. ", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3157,7 +3157,7 @@ config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorb
duration = parse_duration(value);
if ( errno == ERANGE || duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- slapi_create_errormsg(errorbuf, 0, "password reset count duration \"%s\" is invalid. ", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "password reset count duration \"%s\" is invalid. ", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3299,7 +3299,7 @@ config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int
gracelimit = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || gracelimit < 0 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"password grace limit \"%s\" is invalid, password grace limit must range from 0 to %lld",
value , (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
@@ -3522,7 +3522,7 @@ config_set_onoff(const char *attrname, char *value, int *configvalue, char *erro
CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
if (strcasecmp(value, "on") && strcasecmp(value, "off")) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\". Valid values are \"on\" or \"off\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}
@@ -3725,7 +3725,7 @@ config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply
/* pwd enc func returns slapi_ch_malloc memory */
slapdFrontendConfig->rootpw = (slapdFrontendConfig->rootpwstoragescheme->pws_enc)(value);
} else {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: password scheme mismatch (passwd scheme is %s; password is clear text)",
attrname, slapdFrontendConfig->rootpwstoragescheme->pws_name);
retVal = LDAP_PARAM_ERROR;
@@ -3751,10 +3751,10 @@ config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbu
if (errorbuf) {
char * scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
if ( scheme_list ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid scheme - %s. Valid schemes are: %s",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid scheme - %s. Valid schemes are: %s",
attrname, value, scheme_list );
} else {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid scheme - %s (no pwdstorage scheme plugin loaded)", attrname, value);
}
slapi_ch_free_string(&scheme_list);
@@ -3834,12 +3834,12 @@ config_set_workingdir( const char *attrname, char *value, char *errorbuf, int ap
}
if ( PR_Access ( value, PR_ACCESS_EXISTS ) != 0 ) {
- slapi_create_errormsg(errorbuf, 0, "Working directory \"%s\" does not exist.", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" does not exist.", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
if ( PR_Access ( value, PR_ACCESS_WRITE_OK ) != 0 ) {
- slapi_create_errormsg(errorbuf, 0, "Working directory \"%s\" is not writeable.", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" is not writeable.", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3889,7 +3889,7 @@ config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int
threadnum = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || threadnum < 1 || threadnum > 65535 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", maximum thread number must range from 1 to 65535", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}
@@ -3919,7 +3919,7 @@ config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf,
maxthreadnum = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || maxthreadnum < 1 || maxthreadnum > 65535 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", maximum thread number per connection must range from 1 to 65535",
attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
@@ -3960,7 +3960,7 @@ config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, in
nValue = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", maximum file descriptors must range from 1 to %d (the current process limit). "
"Server will use a setting of %d.", attrname, value, maxVal, maxVal);
if ( nValue > maxVal ) {
@@ -4001,7 +4001,7 @@ config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int
nValue = strtol(value, &endp, 0);
if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", connection table size must range from 1 to %d (the current process maxdescriptors limit). "
"Server will use a setting of %d.", attrname, value, maxVal, maxVal );
if ( nValue > maxVal) {
@@ -4043,7 +4043,7 @@ config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf
nValue = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", reserved file descriptors must range from 1 to %d (the current process maxdescriptors limit). "
"Server will use a setting of %d.", attrname, value, maxVal, maxVal);
if ( nValue > maxVal) {
@@ -4079,7 +4079,7 @@ config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, in
nValue = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || nValue < 0 ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %lld",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %lld",
attrname, value, (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -4115,7 +4115,7 @@ config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int a
nValue = strtol(value, &endp, 10);
if (*endp != '\0' || errno == ERANGE || nValue < 0 ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\", idle timeout must range from 0 to %lld",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", idle timeout must range from 0 to %lld",
attrname, value, (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -4148,7 +4148,7 @@ config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbu
nValue = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || nValue < 0 || nValue > 5 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", group eval nest level must range from 0 to 5", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -4214,7 +4214,7 @@ config_set_timelimit( const char *attrname, char *value, char *errorbuf, int app
nVal = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || nVal < -1 ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", time limit must range from -1 to %lld",
attrname, value, (long long int)LONG_MAX );
retVal = LDAP_OPERATIONS_ERROR;
@@ -4268,7 +4268,7 @@ config_set_accesslog( const char *attrname, char *value, char *errorbuf, int app
retVal = log_update_accesslogdir ( value, apply );
if (retVal != LDAP_SUCCESS) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"Cannot open accesslog directory \"%s\", client accesses will not be logged.", value);
}
@@ -4293,7 +4293,7 @@ config_set_errorlog( const char *attrname, char *value, char *errorbuf, int appl
retVal = log_update_errorlogdir ( value, apply );
if ( retVal != LDAP_SUCCESS ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...", value);
syslog(LOG_ERR,
"Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...", value);
@@ -4321,7 +4321,7 @@ config_set_auditlog( const char *attrname, char *value, char *errorbuf, int appl
retVal = log_update_auditlogdir ( value, apply );
if (retVal != LDAP_SUCCESS) {
- slapi_create_errormsg(errorbuf, 0, "Cannot open auditlog directory \"%s\"", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Cannot open auditlog directory \"%s\"", value);
}
if ( apply ) {
@@ -4345,7 +4345,7 @@ config_set_auditfaillog( const char *attrname, char *value, char *errorbuf, int
retVal = log_update_auditfaillogdir ( value, apply );
if (retVal != LDAP_SUCCESS) {
- slapi_create_errormsg(errorbuf, 0, "Cannot open auditfaillog directory \"%s\"", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Cannot open auditfaillog directory \"%s\"", value);
}
if ( apply ) {
@@ -4373,7 +4373,7 @@ config_set_pw_maxage( const char *attrname, char *value, char *errorbuf, int app
age = parse_duration(value);
if ( age <= 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- slapi_create_errormsg(errorbuf, 0, "%s: password maximum age \"%s\" is invalid.", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: password maximum age \"%s\" is invalid.", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -4398,7 +4398,7 @@ config_set_pw_minage( const char *attrname, char *value, char *errorbuf, int app
/* age in seconds */
age = parse_duration(value);
if ( age < 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- slapi_create_errormsg(errorbuf, 0, "%s: password minimum age \"%s\" is invalid.", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: password minimum age \"%s\" is invalid.", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -4425,7 +4425,7 @@ config_set_pw_warning( const char *attrname, char *value, char *errorbuf, int ap
sec = parse_duration(value);
if (errno == ERANGE || sec < 0) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: password warning age \"%s\" is invalid, password warning "
"age must range from 0 to %lld seconds",
attrname, value, (long long int)LONG_MAX );
@@ -4457,7 +4457,7 @@ config_set_errorlog_level( const char *attrname, char *value, char *errorbuf, in
level = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
- slapi_create_errormsg(errorbuf, 0, "%s: error log level \"%s\" is invalid,"
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: error log level \"%s\" is invalid,"
" error log level must range from 0 to %lld",
attrname, value, (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
@@ -4492,7 +4492,7 @@ config_set_accesslog_level( const char *attrname, char *value, char *errorbuf, i
level = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
- slapi_create_errormsg(errorbuf, 0, "%s: access log level \"%s\" is invalid,"
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: access log level \"%s\" is invalid,"
" access log level must range from 0 to %lld",
attrname, value, (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
@@ -4516,7 +4516,7 @@ int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, in
slapdFrontendConfig->refer_mode=REFER_MODE_OFF;
if ((!url) || (!url[0])) {
- slapi_create_errormsg(errorbuf, 0, "referral url must have a value");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "referral url must have a value");
return LDAP_OPERATIONS_ERROR;
}
if (apply) {
@@ -4533,7 +4533,7 @@ config_set_versionstring( const char *attrname, char *version, char *errorbuf, i
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
if ((!version) || (!version[0])) {
- slapi_create_errormsg(errorbuf, 0, "versionstring must have a value");
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "versionstring must have a value");
return LDAP_OPERATIONS_ERROR;
}
if (apply) {
@@ -5909,7 +5909,7 @@ config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int ap
errno = 0;
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
- slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n",attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) is invalid\n",attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -5974,7 +5974,7 @@ config_set_maxsasliosize( const char *attrname, char *value, char *errorbuf, int
}
if (retVal != LDAP_SUCCESS) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid. Value must range from -1 to %lld",
attrname, value, (long long int)LONG_MAX);
} else if (apply) {
@@ -6028,7 +6028,7 @@ config_set_localssf( const char *attrname, char *value, char *errorbuf, int appl
}
if (retVal != LDAP_SUCCESS) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid. Value must range from 0 to %d", attrname, value, INT_MAX);
} else if (apply) {
CFG_LOCK_WRITE(slapdFrontendConfig);
@@ -6070,7 +6070,7 @@ config_set_minssf( const char *attrname, char *value, char *errorbuf, int apply
}
if (retVal != LDAP_SUCCESS) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%s\" is invalid. Value must range from 0 to %d", attrname, value, INT_MAX);
} else if (apply) {
CFG_LOCK_WRITE(slapdFrontendConfig);
@@ -6147,7 +6147,7 @@ config_set_max_filter_nest_level( const char *attrname, char *value,
errno = 0;
level = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
- slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) " "is invalid\n",attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) " "is invalid\n",attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -6836,7 +6836,7 @@ config_set_schemareplace( const char *attrname, char *value, char *errorbuf, int
0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_ON ) &&
0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY )) {
retVal = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0, "unsupported value: %s", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "unsupported value: %s", value);
}
}
@@ -6868,7 +6868,7 @@ config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
errno = 0;
timeout = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
- slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n",attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) is invalid\n",attrname, value);
return LDAP_OPERATIONS_ERROR;
}
@@ -6926,7 +6926,7 @@ config_set_anon_access_switch( const char *attrname, char *value,
if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
(strcasecmp(value, "rootdse") != 0)) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\". Valid values are \"on\", \"off\", or \"rootdse\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}
@@ -6963,7 +6963,7 @@ config_set_validate_cert_switch( const char *attrname, char *value,
if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
(strcasecmp(value, "warn") != 0)) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\". Valid values are \"on\", \"off\", or \"warn\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}
@@ -7217,7 +7217,7 @@ config_set_default_naming_context(const char *attrname,
int in_init = 0;
suffix = slapi_create_dn_string("%s", value);
if (NULL == suffix) {
- slapi_create_errormsg(errorbuf, 0, "%s is not a valid suffix.", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s is not a valid suffix.", value);
return LDAP_INVALID_DN_SYNTAX;
}
sdn = slapi_get_first_suffix(&node, 0);
@@ -7232,7 +7232,7 @@ config_set_default_naming_context(const char *attrname,
sdn = slapi_get_next_suffix(&node, 0);
}
if (!in_init && (NULL == sdn)) { /* not in startup && no match */
- slapi_create_errormsg(errorbuf, 0, "%s is not an existing suffix.", value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s is not an existing suffix.", value);
slapi_ch_free_string(&suffix);
return LDAP_NO_SUCH_OBJECT;
}
@@ -7273,7 +7273,7 @@ config_set_unhashed_pw_switch(const char *attrname, char *value,
if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
(strcasecmp(value, "nolog") != 0)) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\". Valid values are \"on\", \"off\", or \"nolog\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}
@@ -7464,7 +7464,7 @@ config_set_connection_buffer( const char *attrname, char *value,
if ((strcasecmp(value, "0") != 0) && (strcasecmp(value, "1") != 0) &&
(strcasecmp(value, "2") != 0)) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\". Valid values are \"0\", \"1\", or \"2\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}
@@ -7492,7 +7492,7 @@ config_set_listen_backlog_size( const char *attrname, char *value,
errno = 0;
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
- slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) is invalid\n", attrname, value);
return LDAP_OPERATIONS_ERROR;
}
@@ -7573,7 +7573,7 @@ config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
#if 0
debugHashTable(attr);
#endif
- slapi_create_errormsg(errorbuf, 0, "Unknown attribute %s will be ignored", attr);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr);
slapi_log_error(SLAPI_LOG_FATAL, "config_set", "Unknown attribute %s will be ignored", attr);
return LDAP_NO_SUCH_ATTRIBUTE;
}
@@ -8007,7 +8007,7 @@ config_set_maxsimplepaged_per_conn( const char *attrname, char *value, char *err
errno = 0;
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
- slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n", attrname, value);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) is invalid\n", attrname, value);
return LDAP_OPERATIONS_ERROR;
}
@@ -8068,7 +8068,7 @@ config_set_malloc_mxfast(const char *attrname, char *value, char *errorbuf, int
errno = 0;
mxfast = strtol(value, &endp, 10);
if ((*endp != '\0') || (errno == ERANGE)) {
- slapi_create_errormsg(errorbuf, 0, "limit \"%s\" is invalid, %s must range from 0 to %d",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "limit \"%s\" is invalid, %s must range from 0 to %d",
value, CONFIG_MALLOC_MXFAST, max);
return LDAP_OPERATIONS_ERROR;
}
@@ -8109,7 +8109,7 @@ config_set_malloc_trim_threshold(const char *attrname, char *value, char *errorb
errno = 0;
trim_threshold = strtol(value, &endp, 10);
if ((*endp != '\0') || (errno == ERANGE)) {
- slapi_create_errormsg(errorbuf, 0, "limit \"%s\" is invalid, %s must range from 0 to %lld",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "limit \"%s\" is invalid, %s must range from 0 to %lld",
value, CONFIG_MALLOC_TRIM_THRESHOLD, (long long int)LONG_MAX);
return LDAP_OPERATIONS_ERROR;
}
@@ -8158,7 +8158,7 @@ config_set_malloc_mmap_threshold(const char *attrname, char *value, char *errorb
errno = 0;
mmap_threshold = strtol(value, &endp, 10);
if ((*endp != '\0') || (errno == ERANGE)) {
- slapi_create_errormsg(errorbuf, 0, "limit \"%s\" is invalid, %s must range from 0 to %d",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "limit \"%s\" is invalid, %s must range from 0 to %d",
value, CONFIG_MALLOC_MMAP_THRESHOLD, max);
return LDAP_OPERATIONS_ERROR;
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index d26b8acc0..a16c39557 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -310,7 +310,7 @@ log_set_logging(const char *attrname, char *value, int logtype, char *errorbuf,
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
if ( NULL == value ) {
- slapi_create_errormsg(errorbuf, 0, "%s: NULL value; valid values are \"on\" or \"off\"", attrname);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: NULL value; valid values are \"on\" or \"off\"", attrname);
return LDAP_OPERATIONS_ERROR;
}
@@ -321,7 +321,7 @@ log_set_logging(const char *attrname, char *value, int logtype, char *errorbuf,
v = 0;
}
else {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\", valid values are \"on\" or \"off\"",
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", valid values are \"on\" or \"off\"",
attrname, value);
return LDAP_OPERATIONS_ERROR;
}
@@ -759,7 +759,7 @@ log_set_mode (const char *attrname, char *value, int logtype, char *errorbuf, in
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
if ( NULL == value ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: null value; valid values are are of the format \"yz-yz-yz-\" where y could be 'r' or '-',"
" and z could be 'w' or '-'", attrname );
return LDAP_OPERATIONS_ERROR;
@@ -777,7 +777,7 @@ log_set_mode (const char *attrname, char *value, int logtype, char *errorbuf, in
if (loginfo.log_access_file &&
( chmod( loginfo.log_access_file, v ) != 0) ) {
int oserr = errno;
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: Failed to chmod access log file to %s: errno %d (%s)",
attrname, value, oserr, slapd_system_strerror(oserr));
retval = LDAP_UNWILLING_TO_PERFORM;
@@ -793,7 +793,7 @@ log_set_mode (const char *attrname, char *value, int logtype, char *errorbuf, in
if (loginfo.log_error_file &&
( chmod( loginfo.log_error_file, v ) != 0) ) {
int oserr = errno;
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: Failed to chmod error log file to %s: errno %d (%s)",
attrname, value, oserr, slapd_system_strerror(oserr));
retval = LDAP_UNWILLING_TO_PERFORM;
@@ -809,7 +809,7 @@ log_set_mode (const char *attrname, char *value, int logtype, char *errorbuf, in
if (loginfo.log_audit_file &&
( chmod( loginfo.log_audit_file, v ) != 0) ) {
int oserr = errno;
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: Failed to chmod audit log file to %s: errno %d (%s)",
attrname, value, oserr, slapd_system_strerror(oserr));
retval = LDAP_UNWILLING_TO_PERFORM;
@@ -1014,7 +1014,7 @@ log_set_rotationsync_enabled(const char *attrname, char *value, int logtype, cha
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
if ( NULL == value ) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: NULL value; valid values are \"on\" or \"off\"", attrname);
return LDAP_OPERATIONS_ERROR;
}
@@ -1026,7 +1026,7 @@ log_set_rotationsync_enabled(const char *attrname, char *value, int logtype, cha
v = LDAP_OFF;
}
else {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: invalid value \"%s\", valid values are \"on\" or \"off\"", attrname, value);
return LDAP_OPERATIONS_ERROR;
}
@@ -1304,7 +1304,7 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
logtype != SLAPD_ERROR_LOG &&
logtype != SLAPD_AUDIT_LOG &&
logtype != SLAPD_AUDITFAIL_LOG ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid log type: %d", attrname, logtype);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid log type: %d", attrname, logtype);
return LDAP_OPERATIONS_ERROR;
}
@@ -1315,7 +1315,7 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
(strcasecmp(runit, "minute") == 0)) {
/* all good values */
} else {
- slapi_create_errormsg(errorbuf, 0, "%s: unknown unit \"%s\"", attrname, runit);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: unknown unit \"%s\"", attrname, runit);
rv = LDAP_OPERATIONS_ERROR;
}
@@ -1423,7 +1423,7 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
logtype != SLAPD_ERROR_LOG &&
logtype != SLAPD_AUDIT_LOG &&
logtype != SLAPD_AUDITFAIL_LOG ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid log type: %d", attrname, logtype);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid log type: %d", attrname, logtype);
return LDAP_OPERATIONS_ERROR;
}
@@ -1456,7 +1456,7 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
maxdiskspace = -1;
} else if (maxdiskspace < mlogsize) {
rv = LDAP_OPERATIONS_ERROR;
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
"%s: \"%d (MB)\" is less than max log size \"%d (MB)\"",
attrname, s_maxdiskspace, (int)(mlogsize/LOG_MB_IN_BYTES));
}
@@ -1513,7 +1513,7 @@ log_set_mindiskspace(const char *attrname, char *minfreespace_str, int logtype,
logtype != SLAPD_ERROR_LOG &&
logtype != SLAPD_AUDIT_LOG &&
logtype != SLAPD_AUDITFAIL_LOG ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid log type: %d", attrname, logtype);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid log type: %d", attrname, logtype);
rv = LDAP_OPERATIONS_ERROR;
}
@@ -1578,7 +1578,7 @@ log_set_expirationtime(const char *attrname, char *exptime_str, int logtype, cha
logtype != SLAPD_ERROR_LOG &&
logtype != SLAPD_AUDIT_LOG &&
logtype != SLAPD_AUDITFAIL_LOG ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid log type: %d", attrname, logtype);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid log type: %d", attrname, logtype);
rv = LDAP_OPERATIONS_ERROR;
}
@@ -1684,12 +1684,12 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
logtype != SLAPD_ERROR_LOG &&
logtype != SLAPD_AUDIT_LOG &&
logtype != SLAPD_AUDITFAIL_LOG ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid log type: %d", attrname, logtype);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid log type: %d", attrname, logtype);
return LDAP_OPERATIONS_ERROR;
}
if ( NULL == expunit ) {
- slapi_create_errormsg(errorbuf, 0, "%s: NULL value", attrname);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: NULL value", attrname);
return LDAP_OPERATIONS_ERROR;
}
@@ -1698,7 +1698,7 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
(strcasecmp(expunit, "day") == 0)) {
/* we have good values */
} else {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid time unit \"%s\"", attrname, expunit);
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid time unit \"%s\"", attrname, expunit);
rv = LDAP_OPERATIONS_ERROR;;
}
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index ed0b51034..df66f30c3 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -120,7 +120,7 @@ static void mtn_free_node (mapping_tree_node **node);
static int mtn_get_be_distributed(Slapi_PBlock *pb,
mapping_tree_node * target_node, Slapi_DN *target_sdn, int * flag_stop);
static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
- Slapi_Backend **be, int * index, Slapi_Entry **referral, char *errorbuf);
+ Slapi_Backend **be, int * index, Slapi_Entry **referral, char *errorbuf, size_t ebuflen);
static mapping_tree_node * mtn_get_next_node(mapping_tree_node * node,
mapping_tree_node * node_list, int scope);
static mapping_tree_node * mtn_get_first_node(mapping_tree_node * node,
@@ -1872,7 +1872,7 @@ mtn_get_first_node(mapping_tree_node * node, int scope)
int slapi_mtn_get_first_be(mapping_tree_node * node_list,
mapping_tree_node ** node, Slapi_PBlock *pb, Slapi_Backend **be,
- int * be_index, Slapi_Entry **referral, char *errorbuf, int scope)
+ int * be_index, Slapi_Entry **referral, char *errorbuf, size_t ebuflen, int scope)
{
*node = mtn_get_first_node(node_list, scope);
if (scope == LDAP_SCOPE_BASE)
@@ -1880,12 +1880,12 @@ int slapi_mtn_get_first_be(mapping_tree_node * node_list,
else
*be_index = 0;
- return mtn_get_be(*node, pb, be, be_index, referral, errorbuf);
+ return mtn_get_be(*node, pb, be, be_index, referral, errorbuf, ebuflen);
}
int slapi_mtn_get_next_be(mapping_tree_node * node_list,
mapping_tree_node ** node, Slapi_PBlock *pb, Slapi_Backend **be,
- int * be_index, Slapi_Entry **referral, char *errorbuf, int scope)
+ int * be_index, Slapi_Entry **referral, char *errorbuf, size_t ebuflen, int scope)
{
int rc;
@@ -1908,7 +1908,7 @@ int slapi_mtn_get_next_be(mapping_tree_node * node_list,
return 0;
}
- rc = mtn_get_be(*node, pb, be, be_index, referral, errorbuf);
+ rc = mtn_get_be(*node, pb, be, be_index, referral, errorbuf, ebuflen);
if (rc != LDAP_SUCCESS)
{
@@ -1925,7 +1925,7 @@ int slapi_mtn_get_next_be(mapping_tree_node * node_list,
return 0;
}
*be_index = 0;
- return mtn_get_be(*node, pb, be, be_index, referral, errorbuf);
+ return mtn_get_be(*node, pb, be, be_index, referral, errorbuf, ebuflen);
}
return LDAP_SUCCESS;
@@ -2135,7 +2135,7 @@ int slapi_dn_write_needs_referral(Slapi_DN *target_sdn, Slapi_Entry **referral)
* Returns:
* LDAP_SUCCESS on success, other LDAP result codes if there is a problem.
*/
-int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry **referral, char *errorbuf)
+int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry **referral, char *errorbuf, size_t ebuflen)
{
Slapi_DN *target_sdn = NULL;
mapping_tree_node *target_node;
@@ -2204,7 +2204,7 @@ int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry
* used for BASE search, ADD, DELETE, MODIFY
*/
index = -1;
- ret = mtn_get_be(target_node, pb, be, &index, referral, errorbuf);
+ ret = mtn_get_be(target_node, pb, be, &index, referral, errorbuf, ebuflen);
slapi_pblock_set(pb, SLAPI_BACKEND_COUNT, &index);
mtn_unlock();
@@ -2227,7 +2227,7 @@ int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry
{
if (errorbuf) {
PL_strncpyz(errorbuf, slapi_config_get_readonly() ?
- "Server is read-only" : "database is read-only", sizeof(errorbuf));
+ "Server is read-only" : "database is read-only", ebuflen);
}
ret = LDAP_UNWILLING_TO_PERFORM;
slapi_be_Unlock(*be);
@@ -2239,7 +2239,7 @@ int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry
}
int slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list,
- Slapi_Entry **referral_list, char *errorbuf)
+ Slapi_Entry **referral_list, char *errorbuf, size_t ebuflen)
{
Slapi_DN *target_sdn = NULL;
mapping_tree_node *node_list;
@@ -2306,7 +2306,7 @@ int slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list,
return ret_code;
}
- ret = slapi_mtn_get_first_be(node_list, &node, pb, &be, &index, &referral, errorbuf, scope);
+ ret = slapi_mtn_get_first_be(node_list, &node, pb, &be, &index, &referral, errorbuf, ebuflen, scope);
while ((node) && (be_index <= BE_LIST_SIZE))
{
@@ -2335,7 +2335,7 @@ int slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list,
if (be && !be_isdeleted(be))
{
if (be_index == BE_LIST_SIZE) { /* error - too many backends */
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, ebuflen,
"Error: too many backends match search request - cannot proceed");
slapi_log_error(SLAPI_LOG_FATAL, "mapping_tree",
"Error: too many backends match search request - cannot proceed");
@@ -2363,7 +2363,7 @@ int slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list,
}
ret = slapi_mtn_get_next_be(node_list, &node, pb, &be, &index,
- &referral, errorbuf, scope);
+ &referral, errorbuf, ebuflen, scope);
}
mtn_unlock();
be_list[be_index] = NULL;
@@ -2424,7 +2424,7 @@ void slapi_mapping_tree_free_all(Slapi_Backend **be_list, Slapi_Entry **referral
/* same as slapi_mapping_tree_select() but will also check that the supplied
* newdn is in the same backend
*/
-int slapi_mapping_tree_select_and_check(Slapi_PBlock *pb,char *newdn, Slapi_Backend **be, Slapi_Entry **referral, char *errorbuf)
+int slapi_mapping_tree_select_and_check(Slapi_PBlock *pb,char *newdn, Slapi_Backend **be, Slapi_Entry **referral, char *errorbuf, size_t ebuflen)
{
Slapi_DN *target_sdn = NULL;
Slapi_DN dn_newdn;
@@ -2446,7 +2446,7 @@ int slapi_mapping_tree_select_and_check(Slapi_PBlock *pb,char *newdn, Slapi_Back
target_sdn = operation_get_target_spec (op);
* referral = NULL;
- ret = slapi_mapping_tree_select(pb, be, referral, errorbuf);
+ ret = slapi_mapping_tree_select(pb, be, referral, errorbuf, ebuflen);
if (ret)
goto unlock_and_return;
@@ -2460,7 +2460,7 @@ int slapi_mapping_tree_select_and_check(Slapi_PBlock *pb,char *newdn, Slapi_Back
if (target_node == NULL)
target_node = mapping_tree_root;
index = -1;
- ret = mtn_get_be(target_node, pb, &new_be, &index, &new_referral, errorbuf);
+ ret = mtn_get_be(target_node, pb, &new_be, &index, &new_referral, errorbuf, ebuflen);
if (ret)
goto unlock_and_return;
@@ -2470,7 +2470,7 @@ int slapi_mapping_tree_select_and_check(Slapi_PBlock *pb,char *newdn, Slapi_Back
const Slapi_DN *suffix = slapi_get_suffix_by_dn(target_sdn);
if ((*be != def_be) && (NULL == suffix))
{
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, ebuflen,
"Target entry \"%s\" does not exist\n", slapi_sdn_get_dn(target_sdn));
ret = LDAP_NO_SUCH_OBJECT;
goto unlock_and_return;
@@ -2484,25 +2484,25 @@ int slapi_mapping_tree_select_and_check(Slapi_PBlock *pb,char *newdn, Slapi_Back
if (!slapi_be_exist((const Slapi_DN *)&dn_newdn))
{
/* new_be is an empty backend */
- slapi_create_errormsg(errorbuf, 0, "Backend for suffix \"%s\" does not exist\n", newdn);
+ slapi_create_errormsg(errorbuf, ebuflen, "Backend for suffix \"%s\" does not exist\n", newdn);
ret = LDAP_NO_SUCH_OBJECT;
goto unlock_and_return;
}
if (0 == slapi_sdn_compare(&dn_newdn, new_suffix))
{
ret = LDAP_ALREADY_EXISTS;
- slapi_create_errormsg(errorbuf, 0, "Suffix \"%s\" already exists\n", newdn);
+ slapi_create_errormsg(errorbuf, ebuflen, "Suffix \"%s\" already exists\n", newdn);
goto unlock_and_return;
}
ret = LDAP_NAMING_VIOLATION;
- slapi_create_errormsg(errorbuf, 0, "Cannot rename suffix \"%s\"\n", slapi_sdn_get_dn(target_sdn));
+ slapi_create_errormsg(errorbuf, ebuflen, "Cannot rename suffix \"%s\"\n", slapi_sdn_get_dn(target_sdn));
goto unlock_and_return;
}
else
{
if ((*be != new_be) || mtn_sdn_has_child(target_sdn))
{
- slapi_create_errormsg(errorbuf, 0, "Cannot move entries across backends\n");
+ slapi_create_errormsg(errorbuf, ebuflen, "Cannot move entries across backends\n");
ret = LDAP_AFFECTS_MULTIPLE_DSAS;
goto unlock_and_return;
}
@@ -2613,7 +2613,7 @@ mtn_get_be_distributed(Slapi_PBlock *pb, mapping_tree_node * target_node,
* that position must be returned
*/
static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
- Slapi_Backend **be, int * index, Slapi_Entry **referral, char *errorbuf)
+ Slapi_Backend **be, int * index, Slapi_Entry **referral, char *errorbuf, size_t ebuflen)
{
Slapi_DN *target_sdn;
Slapi_Operation *op;
@@ -2633,7 +2633,7 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
target_sdn = operation_get_target_spec (op);
if (target_node->mtn_state == MTN_DISABLED) {
- slapi_create_errormsg(errorbuf, 0,
+ slapi_create_errormsg(errorbuf, ebuflen,
"Warning: Operation attempted on a disabled node : %s\n",
slapi_sdn_get_dn(target_node->mtn_subtree));
result = LDAP_OPERATIONS_ERROR;
@@ -2767,7 +2767,7 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
}
(*index)++;
if (NULL == target_node->mtn_referral_entry) {
- slapi_create_errormsg(errorbuf, 0, "Mapping tree node for %s is set to return a referral,"
+ slapi_create_errormsg(errorbuf, ebuflen, "Mapping tree node for %s is set to return a referral,"
" but no referral is configured for it", slapi_sdn_get_ndn(target_node->mtn_subtree));
result = LDAP_OPERATIONS_ERROR;
} else {
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index b0c474bed..438c9256e 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -66,7 +66,7 @@ mod_op_image (int op)
#endif
/* an AttrCheckFunc function should return an LDAP result code (LDAP_SUCCESS if all goes well). */
-typedef int (*AttrCheckFunc)(const char *attr_name, char *value, long minval, long maxval, char *errorbuf);
+typedef int (*AttrCheckFunc)(const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen);
static struct attr_value_check {
const char *attr_name; /* the name of the attribute */
@@ -711,7 +711,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
* appropriate one.
*/
errorbuf[0] = '\0';
- if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf)) != LDAP_SUCCESS) {
+ if ((err = slapi_mapping_tree_select(pb, &be, &referral, errorbuf, sizeof(errorbuf))) != LDAP_SUCCESS) {
send_ldap_result(pb, err, NULL, errorbuf, 0, NULL);
be = NULL;
goto free_and_return;
@@ -766,7 +766,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
*/
if ( (err = AttrValueCheckList[i].checkfunc (AttrValueCheckList[i].attr_name,
(*tmpmods)->mod_bvalues[0]->bv_val, AttrValueCheckList[i].minval,
- AttrValueCheckList[i].maxval, errorbuf))
+ AttrValueCheckList[i].maxval, errorbuf, sizeof(errorbuf)))
!= LDAP_SUCCESS)
{
/* return error */
diff --git a/ldap/servers/slapd/modrdn.c b/ldap/servers/slapd/modrdn.c
index 4edd07e80..992700ad3 100644
--- a/ldap/servers/slapd/modrdn.c
+++ b/ldap/servers/slapd/modrdn.c
@@ -572,7 +572,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
/* slapi_mapping_tree_select_and_check ignores the case of newdn
* which is generated using newrdn above. */
errorbuf[0] = '\0';
- if ((err = slapi_mapping_tree_select_and_check(pb, newdn, &be, &referral, errorbuf)) != LDAP_SUCCESS)
+ if ((err = slapi_mapping_tree_select_and_check(pb, newdn, &be, &referral, errorbuf, sizeof(errorbuf))) != LDAP_SUCCESS)
{
send_ldap_result(pb, err, NULL, errorbuf, 0, NULL);
goto free_and_return_nolock;
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 98505e984..29a1d847f 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -437,7 +437,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* no specific backend was requested, use the mapping tree
*/
errorbuf[0] = '\0';
- err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf);
+ err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf, sizeof(errorbuf));
if (((err_code != LDAP_SUCCESS) && (err_code != LDAP_OPERATIONS_ERROR) && (err_code != LDAP_REFERRAL))
|| ((err_code == LDAP_OPERATIONS_ERROR) && (be_list[0] == NULL))) {
send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 6c43817fb..b8d7b86f3 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -38,8 +38,8 @@ void do_add( Slapi_PBlock *pb );
void attr_done(Slapi_Attr *a);
int attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn);
int attr_replace(Slapi_Attr *a, Slapi_Value **vals);
-int attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
-int attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
+int attr_check_onoff(const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen);
+int attr_check_minmax(const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen);
/**
* Returns the function which can be used to compare (like memcmp/strcmp)
* two values of this type of attribute. The comparison function will use
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 4500e0d8f..703c9e9c7 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -2197,22 +2197,22 @@ pw_boolean_str2value (const char *str)
}
int
-check_pw_duration_value( const char *attr_name, char *value,
- long minval, long maxval, char *errorbuf )
+check_pw_duration_value(const char *attr_name, char *value,
+ long minval, long maxval, char *errorbuf, size_t ebuflen)
{
int retVal = LDAP_SUCCESS;
long age;
age = parse_duration(value);
if (-1 == age) {
- slapi_create_errormsg(errorbuf, 0, "password minimum age \"%s\" is invalid. ", value);
+ slapi_create_errormsg(errorbuf, ebuflen, "password minimum age \"%s\" is invalid. ", value);
retVal = LDAP_CONSTRAINT_VIOLATION;
} else if (0 == strcasecmp(CONFIG_PW_LOCKDURATION_ATTRIBUTE, attr_name)) {
if ( (age <= 0) ||
(age > (MAX_ALLOWED_TIME_IN_SECS - current_time())) ||
((-1 != minval) && (age < minval)) ||
((-1 != maxval) && (age > maxval))) {
- slapi_create_errormsg(errorbuf, 0, "%s: \"%s\" seconds is invalid. ", attr_name, value);
+ slapi_create_errormsg(errorbuf, ebuflen, "%s: \"%s\" seconds is invalid. ", attr_name, value);
retVal = LDAP_CONSTRAINT_VIOLATION;
}
} else {
@@ -2220,7 +2220,7 @@ check_pw_duration_value( const char *attr_name, char *value,
(age > (MAX_ALLOWED_TIME_IN_SECS - current_time())) ||
((-1 != minval) && (age < minval)) ||
((-1 != maxval) && (age > maxval))) {
- slapi_create_errormsg(errorbuf, 0, "%s: \"%s\" seconds is invalid. ", attr_name, value);
+ slapi_create_errormsg(errorbuf, ebuflen, "%s: \"%s\" seconds is invalid. ", attr_name, value);
retVal = LDAP_CONSTRAINT_VIOLATION;
}
}
@@ -2229,7 +2229,8 @@ check_pw_duration_value( const char *attr_name, char *value,
}
int
-check_pw_resetfailurecount_value( const char *attr_name, char *value, long minval, long maxval, char *errorbuf )
+check_pw_resetfailurecount_value(const char *attr_name, char *value,
+ long minval, long maxval, char *errorbuf, size_t ebuflen)
{
int retVal = LDAP_SUCCESS;
long duration = 0; /* in minutes */
@@ -2237,7 +2238,7 @@ check_pw_resetfailurecount_value( const char *attr_name, char *value, long minva
/* in seconds */
duration = strtol (value, NULL, 0);
if ( duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- slapi_create_errormsg(errorbuf, 0, "password reset count duration \"%s\" seconds is invalid.", value);
+ slapi_create_errormsg(errorbuf, ebuflen, "password reset count duration \"%s\" seconds is invalid.", value);
retVal = LDAP_CONSTRAINT_VIOLATION;
}
@@ -2245,7 +2246,8 @@ check_pw_resetfailurecount_value( const char *attr_name, char *value, long minva
}
int
-check_pw_storagescheme_value( const char *attr_name, char *value, long minval, long maxval, char *errorbuf )
+check_pw_storagescheme_value(const char *attr_name, char *value,
+ long minval, long maxval, char *errorbuf, size_t ebuflen)
{
int retVal = LDAP_SUCCESS;
struct pw_scheme *new_scheme = NULL;
@@ -2255,10 +2257,10 @@ check_pw_storagescheme_value( const char *attr_name, char *value, long minval, l
new_scheme = pw_name2scheme(value);
if ( new_scheme == NULL) {
if ( scheme_list != NULL ) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid scheme - %s. Valid schemes are: %s",
+ slapi_create_errormsg(errorbuf, ebuflen, "%s: invalid scheme - %s. Valid schemes are: %s",
CONFIG_PW_STORAGESCHEME_ATTRIBUTE, value, scheme_list );
} else {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid scheme - %s (no pwdstorage scheme plugin loaded)",
+ slapi_create_errormsg(errorbuf, ebuflen, "%s: invalid scheme - %s (no pwdstorage scheme plugin loaded)",
CONFIG_PW_STORAGESCHEME_ATTRIBUTE, value);
}
retVal = LDAP_CONSTRAINT_VIOLATION;
@@ -2272,7 +2274,7 @@ check_pw_storagescheme_value( const char *attr_name, char *value, long minval, l
*/
if (scheme_list) {
- slapi_create_errormsg(errorbuf, 0, "%s: invalid encoding scheme - %s\nValid values are: %s\n",
+ slapi_create_errormsg(errorbuf, ebuflen, "%s: invalid encoding scheme - %s\nValid values are: %s\n",
CONFIG_PW_STORAGESCHEME_ATTRIBUTE, value, scheme_list );
}
diff --git a/ldap/servers/slapd/pw.h b/ldap/servers/slapd/pw.h
index 2cd7f7caf..58e744125 100644
--- a/ldap/servers/slapd/pw.h
+++ b/ldap/servers/slapd/pw.h
@@ -36,9 +36,9 @@ struct passwordpolicyarray *new_passwdPolicy ( Slapi_PBlock *pb, const char *dn
void delete_passwdPolicy( struct passwordpolicyarray **pwpolicy);
/* function for checking the values of fine grained password policy attributes */
-int check_pw_duration_value( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
-int check_pw_resetfailurecount_value( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
-int check_pw_storagescheme_value( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
+int check_pw_duration_value(const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen);
+int check_pw_resetfailurecount_value(const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen);
+int check_pw_storagescheme_value(const char *attr_name, char *value, long minval, long maxval, char *errorbuf, size_t ebuflen);
int pw_is_pwp_admin(Slapi_PBlock *pb, struct passwordpolicyarray *pwp);
/*
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index 6528a93d6..eb682091a 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -955,7 +955,7 @@ sasl_check_result:
slapi_add_auth_response_control(pb, normdn);
}
- if (slapi_mapping_tree_select(pb, &be, &referral, NULL) != LDAP_SUCCESS) {
+ if (slapi_mapping_tree_select(pb, &be, &referral, NULL, 0) != LDAP_SUCCESS) {
send_nobackend_ldap_result( pb );
be = NULL;
LDAPDebug( LDAP_DEBUG_TRACE, "<= ids_sasl_check_bind\n", 0, 0, 0 );
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 25506206b..a5efddab1 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -681,14 +681,14 @@ PRBool slapi_mapping_tree_node_is_set (const mapping_tree_node *node,
PRUint32 flag);
Slapi_DN* slapi_mtn_get_dn(mapping_tree_node *node);
int slapi_mapping_tree_select_and_check(Slapi_PBlock *pb,char *newdn,
- Slapi_Backend **be, Slapi_Entry **referral, char *errorbuf);
+ Slapi_Backend **be, Slapi_Entry **referral, char *errorbuf, size_t ebuflen);
int slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list,
- Slapi_Entry **referral_list, char *errorbuf);
+ Slapi_Entry **referral_list, char *errorbuf, size_t ebuflen);
void slapi_mapping_tree_free_all(Slapi_Backend **be_list,
Slapi_Entry **referral_list);
/* Mapping Tree */
-int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry **referral, char *error_string);
+int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry **referral, char *error_string, size_t ebuflen);
char ** slapi_mtn_get_referral(const Slapi_DN *sdn);
int slapi_mtn_set_referral(const Slapi_DN *sdn, char ** referral);
int slapi_mtn_set_state(const Slapi_DN *sdn, char *state);
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index 675b763b1..9096cb5e7 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -3022,7 +3022,7 @@ slapd_extract_key(Slapi_Entry *entry, char *token, PK11SlotInfo *slot)
* password to get NSS to export an encrypted
* key which we will decrypt.
*/
- rv = PK11_GenerateRandom(randomPassword, sizeof((const char *)randomPassword) - 1);
+ rv = PK11_GenerateRandom(randomPassword, sizeof(randomPassword) - 1);
if (rv != SECSuccess) {
slapi_log_error(SLAPI_LOG_FATAL, "slapd_extract_key", "Failed to generate random.\n");
goto bail;
| 0 |
1b7198a025898b36e90f953dda157d9699fa43c9
|
389ds/389-ds-base
|
Ticket 49675 - Revise coverity fix
Description: Fix issues with last coverity patch: missing unlock, and a
return code was needed.
Also fixed issue 17472 (memory leak in uid.c)
https://pagure.io/389-ds-base/issue/49675
Reviewed by: tbordaz & lkrispenz(Thanks!!)
|
commit 1b7198a025898b36e90f953dda157d9699fa43c9
Author: Mark Reynolds <[email protected]>
Date: Mon May 28 12:36:35 2018 -0400
Ticket 49675 - Revise coverity fix
Description: Fix issues with last coverity patch: missing unlock, and a
return code was needed.
Also fixed issue 17472 (memory leak in uid.c)
https://pagure.io/389-ds-base/issue/49675
Reviewed by: tbordaz & lkrispenz(Thanks!!)
diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
index 8a27f5250..f08139183 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -550,7 +550,7 @@ memberof_apply_config(Slapi_PBlock *pb __attribute__((unused)),
}
/* Build the new list */
- for (i = 0; theConfig.groupattrs && theConfig.groupattrs[i]; i++) {
+ for (i = 0; theConfig.group_slapiattrs && theConfig.groupattrs && theConfig.groupattrs[i]; i++) {
theConfig.group_slapiattrs[i] = slapi_attr_new();
slapi_attr_init(theConfig.group_slapiattrs[i], theConfig.groupattrs[i]);
}
@@ -731,7 +731,7 @@ memberof_copy_config(MemberOfConfig *dest, MemberOfConfig *src)
}
/* Copy the attributes. */
- for (i = 0; src->group_slapiattrs && src->group_slapiattrs[i]; i++) {
+ for (i = 0; dest->group_slapiattrs && src->group_slapiattrs && src->group_slapiattrs[i]; i++) {
dest->group_slapiattrs[i] = slapi_attr_dup(src->group_slapiattrs[i]);
}
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index ddb88b998..d021f0fed 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -1673,9 +1673,10 @@ ruv_update_ruv(RUV *ruv, const CSN *csn, const char *replica_purl, void *replica
if (local_rid != prim_rid) {
repl_ruv = ruvGetReplica(ruv, prim_rid);
if ((rc = ruv_update_ruv_element(ruv, repl_ruv, prim_csn, replica_purl, PR_FALSE))) {
- slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "ruv_update_ruv - failed to update primary ruv, error (%d)", rc);
- return rc;
+ slapi_rwlock_unlock(ruv->lock);
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "ruv_update_ruv - failed to update primary ruv, error (%d)", rc);
+ return rc;
}
}
repl_ruv = ruvGetReplica(ruv, local_rid);
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index 3a75f1f29..3ca598597 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -454,10 +454,10 @@ uid_op_error(int internal_error)
static char *
create_filter(const char **attributes, const struct berval *value, const char *requiredObjectClass)
{
- char *filter;
+ char *filter = NULL;
char *fp;
char *max;
- int *attrLen;
+ int *attrLen = NULL;
int totalAttrLen = 0;
int attrCount = 0;
int valueLen;
@@ -487,9 +487,10 @@ create_filter(const char **attributes, const struct berval *value, const char *r
totalAttrLen += 3;
}
- if (ldap_quote_filter_value(value->bv_val,
- value->bv_len, 0, 0, &valueLen))
- return 0;
+ if (ldap_quote_filter_value(value->bv_val, value->bv_len, 0, 0, &valueLen)) {
+ slapi_ch_free((void **)&attrLen);
+ return filter;
+ }
if (requiredObjectClass) {
classLen = strlen(requiredObjectClass);
@@ -523,9 +524,9 @@ create_filter(const char **attributes, const struct berval *value, const char *r
*fp++ = '=';
/* Place value in filter */
- if (ldap_quote_filter_value(value->bv_val, value->bv_len,
- fp, max - fp, &valueLen)) {
- slapi_ch_free((void **)&filter);
+ if (ldap_quote_filter_value(value->bv_val, value->bv_len, fp, max - fp, &valueLen)) {
+ slapi_ch_free_string(&filter);
+ slapi_ch_free((void **)&attrLen);
return 0;
}
fp += valueLen;
@@ -545,9 +546,8 @@ create_filter(const char **attributes, const struct berval *value, const char *r
*fp++ = '=';
/* Place value in filter */
- if (ldap_quote_filter_value(value->bv_val, value->bv_len,
- fp, max - fp, &valueLen)) {
- slapi_ch_free((void **)&filter);
+ if (ldap_quote_filter_value(value->bv_val, value->bv_len, fp, max - fp, &valueLen)) {
+ slapi_ch_free_string(&filter);
slapi_ch_free((void **)&attrLen);
return 0;
}
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 18dd944f4..4b8754dfe 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -5656,6 +5656,7 @@ dblayer_copy_directory(struct ldbminfo *li,
inst_dir, MAXPATHLEN);
if (!inst_dirp || !*inst_dirp) {
slapi_log_err(SLAPI_LOG_ERR, "dblayer_copy_directory", "Instance dir is NULL.\n");
+ slapi_ch_free_string(&inst_dirp);
return return_value;
}
len = strlen(inst_dirp);
@@ -5969,6 +5970,7 @@ dblayer_backup(struct ldbminfo *li, char *dest_dir, Slapi_Task *task)
slapi_task_log_notice(task,
"Backup: Instance dir is empty\n");
}
+ slapi_ch_free_string(&inst_dirp);
return_value = -1;
goto bail;
}
@@ -7090,6 +7092,7 @@ dblayer_in_import(ldbm_instance *inst)
inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
inst_dir, MAXPATHLEN);
if (!inst_dirp || !*inst_dirp) {
+ slapi_ch_free_string(&inst_dirp);
rval = -1;
goto done;
}
@@ -7141,6 +7144,7 @@ dblayer_update_db_ext(ldbm_instance *inst, char *oldext, char *newext)
if (NULL == inst_dirp || '\0' == *inst_dirp) {
slapi_log_err(SLAPI_LOG_ERR,
"dblayer_update_db_ext", "Instance dir is NULL\n");
+ slapi_ch_free_string(&inst_dirp);
return -1; /* non zero */
}
for (a = (struct attrinfo *)avl_getfirst(inst->inst_attrs);
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 16b87ee6b..ab794a189 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -1639,7 +1639,7 @@ bye:
dblayer_release_id2entry(be, db);
- if (fd > STDERR_FILENO) {
+ if (fd >= 0) {
close(fd);
}
diff --git a/ldap/servers/slapd/backend_manager.c b/ldap/servers/slapd/backend_manager.c
index 401ab5b21..d5475051e 100644
--- a/ldap/servers/slapd/backend_manager.c
+++ b/ldap/servers/slapd/backend_manager.c
@@ -42,18 +42,18 @@ slapi_be_new(const char *type, const char *name, int isprivate, int logchanges)
}
}
- /* Find the first open slot */
- for (i = 0; ((i < maxbackends) && (backends[i])); i++)
- ;
-
- PR_ASSERT(i < maxbackends);
be = (Slapi_Backend *)slapi_ch_calloc(1, sizeof(Slapi_Backend));
be->be_lock = slapi_new_rwlock();
be_init(be, type, name, isprivate, logchanges, defsize, deftime);
- backends[i] = be;
- nbackends++;
+ for (size_t i = 0; i < maxbackends; i++) {
+ if (backends[i] == NULL) {
+ backends[i] = be;
+ nbackends++;
+ break;
+ }
+ }
slapi_log_err(SLAPI_LOG_TRACE, "slapi_be_new",
"Added new backend name [%s] type [%s] nbackends [%d]\n",
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index e2cd165bc..6b5684ad5 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1164,6 +1164,7 @@ update_pw_history(Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw)
if (old_pw) {
/* we have a password to replace with the oldest one in the history. */
if (!values_replace || !vacnt) { /* This is the first one to store */
+ slapi_ch_array_free(values_replace);
values_replace = (char **)slapi_ch_calloc(2, sizeof(char *));
}
} else {
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index a36c6bd81..0e6d15b36 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -2376,7 +2376,7 @@ slapd_SSL_client_auth(LDAP *ld)
/* Free config data */
- if (!svrcore_setup() && token != NULL) {
+ if (token && !svrcore_setup()) {
#ifdef WITH_SYSTEMD
slapd_SSL_warn("Sending pin request to SVRCore. You may need to run "
"systemd-tty-ask-password-agent to provide the password.");
@@ -2460,6 +2460,11 @@ slapd_SSL_client_auth(LDAP *ld)
}
}
}
+ } else {
+ if (token == NULL) {
+ slapd_SSL_warn("slapd_SSL_client_auth - certificate token was not found\n");
+ }
+ rc = -1;
}
slapi_ch_free_string(&token);
| 0 |
bc83e3255b4b0ebe31d9f42ad57fbea0bc49e056
|
389ds/389-ds-base
|
Resolves: bug 345711
Description: migration : ignore idl switch value in 6.21 and earlier
Fix Description: Have to assign the values directly to the array ref - not to a temp array ref
|
commit bc83e3255b4b0ebe31d9f42ad57fbea0bc49e056
Author: Rich Megginson <[email protected]>
Date: Wed Nov 14 15:12:09 2007 +0000
Resolves: bug 345711
Description: migration : ignore idl switch value in 6.21 and earlier
Fix Description: Have to assign the values directly to the array ref - not to a temp array ref
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
index 84344152b..e500bd26a 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -143,8 +143,7 @@ sub getDBVERSION {
my $line = <DBVERSION>;
close DBVERSION;
chomp($line);
- my @foo = split("/", $line);
- $data = \@foo;
+ @{$data} = split("/", $line);
return ();
}
| 0 |
e74fae45de948402d0b73d4c72748577031d8a58
|
389ds/389-ds-base
|
Ticket 50947 - change 00core.ldif objectClasses for openldap migration
Bug Description: Some values from rfc2256 are still present in openldap
despite being deprecated. We need to support these incase someone
has them, and to prevent the openldap_2_389 tool from attempting this
migration.
Fix Description: Add the missing rfc2256 attributes and values.
https://pagure.io/389-ds-base/issue/50947
Author: William Brown <[email protected]>
Review by: ???
|
commit e74fae45de948402d0b73d4c72748577031d8a58
Author: William Brown <[email protected]>
Date: Tue Mar 10 14:19:09 2020 +1000
Ticket 50947 - change 00core.ldif objectClasses for openldap migration
Bug Description: Some values from rfc2256 are still present in openldap
despite being deprecated. We need to support these incase someone
has them, and to prevent the openldap_2_389 tool from attempting this
migration.
Fix Description: Add the missing rfc2256 attributes and values.
https://pagure.io/389-ds-base/issue/50947
Author: William Brown <[email protected]>
Review by: ???
diff --git a/ldap/schema/00core.ldif b/ldap/schema/00core.ldif
index 2bba414c8..aa414a838 100644
--- a/ldap/schema/00core.ldif
+++ b/ldap/schema/00core.ldif
@@ -68,6 +68,13 @@ attributeTypes: ( 2.5.4.0 NAME 'objectClass'
#
################################################################################
#
+attributeTypes: ( 2.5.4.2 NAME 'knowledgeInformation'
+ EQUALITY caseIgnoreMatch
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
attributeTypes: ( 2.5.18.3 NAME 'creatorsName'
EQUALITY distinguishedNameMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
@@ -415,6 +422,32 @@ attributeTypes: ( 2.5.4.43 NAME 'initials'
#
################################################################################
#
+attributeTypes: ( 2.5.4.29 NAME 'presentationAddress'
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
+ SINGLE-VALUE
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
+attributeTypes: ( 2.5.4.30 NAME 'supportedApplicationContext'
+ EQUALITY objectIdentifierMatch
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.38
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
+attributeTypes: ( 2.5.4.48 NAME 'protocolInformation'
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
+attributeTypes: ( 2.5.4.54 NAME 'dmdName'
+ SUP name
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
attributeTypes: ( 2.5.4.25 NAME 'internationalISDNNumber'
EQUALITY numericStringMatch
SUBSTR numericStringSubstringsMatch
@@ -627,6 +660,37 @@ objectClasses: ( 2.5.6.11 NAME 'applicationProcess'
#
################################################################################
#
+objectClasses: ( 2.5.6.12 NAME 'applicationEntity'
+ SUP top
+ STRUCTURAL
+ MUST ( cn $ presentationAddress )
+ MAY ( supportedApplicationContext $ seeAlso $ ou $ o $ l $ description )
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
+objectClasses: ( 2.5.6.13 NAME 'dSA'
+ SUP applicationEntity
+ STRUCTURAL
+ MAY knowledgeInformation
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
+objectClasses: ( 2.5.6.20 NAME 'dmd'
+ SUP top
+ STRUCTURAL
+ MUST ( dmdName )
+ MAY ( userPassword $ searchGuide $ seeAlso $ businessCategory $
+ x121Address $ registeredAddress $ destinationIndicator $
+ preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $
+ telephoneNumber $ internationaliSDNNumber $
+ facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $ postalAddress $
+ physicalDeliveryOfficeName $ st $ l $ description )
+ X-ORIGIN 'RFC 2256' )
+#
+################################################################################
+#
objectClasses: ( 2.5.6.2 NAME 'country'
SUP top
STRUCTURAL
| 0 |
44ee32bb2f39712b8c0f5628d5c17109c48772d7
|
389ds/389-ds-base
|
Resolves: bug 245815
Bug Description: DS Admin Migration framework - cross platform support
Reviewed by: nhosoi (Thanks!)
Fix Description: There are basically three parts to cross platform support
1) Allow a different physical server root than the logical server root. This allows you to copy the old server root directory to the target machine, either by making a tarball or by a network mount. Then you can migrate from e.g. /mnt/opt/fedora-ds, and specify that the real old server root was /opt/fedora-ds. This is the distinction between the --oldsroot and --actualsroot parameters.
2) Cross platform database migration requires the old data is converted to LDIF first. Migration makes the simplifying assumption that the database LDIF file is in the old db directory and has the name of <old backend name>.ldif e.g. userRoot.ldif
3) Cross platform replication migration doesn't preserve the state, so the changelog nor other associated state information can be migrated.
I rewrote the old migration script to use the FileConn - this theoretically will allow us to support migration using an LDAP::Conn as well.
I had to make some fixes to FileConn, primarily to support the root DSE.
Platforms tested: RHEL4
Flag Day: no
Doc impact: Yes, along with the rest of the new migration framework.
|
commit 44ee32bb2f39712b8c0f5628d5c17109c48772d7
Author: Rich Megginson <[email protected]>
Date: Thu Jul 12 13:52:42 2007 +0000
Resolves: bug 245815
Bug Description: DS Admin Migration framework - cross platform support
Reviewed by: nhosoi (Thanks!)
Fix Description: There are basically three parts to cross platform support
1) Allow a different physical server root than the logical server root. This allows you to copy the old server root directory to the target machine, either by making a tarball or by a network mount. Then you can migrate from e.g. /mnt/opt/fedora-ds, and specify that the real old server root was /opt/fedora-ds. This is the distinction between the --oldsroot and --actualsroot parameters.
2) Cross platform database migration requires the old data is converted to LDIF first. Migration makes the simplifying assumption that the database LDIF file is in the old db directory and has the name of <old backend name>.ldif e.g. userRoot.ldif
3) Cross platform replication migration doesn't preserve the state, so the changelog nor other associated state information can be migrated.
I rewrote the old migration script to use the FileConn - this theoretically will allow us to support migration using an LDAP::Conn as well.
I had to make some fixes to FileConn, primarily to support the root DSE.
Platforms tested: RHEL4
Flag Day: no
Doc impact: Yes, along with the rest of the new migration framework.
diff --git a/ldap/admin/src/scripts/DSDialogs.pm b/ldap/admin/src/scripts/DSDialogs.pm
index 33e6c7445..049e794d5 100644
--- a/ldap/admin/src/scripts/DSDialogs.pm
+++ b/ldap/admin/src/scripts/DSDialogs.pm
@@ -98,7 +98,7 @@ my $dsserverid = new Dialog (
my $ans = shift;
my $res = $DialogManager::SAME;
my $path = $self->{manager}->{setup}->{configdir} . "/slapd-" . $ans;
- if ($ans !~ /^[0-9a-zA-Z_-]+$/) {
+ if (!isValidServerID($ans)) {
$self->{manager}->alert("dialog_dsserverid_error", $ans);
} elsif (-d $path) {
$self->{manager}->alert("dialog_dsserverid_inuse", $ans);
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
index 0e0370441..070c909bd 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -53,6 +53,7 @@ use Inf;
# tempfiles
use File::Temp qw(tempfile tempdir);
+use File::Basename qw(basename);
# load perldap
use Mozilla::LDAP::Conn;
@@ -88,6 +89,8 @@ my %ignoreOld =
'nsslapd-lockdir' => 'nsslapd-lockdir',
'nsslapd-tmpdir' => 'nsslapd-tmpdir',
'nsslapd-certdir' => 'nsslapd-certdir',
+ 'nsslapd-ldifdir' => 'nsslapd-ldifdir',
+ 'nsslapd-bakdir' => 'nsslapd-bakdir',
'nsslapd-ldapifilepath' => 'nsslapd-ldapifilepath',
'nsslapd-ldapilisten' => 'nsslapd-ldapilisten',
'nsslapd-ldapiautobind' => 'nsslapd-ldapiautobind',
@@ -106,34 +109,55 @@ my %alwaysUseOld =
'aci' => 'aci'
);
-my $pkgname; # global used in several different places - set in migrateDS
-my $oldsroot; # global used in several different places - set in migrateDS
-
sub getNewDbDir {
- my ($ent, $attr, $inst) = @_;
+ my ($ent, $attr, $mig, $inst) = @_;
my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
my $cn = $ent->getValues('cn');
+ my $oldval = $ent->getValues($attr);
my $newval;
+ # there is one case where we want to just use the existing db directory
+ # that's the case where the user has moved the indexes and/or the
+ # transaction logs to different partitions for performance
+ # in that case, the old directory will not be the same as the default,
+ # and the directory will exist
+ my $olddefault = "$mig->{actualsroot}/$inst";
+ if (-d $oldval and ($oldval !~ /^$olddefault/)) {
+ debug(2, "Keeping old value [$oldval] for attr $attr in entry ", $ent->getDN(), "\n");
+ return $oldval;
+ }
+ # otherwise, just use the new default locations
if ($objclasses{nsbackendinstance}) {
- $newval = "@localstatedir@/lib/$pkgname/$inst/db/$cn";
+ $newval = "@localstatedir@/lib/$mig->{pkgname}/$inst/db/$cn";
} elsif (lc $cn eq 'config') {
- $newval = "@localstatedir@/lib/$pkgname/$inst/db";
+ $newval = "@localstatedir@/lib/$mig->{pkgname}/$inst/db";
} elsif (lc $cn eq 'changelog5') {
- $newval = "@localstatedir@/lib/$pkgname/$inst/cldb";
+ $newval = "@localstatedir@/lib/$mig->{pkgname}/$inst/changelogdb";
}
debug(2, "New value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
return $newval;
}
sub migrateCredentials {
- my ($ent, $attr, $inst) = @_;
+ my ($ent, $attr, $mig, $inst) = @_;
my $oldval = $ent->getValues($attr);
- debug(3, "Executing migratecred -o $oldsroot/$inst -n @instconfigdir@/$inst -c $oldval . . .\n");
- my $newval = `migratecred -o $oldsroot/$inst -n @instconfigdir@/$inst -c $oldval`;
+ debug(3, "Executing migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c $oldval . . .\n");
+ my $newval = `migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c $oldval`;
debug(3, "Converted old value [$oldval] to new value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
return $newval;
}
+sub removensState {
+ my ($ent, $attr, $mig, $inst) = @_;
+ my $newval;
+
+ # nsstate is binary and cannot be migrated cross platform
+ if (!$mig->{crossplatform}) {
+ $newval = $ent->getValues($attr);
+ }
+
+ return $newval;
+}
+
# these are attributes that we have to transform from
# the old value to the new value (e.g. a pathname)
# The key of this hash is the attribute name. The value
@@ -146,110 +170,170 @@ my %transformAttr =
'nsslapd-db-logdirectory' => \&getNewDbDir,
'nsslapd-changelogdir' => \&getNewDbDir,
'nsds5replicacredentials' => \&migrateCredentials,
- 'nsmultiplexorcredentials' => \&migrateCredentials
+ 'nsmultiplexorcredentials' => \&migrateCredentials,
+ 'nsstate' => \&removensState
);
sub copyDatabaseDirs {
my $srcdir = shift;
my $destdir = shift;
- if (-d $srcdir && ! -d $destdir) {
+ my $filesonly = shift;
+ if (-d $srcdir && ! -d $destdir && !$filesonly) {
debug(1, "Copying database directory $srcdir to $destdir\n");
- system ("cp -p -r $srcdir $destdir") == 0 or
- die "Could not copy database directory $srcdir to $destdir: $?";
+ if (system ("cp -p -r $srcdir $destdir")) {
+ return ('error_copying_dbdir', $srcdir, $destdir, $?);
+ }
} elsif (! -d $srcdir) {
- die "Error: database directory $srcdir does not exist";
+ return ("error_dbsrcdir_not_exist", $srcdir);
} else {
debug(1, "The destination directory $destdir already exists, copying files/dirs individually\n");
foreach my $file (glob("$srcdir/*")) {
debug(3, "Copying $file to $destdir\n");
if (-f $file) {
- system ("cp -p $file $destdir") == 0 or
- die "Error: could not copy $file to $destdir: $!";
- } elsif (-d $file) {
- system ("cp -p -r $file $destdir") == 0 or
- die "Error: could not copy $file to $destdir: $!";
+ if (system ("cp -p $file $destdir")) {
+ return ('error_copying_dbfile', $file, $destdir, $?);
+ }
+ } elsif (-d $file && !$filesonly) {
+ if (system ("cp -p -r $file $destdir")) {
+ return ('error_copying_dbdir', $file, $destdir, $?);
+ }
}
}
}
}
-sub copyDatabases {
- my $oldroot = shift;
- my $inst = shift;
- my $newdbdir = shift;
-
- # global config and instance specific config are children of this entry
- my $basedbdn = normalizeDN("cn=ldbm database,cn=plugins,cn=config");
- # get the list of databases, their index and transaction log locations
- my $fname = "$oldroot/$inst/config/dse.ldif";
- open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
- my $in = new Mozilla::LDAP::LDIF(*DSELDIF);
- my $targetdn = normalizeDN("cn=config,cn=ldbm database,cn=plugins,cn=config");
- while (my $ent = readOneEntry $in) {
- next if (!$ent->getDN()); # just skip root dse
- # look for the one level children of $basedbdn
- my @rdns = ldap_explode_dn($ent->getDN(), 0);
- my $parentdn = normalizeDN(join(',', @rdns[1..$#rdns]));
- if ($parentdn eq $basedbdn) {
- my $cn = $ent->getValues('cn');
- my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
- if ($cn eq 'config') { # global config
- debug(1, "Found ldbm database plugin config entry ", $ent->getDN(), "\n");
- my $dir = $ent->getValues('nsslapd-directory');
- my $homedir = $ent->getValues('nsslapd-db-home-directory');
- my $logdir = $ent->getValues('nsslapd-db-logdirectory');
- debug(1, "old db dir = $dir homedir = $homedir logdir = $logdir\n");
- my $srcdir = $homedir || $dir || "$oldroot/$inst/db";
- copyDatabaseDirs($srcdir, $newdbdir);
- copyDatabaseDirs($logdir, $newdbdir) if ($logdir && $logdir ne $srcdir);
- } elsif ($objclasses{nsbackendinstance}) {
- debug(1, "Found ldbm database instance entry ", $ent->getDN(), "\n");
- my $dir = $ent->getValues('nsslapd-directory');
- # the default db instance directory is
- # $oldroot/$inst/$cn
- debug(1, "old instance $cn dbdir $dir\n");
- my $srcdir = $dir || "$oldroot/$inst/db/$cn";
- copyDatabaseDirs($srcdir, "$newdbdir/$cn");
- } # else just ignore for now
+# migrate all of the databases in an instance
+sub migrateDatabases {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+ my $olddefault = "$mig->{actualsroot}/$inst/db"; # old default db home directory
+ my @errs;
+
+ # first, look for an LDIF file in that directory with the same name as the
+ # database
+ my $foundldif;
+ for (glob("$mig->{oldsroot}/$inst/db/*.ldif")) {
+ my $dbname = basename($_, '.ldif');
+ my @cmd = ("@serverdir@/$inst/ldif2db", "-n", $dbname, "-i", $_);
+ debug(1, "migrateDatabases: executing command ", @cmd);
+ if (system(@cmd)) {
+ return ('error_importing_migrated_db', $_, $?);
}
+ $foundldif = 1;
}
- close DSELDIF;
+
+ if ($foundldif) {
+ return (); # done - can do nothing else for cross-platform
+ }
+
+ # if no LDIF files, just copy over the database directories
+ my $ent = $src->search("cn=ldbm database,cn=plugins,cn=config", "one",
+ "(objectclass=*)");
+ if (!$ent) {
+ return ("error_reading_olddbconfig", $src->getErrorString());
+ }
+ # there is one case where we want to just use the existing db directory
+ # that's the case where the user has moved the indexes and/or the
+ # transaction logs to different partitions for performance
+ # in that case, the old directory will not be the same as the default,
+ # and the directory will exist
+ my $olddefault = "$mig->{actualsroot}/$inst";
+ do {
+ my $cn = $ent->getValues('cn');
+ my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
+ if ($cn eq 'config') { # global config
+ my $newent = $dest->search($ent->getDN(), "base", "(objectclass=*)");
+ my $newdbdir = $newent->getValues('nsslapd-directory') ||
+ "@localstatedir@/lib/$mig->{pkgname}/$inst/db";
+ debug(1, "Found ldbm database plugin config entry ", $ent->getDN(), "\n");
+ my $dir = $ent->getValues('nsslapd-directory');
+ my $homedir = $ent->getValues('nsslapd-db-home-directory');
+ my $logdir = $ent->getValues('nsslapd-db-logdirectory');
+ debug(1, "old db dir = $dir homedir = $homedir logdir = $logdir\n");
+ my $srcdir = $homedir || $dir || "$olddefault/db";
+ if (-d $srcdir and ($srcdir !~ /^$olddefault/)) {
+ debug(2, "Not copying database files from [$srcdir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $srcdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ if (@errs = copyDatabaseDirs($srcdir, $newdbdir, 1)) {
+ return @errs;
+ }
+ }
+ if ($logdir && ($logdir ne $srcdir)) {
+ if (-d $logdir and ($logdir !~ /^$olddefault/)) {
+ debug(2, "Not copying transaction logs from [$logdir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $newdbdir = $newent->getValues('nsslapd-db-logdirectory') ||
+ $newdbdir;
+ $logdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ if (@errs = copyDatabaseDirs($logdir, $newdbdir, 1)) {
+ return @errs;
+ }
+ }
+ }
+ } elsif ($objclasses{nsbackendinstance}) {
+ debug(1, "Found ldbm database instance entry ", $ent->getDN(), "\n");
+ my $dir = $ent->getValues('nsslapd-directory');
+ # the default db instance directory is
+ # $oldroot/$inst/$cn
+ debug(1, "old instance $cn dbdir $dir\n");
+ my $srcdir = $dir || "$olddefault/db/$cn";
+ my $newent = $dest->search($ent->getDN(), "base", "(objectclass=*)");
+ my $newdbdir = $newent->getValues('nsslapd-directory') ||
+ "@localstatedir@/lib/$mig->{pkgname}/$inst/db";
+ if (-d $srcdir and ($srcdir !~ /^$olddefault/)) {
+ debug(2, "Not copying database indexes from [$srcdir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $srcdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ if (@errs = copyDatabaseDirs($srcdir, "$newdbdir/$cn")) {
+ return @errs;
+ }
+ }
+ }
+ } while ($ent = $src->nextEntry());
+
+ return ();
}
-sub copyChangelogDB {
- my $oldroot = shift;
- my $inst = shift;
- my $newdbdir = shift;
+sub migrateChangelogs {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+ my $olddefault = "$mig->{actualsroot}/$inst"; # old default db home directory
# changelog config entry
- my $cldn = normalizeDN("cn=changelog5, cn=config");
- my $fname = "$oldroot/$inst/config/dse.ldif";
- open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
- my $in = new Mozilla::LDAP::LDIF(*DSELDIF);
- while (my $ent = readOneEntry $in) {
- my $targetdn = normalizeDN($ent->getDN());
- if ($targetdn eq $cldn) {
- my $oldcldir = $ent->getValues('nsslapd-changelogdir');
- debug(1, "old cldb dir = $oldcldir\n");
- my $srcdir = $oldcldir || "$oldroot/$inst/cldb";
- copyDatabaseDirs($srcdir, $newdbdir);
- last;
+ my $oldent = $src->search("cn=changelog5, cn=config", "base", "(objectclass=*)");
+ my $newent = $dest->search("cn=changelog5, cn=config", "base", "(objectclass=*)");
+ if ($oldent and $newent) { # changelog configured
+ my $oldcldir = $oldent->getValues('nsslapd-changelogdir');
+ if (-d $oldcldir and ($oldcldir !~ /^$olddefault/)) {
+ debug(2, "Not copying changelogdb from [$oldcldir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $oldcldir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ my $newcldir = $newent->getValues('nsslapd-changelogdir');
+ copyDatabaseDirs($oldcldir, $newcldir);
}
}
- close DSELDIF;
}
sub fixAttrsInEntry {
- my ($ent, $inst) = @_;
+ my ($ent, $mig, $inst) = @_;
for my $attr (keys %{$ent}) {
my $lcattr = lc $attr;
if ($transformAttr{$lcattr}) {
- $ent->setValues($attr, &{$transformAttr{$lcattr}}($ent, $attr, $inst));
+ $ent->setValues($attr, &{$transformAttr{$lcattr}}($ent, $attr, $mig, $inst));
}
}
}
sub mergeEntries {
- my ($old, $new, $inst) = @_;
+ my ($old, $new, $mig, $inst) = @_;
my %inoldonly; # attrs in old entry but not new one
my %innewonly; # attrs in new entry but not old one
my @attrs; # attrs common to old and new
@@ -280,7 +364,7 @@ sub mergeEntries {
} elsif ($transformAttr{$lcattr}) {
# only transform if the value is in the old entry
if (!$innewonly{$attr}) {
- $new->setValues($attr, &{$transformAttr{$lcattr}}($old, $attr, $inst));
+ $new->setValues($attr, &{$transformAttr{$lcattr}}($old, $attr, $mig, $inst));
}
} elsif ($cn eq "internationalization plugin" and $lcattr eq "nsslapd-pluginarg0") {
next; # use the new value of this path name
@@ -294,41 +378,72 @@ sub mergeEntries {
}
}
-sub mergeDseLdif {
- my $oldroot = shift;
- my $inst = shift;
- my $ent;
+
+my @allattrlist = ('*', 'aci', 'createTimestamp', 'creatorsName',
+ 'modifyTimestamp', 'modifiersName');
+
+sub getAllEntries {
+ my $conn = shift;
+ my $href = shift;
+ my $aref = shift;
+
+ # these are the special DSEs for which we only need ACIs
+ for my $dn ("", "cn=monitor", "cn=config") {
+ my $scope = $dn ? "sub" : "base";
+ my @attrlist;
+ if ($dn eq "cn=config") {
+ @attrlist = @allattrlist;
+ } else {
+ @attrlist = qw(aci);
+ }
+ my $ent = $conn->search($dn, $scope, "(objectclass=*)", 0, @attrlist);
+ next if (!$ent or ($conn->getErrorCode() eq 32));
+ if ($conn->getErrorCode()) {
+ return ('error_reading_entry', $dn, $conn->getErrorString());
+ }
+ do {
+ my $ndn = normalizeDN($ent->getDN());
+ $href->{$ndn} = $ent;
+ push @{$aref}, $ndn;
+ } while ($ent = $conn->nextEntry());
+ }
+
+ return ();
+}
+
+# these entries cannot be migrated if doing cross platform
+my %noCrossPlatformDN = (
+ 'cn=uniqueid generator,cn=config' => 'cn=uniqueid generator,cn=config'
+);
+
+sub mergeConfigEntries {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
# first, read in old file
my %olddse; # map of normalized DN to Entry
my @olddns; # the DNs in their original order
- my $fname = "$oldroot/$inst/config/dse.ldif";
- open( OLDDSELDIF, $fname ) || die "Can't open $fname: $!";
- my $in = new Mozilla::LDAP::LDIF(*OLDDSELDIF);
- while ($ent = readOneEntry $in) {
- my $dn = normalizeDN($ent->getDN());
- push @olddns, $dn;
- $olddse{$dn} = $ent;
+ my @errs;
+ if (@errs = getAllEntries($src, \%olddse, \@olddns)) {
+ return @errs;
}
- close OLDDSELDIF;
# next, read in new file
my %newdse; # map of normalized DN to Entry
+ my @allnewdns;
my @newdns; # the DNs in their original order that are not in olddns
- $fname = "@instconfigdir@/$inst/dse.ldif";
- open( NEWDSELDIF, $fname ) || die "Can't open $fname: $!";
- $in = new Mozilla::LDAP::LDIF(*NEWDSELDIF);
- while ($ent = readOneEntry $in) {
- my $dn = normalizeDN($ent->getDN());
- $newdse{$dn} = $ent;
- if (! exists $olddse{$dn}) {
- push @newdns, $dn;
+ if (@errs = getAllEntries($dest, \%newdse, \@allnewdns)) {
+ return @errs;
+ }
+
+ for my $ndn (@allnewdns) {
+ if (! exists $olddse{$ndn}) {
+ push @newdns, $ndn;
}
}
- close NEWDSELDIF;
- # temp file for new, merged dse.ldif
- my ($dsefh, $tmpdse) = tempfile(SUFFIX => '.ldif');
# now, compare entries
# if the entry exists in the old tree but not the new, add it
# if the entry exists in the new tree but not the old, delete it
@@ -339,58 +454,144 @@ sub mergeDseLdif {
for my $dn (@olddns, @newdns) {
my $oldent = $olddse{$dn};
my $newent = $newdse{$dn};
- my $outputent;
- if ($oldent && !$newent) {
+ my $op;
+ my $rc = 1;
+ if ($mig->{crossplatform} && $noCrossPlatformDN{$dn}) {
+ debug(1, "Cannot migrate the entry $dn - skipping\n");
+ next;
+ } elsif ($oldent && !$newent) {
# may have to fix up some values in the old entry
- fixAttrsInEntry($oldent, $inst);
- # output $oldent
- $outputent = $oldent;
+ fixAttrsInEntry($oldent, $mig, $inst);
+ $rc = $dest->add($oldent);
+ $op = "add";
} elsif (!$oldent && $newent) {
- next if ($dn =~ /o=deleteAfterMigration/i);
- # output $newent
- $outputent = $newent;
+ if ($dn =~ /o=deleteAfterMigration/i) {
+ $rc = $dest->delete($dn);
+ $op = "delete";
+ } else {
+ # do nothing - no change to entry
+ }
} else { #merge
# $newent will contain the merged entry
- mergeEntries($oldent, $newent, $inst);
- $outputent = $newent;
+ mergeEntries($oldent, $newent, $mig, $inst);
+ $rc = $dest->update($newent);
+ $op = "update";
}
- # special fix for rootDSE - perldap doesn't like "" for a dn
- if (! $outputent->getDN()) {
- my $ary = $outputent->getLDIFrecords();
- shift @$ary; # remove "dn"
- shift @$ary; # remove the empty dn value
- print $dsefh "dn:\n";
- print $dsefh (Mozilla::LDAP::LDIF::pack_LDIF (78, $ary), "\n");
- } else {
- Mozilla::LDAP::LDIF::put_LDIF($dsefh, 78, $outputent);
+
+ if (!$rc) {
+ return ('error_updating_merge_entry', $op, $dn, $dest->getErrorString());
+ }
+ }
+
+ return ();
+}
+
+my %deletedschema = (
+ '50ns-calendar' => '50ns-calendar.ldif',
+ '50ns-compass' => '50ns-compass.ldif',
+ '50ns-delegated-admin' => '50ns-delegated-admin.ldif',
+ '50ns-legacy' => '50ns-legacy.ldif',
+ '50ns-mail' => '50ns-mail.ldif',
+ '50ns-mcd-browser' => '50ns-mcd-browser.ldif',
+ '50ns-mcd-config' => '50ns-mcd-config.ldif',
+ '50ns-mcd-li' => '50ns-mcd-li.ldif',
+ '50ns-mcd-mail' => '50ns-mcd-mail.ldif',
+ '50ns-media' => '50ns-media.ldif',
+ '50ns-mlm' => '50ns-mlm.ldif',
+ '50ns-msg' => '50ns-msg.ldif',
+ '50ns-netshare' => '50ns-netshare.ldif',
+ '50ns-news' => '50ns-news.ldif',
+ '50ns-proxy' => '50ns-proxy.ldif',
+ '50ns-wcal' => '50ns-wcal.ldif',
+ '51ns-calendar' => '51ns-calendar.ldif'
+);
+
+sub migrateSchema {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+
+ my $cfgent = $dest->search("cn=config", "base", "(objectclass=*)");
+ my $newschemadir = $cfgent->getValues('nsslapd-schemadir') ||
+ "$mig->{configdir}/$inst/schema";
+ my %newschema = map {basename($_, '.ldif') => $_} glob("$newschemadir/*.ldif");
+ delete $newschema{"99user"}; # always copy this one
+ for (glob("$mig->{oldsroot}/$inst/config/schema/*.ldif")) {
+ my $fname = basename($_, '.ldif');
+ next if ($deletedschema{$fname}); # don't copy deleted schema
+ next if ($newschema{$fname}); # use new version
+ if (system("cp -p $_ $newschemadir")) {
+ return ("error_migrating_schema", $_, $!);
}
}
- close $dsefh;
- return $tmpdse;
+ return ();
+}
+
+sub migrateDSInstance {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+
+ my @errs;
+ # first, merge dse ldif
+ if (@errs = mergeConfigEntries($mig, $inst, $src, $dest)) {
+ return @errs;
+ }
+
+ # next, grab the old schema
+ if (@errs = migrateSchema($mig, $inst, $src, $dest)) {
+ return @errs;
+ }
+
+ # next, the databases
+ if (@errs = migrateDatabases($mig, $inst, $src, $dest)) {
+ return @errs;
+ }
+
+ # next, the changelogs
+ if (!$mig->{crossplatform}) {
+ if (@errs = migrateChangelogs($mig, $inst, $src, $dest)) {
+ return @errs;
+ }
+ }
+
+ # next, the security files
+ my $cfgent = $dest->search("cn=config", "base", "(objectclass=*)");
+ my $newcertdir = $cfgent->getValues("nsslapd-certdir") ||
+ "@instconfigdir@/$inst";
+ $mig->migrateSecurityFiles($inst, $newcertdir);
+
+ return @errs;
}
sub migrateDS {
my $mig = shift;
- $pkgname = $mig->{pkgname}; # set globals
- $oldsroot = $mig->{oldsroot}; # set globals
my @errs;
# for each instance
foreach my $inst (@{$mig->{instances}}) {
- if (-f "@instconfigdir@/$inst/dse.ldif") {
- $mig->msg($WARN, 'instance_already_exists', "@instconfigdir@/$inst/dse.ldif");
+ if (-f "$mig->{configdir}/$inst/dse.ldif") {
+ $mig->msg($WARN, 'instance_already_exists', "$mig->{configdir}/$inst/dse.ldif");
next;
}
- # set instance specific defaults
- my $newdbdir = "@localstatedir@/lib/$pkgname/$inst/db";
- my $newcertdir = "@instconfigdir@/$inst";
- my $newcldbdir = "@localstatedir@/lib/$pkgname/$inst/cldb";
+
+ # you could theoretically make this work with either a remote source or
+ # remote dest
+ # $mig->{inf} would contain an entry for each instance e.g.
+ # $mig->{inf}->{$inst}
+ # each instance specific entry would contain a {General} and a {slapd}
+ # all the information necessary to open an LDAP::Conn to the server
+ # if the source, you could also change createInfFromConfig to read
+ # the info from the Conn (or FileConn) that's needed to create the
+ # instance on the dest
# extract the information needed for ds_newinst.pl
- my $configdir = "$oldsroot/$inst/config";
- my $inf = createInfFromConfig($configdir, $inst, \@errs);
- debug(2, "Using inffile $inf->{filename} created from $configdir\n");
+ my $oldconfigdir = "$mig->{oldsroot}/$inst/config";
+ my $inf = createInfFromConfig($oldconfigdir, $inst, \@errs);
+ debug(2, "Using inffile $inf->{filename} created from $oldconfigdir\n");
if (@errs) {
$mig->msg(@errs);
return 0;
@@ -407,31 +608,16 @@ sub migrateDS {
$mig->msg('created_dsinstance', $output);
}
- # copy over the files/directories
- # copy the databases
- copyDatabases($oldsroot, $inst, $newdbdir);
+ my $src = new FileConn("$oldconfigdir/dse.ldif", 1); # read-only
+ my $dest = new FileConn("$mig->{configdir}/$inst/dse.ldif");
- # copy the security related files
- $mig->migrateSecurityFiles($inst, $newcertdir);
-
- # copy the repl changelog database
- copyChangelogDB($oldsroot, $inst, $newcldbdir);
-
- # merge the old info into the new dse.ldif
- my $tmpdse = mergeDseLdif($oldsroot, $inst);
-
- # get user/group of new dse
- my ($dev, $ino, $mode, $uid, $gid, @rest) = stat "@instconfigdir@/$inst/dse.ldif";
- # save the original new dse.ldif
- system("cp -p @instconfigdir@/$inst/dse.ldif @instconfigdir@/$inst/dse.ldif.premigrate");
- # copy the new one
- system("cp $tmpdse @instconfigdir@/$inst/dse.ldif");
- # change owner/group
- chmod $mode, "@instconfigdir@/$inst/dse.ldif";
- chown $uid, $gid, "@instconfigdir@/$inst/dse.ldif";
-
- # remove the temp one
- unlink($tmpdse);
+ @errs = migrateDSInstance($mig, $inst, $src, $dest);
+ $src->close();
+ $dest->close();
+ if (@errs) {
+ $mig->msg(@errs);
+ return 0;
+ }
}
return 1;
diff --git a/ldap/admin/src/scripts/FileConn.pm b/ldap/admin/src/scripts/FileConn.pm
index c777b1562..ea68d41fe 100644
--- a/ldap/admin/src/scripts/FileConn.pm
+++ b/ldap/admin/src/scripts/FileConn.pm
@@ -54,10 +54,12 @@ require Exporter;
sub new {
my $class = shift;
my $filename = shift;
+ my $readonly = shift;
my $self = {};
$self = bless $self, $class;
+ $self->{readonly} = $readonly;
$self->read($filename);
return $self;
@@ -103,8 +105,12 @@ sub iterate {
my $context = shift;
my $suppress = shift;
my $ndn = normalizeDN($dn);
- my $children = $self->{$ndn}->{children};
- if (($scope != LDAP_SCOPE_ONELEVEL) && $self->{$ndn}->{data} && !$suppress) {
+ my $children;
+ if (exists($self->{$ndn}) and exists($self->{$ndn}->{children})) {
+ $children = $self->{$ndn}->{children};
+ }
+ if (($scope != LDAP_SCOPE_ONELEVEL) && exists($self->{$ndn}) &&
+ exists($self->{$ndn}->{data}) && $self->{$ndn}->{data} && !$suppress) {
&{$callback}($self->{$ndn}->{data}, $context);
}
@@ -146,7 +152,7 @@ sub write {
$filename = $self->{filename};
}
- if (!$self->{filename}) {
+ if (!$self->{filename} or $self->{readonly}) {
return;
}
@@ -181,8 +187,14 @@ sub printError
print "$str ", $self->getErrorString(), "\n";
}
+sub DESTROY {
+ my $self = shift;
+ $self->close();
+}
+
sub close {
my $self = shift;
+ return if ($self->{readonly});
$self->write();
}
@@ -280,7 +292,7 @@ sub search {
$self->{entries} = [];
my $ndn = normalizeDN($basedn);
- if (!exists($self->{$ndn})) {
+ if (!exists($self->{$ndn}) or !exists($self->{$ndn}->{data})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return undef;
}
@@ -308,12 +320,22 @@ sub add {
my $parentdn = getParentDN($dn);
my $nparentdn = normalizeDN($parentdn);
+
$self->setErrorCode(0);
+ # special case of root DSE
+ if (!$ndn and exists($self->{$ndn}) and
+ !exists($self->{$ndn}->{data})) {
+ $self->{$ndn}->{data} = $entry;
+ $self->write();
+ return 1;
+ }
+
if (exists($self->{$ndn})) {
$self->setErrorCode(LDAP_ALREADY_EXISTS);
return 0;
}
- if ($nparentdn && !exists($self->{$nparentdn})) {
+
+ if ($ndn && $nparentdn && !exists($self->{$nparentdn})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return 0;
}
@@ -321,7 +343,10 @@ sub add {
# data is the actual Entry
# children is the array ref of the one level children of this dn
$self->{$ndn}->{data} = $entry;
- push @{$self->{$nparentdn}->{children}}, $self->{$ndn};
+ # don't add parent to list of children
+ if ($nparentdn ne $ndn) {
+ push @{$self->{$nparentdn}->{children}}, $self->{$ndn};
+ }
return 1;
}
@@ -339,6 +364,7 @@ sub update {
}
$self->{$ndn}->{data} = $entry;
+ $self->write();
return 1;
}
@@ -370,20 +396,23 @@ sub delete {
my $parentdn = getParentDN($dn);
my $nparentdn = normalizeDN($parentdn);
# delete this node from its parent
- for (my $ii = 0; $ii < @{$self->{$nparentdn}->{children}}; ++$ii) {
- # find matching hash ref in parent's child list
- if ($self->{$nparentdn}->{children}->[$ii] eq $self->{$ndn}) {
- # remove that element from the array
- splice @{$self->{$nparentdn}->{children}}, $ii, 1;
- # done - should only ever be one matching child
- last;
+ if ($ndn ne $nparentdn) {
+ for (my $ii = 0; $ii < @{$self->{$nparentdn}->{children}}; ++$ii) {
+ # find matching hash ref in parent's child list
+ if ($self->{$nparentdn}->{children}->[$ii] eq $self->{$ndn}) {
+ # remove that element from the array
+ splice @{$self->{$nparentdn}->{children}}, $ii, 1;
+ # done - should only ever be one matching child
+ last;
+ }
}
}
# delete this node
delete $self->{$ndn};
- return 0;
+ $self->write();
+ return 1;
}
1;
diff --git a/ldap/admin/src/scripts/Migration.pm.in b/ldap/admin/src/scripts/Migration.pm.in
index 94123d375..211227092 100644
--- a/ldap/admin/src/scripts/Migration.pm.in
+++ b/ldap/admin/src/scripts/Migration.pm.in
@@ -101,16 +101,24 @@ options:
--version Print the version and exit
--debug Turn on debugging
--oldsroot The old server root directory to migrate from
- --actualsroot This is the old location of the old server root. See below.
+ --actualsroot This is the old location of the old server root.
+ See below.
--silent Use silent setup - no user input
- --file=name Use the file 'name' in .inf format to supply the default answers
- --keepcache Do not delete the temporary .inf file generated by this program
- --logfile Log migration messages to this file - otherwise, a temp file will be used
- --instance By default, all directory server instances will be migrated. You can use
- this argument to specify one or more (e.g. -i slapd-foo -i slapd-bar) if
- you do not want to migrate all of them.
-For all options, you can also use the short name e.g. -h, -d, etc. For the -d argument,
-specifying it more than once will increase the debug level e.g. -ddddd
+ --file=name Use the file 'name' in .inf format to supply the
+ default answers
+ --keepcache Do not delete the temporary .inf file generated by
+ this program
+ --logfile Log migration messages to this file - otherwise, a temp
+ file will be used
+ --instance By default, all directory server instances will be
+ migrated. You can use this argument to specify one
+ or more (e.g. -i slapd-foo -i slapd-bar) if you do
+ not want to migrate all of them.
+ --cross See below.
+
+For all options, you can also use the short name e.g. -h, -d, etc.
+For the -d argument, specifying it more than once will increase the
+debug level e.g. -ddddd
args:
You can supply default .inf data in this format:
@@ -119,7 +127,18 @@ e.g.
General.FullMachineName=foo.example.com
or
"slapd.Suffix=dc=example, dc=com"
-Values passed in this manner will override values in an .inf file given with the -f argument.
+Values passed in this manner will override values in an .inf file
+given with the -f argument. If you need to specify the cleartext
+directory manager password (e.g. in order to do remote migration),
+you must specify the password for each instance in a section whose
+name is the instance name e.g.
+ [slapd-ldap1]
+ RootDNPwd=ldap1password
+ [slapd-ldap2]
+ RootDNPwd=ldap2password
+or on the command line like this:
+ command ... slapd-ldap1.RootDNPwd=ldap1password \
+ slapd-ldap2.RootDNPwd=ldap2password ...
actualsroot:
This is used when you must migrate from one machine to another. The
@@ -142,13 +161,36 @@ as the --actualsroot argument, and use /migration/opt/myds for the
--oldsroot argument. That is, the oldsroot is the physical location of
the files on disk. The actualsroot is the old value of the server root
on the source machine.
+
+cross:
+Also known as crossplatform, or 'c', or 'x'.
+This is when the source machine is a different architecture than the
+destination machine. In this case, only certain data will be available
+for migration. Changelog information will not be migrated, and replicas
+will need to be reinitialized (if migrating masters or hubs). This type
+of migration requires that all of your old databases have been dumped
+to LDIF format, and the LDIF file must be in the default database directory
+(usually /opt/@brand@-ds/slapd-instance/db), and the LDIF file must have
+the same name as the database instance directory, with a ".ldif". For
+example, if you have
+ /opt/@brand@-ds/slapd-instance/db/userRoot/ and
+ /opt/@brand@-ds/slapd-instance/db/NetscapeRoot/
+you must first use db2ldif to export these databases to LDIF e.g.
+ cd /opt/@brand@-ds/slapd-instance
+ ./db2ldif -n userRoot -a /opt/@brand@-ds/slapd-instance/db/userRoot.ldif and
+ ./db2ldif -n NetscapeRoot -a /opt/@brand@-ds/slapd-instance/db/NetscapeRoot.ldif
+
+Then you must somehow make your old server root directory available on
+the destination machine, either by creating a tar archive on the source
+and copying it to the destination, or by network mounting the source
+directory on the destination machine.
EOF
}
sub init {
my $self = shift;
$self->{res} = shift;
- my ($silent, $inffile, $keep, $preonly, $logfile, $oldsroot, $actualsroot);
+ my ($silent, $inffile, $keep, $preonly, $logfile, $oldsroot, $actualsroot, $crossplatform);
my @instances;
GetOptions('help|h|?' => sub { VersionMessage(); HelpMessage(); exit 0 },
@@ -161,6 +203,7 @@ sub init {
'logfile|l=s' => \$logfile,
'oldsroot|o=s' => \$oldsroot,
'actualsroot|a=s' => \$actualsroot,
+ 'crossplatform|cross|c|x' => \$crossplatform,
'instance|i=s' => \@instances
);
@@ -180,6 +223,7 @@ sub init {
$self->{keep} = $keep;
$self->{preonly} = $preonly;
$self->{logfile} = $logfile;
+ $self->{crossplatform} = $crossplatform;
$self->{log} = new SetupLog($self->{logfile}, "migrate");
# if user supplied inf file, use that to initialize
if (defined($self->{inffile})) {
@@ -220,7 +264,12 @@ sub init {
glob("$self->{oldsroot}/slapd-*");
}
- die "No instances found to migrate" unless (@instances);
+ if (!@instances) {
+ $self->msg($FATAL, "error_no_instances", $self->{oldsroot});
+ VersionMessage();
+ HelpMessage();
+ exit 1;
+ }
$self->{instances} = \@instances;
}
diff --git a/ldap/admin/src/scripts/Util.pm.in b/ldap/admin/src/scripts/Util.pm.in
index b8b1528fc..364e91152 100644
--- a/ldap/admin/src/scripts/Util.pm.in
+++ b/ldap/admin/src/scripts/Util.pm.in
@@ -47,10 +47,12 @@ require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword debug createDSInstance createInfFromConfig);
+ getHashedPassword debug createDSInstance createInfFromConfig
+ isValidServerID);
@EXPORT_OK = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword debug createDSInstance createInfFromConfig);
+ getHashedPassword debug createDSInstance createInfFromConfig
+ isValidServerID);
use strict;
@@ -102,6 +104,40 @@ sub isValidDN {
return ($dn =~ /^[0-9a-zA-Z_-]+=.*$/);
}
+sub isValidServerID {
+ my $servid = shift;
+ my $validchars = '#%,.:\w@_-';
+ return $servid =~ /^[$validchars]+$/o;
+}
+
+sub isValidUser {
+ my $user = shift;
+ # convert numeric uid to string
+ my $strans = $user;
+ if ($user =~ /^\d+$/) { # numeric - convert to string
+ $strans = getpwuid $user;
+ if (!$strans) {
+ return ("dialog_ssuser_error", $user);
+ }
+ }
+ if ($> != 0) { # if not root, the user must be our uid
+ my $username = getlogin;
+ if ($strans ne $username) {
+ return ("dialog_ssuser_must_be_same", $username);
+ }
+ } else { # user is root - verify id
+ my $nuid = getpwnam $strans;
+ if (!defined($nuid)) {
+ return ("dialog_ssuser_error", $user);
+ }
+ if (!$nuid) {
+ return ("dialog_ssuser_root_warning");
+ }
+ }
+
+ return ();
+}
+
# delete the subtree starting from the passed entry
sub delete_all
{
diff --git a/ldap/admin/src/scripts/migrate-ds.res b/ldap/admin/src/scripts/migrate-ds.res
index e0eec6985..f5cfef155 100644
--- a/ldap/admin/src/scripts/migrate-ds.res
+++ b/ldap/admin/src/scripts/migrate-ds.res
@@ -1,4 +1,13 @@
begin_ds_migration = Beginning migration of directory server instances in %s . . .\n
end_ds_migration = Directory server migration is complete. Please check output and log files for details.\n
migration_exiting = Exiting . . .\nLog file is '%s'\n\n
-instance_already_exists = The target directory server instance already exists at %s. Skipping migration.\n\
+instance_already_exists = The target directory server instance already exists at %s. Skipping migration. Note that if you want to migrate the old instance you will have to first remove the new one of the same name.\n\n
+error_reading_entry = Could not read the entry '%s'. Error: %s\n
+error_updating_merge_entry = Could not %s the migrated entry '%s' in the target directory server. Error: %s\n
+error_importing_migrated_db = Could not import the LDIF file '%s' for the migrated database. Error: %s. Please check the directory server error log for more details.\n
+error_reading_olddbconfig = Could not read the old database configuration information. Error: %s\n
+error_migrating_schema = Could not copy old schema file '%s'. Error: %s\n
+error_copying_dbdir = Could not copy database directory '%s' to '%s'. Error: %s\n
+error_copying_dbfile = Could not copy database file '%s' to '%s'. Error: %s\n
+error_dbsrcdir_not_exist = Could not copy from the database source directory '%s' because it does not exist. Please check your configuration.\n
+error_no_instances = Could not find any instances in the old directory '%s' to migrate.\n
diff --git a/ldap/admin/src/scripts/setup-ds.pl.in b/ldap/admin/src/scripts/setup-ds.pl.in
index f52cd1692..b455a5795 100644
--- a/ldap/admin/src/scripts/setup-ds.pl.in
+++ b/ldap/admin/src/scripts/setup-ds.pl.in
@@ -42,6 +42,7 @@ use lib '@perldir@';
use strict;
use Setup;
+use SetupLog;
use Inf;
use Resource;
use DialogManager;
@@ -78,4 +79,12 @@ if ($rc) {
$setup->msg('created_dsinstance', $output);
}
-$setup->doExit();
+END {
+ if ($setup) {
+ if (!$setup->{keep}) {
+ unlink $setup->{inffile};
+ }
+
+ $setup->doExit();
+ }
+}
diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in
index 4b8982e1a..329a7c24b 100644
--- a/ldap/admin/src/scripts/setup-ds.res.in
+++ b/ldap/admin/src/scripts/setup-ds.res.in
@@ -95,3 +95,12 @@ error_mapping_token_ldiftmpl = The entry '%s' in LDIF file '%s' contains a token
error_deleteall_entries = Error deleting entry '%s' and all children. Error: %s\n
error_adding_entry = Error adding entry '%s'. Error: %s\n
error_updating_entry = Error updating entry '%s'. Error: %s\n
+
+
+error_invalid_param = The parameter '%s' has an invalid value '%s'.\n
+error_port_available = The port number '%s' is not available for use. This may be due to an\
+invalid port number, or the port already being in use by another\
+program, or low port restriction. Please choose another value for\
+ServerPort. Error: $!\n
+error_invalid_serverid = The ServerIdentifier '%s' contains invalid characters. It must\
+contain only alphanumeric characters and the following: #%,.:@_-\n
| 0 |
b4c3983cad8e6c0e47494bcbd98466d4a274a1db
|
389ds/389-ds-base
|
Ticket #278 - Schema replication update failed: Invalid syntax
https://fedorahosted.org/389/ticket/278
Resolves: Ticket #278
Bug Description: Schema replication update failed: Invalid syntax
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: Schema replication apparently either sends everything or
re-reads everything. unhashed#user#password is an invalid attribute
name - # is not allowed in an attribute name. The fix is to explicitly
allow this particular attribute name.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit b4c3983cad8e6c0e47494bcbd98466d4a274a1db
Author: Rich Megginson <[email protected]>
Date: Thu Feb 2 15:54:27 2012 -0700
Ticket #278 - Schema replication update failed: Invalid syntax
https://fedorahosted.org/389/ticket/278
Resolves: Ticket #278
Bug Description: Schema replication update failed: Invalid syntax
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: Schema replication apparently either sends everything or
re-reads everything. unhashed#user#password is an invalid attribute
name - # is not allowed in an attribute name. The fix is to explicitly
allow this particular attribute name.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index f5bc0c206..5f1438b40 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -3644,6 +3644,11 @@ schema_check_name(char *name, PRBool isAttribute, char *errorbuf,
return 0;
}
+ if (!strcasecmp(name, PSEUDO_ATTR_UNHASHEDUSERPASSWORD)) {
+ /* explicitly allow this badly named attribute */
+ return 1;
+ }
+
/* attribute names must begin with a letter */
if ( (isascii (name[0]) == 0) || (isalpha (name[0]) == 0)) {
if ( (strlen(name) + 80) < BUFSIZ ) {
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.