commit_id
string
repo
string
commit_message
string
diff
string
label
int64
07dddbe1142bc3998df3ff5dbf54cd78d21d199e
389ds/389-ds-base
Issue 4596 - BUG - lto linking issues Bug Description: Fedora is introducing lto by default which may affect our build especially with rust and asan Fix Description: Adapt how we use lto and how we link in our builds so that lto works for gcc. fixes: https://github.com/389ds/389-ds-base/issues/4596 Author: William Brown <[email protected]> Review by: ???
commit 07dddbe1142bc3998df3ff5dbf54cd78d21d199e Author: William Brown <[email protected]> Date: Wed Sep 15 12:14:52 2021 +1000 Issue 4596 - BUG - lto linking issues Bug Description: Fedora is introducing lto by default which may affect our build especially with rust and asan Fix Description: Adapt how we use lto and how we link in our builds so that lto works for gcc. fixes: https://github.com/389ds/389-ds-base/issues/4596 Author: William Brown <[email protected]> Review by: ??? diff --git a/Makefile.am b/Makefile.am index dfaaa47dc..a37c2c8cb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,11 +60,11 @@ CARGO_FLAGS = @cargo_defs@ if CLANG_ENABLE RUSTC_FLAGS = @asan_rust_defs@ @msan_rust_defs@ @tsan_rust_defs@ @debug_rust_defs@ -RUSTC_LINK_FLAGS = -C link-arg=-fuse-ld=lld +RUSTC_LINK_FLAGS = -Clink-arg=-fuse-ld=lld RUST_LDFLAGS = -ldl -lpthread -lc -lm -lrt -lutil else RUSTC_FLAGS = @asan_rust_defs@ @msan_rust_defs@ @tsan_rust_defs@ @debug_rust_defs@ -RUSTC_LINK_FLAGS = +RUSTC_LINK_FLAGS = -Clink-arg=-fuse-ld=ld # This avoids issues with stderr being double provided with clang + asan. RUST_LDFLAGS = -ldl -lpthread -lgcc_s -lc -lm -lrt -lutil endif @@ -81,7 +81,7 @@ CLANG_LDFLAGS = -latomic -fuse-ld=lld EXPORT_LDFLAGS = else CLANG_ON = 0 -CLANG_LDFLAGS = +CLANG_LDFLAGS = -flto if DEBUG EXPORT_LDFLAGS = -rdynamic endif
0
7dc991b16b97bacb69ddb334358e27e1220ca27b
389ds/389-ds-base
Ticket 49209 - Hang due to omitted replica lock release Bug Description: When an operation is canceled (failure), its csn is aborted and removed from the pending list. If at that time the pending list is empty or the csn is not found in that list, the cancel callback forgots to release the replica lock Fix Description: Release replica lock systematically, whether cnsplRemove fails or not https://pagure.io/389-ds-base/issue/49209 Reviewed by: Mark Reynolds (thanks Mark !!) Platforms tested: F23 Flag Day: no Doc impact: no
commit 7dc991b16b97bacb69ddb334358e27e1220ca27b Author: Thierry Bordaz <[email protected]> Date: Tue Apr 4 10:44:55 2017 +0200 Ticket 49209 - Hang due to omitted replica lock release Bug Description: When an operation is canceled (failure), its csn is aborted and removed from the pending list. If at that time the pending list is empty or the csn is not found in that list, the cancel callback forgots to release the replica lock Fix Description: Release replica lock systematically, whether cnsplRemove fails or not https://pagure.io/389-ds-base/issue/49209 Reviewed by: Mark Reynolds (thanks Mark !!) Platforms tested: F23 Flag Day: no Doc impact: no diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c index 320c1440c..0661d60e8 100644 --- a/ldap/servers/plugins/replication/repl5_replica.c +++ b/ldap/servers/plugins/replication/repl5_replica.c @@ -3662,6 +3662,7 @@ abort_csn_callback(const CSN *csn, void *data) int rc = csnplRemove(r->min_csn_pl, csn); if (rc) { slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "abort_csn_callback - csnplRemove failed"); + replica_unlock(r->repl_lock); return; } }
0
cc435b8c382f7da662b5c27339d23fd33a8f4117
389ds/389-ds-base
Ticket #48203 - Fix coverity issues - 07/14/2015 Description: Overrunning array "mctx.negativeErrors" of 19 4-byte elements at element index 122 (byte offset 488) using index "abs(err)" (which evaluates to 122). Commit 71be5faaa478593bb056887410ca8e48e05b2fe4 to fix Ticket #47799 introduced this problem. The error count checking has to be done per error. https://fedorahosted.org/389/ticket/48203 Reviewed by [email protected] (Thank you, Rich!)
commit cc435b8c382f7da662b5c27339d23fd33a8f4117 Author: Noriko Hosoi <[email protected]> Date: Tue Jul 14 16:00:03 2015 -0700 Ticket #48203 - Fix coverity issues - 07/14/2015 Description: Overrunning array "mctx.negativeErrors" of 19 4-byte elements at element index 122 (byte offset 488) using index "abs(err)" (which evaluates to 122). Commit 71be5faaa478593bb056887410ca8e48e05b2fe4 to fix Ticket #47799 introduced this problem. The error count checking has to be done per error. https://fedorahosted.org/389/ticket/48203 Reviewed by [email protected] (Thank you, Rich!) diff --git a/ldap/servers/slapd/tools/ldclt/threadMain.c b/ldap/servers/slapd/tools/ldclt/threadMain.c index 5d915fde4..88353c6ce 100644 --- a/ldap/servers/slapd/tools/ldclt/threadMain.c +++ b/ldap/servers/slapd/tools/ldclt/threadMain.c @@ -477,7 +477,7 @@ addErrorStat ( #else if ((err <= 0) || (err >= MAX_ERROR_NB)) #endif - { + { if (mctx.errorsBad > mctx.maxErrors) { printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid); (void) printGlobalStatistics(); /*JLS 25-08-00*/ @@ -485,8 +485,22 @@ addErrorStat ( ldclt_sleep (5); ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/ } - } else { - if (mctx.errors[err] + mctx.negativeErrors[abs(err)] > mctx.maxErrors) { + } +#if defined(USE_OPENLDAP) + else if (err < 0) + { + if (mctx.negativeErrors[abs(err)] > mctx.maxErrors) { + printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid); + (void) printGlobalStatistics(); /*JLS 25-08-00*/ + fflush (stdout); + ldclt_sleep (5); + ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/ + } + } +#endif + else + { + if (mctx.errors[err] > mctx.maxErrors) { printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid); (void) printGlobalStatistics(); /*JLS 25-08-00*/ fflush (stdout);
0
bfcf152ef07ecaaf533afc8cdadbd273ed9b9024
389ds/389-ds-base
Ticket 48895 - tests package should be noarch Bug description: 389-ds-base-tests has builds for all architectures, though it contains only python scripts. It should be noarch instead. Fix description: Change BuildArch for 389-ds-base-tests package to noarch. https://fedorahosted.org/389/ticket/48895 Reviewed by: [email protected].
commit bfcf152ef07ecaaf533afc8cdadbd273ed9b9024 Author: Viktor Ashirov <[email protected]> Date: Tue Jun 21 11:34:47 2016 +0200 Ticket 48895 - tests package should be noarch Bug description: 389-ds-base-tests has builds for all architectures, though it contains only python scripts. It should be noarch instead. Fix description: Change BuildArch for 389-ds-base-tests package to noarch. https://fedorahosted.org/389/ticket/48895 Reviewed by: [email protected]. diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index c0ceb9811..d08d37962 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -224,6 +224,7 @@ Obsoletes: %{name} <= 1.3.5.4 Summary: The lib389 Continuous Integration Tests Group: Development/Libraries Requires: python-lib389 +BuildArch: noarch %description tests The lib389 CI tests that can be run against the Directory Server.
0
f082527516088a40074561aee72822a355a6c829
389ds/389-ds-base
Issue 4489 - Remove return statement from a void function (#4490) Bug Description: void function returns a value, causing compiler warnings. Fix Description: Remove return statement. Relates: https://github.com/389ds/389-ds-base/issues/4419 Reviewed by: One line rule
commit f082527516088a40074561aee72822a355a6c829 Author: James Chapman <[email protected]> Date: Thu Dec 10 03:15:43 2020 +0000 Issue 4489 - Remove return statement from a void function (#4490) Bug Description: void function returns a value, causing compiler warnings. Fix Description: Remove return statement. Relates: https://github.com/389ds/389-ds-base/issues/4419 Reviewed by: One line rule diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c index 583fa448f..4957f51b9 100644 --- a/ldap/servers/slapd/task.c +++ b/ldap/servers/slapd/task.c @@ -473,7 +473,7 @@ void slapi_task_set_warning(Slapi_Task *task, task_warning warn) { if (task) { - return task->task_warn |= warn; + task->task_warn |= warn; } }
0
5370d95a66304870be8c7c1871ef1cb12d72ae86
389ds/389-ds-base
Resolves: bug 367721 Bug Description: dbgen.pl uses incorrect perl interpreter on hpux Reviewed by: nhosoi (Thanks!) Fix Description: Set @perlexec@ to the correct platform specific perl location. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no QA impact: should be covered by regular nightly and manual testing New Tests integrated into TET: none
commit 5370d95a66304870be8c7c1871ef1cb12d72ae86 Author: Rich Megginson <[email protected]> Date: Wed Nov 14 15:07:35 2007 +0000 Resolves: bug 367721 Bug Description: dbgen.pl uses incorrect perl interpreter on hpux Reviewed by: nhosoi (Thanks!) Fix Description: Set @perlexec@ to the correct platform specific perl location. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no QA impact: should be covered by regular nightly and manual testing New Tests integrated into TET: none diff --git a/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in b/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in index 43f5e5de4..00bd6541d 100755 --- a/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in +++ b/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!@perlexec@ # 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
0
855910d56b83314281ae274fd7573635f0d7fa2b
389ds/389-ds-base
204410 - Pick up new ldapcsdk, nspr, and sasl components
commit 855910d56b83314281ae274fd7573635f0d7fa2b Author: Nathan Kinder <[email protected]> Date: Mon Aug 28 23:23:59 2006 +0000 204410 - Pick up new ldapcsdk, nspr, and sasl components diff --git a/component_versions.mk b/component_versions.mk index c6b15505b..e817484c2 100644 --- a/component_versions.mk +++ b/component_versions.mk @@ -52,7 +52,7 @@ # naming scheme. # NSPR ifndef NSPR_RELDATE - NSPR_RELDATE = v4.6.2 + NSPR_RELDATE = v4.6.2-dstest endif # SECURITY (NSS) LIBRARY @@ -76,10 +76,10 @@ endif # LDAP SDK ifndef LDAP_RELDATE - LDAP_RELDATE = v5.17 + LDAP_RELDATE = v5.17-sun-merge endif ifndef LDAPCOMP_DIR - LDAPCOMP_DIR=ldapsdk50 + LDAPCOMP_DIR=ldapcsdk endif # CRIMSONJAR @@ -185,7 +185,7 @@ ifndef SASL_VERSDIR SASL_VERSDIR=cyrus endif ifndef SASL_RELDATE - SASL_RELDATE=v2.1.20.1 + SASL_RELDATE=v2.1.20.2 endif # jakarta/axis for DSMLGW diff --git a/internal_comp_deps.mk b/internal_comp_deps.mk index c0ed246eb..49df63b82 100644 --- a/internal_comp_deps.mk +++ b/internal_comp_deps.mk @@ -53,7 +53,7 @@ BOMB=$(BUILD_BOMB) endif # BUILD_PUMPKIN ifndef NSPR_SOURCE_ROOT -NSPR_IMPORT = $(COMPONENTS_DIR)/nspr/$(NSPR_RELDATE)/$(FULL_RTL_OBJDIR) +NSPR_IMPORT = $(COMPONENTS_DIR_DEV)/nspr/$(NSPR_RELDATE)/$(FULL_RTL_OBJDIR) NSPR_DEP = $(NSPR_LIBPATH)/libnspr4.$(LIB_SUFFIX) ifndef NSPR_PULL_METHOD @@ -140,8 +140,8 @@ ifndef LDAP_VERSION LDAP_VERSION = $(LDAP_RELDATE) endif ifndef LDAP_SBC -#LDAP_SBC = $(COMPONENTS_DIR_DEV) -LDAP_SBC = $(COMPONENTS_DIR) +LDAP_SBC = $(COMPONENTS_DIR_DEV) +#LDAP_SBC = $(COMPONENTS_DIR) endif LDAPOBJDIR = $(FULL_RTL_OBJDIR) # LDAP does not have PTH version, so here is the hack which treat non PTH @@ -162,7 +162,7 @@ endif # Solaris and HP-UX PA-RISC only ######################################### # if building 64 bit version, also need the 32 bit version of NSS and NSPR ifeq ($(PACKAGE_LIB32), 1) - NSPR_IMPORT_32 = $(COMPONENTS_DIR)/nspr/$(NSPR_RELDATE)/$(FULL_RTL_OBJDIR_32) + NSPR_IMPORT_32 = $(COMPONENTS_DIR_DEV)/nspr/$(NSPR_RELDATE)/$(FULL_RTL_OBJDIR_32) SECURITY_IMPORT_32 = $(COMPONENTS_DIR)/nss/$(SECURITY_RELDATE)/$(FULL_RTL_OBJDIR_32) LDAP_RELEASE_32 = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(FULL_RTL_OBJDIR_32) SECURITY_FILES_32 = $(subst $(SPACE),$(COMMA),$(SECURITY_FILES_32_TMP)) diff --git a/ldap/admin/src/Makefile b/ldap/admin/src/Makefile index d7c493584..e7d43c486 100644 --- a/ldap/admin/src/Makefile +++ b/ldap/admin/src/Makefile @@ -77,7 +77,7 @@ DYNAMIC_DEPLIBS=$(LDAP_COMMON_LIBS_DEP) DYNAMIC_DEPLINK=$(LDAP_ADMLIB) $(LDAP_COMMON_LIBS) endif -EXTRA_LIBS_DEP += $(NSPR_DEP) $(LDAPSDK_DEP) +EXTRA_LIBS_DEP += $(NSPR_DEP) $(LDAPSDK_DEP) $(SASL_DEP) ifeq ($(USE_ADMINSERVER), 1) EXTRA_LIBS_DEP += $(ADMINUTIL_DEP) endif @@ -98,7 +98,7 @@ EXTRA_LIBS += $(SECURITYLINK) $(NSPRLINK) ifeq ($(USE_SETUPUTIL), 1) EXTRA_LIBS += $(SETUPUTIL_S_LINK) endif -EXTRA_LIBS += $(ICULINK) $(OLD_EXTRA_LIBS) +EXTRA_LIBS += $(ICULINK) $(SASL_LINK) $(OLD_EXTRA_LIBS) # these are the libraries to use when building the installer for the open source version OPENSOURCE_LIBS = $(LDAP_ADMLIB) $(LDAP_NOSSL_LINK) $(SECURITYLINK) $(NSPRLINK) diff --git a/ldap/clients/dsgw/Makefile b/ldap/clients/dsgw/Makefile index 037b1f8d8..085cb92d1 100644 --- a/ldap/clients/dsgw/Makefile +++ b/ldap/clients/dsgw/Makefile @@ -150,18 +150,18 @@ LIBS := $(DISTLIBFLAG) $(LINKOPTIONS) $(LIBLDAPU) $(LDAPLINK) \ $(ADMINUTIL_LINK) $(DYN_NSHTTPD) \ $(LDAP_LIBLDBM) $(ICULINK) $(NSPRLINK) \ $(LDAP_LIBLDIF) $(ALIBS) $(DBMLINK) $(SECURITYLINK) \ - $(THREADSLIB) $(NSPRLINK) $(LDAP_LIBLITEKEY) + $(SASL_LINK) $(THREADSLIB) $(NSPRLINK) $(LDAP_LIBLITEKEY) LIBS_DEP = $(LIBLDAPU_DEP) $(LDAP_LIBLDBM_DEP) $(LDAP_LIBLDIF_DEP) -LIBS_DEP += $(LDAPSDK_DEP) $(ICU_DEP) $(NSPR_DEP) $(DB_LIB_DEP) +LIBS_DEP += $(LDAPSDK_DEP) $(SASL_DEP) $(ICU_DEP) $(NSPR_DEP) $(DB_LIB_DEP) NSECLIBS = $(DISTLIBFLAG) $(SSLLIBFLAG) $(LINKOPTIONS) $(LIBLDAPU) \ $(LDAP_NOSSL_LINK) $(ADMINUTIL_LINK) \ $(LDAP_LIBLDBM) $(ICULINK) $(NOSSLLIBS) \ - $(LDAP_LIBLDIF) $(DBMLINK) $(ALIBS) \ + $(LDAP_LIBLDIF) $(SASL_LINK) $(DBMLINK) $(ALIBS) \ $(THREADSLIB) $(NSPRLINK) $(LDAP_LIBLITEKEY) endif NSECLIBS_DEP=$(SECGLUEOBJS) -NSECLIBS_DEP += $(ICU_DEP) +NSECLIBS_DEP += $(ICU_DEP) $(SASL_DEP) #EXTRA_LIBS += -l$(LIBARES) diff --git a/ldap/cm/newinst/Makefile b/ldap/cm/newinst/Makefile index 890f83751..321cc3c85 100644 --- a/ldap/cm/newinst/Makefile +++ b/ldap/cm/newinst/Makefile @@ -171,7 +171,7 @@ $(BINDEST)/uninstall: uninstall $(BINDEST)/ns-config: $(OBJS1) $(OBJS2) $(PURIFY) $(CXX) $(SHARED_FLAG) $(CFLAGS) $(MCC_INCLUDE) $(INCDIR) \ -o $(BINDEST)/ns-config $(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) $(OBJS1) $(OBJS2) $(SETUPUTILLINK) $(LDAPLINK) $(SECURITYLINK) $(NSPRLINK) \ - $(EXTRA_LIBS) $(CURSES) + $(SASL_LINK) $(EXTRA_LIBS) $(CURSES) $(RELDIR)/shared/bin/%: sec_tools_wrapper $(RELDIR)/shared/bin -@$(RM) $@ diff --git a/ldap/servers/slapd/tools/Makefile b/ldap/servers/slapd/tools/Makefile index 689231c37..fc1634622 100644 --- a/ldap/servers/slapd/tools/Makefile +++ b/ldap/servers/slapd/tools/Makefile @@ -105,14 +105,15 @@ DEPLIBS= EXTRA_LIBS_DEP = $(LDAPSDK_DEP) \ $(LDAP_LIBLDIF_DEP) \ $(LDAP_SLIBLCACHE_DEP) $(DB_LIB_DEP) $(LIBSLAPD_DEP) \ - $(LDAP_COMMON_LIBS_DEP) + $(LDAP_COMMON_LIBS_DEP) $(SASL_DEP) EXTRA_LIBS += $(LDAPLINK) \ $(LDAP_SLIBLCACHE) $(DB_LIB) \ $(PLATFORM_SPECIFIC_EXTRA_LIBRARY) $(LIBSLAPD) $(LDAP_LIBLITEKEY) \ $(ALIBS) \ $(SECURITYLINK) $(DBMLINK) \ - $(THREADSLIB) $(LDAP_COMMON_LIBS) $(NSPRLINK) $(SVRCORELINK) + $(THREADSLIB) $(LDAP_COMMON_LIBS) $(NSPRLINK) $(SVRCORELINK) \ + $(SASL_LINK) ifeq ($(ARCH), Linux) EXTRA_LIBS += -lcrypt @@ -180,7 +181,7 @@ all: $(OBJDEST) $(BINDIR) $(LDAP_ADMIN_BIN_RELDIR) $(BINS) buildRsearch buildLdc extras: $(OBJDEST) $(BINDIR) $(EGGENCODE) $(LDIF): $(OBJDEST)/ldif.o $(LDAP_LIBLDIF_DEP) - $(LINK_EXE) $< $(LDAP_LIBLDIF) + $(LINK_EXE) $< $(LDAP_LIBLDIF) $(SASL_LINK) $(PWDHASH): $(OBJS1) $(EXTRA_LIBS_DEP) $(LINK_EXE) $(OBJS1) $(EXTRA_LIBS) diff --git a/ldap/servers/slapd/tools/ldclt/Makefile b/ldap/servers/slapd/tools/ldclt/Makefile index 687950f0c..d4a636a90 100644 --- a/ldap/servers/slapd/tools/ldclt/Makefile +++ b/ldap/servers/slapd/tools/ldclt/Makefile @@ -61,12 +61,12 @@ else OBJEXT =.o endif -EXTRA_LIBS_DEP = $(LDAPSDK_DEP) $(DB_LIB_DEP) $(LDAP_COMMON_LIBS_DEP) +EXTRA_LIBS_DEP = $(LDAPSDK_DEP) $(DB_LIB_DEP) $(LDAP_COMMON_LIBS_DEP) $(SASL_DEP) EXTRA_LIBS += $(LDAPLINK) $(DB_LIB) \ $(PLATFORM_SPECIFIC_EXTRA_LIBRARY) \ $(ALIBS) $(NSPRLINK) $(SECURITYLINK) \ - $(THREADSLIB) $(LDAP_COMMON_LIBS) + $(THREADSLIB) $(LDAP_COMMON_LIBS) $(SASL_LINK) LDCLTSRC = \ data.c \ diff --git a/ldap/servers/slapd/tools/rsearch/Makefile b/ldap/servers/slapd/tools/rsearch/Makefile index 156d567a3..c265489f6 100644 --- a/ldap/servers/slapd/tools/rsearch/Makefile +++ b/ldap/servers/slapd/tools/rsearch/Makefile @@ -63,12 +63,12 @@ else # OSF1 PLATFORM_SPECIFIC_EXTRA_LIBRARY = endif # OSF1 -EXTRA_LIBS_DEP = $(LDAPSDK_DEP) $(DB_LIB_DEP) $(LDAP_COMMON_LIBS_DEP) +EXTRA_LIBS_DEP = $(LDAPSDK_DEP) $(DB_LIB_DEP) $(LDAP_COMMON_LIBS_DEP) $(SASL_DEP) EXTRA_LIBS += $(LDAPLINK) $(DB_LIB) \ $(PLATFORM_SPECIFIC_EXTRA_LIBRARY) \ $(ALIBS) $(NSPRLINK) $(SECURITYLINK) \ - $(THREADSLIB) $(LDAP_COMMON_LIBS) + $(THREADSLIB) $(LDAP_COMMON_LIBS) $(SASL_LINK) ifeq ($(ARCH), Linux) EXTRA_LIBS += -lcrypt
0
4e20a696f82cc66efec52868ff5513923c941643
389ds/389-ds-base
Ticket 14 - Remane dsadm to dsctl Bug Description: Rename dsadm to dsctl https://pagure.io/lib389/issue/14 Author: wibrown Review by: mreynolds (Thanks!)
commit 4e20a696f82cc66efec52868ff5513923c941643 Author: William Brown <[email protected]> Date: Mon Apr 3 13:16:02 2017 +1000 Ticket 14 - Remane dsadm to dsctl Bug Description: Rename dsadm to dsctl https://pagure.io/lib389/issue/14 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/src/lib389/cli/dsadm b/src/lib389/cli/dsadm deleted file mode 100755 index 4779b252c..000000000 --- a/src/lib389/cli/dsadm +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/python - -# --- 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 --- - -import argparse -import logging -import sys - -# This has to happen before we import DirSrv else it tramples our config ... :( -logging.basicConfig(format='%(message)s') - -from lib389.cli_base import _get_arg -from lib389 import DirSrv -from lib389.cli_adm import instance as cli_instance -from lib389.cli_adm import dbtasks as cli_dbtasks -from lib389.cli_base import disconnect_instance - -log = logging.getLogger("dsadm") - -if __name__ == '__main__': - - parser = argparse.ArgumentParser() - - parser.add_argument('-v', '--verbose', - help="Display verbose operation tracing during command execution", - action='store_true', default=False - ) - parser.add_argument('instance', - help="The name of the instance to act upon", - ) - - subparsers = parser.add_subparsers(help="action") - - # We stack our needed options in via submodules. - - cli_instance.create_parser(subparsers) - cli_dbtasks.create_parser(subparsers) - - # Then we tell it to execute. - - args = parser.parse_args() - - if args.verbose: - log.setLevel(logging.DEBUG) - else: - log.setLevel(logging.INFO) - - log.debug("The 389 Directory Server Administration Tool") - # Leave this comment here: UofA let me take this code with me provided - # I gave attribution. -- wibrown - log.debug("Inspired by works of: ITS, The University of Adelaide") - - log.debug("Called with: %s", args) - - # Assert we have a resources to work on. - if not hasattr(args, 'func'): - log.error("No action provided") - log.error("USAGE: dsadm [options] <resource> <action> [action options]") - sys.exit(1) - - # Connect - # inst = None - inst = DirSrv(verbose=args.verbose) - - result = True - - # Allocate the instance based on name - insts = inst.list(serverid=args.instance) - if len(insts) != 1: - raise ValueError("No such instance %s" % args.instance) - - inst.allocate(insts[0]) - log.debug('Instance allocated') - - if args.verbose: - result = args.func(inst, log, args) - else: - try: - result = args.func(inst, log, args) - except Exception as e: - log.debug(e, exc_info=True) - log.error("Error: %s" % e.message) - disconnect_instance(inst) - - if result is True: - log.info('FINISH: Command succeeded') - elif result is False: - log.info('FAIL: Command failed. See output for details.') - - # Done! - log.debug("dsadm is brought to you by the letter R and the number 27.") - - if result is False: - sys.exit(1) - diff --git a/src/lib389/cli/dscreate b/src/lib389/cli/dscreate index cec121ff4..ffcb114fe 100755 --- a/src/lib389/cli/dscreate +++ b/src/lib389/cli/dscreate @@ -16,7 +16,7 @@ import sys logging.basicConfig(format='%(message)s') from lib389 import DirSrv -from lib389.cli_adm import instance as cli_instance +from lib389.cli_ctl import instance as cli_instance log = logging.getLogger("dscreate") diff --git a/src/lib389/lib389/cli_adm/__init__.py b/src/lib389/lib389/cli_adm/__init__.py deleted file mode 100644 index d57ac3325..000000000 --- a/src/lib389/lib389/cli_adm/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# --- 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 --- - diff --git a/src/lib389/lib389/cli_adm/dbtasks.py b/src/lib389/lib389/cli_adm/dbtasks.py deleted file mode 100644 index 276f478e7..000000000 --- a/src/lib389/lib389/cli_adm/dbtasks.py +++ /dev/null @@ -1,18 +0,0 @@ -# --- 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 --- - -def dbtasks_db2index(inst, log, args): - # inst.db2index(suffixes=[args.suffix,]) - inst.db2index(bename=args.backend) - -def create_parser(subcommands): - db2index_parser = subcommands.add_parser('db2index', help="Initialise a reindex of the server database. The server must be stopped for this to proceed.") - # db2index_parser.add_argument('suffix', help="The suffix to reindex. IE dc=example,dc=com.") - db2index_parser.add_argument('backend', help="The backend to reindex. IE userRoot") - db2index_parser.set_defaults(func=dbtasks_db2index) - diff --git a/src/lib389/lib389/cli_adm/instance.py b/src/lib389/lib389/cli_adm/instance.py deleted file mode 100644 index f59fb2b32..000000000 --- a/src/lib389/lib389/cli_adm/instance.py +++ /dev/null @@ -1,133 +0,0 @@ -# --- 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 --- - -from lib389._constants import * - -from lib389.tools import DirSrvTools -from lib389.instance.setup import SetupDs -from getpass import getpass -import os -import time -import sys - -from lib389.instance.options import General2Base, Slapd2Base - -def instance_list(inst, log, args): - instances = inst.list(all=True) - - try: - if len(instances) > 0: - for instance in instances: - log.info("instance: %s" % instance[CONF_SERVER_ID]) - else: - log.info("No instances of Directory Server") - except IOError as e: - log.info(e) - log.info("Perhaps you need to be a different user?") - -def instance_restart(inst, log, args): - inst.restart(post_open=False) - -def instance_start(inst, log, args): - inst.start(post_open=False) - -def instance_stop(inst, log, args): - inst.stop() - -def instance_status(inst, log, args): - if inst.status() is True: - log.info("Instance is running") - else: - log.info("Instance is not running") - -def instance_create(inst, log, args): - if not args.ack: - sys.exit(0) - else: - log.info(""" - _________________________________________ -/ This is not what you want! Press ctrl-c \\ -\ now ... / - ----------------------------------------- - \\ / \\ //\\ - \\ |\\___/| / \\// \\\\ - /0 0 \\__ / // | \\ \\ - / / \\/_/ // | \\ \\ - @_^_@'/ \\/_ // | \\ \\ - //_^_/ \\/_ // | \\ \\ - ( //) | \\/// | \\ \\ - ( / /) _|_ / ) // | \\ _\\ - ( // /) '/,_ _ _/ ( ; -. | _ _\\.-~ .-~~~^-. - (( / / )) ,-{ _ `-.|.-~-. .~ `. - (( // / )) '/\\ / ~-. _ .-~ .-~^-. \\ - (( /// )) `. { } / \\ \\ - (( / )) .----~-.\\ \\-' .~ \\ `. \\^-. - ///.----..> \\ _ -~ `. ^-` ^-_ - ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~ - /.-~ - """) - for i in range(1,6): - log.info('%s ...' % (5 - int(i))) - time.sleep(1) - log.info('Launching ...') - if args.containerised: - log.debug("Containerised features requested.") - sd = SetupDs(args.verbose, args.dryrun, log, args.containerised) - ### If args.file is not set, we need to interactively get answers! - if sd.create_from_inf(args.file): - # print("Sucessfully created instance") - return True - else: - # print("Failed to create instance") - return False - -def instance_example(inst, log, args): - print(""" -; --- BEGIN COPYRIGHT BLOCK --- -; Copyright (C) 2015 Red Hat, Inc. -; All rights reserved. -; -; License: GPL (version 3 or any later version). -; See LICENSE for details. -; --- END COPYRIGHT BLOCK --- - -; Author: firstyear at redhat.com - -; This is a version 2 ds setup inf file. -; It is used by the python versions of setup-ds-* -; Most options map 1 to 1 to the original .inf file. -; However, there are some differences that I envision -; For example, note the split backend section. -; You should be able to create, one, many or no backends in an install -; -; The special value {instance_name} is substituted at installation time. -; - - """) - g2b = General2Base(log) - s2b = Slapd2Base(log) - print(g2b.collect_help()) - print(s2b.collect_help()) - -def create_parser(subcommands): - # list_parser = subcommands.add_parser('list', help="List installed instances of Directory Server") - # list_parser.set_defaults(func=instance_list) - # list_parser.set_defaults(noinst=True) - restart_parser = subcommands.add_parser('restart', help="Restart an instance of Directory Server, if it is running: else start it.") - restart_parser.set_defaults(func=instance_restart) - - start_parser = subcommands.add_parser('start', help="Start an instance of Directory Server, if it is not currently running") - start_parser.set_defaults(func=instance_start) - - stop_parser = subcommands.add_parser('stop', help="Stop an instance of Directory Server, if it is currently running") - stop_parser.set_defaults(func=instance_stop) - - status_parser = subcommands.add_parser('status', help="Check running status of an instance of Directory Server") - status_parser.set_defaults(func=instance_status) - - diff --git a/src/lib389/lib389/cli_base/__init__.py b/src/lib389/lib389/cli_base/__init__.py index 9dca62526..3ede30f02 100644 --- a/src/lib389/lib389/cli_base/__init__.py +++ b/src/lib389/lib389/cli_base/__init__.py @@ -81,7 +81,6 @@ def connect_instance(ldapurl, binddn, verbose, starttls): raise Exception("Must provide a binddn to connect with") ds.allocate(dsargs) ds.open(starttls=starttls, connOnly=True) - print("") return ds def disconnect_instance(inst): diff --git a/src/lib389/lib389/tests/cli/adm_instance.py b/src/lib389/lib389/tests/cli/adm_instance.py index 6de4aa788..1c3d829e4 100644 --- a/src/lib389/lib389/tests/cli/adm_instance.py +++ b/src/lib389/lib389/tests/cli/adm_instance.py @@ -9,7 +9,7 @@ # Test the cli tools from the dsadm command for correct behaviour. import pytest -from lib389.cli_adm.instance import instance_list +from lib389.cli_ctl.instance import instance_list from lib389 import DirSrv from lib389.cli_base import LogCapture diff --git a/src/lib389/setup.py b/src/lib389/setup.py index 52e96cf8e..b3c41c68f 100644 --- a/src/lib389/setup.py +++ b/src/lib389/setup.py @@ -53,7 +53,7 @@ setup( data_files=[ ('/usr/sbin/', [ # 'lib389/clitools/ds_setup', - 'cli/dsadm', + 'cli/dsctl', 'cli/dsconf', 'cli/dscreate', 'cli/dsidm',
0
15109fc0beee88229131d7f1508e9a718e3e8081
389ds/389-ds-base
Issue 4581 - A failed re-indexing leaves the database in broken state (#4582) Bug description: During reindex the numsubordinates attribute is not updated in parent entries. The consequence is that the internal counter job->numsubordinates==0. Later when indexing the ancestorid, the server can show the progression of this indexing with a ratio using job->numsubordinates==0. Division with 0 -> SIGFPE Fix description: if the numsubordinates is NULL, log a message without a division. relates: https://github.com/389ds/389-ds-base/issues/4581 Reviewed by: Pierre Rogier, Mark Reynolds, Simon Pichugin, Teko Mihinto (thanks !!) Platforms tested: F31
commit 15109fc0beee88229131d7f1508e9a718e3e8081 Author: tbordaz <[email protected]> Date: Mon Feb 1 09:28:25 2021 +0100 Issue 4581 - A failed re-indexing leaves the database in broken state (#4582) Bug description: During reindex the numsubordinates attribute is not updated in parent entries. The consequence is that the internal counter job->numsubordinates==0. Later when indexing the ancestorid, the server can show the progression of this indexing with a ratio using job->numsubordinates==0. Division with 0 -> SIGFPE Fix description: if the numsubordinates is NULL, log a message without a division. relates: https://github.com/389ds/389-ds-base/issues/4581 Reviewed by: Pierre Rogier, Mark Reynolds, Simon Pichugin, Teko Mihinto (thanks !!) Platforms tested: F31 diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c index ba783ee59..7f484934f 100644 --- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c +++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c @@ -468,18 +468,30 @@ bdb_get_nonleaf_ids(backend *be, DB_TXN *txn, IDList **idl, ImportJob *job) } key_count++; if (!(key_count % PROGRESS_INTERVAL)) { - import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids", - "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)", - (key_count * 100 / job->numsubordinates), key_count); + if (job->numsubordinates) { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids", + "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)", + (key_count * 100 / job->numsubordinates), key_count); + } else { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids", + "Gathering ancestorid non-leaf IDs: processed %d ancestors...", + key_count); + } started_progress_logging = 1; } } while (ret == 0 && !(job->flags & FLAG_ABORT)); if (started_progress_logging) { /* finish what we started logging */ - import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids", - "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)", - (key_count * 100 / job->numsubordinates), key_count); + if (job->numsubordinates) { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids", + "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)", + (key_count * 100 / job->numsubordinates), key_count); + } else { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids", + "Gathering ancestorid non-leaf IDs: processed %d ancestors", + key_count); + } } import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids", "Finished gathering ancestorid non-leaf IDs."); @@ -660,9 +672,15 @@ bdb_ancestorid_default_create_index(backend *be, ImportJob *job) key_count++; if (!(key_count % PROGRESS_INTERVAL)) { - import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index", - "Creating ancestorid index: processed %d%% (ID count %d)", - (key_count * 100 / job->numsubordinates), key_count); + if (job->numsubordinates) { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index", + "Creating ancestorid index: processed %d%% (ID count %d)", + (key_count * 100 / job->numsubordinates), key_count); + } else { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index", + "Creating ancestorid index: processed %d ancestors...", + key_count); + } started_progress_logging = 1; } @@ -743,9 +761,15 @@ out: if (ret == 0) { if (started_progress_logging) { /* finish what we started logging */ - import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index", - "Creating ancestorid index: processed %d%% (ID count %d)", - (key_count * 100 / job->numsubordinates), key_count); + if (job->numsubordinates) { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index", + "Creating ancestorid index: processed %d%% (ID count %d)", + (key_count * 100 / job->numsubordinates), key_count); + } else { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index", + "Creating ancestorid index: processed %d ancestors", + key_count); + } } import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index", "Created ancestorid index (old idl)."); @@ -869,9 +893,15 @@ bdb_ancestorid_new_idl_create_index(backend *be, ImportJob *job) key_count++; if (!(key_count % PROGRESS_INTERVAL)) { - import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index", - "Creating ancestorid index: progress %d%% (ID count %d)", - (key_count * 100 / job->numsubordinates), key_count); + if (job->numsubordinates) { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index", + "Creating ancestorid index: progress %d%% (ID count %d)", + (key_count * 100 / job->numsubordinates), key_count); + } else { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index", + "Creating ancestorid index: progress %d ancestors...", + key_count); + } started_progress_logging = 1; } @@ -932,9 +962,15 @@ out: if (ret == 0) { if (started_progress_logging) { /* finish what we started logging */ - import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index", - "Creating ancestorid index: processed %d%% (ID count %d)", - (key_count * 100 / job->numsubordinates), key_count); + if (job->numsubordinates) { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index", + "Creating ancestorid index: processed %d%% (ID count %d)", + (key_count * 100 / job->numsubordinates), key_count); + } else { + import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index", + "Creating ancestorid index: processed %d ancestors", + key_count); + } } import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index", "Created ancestorid index (new idl).");
0
87f5ef5a97437cc92afe2496cd06e5d2ec71d9ff
389ds/389-ds-base
Ticket #47341 - logconv.pl -m time calculation is wrong https://fedorahosted.org/389/ticket/47341 Reviewed by: nkinder (Thanks!) Branch: master Fix Description: The variable name is $hr, not $hours. The regex for the sign in the timezone should have been (.) not (?). Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no
commit 87f5ef5a97437cc92afe2496cd06e5d2ec71d9ff Author: Rich Megginson <[email protected]> Date: Mon Apr 22 20:28:14 2013 -0600 Ticket #47341 - logconv.pl -m time calculation is wrong https://fedorahosted.org/389/ticket/47341 Reviewed by: nkinder (Thanks!) Branch: master Fix Description: The variable name is $hr, not $hours. The regex for the sign in the timezone should have been (.) not (?). Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl index 757f799af..3b8adc574 100755 --- a/ldap/admin/src/logconv.pl +++ b/ldap/admin/src/logconv.pl @@ -1574,7 +1574,7 @@ sub parseLineNormal { # tz offset change $lastzone=$tzone; - ($sign,$hr,$min) = $tzone =~ m/(?)(\d\d)(\d\d)/; + ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/; $tzoff = $hr*3600 + $min*60; $tzoff *= -1 if $sign eq '-'; @@ -1582,7 +1582,7 @@ sub parseLineNormal } ($date, $hr, $min, $sec) = split (':', $time); ($day, $mon, $yr) = split ('/', $date); - $newmin = timegm(0, $min, $hours, $day, $monthname{$mon}, $yr) - $tzoff; + $newmin = timegm(0, $min, $hr, $day, $monthname{$mon}, $yr) - $tzoff; $gmtime = $newmin + $sec; print_stats_block( $s_stats ); reset_stats_block( $s_stats, $gmtime, $time.' '.$tzone );
0
2e202490a8d6a3597cecfceaaa8cd4e70e531f8f
389ds/389-ds-base
Fix missing 'not' in description (closes #5423) (#5424) Issue #5243 - Fix missing 'not' in description Bug Description: The helptext for 'start' is missing the word 'not' Fix Description: Adds in missing word relates: https://github.com/389ds/389-ds-base/issues/5423 Author: Andrew Elwell Reviewed by: mreynolds
commit 2e202490a8d6a3597cecfceaaa8cd4e70e531f8f Author: Andrew Elwell <[email protected]> Date: Tue Aug 23 02:12:56 2022 +1000 Fix missing 'not' in description (closes #5423) (#5424) Issue #5243 - Fix missing 'not' in description Bug Description: The helptext for 'start' is missing the word 'not' Fix Description: Adds in missing word relates: https://github.com/389ds/389-ds-base/issues/5423 Author: Andrew Elwell Reviewed by: mreynolds diff --git a/src/lib389/lib389/instance/options.py b/src/lib389/lib389/instance/options.py index 0ecade2b2..fbc3a1d7e 100644 --- a/src/lib389/lib389/instance/options.py +++ b/src/lib389/lib389/instance/options.py @@ -138,7 +138,7 @@ class General2Base(Options2): self._options['start'] = True self._type['start'] = bool - self._helptext['start'] = "Starts the instance after the install completes. If false, the instance is created but started." + self._helptext['start'] = "Starts the instance after the install completes. If false, the instance is created but not started." self._options['defaults'] = INSTALL_LATEST_CONFIG self._type['defaults'] = str
0
a9a9237c9ab99f14c7c040081481354ef3543e28
389ds/389-ds-base
Ticket 49126 - DIT management tool Bug Description: This adds a tool allowing us to manage items in the DIT of an LDAP server. Fix Description: This tool is able to manage users, groups, ous and posixgroups. Additionally, the functionality for schema management was ported into the dsconf tool. https://fedorahosted.org/389/ticket/49126 Author: wibrown Review by: mreynolds (Thanks!)
commit a9a9237c9ab99f14c7c040081481354ef3543e28 Author: William Brown <[email protected]> Date: Fri Feb 10 15:48:33 2017 +1000 Ticket 49126 - DIT management tool Bug Description: This adds a tool allowing us to manage items in the DIT of an LDAP server. Fix Description: This tool is able to manage users, groups, ous and posixgroups. Additionally, the functionality for schema management was ported into the dsconf tool. https://fedorahosted.org/389/ticket/49126 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/src/lib389/cli/dsconf b/src/lib389/cli/dsconf index bbb4fbaf1..c74698d9d 100755 --- a/src/lib389/cli/dsconf +++ b/src/lib389/cli/dsconf @@ -19,6 +19,7 @@ logging.basicConfig(format='%(message)s') from lib389 import DirSrv from lib389.cli_conf import backend as cli_backend from lib389.cli_conf import plugin as cli_plugin +from lib389.cli_conf import schema as cli_schema from lib389.cli_conf import lint as cli_lint from lib389.cli_base import disconnect_instance, connect_instance @@ -57,6 +58,7 @@ if __name__ == '__main__': subparsers = parser.add_subparsers(help="resources to act upon") cli_backend.create_parser(subparsers) + cli_schema.create_parser(subparsers) cli_lint.create_parser(subparsers) cli_plugin.create_parser(subparsers) diff --git a/src/lib389/cli/dsidm b/src/lib389/cli/dsidm new file mode 100755 index 000000000..64f10ed5e --- /dev/null +++ b/src/lib389/cli/dsidm @@ -0,0 +1,94 @@ +#!/usr/bin/python3 + +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016, William Brown <william at blackhats.net.au> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import ldap +import argparse +# import argcomplete +import logging + +from lib389.cli_idm import organisationalunit as cli_ou +from lib389.cli_idm import group as cli_group +from lib389.cli_idm import posixgroup as cli_posixgroup +from lib389.cli_idm import user as cli_user + +from lib389.cli_base import connect_instance, disconnect_instance + +logging.basicConfig() +log = logging.getLogger("dsidm") + +if __name__ == '__main__': + + defbase = ldap.get_option(ldap.OPT_DEFBASE) + + parser = argparse.ArgumentParser() + # First, add the LDAP options + parser.add_argument('-D', '--binddn', + help="The account to bind as for executing operations", + default=None, + ) + parser.add_argument('-H', '--ldapurl', + help="The LDAP url to connect to, IE ldap://mai.example.com:389", + default=None, + ) + parser.add_argument('-Z', '--starttls', + help="Connect with StartTLS", + default=False, action='store_true' + ) + parser.add_argument('-b', '--basedn', + help="Basedn (root naming context) of the instance to manage", + default=defbase + ) + parser.add_argument('-v', '--verbose', + help="Display verbose operation tracing during command execution", + action='store_true', default=False + ) + + subparsers = parser.add_subparsers(help="resources to act upon") + + # Call all the other cli modules to register their bits + + cli_ou.create_parser(subparsers) + cli_group.create_parser(subparsers) + cli_posixgroup.create_parser(subparsers) + cli_user.create_parser(subparsers) + + # argcomplete.autocomplete(parser) + args = parser.parse_args() + + if args.verbose: + log.setLevel(logging.DEBUG) + else: + log.setLevel(logging.INFO) + + log.debug("The 389 Directory Server Identity Manager") + # Leave this comment here: UofA let me take this code with me provided + # I gave attribution. -- wibrown + log.debug("Inspired by works of: ITS, The University of Adelaide") + + log.debug("Called with: %s", args) + + # Connect + inst = None + if args.verbose: + inst = connect_instance(args.ldapurl, args.binddn, args.verbose, args.starttls) + args.func(inst, args.basedn, log, args) + else: + try: + inst = connect_instance(args.ldapurl, args.binddn, args.verbose, args.starttls) + args.func(inst, args.basedn, log, args) + except Exception as e: + log.debug(e, exc_info=True) + log.error("Error: %s" % e.message) + disconnect_instance(inst) + + + log.debug("dsidm is brought to you by the letter E and the number 26.") + + diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index bb3fe26f1..008fb1175 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -522,6 +522,9 @@ class DirSrv(SimpleLDAPObject, object): self.creation_suffix = args.get(SER_CREATION_SUFFIX, DEFAULT_SUFFIX) # These settings are only needed on a local connection. if self.isLocal: + # For compatibility keep self.inst but should be removed + self.inst = self.serverid + self.userid = args.get(SER_USER_ID) if not self.userid: if os.getuid() == 0: @@ -546,9 +549,6 @@ class DirSrv(SimpleLDAPObject, object): # self.errlog = os.path.join(self.prefix, # "var/log/dirsrv/slapd-%s/errors" % self.serverid) - # For compatibility keep self.inst but should be removed - self.inst = self.serverid - # additional settings self.suffixes = {} self.agmt = {} diff --git a/src/lib389/lib389/cli_conf/schema.py b/src/lib389/lib389/cli_conf/schema.py new file mode 100644 index 000000000..c2427c443 --- /dev/null +++ b/src/lib389/lib389/cli_conf/schema.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 + +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016, William Brown <william at blackhats.net.au> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import argparse + +from lib389.cli_base import _get_arg + +def list_attributetype(inst, basedn, log, args): + for attributetype in inst.schema.get_attributetypes(): + print(attributetype) + +def query_attributetype(inst, basedn, log, args): + # Need the query type + attr = _get_arg( args.attr , msg="Enter attribute to query" ) + attributetype, must, may = inst.schema.query_attributetype(attr) + print(attributetype) + print("") + print("MUST") + for oc in must: + print(oc) + print("") + print("MAY") + for oc in may: + print(oc) + +def create_parser(subparsers): + schema_parser = subparsers.add_parser('schema', help='Query and manipulate schema') + + subcommands = schema_parser.add_subparsers(help='schema') + + list_attributetype_parser = subcommands.add_parser('list_attributetype', help='List avaliable attribute types on this system') + list_attributetype_parser.set_defaults(func=list_attributetype) + + query_attributetype_parser = subcommands.add_parser('query_attributetype', help='Query an attribute to determine object classes that may or must take it') + query_attributetype_parser.set_defaults(func=query_attributetype) + query_attributetype_parser.add_argument('attr', nargs='?', help='Attribute type to query') + diff --git a/src/lib389/lib389/cli_idm/__init__.py b/src/lib389/lib389/cli_idm/__init__.py new file mode 100644 index 000000000..39cd01da9 --- /dev/null +++ b/src/lib389/lib389/cli_idm/__init__.py @@ -0,0 +1,114 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016, William Brown <william at blackhats.net.au> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +from getpass import getpass +from lib389 import DirSrv +from lib389.properties import SER_LDAP_URL, SER_ROOT_DN, SER_ROOT_PW + + +def _get_arg(args, msg=None): + if args is not None and len(args) > 0: + if type(args) is list: + return args[0] + else: + return args + else: + return raw_input("%s : " % msg) + +def _get_args(args, kws): + kwargs = {} + while len(kws) > 0: + kw, msg, priv = kws.pop(0) + + if args is not None and len(args) > 0: + kwargs[kw] = args.pop(0) + else: + if priv: + kwargs[kw] = getpass("%s : " % msg) + else: + kwargs[kw] = raw_input("%s : " % msg) + return kwargs + +# This is really similar to get_args, but generates from the MUST_ATTRIBUTES array +def _get_attributes(args, attrs): + kwargs = {} + for attr in attrs: + if args is not None and len(args) > 0: + kwargs[attr] = args.pop(0) + else: + if attr.lower() == 'userpassword': + kwargs[attr] = getpass("Enter value for %s : " % attr) + else: + kwargs[attr] = raw_input("Enter value for %s : " % attr) + return kwargs + + +def _warn(data, msg=None): + if msg is not None: + print("%s :" % msg) + if 'Yes I am sure' != raw_input("Type 'Yes I am sure' to continue: "): + raise Exception("Not sure if want") + return data + +def connect_instance(ldapurl, binddn, verbose, starttls): + dsargs = { + SER_LDAP_URL: ldapurl, + SER_ROOT_DN: binddn + } + ds = DirSrv(verbose=verbose) + ds.allocate(dsargs) + if not ds.can_autobind() and binddn is not None: + dsargs[SER_ROOT_PW] = getpass("Enter password for %s on %s : " % (binddn, ldapurl)) + elif binddn is None: + raise Exception("Must provide a binddn to connect with") + ds.allocate(dsargs) + ds.open(starttls=starttls) + print("") + return ds + +def disconnect_instance(inst): + if inst is not None: + inst.close() + +def _generic_list(inst, basedn, log, manager_class, **kwargs): + mc = manager_class(inst, basedn) + ol = mc.list() + if len(ol) == 0: + print("No objects to display") + elif len(ol) > 0: + # We might sort this in the future + for o in ol: + o_str = o.__unicode__() + print(o_str) + +# Display these entries better! +def _generic_get(inst, basedn, log, manager_class, selector): + mc = manager_class(inst, basedn) + o = mc.get(selector) + o_str = o.__unicode__() + print(o_str) + +def _generic_get_dn(inst, basedn, log, manager_class, dn): + mc = manager_class(inst, basedn) + o = mc.get(dn=dn) + o_str = o.__unicode__() + print(o_str) + +def _generic_create(inst, basedn, log, manager_class, kwargs): + mc = manager_class(inst, basedn) + o = mc.create(properties=kwargs) + o_str = o.__unicode__() + print('Sucessfully created %s' % o_str) + +def _generic_delete(inst, basedn, log, object_class, dn): + # Load the oc direct + o = object_class(inst, dn) + o.delete() + print('Sucessfully deleted %s' % dn) + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/src/lib389/lib389/cli_idm/group.py b/src/lib389/lib389/cli_idm/group.py new file mode 100644 index 000000000..d41205feb --- /dev/null +++ b/src/lib389/lib389/cli_idm/group.py @@ -0,0 +1,79 @@ +#!/usr/bin/python3 + +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016, William Brown <william at blackhats.net.au> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import argparse +from lib389.idm.group import Group, Groups + +from lib389.cli_base import ( + _generic_list, + _generic_get, + _generic_get_dn, + _generic_create, + _generic_delete, + _get_arg, + _get_args, + _get_attributes, + _warn, + ) + +SINGULAR = Group +MANY = Groups +RDN = 'cn' + +# These are a generic specification, try not to tamper with them + +def list(inst, basedn, log, args): + _generic_list(inst, basedn, log.getChild('_generic_list'), MANY) + +def get(inst, basedn, log, args): + rdn = _get_arg( args.selector, msg="Enter %s to retrieve" % RDN) + _generic_get(inst, basedn, log.getChild('_generic_get'), MANY, rdn) + +def get_dn(inst, basedn, log, args): + dn = lambda args: _get_arg( args.dn, msg="Enter dn to retrieve") + _generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn) + +def create(inst, basedn, log, args): + kwargs = _get_attributes(args, MUST_ATTRIBUTES) + _generic_create(inst, basedn, log.getChild('_generic_create'), MANY, kwargs) + +def delete(inst, basedn, log, args): + dn = _get_arg( args, msg="Enter dn to delete") + _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn)) + _generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR, dn) + +def create_parser(subparsers): + group_parser = subparsers.add_parser('group', help='Manage groups') + + subcommands = group_parser.add_subparsers(help='action') + + list_parser = subcommands.add_parser('list', help='list') + list_parser.set_defaults(func=list) + + get_parser = subcommands.add_parser('get', help='get') + get_parser.set_defaults(func=get) + get_parser.add_argument('selector', nargs='?', help='The term to search for') + + get_dn_parser = subcommands.add_parser('get_dn', help='get_dn') + get_dn_parser.set_defaults(func=get_dn) + get_dn_parser.add_argument('dn', nargs='?', help='The dn to get') + + create_parser = subcommands.add_parser('create', help='create') + create_parser.set_defaults(func=create) + create_parser.add_argument('extra', nargs=argparse.REMAINDER, + help='A create may take one or more extra arguments. This parameter provides them' + ) + + delete_parser = subcommands.add_parser('delete', help='deletes the object') + delete_parser.set_defaults(func=delete) + delete_parser.add_argument('dn', nargs='?', help='The dn to delete') + + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/src/lib389/lib389/cli_idm/organisationalunit.py b/src/lib389/lib389/cli_idm/organisationalunit.py new file mode 100644 index 000000000..bcc2232f5 --- /dev/null +++ b/src/lib389/lib389/cli_idm/organisationalunit.py @@ -0,0 +1,79 @@ +#!/usr/bin/python3 + +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016, William Brown <william at blackhats.net.au> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import argparse +from lib389.idm.organisationalunit import OrganisationalUnit, OrganisationalUnits + +from lib389.cli_base import ( + _generic_list, + _generic_get, + _generic_get_dn, + _generic_create, + _generic_delete, + _get_arg, + _get_args, + _get_attributes, + _warn, + ) + +SINGULAR = OrganisationalUnit +MANY = OrganisationalUnits +RDN = 'ou' + +# These are a generic specification, try not to tamper with them + +def list(inst, basedn, log, args): + _generic_list(inst, basedn, log.getChild('_generic_list'), MANY) + +def get(inst, basedn, log, args): + rdn = _get_arg( args.selector, msg="Enter %s to retrieve" % RDN) + _generic_get(inst, basedn, log.getChild('_generic_get'), MANY, rdn) + +def get_dn(inst, basedn, log, args): + dn = lambda args: _get_arg( args.dn, msg="Enter dn to retrieve") + _generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn) + +def create(inst, basedn, log, args): + kwargs = _get_attributes(args, MUST_ATTRIBUTES) + _generic_create(inst, basedn, log.getChild('_generic_create'), MANY, kwargs) + +def delete(inst, basedn, log, args): + dn = _get_arg( args, msg="Enter dn to delete") + _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn)) + _generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR, dn) + +def create_parser(subparsers): + ou_parser = subparsers.add_parser('organisationalunit', help='Manage organisational units') + + subcommands = ou_parser.add_subparsers(help='action') + + list_parser = subcommands.add_parser('list', help='list') + list_parser.set_defaults(func=list) + + get_parser = subcommands.add_parser('get', help='get') + get_parser.set_defaults(func=get) + get_parser.add_argument('selector', nargs='?', help='The term to search for') + + get_dn_parser = subcommands.add_parser('get_dn', help='get_dn') + get_dn_parser.set_defaults(func=get_dn) + get_dn_parser.add_argument('dn', nargs='?', help='The dn to get') + + create_parser = subcommands.add_parser('create', help='create') + create_parser.set_defaults(func=create) + create_parser.add_argument('extra', nargs=argparse.REMAINDER, + help='A create may take one or more extra arguments. This parameter provides them' + ) + + delete_parser = subcommands.add_parser('delete', help='deletes the object') + delete_parser.set_defaults(func=delete) + delete_parser.add_argument('dn', nargs='?', help='The dn to delete') + + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/src/lib389/lib389/cli_idm/posixgroup.py b/src/lib389/lib389/cli_idm/posixgroup.py new file mode 100644 index 000000000..5c9331a6a --- /dev/null +++ b/src/lib389/lib389/cli_idm/posixgroup.py @@ -0,0 +1,80 @@ +#!/usr/bin/python3 + +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016, William Brown <william at blackhats.net.au> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import argparse +from lib389.idm.posixgroup import PosixGroup, PosixGroups, MUST_ATTRIBUTES + +from lib389.cli_base import ( + _generic_list, + _generic_get, + _generic_get_dn, + _generic_create, + _generic_delete, + _get_arg, + _get_args, + _get_attributes, + _warn, + ) + + +SINGULAR = PosixGroup +MANY = PosixGroups +RDN = 'cn' + +# These are a generic specification, try not to tamper with them + +def list(inst, basedn, log, args): + _generic_list(inst, basedn, log.getChild('_generic_list'), MANY) + +def get(inst, basedn, log, args): + rdn = _get_arg( args.selector, msg="Enter %s to retrieve" % RDN) + _generic_get(inst, basedn, log.getChild('_generic_get'), MANY, rdn) + +def get_dn(inst, basedn, log, args): + dn = lambda args: _get_arg( args.dn, msg="Enter dn to retrieve") + _generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn) + +def create(inst, basedn, log, args): + kwargs = _get_attributes(args.extra, MUST_ATTRIBUTES) + _generic_create(inst, basedn, log.getChild('_generic_create'), MANY, kwargs) + +def delete(inst, basedn, log, args): + dn = _get_arg( args, msg="Enter dn to delete") + _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn)) + _generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR, dn) + +def create_parser(subparsers): + posixgroup_parser = subparsers.add_parser('posixgroup', help='Manage posix groups') + + subcommands = posixgroup_parser.add_subparsers(help='action') + + list_parser = subcommands.add_parser('list', help='list') + list_parser.set_defaults(func=list) + + get_parser = subcommands.add_parser('get', help='get') + get_parser.set_defaults(func=get) + get_parser.add_argument('selector', nargs='?', help='The term to search for') + + get_dn_parser = subcommands.add_parser('get_dn', help='get_dn') + get_dn_parser.set_defaults(func=get_dn) + get_dn_parser.add_argument('dn', nargs='?', help='The dn to get') + + create_parser = subcommands.add_parser('create', help='create') + create_parser.set_defaults(func=create) + create_parser.add_argument('extra', nargs=argparse.REMAINDER, + help='A create may take one or more extra arguments. This parameter provides them' + ) + + delete_parser = subcommands.add_parser('delete', help='deletes the object') + delete_parser.set_defaults(func=delete) + delete_parser.add_argument('dn', nargs='?', help='The dn to delete') + + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/src/lib389/lib389/cli_idm/user.py b/src/lib389/lib389/cli_idm/user.py new file mode 100644 index 000000000..07e485329 --- /dev/null +++ b/src/lib389/lib389/cli_idm/user.py @@ -0,0 +1,79 @@ +#!/usr/bin/python3 + +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016, William Brown <william at blackhats.net.au> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import argparse +from lib389.idm.user import UserAccount, UserAccounts + +from lib389.cli_base import ( + _generic_list, + _generic_get, + _generic_get_dn, + _generic_create, + _generic_delete, + _get_arg, + _get_args, + _get_attributes, + _warn, + ) + +SINGULAR = UserAccount +MANY = UserAccounts +RDN = 'uid' + +# These are a generic specification, try not to tamper with them + +def list(inst, basedn, log, args): + _generic_list(inst, basedn, log.getChild('_generic_list'), MANY) + +def get(inst, basedn, log, args): + rdn = _get_arg( args.selector, msg="Enter %s to retrieve" % RDN) + _generic_get(inst, basedn, log.getChild('_generic_get'), MANY, rdn) + +def get_dn(inst, basedn, log, args): + dn = lambda args: _get_arg( args.dn, msg="Enter dn to retrieve") + _generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn) + +def create(inst, basedn, log, args): + kwargs = _get_attributes(args, MUST_ATTRIBUTES) + _generic_create(inst, basedn, log.getChild('_generic_create'), MANY, kwargs) + +def delete(inst, basedn, log, args): + dn = _get_arg( args, msg="Enter dn to delete") + _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn)) + _generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR, dn) + +def create_parser(subparsers): + user_parser = subparsers.add_parser('user', help='Manage posix users') + + subcommands = user_parser.add_subparsers(help='action') + + list_parser = subcommands.add_parser('list', help='list') + list_parser.set_defaults(func=list) + + get_parser = subcommands.add_parser('get', help='get') + get_parser.set_defaults(func=get) + get_parser.add_argument('selector', nargs='?', help='The term to search for') + + get_dn_parser = subcommands.add_parser('get_dn', help='get_dn') + get_dn_parser.set_defaults(func=get_dn) + get_dn_parser.add_argument('dn', nargs='?', help='The dn to get') + + create_parser = subcommands.add_parser('create', help='create') + create_parser.set_defaults(func=create) + create_parser.add_argument('extra', nargs=argparse.REMAINDER, + help='A create may take one or more extra arguments. This parameter provides them' + ) + + delete_parser = subcommands.add_parser('delete', help='deletes the object') + delete_parser.set_defaults(func=delete) + delete_parser.add_argument('dn', nargs='?', help='The dn to delete') + + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
0
30cb81261036e1347e2dcb86b801dd89d13a2849
389ds/389-ds-base
Bug 675853 - dirsrv crash segfault in need_new_pw() A bind DN with a trailing tab in the RDN can cause ns-slapd to crash. This is ultimately caused by the function that explodes the bind DN trimming off the tab character, causing the bind entry to be found by the backend. The frontend uses different logic to find the bind entry, which fails to find the entry. This discrepency leads to a crash. The fix is to only trim trailing spaces (0x20) from RDN values when exploding a DN. The DN explode function is an internal function when built against the OpenLDAP client libs, but we use an external MozLDAP call when built against MozLDAP. This patch makes us always use our own internal function regardless of the client libs we are built against.
commit 30cb81261036e1347e2dcb86b801dd89d13a2849 Author: Nathan Kinder <[email protected]> Date: Tue Feb 8 14:09:58 2011 -0800 Bug 675853 - dirsrv crash segfault in need_new_pw() A bind DN with a trailing tab in the RDN can cause ns-slapd to crash. This is ultimately caused by the function that explodes the bind DN trimming off the tab character, causing the bind entry to be found by the backend. The frontend uses different logic to find the bind entry, which fails to find the entry. This discrepency leads to a crash. The fix is to only trim trailing spaces (0x20) from RDN values when exploding a DN. The DN explode function is an internal function when built against the OpenLDAP client libs, but we use an external MozLDAP call when built against MozLDAP. This patch makes us always use our own internal function regardless of the client libs we are built against. diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c index 11fe4fbf3..34aa12e71 100644 --- a/ldap/servers/slapd/ldaputil.c +++ b/ldap/servers/slapd/ldaputil.c @@ -101,14 +101,12 @@ #include <ldappr.h> #endif -#if defined(USE_OPENLDAP) /* the server depends on the old, deprecated ldap_explode behavior which openldap - does not support - the use of the mozldap code should be seen as a temporary - measure which we should remove as we improve our internal DN handling */ + does not support - the use of the mozldap code should be discouraged as + there are issues that mozldap does not handle correctly. */ static char **mozldap_ldap_explode( const char *dn, const int notypes, const int nametype ); static char **mozldap_ldap_explode_dn( const char *dn, const int notypes ); static char **mozldap_ldap_explode_rdn( const char *rdn, const int notypes ); -#endif #ifdef MEMPOOL_EXPERIMENTAL void _free_wrapper(void *ptr) @@ -1094,21 +1092,13 @@ done: char ** slapi_ldap_explode_rdn(const char *rdn, int notypes) { -#if defined(USE_OPENLDAP) return mozldap_ldap_explode_rdn(rdn, notypes); -#else - return ldap_explode_rdn(rdn, notypes); -#endif } char ** slapi_ldap_explode_dn(const char *dn, int notypes) { -#if defined(USE_OPENLDAP) return mozldap_ldap_explode_dn(dn, notypes); -#else - return ldap_explode_dn(dn, notypes); -#endif } void @@ -1992,14 +1982,15 @@ cleanup: #endif /* HAVE_KRB5 */ -#if defined(USE_OPENLDAP) - #define LDAP_DN 1 #define LDAP_RDN 2 #define INQUOTE 1 #define OUTQUOTE 2 +/* We use the following two functions when built against OpenLDAP + * or the MozLDAP libs since the MozLDAP ldap_explode_dn() function + * does not handle trailing whitespace characters properly. */ static char ** mozldap_ldap_explode( const char *dn, const int notypes, const int nametype ) { @@ -2101,8 +2092,7 @@ mozldap_ldap_explode( const char *dn, const int notypes, const int nametype ) if ( !endquote ) { /* trim trailing spaces */ while ( len > 0 && - ldap_utf8isspace( - &rdns[count-1][len-1] )) { + (rdns[count-1][len-1] == ' ')) { --len; } } @@ -2148,4 +2138,3 @@ mozldap_ldap_explode_rdn( const char *rdn, const int notypes ) return( mozldap_ldap_explode( rdn, notypes, LDAP_RDN ) ); } -#endif /* USE_OPENLDAP */
0
56373fb562fc86e53e5ba8ffd5e5d09c21f532f5
389ds/389-ds-base
Ticket 49390, 50019 - support cn=config compare operations Bug Description: Ansible will attempt to check the state of a value before it makes an alteration on the ldap server. To do this in a correct and schema aware fashion, it will use the ldapcompare operation. It's a request that people want to manage their cn=config with ansible, however dse.c didn't support ldapcompare on these backends. Fix Description: Add support for ldapcompare operations on dse.c, including the ability to correctly generate the cn=config defaults into the entry for comparison. This also adds support for ldapcompare as the default comparitor in lib389. https://pagure.io/389-ds-base/issue/49390 https://pagure.io/389-ds-base/issue/50019 Author: William Brown <[email protected]> Review by: ???
commit 56373fb562fc86e53e5ba8ffd5e5d09c21f532f5 Author: William Brown <[email protected]> Date: Thu Mar 28 14:01:07 2019 +1000 Ticket 49390, 50019 - support cn=config compare operations Bug Description: Ansible will attempt to check the state of a value before it makes an alteration on the ldap server. To do this in a correct and schema aware fashion, it will use the ldapcompare operation. It's a request that people want to manage their cn=config with ansible, however dse.c didn't support ldapcompare on these backends. Fix Description: Add support for ldapcompare operations on dse.c, including the ability to correctly generate the cn=config defaults into the entry for comparison. This also adds support for ldapcompare as the default comparitor in lib389. https://pagure.io/389-ds-base/issue/49390 https://pagure.io/389-ds-base/issue/50019 Author: William Brown <[email protected]> Review by: ??? diff --git a/Makefile.am b/Makefile.am index 4d027e6c9..5649cbc2d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1301,6 +1301,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \ ldap/servers/slapd/ch_malloc.c \ ldap/servers/slapd/computed.c \ ldap/servers/slapd/control.c \ + ldap/servers/slapd/configdse.c \ ldap/servers/slapd/counters.c \ ldap/servers/slapd/csn.c \ ldap/servers/slapd/csngen.c \ @@ -2056,7 +2057,6 @@ ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \ ldap/servers/slapd/bind.c \ ldap/servers/slapd/compare.c \ ldap/servers/slapd/config.c \ - ldap/servers/slapd/configdse.c \ ldap/servers/slapd/connection.c \ ldap/servers/slapd/conntable.c \ ldap/servers/slapd/daemon.c \ diff --git a/dirsrvtests/tests/suites/lib389/config_compare_test.py b/dirsrvtests/tests/suites/lib389/config_compare_test.py index 6379555e9..220160999 100644 --- a/dirsrvtests/tests/suites/lib389/config_compare_test.py +++ b/dirsrvtests/tests/suites/lib389/config_compare_test.py @@ -16,7 +16,6 @@ def test_config_compare(topology_i2): :expectedresults: 1. It should be the same (excluding unique id attrs) """ - st1_config = topology_i2.ins.get('standalone1').config st2_config = topology_i2.ins.get('standalone2').config # 'nsslapd-port' attribute is expected to be same in cn=config comparison, @@ -30,7 +29,6 @@ def test_config_compare(topology_i2): assert Config.compare(st1_config, st2_config) - if __name__ == '__main__': # Run isolated # -s for DEBUG mode diff --git a/ldap/admin/src/scripts/ns-slapd-gdb.py b/ldap/admin/src/scripts/ns-slapd-gdb.py index 4e463b575..73e25aa0b 100644 --- a/ldap/admin/src/scripts/ns-slapd-gdb.py +++ b/ldap/admin/src/scripts/ns-slapd-gdb.py @@ -117,7 +117,55 @@ class DSIdleFilter(): frame_iter = map(DSIdleFilterDecorator, frame_iter) return frame_iter +class DSEntryPrint (gdb.Command): + """Display a Slapi_Entry""" + def __init__(self): + super (DSEntryPrint, self).__init__("ds-entry-print", gdb.COMMAND_DATA) + + def _display_values(self, a_name, va_ptr, num): + inum = int(num) + + for i in range(0, inum): + value = va_ptr[i].dereference() + bv = value['bv']['bv_val'] + if bv == 0: + print("%s: X 0" % a_name) + else: + print("%s: %s" % (a_name, bv.string())) + + + def _display_attrs(self, start): + if start.address == 0: + return + attr = start.dereference() + while True: + name = attr['a_type'].string() + # print(dir(name)) + va = attr['a_present_values']['va'] + num = attr['a_present_values']['num'] + self._display_values(name, va, num) + # Now loop + n = attr['a_next'] + if n == 0: + return + attr = n.dereference() + + + def invoke (self, arg, from_tty): + gdb.newest_frame() + cur_frame = gdb.selected_frame() + entry_val = cur_frame.read_var(arg) + entry_root = entry_val.dereference() + entry_sdn = entry_root['e_sdn']['ndn'] + # Display the SDN + print("Display Slapi_Entry: %s" % entry_sdn.string()) + # Display the attributes. + entry_attrs = entry_root['e_attrs'] + self._display_attrs(entry_attrs) + DSAccessLog() DSBacktrace() DSIdleFilter() +DSEntryPrint() + diff --git a/ldap/servers/slapd/backend_manager.c b/ldap/servers/slapd/backend_manager.c index d5475051e..299773fe6 100644 --- a/ldap/servers/slapd/backend_manager.c +++ b/ldap/servers/slapd/backend_manager.c @@ -113,7 +113,7 @@ be_new_internal(struct dse *pdse, const char *type, const char *name, struct sla be->be_database->plg_next_search_entry = &dse_next_search_entry; be->be_database->plg_search_results_release = &dse_search_set_release; be->be_database->plg_prev_search_results = &dse_prev_search_results; - be->be_database->plg_compare = &be_plgfn_unwillingtoperform; + be->be_database->plg_compare = &dse_compare; be->be_database->plg_modify = &dse_modify; be->be_database->plg_modrdn = &be_plgfn_unwillingtoperform; be->be_database->plg_add = &dse_add; diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c index 74dfd9093..1f1f51630 100644 --- a/ldap/servers/slapd/dse.c +++ b/ldap/servers/slapd/dse.c @@ -39,6 +39,8 @@ #include <prcountr.h> #include "slap.h" #include <pwd.h> +/* Needed to access read_config_dse */ +#include "proto-slap.h" #include <unistd.h> /* provides fsync/close */ @@ -186,16 +188,18 @@ dse_get_entry_copy(struct dse *pdse, const Slapi_DN *dn, int use_lock) Slapi_Entry *e = NULL; struct dse_node *n; - if (use_lock == DSE_USE_LOCK && pdse->dse_rwlock) + if (use_lock == DSE_USE_LOCK && pdse->dse_rwlock) { slapi_rwlock_rdlock(pdse->dse_rwlock); + } n = dse_find_node(pdse, dn); if (n != NULL) { e = slapi_entry_dup(n->entry); } - if (use_lock == DSE_USE_LOCK && pdse->dse_rwlock) + if (use_lock == DSE_USE_LOCK && pdse->dse_rwlock) { slapi_rwlock_unlock(pdse->dse_rwlock); + } return e; } @@ -1678,6 +1682,89 @@ dse_search(Slapi_PBlock *pb) /* JCM There should only be one exit point from thi return 0; } +int32_t +dse_compare(Slapi_PBlock *pb) +{ + /* + * Inspired largely by ldbm_compare.c. Allow schema aware comparison + * of entries in the DSE, including cn=config. + */ + backend *be = NULL; + char *type = NULL; + struct berval *bval = NULL; + Slapi_DN *sdn = NULL; + struct dse *pdse = NULL; + Slapi_Entry *ec = NULL; + Slapi_Value compare_value = {0}; + + slapi_pblock_get(pb, SLAPI_BACKEND, &be); + slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &pdse); + slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn); + slapi_pblock_get(pb, SLAPI_COMPARE_TYPE, &type); + slapi_pblock_get(pb, SLAPI_COMPARE_VALUE, &bval); + + /* get the entry */ + ec = dse_get_entry_copy(pdse, sdn, DSE_USE_LOCK); + if (ec == NULL) { + slapi_send_ldap_result(pb, LDAP_NO_SUCH_OBJECT, NULL, NULL, 0, NULL); + return -1; + } + + /* Access control check */ + int32_t err = slapi_access_allowed(pb, ec, type, bval, SLAPI_ACL_COMPARE); + if (err != LDAP_SUCCESS) { + slapi_entry_free(ec); + slapi_send_ldap_result(pb, err, NULL, NULL, 0, NULL); + return -1; + } + + /* If cn=config, setup the entry with ALL values we could check from defaults */ + Slapi_DN config_dn; + slapi_sdn_init_ndn_byref(&config_dn, "cn=config"); + if (slapi_sdn_compare(&config_dn, sdn) == 0) { + read_config_dse(pb, ec, NULL, &err, NULL, NULL); + /* + * read_config_dse, and in turn, config_set_entry always returns + * a 1 here, which is probably dse_callback related. + */ + if (err != 1) { + slapi_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, NULL, 0, NULL); + return -1; + } + /* + * cn=config is now populated + */ + } + slapi_sdn_done(&config_dn); + + /* Do the schema aware check. */ + slapi_value_init_berval(&compare_value, bval); + + int32_t result = 0; + err = slapi_vattr_value_compare(ec, type, &compare_value, &result, 0); + + /* We have the results, now free and then send. */ + slapi_entry_free(ec); + value_done(&compare_value); + + /* Format the result as expected. */ + if (err != LDAP_SUCCESS) { + if (SLAPI_VIRTUALATTRS_NOT_FOUND == err) { + slapi_send_ldap_result(pb, LDAP_NO_SUCH_ATTRIBUTE, NULL, NULL, 0, NULL); + } else { + /* Some other problem, call it an operations error */ + slapi_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, NULL, 0, NULL); + } + return -1; + } else { + if (result != 0) { + slapi_send_ldap_result(pb, LDAP_COMPARE_TRUE, NULL, NULL, 0, NULL); + } else { + slapi_send_ldap_result(pb, LDAP_COMPARE_FALSE, NULL, NULL, 0, NULL); + } + } + return 0; +} /* * -1 means something went wrong. diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index dce424321..6f20097ff 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -701,6 +701,7 @@ int dse_read_file(struct dse *pdse, Slapi_PBlock *pb); int dse_bind(Slapi_PBlock *pb); int dse_unbind(Slapi_PBlock *pb); int dse_search(Slapi_PBlock *pb); +int32_t dse_compare(Slapi_PBlock *pb); int dse_modify(Slapi_PBlock *pb); int dse_add(Slapi_PBlock *pb); int dse_delete(Slapi_PBlock *pb); diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py index 6981d4a5a..e96e0fe08 100644 --- a/src/lib389/lib389/_mapped_object.py +++ b/src/lib389/lib389/_mapped_object.py @@ -415,7 +415,7 @@ class DSLdapObject(DSLogging): raise ValueError('Too many arguments in the mod op') return self._instance.modify_ext_s(self._dn, mod_list, serverctrls=self._server_controls, clientctrls=self._client_controls, escapehatch='i am sure') - def _unsafe_compare_attribute(self, other): + def _unsafe_compare_attribute(self, attr, values): """Compare two attributes from two objects. This is currently marked unsafe as it's not complete yet. @@ -430,7 +430,12 @@ class DSLdapObject(DSLogging): To allow schema aware checking, we need to call ldap compare extop here. """ - pass + return all([ + self._instance.compare_ext_s(self._dn, attr, value, serverctrls=self._server_controls, + clientctrls=self._client_controls, escapehatch='i am sure') + for value in values + ]) + @classmethod def compare(cls, obj1, obj2): @@ -469,10 +474,14 @@ class DSLdapObject(DSLogging): if set(obj1_attrs.keys()) != set(obj2_attrs.keys()): obj1._log.debug("%s != %s" % (obj1_attrs.keys(), obj2_attrs.keys())) return False + obj1._log.debug(sorted(obj1_attrs.keys())) # Check the values of each key # using obj1_attrs.keys() because obj1_attrs.iterkleys() is not supported in python3 for key in obj1_attrs.keys(): - if set(obj1_attrs[key]) != set(obj2_attrs[key]): + # Check if they are offline/online? + # if set(obj1_attrs[key]) != set(obj2_attrs[key]): + obj1._log.debug("checking %s: %s ..." % (key, obj2_attrs[key])) + if not obj1._unsafe_compare_attribute(key, obj2_attrs[key]): obj1._log.debug(" v-- %s != %s" % (key, key)) obj1._log.debug("%s != %s" % (obj1_attrs[key], obj2_attrs[key])) return False
0
b5294b46fb613e7595683079369b96ba094cbd3c
389ds/389-ds-base
Ticket 47584: CI tests: add backup/restore of an instance Bug Description: A test case or a test suite needs to be isolated from side effects of others test cases run previously. For this we need to run a test case with "clean" instances. Fix Description: Creating/deleting instances is consuming time and could take much more time than the test case itself. The idea, is to create a kind of instance backup file. This backup file contains all components of the instance: config, schema, database environement, database files, certificates/keys... Before running a test case, the test reinit the instance it needs from this backup. So it gets rapidely "clean" instances https://fedorahosted.org/389/ticket/47584 Reviewed by: Rich Megginson, Roberto Polli (Thank you both for your help/patience !) Platforms tested: F19 Flag Day: no Doc impact: no
commit b5294b46fb613e7595683079369b96ba094cbd3c Author: Thierry bordaz (tbordaz) <[email protected]> Date: Wed Nov 6 14:06:49 2013 +0100 Ticket 47584: CI tests: add backup/restore of an instance Bug Description: A test case or a test suite needs to be isolated from side effects of others test cases run previously. For this we need to run a test case with "clean" instances. Fix Description: Creating/deleting instances is consuming time and could take much more time than the test case itself. The idea, is to create a kind of instance backup file. This backup file contains all components of the instance: config, schema, database environement, database files, certificates/keys... Before running a test case, the test reinit the instance it needs from this backup. So it gets rapidely "clean" instances https://fedorahosted.org/389/ticket/47584 Reviewed by: Rich Megginson, Roberto Polli (Thank you both for your help/patience !) Platforms tested: F19 Flag Day: no Doc impact: no diff --git a/src/lib389/lib389/tools.py b/src/lib389/lib389/tools.py index 087dd8856..b2f4cba47 100644 --- a/src/lib389/lib389/tools.py +++ b/src/lib389/lib389/tools.py @@ -22,6 +22,9 @@ import select import time import shutil import subprocess +import tarfile +import re +import glob import lib389 from lib389 import InvalidArgumentError @@ -256,6 +259,153 @@ class DirSrvTools(object): else: log.debug("Starting server %r" % self) return DirSrvTools.serverCmd(self, 'start', verbose, timeout) + + @staticmethod + def _infoInstanceBackupFS(dirsrv): + """ + Return the information to retrieve the backup file of a given instance + It returns: + - Directory name containing the backup (e.g. /tmp/slapd-standalone.bck) + - The pattern of the backup files (e.g. /tmp/slapd-standalone.bck/backup*.tar.gz) + """ + backup_dir = "%s/slapd-%s.bck" % (dirsrv.backupdir, dirsrv.inst) + backup_pattern = os.path.join(backup_dir, "backup*.tar.gz") + return backup_dir, backup_pattern + + @staticmethod + def clearInstanceBackupFS(dirsrv, backup_file=None): + """ + Remove a backup_file or all backup up of a given instance + """ + if backup_file: + if os.path.isfile(backup_file): + try: + os.remove(backup_file) + except: + log.info("clearInstanceBackupFS: fail to remove %s" % backup_file) + pass + else: + backup_dir, backup_pattern = DirSrvTools._infoInstanceBackupFS(dirsrv) + list_backup_files = glob.glob(backup_pattern) + for f in list_backup_files: + try: + os.remove(f) + except: + log.info("clearInstanceBackupFS: fail to remove %s" % backup_file) + pass + + + @staticmethod + def checkInstanceBackupFS(dirsrv): + """ + If it exits a backup file, it returns it + else it returns None + """ + + backup_dir, backup_pattern = DirSrvTools._infoInstanceBackupFS(dirsrv) + list_backup_files = glob.glob(backup_pattern) + if not list_backup_files: + return None + else: + # returns the first found backup + return list_backup_files[0] + + + @staticmethod + def instanceBackupFS(dirsrv): + """ + Saves the files of an instance under /tmp/slapd-<instance_name>.bck/backup_HHMMSS.tar.gz + and return the archive file name. + If it already exists a such file, it assums it is a valid backup and + returns its name + + dirsrv.sroot : root of the instance (e.g. /usr/lib64/dirsrv) + dirsrv.inst : instance name (e.g. standalone for /etc/dirsrv/slapd-standalone) + dirsrv.confdir : root of the instance config (e.g. /etc/dirsrv) + dirsrv.dbdir: directory where is stored the database (e.g. /var/lib/dirsrv/slapd-standalon/db + """ + + # First check it if already exists a backup file + backup_dir, backup_pattern = DirSrvTools._infoInstanceBackupFS(dirsrv) + backup_file = DirSrvTools.checkInstanceBackupFS(dirsrv) + if backup_file is None: + if not os.path.exists(backup_dir): + os.makedirs(backup_dir) + else: + return backup_file + + # goes under the directory where the DS is deployed + listFilesToBackup = [] + here = os.getcwd() + os.chdir(dirsrv.prefix) + prefix_pattern = "%s/" % dirsrv.prefix + + instroot = "%s/slapd-%s" % (dirsrv.sroot, dirsrv.inst) + for dirToBackup in [ instroot, dirsrv.confdir, dirsrv.dbdir]: + for root, dirs, files in os.walk(dirToBackup): + for file in files: + name = os.path.join(root, file) + name = re.sub(prefix_pattern, '', name) + + if os.path.isfile(name): + listFilesToBackup.append(name) + log.debug("instanceBackupFS add = %s (%s)" % (name, dirsrv.prefix)) + + + # create the archive + name = "backup_%s.tar.gz" % (time.strftime("%m%d%Y_%H%M%S")) + backup_file = os.path.join(backup_dir, name) + tar = tarfile.open(backup_file, "w:gz") + + + for name in listFilesToBackup: + if os.path.isfile(name): + tar.add(name) + tar.close() + log.info("instanceBackupFS: archive done : %s" % backup_file) + + # return to the directory where we were + os.chdir(here) + + return backup_file + + @staticmethod + def instanceRestoreFS(dirsrv, backup_file): + """ + """ + + # First check the archive exists + if backup_file is None: + log.warning("Unable to restore the instance (missing backup)") + return 1 + if not os.path.isfile(backup_file): + log.warning("Unable to restore the instance (%s is not a file)" % backup_file) + return 1 + + # Then restore from the directory where DS was deployed + here = os.getcwd() + os.chdir(dirsrv.prefix) + + tar = tarfile.open(backup_file) + for member in tar.getmembers(): + if os.path.isfile(member.name): + # + # restore only writable files + # It could be a bad idea and preferably restore all. + # Now it will be easy to enhance that function. + if os.access(member.name, os.W_OK): + log.debug("instanceRestoreFS: restored %s" % member.name) + tar.extract(member.name) + else: + log.debug("instanceRestoreFS: not restored %s (no write access)" % member.name) + else: + log.debug("instanceRestoreFS: restored %s" % member.name) + tar.extract(member.name) + + tar.close() + + os.chdir(here) + @staticmethod def setupSSL(dirsrv, secport=636, sourcedir=None, secargs=None): @@ -378,6 +528,9 @@ class DirSrvTools(object): # optionally register instance on an admin tree 'have_admin': True, + # optionally directory where to store instance backup + 'backupdir': [ /tmp ] + # you can configure a new dirsrv-admin 'setup_admin': True, @@ -395,6 +548,9 @@ class DirSrvTools(object): # use prefix if binaries are relocated sroot = args.get('sroot', '') prefix = args.setdefault('prefix', '') + + # get the backup directory to store instance backup + backupdir = args.get('backupdir', '/tmp') # new style - prefix or FHS? args['new_style'] = not args.get('sroot') @@ -464,6 +620,7 @@ class DirSrvTools(object): newconn = lib389.DirSrv(args['newhost'], args['newport'], args['newrootdn'], args['newrootpw'], args['newinstance']) newconn.prefix = prefix + newconn.backupdir = backupdir newconn.isLocal = isLocal if args['have_admin'] and not args['setup_admin']: newconn.asport = asport @@ -531,6 +688,7 @@ class DirSrvTools(object): newconn = lib389.DirSrv(args['newhost'], args['newport'], args['newrootdn'], args['newrootpw'], args['newinstance']) newconn.prefix = prefix + newconn.backupdir = backupdir newconn.isLocal = isLocal # Now the admin should have been created # but still I should have taken all the required infos
0
c6976c182e7c2f957b210a5b4241c09bcda6c60d
389ds/389-ds-base
Issue 50873 - Fix healthcheck and virtual attr check Description: Used the wrong DN to lookup COS definitions relates: https://pagure.io/389-ds-base/issue/50873 Reviewed by: mreynolds (one line commit rule)
commit c6976c182e7c2f957b210a5b4241c09bcda6c60d Author: Mark Reynolds <[email protected]> Date: Wed Feb 5 09:48:15 2020 -0500 Issue 50873 - Fix healthcheck and virtual attr check Description: Used the wrong DN to lookup COS definitions relates: https://pagure.io/389-ds-base/issue/50873 Reviewed by: mreynolds (one line commit rule) diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py index ac2af021c..86ee33e6e 100644 --- a/src/lib389/lib389/backend.py +++ b/src/lib389/lib389/backend.py @@ -438,7 +438,7 @@ class Backend(DSLdapObject): # Check COS next for cosDefType in [CosIndirectDefinitions, CosPointerDefinitions, CosClassicDefinitions]: - defs = cosDefType(self._instance, self._dn).list() + defs = cosDefType(self._instance, suffix).list() for cosDef in defs: attrs = cosDef.get_attr_val_utf8_l("cosAttribute").split() for attr in attrs:
0
61dc5e1fd0c3f3045b37ef076f814a0fef9aedc4
389ds/389-ds-base
Ticket 47885 - deref plugin should not return references with noc access rights Bug Description: deref shows derefernced entries for which th client doesn't have access as dn and empty attribute list Fix Description: if client has no accesss to the derferernced entry then omit it from the list in the deref control In general, if no entries are returned don't send an empty control https://fedorahosted.org/389/ticket/47885 Reviewed by: noriko, thanks
commit 61dc5e1fd0c3f3045b37ef076f814a0fef9aedc4 Author: Ludwig Krispenz <[email protected]> Date: Wed Sep 3 13:44:17 2014 +0200 Ticket 47885 - deref plugin should not return references with noc access rights Bug Description: deref shows derefernced entries for which th client doesn't have access as dn and empty attribute list Fix Description: if client has no accesss to the derferernced entry then omit it from the list in the deref control In general, if no entries are returned don't send an empty control https://fedorahosted.org/389/ticket/47885 Reviewed by: noriko, thanks diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c index f6588b097..96d42e6a2 100644 --- a/ldap/servers/plugins/deref/deref.c +++ b/ldap/servers/plugins/deref/deref.c @@ -591,13 +591,14 @@ deref_values_free(Slapi_ValueSet** results, char** actual_type_name, int buffer_ slapi_vattr_values_free(results, actual_type_name, buffer_flags); } -static void -deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn, const char **attrs) +static int +deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn, const char *derefattr, const char **attrs) { char **retattrs = NULL; Slapi_PBlock *derefpb = NULL; Slapi_Entry **entries = NULL; int rc; + int needcontrol = 0; /* If the access check on the attributes is done without retrieveing the entry * it cannot handle acis which need teh entry, eg to apply a targetfilter rule @@ -626,7 +627,9 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn, slapi_log_error(SLAPI_LOG_PLUGIN, DEREF_PLUGIN_SUBSYSTEM, "The client does not have permission to read the requested " "attributes in entry %s\n", derefdn); - } else { + } else { + needcontrol = 1; + ber_printf(ctrlber, "{ss", derefattr, derefdn); /* begin DerefRes + derefAttr + derefVal */ for (ii = 0; retattrs[ii]; ++ii) { Slapi_Value *sv; int idx = 0; @@ -684,6 +687,7 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn, if (needattrvals == 0) { ber_printf(ctrlber, "}"); } + ber_printf(ctrlber, "}"); /* end DerefRes */ } } } else { /* nothing */ @@ -700,7 +704,7 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn, slapi_pblock_destroy(derefpb); slapi_ch_free((void **)&retattrs); /* retattrs does not own the strings */ - return; + return needcontrol; } static int @@ -714,6 +718,7 @@ deref_pre_entry(Slapi_PBlock *pb) LDAPControl *ctrl = NULL; const LDAPControl **searchctrls = NULL; LDAPControl **newsearchctrls = NULL; + int needcontrol = 0; if (!speclist) { return 0; /* nothing to do */ @@ -757,31 +762,26 @@ deref_pre_entry(Slapi_PBlock *pb) for (; results && sv; idx = slapi_valueset_next_value(results, idx, &sv)) { const char *derefdn = slapi_value_get_string(sv); - ber_printf(ctrlber, "{ss", spec->derefattr, derefdn); /* begin DerefRes + derefAttr + derefVal */ - deref_do_deref_attr(pb, ctrlber, derefdn, (const char **)spec->attrs); - ber_printf(ctrlber, "}"); /* end DerefRes */ + needcontrol += deref_do_deref_attr(pb, ctrlber, derefdn, spec->derefattr, (const char **)spec->attrs); } deref_values_free(&results, &actual_type_name, buffer_flags); } ber_printf(ctrlber, "}"); /* end control val */ - - slapi_build_control(LDAP_CONTROL_X_DEREF, ctrlber, 0, &ctrl); - - ber_free(ctrlber, 1); - - /* get the list of controls */ + + if (needcontrol) { + slapi_build_control(LDAP_CONTROL_X_DEREF, ctrlber, 0, &ctrl); + /* get the list of controls */ slapi_pblock_get(pb, SLAPI_SEARCH_CTRLS, &searchctrls); - - /* dup them */ - slapi_add_controls(&newsearchctrls, (LDAPControl **)searchctrls, 1); - - /* add our control */ - slapi_add_control_ext(&newsearchctrls, ctrl, 0); - ctrl = NULL; /* newsearchctrls owns it now */ - - /* set the controls in the pblock */ - slapi_pblock_set(pb, SLAPI_SEARCH_CTRLS, newsearchctrls); + /* dup them */ + slapi_add_controls(&newsearchctrls, (LDAPControl **)searchctrls, 1); + /* add our control */ + slapi_add_control_ext(&newsearchctrls, ctrl, 0); + ctrl = NULL; /* newsearchctrls owns it now */ + /* set the controls in the pblock */ + slapi_pblock_set(pb, SLAPI_SEARCH_CTRLS, newsearchctrls); + } + ber_free(ctrlber, 1); return 0; }
0
8fcc1ddedfa71fa6c0c53e32ad92d22363d9651a
389ds/389-ds-base
Issue 6441 - Add basic dsidm posixgroup tests New basic dsidm posixgroup test - create, list, get, get_dn, modify, rename, rename with keep-old-rdn option. Contains fix for failing get_dn option - #6439. Relates: https://github.com/389ds/389-ds-base/issues/6441, https://github.com/389ds/389-ds-base/issues/6439 Author: Lenka Doudova Reviewed by: Simon Pichugin
commit 8fcc1ddedfa71fa6c0c53e32ad92d22363d9651a Author: Lenka Doudova <[email protected]> Date: Tue Dec 10 18:25:20 2024 +0100 Issue 6441 - Add basic dsidm posixgroup tests New basic dsidm posixgroup test - create, list, get, get_dn, modify, rename, rename with keep-old-rdn option. Contains fix for failing get_dn option - #6439. Relates: https://github.com/389ds/389-ds-base/issues/6441, https://github.com/389ds/389-ds-base/issues/6439 Author: Lenka Doudova Reviewed by: Simon Pichugin diff --git a/dirsrvtests/tests/suites/clu/dsidm_posixgroup_test.py b/dirsrvtests/tests/suites/clu/dsidm_posixgroup_test.py new file mode 100644 index 000000000..ccafd3905 --- /dev/null +++ b/dirsrvtests/tests/suites/clu/dsidm_posixgroup_test.py @@ -0,0 +1,425 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2024 Red Hat, Inc. +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import pytest +import logging +import os + +from lib389 import DEFAULT_SUFFIX +from lib389.cli_idm.posixgroup import list, get, get_dn, create, delete, modify, rename +from lib389.topologies import topology_st +from lib389.cli_base import FakeArgs +from lib389.utils import ds_is_older, ensure_str +from lib389.idm.posixgroup import PosixGroups +from . import check_value_in_log_and_reset + +pytestmark = pytest.mark.tier0 + +logging.getLogger(__name__).setLevel(logging.DEBUG) +log = logging.getLogger(__name__) + +posixgroup_name = 'test_posixgroup' + [email protected](scope="function") +def create_test_posixgroup(topology_st, request): + posixgroups = PosixGroups(topology_st.standalone, DEFAULT_SUFFIX) + + log.info('Create test posixgroup') + if posixgroups.exists(posixgroup_name): + test_posixgroup = posixgroups.get(posixgroup_name) + test_posixgroup.delete() + + properties = FakeArgs() + properties.cn = posixgroup_name + properties.gidNumber = '3000' + create(topology_st.standalone, DEFAULT_SUFFIX, topology_st.logcap.log, properties) + test_posixgroup = posixgroups.get(posixgroup_name) + + def fin(): + log.info('Delete test posixgroup') + if test_posixgroup.exists(): + test_posixgroup.delete() + + request.addfinalizer(fin) + + [email protected](scope="function") +def add_description(topology_st, request): + args = FakeArgs() + args.selector = posixgroup_name + args.changes = ['add:description:{}'.format(posixgroup_name)] + modify(topology_st.standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args, warn=False) + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_create(topology_st): + """ Test dsidm posixgroup create option + + :id: 90c988df-ff98-4004-838d-2012d77c6bd7 + :setup: Standalone instance + :steps: + 1. Run dsidm posixgroup create + 2. Check that a message is provided on creation + 3. Check that created posixgroup exists + :expectedresults: + 1. Success + 2. Success + 3. Success + """ + + standalone = topology_st.standalone + output = 'Successfully created {}'.format(posixgroup_name) + + args = FakeArgs() + args.cn = posixgroup_name + args.gidNumber = '3000' + + log.info('Test dsidm posixgroup create') + create(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, check_value=output) + + log.info('Check that posixgroup is present') + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + new_posixgroup = posixgroups.get(posixgroup_name) + assert new_posixgroup.exists() + assert new_posixgroup.present('gidNumber', '3000') + + log.info('Clean up for next test') + new_posixgroup.delete() + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_delete(topology_st, create_test_posixgroup): + """ Test dsidm posixgroup delete option + + :id: d471c8b9-6a67-4b50-a3c7-651f1b8c1283 + :setup: Standalone instance + :steps: + 1. Run dsidm posixgroup delete on a created group + 2. Check that a message is provided on deletion + 3. Check that posixgroup does not exist + :expectedresults: + 1. Success + 2. Success + 3. Success + """ + + standalone = topology_st.standalone + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + test_posixgroup = posixgroups.get(posixgroup_name) + output = 'Successfully deleted {}'.format(test_posixgroup.dn) + + args = FakeArgs() + args.dn = test_posixgroup.dn + + log.info('Test dsidm posixgroup delete') + delete(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args, warn=False) + check_value_in_log_and_reset(topology_st, check_value=output) + + log.info('Check that posixgroup does not exist') + assert not test_posixgroup.exists() + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_modify(topology_st, create_test_posixgroup): + """ Test dsidm posixgroup modify option + + :id: c166ed02-56cc-4e85-bf19-d63142fac711 + :setup: Standalone instance + :steps: + 1. Run dsidm posixgroup modify add description value + 2. Run dsidm posixgroup modify replace description value + 3. Run dsidm posixgroup modify delete description value + :expectedresults: + 1. Description value is present + 2. Description value is replaced with the new one + 3. Description value is deleted + """ + + standalone = topology_st.standalone + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + test_posixgroup = posixgroups.get(posixgroup_name) + output = 'Successfully modified {}'.format(test_posixgroup.dn) + + args = FakeArgs() + args.selector = posixgroup_name + + log.info('Test dsidm posixgroup modify add') + args.changes = ['add:description:test_posixgroup_description'] + modify(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args, warn=False) + check_value_in_log_and_reset(topology_st, check_value=output) + assert test_posixgroup.present('description', 'test_posixgroup_description') + + log.info('Test dsidm posixgroup modify replace') + args.changes = ['replace:description:new_posixgroup_description'] + modify(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args, warn=False) + check_value_in_log_and_reset(topology_st, check_value=output) + assert test_posixgroup.present('description', 'new_posixgroup_description') + + log.info('Test dsidm posixgroup modify delete') + args.changes = ['delete:description:new_posixgroup_description'] + modify(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args, warn=False) + check_value_in_log_and_reset(topology_st, check_value=output) + assert not test_posixgroup.present('description', 'new_posixgroup_description') + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_list(topology_st, create_test_posixgroup): + """ Test dsidm posixgroup list option + + :id: 03b72540-2c2b-405d-a918-4ca0dbddfcc5 + :setup: Standalone instance + :steps: + 1. Run dsidm posixgroup list option without json + 2. Check the output content is correct + 3. Run dsidm posixgroup list option with json + 4. Check the output content is correct + 5. Delete the posixgroup + 6. Check the posixgroup is not in the list with json + 7. Check the posixgroup is not in the list without json + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + 7. Success + """ + + standalone = topology_st.standalone + args = FakeArgs() + args.json = False + json_list = ['type', + 'list', + 'items'] + + log.info('Empty the log file to prevent false data to check about posixgroup') + topology_st.logcap.flush() + + log.info('Test dsidm posixgroup list without json') + list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, check_value=posixgroup_name) + + log.info('Test dsidm posixgroup list with json') + args.json = True + list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, content_list=json_list, check_value=posixgroup_name) + + log.info('Delete the posixgroup') + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + test_posixgroup = posixgroups.get(posixgroup_name) + test_posixgroup.delete() + + log.info('Test empty dsidm posixgroup list with json') + list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, content_list=json_list, check_value_not=posixgroup_name) + + log.info('Test empty dsidm posixgroup list without json') + args.json = False + list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, check_value_not=posixgroup_name) + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_get_dn(topology_st, create_test_posixgroup): + """ Test dsidm posixgroup get_dn option + + :id: 2ca19f8c-6f26-4dff-9e1f-8801a748b23b + :setup: Standalone instance + :steps: + 1. Run dsidm group get_dn for created group without json + 2. Check the output content is correct + 3. Run dsidm group get_dn for created group with json + 4. Check the output content is correct + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + """ + + standalone = topology_st.standalone + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + test_posixgroup = posixgroups.get(posixgroup_name) + args = FakeArgs() + args.dn = test_posixgroup.dn + args.json = False + + log.info('Empty the log file to prevent false data to check about group') + topology_st.logcap.flush() + + log.info('Test dsidm group get_dn without json') + get_dn(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, content_list=posixgroup_name) + + log.info('Test dsidm group get_dn with json') + args.json = True + get_dn(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, content_list=posixgroup_name) + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_get_rdn(topology_st, create_test_posixgroup): + """ Test dsidm group get option + + :id: 54fe642d-bbaf-480e-8bb0-a7dc50f8f594 + :setup: Standalone instance + :steps: + 1. Run dsidm get option for created group with json + 2. Check the output content is correct + 3. Run dsidm get option for created group without json + 4. Check the json content is correct + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + """ + + standalone = topology_st.standalone + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + test_posixgroup = posixgroups.get(posixgroup_name) + + posixgroup_content = ['dn: {}'.format(test_posixgroup.dn), + 'cn: {}'.format(test_posixgroup.rdn), + 'gidNumber: 3000', + 'objectClass: top', + 'objectClass: groupOfNames', + 'objectClass: posixGroup', + 'objectClass: nsMemberOf'] + + json_content = ['attrs', + 'objectclass', + 'top', + 'groupOfNames', + 'posixGroup', + 'nsMemberOf', + 'cn', + test_posixgroup.rdn, + 'gidnumber', + '3000', + 'creatorsname', + 'cn=directory manager', + 'modifiersname', + 'createtimestamp', + 'modifytimestamp', + 'nsuniqueid', + 'parentid', + 'entryid', + 'entryuuid', + 'dsentrydn', + 'entrydn', + test_posixgroup.dn] + + args = FakeArgs() + args.json = False + args.selector = posixgroup_name + + log.info('Empty the log file to prevent false data to check about posixgroup') + topology_st.logcap.flush() + + log.info('Test dsidm posixgroup get without json') + get(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, content_list=posixgroup_content) + + log.info('Test dsidm posixgroup get with json') + args.json = True + get(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + check_value_in_log_and_reset(topology_st, content_list=json_content) + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_rename(topology_st, create_test_posixgroup, add_description): + """ Test dsidm posixgroup rename option + + :id: 1919805e-efd6-41da-91e7-59c011546993 + :setup: Standalone instance + :steps: + 1. Run dsidm posixgroup rename option on created posixgroup + 2. Check the group does not have another cn attribute with the old rdn + 3. Check the old group is deleted + :expectedresults: + 1. Success + 2. Success + 3. Success + """ + + standalone = topology_st.standalone + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + test_posixgroup = posixgroups.get(posixgroup_name) + + args = FakeArgs() + args.selector = posixgroup_name + args.new_name = 'new_posixgroup' + args.keep_old_rdn = False + + log.info('Test dsidm posixgroup rename') + rename(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + new_posixgroup = posixgroups.get(args.new_name) + output = 'Successfully renamed to {}'.format(new_posixgroup.dn) + check_value_in_log_and_reset(topology_st, check_value=output) + + log.info('Verify the new posixgroup does not have cn attribute with the old rdn') + assert not new_posixgroup.present('cn', posixgroup_name) + assert new_posixgroup.get_attr_val_utf8('description') == posixgroup_name + + log.info('Verify old posixgroup dn does not exist') + assert not test_posixgroup.exists() + + log.info('Clean up') + new_posixgroup.delete() + + [email protected](ds_is_older("1.4.2"), reason="Not implemented") +def test_dsidm_posixgroup_rename_keep_old_rdn(topology_st, create_test_posixgroup, add_description): + """ Test dsidm posixgroup rename option with keep-old-rdn + + :id: 80b5faf0-dd84-4853-a21a-739388c112f5 + :setup: Standalone instance + :steps: + 1. Run dsidm posixgroup rename option on created posixgroup with keep-old-rdn + 2. Check the group has another cn attribute with the old rdn + 3. Check the old group is deleted + :expectedresults: + 1. Success + 2. Success + 3. Success + """ + + standalone = topology_st.standalone + posixgroups = PosixGroups(standalone, DEFAULT_SUFFIX) + test_posixgroup = posixgroups.get(posixgroup_name) + + args = FakeArgs() + args.selector = posixgroup_name + args.new_name = 'new_posixgroup' + args.keep_old_rdn = True + + log.info('Test dsidm posixgroup rename with keep-old-rdn') + rename(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) + new_posixgroup = posixgroups.get(args.new_name) + output = 'Successfully renamed to {}'.format(new_posixgroup.dn) + check_value_in_log_and_reset(topology_st, check_value=output) + + log.info('Verify the new posixgroup has cn attribute with the old rdn') + assert new_posixgroup.present('cn', posixgroup_name) + assert new_posixgroup.get_attr_val_utf8('description') == posixgroup_name + + log.info('Verify old posixgroup dn does not exist') + assert not test_posixgroup.exists() + + log.info('Clean up') + new_posixgroup.delete() + + +if __name__ == '__main__': + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE) \ No newline at end of file diff --git a/src/lib389/lib389/cli_idm/posixgroup.py b/src/lib389/lib389/cli_idm/posixgroup.py index 0b71d97c0..6318d9b00 100644 --- a/src/lib389/lib389/cli_idm/posixgroup.py +++ b/src/lib389/lib389/cli_idm/posixgroup.py @@ -38,7 +38,7 @@ def get(inst, basedn, log, args): def get_dn(inst, basedn, log, args): - dn = lambda args: _get_arg( args.dn, msg="Enter dn to retrieve") + dn = _get_arg( args.dn, msg="Enter dn to retrieve") _generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn, args) @@ -47,9 +47,10 @@ def create(inst, basedn, log, args): _generic_create(inst, basedn, log.getChild('_generic_create'), MANY, kwargs, args) -def delete(inst, basedn, log, args): - dn = _get_arg( args, msg="Enter dn to delete") - _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn)) +def delete(inst, basedn, log, args, warn=True): + dn = _get_arg( args.dn, msg="Enter dn to delete") + if warn: + _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn)) _generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR, dn, args)
0
5c62419806c7b9c836153358079898216f6f13da
389ds/389-ds-base
Fix spal_meminfo_get function prototype Fixes RHBZ #1515191 Signed-off-by: Christian Heimes <[email protected]>
commit 5c62419806c7b9c836153358079898216f6f13da Author: Christian Heimes <[email protected]> Date: Mon Nov 20 12:25:53 2017 +0100 Fix spal_meminfo_get function prototype Fixes RHBZ #1515191 Signed-off-by: Christian Heimes <[email protected]> diff --git a/ldap/servers/slapd/slapi_pal.h b/ldap/servers/slapd/slapi_pal.h index a6d9453d1..07d47d605 100644 --- a/ldap/servers/slapd/slapi_pal.h +++ b/ldap/servers/slapd/slapi_pal.h @@ -44,7 +44,7 @@ typedef struct _slapi_pal_meminfo * * \return slapi_pal_meminfo * pointer to structure containing data, or NULL. */ -slapi_pal_meminfo *spal_meminfo_get(); +slapi_pal_meminfo *spal_meminfo_get(void); /** * Destroy an allocated memory info structure. The caller is responsible for
0
38c74d224c250abd907636f7d78e95775ebf63dd
389ds/389-ds-base
Ticket #47875 - dirsrv not running with old openldap Description: Changing the function of AC_CHECK_LIB from ldif_open to _init so that regardless of the contents of the library, it's linked to the server if it exists. https://fedorahosted.org/389/ticket/47875 Reviewed by [email protected] (Thank you, Rich!!)
commit 38c74d224c250abd907636f7d78e95775ebf63dd Author: Noriko Hosoi <[email protected]> Date: Wed Aug 20 13:51:40 2014 -0700 Ticket #47875 - dirsrv not running with old openldap Description: Changing the function of AC_CHECK_LIB from ldif_open to _init so that regardless of the contents of the library, it's linked to the server if it exists. https://fedorahosted.org/389/ticket/47875 Reviewed by [email protected] (Thank you, Rich!!) diff --git a/m4/openldap.m4 b/m4/openldap.m4 index 74700d74f..1e297c48c 100644 --- a/m4/openldap.m4 +++ b/m4/openldap.m4 @@ -146,8 +146,12 @@ if test "$with_openldap" = yes ; then dnl ldif functionality into libldap ldap_lib_ldif="" LDFLAGS="$LDFLAGS" - AC_CHECK_LIB([ldap$ol_libver], [ldif_open], [ldap_lib_ldif=], - [ldap_lib_ldif=-lldif$ol_libver]) + AC_CHECK_LIB([ldif$ol_libver], [_init], [ldap_lib_ldif=-lldif$ol_libver], + [ldap_lib_ldif=]) + if test -z "$ldap_lib_ldif" ; then + AC_CHECK_LIB([ldif], [_init], [ldap_lib_ldif=-lldif], + [ldap_lib_ldif=]) + fi AC_SUBST([ldap_lib_ldif]) LDFLAGS="$save_ldflags" CPPFLAGS="$save_cppflags"
0
58be90b8bf96a7a0e10740b122035ea03fa13e0f
389ds/389-ds-base
Ticket 49540 - FIx compiler warning in ldif2ldbm https://pagure.io/389-ds-base/issue/49540 Reviewed by: mreynolds(one line commit rule)
commit 58be90b8bf96a7a0e10740b122035ea03fa13e0f Author: Mark Reynolds <[email protected]> Date: Tue Jan 15 13:55:18 2019 -0500 Ticket 49540 - FIx compiler warning in ldif2ldbm https://pagure.io/389-ds-base/issue/49540 Reviewed by: mreynolds(one line commit rule) diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c index b8052f960..a5c8c8207 100644 --- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c +++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c @@ -713,7 +713,7 @@ ldbm_back_ldif2ldbm(Slapi_PBlock *pb) uint64_t refcnt; refcnt = slapi_counter_get_value(inst->inst_ref_count); if (refcnt > 0) { - slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_ldif2ldbm", "ldbm: '%s' there are %d pending operation(s)." + slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_ldif2ldbm", "ldbm: '%s' there are %" PRIu64 " pending operation(s)." " Import can not proceed until they are completed.\n", inst->inst_name, refcnt);
0
f06181b212b4fb8a747439a8cfb777ca69026596
389ds/389-ds-base
Issue 4315 - performance search rate: nagle triggers high rate of setsocketopt Description: The config value of nsslapd-nagle is now set to 'off' by default. Added a test case, that checks the value. Relates: https://github.com/389ds/389-ds-base/issues/4315 Reviewed by: droideck (Thanks!)
commit f06181b212b4fb8a747439a8cfb777ca69026596 Author: Barbora Simonova <[email protected]> Date: Mon Jan 11 15:51:24 2021 +0100 Issue 4315 - performance search rate: nagle triggers high rate of setsocketopt Description: The config value of nsslapd-nagle is now set to 'off' by default. Added a test case, that checks the value. Relates: https://github.com/389ds/389-ds-base/issues/4315 Reviewed by: droideck (Thanks!) diff --git a/dirsrvtests/tests/suites/config/config_test.py b/dirsrvtests/tests/suites/config/config_test.py index 38d1ed9ac..fda16a530 100644 --- a/dirsrvtests/tests/suites/config/config_test.py +++ b/dirsrvtests/tests/suites/config/config_test.py @@ -41,6 +41,26 @@ def big_file(): return TEMP_BIG_FILE [email protected] [email protected] [email protected](ds_is_older('1.4.3.16'), reason="This config setting exists in 1.4.3.16 and higher") +def test_nagle_default_value(topo): + """Test that nsslapd-nagle attribute is off by default + + :id: 00361f5d-d638-4d39-8231-66fa52637203 + :setup: Standalone instance + :steps: + 1. Create instance + 2. Check the value of nsslapd-nagle + :expectedresults: + 1. Success + 2. The value of nsslapd-nagle should be off + """ + + log.info('Check the value of nsslapd-nagle attribute is off by default') + assert topo.standalone.config.get_attr_val_utf8('nsslapd-nagle') == 'off' + + def test_maxbersize_repl(topology_m2, big_file): """maxbersize is ignored in the replicated operations.
0
7110db91e75f392f1c83643d9aa88895992d9c01
389ds/389-ds-base
Ticket 48882 - server can hang in connection list processing Bug Description: if a thread holding the connection monitor is stuck in polling and the client doesn't respond, the main thread can be blocked on this connection when iterating the connection table. Fix Description: Implement a test and enter function for the connection monitor, so the main thread will never wait for a connection monitor already owned by an other thread https://fedorahosted.org/389/ticket/48882 Reviewed by: Noriko, Thanks
commit 7110db91e75f392f1c83643d9aa88895992d9c01 Author: Ludwig Krispenz <[email protected]> Date: Mon Aug 1 10:47:31 2016 +0200 Ticket 48882 - server can hang in connection list processing Bug Description: if a thread holding the connection monitor is stuck in polling and the client doesn't respond, the main thread can be blocked on this connection when iterating the connection table. Fix Description: Implement a test and enter function for the connection monitor, so the main thread will never wait for a connection monitor already owned by an other thread https://fedorahosted.org/389/ticket/48882 Reviewed by: Noriko, Thanks diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 81a54cfc1..23c30c384 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -164,6 +164,67 @@ static void unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, PRFileDes static int write_pid_file(); static int init_shutdown_detect(); +/* + * NSPR has different implementations for PRMonitor, depending + * on the availble threading model + * The PR_TestAndEnterMonitor is not available for pthreads + * so this is a implementation based on the code in + * prmon.c adapted to resemble the implementation in ptsynch.c + * + * The function needs access to the elements of the PRMonitor struct. + * Therfor the pthread variant of PRMonitor is copied here. + */ +typedef struct MY_PRMonitor { + const char* name; + pthread_mutex_t lock; + pthread_t owner; + pthread_cond_t entryCV; + pthread_cond_t waitCV; + PRInt32 refCount; + PRUint32 entryCount; + PRIntn notifyTimes; +} MY_PRMonitor; + +static PRBool MY_TestAndEnterMonitor(MY_PRMonitor *mon) +{ + pthread_t self = pthread_self(); + PRStatus rv; + PRBool rc = PR_FALSE; + + PR_ASSERT(mon != NULL); + rv = pthread_mutex_lock(&mon->lock); + if (rv != 0) { + slapi_log_error(SLAPI_LOG_FATAL ,"TestAndEnterMonitor", + "Failed to acquire monitor mutex, error (%d)\n", rv); + return rc; + } + if (mon->entryCount != 0) { + if (pthread_equal(mon->owner, self)) + goto done; + rv = pthread_mutex_unlock(&mon->lock); + if (rv != 0) { + slapi_log_error(SLAPI_LOG_FATAL ,"TestAndEnterMonitor", + "Failed to release monitor mutex, error (%d)\n", rv); + } + return PR_FALSE; + } + /* and now I have the monitor */ + PR_ASSERT(mon->notifyTimes == 0); + PR_ASSERT((mon->owner) == 0); + mon->owner = self; + +done: + mon->entryCount += 1; + rv = pthread_mutex_unlock(&mon->lock); + if (rv == PR_SUCCESS) { + rc = PR_TRUE; + } else { + slapi_log_error(SLAPI_LOG_FATAL ,"TestAndEnterMonitor", + "Failed to release monitor mutex, error (%d)\n", rv); + rc = PR_FALSE; + } + return rc; +} /* Globals which are used to store the sockets between * calls to daemon_pre_setuid_init() and the daemon thread * creation. */ @@ -1552,7 +1613,13 @@ setup_pr_read_pds(Connection_Table *ct, PRFileDesc **n_tcps, PRFileDesc **s_tcps } else { - PR_EnterMonitor(c->c_mutex); + /* we try to acquire the connection mutex, if it is already + * acquired by another thread, don't wait + */ + if (PR_FALSE == MY_TestAndEnterMonitor((MY_PRMonitor *)c->c_mutex)) { + c = next; + continue; + } if (c->c_flags & CONN_FLAG_CLOSING) { /* A worker thread has marked that this connection
0
f70152942727368aa0ce378bdfd54c6bad32e69d
389ds/389-ds-base
Bug 604453 - SASL Stress and Server crash: Program quits with the assertion failure in PR_Poll https://bugzilla.redhat.com/show_bug.cgi?id=604453 Resolves: bug 604453 Bug Description: SASL Stress and Server crash: Program quits with the assertion failure in PR_Poll Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: When the server pushes the SASL IO layer on to the connection it must do so when there are no other references to the connection. The only way to do this without introducing more locking is to have the saslbind code just register the intent to push SASL IO at the next available time. This cannot be done in the sasl bind code (or any operation code for that matter) because connection_threadmain() will enable the connection for reading (and polling) after reading the PDU and before calling the operation function. Therefore, during the operation function, the connection may be being actively polled, so we must not access the conn c_prfd. The best place to push the IO layer is in connection_threadmain, after the server has notified that there is read ready on the connection, but before we have actually attempted to read anything. At this point, connection_threadmain is the only thread that will be accessing the connection, and if we push or pop the IO layer before calling the read function, we are guaranteed to have the correct IO layer to use. The code has been made generic enough to allow for use by the startTLS code if the need arises. I also added some more locking in the saslbind code, and changed the sasl IO code to more closely resemble the way that the NSS code deals with IO layer push/pop. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no (cherry picked from commit c28fcadfc7812108573e40f13624e11a5a8609e5)
commit f70152942727368aa0ce378bdfd54c6bad32e69d Author: Rich Megginson <[email protected]> Date: Wed Jun 23 10:36:52 2010 -0600 Bug 604453 - SASL Stress and Server crash: Program quits with the assertion failure in PR_Poll https://bugzilla.redhat.com/show_bug.cgi?id=604453 Resolves: bug 604453 Bug Description: SASL Stress and Server crash: Program quits with the assertion failure in PR_Poll Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: When the server pushes the SASL IO layer on to the connection it must do so when there are no other references to the connection. The only way to do this without introducing more locking is to have the saslbind code just register the intent to push SASL IO at the next available time. This cannot be done in the sasl bind code (or any operation code for that matter) because connection_threadmain() will enable the connection for reading (and polling) after reading the PDU and before calling the operation function. Therefore, during the operation function, the connection may be being actively polled, so we must not access the conn c_prfd. The best place to push the IO layer is in connection_threadmain, after the server has notified that there is read ready on the connection, but before we have actually attempted to read anything. At this point, connection_threadmain is the only thread that will be accessing the connection, and if we push or pop the IO layer before calling the read function, we are guaranteed to have the correct IO layer to use. The code has been made generic enough to allow for use by the startTLS code if the need arises. I also added some more locking in the saslbind code, and changed the sasl IO code to more closely resemble the way that the NSS code deals with IO layer push/pop. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no (cherry picked from commit c28fcadfc7812108573e40f13624e11a5a8609e5) diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index 85aef8e08..cf88a5904 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -2181,6 +2181,14 @@ connection_threadmain() g_decr_active_threadcnt(); return; case CONN_FOUND_WORK_TO_DO: + /* note - don't need to lock here - connection should only + be used by this thread - since c_gettingber is set to 1 + in connection_activity when the conn is added to the + work queue, setup_pr_read_pds won't add the connection prfd + to the poll list */ + if (connection_call_io_layer_callbacks(pb->pb_conn)) { + LDAPDebug0Args( LDAP_DEBUG_ANY, "Error: could not add/remove IO layers from connection\n" ); + } default: break; } @@ -2194,6 +2202,9 @@ connection_threadmain() PR_Lock(conn->c_mutex); /* Make our own pb in turbo mode */ connection_make_new_pb(&pb,conn); + if (connection_call_io_layer_callbacks(conn)) { + LDAPDebug0Args( LDAP_DEBUG_ANY, "Error: could not add/remove IO layers from connection\n" ); + } PR_Unlock(conn->c_mutex); if (! config_check_referral_mode()) { slapi_counter_increment(ops_initiated); @@ -2775,3 +2786,31 @@ connection_abandon_operations( Connection *c ) } } } + +/* must be called within c->c_mutex */ +void +connection_set_io_layer_cb( Connection *c, Conn_IO_Layer_cb push_cb, Conn_IO_Layer_cb pop_cb, void *cb_data ) +{ + c->c_push_io_layer_cb = push_cb; + c->c_pop_io_layer_cb = pop_cb; + c->c_io_layer_cb_data = cb_data; +} + +/* must be called within c->c_mutex */ +int +connection_call_io_layer_callbacks( Connection *c ) +{ + int rv = 0; + if (c->c_pop_io_layer_cb) { + rv = (c->c_pop_io_layer_cb)(c, c->c_io_layer_cb_data); + c->c_pop_io_layer_cb = NULL; + } + if (!rv && c->c_push_io_layer_cb) { + rv = (c->c_push_io_layer_cb)(c, c->c_io_layer_cb_data); + c->c_push_io_layer_cb = NULL; + } + c->c_io_layer_cb_data = NULL; + + return rv; +} + diff --git a/ldap/servers/slapd/fe.h b/ldap/servers/slapd/fe.h index 3eb1d0adf..3a985cb70 100644 --- a/ldap/servers/slapd/fe.h +++ b/ldap/servers/slapd/fe.h @@ -116,6 +116,8 @@ int connection_operations_pending( Connection *conn, Operation *op2ignore, void connection_done(Connection *conn); void connection_cleanup(Connection *conn); void connection_reset(Connection* conn, int ns, PRNetAddr * from, int fromLen, int is_SSL); +void connection_set_io_layer_cb( Connection *c, Conn_IO_Layer_cb push_cb, Conn_IO_Layer_cb pop_cb, void *cb_data ); +int connection_call_io_layer_callbacks( Connection *c ); /* * conntable.c @@ -182,7 +184,8 @@ void configure_ns_socket( int * ns ); /* * sasl_io.c */ -int sasl_io_enable(Connection *c); +int sasl_io_enable(Connection *c, void *data); +int sasl_io_cleanup(Connection *c, void *data); /* * sasl_map.c diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 68d5d4828..f0d27ca7a 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -949,7 +949,6 @@ int slapd_ssl_init(); int slapd_ssl_init2(PRFileDesc **fd, int startTLS); int slapd_security_library_is_initialized(); int slapd_ssl_listener_is_initialized(); -int sasl_io_cleanup(Connection *c); int slapd_SSL_client_auth (LDAP* ld); /* diff --git a/ldap/servers/slapd/sasl_io.c b/ldap/servers/slapd/sasl_io.c index f0e403de5..b831a8601 100644 --- a/ldap/servers/slapd/sasl_io.c +++ b/ldap/servers/slapd/sasl_io.c @@ -481,20 +481,33 @@ sasl_io_write(PRFileDesc *fd, const void *buf, PRInt32 amount) } static PRStatus PR_CALLBACK -sasl_pop_IO_layer(PRFileDesc* stack) +sasl_pop_IO_layer(PRFileDesc* stack, int doclose) { PRFileDesc* layer = NULL; sasl_io_private *sp = NULL; + PRStatus rv = 0; + PRDescIdentity id = PR_TOP_IO_LAYER; /* see if stack has the sasl io layer */ - if (!sasl_LayerID || !stack || !PR_GetIdentitiesLayer(stack, sasl_LayerID)) { + if (!sasl_LayerID || !stack) { LDAPDebug0Args( LDAP_DEBUG_CONNS, "sasl_pop_IO_layer: no SASL IO layer\n" ); return PR_SUCCESS; } + /* if we're not being called during PR_Close, then we just want to + pop the sasl io layer if it is on the stack */ + if (!doclose) { + id = sasl_LayerID; + if (!PR_GetIdentitiesLayer(stack, id)) { + LDAPDebug0Args( LDAP_DEBUG_CONNS, + "sasl_pop_IO_layer: no SASL IO layer\n" ); + return PR_SUCCESS; + } + } + /* remove the layer from the stack */ - layer = PR_PopIOLayer(stack, sasl_LayerID); + layer = PR_PopIOLayer(stack, id); if (!layer) { LDAPDebug0Args( LDAP_DEBUG_CONNS, "sasl_pop_IO_layer: error - could not pop SASL IO layer\n" ); @@ -517,23 +530,29 @@ sasl_pop_IO_layer(PRFileDesc* stack) layer->dtor(layer); } - return PR_SUCCESS; + if (doclose) { + rv = stack->methods->close(stack); + } else { + rv = PR_SUCCESS; + } + + return rv; } static PRStatus PR_CALLBACK closeLayer(PRFileDesc* stack) { + PRStatus rv = 0; LDAPDebug0Args( LDAP_DEBUG_CONNS, "closeLayer: closing SASL IO layer\n" ); - if (PR_FAILURE == sasl_pop_IO_layer(stack)) { + rv = sasl_pop_IO_layer(stack, 1 /* do close */); + if (PR_SUCCESS != rv) { LDAPDebug0Args( LDAP_DEBUG_CONNS, - "closeLayer: error closing SASL IO layer\n" ); - return PR_FAILURE; + "closeLayer: error closing SASL IO layer\n" ); + return rv; } - LDAPDebug0Args( LDAP_DEBUG_CONNS, - "closeLayer: calling PR_Close to close other layers\n" ); - return PR_Close(stack); + return rv; } static PRStatus PR_CALLBACK @@ -561,22 +580,28 @@ initialize(void) /* * Push the SASL I/O layer on top of the current NSPR I/O layer of the prfd used * by the connection. + * must be called with the connection lock (c_mutex) held or in a condition in which + * no other threads are accessing conn->c_prfd */ int -sasl_io_enable(Connection *c) +sasl_io_enable(Connection *c, void *data /* UNUSED */) { PRStatus rv = PR_CallOnce(&sasl_callOnce, initialize); if (PR_SUCCESS == rv) { - PRFileDesc* layer = PR_CreateIOLayerStub(sasl_LayerID, &sasl_IoMethods); - sasl_io_private *sp = (sasl_io_private*) slapi_ch_calloc(1, sizeof(sasl_io_private)); + PRFileDesc* layer = NULL; + sasl_io_private *sp = NULL; + if ( c->c_flags & CONN_FLAG_CLOSING ) { + slapi_log_error( SLAPI_LOG_FATAL, "sasl_io_enable", + "Cannot enable SASL security on connection in CLOSING state\n"); + return PR_FAILURE; + } + layer = PR_CreateIOLayerStub(sasl_LayerID, &sasl_IoMethods); + sp = (sasl_io_private*) slapi_ch_calloc(1, sizeof(sasl_io_private)); sasl_io_init_buffers(sp); layer->secret = sp; - - PR_Lock( c->c_mutex ); sp->conn = c; rv = PR_PushIOLayer(c->c_prfd, PR_TOP_IO_LAYER, layer); - PR_Unlock( c->c_mutex ); if (rv) { LDAPDebug( LDAP_DEBUG_ANY, "sasl_io_enable: error enabling sasl io on connection %" NSPRIu64 " %d:%s\n", c->c_connid, rv, slapd_pr_strerror(rv) ); @@ -592,17 +617,17 @@ sasl_io_enable(Connection *c) /* * Remove the SASL I/O layer from the top of the current NSPR I/O layer of the prfd used * by the connection. Must either be called within the connection lock, or be - * called while the connection is not being referenced by another thread. + * called while the connection (c_prfd) is not being referenced by another thread. */ int -sasl_io_cleanup(Connection *c) +sasl_io_cleanup(Connection *c, void *data /* UNUSED */) { int ret = 0; LDAPDebug( LDAP_DEBUG_CONNS, "sasl_io_cleanup for connection %" NSPRIu64 "\n", c->c_connid, 0, 0 ); - ret = sasl_pop_IO_layer(c->c_prfd); + ret = sasl_pop_IO_layer(c->c_prfd, 0 /* do not close */); c->c_sasl_ssf = 0; diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c index 1ed9942d3..58703657e 100644 --- a/ldap/servers/slapd/saslbind.c +++ b/ldap/servers/slapd/saslbind.c @@ -800,10 +800,12 @@ void ids_sasl_check_bind(Slapi_PBlock *pb) PR_ASSERT(pb); PR_ASSERT(pb->pb_conn); + PR_Lock(pb->pb_conn->c_mutex); continuing = pb->pb_conn->c_flags & CONN_FLAG_SASL_CONTINUE; pb->pb_conn->c_flags &= ~CONN_FLAG_SASL_CONTINUE; /* reset flag */ sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn; + PR_Unlock(pb->pb_conn->c_mutex); if (sasl_conn == NULL) { send_ldap_result( pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL, "sasl library unavailable", 0, NULL ); @@ -820,6 +822,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb) * library that CRAM-MD5 is disabled, but it gives us a * different error code to SASL_NOMECH. */ + /* richm - this locks and unlocks pb->pb_conn */ if (!ids_sasl_mech_supported(pb, sasl_conn, mech)) { rc = SASL_NOMECH; goto sasl_check_result; @@ -857,30 +860,33 @@ void ids_sasl_check_bind(Slapi_PBlock *pb) * using the new mechanism. We also need to do this if the * mechanism changed in the middle of the SASL authentication * process. */ + PR_Lock(pb->pb_conn->c_mutex); if ((pb->pb_conn->c_flags & CONN_FLAG_SASL_COMPLETE) || continuing) { + Slapi_Operation *operation; + slapi_pblock_get( pb, SLAPI_OPERATION, &operation); + slapi_log_error(SLAPI_LOG_CONNS, "ids_sasl_check_bind", + "cleaning up sasl IO conn=%d op=%d complete=%d continuing=%d\n", + pb->pb_conn->c_connid, operation->o_opid, + (pb->pb_conn->c_flags & CONN_FLAG_SASL_COMPLETE), continuing); /* reset flag */ pb->pb_conn->c_flags &= ~CONN_FLAG_SASL_COMPLETE; - /* Lock the connection mutex */ - PR_Lock(pb->pb_conn->c_mutex); - /* remove any SASL I/O from the connection */ - sasl_io_cleanup(pb->pb_conn); + connection_set_io_layer_cb(pb->pb_conn, NULL, sasl_io_cleanup, NULL); /* dispose of sasl_conn and create a new sasl_conn */ sasl_dispose(&sasl_conn); ids_sasl_server_new(pb->pb_conn); sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn; - /* Unlock the connection mutex */ - PR_Unlock(pb->pb_conn->c_mutex); - if (sasl_conn == NULL) { send_ldap_result( pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL, "sasl library unavailable", 0, NULL ); + PR_Unlock(pb->pb_conn->c_mutex); return; } } + PR_Unlock(pb->pb_conn->c_mutex); rc = sasl_server_start(sasl_conn, mech, cred->bv_val, cred->bv_len, @@ -890,9 +896,6 @@ void ids_sasl_check_bind(Slapi_PBlock *pb) switch (rc) { case SASL_OK: /* complete */ - /* Set a flag to signify that sasl bind is complete */ - pb->pb_conn->c_flags |= CONN_FLAG_SASL_COMPLETE; - /* retrieve the authenticated username */ if (sasl_getprop(sasl_conn, SASL_USERNAME, (const void**)&username) != SASL_OK) { @@ -922,6 +925,35 @@ void ids_sasl_check_bind(Slapi_PBlock *pb) } slapi_pblock_set( pb, SLAPI_BIND_TARGET, slapi_ch_strdup( dn ) ); + /* see if we negotiated a security layer */ + if ((sasl_getprop(sasl_conn, SASL_SSF, + (const void**)&ssfp) == SASL_OK) && (*ssfp > 0)) { + LDAPDebug(LDAP_DEBUG_TRACE, "sasl ssf=%u\n", (unsigned)*ssfp, 0, 0); + } else { + *ssfp = 0; + } + + /* this is stuff we have to do inside the conn mutex */ + PR_Lock(pb->pb_conn->c_mutex); + /* Set a flag to signify that sasl bind is complete */ + pb->pb_conn->c_flags |= CONN_FLAG_SASL_COMPLETE; + /* note - we set this here in case there are pre-bind + plugins that want to know what the negotiated + ssf is - but this happens before we actually set + up the socket for SASL encryption - so one + consequence is that we attempt to do sasl + encryption on the connection after the pre-bind + plugin has been called, and sasl encryption fails + and the operation returns an error */ + pb->pb_conn->c_sasl_ssf = (unsigned)*ssfp; + + /* set the connection bind credentials */ + PR_snprintf(authtype, sizeof(authtype), "%s%s", SLAPD_AUTH_SASL, mech); + bind_credentials_set_nolock(pb->pb_conn, authtype, dn, + NULL, NULL, NULL, bind_target_entry); + + PR_Unlock(pb->pb_conn->c_mutex); + if (plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) != 0){ break; } @@ -942,26 +974,6 @@ void ids_sasl_check_bind(Slapi_PBlock *pb) } } - /* see if we negotiated a security layer */ - if ((sasl_getprop(sasl_conn, SASL_SSF, - (const void**)&ssfp) == SASL_OK) && (*ssfp > 0)) { - LDAPDebug(LDAP_DEBUG_TRACE, "sasl ssf=%u\n", (unsigned)*ssfp, 0, 0); - - /* Enable SASL I/O on the connection now */ - if (0 != sasl_io_enable(pb->pb_conn) ) { - send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, - "failed to enable sasl i/o", - 0, NULL); - } - /* Set the SSF in the connection */ - pb->pb_conn->c_sasl_ssf = (unsigned)*ssfp; - } - - /* set the connection bind credentials */ - PR_snprintf(authtype, sizeof(authtype), "%s%s", SLAPD_AUTH_SASL, mech); - bind_credentials_set(pb->pb_conn, authtype, dn, - NULL, NULL, NULL, bind_target_entry); - /* set the auth response control if requested */ slapi_pblock_get(pb, SLAPI_REQCONTROLS, &ctrls); if (slapi_control_present(ctrls, LDAP_CONTROL_AUTH_REQUEST, @@ -1017,11 +1029,17 @@ void ids_sasl_check_bind(Slapi_PBlock *pb) slapi_pblock_set(pb, SLAPI_BIND_RET_SASLCREDS, &bvr); } + /* see if we negotiated a security layer */ + if (*ssfp > 0) { + /* Enable SASL I/O on the connection */ + PR_Lock(pb->pb_conn->c_mutex); + connection_set_io_layer_cb(pb->pb_conn, sasl_io_enable, NULL, NULL); + PR_Unlock(pb->pb_conn->c_mutex); + } + /* send successful result */ send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL ); - /* TODO: enable sasl security layer */ - /* remove the sasl data from the pblock */ slapi_pblock_set(pb, SLAPI_BIND_RET_SASLCREDS, NULL); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 7e60ca551..c5ea51cd2 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1290,6 +1290,8 @@ typedef struct op { * represents a connection from an ldap client */ +typedef int (*Conn_IO_Layer_cb)(struct conn*, void *data); + struct Conn_Private; typedef struct Conn_private Conn_private; @@ -1345,6 +1347,11 @@ typedef struct conn { int c_sort_result_code; /* sort result put in response */ time_t c_timelimit; /* time limit for this connection */ /* PAGED_RESULTS ENDS */ + /* IO layer push/pop */ + Conn_IO_Layer_cb c_push_io_layer_cb; /* callback to push an IO layer on the conn->c_prfd */ + Conn_IO_Layer_cb c_pop_io_layer_cb; /* callback to pop an IO layer off of the conn->c_prfd */ + void *c_io_layer_cb_data; /* callback data */ + } Connection; #define CONN_FLAG_SSL 1 /* Is this connection an SSL connection or not ? * Used to direct I/O code when SSL is handled differently
0
3b76ff7a8f0498e6b4752bdb7d386e887eba7df8
389ds/389-ds-base
Issue 3527 - Fix HAProxy x390x compatibility and compiler warnings (#5801) Description: We need to support both big-endian (x390x) and little-endian (x86) architectures, it's better to dynamically adjust the byte order in our test cases based on the architecture of the system executing the tests. Define the values depending on the architecture. Fix minor compiler warnings. Related: https://github.com/389ds/389-ds-base/issues/3527 Reviewed by: @mreynolds389 (Thanks!)
commit 3b76ff7a8f0498e6b4752bdb7d386e887eba7df8 Author: Simon Pichugin <[email protected]> Date: Mon Jun 19 14:12:00 2023 -0700 Issue 3527 - Fix HAProxy x390x compatibility and compiler warnings (#5801) Description: We need to support both big-endian (x390x) and little-endian (x86) architectures, it's better to dynamically adjust the byte order in our test cases based on the architecture of the system executing the tests. Define the values depending on the architecture. Fix minor compiler warnings. Related: https://github.com/389ds/389-ds-base/issues/3527 Reviewed by: @mreynolds389 (Thanks!) diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index 10e49ed54..a30511c97 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -1187,10 +1187,8 @@ connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, int * char str_ip[INET6_ADDRSTRLEN + 1] = {0}; char str_haproxy_ip[INET6_ADDRSTRLEN + 1] = {0}; char str_haproxy_destip[INET6_ADDRSTRLEN + 1] = {0}; - PRStatus status = PR_SUCCESS; struct berval **bvals = NULL; int proxy_connection = 0; - int restrict_access = 0; pthread_mutex_lock(&(conn->c_mutex)); /* diff --git a/ldap/servers/slapd/haproxy.c b/ldap/servers/slapd/haproxy.c index 329c9659f..4f0edf5e2 100644 --- a/ldap/servers/slapd/haproxy.c +++ b/ldap/servers/slapd/haproxy.c @@ -368,7 +368,7 @@ int haproxy_receive(int fd, int *proxy_connection, PRNetAddr *pr_netaddr_from, P if (hdr_len < sizeof(hdr)) { hdr[hdr_len] = 0; } else { - slapi_log_err(SLAPI_LOG_CONNS, "haproxy_receive", "Recieved header is too long: %d\n", hdr_len); + slapi_log_err(SLAPI_LOG_CONNS, "haproxy_receive", "Recieved header is too long: %ld\n", hdr_len); rc = HAPROXY_NOT_A_HEADER; return rc; } diff --git a/test/libslapd/haproxy/parse.c b/test/libslapd/haproxy/parse.c index d6a09fe7e..afdaf63e1 100644 --- a/test/libslapd/haproxy/parse.c +++ b/test/libslapd/haproxy/parse.c @@ -26,62 +26,81 @@ test_input test_cases[] = { .expected_result = HAPROXY_HEADER_PARSED, .expected_len = 39, .expected_proxy_connection = 1, + +/* We need to support both big-endian (x390x) and little-endian (x86) architectures, + * it's better to dynamically adjust the byte order in our test cases based on + * the architecture of the system executing the tests.*/ +#ifdef __s390x__ + .expected_pr_netaddr_from = { .inet = { .family = PR_AF_INET, .ip = 0xC0A80001, .port = 0x3039 }}, + .expected_pr_netaddr_dest = { .inet = { .family = PR_AF_INET, .ip = 0xC0A80002, .port = 0x0185 }} +#else .expected_pr_netaddr_from = { .inet = { .family = PR_AF_INET, .ip = 0x0100A8C0, .port = 0x3930 }}, .expected_pr_netaddr_dest = { .inet = { .family = PR_AF_INET, .ip = 0x0200A8C0, .port = 0x8501 }} +#endif }, { .input_str = "PROXY TCP6 2001:db8::1 2001:db8::2 12345 389\r\n", .expected_result = HAPROXY_HEADER_PARSED, .expected_len = 46, .expected_proxy_connection = 1, - .expected_pr_netaddr_from = { .ipv6 = { .family = PR_AF_INET6, .ip = {0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, .port = 0x3930 }}, - .expected_pr_netaddr_dest = { .ipv6 = { .family = PR_AF_INET6, .ip = {0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, .port = 0x8501 }}, +#ifdef __s390x__ + .expected_pr_netaddr_from = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}, .port = 0x3039 }}, + .expected_pr_netaddr_dest = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}, .port = 0x0185 }} +#else + .expected_pr_netaddr_from = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}, .port = 0x3930 }}, + .expected_pr_netaddr_dest = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}, .port = 0x8501 }} +#endif }, { - .input_str = "PROXY TCP6 ::ffff:192.168.0.1 ::ffff:192.168.0.2 12345 389\r\n", - .expected_result = HAPROXY_HEADER_PARSED, - .expected_len = 54, - .expected_proxy_connection = 1, - .expected_pr_netaddr_from = { .ipv6 = { .family = PR_AF_INET6, .ip = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x01}, .port = 0x3930 }}, - .expected_pr_netaddr_dest = { .ipv6 = { .family = PR_AF_INET6, .ip = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x02}, .port = 0x8501 }}, + .input_str = "PROXY TCP6 ::ffff:192.168.0.1 ::ffff:192.168.0.2 12345 389\r\n", + .expected_result = HAPROXY_HEADER_PARSED, + .expected_len = 54, + .expected_proxy_connection = 1, +#ifdef __s390x__ + .expected_pr_netaddr_from = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x01}}}, .port = 0x3039 }}, + .expected_pr_netaddr_dest = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x02}}}, .port = 0x0185 }} +#else + .expected_pr_netaddr_from = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x01}}}, .port = 0x3930 }}, + .expected_pr_netaddr_dest = { .ipv6 = { .family = PR_AF_INET6, .ip = {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x02}}}, .port = 0x8501 }} +#endif }, - // Invalid IP + /* Invalid IP */ { .input_str = "PROXY TCP4 256.168.0.1 192.168.0.2 12345 389\r\n", .expected_result = HAPROXY_ERROR, .expected_proxy_connection = 0, }, - // Invalid port + /* Invalid port */ { .input_str = "PROXY TCP4 192.168.0.1 192.168.0.2 123456 389\r\n", .expected_result = HAPROXY_ERROR, .expected_proxy_connection = 0, }, - // One port + /* One port */ { .input_str = "PROXY TCP4 192.168.0.1 192.168.0.2 12345\r\n", .expected_result = HAPROXY_ERROR, .expected_proxy_connection = 0, }, - // No ports + /* No ports */ { .input_str = "PROXY TCP4 192.168.0.1 192.168.0.2\r\n", .expected_result = HAPROXY_ERROR, .expected_proxy_connection = 0, }, - // Empty string + /* Empty string */ { .input_str = "", .expected_result = HAPROXY_NOT_A_HEADER, .expected_proxy_connection = 0, }, - // Invalid protocol + /* Invalid protocol */ { .input_str = "PROXY TCP3 192.168.0.1 192.168.0.2 12345 389\r\n", .expected_result = HAPROXY_ERROR, .expected_proxy_connection = 0, }, - // Missing protocol + /* Missing protocol */ { .input_str = "PROXY 192.168.0.1 192.168.0.2 12345 389\r\n", .expected_result = HAPROXY_ERROR,
0
65773c3746af1153f49f6658aaf9132b69400507
389ds/389-ds-base
Issue 6340 - RFE - extract keys once (#6413) Bug Description: Keys/Certs are extracted to PEM repeatedly causing many warnings during outbound TLS authenticated replication Fix Description: After more testing, if the connection is dropped and restarted, the certpath is retrieved but re-extraction does not occur. This still triggers the warning however. To resolve this, we only warn about the tpm namespace during library initialisation. I really hope I got it right this time :( fixes: https://github.com/389ds/389-ds-base/issues/6340 Author: William Brown <[email protected]> Review by: @progier389 @vashirov
commit 65773c3746af1153f49f6658aaf9132b69400507 Author: Firstyear <[email protected]> Date: Fri Nov 29 12:51:41 2024 +1000 Issue 6340 - RFE - extract keys once (#6413) Bug Description: Keys/Certs are extracted to PEM repeatedly causing many warnings during outbound TLS authenticated replication Fix Description: After more testing, if the connection is dropped and restarted, the certpath is retrieved but re-extraction does not occur. This still triggers the warning however. To resolve this, we only warn about the tpm namespace during library initialisation. I really hope I got it right this time :( fixes: https://github.com/389ds/389-ds-base/issues/6340 Author: William Brown <[email protected]> Review by: @progier389 @vashirov diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c index ae064e339..94259efe7 100644 --- a/ldap/servers/slapd/ssl.c +++ b/ldap/servers/slapd/ssl.c @@ -966,9 +966,12 @@ check_private_certdir() if (!tmp_private) { /* tmp is not a private name space */ - slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", + if (_security_library_initialized == 0) { + /* only alert about this the first time around */ + slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", "%s is not a private namespace. pem files not exported there\n", private_mountpoint); + } return NULL; }
0
326a7ed47b5e439929159065cc0653fb769c8670
389ds/389-ds-base
Ticket 48319 Fix ldap.LDAPError exception processing Bug Description: Many lib389 modules contain the code block like this: except ldap.LDAPError as e: self.log.fatal('Failed. Error: %s' % e.message('desc')) raise ldap.LDAPError It causes problems for the debugging. For example: - ldap.LDAPError is a string object, not a method or a function; "e.message('desc'))" will cause "TypeError: 'str' object is not callable". - 'raise ldap.LDAPError' will raise a new blank ldap.LDAPError object. Fix Description: Replace e.message('desc') with str(e) Replace 'raise ldap.LDAPError' with 'raise' https://fedorahosted.org/389/ticket/48319 Review by: mreynolds (Thanks!)
commit 326a7ed47b5e439929159065cc0653fb769c8670 Author: Simon Pichugin <[email protected]> Date: Wed Oct 21 16:05:43 2015 +0200 Ticket 48319 Fix ldap.LDAPError exception processing Bug Description: Many lib389 modules contain the code block like this: except ldap.LDAPError as e: self.log.fatal('Failed. Error: %s' % e.message('desc')) raise ldap.LDAPError It causes problems for the debugging. For example: - ldap.LDAPError is a string object, not a method or a function; "e.message('desc'))" will cause "TypeError: 'str' object is not callable". - 'raise ldap.LDAPError' will raise a new blank ldap.LDAPError object. Fix Description: Replace e.message('desc') with str(e) Replace 'raise ldap.LDAPError' with 'raise' https://fedorahosted.org/389/ticket/48319 Review by: mreynolds (Thanks!) diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 2763af5e1..2119a9460 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -276,7 +276,7 @@ class DirSrv(SimpleLDAPObject): except ldap.OPERATIONS_ERROR as e: log.exception("Skipping exception: Probably Active Directory") except ldap.LDAPError as e: - log.exception("Error during initialization, error: " + e.message['desc']) + log.exception("Error during initialization, error: " + str(e)) raise def __localinit__(self): @@ -1883,7 +1883,7 @@ class DirSrv(SimpleLDAPObject): break except ldap.LDAPError as e: log.fatal('testReplication() failed to modify (%s), error (%d)' - % (suffix, e.message['desc'])) + % (suffix, str(e))) return False loop += 1 time.sleep(2) diff --git a/src/lib389/lib389/agreement.py b/src/lib389/lib389/agreement.py index 675f3caec..27db71dbb 100644 --- a/src/lib389/lib389/agreement.py +++ b/src/lib389/lib389/agreement.py @@ -550,8 +550,8 @@ class Agreement(object): self.conn.delete_s(agmts[0].dn) except ldap.LDAPError as e: self.log.error('Failed to delete agreement (%s), error: %s' % - (agmts[0].dn, e.message['desc'])) - raise ldap.LDAPError + (agmts[0].dn, str(e))) + raise else: # No agreements, error? self.log.error('No agreements found') diff --git a/src/lib389/lib389/changelog.py b/src/lib389/lib389/changelog.py index cea25e7f7..d0266268f 100644 --- a/src/lib389/lib389/changelog.py +++ b/src/lib389/lib389/changelog.py @@ -66,8 +66,8 @@ class Changelog(object): try: self.conn.delete_s(DN_CHANGELOG) except ldap.LDAPError as e: - self.log.error('Failed to delete the changelog: ' + e.message['desc']) - raise ldap.LDAPError + self.log.error('Failed to delete the changelog: ' + str(e)) + raise def setProperties(self, changelogdn=None, properties=None): if not changelogdn: diff --git a/src/lib389/lib389/replica.py b/src/lib389/lib389/replica.py index 69c32e4cc..13990bbb0 100644 --- a/src/lib389/lib389/replica.py +++ b/src/lib389/lib389/replica.py @@ -357,12 +357,12 @@ class Replica(object): self.conn.delete_s(agmt.dn) except ldap.LDAPError as e: self.log.fatal('Failed to delete replica agreement (%s), error: %s' % - (admt.dn, e.message('desc'))) - raise ldap.LDAPError + (admt.dn, str(e))) + raise except ldap.LDAPError as e: self.log.fatal('Failed to search for replication agreements under (%s), error: %s' % - (dn_replica, e.message('desc'))) - raise ldap.LDAPError + (dn_replica, str(e))) + raise def disableReplication(self, suffix=None): ''' @@ -395,14 +395,14 @@ class Replica(object): self.deleteAgreements(nsuffix) except ldap.LDAPError as e: self.log.fatal('Failed to delete replica agreements!') - raise ldap.LDAPError + raise # Delete the replica try: self.conn.delete_s(dn_replica) except ldap.LDAPError as e: - self.log.fatal('Failed to delete replica configuration (%s), error: %s' % (dn_replica, e.message('desc'))) - raise ldap.LDAPError + self.log.fatal('Failed to delete replica configuration (%s), error: %s' % (dn_replica, str(e))) + raise def enableReplication(self, suffix=None, role=None, replicaId=CONSUMER_REPLICAID, binddn=None): if not suffix:
0
9e6cefb1f37740f3ce180f272ee0653d65b878d9
389ds/389-ds-base
Security fix for CVE-2024-5953 Description: A denial of service vulnerability was found in the 389 Directory Server. This issue may allow an authenticated user to cause a server denial of service while attempting to log in with a user with a malformed hash in their password. Fix Description: To prevent buffer overflow when a bind request is processed, the bind fails if the hash size is not coherent without even attempting to process further the hashed password. References: - https://nvd.nist.gov/vuln/detail/CVE-2024-5953 - https://access.redhat.com/security/cve/CVE-2024-5953 - https://bugzilla.redhat.com/show_bug.cgi?id=2292104
commit 9e6cefb1f37740f3ce180f272ee0653d65b878d9 Author: Pierre Rogier <[email protected]> Date: Fri Jun 14 13:27:10 2024 +0200 Security fix for CVE-2024-5953 Description: A denial of service vulnerability was found in the 389 Directory Server. This issue may allow an authenticated user to cause a server denial of service while attempting to log in with a user with a malformed hash in their password. Fix Description: To prevent buffer overflow when a bind request is processed, the bind fails if the hash size is not coherent without even attempting to process further the hashed password. References: - https://nvd.nist.gov/vuln/detail/CVE-2024-5953 - https://access.redhat.com/security/cve/CVE-2024-5953 - https://bugzilla.redhat.com/show_bug.cgi?id=2292104 diff --git a/dirsrvtests/tests/suites/password/regression_test.py b/dirsrvtests/tests/suites/password/regression_test.py index 4876ff435..160d6f01d 100644 --- a/dirsrvtests/tests/suites/password/regression_test.py +++ b/dirsrvtests/tests/suites/password/regression_test.py @@ -8,11 +8,12 @@ import pytest import time import glob +import base64 from lib389._constants import PASSWORD, DN_DM, DEFAULT_SUFFIX from lib389._constants import SUFFIX, PASSWORD, DN_DM, DN_CONFIG, PLUGIN_RETRO_CHANGELOG, DEFAULT_SUFFIX, DEFAULT_CHANGELOG_DB, DEFAULT_BENAME from lib389 import Entry from lib389.topologies import topology_m1 as topo_supplier -from lib389.idm.user import UserAccounts +from lib389.idm.user import UserAccounts, UserAccount from lib389.utils import ldap, os, logging, ensure_bytes, ds_is_newer, ds_supports_new_changelog from lib389.topologies import topology_st as topo from lib389.idm.organizationalunit import OrganizationalUnits @@ -40,6 +41,13 @@ TEST_PASSWORDS += ['CNpwtest1ZZZZ', 'ZZZZZCNpwtest1', TEST_PASSWORDS2 = ( 'CN12pwtest31', 'SN3pwtest231', 'UID1pwtest123', '[email protected]', '2GN1pwtest123', 'People123') +SUPPORTED_SCHEMES = ( + "{SHA}", "{SSHA}", "{SHA256}", "{SSHA256}", + "{SHA384}", "{SSHA384}", "{SHA512}", "{SSHA512}", + "{crypt}", "{NS-MTA-MD5}", "{clear}", "{MD5}", + "{SMD5}", "{PBKDF2_SHA256}", "{PBKDF2_SHA512}", + "{GOST_YESCRYPT}", "{PBKDF2-SHA256}", "{PBKDF2-SHA512}" ) + def _check_unhashed_userpw(inst, user_dn, is_present=False): """Check if unhashed#user#password attribute is present or not in the changelog""" unhashed_pwd_attribute = 'unhashed#user#password' @@ -319,6 +327,47 @@ def test_unhashed_pw_switch(topo_supplier): # Add debugging steps(if any)... pass [email protected]("scheme", SUPPORTED_SCHEMES ) +def test_long_hashed_password(topo, create_user, scheme): + """Check that hashed password with very long value does not cause trouble + + :id: 252a1f76-114b-11ef-8a7a-482ae39447e5 + :setup: standalone Instance + :parametrized: yes + :steps: + 1. Add a test user user + 2. Set a long password with requested scheme + 3. Bind on that user using a wrong password + 4. Check that instance is still alive + 5. Remove the added user + :expectedresults: + 1. Success + 2. Success + 3. Should get ldap.INVALID_CREDENTIALS exception + 4. Success + 5. Success + """ + inst = topo.standalone + inst.simple_bind_s(DN_DM, PASSWORD) + users = UserAccounts(inst, DEFAULT_SUFFIX) + # Make sure that server is started as this test may crash it + inst.start() + # Adding Test user (It may already exists if previous test failed) + user2 = UserAccount(inst, dn='uid=test_user_1002,ou=People,dc=example,dc=com') + if not user2.exists(): + user2 = users.create_test_user(uid=1002, gid=2002) + # Setting hashed password + passwd = 'A'*4000 + hashed_passwd = scheme.encode('utf-8') + base64.b64encode(passwd.encode('utf-8')) + user2.replace('userpassword', hashed_passwd) + # Bind on that user using a wrong password + with pytest.raises(ldap.INVALID_CREDENTIALS): + conn = user2.bind(PASSWORD) + # Check that instance is still alive + assert inst.status() + # Remove the added user + user2.delete() + if __name__ == '__main__': # Run isolated diff --git a/ldap/servers/plugins/pwdstorage/md5_pwd.c b/ldap/servers/plugins/pwdstorage/md5_pwd.c index 1e2cf58e7..b9a48d5ca 100644 --- a/ldap/servers/plugins/pwdstorage/md5_pwd.c +++ b/ldap/servers/plugins/pwdstorage/md5_pwd.c @@ -37,6 +37,7 @@ md5_pw_cmp(const char *userpwd, const char *dbpwd) unsigned char hash_out[MD5_HASH_LEN]; unsigned char b2a_out[MD5_HASH_LEN * 2]; /* conservative */ SECItem binary_item; + size_t dbpwd_len = strlen(dbpwd); ctx = PK11_CreateDigestContext(SEC_OID_MD5); if (ctx == NULL) { @@ -45,6 +46,12 @@ md5_pw_cmp(const char *userpwd, const char *dbpwd) goto loser; } + if (dbpwd_len >= sizeof b2a_out) { + slapi_log_err(SLAPI_LOG_PLUGIN, MD5_SUBSYSTEM_NAME, + "The hashed password stored in the user entry is longer than any valid md5 hash"); + goto loser; + } + /* create the hash */ PK11_DigestBegin(ctx); PK11_DigestOp(ctx, (const unsigned char *)userpwd, strlen(userpwd)); @@ -57,7 +64,7 @@ md5_pw_cmp(const char *userpwd, const char *dbpwd) bver = NSSBase64_EncodeItem(NULL, (char *)b2a_out, sizeof b2a_out, &binary_item); /* bver points to b2a_out upon success */ if (bver) { - rc = slapi_ct_memcmp(bver, dbpwd, strlen(dbpwd)); + rc = slapi_ct_memcmp(bver, dbpwd, dbpwd_len); } else { slapi_log_err(SLAPI_LOG_PLUGIN, MD5_SUBSYSTEM_NAME, "Could not base64 encode hashed value for password compare"); diff --git a/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c b/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c index dcac4fcdd..82b8c9501 100644 --- a/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c +++ b/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c @@ -255,6 +255,12 @@ pbkdf2_sha256_pw_cmp(const char *userpwd, const char *dbpwd) passItem.data = (unsigned char *)userpwd; passItem.len = strlen(userpwd); + if (pwdstorage_base64_decode_len(dbpwd, dbpwd_len) > sizeof dbhash) { + /* Hashed value is too long and cannot match any value generated by pbkdf2_sha256_hash */ + slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Unable to base64 decode dbpwd value. (hashed value is too long)\n"); + return result; + } + /* 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");
0
85dcc19c351c7b950f2e789816ddc74f2181526f
389ds/389-ds-base
Ticket 49194 - Lower default ioblock timeout Bug Description: The default ioblock timeout is very high: 30 minutes. This often results in hangs and other odd symptoms. Fix Description: Reduce the time to 10 minutes, and then step it down further in the future. https://pagure.io/389-ds-base/issue/49194 Author: wibrown Review by: mreynolds (Thanks!)
commit 85dcc19c351c7b950f2e789816ddc74f2181526f Author: William Brown <[email protected]> Date: Tue Mar 28 14:20:14 2017 +1000 Ticket 49194 - Lower default ioblock timeout Bug Description: The default ioblock timeout is very high: 30 minutes. This often results in hangs and other odd symptoms. Fix Description: Reduce the time to 10 minutes, and then step it down further in the future. https://pagure.io/389-ds-base/issue/49194 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 5871bf076..ec3eddbcb 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -257,8 +257,8 @@ typedef void (*VFPV)(); /* takes undefined arguments */ #define SLAPD_DEFAULT_MAX_FILTER_NEST_LEVEL 40 /* use -1 for no limit */ #define SLAPD_DEFAULT_MAX_SASLIO_SIZE 2097152 /* 2MB in bytes. Use -1 for no limit */ #define SLAPD_DEFAULT_MAX_SASLIO_SIZE_STR "2097152" -#define SLAPD_DEFAULT_IOBLOCK_TIMEOUT 1800000 /* half hour in ms */ -#define SLAPD_DEFAULT_IOBLOCK_TIMEOUT_STR "1800000" +#define SLAPD_DEFAULT_IOBLOCK_TIMEOUT 300000 /* 5 minutes in ms */ +#define SLAPD_DEFAULT_IOBLOCK_TIMEOUT_STR "300000" #define SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT 300000 /* 5 minutes in ms */ #define SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT_STR "300000" #define SLAPD_DEFAULT_RESERVE_FDS 64
0
151a96785d59050a03c88409be6d51c627fe86c1
389ds/389-ds-base
Issue 51042 - try to use both c_rehash and openssl rehash Bug Description: It's not possible to fully migrate to openssl rehash, since it is not available everywhere. And versions of openssl which don't have rehash, also cannot check if rehash is available, or try running it at all as a fallback, because the return value is meaningless. Fix Description: Add a utility function that checks the openssl version and parses it into a LegacyVersion class. `openssl version` should work everywhere, despite being unfriendly to parse. On versions of openssl >= 1.1.0a (LegacyVersion also considers 1.1.0 > 1.1.0a), use openssl rehash, otherwise fall back to c_rehash. Fixes https://pagure.io/389-ds-base/issue/51042 Author: eschwartz
commit 151a96785d59050a03c88409be6d51c627fe86c1 Author: Eli Schwartz <[email protected]> Date: Sun Apr 26 16:18:56 2020 -0400 Issue 51042 - try to use both c_rehash and openssl rehash Bug Description: It's not possible to fully migrate to openssl rehash, since it is not available everywhere. And versions of openssl which don't have rehash, also cannot check if rehash is available, or try running it at all as a fallback, because the return value is meaningless. Fix Description: Add a utility function that checks the openssl version and parses it into a LegacyVersion class. `openssl version` should work everywhere, despite being unfriendly to parse. On versions of openssl >= 1.1.0a (LegacyVersion also considers 1.1.0 > 1.1.0a), use openssl rehash, otherwise fall back to c_rehash. Fixes https://pagure.io/389-ds-base/issue/51042 Author: eschwartz diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index cdec1465a..43d1d5b24 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -289,6 +289,8 @@ BuildArch: noarch Group: Development/Libraries Requires: krb5-workstation Requires: openssl +# This is for /usr/bin/c_rehash tool, only needed for openssl < 1.1.0 +Requires: openssl-perl Requires: iproute Requires: python%{python3_pkgversion} Requires: python%{python3_pkgversion}-distro diff --git a/src/lib389/lib389/cli_idm/client_config.py b/src/lib389/lib389/cli_idm/client_config.py index aeee7ac0d..3cd8f3e03 100644 --- a/src/lib389/lib389/cli_idm/client_config.py +++ b/src/lib389/lib389/cli_idm/client_config.py @@ -40,6 +40,8 @@ ldap_uri = {ldap_uri} ldap_tls_reqcert = demand # To use cacert dir, place *.crt files in this path then run: # /usr/bin/openssl rehash /etc/openldap/certs +# or (for older versions of openssl) +# /usr/bin/c_rehash /etc/openldap/certs ldap_tls_cacertdir = /etc/openldap/certs # Path to the cacert @@ -124,6 +126,8 @@ URI {ldap_uri} DEREF never # To use cacert dir, place *.crt files in this path then run: # /usr/bin/openssl rehash /etc/openldap/certs +# or (for older versions of openssl) +# /usr/bin/c_rehash /etc/openldap/certs TLS_CACERTDIR /etc/openldap/certs # TLS_CACERT /etc/openldap/certs/ca.crt diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py index 6d13199e5..fbf708e20 100644 --- a/src/lib389/lib389/nss_ssl.py +++ b/src/lib389/lib389/nss_ssl.py @@ -25,6 +25,13 @@ from lib389.lint import DSCERTLE0001, DSCERTLE0002 from lib389.utils import ensure_str, format_cmd_list import uuid +# Setuptools ships with 'packaging' module, let's use it from there +try: + from pkg_resources.extern.packaging.version import LegacyVersion +# Fallback to a normal 'packaging' module in case 'setuptools' is stripped +except: + from packaging.version import LegacyVersion + KEYBITS = 4096 CA_NAME = 'Self-Signed-CA' CERT_NAME = 'Server-Cert' @@ -218,6 +225,24 @@ only. assert not self._db_exists() return True + def openssl_rehash(self, certdir): + """ + Compatibly run c_rehash (on old openssl versions) or openssl rehash (on + new ones). Prefers openssl rehash, because openssl on versions where + the rehash command doesn't exist, also doesn't correctly set the return + code. Instead, we parse the output of `openssl version` and try to + figure out if we have a new enough version to unconditionally run rehash. + """ + openssl_version = check_output(['/usr/bin/openssl', 'version']).decode('utf-8').strip() + rehash_available = LegacyVersion(openssl_version.split(' ')[1]) >= LegacyVersion('1.1.0') + + if rehash_available: + cmd = ['/usr/bin/openssl', 'rehash', certdir] + else: + cmd = ['/usr/bin/c_rehash', certdir] + self.log.debug("nss cmd: %s", format_cmd_list(cmd)) + check_output(cmd, stderr=subprocess.STDOUT) + def create_rsa_ca(self, months=VALID): """ Create a self signed CA. @@ -271,9 +296,7 @@ only. certdetails = check_output(cmd, stderr=subprocess.STDOUT) with open('%s/ca.crt' % self._certdb, 'w') as f: f.write(ensure_str(certdetails)) - cmd = ['/usr/bin/openssl', 'rehash', self._certdb] - self.log.debug("nss cmd: %s", format_cmd_list(cmd)) - check_output(cmd, stderr=subprocess.STDOUT) + self.openssl_rehash(self._certdb) return True def rsa_ca_needs_renew(self): @@ -353,9 +376,7 @@ only. self.log.debug("nss cmd: %s", format_cmd_list(cmd)) check_output(cmd, stderr=subprocess.STDOUT) - cmd = ['/usr/bin/openssl', 'rehash', self._certdb] - self.log.debug("nss cmd: %s", format_cmd_list(cmd)) - check_output(cmd, stderr=subprocess.STDOUT) + self.openssl_rehash(self._certdb) # Import the new CA to our DB instead of the old CA cmd = [ @@ -611,9 +632,7 @@ only. if ca is not None: shutil.copyfile(ca, '%s/ca.crt' % self._certdb) - cmd = ['/usr/bin/openssl', 'rehash', self._certdb] - self.log.debug("nss cmd: %s", format_cmd_list(cmd)) - check_output(cmd, stderr=subprocess.STDOUT) + self.openssl_rehash(self._certdb) cmd = [ '/usr/bin/certutil', '-A',
0
5a26d5458355d175d051f02eadaca8b2e108563d
389ds/389-ds-base
Ticket 50641 - Update default aci to allows users to change their own password Bug Description: The default acis were too restrictive - we do want people to be able to self change passwords by default! Fix Description: Fix the default aci's and add tests to prove they behave as we actually expect. https://pagure.io/389-ds-base/pull-request/50641 Author: William Brown <[email protected]> Review by: vashirov
commit 5a26d5458355d175d051f02eadaca8b2e108563d Author: William Brown <[email protected]> Date: Thu Oct 10 11:47:52 2019 +1000 Ticket 50641 - Update default aci to allows users to change their own password Bug Description: The default acis were too restrictive - we do want people to be able to self change passwords by default! Fix Description: Fix the default aci's and add tests to prove they behave as we actually expect. https://pagure.io/389-ds-base/pull-request/50641 Author: William Brown <[email protected]> Review by: vashirov diff --git a/dirsrvtests/tests/suites/acl/default_aci_allows_self_write.py b/dirsrvtests/tests/suites/acl/default_aci_allows_self_write.py new file mode 100644 index 000000000..d82f5eb45 --- /dev/null +++ b/dirsrvtests/tests/suites/acl/default_aci_allows_self_write.py @@ -0,0 +1,131 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2019 William Brown <[email protected]> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + + +import pytest +from lib389.idm.user import nsUserAccounts, UserAccounts +from lib389.topologies import topology_st as topology +from lib389.utils import ds_is_older +from lib389._constants import * + + +pytestmark = pytest.mark.tier1 + +USER_PASSWORD = "some test password" +NEW_USER_PASSWORD = "some new password" + [email protected](ds_is_older('1.4.2.0'), reason="Default aci's in older versions do not support this functionality") +def test_acl_default_allow_self_write_nsuser(topology): + """ + Testing nsusers can self write and self read. This it a sanity test + so that our default entries have their aci's checked. + + :id: 4f0fb01a-36a6-430c-a2ee-ebeb036bd951 + + :setup: Standalone instance + + :steps: + 1. Testing comparison of two different users. + + :expectedresults: + 1. Should fail to compare + """ + topology.standalone.enable_tls() + nsusers = nsUserAccounts(topology.standalone, DEFAULT_SUFFIX) + # Create a user as dm. + user = nsusers.create(properties={ + 'uid': 'test_nsuser', + 'cn': 'test_nsuser', + 'displayName': 'testNsuser', + 'legalName': 'testNsuser', + 'uidNumber': '1001', + 'gidNumber': '1001', + 'homeDirectory': '/home/testnsuser', + 'userPassword': USER_PASSWORD, + }) + # Create a new con and bind as the user. + user_conn = user.bind(USER_PASSWORD) + + user_nsusers = nsUserAccounts(user_conn, DEFAULT_SUFFIX) + self_ent = user_nsusers.get(dn=user.dn) + + # Can we self read x,y,z + check = self_ent.get_attrs_vals_utf8([ + 'uid', + 'cn', + 'displayName', + 'legalName', + 'uidNumber', + 'gidNumber', + 'homeDirectory', + ]) + for k in check.values(): + # Could we read the values? + assert(isinstance(k, list)) + assert(len(k) > 0) + # Can we self change a,b,c + self_ent.ensure_attr_state({ + 'legalName': ['testNsuser_update'], + 'displayName': ['testNsuser_update'], + 'nsSshPublicKey': ['testkey'], + }) + # self change pw + self_ent.change_password(USER_PASSWORD, NEW_USER_PASSWORD) + + [email protected](ds_is_older('1.4.2.0'), reason="Default aci's in older versions do not support this functionality") +def test_acl_default_allow_self_write_user(topology): + """ + Testing users can self write and self read. This it a sanity test + so that our default entries have their aci's checked. + + :id: 4c52321b-f473-4c32-a1d5-489b138cd199 + + :setup: Standalone instance + + :steps: + 1. Testing comparison of two different users. + + :expectedresults: + 1. Should fail to compare + """ + topology.standalone.enable_tls() + users = UserAccounts(topology.standalone, DEFAULT_SUFFIX) + # Create a user as dm. + user = users.create(properties={ + 'uid': 'test_user', + 'cn': 'test_user', + 'sn': 'User', + 'uidNumber': '1002', + 'gidNumber': '1002', + 'homeDirectory': '/home/testuser', + 'userPassword': USER_PASSWORD, + }) + # Create a new con and bind as the user. + user_conn = user.bind(USER_PASSWORD) + + user_users = UserAccounts(user_conn, DEFAULT_SUFFIX) + self_ent = user_users.get(dn=user.dn) + # Can we self read x,y,z + check = self_ent.get_attrs_vals_utf8([ + 'uid', + 'cn', + 'sn', + 'uidNumber', + 'gidNumber', + 'homeDirectory', + ]) + for (a, k) in check.items(): + print(a) + # Could we read the values? + assert(isinstance(k, list)) + assert(len(k) > 0) + # Self change pw + self_ent.change_password(USER_PASSWORD, NEW_USER_PASSWORD) + + diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py index 91b37119f..62fd0ae94 100644 --- a/src/lib389/lib389/backend.py +++ b/src/lib389/lib389/backend.py @@ -421,12 +421,14 @@ class Backend(DSLdapObject): :type version: str """ - self._log.debug('Creating sample entries at version %s....' % version) - # Grab the correct sample entry config + self._log.debug('Requested sample entries at version %s....' % version) + # Grab the correct sample entry config - remember this is a function ptr. centries = get_sample_entries(version) # apply it. basedn = self.get_attr_val('nsslapd-suffix') cent = centries(self._instance, basedn) + # Now it's built, we can get the version for logging. + self._log.debug('Creating sample entries at version %s' % cent.version) cent.apply() def _validate(self, rdn, properties, basedn): diff --git a/src/lib389/lib389/configurations/__init__.py b/src/lib389/lib389/configurations/__init__.py index 94ca3aae8..da6fc35e9 100644 --- a/src/lib389/lib389/configurations/__init__.py +++ b/src/lib389/lib389/configurations/__init__.py @@ -10,15 +10,20 @@ from lib389.utils import ds_is_newer from lib389._constants import INSTALL_LATEST_CONFIG from .config_001003006 import c001003006, c001003006_sample_entries from .config_001004000 import c001004000, c001004000_sample_entries +from .config_001004002 import c001004002, c001004002_sample_entries def get_config(version): # We do this to avoid test breaking on older version that may # not expect the new default layout. - if (version == INSTALL_LATEST_CONFIG and ds_is_newer('1.4.0')): + if (version == INSTALL_LATEST_CONFIG and ds_is_newer('1.4.2')): + return c001004002 + elif (version == INSTALL_LATEST_CONFIG and ds_is_newer('1.4.0')): return c001004000 elif (version == INSTALL_LATEST_CONFIG): return c001003006 + elif (version == '001004002' and ds_is_newer('1.4.2')): + return c001004002 elif (version == '001004000' and ds_is_newer('1.4.0')): return c001004000 elif (version == '001003006'): @@ -28,7 +33,9 @@ def get_config(version): def get_sample_entries(version): if (version == INSTALL_LATEST_CONFIG): - return c001004000_sample_entries + return c001004002_sample_entries + elif (version == '001004002'): + return c001004002_sample_entries elif (version == '001004000'): return c001004000_sample_entries elif (version == '001003006'): diff --git a/src/lib389/lib389/configurations/config_001003006.py b/src/lib389/lib389/configurations/config_001003006.py index d04caaa9b..df7dba238 100644 --- a/src/lib389/lib389/configurations/config_001003006.py +++ b/src/lib389/lib389/configurations/config_001003006.py @@ -18,6 +18,7 @@ class c001003006_sample_entries(sampleentries): def __init__(self, instance, basedn): super(c001003006_sample_entries, self).__init__(instance, basedn) self.description = """Apply sample entries matching the 1.3.6 sample data and access controls.""" + self.version = "c001003006" # All the checks are done, apply them. def _apply(self): diff --git a/src/lib389/lib389/configurations/config_001004000.py b/src/lib389/lib389/configurations/config_001004000.py index dbeab1f6e..d5ee3f631 100644 --- a/src/lib389/lib389/configurations/config_001004000.py +++ b/src/lib389/lib389/configurations/config_001004000.py @@ -26,6 +26,7 @@ class c001004000_sample_entries(sampleentries): def __init__(self, instance, basedn): super(c001004000_sample_entries, self).__init__(instance, basedn) self.description = """Apply sample entries matching the 1.4.0 sample data and access controls""" + self.version = "c001004000" # All checks done, apply! def _apply(self): diff --git a/src/lib389/lib389/configurations/config_001004002.py b/src/lib389/lib389/configurations/config_001004002.py new file mode 100644 index 000000000..4d031e744 --- /dev/null +++ b/src/lib389/lib389/configurations/config_001004002.py @@ -0,0 +1,140 @@ +# --- 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 --- + +from .config import baseconfig, configoperation +from .sample import sampleentries, create_base_domain + +from lib389.idm.organizationalunit import OrganizationalUnits +from lib389.idm.group import Groups +from lib389.idm.posixgroup import PosixGroups +from lib389.idm.user import nsUserAccounts +from lib389.idm.services import ServiceAccounts + +from lib389.idm.nscontainer import nsHiddenContainers + +class c001004002_sample_entries(sampleentries): + def __init__(self, instance, basedn): + super(c001004002_sample_entries, self).__init__(instance, basedn) + self.description = """Apply sample entries matching the 1.4.2 sample data and access controls""" + self.version = "c001004002" + + # All checks done, apply! + def _apply(self): + # Create the base domain object + domain = create_base_domain(self._instance, self._basedn) + domain.add('aci', [ + # Allow reading the base domain object + '(targetattr="dc || description || objectClass")(targetfilter="(objectClass=domain)")(version 3.0; acl "Enable anyone domain read"; allow (read, search, compare)(userdn="ldap:///anyone");)', + # Allow reading the ou + '(targetattr="ou || objectClass")(targetfilter="(objectClass=organizationalUnit)")(version 3.0; acl "Enable anyone ou read"; allow (read, search, compare)(userdn="ldap:///anyone");)' + ]) + + # Create the 389 service container + # This could also move to be part of core later .... + hidden_containers = nsHiddenContainers(self._instance, self._basedn) + ns389container = hidden_containers.create(properties={ + 'cn': '389_ds_system' + }) + + # Create our ous. + ous = OrganizationalUnits(self._instance, self._basedn) + ous.create(properties = { + 'ou': 'groups', + 'aci': [ + # Allow anon partial read + '(targetattr="cn || member || gidNumber || nsUniqueId || description || objectClass")(targetfilter="(objectClass=groupOfNames)")(version 3.0; acl "Enable anyone group read"; allow (read, search, compare)(userdn="ldap:///anyone");)', + # Allow group_modify to modify but not create groups + '(targetattr="member")(targetfilter="(objectClass=groupOfNames)")(version 3.0; acl "Enable group_modify to alter members"; allow (write)(groupdn="ldap:///cn=group_modify,ou=permissions,{BASEDN}");)'.format(BASEDN=self._basedn), + # Allow group_admin to fully manage groups (posix or not). + '(targetattr="cn || member || gidNumber || description || objectClass")(targetfilter="(objectClass=groupOfNames)")(version 3.0; acl "Enable group_admin to manage groups"; allow (write, add, delete)(groupdn="ldap:///cn=group_admin,ou=permissions,{BASEDN}");)'.format(BASEDN=self._basedn), + ] + }) + + ous.create(properties = { + 'ou': 'people', + 'aci': [ + # allow anon partial read. + '(targetattr="objectClass || description || nsUniqueId || uid || displayName || loginShell || uidNumber || gidNumber || gecos || homeDirectory || cn || memberOf || mail || nsSshPublicKey || nsAccountLock || userCertificate")(targetfilter="(objectClass=posixaccount)")(version 3.0; acl "Enable anyone user read"; allow (read, search, compare)(userdn="ldap:///anyone");)', + # allow self partial mod + '(targetattr="displayName || legalName || userPassword || nsSshPublicKey")(version 3.0; acl "Enable self partial modify"; allow (write)(userdn="ldap:///self");)', + # Allow self full read + '(targetattr="legalName || telephoneNumber || mobile || sn")(targetfilter="(|(objectClass=nsPerson)(objectClass=inetOrgPerson))")(version 3.0; acl "Enable self legalname read"; allow (read, search, compare)(userdn="ldap:///self");)', + # Allow reading legal name + '(targetattr="legalName || telephoneNumber")(targetfilter="(objectClass=nsPerson)")(version 3.0; acl "Enable user legalname read"; allow (read, search, compare)(groupdn="ldap:///cn=user_private_read,ou=permissions,{BASEDN}");)'.format(BASEDN=self._basedn), + # These below need READ so they can read userPassword and legalName + # Allow user admin create mod + '(targetattr="uid || description || displayName || loginShell || uidNumber || gidNumber || gecos || homeDirectory || cn || memberOf || mail || legalName || telephoneNumber || mobile")(targetfilter="(&(objectClass=nsPerson)(objectClass=nsAccount))")(version 3.0; acl "Enable user admin create"; allow (write, add, delete, read)(groupdn="ldap:///cn=user_admin,ou=permissions,{BASEDN}");)'.format(BASEDN=self._basedn), + # Allow user mod permission to mod only + '(targetattr="uid || description || displayName || loginShell || uidNumber || gidNumber || gecos || homeDirectory || cn || memberOf || mail || legalName || telephoneNumber || mobile")(targetfilter="(&(objectClass=nsPerson)(objectClass=nsAccount))")(version 3.0; acl "Enable user modify to change users"; allow (write, read)(groupdn="ldap:///cn=user_modify,ou=permissions,{BASEDN}");)'.format(BASEDN=self._basedn), + # Allow user_pw_admin to nsaccountlock and password + '(targetattr="userPassword || nsAccountLock || userCertificate || nsSshPublicKey")(targetfilter="(objectClass=nsAccount)")(version 3.0; acl "Enable user password reset"; allow (write, read)(groupdn="ldap:///cn=user_passwd_reset,ou=permissions,{BASEDN}");)'.format(BASEDN=self._basedn), + ] + }) + + ous.create(properties = { + 'ou': 'permissions', + }) + + ous.create(properties = { + 'ou': 'services', + 'aci': [ + # Minimal service read + '(targetattr="objectClass || description || nsUniqueId || cn || memberOf || nsAccountLock ")(targetfilter="(objectClass=netscapeServer)")(version 3.0; acl "Enable anyone service account read"; allow (read, search, compare)(userdn="ldap:///anyone");)', + ] + }) + + # Create the demo user + users = nsUserAccounts(self._instance, self._basedn) + users.create(properties={ + 'uid': 'demo_user', + 'cn': 'Demo User', + 'displayName': 'Demo User', + 'legalName': 'Demo User Name', + 'uidNumber': '99998', + 'gidNumber': '99998', + 'homeDirectory': '/var/empty', + 'loginShell': '/bin/false', + 'nsAccountlock': 'true' + }) + + # Create the demo group + groups = PosixGroups(self._instance, self._basedn) + groups.create(properties={ + 'cn' : 'demo_group', + 'gidNumber': '99999' + }) + + # Create the permission groups required for the acis + permissions = Groups(self._instance, self._basedn, rdn='ou=permissions') + permissions.create(properties={ + 'cn': 'group_admin', + }) + permissions.create(properties={ + 'cn': 'group_modify', + }) + permissions.create(properties={ + 'cn': 'user_admin', + }) + permissions.create(properties={ + 'cn': 'user_modify', + }) + permissions.create(properties={ + 'cn': 'user_passwd_reset', + }) + permissions.create(properties={ + 'cn': 'user_private_read', + }) + + +class c001004002(baseconfig): + def __init__(self, instance): + super(c001004002, self).__init__(instance) + self._operations = [ + # For now this is an empty place holder - likely this + # will become part of core server. + ] diff --git a/src/lib389/lib389/configurations/sample.py b/src/lib389/lib389/configurations/sample.py index f30b8d693..dbc4d8bdc 100644 --- a/src/lib389/lib389/configurations/sample.py +++ b/src/lib389/lib389/configurations/sample.py @@ -20,6 +20,7 @@ class sampleentries(object): self._instance = instance self._basedn = ensure_str(basedn) self.description = None + self.version = None def apply(self): self._apply()
0
dd95d476079904fcb5b3274cd5af8cd3e7728912
389ds/389-ds-base
Fixed BUILD_MODE flag to look in correct file
commit dd95d476079904fcb5b3274cd5af8cd3e7728912 Author: Nathan Kinder <[email protected]> Date: Mon Mar 21 19:47:54 2005 +0000 Fixed BUILD_MODE flag to look in correct file diff --git a/nsdefs.mk b/nsdefs.mk index 96f627f88..8c9668c3c 100644 --- a/nsdefs.mk +++ b/nsdefs.mk @@ -192,7 +192,7 @@ else NSPR_DIR=nspr endif NSPR_BASENAME=libnspr21 -PRODUCT="Brandx Directory Server" +PRODUCT="Red Hat Directory Server" PRODUCT_IS_DIRECTORY_SERVER=1 INSTANCE_NAME_PREFIX="Directory Server" DIR=slapd
0
840161b8e2ae8d53a7792a35b34d792b0d860f4e
389ds/389-ds-base
Issue 6112 - RFE - add new operation note for MFA authentications Add a new operation note to indicate that a MFA plugin performed the BIND. This implies that the plugin must set the note itself as there is no other way to detect this: slapi_pblock_set_flag_operation_notes(pb, SLAPI_OP_NOTE_MFA_AUTH); The purpose for this is for auditing needs Fixes: https://github.com/389ds/389-ds-base/issues/6112 Reviewed by: spichugi(Thanks!)
commit 840161b8e2ae8d53a7792a35b34d792b0d860f4e Author: Mark Reynolds <[email protected]> Date: Fri Mar 1 11:28:17 2024 -0500 Issue 6112 - RFE - add new operation note for MFA authentications Add a new operation note to indicate that a MFA plugin performed the BIND. This implies that the plugin must set the note itself as there is no other way to detect this: slapi_pblock_set_flag_operation_notes(pb, SLAPI_OP_NOTE_MFA_AUTH); The purpose for this is for auditing needs Fixes: https://github.com/389ds/389-ds-base/issues/6112 Reviewed by: spichugi(Thanks!) diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl index 4fb11890e..0bb3ef304 100755 --- a/ldap/admin/src/logconv.pl +++ b/ldap/admin/src/logconv.pl @@ -2,11 +2,11 @@ # # BEGIN COPYRIGHT BLOCK # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. -# Copyright (C) 2022 Red Hat, Inc. +# Copyright (C) 2010-2024 Red Hat, Inc. # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # END COPYRIGHT BLOCK # @@ -218,6 +218,7 @@ my $sslClientFailedCount = 0; my $objectclassTopCount= 0; my $pagedSearchCount = 0; my $invalidFilterCount = 0; +my $mfaCount = 0; my $bindCount = 0; my $filterCount = 0; my $baseCount = 0; @@ -408,7 +409,7 @@ sub statusreport { ########################################## # # # Parse Access Logs # -# # +# # ########################################## if ($files[$#files] =~ m/access.rotationinfo/) { @@ -710,7 +711,7 @@ if($endTime){ # # Get the start time in seconds -# +# my $logStart = $start; my $startTotal = convertTimeToNanoseconds($logStart); @@ -891,6 +892,7 @@ $etimeAvg = $totalEtime / $etimeCount; print sprintf "Average etime (elapsed time): %.9f\n", $etimeAvg; print "\n"; +print "Multi-factor Authentications: $mfaCount\n"; print "Proxied Auth Operations: $proxiedAuthCount\n"; print "Persistent Searches: $persistentSrchCount\n"; print "Internal Operations: $internalOpCount\n"; @@ -1763,7 +1765,7 @@ if ($usage =~ /j/i || $verb eq "yes"){ $recCount++; } if ($objectclassTopCount > ($srchCount *.25)){ - print "\n $recCount. You have a high number of searches that query the entire search base. Although this is not necessarily bad, it could be resource intensive if the search base contains many entries.\n"; + print "\n $recCount. You have a high number of searches that query the entire search base. Although this is not necessarily bad, it could be resource intensive if the search base contains many entries.\n"; $recCount++; } if ($recCount == 1){ @@ -1797,7 +1799,7 @@ sub displayUsage { print " -h, --help help/usage\n"; print " -d, --rootDN <Directory Managers DN> default is \"cn=directory manager\"\n"; - print " -D, --data <Location for temporary data files> default is \"/tmp\"\n"; + print " -D, --data <Location for temporary data files> default is \"/tmp\"\n"; print " -s, --sizeLimit <Number of results to return per catagory> default is 20\n"; print " -X, --excludeIP <IP address to exclude from connection stats> E.g. Load balancers\n"; print " -v, --version show version of tool\n"; @@ -1805,8 +1807,8 @@ sub displayUsage { print " E.g. \"[28/Mar/2002:13:14:22 -0800]\"\n"; print " -E, --endTime <time to stop analyzing logfile>\n"; print " E.g. \"[28/Mar/2002:13:24:62 -0800]\"\n"; - print " -m, --reportFileSecs <CSV output file - per second stats>\n"; - print " -M, --reportFileMins <CSV output file - per minute stats>\n"; + print " -m, --reportFileSecs <CSV output file - per second stats>\n"; + print " -M, --reportFileMins <CSV output file - per minute stats>\n"; print " -B, --bind <ALL | ANONYMOUS | \"Actual Bind DN\">\n"; print " -T, --minEtime <minimum etime to report unindexed searches>\n"; print " -V, --verbose <enable verbose output - includes all stats listed below>\n"; @@ -2293,6 +2295,9 @@ sub parseLineNormal if (m/ RESULT err=/ && m/ notes=[A-Z,]*P/){ $pagedSearchCount++; } + if (m/ RESULT err=/ && m/ notes=[A-Z,]*M/){ + $mfaCount++; + } if (m/ RESULT err=/ && m/ notes=[A-Z,]*F/){ $invalidFilterCount++; $con = ""; @@ -2323,7 +2328,7 @@ sub parseLineNormal if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++; $isVlvNotes="1";} } if($isVlvNotes == 0){ - # We don't want to record vlv unindexed searches for our regular "bad" + # We don't want to record vlv unindexed searches for our regular "bad" # unindexed search stat, as VLV unindexed searches aren't that bad $unindexedSrchCountNotesA++; if($reportStats){ inc_stats('notesA',$s_stats,$m_stats); } @@ -2350,7 +2355,7 @@ sub parseLineNormal if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++; $isVlvNotes="1";} } if($isVlvNotes == 0){ - # We don't want to record vlv unindexed searches for our regular "bad" + # We don't want to record vlv unindexed searches for our regular "bad" # unindexed search stat, as VLV unindexed searches aren't that bad $unindexedSrchCountNotesU++; if($reportStats){ inc_stats('notesU',$s_stats,$m_stats); } @@ -2608,7 +2613,7 @@ sub parseLineNormal if ($errcode ne "0"){ $errorCount++;} else { $successCount++;} } - if ($_ =~ /etime= *([0-9.]+)/ ) { + if ($_ =~ /etime= *([0-9.]+)/ ) { my $etime_val = $1; $totalEtime = $totalEtime + $1; $etimeCount++; @@ -2630,10 +2635,10 @@ sub parseLineNormal if ($reportStats){ inc_stats_val('optime',$optime_val,$s_stats,$m_stats); } } if ($_ =~ / tag=101 / || $_ =~ / tag=111 / || $_ =~ / tag=100 / || $_ =~ / tag=115 /){ - if ($_ =~ / nentries= *([0-9]+)/i ){ + if ($_ =~ / nentries= *([0-9]+)/i ){ my $nents = $1; - if ($usage =~ /n/i || $verb eq "yes"){ - $hashes->{nentries}->{$nents}++; + if ($usage =~ /n/i || $verb eq "yes"){ + $hashes->{nentries}->{$nents}++; } } } @@ -2643,7 +2648,7 @@ sub parseLineNormal if (m/ EXT oid=/){ $extopCount++; my $oid; - if ($_ =~ /oid=\" *([0-9\.]+)/i ){ + if ($_ =~ /oid=\" *([0-9\.]+)/i ){ $oid = $1; if ($usage =~ /x/i || $verb eq "yes"){$hashes->{oid}->{$oid}++; } } @@ -2944,7 +2949,7 @@ printClients my $IPcount = "1"; foreach my $ip ( keys %connList ){ # Loop over all the IP addresses - foreach my $bc (@bindConns){ # Loop over each bind conn number and compare it + foreach my $bc (@bindConns){ # Loop over each bind conn number and compare it if($connList{$ip} =~ / $bc /){ print(" [$IPcount] $ip\n"); $IPcount++; diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index d061a65bc..1621192dc 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -3973,6 +3973,7 @@ slapi_log_security(Slapi_PBlock *pb, const char *event_type, const char *msg) int isroot = 0; int rc = 0; uint64_t conn_id = 0; + uint32_t operation_notes = 0; int32_t op_id = 0; json_object *log_json = NULL; @@ -3997,6 +3998,8 @@ slapi_log_security(Slapi_PBlock *pb, const char *event_type, const char *msg) client_ip = pb_conn->c_ipaddr; server_ip = pb_conn->c_serveripaddr; ldap_version = pb_conn->c_ldapversion; + operation_notes = slapi_pblock_get_operation_notes(pb); + if (saslmech) { external_bind = !strcasecmp(saslmech, LDAP_SASL_EXTERNAL); } @@ -4063,7 +4066,8 @@ slapi_log_security(Slapi_PBlock *pb, const char *event_type, const char *msg) break; default: /* Simple auth */ - PR_snprintf(method_and_mech, sizeof(method_and_mech), "SIMPLE"); + PR_snprintf(method_and_mech, sizeof(method_and_mech), "%s", + (operation_notes & SLAPI_OP_NOTE_MFA_AUTH) ? "SIMPLE/MFA" : "SIMPLE"); } /* Get the time */ diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c index 56ba6db8b..97af5a2b8 100644 --- a/ldap/servers/slapd/result.c +++ b/ldap/servers/slapd/result.c @@ -1946,11 +1946,11 @@ static struct slapi_note_map notemap[] = { {SLAPI_OP_NOTE_SIMPLEPAGED, "P", "Paged Search"}, {SLAPI_OP_NOTE_FULL_UNINDEXED, "A", "Fully Unindexed Filter"}, {SLAPI_OP_NOTE_FILTER_INVALID, "F", "Filter Element Missing From Schema"}, + {SLAPI_OP_NOTE_MFA_AUTH, "M", "Multi-factor Authentication"}, }; #define SLAPI_NOTEMAP_COUNT (sizeof(notemap) / sizeof(struct slapi_note_map)) - /* * fill buf with a string representation of the bits present in notes. * diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 4853e143b..12bc1f0aa 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -7323,6 +7323,7 @@ typedef enum _slapi_op_note_t { SLAPI_OP_NOTE_SIMPLEPAGED = 0x02, SLAPI_OP_NOTE_FULL_UNINDEXED = 0x04, SLAPI_OP_NOTE_FILTER_INVALID = 0x08, + SLAPI_OP_NOTE_MFA_AUTH = 0x10, } slapi_op_note_t;
0
fa2361ffc54719b14f2e0c304ee15940df229028
389ds/389-ds-base
Ticket 47845 - Add backup/restore/fixup tombstone tasks to lib389 Description: Add backup/restore/fixup tombstone tasks to lib389. Also improved the task time stamp value to be always unique. https://fedorahosted.org/389/ticket/47845 Reviewed by: tbordaz(Thanks!!)
commit fa2361ffc54719b14f2e0c304ee15940df229028 Author: Mark Reynolds <[email protected]> Date: Thu Jul 10 09:36:17 2014 -0400 Ticket 47845 - Add backup/restore/fixup tombstone tasks to lib389 Description: Add backup/restore/fixup tombstone tasks to lib389. Also improved the task time stamp value to be always unique. https://fedorahosted.org/389/ticket/47845 Reviewed by: tbordaz(Thanks!!) diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py index 6fe9af926..c259ca887 100644 --- a/src/lib389/lib389/_constants.py +++ b/src/lib389/lib389/_constants.py @@ -93,11 +93,14 @@ DN_CHANGELOG = "cn=changelog5,%s" % DN_CONFIG DN_LDBM = "cn=ldbm database,%s" % DN_PLUGIN DN_CHAIN = "cn=chaining database,%s" % DN_PLUGIN -DN_TASKS = "cn=tasks,%s" % DN_CONFIG -DN_INDEX_TASK = "cn=index,%s" % DN_TASKS -DN_MBO_TASK = "cn=memberOf task,%s" % DN_TASKS -DN_EXPORT_TASK = "cn=export,%s" % DN_TASKS -DN_IMPORT_TASK = "cn=import,%s" % DN_TASKS +DN_TASKS = "cn=tasks,%s" % DN_CONFIG +DN_INDEX_TASK = "cn=index,%s" % DN_TASKS +DN_EXPORT_TASK = "cn=export,%s" % DN_TASKS +DN_IMPORT_TASK = "cn=import,%s" % DN_TASKS +DN_BACKUP_TASK = "cn=backup,%s" % DN_TASKS +DN_RESTORE_TASK = "cn=restore,%s" % DN_TASKS +DN_MBO_TASK = "cn=memberOf task,%s" % DN_TASKS +DN_TOMB_FIXUP_TASK = "cn=fixup tombstones,%s" % DN_TASKS RDN_REPLICA = "cn=replica" diff --git a/src/lib389/lib389/_entry.py b/src/lib389/lib389/_entry.py index f993a3676..b97b6e798 100644 --- a/src/lib389/lib389/_entry.py +++ b/src/lib389/lib389/_entry.py @@ -118,14 +118,16 @@ class Entry(object): return val.lower() in [x.lower() for x in self.data.get(name)] def setValue(self, name, *value): - """Value passed in may be a single value, several values, or a single sequence. + """ + Value passed in may be a single value, several values, or a single sequence. For example: ent.setValue('name', 'value') ent.setValue('name', 'value1', 'value2', ..., 'valueN') ent.setValue('name', ['value1', 'value2', ..., 'valueN']) ent.setValue('name', ('value1', 'value2', ..., 'valueN')) Since *value is a tuple, we may have to extract a list or tuple from that - tuple as in the last two examples above""" + tuple as in the last two examples above + """ if isinstance(value[0], list) or isinstance(value[0], tuple): self.data[name] = value[0] else: diff --git a/src/lib389/lib389/replica.py b/src/lib389/lib389/replica.py index 00d765f2f..5357207a8 100644 --- a/src/lib389/lib389/replica.py +++ b/src/lib389/lib389/replica.py @@ -173,7 +173,7 @@ class Replica(object): InvalidArgumentError: If missing mandatory parameter ''' - + # No properties provided if len(properties) == 0: return @@ -198,10 +198,10 @@ class Replica(object): # that is fine, now set the values for prop in properties: val = rawProperty(prop) - + # for Entry update it is a replace replica_entry.update({REPLICA_PROPNAME_TO_ATTRNAME[val]: properties[prop]}) - + return # If it provides the suffix or the replicaDN, replica.list will @@ -213,7 +213,7 @@ class Replica(object): else: raise ValueError("invalid suffix: %s" % suffix) - + # build the MODS mods = [] for prop in properties: diff --git a/src/lib389/lib389/tasks.py b/src/lib389/lib389/tasks.py index f61f93570..819f7c558 100644 --- a/src/lib389/lib389/tasks.py +++ b/src/lib389/lib389/tasks.py @@ -8,19 +8,23 @@ from lib389._constants import * from lib389.properties import * import ldap import time +import os.path class Tasks(object): proxied_methods = 'search_s getEntry'.split() + def __init__(self, conn): """@param conn - a DirSrv instance""" self.conn = conn self.log = conn.log + def __getattr__(self, name): if name in Tasks.proxied_methods: return DirSrv.__getattr__(self.conn, name) + def checkTask(self, entry, dowait=False): '''check task status - task is complete when the nsTaskExitCode attr is set return a 2 tuple (true/false,code) first is false if task is running, true if @@ -44,6 +48,7 @@ class Tasks(object): break return (done, exitCode) + def importLDIF(self, suffix=None, benamebase=None, input_file=None, args=None): ''' Import from a LDIF format a given 'suffix' (or 'benamebase' that stores that suffix). @@ -68,12 +73,15 @@ class Tasks(object): # Checking the parameters if not benamebase and not suffix: raise ValueError("Specify either bename or suffix") - + if not input_file: raise ValueError("input_file is mandatory") - + + if not os.path.exists(input_file): + raise ValueError("Import file (%s) does not exist" % input_file) + # Prepare the task entry - cn = "import" + str(int(time.time())) + cn = "import_" + time.strftime("%m%d%Y_%H%M%S", time.localtime()) dn = "cn=%s,%s" % (cn, DN_IMPORT_TASK) entry = Entry(dn) entry.setValues('objectclass', 'top', 'extensibleObject') @@ -103,6 +111,7 @@ class Tasks(object): cn, input_file)) return exitCode + def exportLDIF(self, suffix=None, benamebase=None, output_file=None, args=None): ''' Export in a LDIF format a given 'suffix' (or 'benamebase' that stores that suffix). @@ -134,7 +143,7 @@ class Tasks(object): raise ValueError("output_file is mandatory") # Prepare the task entry - cn = "export%d" % time.time() + cn = "export_" + time.strftime("%m%d%Y_%H%M%S", time.localtime()) dn = "cn=%s,%s" % (cn, DN_EXPORT_TASK) entry = Entry(dn) entry.update({ @@ -166,6 +175,111 @@ class Tasks(object): return exitCode + def db2bak(self, backup_dir=None, args=None): + ''' + Perform a backup by creating a db2bak task + + @param backup_dir - backup directory + @param args - is a dictionary that contains modifier of the task + wait: True/[False] - If True, waits for the completion of the task before to return + + @return exit code + + @raise ValueError: if bename name does not exist + ''' + + # Checking the parameters + if not backup_dir: + raise ValueError("You must specify a backup directory.") + if not os.path.exists(backup_dir): + raise ValueError("Backup file (%s) does not exist" % backup_dir) + + # build the task entry + cn = "backup_" + time.strftime("%m%d%Y_%H%M%S", time.localtime()) + dn = "cn=%s,%s" % (cn, DN_BACKUP_TASK) + entry = Entry(dn) + entry.update({ + 'objectclass': ['top', 'extensibleObject'], + 'cn': cn, + 'nsArchiveDir': backup_dir, + 'nsDatabaseType': 'ldbm database' + }) + + # start the task and possibly wait for task completion + try: + self.conn.add_s(entry) + except ldap.ALREADY_EXISTS: + self.log.error("Fail to add the backup task (%s)" % dn) + return -1 + + exitCode = 0 + if args and args.get(TASK_WAIT, False): + (done, exitCode) = self.conn.tasks.checkTask(entry, True) + + if exitCode: + self.log.error("Error: backup task %s exited with %d" % (cn, exitCode)) + else: + self.log.info("Backup task %s completed successfully" % (cn)) + return exitCode + + + def bak2db(self, bename=None, backup_dir=None, args=None): + ''' + Restore a backup by creating a bak2db task + + @param bename - 'commonname'/'cn' of the backend (e.g. 'userRoot') + @param backup_dir - backup directory + @param args - is a dictionary that contains modifier of the task + wait: True/[False] - If True, waits for the completion of the task before to return + + @return exit code + + @raise ValueError: if bename name does not exist + ''' + + # Checking the parameters + if not backup_dir: + raise ValueError("You must specify a backup directory") + if not os.path.exists(backup_dir): + raise ValueError("Backup file (%s) does not exist" % backup_dir) + + # If a backend name was provided then verify it + if bename: + ents = self.conn.mappingtree.list(bename=bename) + if len(ents) != 1: + raise ValueError("invalid backend name: %s" % bename) + + # build the task entry + cn = "restore_" + time.strftime("%m%d%Y_%H%M%S", time.localtime()) + dn = "cn=%s,%s" % (cn, DN_RESTORE_TASK) + entry = Entry(dn) + entry.update({ + 'objectclass': ['top', 'extensibleObject'], + 'cn': cn, + 'nsArchiveDir': backup_dir, + 'nsDatabaseType': 'ldbm database' + }) + if bename: + entry.update({'nsInstance': bename}) + + # start the task and possibly wait for task completion + try: + self.conn.add_s(entry) + except ldap.ALREADY_EXISTS: + self.log.error("Fail to add the backup task (%s)" % dn) + return -1 + + exitCode = 0 + if args and args.get(TASK_WAIT, False): + (done, exitCode) = self.conn.tasks.checkTask(entry, True) + + if exitCode: + self.log.error("Error: restore task %s exited with %d" % (cn, exitCode)) + else: + self.log.info("Restore task %s completed successfully" % (cn)) + return exitCode + + def reindex(self, suffix=None, benamebase=None, attrname=None, args=None): ''' Reindex a 'suffix' (or 'benamebase' that stores that suffix) for a given 'attrname'. @@ -201,7 +315,7 @@ class Tasks(object): suffix = ents[0].getValue(attr_suffix) entries_backend = self.conn.backend.list(suffix=suffix) - cn = "index_%s_%d" % (attrname, time.time()) + cn = "index_%s_%s" % (attrname, time.strftime("%m%d%Y_%H%M%S", time.localtime())) dn = "cn=%s,%s" % (cn, DN_INDEX_TASK) entry = Entry(dn) entry.update({ @@ -231,6 +345,7 @@ class Tasks(object): cn)) return exitCode + def fixupMemberOf(self, suffix=None, benamebase=None, filt=None, args=None): ''' Trigger a fixup task on 'suffix' (or 'benamebase' that stores that suffix) related to the @@ -268,7 +383,7 @@ class Tasks(object): suffix = ents[0].getValue(attr) - cn = "fixupmemberof%d" % time.time() + cn = "fixupmemberof_" + time.strftime("%m%d%Y_%H%M%S", time.localtime()) dn = "cn=%s,%s" % (cn, DN_MBO_TASK) entry = Entry(dn) entry.setValues('objectclass', 'top', 'extensibleObject') @@ -278,11 +393,15 @@ class Tasks(object): entry.setValues('filter', filt) # start the task and possibly wait for task completion - self.conn.add_s(entry) + try: + self.conn.add_s(entry) + except ldap.ALREADY_EXISTS: + self.log.error("Fail to add the memberOf fixup task") + return -1 + exitCode = 0 if args and args.get(TASK_WAIT, False): (done, exitCode) = self.conn.tasks.checkTask(entry, True) - if exitCode: self.log.error("Error: fixupMemberOf task %s for basedn %s exited with %d" % (cn, suffix, exitCode)) @@ -290,3 +409,49 @@ class Tasks(object): self.log.info("fixupMemberOf task %s for basedn %s completed successfully" % (cn, suffix)) return exitCode + + def fixupTombstones(self, bename=None, args=None): + ''' + Trigger a tombstone fixup task on the specified backend + + @param bename - 'commonname'/'cn' of the backend (e.g. 'userRoot'). Optional. + @param args - is a dictionary that contains modifier of the task + wait: True/[False] - If True, waits for the completion of the task before to return + + @return exit code + + @raise ValueError: if bename name does not exist + ''' + + if not bename: + bename = DEFAULT_BENAME + + # Verify the backend name + if bename: + ents = self.conn.mappingtree.list(bename=bename) + if len(ents) != 1: + raise ValueError("invalid backend name: %s" % bename) + + cn = "fixupTombstone_" + time.strftime("%m%d%Y_%H%M%S", time.localtime()) + dn = "cn=%s,%s" % (cn, DN_TOMB_FIXUP_TASK) + entry = Entry(dn) + entry.setValues('objectclass', 'top', 'extensibleObject') + entry.setValues('cn', cn) + entry.setValues('backend', bename) + + # start the task and possibly wait for task completion + try: + self.conn.add_s(entry) + except ldap.ALREADY_EXISTS: + self.log.error("Fail to add the fixup tombstone task") + return -1 + + exitCode = 0 + if args and args.get(TASK_WAIT, False): + (done, exitCode) = self.conn.tasks.checkTask(entry, True) + + if exitCode: + self.log.error("Error: tombstone fixup task %s for backend %s exited with %d" % (cn, bename, exitCode)) + else: + self.log.info("tombstone fixup task %s for backend %s completed successfully" % (cn, bename)) + return exitCode
0
463d6b754dbafd79bae5bd66ce80605dd5b128f5
389ds/389-ds-base
Ticket 50709: Several memory leaks reported by Valgrind for 389-ds 1.3.9.1-10 Description of the problem: When evaluating an ACI with 'ip' subject, it adds a PRNetAddr to the subject property list. When the list is free (acl__done_aclpb) the property is not freed. Description of the fix: Add the property to the pblock (SLAPI_CONN_CLIENTNETADDR_ACLIP) so that it the property is freed with acl pblock. https://pagure.io/389-ds-base/issue/50709 Reviewed by: Mark Reynolds, William Brown, Ludwig Krispenz
commit 463d6b754dbafd79bae5bd66ce80605dd5b128f5 Author: Thierry Bordaz <[email protected]> Date: Fri Nov 8 18:16:06 2019 +0100 Ticket 50709: Several memory leaks reported by Valgrind for 389-ds 1.3.9.1-10 Description of the problem: When evaluating an ACI with 'ip' subject, it adds a PRNetAddr to the subject property list. When the list is free (acl__done_aclpb) the property is not freed. Description of the fix: Add the property to the pblock (SLAPI_CONN_CLIENTNETADDR_ACLIP) so that it the property is freed with acl pblock. https://pagure.io/389-ds-base/issue/50709 Reviewed by: Mark Reynolds, William Brown, Ludwig Krispenz diff --git a/ldap/servers/plugins/acl/acllas.c b/ldap/servers/plugins/acl/acllas.c index 3950fd405..dd41d41bd 100644 --- a/ldap/servers/plugins/acl/acllas.c +++ b/ldap/servers/plugins/acl/acllas.c @@ -251,6 +251,7 @@ DS_LASIpGetter(NSErr_t *errp, PList_t subject, PList_t resource, PList_t auth_in { struct acl_pblock *aclpb = NULL; PRNetAddr *client_praddr = NULL; + PRNetAddr *pb_client_praddr = NULL; char ip_str[256]; int rv = LAS_EVAL_TRUE; @@ -262,25 +263,39 @@ DS_LASIpGetter(NSErr_t *errp, PList_t subject, PList_t resource, PList_t auth_in return LAS_EVAL_FAIL; } - client_praddr = (PRNetAddr *)slapi_ch_malloc(sizeof(PRNetAddr)); - if (client_praddr == NULL) { - slapi_log_err(SLAPI_LOG_ERR, plugin_name, "DS_LASIpGetter - Failed to allocate client_praddr\n"); - return (LAS_EVAL_FAIL); - } + slapi_pblock_get(aclpb->aclpb_pblock, SLAPI_CONN_CLIENTNETADDR_ACLIP, &pb_client_praddr); + if (pb_client_praddr == NULL) { - if (slapi_pblock_get(aclpb->aclpb_pblock, SLAPI_CONN_CLIENTNETADDR, client_praddr) != 0) { - slapi_log_err(SLAPI_LOG_ERR, plugin_name, "DS_LASIpGetter - Could not get client IP.\n"); - slapi_ch_free((void **)&client_praddr); - return (LAS_EVAL_FAIL); - } + client_praddr = (PRNetAddr *) slapi_ch_malloc(sizeof (PRNetAddr)); + if (client_praddr == NULL) { + slapi_log_err(SLAPI_LOG_ERR, plugin_name, "DS_LASIpGetter - Failed to allocate client_praddr\n"); + return (LAS_EVAL_FAIL); + } - rv = PListInitProp(subject, 0, ACL_ATTR_IP, (void *)client_praddr, NULL); - if (rv < 0) { - slapi_log_err(SLAPI_LOG_ACL, plugin_name, "DS_LASIpGetter - " - "Couldn't set the client addr property(%d)\n", - rv); - slapi_ch_free((void **)&client_praddr); - return LAS_EVAL_FAIL; + if (slapi_pblock_get(aclpb->aclpb_pblock, SLAPI_CONN_CLIENTNETADDR, client_praddr) != 0) { + slapi_log_err(SLAPI_LOG_ERR, plugin_name, "DS_LASIpGetter - Could not get client IP.\n"); + slapi_ch_free((void **) &client_praddr); + return (LAS_EVAL_FAIL); + } + + rv = PListInitProp(subject, 0, ACL_ATTR_IP, (void *) client_praddr, NULL); + if (rv < 0) { + slapi_log_err(SLAPI_LOG_ACL, plugin_name, "DS_LASIpGetter - " + "Couldn't set the client addr property(%d)\n", + rv); + slapi_ch_free((void **) &client_praddr); + return LAS_EVAL_FAIL; + } + + } else { + client_praddr = pb_client_praddr; + rv = PListInitProp(subject, 0, ACL_ATTR_IP, (void *) client_praddr, NULL); + if (rv < 0) { + slapi_log_err(SLAPI_LOG_ACL, plugin_name, "DS_LASIpGetter - " + "Couldn't set the client addr property(%d)\n", + rv); + return LAS_EVAL_FAIL; + } } if (PR_NetAddrToString(client_praddr, ip_str, sizeof(ip_str)) == PR_SUCCESS) { slapi_log_err(SLAPI_LOG_ACL, plugin_name, "DS_LASIpGetter - " @@ -290,7 +305,7 @@ DS_LASIpGetter(NSErr_t *errp, PList_t subject, PList_t resource, PList_t auth_in slapi_log_err(SLAPI_LOG_ACL, plugin_name, "DS_LASIpGetter - " "Returning client ip address 'unknown'\n"); } - + slapi_pblock_set(aclpb->aclpb_pblock, SLAPI_CONN_CLIENTNETADDR_ACLIP, client_praddr); return LAS_EVAL_TRUE; } diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index e124303be..da954ada6 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -206,6 +206,7 @@ connection_cleanup(Connection *conn) conn->c_isreplication_session = 0; slapi_ch_free((void **)&conn->cin_addr); slapi_ch_free((void **)&conn->cin_destaddr); + slapi_ch_free((void **)&conn->cin_addr_aclip); slapi_ch_free_string(&conn->c_ipaddr); if (conn->c_domain != NULL) { ber_bvecfree(conn->c_domain); @@ -408,6 +409,7 @@ connection_reset(Connection *conn, int ns, PRNetAddr *from, int fromLen __attrib str_destip = str_unknown; } } + slapi_ch_free((void **)&conn->cin_addr_aclip); if (!in_referral_mode) { /* create a sasl connection */ diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index cc44ace30..348cc6f1a 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -482,6 +482,14 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value) } pthread_mutex_unlock(&(pblock->pb_conn->c_mutex)); break; + case SLAPI_CONN_CLIENTNETADDR_ACLIP: + if (pblock->pb_conn == NULL) { + break; + } + pthread_mutex_lock(&(pblock->pb_conn->c_mutex)); + (*(PRNetAddr **) value) = pblock->pb_conn->cin_addr_aclip; + pthread_mutex_unlock(&(pblock->pb_conn->c_mutex)); + break; case SLAPI_CONN_SERVERNETADDR: if (pblock->pb_conn == NULL) { memset(value, 0, sizeof(PRNetAddr)); @@ -2571,6 +2579,14 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value) pblock->pb_conn->c_authtype = slapi_ch_strdup((char *)value); pthread_mutex_unlock(&(pblock->pb_conn->c_mutex)); break; + case SLAPI_CONN_CLIENTNETADDR_ACLIP: + if (pblock->pb_conn == NULL) { + break; + } + pthread_mutex_lock(&(pblock->pb_conn->c_mutex)); + slapi_ch_free((void **)&pblock->pb_conn->cin_addr_aclip); + pblock->pb_conn->cin_addr_aclip = (PRNetAddr *)value; + pthread_mutex_unlock(&(pblock->pb_conn->c_mutex)); case SLAPI_CONN_IS_REPLICATION_SESSION: if (pblock->pb_conn == NULL) { slapi_log_err(SLAPI_LOG_ERR, diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 0aa2dcc1a..8a2748519 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1634,6 +1634,7 @@ typedef struct conn char *c_external_dn; /* client DN of this SSL session */ char *c_external_authtype; /* used for c_external_dn */ PRNetAddr *cin_addr; /* address of client on this conn */ + PRNetAddr *cin_addr_aclip; /* address of client allocated by acl with 'ip' subject */ PRNetAddr *cin_destaddr; /* address client connected to */ struct berval **c_domain; /* DNS names of client */ Operation *c_ops; /* list of pending operations */ diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 01dcb0554..29a6238d9 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -6930,6 +6930,7 @@ slapi_timer_result slapi_timespec_expire_check(struct timespec *expire); #define SLAPI_CONN_DN 143 #define SLAPI_CONN_CLIENTNETADDR 850 #define SLAPI_CONN_SERVERNETADDR 851 +#define SLAPI_CONN_CLIENTNETADDR_ACLIP 853 #define SLAPI_CONN_IS_REPLICATION_SESSION 149 #define SLAPI_CONN_IS_SSL_SESSION 747 #define SLAPI_CONN_CERT 743
0
ae39d1f0509dadc4fbd2fd436b8f39f998bdcee1
389ds/389-ds-base
Ticket 50159 - sssd and config display Bug Description: It can be very hard and confusing for an admin when they first start with LDAP to know how to configure clients both generic, ldapcli tools or sssd. Fix Description: Add a subcommand to dsidm that allows generation of example configs for ldap.conf, sssd.conf and generic display of parameters for LDAP clients. These have been tested to work on SUSE and Fedora, and they are well commented to advise admins to review and improve the configurations. https://pagure.io/389-ds-base/issue/50159 Author: William Brown <[email protected]> Review by: ???
commit ae39d1f0509dadc4fbd2fd436b8f39f998bdcee1 Author: William Brown <[email protected]> Date: Thu Jan 17 09:55:44 2019 +1000 Ticket 50159 - sssd and config display Bug Description: It can be very hard and confusing for an admin when they first start with LDAP to know how to configure clients both generic, ldapcli tools or sssd. Fix Description: Add a subcommand to dsidm that allows generation of example configs for ldap.conf, sssd.conf and generic display of parameters for LDAP clients. These have been tested to work on SUSE and Fedora, and they are well commented to advise admins to review and improve the configurations. https://pagure.io/389-ds-base/issue/50159 Author: William Brown <[email protected]> Review by: ??? diff --git a/src/lib389/cli/dsidm b/src/lib389/cli/dsidm index 386bc11ca..9e5b998e7 100755 --- a/src/lib389/cli/dsidm +++ b/src/lib389/cli/dsidm @@ -22,6 +22,7 @@ from lib389.cli_idm import organizationalunit as cli_ou from lib389.cli_idm import group as cli_group from lib389.cli_idm import posixgroup as cli_posixgroup from lib389.cli_idm import user as cli_user +from lib389.cli_idm import client_config as cli_client_config from lib389.cli_base import connect_instance, disconnect_instance, setup_script_logger from lib389.cli_base.dsrc import dsrc_to_ldap, dsrc_arg_concat @@ -71,6 +72,7 @@ cli_init.create_parser(subparsers) cli_ou.create_parser(subparsers) cli_posixgroup.create_parser(subparsers) cli_user.create_parser(subparsers) +cli_client_config.create_parser(subparsers) argcomplete.autocomplete(parser) diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py index bc0c8e638..eae3154ce 100644 --- a/src/lib389/lib389/_mapped_object.py +++ b/src/lib389/lib389/_mapped_object.py @@ -871,6 +871,16 @@ class DSLdapObjects(DSLogging): _gen_filter(_term_gen('objectclass'), self._objectclasses) ) + def _get_selector_filter(self, selector): + return _gen_and([ + self._get_objectclass_filter(), + _gen_or( + # This will yield all combinations of selector to filterattrs. + # This won't work with multiple values in selector (yet) + _gen_filter(self._filterattrs, _term_gen(selector)) + ), + ]) + def _entry_to_instance(self, dn=None, entry=None): # Normally this won't be used. But for say the plugin type where we # have "many" possible child types, this allows us to overload @@ -951,14 +961,7 @@ class DSLdapObjects(DSLogging): # Filter based on the objectclasses and the basedn # Based on the selector, we should filter on that too. # This will yield and & filter for objectClass with as many terms as needed. - filterstr=_gen_and([ - self._get_objectclass_filter(), - _gen_or( - # This will yield all combinations of selector to filterattrs. - # This won't work with multiple values in selector (yet) - _gen_filter(self._filterattrs, _term_gen(selector)) - ), - ]) + filterstr=self._get_selector_filter(selector) self._log.debug('_gen_selector filter = %s' % filterstr) return self._instance.search_ext_s( base=self._basedn, diff --git a/src/lib389/lib389/cli_idm/client_config.py b/src/lib389/lib389/cli_idm/client_config.py new file mode 100644 index 000000000..61c6fd554 --- /dev/null +++ b/src/lib389/lib389/cli_idm/client_config.py @@ -0,0 +1,290 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2019, William Brown <[email protected]> +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import argparse + +from lib389.idm.user import nsUserAccount, nsUserAccounts +from lib389.idm.group import Group, Groups +from lib389.plugins import MemberOfPlugin + +from lib389.utils import basedn_to_ldap_dns_uri + +SSSD_CONF_TEMPLATE = """ +# +# sssd.conf +# Generated by 389 Directory Server - dsidm +# +# For more details see man sssd.conf and man sssd-ldap +# Be sure to review the content of this file to ensure it is secure and correct +# in your environment. + +[domain/ldap] +# Uncomment this for more verbose logging. +# debug_level=3 + +# Cache hashes of user authentication for offline auth. +cache_credentials = True +id_provider = ldap +auth_provider = ldap +access_provider = ldap +chpass_provider = ldap +ldap_schema = {schema_type} +ldap_search_base = {basedn} +ldap_uri = {ldap_uri} +# If you have DNS SRV records, you can use the following instead. This derives +# from your ldap_search_base. +# ldap_uri = _srv_ + +ldap_tls_reqcert = demand +# To use cacert dir, place *.crt files in this path then run: +# /usr/bin/c_rehash /etc/openldap/certs +ldap_tls_cacertdir = /etc/openldap/certs + +# Path to the cacert +# ldap_tls_cacert = /etc/openldap/certs/ca.crt + +# Only users who match this filter can login and authorise to this machine. Note +# that users who do NOT match, will still have their uid/gid resolve, but they +# can't login. +ldap_access_filter = {ldap_access_filter} + +enumerate = false +access_provider = ldap +ldap_user_member_of = memberof +ldap_user_gecos = cn +ldap_user_uuid = nsUniqueId +ldap_group_uuid = nsUniqueId +# This is really important as it allows SSSD to respect nsAccountLock +ldap_account_expire_policy = rhds +ldap_access_order = filter, expire +# Setup for ssh keys +# Inside /etc/ssh/sshd_config add the lines: +# AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys +# AuthorizedKeysCommandUser nobody +# You can test with the command: sss_ssh_authorizedkeys <username> +ldap_user_ssh_public_key = nsSshPublicKey + +# This prevents an issue where the Directory is recursively walked on group +# and user look ups. It makes the client faster and more responsive in almost +# every scenario. +ignore_group_members = False + +[sssd] +services = nss, pam, ssh, sudo +config_file_version = 2 + +domains = ldap +[nss] +homedir_substring = /home + +""" + +def sssd_conf(inst, basedn, log, args): + + schema_type = "rfc2307" + try: + mo_plugin = MemberOfPlugin(inst) + if mo_plugin.status(): + schema_type = "rfc2307bis" + except: + schema_type = "unknown - likely access denied to memberof plugin config" + + ldap_access_filter = None + if args.allowed_group: + groups = Groups(inst, basedn) + g_access = groups.get(args.allowed_group) + ldap_access_filter = '(memberOf=%s)' % g_access.dn + + # Print a customised sssd.config. + print(SSSD_CONF_TEMPLATE.format( + basedn=basedn, + schema_type=schema_type, + ldap_uri=inst.ldapuri, + ldap_access_filter=ldap_access_filter, + )) + +LDAP_CONF_TEMPLATE = """ +# +# OpenLDAP client configuration +# Generated by 389 Directory Server - dsidm +# + +# See ldap.conf(5) for details +# This file should be world readable but not world writable. + +BASE {basedn} +# Remember to check this: you can have multiple uris on this line. You may have +# multiple servers or load balancers in your environment. +URI {ldap_uri} +# If you have DNS SRV records you can use: +# URI {ldap_dns_uri} + +DEREF never +# To use cacert dir, place *.crt files in this path then run: +# /usr/bin/c_rehash /etc/openldap/certs +TLS_CACERTDIR /etc/openldap/certs +# TLS_CACERT /etc/openldap/certs/ca.crt + +""" + +def ldap_conf(inst, basedn, log, args): + # Print a customised ldap.conf or ldaprc + print(LDAP_CONF_TEMPLATE.format( + basedn=basedn, + ldap_uri=inst.ldapuri, + ldap_dns_uri=basedn_to_ldap_dns_uri(basedn), + )) + +DISPLAY_TEMPLATE = """ +# This is a generic list of LDAP client configuration parameters you may require +# for connecting a client to this server. Some of them may or may not apply +# to your application, so consult your application documentation for further +# assistance. +# +# This program makes a number of assumptions about your data and configuration +# which may not be correct. Be sure to check these values for your situation. + +; ldap uri +; This is the uri of the server you will connect to and authenticate to. It +; must be a valid subjectAltName in the presented TLS certificate. Note that this +; is not an exhaustive list of your LDAP servers, and other applications in your +; network like load balancers may affect this. This is just what we derive from +; your current connection. +ldap_uri = {ldap_uri} + +; ldap dns discovery uri +; In some environments, you may have DNS SRV records such as +; "_ldap._tcp.<domain name>". If these are present in your dns server, you can +; use the following uri. +ldap_uri = {ldap_dns_uri} + +; ca_cert +; To correctly use TLS, you require the valid CA cert that issued your LDAP TLS +; certificates. Sometimes a copy of this may be in your server instance as +ca_cert = /etc/dirsrv/slapd-<instance>/ca.crt +; However that's not guaranteed. You can show the certs from the LDAP server +; by sshing to the server and running: +certutil -L -d /etc/dirsrv/slapd-<instance>/ +; If you can identify the CA certificate name, you can then view it with: +certutil -L -n <ca cert name> -a -d /etc/dirsrv/slapd-<instance>/ +; This should be a pem file you can use in your application's CA. +; Some applications don't require a ca certificate parameter, and will use the +; ca certificate from /etc/openldap/ldap.conf. You should configure ldap.conf +; in these cases. See the 'client_config ldap.conf' command in dsidm. + +; basedn +; The basedn is the root suffix where all searches will originate from for +; LDAP objects. +basedn = {basedn} + +; schema_type +; LDAP servers have different ways to structure their objects and group +; relationships. Legacy servers will use rfc2307, where as modern servers will +; use rfc2307bis (requires MemberOf plugin to be enabled). This is the schema +; setting of your directory based on your running configuration (if we can +; detect it). +schema_type = {schema_type} + +; user/account basedn +; Some applications may optionally use a user/account basedn to limit searches +; in the directory. This can be for performance or security reasons. Generally +; you shouldn't need this, preferring to use groups and filters for access +; control. +user_basedn = {user_basedn} + +; user filter +; This is an ldap filter that will return only user objects. Additionally some +; applications will template into the filter (similar to sql statements) or they +; will generate the filter based on attributes. We list a number of possible +; filters you might use, but you should customise this for your application. +; +; If you are using rfc2307bis, you can use this filter to provide authorisation +; support by adding filters such as: (memberOf=<groupdn>) +user_filter = {user_filter} +user_filter = {user_id_filter} + +; group basedn +; Some applications may optionnaly use a group basedn to limit searches in the +; directory. This can be for performance or security reasons. Generally you +; shouldn't need this, preferring to use groups and filters for access control. +group_basedn = {group_basedn} + +; group filter +; This is an ldap filter that will return only group objects. Additionally +; some applications will template into the filter (similar to sql statements) +; or they will generate the filter base on attributes. We list a number of +; possible filters you might use, but you should customise this for your +; application. +group_filter = {group_filter} +group_filter = {group_id_filter} + +; attribute mappings +; Due to the variety of schemas and attribute mappings in LDAP, there are +; different representations of attributes and values. This is a guess at +; the mappings that exist in your server, and what attributes you should +; configure and use. +unique id = {uuid_attr} +user rdn = {user_rdn} +user identifier = {user_rdn} +group rdn = {group_rdn} +group member attribute = {group_member} + +""" + + +def display(inst, basedn, log, args): + + users = nsUserAccounts(inst, basedn) + groups = Groups(inst, basedn) + + schema_type = "rfc2307" + try: + mo_plugin = MemberOfPlugin(inst) + if mo_plugin.status(): + schema_type = "rfc2307bis" + except: + schema_type = "unknown - likely access denied to memberof plugin config" + + # Get required information + print(DISPLAY_TEMPLATE.format( + ldap_uri=inst.ldapuri, + ldap_dns_uri=basedn_to_ldap_dns_uri(basedn), + basedn=basedn, + schema_type=schema_type, + user_basedn=users._basedn, + user_filter=users._get_objectclass_filter(), + user_id_filter=users._get_selector_filter('<PARAM>'), + group_basedn=groups._basedn, + group_filter=groups._get_objectclass_filter(), + group_id_filter=groups._get_selector_filter('<PARAM>'), + uuid_attr='nsUniqueId', + user_rdn=users._filterattrs[0], + group_rdn=groups._filterattrs[0], + group_member='member', + )) + +def create_parser(subparsers): + client_config_parser = subparsers.add_parser('client_config', + help="Display and generate client example configs for this LDAP server") + + subcommands = client_config_parser.add_subparsers(help='action') + + sssd_conf_parser = subcommands.add_parser('sssd.conf', + help="Generate a SSSD configuration for this LDAP server") + # Allowed login groups for filter? + sssd_conf_parser.add_argument('allowed_group', nargs='?', help="The name of the group allowed access to this system") + sssd_conf_parser.set_defaults(func=sssd_conf) + + ldap_conf_parser = subcommands.add_parser('ldap.conf', + help="Generate an OpenLDAP ldap.conf configuration for this LDAP server") + ldap_conf_parser.set_defaults(func=ldap_conf) + + display_parser = subcommands.add_parser('display', + help="Display generic application parameters for LDAP connection") + display_parser.set_defaults(func=display) + diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py index 0b90da26e..987176bf8 100644 --- a/src/lib389/lib389/utils.py +++ b/src/lib389/lib389/utils.py @@ -1185,4 +1185,9 @@ def get_user_is_ds_owner(): return True return False +def basedn_to_ldap_dns_uri(basedn): + # ldap:///dc%3Dexample%2Cdc%3Dcom + return "ldaps:///" + basedn.replace("=", "%3D").replace(",", "%2C") + +
0
11b384993fda16739176719b2a3e3703b1a72744
389ds/389-ds-base
Fix valgrind functions
commit 11b384993fda16739176719b2a3e3703b1a72744 Author: Mark Reynolds <[email protected]> Date: Tue Jul 19 10:28:46 2016 -0400 Fix valgrind functions diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 972f75aab..7d2661b01 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -1420,11 +1420,31 @@ class DirSrv(SimpleLDAPObject): return "ldap://%s:%d/" % (ensure_str(host), self.port) def can_autobind(self): + """Check if autobind/LDAPI is enabled.""" return self.ldapi_enabled == 'on' and self.ldapi_socket is not None and self.ldapi_autobind == 'on' def getServerId(self): + """Return the server identifier.""" return self.serverid + def get_ldif_dir(self, prefix=None): + """Return the server instance ldif directory.""" + try: + ldif_dir = self.getEntry(DN_CONFIG).__getattr__('nsslapd-ldifdir') + except: + ldif_dir = self.ldifdir + + return ldif_dir + + def get_bak_dir(self, prefix=None): + """Return the server instance ldif directory.""" + try: + bak_dir = self.getEntry(DN_CONFIG).__getattr__('nsslapd-bakdir') + except: + bak_dir = self.bakdir + + return bak_dir + # # Get entries # diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py index 88b59fbeb..cbb2adecf 100644 --- a/src/lib389/lib389/utils.py +++ b/src/lib389/lib389/utils.py @@ -32,6 +32,7 @@ import socket import subprocess import time import sys +import filecmp from socket import getfqdn from ldapurl import LDAPUrl from contextlib import closing @@ -187,6 +188,9 @@ 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 script calling valgrind_enable() must be run as the 'root' user + as selinux needs to be disabled for valgrind to work + 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 @@ -197,12 +201,17 @@ def valgrind_enable(sbin_dir, wrapper=None): - 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) - @param wrapper - The valgrind wrapper script for ns-slapd (if not set, + :param sbin_dir: the location of the ns-slapd binary (e.g. /usr/sbin) + :param wrapper: The valgrind wrapper script for ns-slapd (if not set, a default wrapper is used) - @raise IOError + :raise IOError: If there is a problem setting up the valgrind scripts + :raise EnvironmentError: If script is not run as 'root' ''' + if os.geteuid() != 0: + log.error('This script must be run as root to use valgrind') + raise EnvironmentError + if not wrapper: # use the default ns-slapd wrapper wrapper = '%s/%s' % (os.path.dirname(os.path.abspath(__file__)), @@ -214,11 +223,10 @@ def valgrind_enable(sbin_dir, wrapper=None): if os.path.isfile(nsslapd_backup): # There is a backup which means we never cleaned up from a previous # run(failed test?) - # We do not want to copy ns-slapd to ns-slapd.original because ns-slapd - # is currently the wrapper. Basically everything is already enabled - # and ready to go. - log.info('Valgrind is already enabled.') - return + if not filecmp.cmp(nsslapd_backup, nsslapd_orig): + # Files are different sizes, we assume valgrind is already setup + log.info('Valgrind is already enabled.') + return # Check both nsslapd's exist if not os.path.isfile(wrapper): @@ -235,7 +243,7 @@ def valgrind_enable(sbin_dir, wrapper=None): except IOError as e: log.fatal('valgrind_enable(): failed to backup ns-slapd, error: %s' % e.strerror) - raise IOError('failed to backup ns-slapd, error: ' % e.strerror) + raise IOError('failed to backup ns-slapd, error: %s' % e.strerror) # Copy the valgrind wrapper into place try: @@ -243,9 +251,12 @@ def valgrind_enable(sbin_dir, wrapper=None): except IOError as e: log.fatal('valgrind_enable(): failed to copy valgrind wrapper ' 'to ns-slapd, error: %s' % e.strerror) - raise IOError('failed to copy valgrind wrapper to ns-slapd, error: ' % + raise IOError('failed to copy valgrind wrapper to ns-slapd, error: %s' % e.strerror) + # Disable selinux + os.system('setenforce 0') + log.info('Valgrind is now enabled.') @@ -253,10 +264,18 @@ def valgrind_disable(sbin_dir): ''' Restore the ns-slapd binary to its original state - the server instances are expected to be stopped. - @param sbin_dir - the location of the ns-slapd binary (e.g. /usr/sbin) - @raise ValueError + + Note - selinux is enabled at the end of this process. + + :param sbin_dir - the location of the ns-slapd binary (e.g. /usr/sbin) + :raise ValueError + :raise EnvironmentError: If script is not run as 'root' ''' + if os.geteuid() != 0: + log.error('This script must be run as root to use valgrind') + raise EnvironmentError + nsslapd_orig = '%s/ns-slapd' % sbin_dir nsslapd_backup = '%s/ns-slapd.original' % sbin_dir @@ -266,7 +285,7 @@ def valgrind_disable(sbin_dir): except IOError as e: log.fatal('valgrind_disable: failed to restore ns-slapd, error: %s' % e.strerror) - raise ValueError('failed to restore ns-slapd, error: ' % e.strerror) + raise ValueError('failed to restore ns-slapd, error: %s' % e.strerror) # Delete the backup now try: @@ -274,9 +293,12 @@ def valgrind_disable(sbin_dir): except OSError as e: log.fatal('valgrind_disable: failed to delete backup ns-slapd, error:' ' %s' % e.strerror) - raise ValueError('Failed to delete backup ns-slapd, error: ' % + raise ValueError('Failed to delete backup ns-slapd, error: %s' % e.strerror) + # Enable selinux + os.system('setenforce 1') + log.info('Valgrind is now disabled.') @@ -290,7 +312,7 @@ def valgrind_get_results_file(dirsrv_inst): 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 + --log-file=/var/tmp/slapd.vg.26179 /usr/sbin/ns-slapd.original -D /etc/dirsrv/slapd-localhost -i /var/run/dirsrv/slapd-localhost.pid -w /var/run/dirsrv/slapd-localhost.startpid
0
026956c7e3b4dc00b6738f9a195e6653fed03d79
389ds/389-ds-base
Ticket 48332 - allow users to specify to relax the FQDN constraint Bug Description: There are situations when the machine name for ds may not match the dns name. In these cases we should allow installation without the strict hostname checks we carry out. Fix Description: Add a new option, General.StrictHostCheck which defaults to true. If true, host name checking is carried out. If false, it is disabled and any hostname in General.FullMachineName is considered valid. https://fedorahosted.org/389/ticket/48332 Author: wibrown Review by: rmeggins (Thanks!)
commit 026956c7e3b4dc00b6738f9a195e6653fed03d79 Author: William Brown <[email protected]> Date: Thu Nov 26 13:11:17 2015 +1000 Ticket 48332 - allow users to specify to relax the FQDN constraint Bug Description: There are situations when the machine name for ds may not match the dns name. In these cases we should allow installation without the strict hostname checks we carry out. Fix Description: Add a new option, General.StrictHostCheck which defaults to true. If true, host name checking is carried out. If false, it is disabled and any hostname in General.FullMachineName is considered valid. https://fedorahosted.org/389/ticket/48332 Author: wibrown Review by: rmeggins (Thanks!) diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index e04d90dc7..d449b023e 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/ldap/admin/src/scripts/DSCreate.pm.in @@ -126,9 +126,18 @@ sub sanityCheckParams { debug(0, "WARNING: The root password is less than 8 characters long. You should choose a longer one.\n"); } - if (@errs = checkHostname($inf->{General}->{FullMachineName}, 0)) { - debug(1, @errs); - return @errs; + $inf->{General}->{StrictHostCheck} = lc $inf->{General}->{StrictHostCheck}; + + if ("true" ne $inf->{General}->{StrictHostCheck} && "false" ne $inf->{General}->{StrictHostCheck}) { + debug(1, "StrictHostCheck is not a valid boolean"); + return ('error_invalid_boolean', $inf->{General}->{StrictHostCheck}); + } + + if ($inf->{General}->{StrictHostCheck} eq "true" ) { + if (@errs = checkHostname($inf->{General}->{FullMachineName}, 0)) { + debug(1, @errs); + return @errs; + } } # We need to make sure this value is lowercase @@ -903,6 +912,10 @@ sub setDefaults { $inf->{slapd}->{InstScriptsEnabled} = "false"; } + if (!defined($inf->{General}->{StrictHostCheck})) { + $inf->{General}->{StrictHostCheck} = "true"; + } + if (!defined($inf->{slapd}->{inst_dir})) { $inf->{slapd}->{inst_dir} = "$inf->{General}->{ServerRoot}/slapd-$servid"; }
0
92d7458355c775ddd62bb82c58cffe2472ee5ff9
389ds/389-ds-base
610281 - fix coverity Defect Type: Control flow issues https://bugzilla.redhat.com/show_bug.cgi?id=610281 11794 DEADCODE Triaged Unassigned Bug Minor Ignore slapi_dn_syntax_check() ds/ldap/servers/slapd/plugin_syntax.c Comment: Checking for the possibility of dn == NULL is not needed since it is already checked at the line 303.
commit 92d7458355c775ddd62bb82c58cffe2472ee5ff9 Author: Noriko Hosoi <[email protected]> Date: Fri Jul 2 10:04:48 2010 -0700 610281 - fix coverity Defect Type: Control flow issues https://bugzilla.redhat.com/show_bug.cgi?id=610281 11794 DEADCODE Triaged Unassigned Bug Minor Ignore slapi_dn_syntax_check() ds/ldap/servers/slapd/plugin_syntax.c Comment: Checking for the possibility of dn == NULL is not needed since it is already checked at the line 303. diff --git a/ldap/servers/slapd/plugin_syntax.c b/ldap/servers/slapd/plugin_syntax.c index 5018326ef..174b136fc 100644 --- a/ldap/servers/slapd/plugin_syntax.c +++ b/ldap/servers/slapd/plugin_syntax.c @@ -319,7 +319,7 @@ slapi_dn_syntax_check( if (dn_plugin->plg_syntax_validate(&dn_bval) != 0) { if (syntaxlogging) { slapi_log_error( SLAPI_LOG_FATAL, "Syntax Check", - "DN value (%s) invalid per syntax\n", dn ? dn : ""); + "DN value (%s) invalid per syntax\n", dn); } if (syntaxcheck || override) {
0
c15baaf473099bc6fe9745a10f4499aea8c045a4
389ds/389-ds-base
Ticket 48985 - Add schema for nested groups to work out of box. Bug Description: Previously, nestedGroups didn't work on pure ds because you needed to add inetUser to a group. As well, the auto objectClass didn't work as it would be NULL by default. Fix Description: Add schema and update defaults for memberof to work out of the box with no alterations. Make it the default add objectClass, and because of it's simple nature, it can apply to groups and users. https://pagure.io/389-ds-base/issue/48985 Author: wibrown Review by: mreynolds (Thanks!)
commit c15baaf473099bc6fe9745a10f4499aea8c045a4 Author: William Brown <[email protected]> Date: Fri May 5 11:21:03 2017 +1000 Ticket 48985 - Add schema for nested groups to work out of box. Bug Description: Previously, nestedGroups didn't work on pure ds because you needed to add inetUser to a group. As well, the auto objectClass didn't work as it would be NULL by default. Fix Description: Add schema and update defaults for memberof to work out of the box with no alterations. Make it the default add objectClass, and because of it's simple nature, it can apply to groups and users. https://pagure.io/389-ds-base/issue/48985 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/dirsrvtests/tests/suites/plugins/memberof_test.py b/dirsrvtests/tests/suites/plugins/memberof_test.py index 5880964b9..f4bf225e0 100644 --- a/dirsrvtests/tests/suites/plugins/memberof_test.py +++ b/dirsrvtests/tests/suites/plugins/memberof_test.py @@ -128,16 +128,12 @@ def text_memberof_683241_01(topology_st): [(ldap.MOD_REPLACE, PLUGIN_TYPE, 'betxnpostoperation')]) - topology_st.standalone.restart(timeout=10) + topology_st.standalone.restart() ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_TYPE]) assert ent.hasAttr(PLUGIN_TYPE) assert ent.getValue(PLUGIN_TYPE) == 'betxnpostoperation' -def test_memberof_setloging(topology_st): - topology_st.standalone.modify_s('cn=config', [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', str(65536))]) - - def test_memberof_MultiGrpAttr_001(topology_st): """ Checking multiple grouping attributes supported @@ -156,7 +152,7 @@ def test_memberof_MultiGrpAttr_003(topology_st): """ log.info("Enable MemberOf plugin") topology_st.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) - topology_st.standalone.restart(timeout=10) + topology_st.standalone.restart() ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_ENABLED]) assert ent.hasAttr(PLUGIN_ENABLED) assert ent.getValue(PLUGIN_ENABLED).lower() == 'on' @@ -294,7 +290,7 @@ def test_memberof_MultiGrpAttr_008(topology_st): [(ldap.MOD_DELETE, PLUGIN_MEMBEROF_GRP_ATTR, ['uniqueMember'])]) - topology_st.standalone.restart(timeout=10) + topology_st.standalone.restart() log.info("Assert that this change of configuration did change the already set values") # assert enh1 is member of grp1 and is NOT member of grp2 @@ -306,7 +302,7 @@ def test_memberof_MultiGrpAttr_008(topology_st): assert _check_memberof(topology_st, member=memofenh2, group=memofegrp2) _set_memberofgroupattr_add(topology_st, 'uniqueMember') - topology_st.standalone.restart(timeout=10) + topology_st.standalone.restart() def test_memberof_MultiGrpAttr_009(topology_st): @@ -2420,7 +2416,43 @@ def test_memberof_auto_add_oc(topology_st): # Enable the plugin topology_st.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) - # First test invalid value (config validation) + # Test that the default add OC works. + + try: + topology_st.standalone.add_s(Entry((USER1_DN, + {'objectclass': 'top', + 'objectclass': 'person', + 'objectclass': 'organizationalPerson', + 'objectclass': 'inetorgperson', + 'sn': 'last', + 'cn': 'full', + 'givenname': 'user1', + 'uid': 'user1' + }))) + except ldap.LDAPError as e: + log.fatal('Failed to add user1 entry, error: ' + e.message['desc']) + assert False + + # Add a group(that already includes one user + try: + topology_st.standalone.add_s(Entry((GROUP_DN, + {'objectclass': 'top', + 'objectclass': 'groupOfNames', + 'cn': 'group', + 'member': USER1_DN + }))) + except ldap.LDAPError as e: + log.fatal('Failed to add group entry, error: ' + e.message['desc']) + assert False + + # Assert memberOf on user1 + _check_memberof(topology_st, USER1_DN, GROUP_DN) + + # Reset for the next test .... + topology_st.standalone.delete_s(USER1_DN) + topology_st.standalone.delete_s(GROUP_DN) + + # Test invalid value (config validation) topology_st.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) try: topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, @@ -2435,6 +2467,7 @@ def test_memberof_auto_add_oc(topology_st): ldap.error('Unexpected error adding invalid objectclass - error: ' + e.message['desc']) assert False + # Add valid objectclass topology_st.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) try: diff --git a/ldap/admin/src/scripts/fixup-memberof.pl.in b/ldap/admin/src/scripts/fixup-memberof.pl.in index fc00c2fac..167ed7fbf 100644 --- a/ldap/admin/src/scripts/fixup-memberof.pl.in +++ b/ldap/admin/src/scripts/fixup-memberof.pl.in @@ -32,7 +32,7 @@ sub usage { print(STDERR " -j filename - Read Directory Manager's password from file\n"); print(STDERR " -b baseDN - Base DN that contains entries to fix up.\n"); print(STDERR " -f filter - Filter for entries to fix up\n"); - print(STDERR " If omitted, all entries with objectclass inetuser/inetadmin under the\n"); + print(STDERR " If omitted, all entries with objectclass inetuser/inetadmin/nsmemberof under the\n"); print(STDERR " specified base will have their memberOf attribute regenerated.\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); print(STDERR " -h - Display usage\n"); diff --git a/ldap/schema/30ns-common.ldif b/ldap/schema/30ns-common.ldif index ebe540a1a..b0959090b 100644 --- a/ldap/schema/30ns-common.ldif +++ b/ldap/schema/30ns-common.ldif @@ -63,3 +63,5 @@ objectClasses: ( nsTaskGroup-oid NAME 'nsTaskGroup' DESC 'Netscape defined objec objectClasses: ( nsAdminObject-oid NAME 'nsAdminObject' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsJarFilename $ nsClassName ) X-ORIGIN 'Netscape' ) objectClasses: ( nsConfig-oid NAME 'nsConfig' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( description $ nsServerPort $ nsServerAddress $ nsSuiteSpotUser $ nsErrorLog $ nsPidLog $ nsAccessLog $ nsDefaultAcceptLanguage $ nsServerSecurity ) X-ORIGIN 'Netscape' ) objectClasses: ( nsDirectoryInfo-oid NAME 'nsDirectoryInfo' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsBindDN $ nsBindPassword $ nsDirectoryURL $ nsDirectoryFailoverList $ nsDirectoryInfoRef ) X-ORIGIN 'Netscape' ) +objectClasses: ( 2.16.840.1.113730.3.2.329 NAME 'nsMemberOf' DESC 'Allow memberOf assignment on groups for nesting and users' SUP top AUXILIARY MAY ( memberOf ) X-ORIGIN '389 Directory Server Project' ) + diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c index 8d36b80fb..b37f1a1c1 100644 --- a/ldap/servers/plugins/memberof/memberof.c +++ b/ldap/servers/plugins/memberof/memberof.c @@ -3140,7 +3140,7 @@ int memberof_task_add(Slapi_PBlock *pb, goto out; } - if ((filter = fetch_attr(e, "filter", "(|(objectclass=inetuser)(objectclass=inetadmin))")) == NULL) + if ((filter = fetch_attr(e, "filter", "(|(objectclass=inetuser)(objectclass=inetadmin)(objectclass=nsmemberof))")) == NULL) { *returncode = LDAP_OBJECT_CLASS_VIOLATION; rv = SLAPI_DSE_CALLBACK_ERROR; diff --git a/ldap/servers/plugins/memberof/memberof.h b/ldap/servers/plugins/memberof/memberof.h index 9a3a6a25d..723c32e3c 100644 --- a/ldap/servers/plugins/memberof/memberof.h +++ b/ldap/servers/plugins/memberof/memberof.h @@ -42,6 +42,7 @@ #define MEMBEROF_ENTRY_SCOPE_EXCLUDE_SUBTREE "memberOfEntryScopeExcludeSubtree" #define MEMBEROF_SKIP_NESTED_ATTR "memberOfSkipNested" #define MEMBEROF_AUTO_ADD_OC "memberOfAutoAddOC" +#define NSMEMBEROF "nsMemberOf" #define DN_SYNTAX_OID "1.3.6.1.4.1.1466.115.121.1.12" #define NAME_OPT_UID_SYNTAX_OID "1.3.6.1.4.1.1466.115.121.1.34" diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c index 522bfb7f4..c1bba2f5c 100644 --- a/ldap/servers/plugins/memberof/memberof_config.c +++ b/ldap/servers/plugins/memberof/memberof_config.c @@ -285,13 +285,19 @@ memberof_validate_config (Slapi_PBlock *pb, } } - if ((auto_add_oc = slapi_entry_attr_get_charptr(e, MEMBEROF_AUTO_ADD_OC))){ + /* Setup a default auto add OC */ + auto_add_oc = slapi_entry_attr_get_charptr(e, MEMBEROF_AUTO_ADD_OC); + if (auto_add_oc == NULL) { + auto_add_oc = slapi_ch_strdup(NSMEMBEROF); + } + + if (auto_add_oc != NULL) { char *sup = NULL; /* Check if the objectclass exists by looking for its superior oc */ if((sup = slapi_schema_get_superior_name(auto_add_oc)) == NULL){ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, - "The %s configuration attribute must be set to " + "The %s configuration attribute must be set " "to an existing objectclass (unknown: %s)", MEMBEROF_AUTO_ADD_OC, auto_add_oc); *returncode = LDAP_UNWILLING_TO_PERFORM; @@ -515,6 +521,10 @@ memberof_apply_config (Slapi_PBlock *pb __attribute__((unused)), skip_nested = slapi_entry_attr_get_charptr(e, MEMBEROF_SKIP_NESTED_ATTR); auto_add_oc = slapi_entry_attr_get_charptr(e, MEMBEROF_AUTO_ADD_OC); + if (auto_add_oc == NULL) { + auto_add_oc = slapi_ch_strdup(NSMEMBEROF); + } + /* * We want to be sure we don't change the config in the middle of * a memberOf operation, so we obtain an exclusive lock here @@ -638,6 +648,7 @@ memberof_apply_config (Slapi_PBlock *pb __attribute__((unused)), theConfig.allBackends = 0; } + slapi_ch_free_string(&(theConfig.auto_add_oc)); theConfig.auto_add_oc = auto_add_oc; /*
0
6d73cc23a7c4932904af734a765d6271c14521c9
389ds/389-ds-base
Issue 5607, 5351, 5611 - UI/CLI - fix various issues Descriptrion: 5607 - Ldap Editor failed to decode base64 values 5351 - CLI - Cockpit enable check for cockpit package was not portable (just removed this check) 5611 - Security page had a lot of issues when trying to change the Server Certificate. Save didn't work, and "Security Enable" modal would crash relates: https://github.com/389ds/389-ds-base/issues/5607 relates: https://github.com/389ds/389-ds-base/issues/5351 relates: https://github.com/389ds/389-ds-base/issues/5611 Reviewed by: spichugi(Thanks!)
commit 6d73cc23a7c4932904af734a765d6271c14521c9 Author: Mark Reynolds <[email protected]> Date: Fri Jan 20 11:51:15 2023 -0500 Issue 5607, 5351, 5611 - UI/CLI - fix various issues Descriptrion: 5607 - Ldap Editor failed to decode base64 values 5351 - CLI - Cockpit enable check for cockpit package was not portable (just removed this check) 5611 - Security page had a lot of issues when trying to change the Server Certificate. Save didn't work, and "Security Enable" modal would crash relates: https://github.com/389ds/389-ds-base/issues/5607 relates: https://github.com/389ds/389-ds-base/issues/5351 relates: https://github.com/389ds/389-ds-base/issues/5611 Reviewed by: spichugi(Thanks!) diff --git a/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx b/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx index 9cd4ff329..22deb6c9e 100644 --- a/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx +++ b/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx @@ -1043,7 +1043,7 @@ export function showCertificate (certificate, showCertCallback) { export function b64DecodeUnicode (str) { // Going backwards: from bytestream, to percent-encoding, to original string. try { - result = decodeURIComponent(atob(str).split('').map(c => { + let result = decodeURIComponent(atob(str).split('').map(c => { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); }).join('')); return result; diff --git a/src/cockpit/389-console/src/security.jsx b/src/cockpit/389-console/src/security.jsx index e5c4f9021..0e343cb8e 100644 --- a/src/cockpit/389-console/src/security.jsx +++ b/src/cockpit/389-console/src/security.jsx @@ -109,9 +109,14 @@ export class Security extends React.Component { // Server Cert this.handleServerCertSelect = (event, selection) => { + let disableSaveBtn = !this.configChanged(); + if (this.state._nssslpersonalityssl !== selection) { + disableSaveBtn = false; + } this.setState({ nssslpersonalityssl: selection, - isServerCertOpen: false + isServerCertOpen: false, + disableSaveBtn, }); }; this.handleServerCertToggle = isServerCertOpen => { @@ -240,6 +245,7 @@ export class Security extends React.Component { this.onSelectToggle = this.onSelectToggle.bind(this); this.onSelectClear = this.onSelectClear.bind(this); this.handleTypeaheadChange = this.handleTypeaheadChange.bind(this); + this.onSecEnableChange = this.onSecEnableChange.bind(this); } componentDidMount () { @@ -558,6 +564,7 @@ export class Security extends React.Component { _sslVersionMin: attrs.sslversionmin, _sslVersionMax: attrs.sslversionmax, _allowWeakCipher: allowWeak, + disableSaveBtn: true, } ), function() { if (!saving) { @@ -628,23 +635,51 @@ export class Security extends React.Component { "dsconf", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket", "security", "enable", ]; - log_cmd("enableSecurity", "Enable security", cmd); - cockpit - .spawn(cmd, { superuser: true, err: "message" }) + + if (this.state._nssslpersonalityssl !== this.state.primaryCertName) { + const rsa_cmd = [ + 'dsconf', '-j', 'ldapi://%2fvar%2frun%2fslapd-' + this.props.serverId + '.socket', + 'security', 'rsa', 'set', '--nss-cert-name=' + this.state.primaryCertName + ]; + log_cmd("enableSecurity", "Update RSA", rsa_cmd); + cockpit + .spawn(rsa_cmd, { superuser: true, err: "message" }) .done(() => { - this.props.addNotification( - "success", - `Successfully enabled security.` - ); - this.props.addNotification( - "warning", - `You must restart the Directory Server for these changes to take effect.` - ); - this.setState({ - securityEnabled: true, - secEnableSpinner: false, - showSecurityEnableModal: false, - }); + this.loadSecurityConfig(); + log_cmd("enableSecurity", "Enable security", cmd); + cockpit + .spawn(cmd, { superuser: true, err: "message" }) + .done(() => { + this.loadSecurityConfig(); + this.props.addNotification( + "success", + `Successfully enabled security.` + ); + this.props.addNotification( + "warning", + `You must restart the Directory Server for these changes to take effect.` + ); + this.setState({ + securityEnabled: true, + secEnableSpinner: false, + showSecurityEnableModal: false, + }); + }) + .fail(err => { + const errMsg = JSON.parse(err); + let msg = errMsg.desc; + if ('info' in errMsg) { + msg = errMsg.desc + " - " + errMsg.info; + } + this.props.addNotification( + "error", + `Error enabling security - ${msg}` + ); + this.setState({ + secEnableSpinner: false, + showSecurityEnableModal: false, + }); + }); }) .fail(err => { const errMsg = JSON.parse(err); @@ -654,13 +689,48 @@ export class Security extends React.Component { } this.props.addNotification( "error", - `Error enabling security - ${msg}` + `Error enabling security (RSA cert name)- ${msg}` ); this.setState({ secEnableSpinner: false, showSecurityEnableModal: false, }); }); + } else { + log_cmd("enableSecurity", "Enable security", cmd); + cockpit + .spawn(cmd, { superuser: true, err: "message" }) + .done(() => { + this.props.addNotification( + "success", + `Successfully enabled security.` + ); + this.props.addNotification( + "warning", + `You must restart the Directory Server for these changes to take effect.` + ); + this.setState({ + securityEnabled: true, + secEnableSpinner: false, + showSecurityEnableModal: false, + }); + }) + .fail(err => { + const errMsg = JSON.parse(err); + let msg = errMsg.desc; + if ('info' in errMsg) { + msg = errMsg.desc + " - " + errMsg.info; + } + this.props.addNotification( + "error", + `Error enabling security - ${msg}` + ); + this.setState({ + secEnableSpinner: false, + showSecurityEnableModal: false, + }); + }); + } } disableSecurity () { @@ -731,6 +801,10 @@ export class Security extends React.Component { 'dsconf', '-j', 'ldapi://%2fvar%2frun%2fslapd-' + this.props.serverId + '.socket', 'security', 'set' ]; + const rsa_cmd = [ + 'dsconf', '-j', 'ldapi://%2fvar%2frun%2fslapd-' + this.props.serverId + '.socket', + 'security', 'rsa', 'set' + ]; if (this.state._validateCert !== this.state.validateCert) { cmd.push("--verify-cert-chain-on-startup=" + this.state.validateCert); @@ -777,6 +851,53 @@ export class Security extends React.Component { cmd.push("--tls-client-renegotiation=" + val); } + if (this.state._nssslpersonalityssl !== this.state.nssslpersonalityssl) { + rsa_cmd.push("--nss-cert-name=" + this.state.nssslpersonalityssl); + } + if (rsa_cmd.length > 6) { + log_cmd("saveSecurityConfig", "Applying security RSA config change", rsa_cmd); + const msg = "Successfully updated security RSA configuration."; + + this.setState({ + // Start the spinner + saving: true + }); + + cockpit + .spawn(rsa_cmd, { superuser: true, err: "message" }) + .done(content => { + this.loadSecurityConfig(); + if (cmd.length < 6) { + this.props.addNotification( + "success", + msg + ); + this.props.addNotification( + "warning", + `You must restart the Directory Server for these changes to take effect.` + ); + this.setState({ + saving: false + }); + } + }) + .fail(err => { + const errMsg = JSON.parse(err); + this.loadSecurityConfig(); + this.setState({ + saving: false + }); + let msg = errMsg.desc; + if ('info' in errMsg) { + msg = errMsg.desc + " - " + errMsg.info; + } + this.props.addNotification( + "error", + `Error updating security RSA configuration - ${msg}` + ); + }); + } + if (cmd.length > 5) { log_cmd("saveSecurityConfig", "Applying security config change", cmd); const msg = "Successfully updated security configuration."; diff --git a/src/lib389/lib389/cli_ctl/cockpit.py b/src/lib389/lib389/cli_ctl/cockpit.py index 3e4ac5454..22d79725e 100644 --- a/src/lib389/lib389/cli_ctl/cockpit.py +++ b/src/lib389/lib389/cli_ctl/cockpit.py @@ -1,5 +1,5 @@ # --- BEGIN COPYRIGHT BLOCK --- -# Copyright (C) 2020 Red Hat, Inc. +# Copyright (C) 2023 Red Hat, Inc. # All rights reserved. # # License: GPL (version 3 or any later version). @@ -9,21 +9,11 @@ import os import subprocess -def cockpit_present(): - rpm_handle = os.popen('rpm -qa --qf "%{NAME}\n"') - rpm_list = rpm_handle.read().splitlines() - if 'cockpit' in rpm_list: - return True - else: - return False - def enable_cockpit(inst, log, args): """ Enable Cockpit socket """ - if not cockpit_present(): - raise ValueError("The 'cockpit' package is not installed on this system") ENABLE_CMD = ['sudo', 'systemctl', 'enable', '--now', 'cockpit.socket'] try:
0
73ff835f29514e33433de9f2be74f73efe6943ce
389ds/389-ds-base
Ticket 48928 log of page result cookie should log empty cookie with a different value than 0 Bug Description: With the ticket https://fedorahosted.org/389/ticket/48752, the cookie value is logged with each page result RESULT. When the page result is completed (no more entry to return), the returned cookie is 'pr_cookie=0'. Else the cookie value is logged 'pr_cookie=<internal index>'. Unfortunately the index ranges [0..N]. So when the value pr_cookie=0 is logged, it is not possible to know if it is an empty cookie or a valid cookie with the value 0. Fix Description: Log the empty cookie with a value '-1' https://fedorahosted.org/389/ticket/48928 Reviewed by: Noriko Hosoi, Simon Pichugin (thanks !!!!) Platforms tested: F23 Flag Day: no Doc impact: no
commit 73ff835f29514e33433de9f2be74f73efe6943ce Author: Thierry Bordaz <[email protected]> Date: Mon Jul 18 18:30:28 2016 +0200 Ticket 48928 log of page result cookie should log empty cookie with a different value than 0 Bug Description: With the ticket https://fedorahosted.org/389/ticket/48752, the cookie value is logged with each page result RESULT. When the page result is completed (no more entry to return), the returned cookie is 'pr_cookie=0'. Else the cookie value is logged 'pr_cookie=<internal index>'. Unfortunately the index ranges [0..N]. So when the value pr_cookie=0 is logged, it is not possible to know if it is an empty cookie or a valid cookie with the value 0. Fix Description: Log the empty cookie with a value '-1' https://fedorahosted.org/389/ticket/48928 Reviewed by: Noriko Hosoi, Simon Pichugin (thanks !!!!) Platforms tested: F23 Flag Day: no Doc impact: no diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c index 07a7b6920..6fec344be 100644 --- a/ldap/servers/slapd/pagedresults.c +++ b/ldap/servers/slapd/pagedresults.c @@ -247,7 +247,7 @@ pagedresults_set_response_control( Slapi_PBlock *pb, int iscritical, /* begin sequence, payload, end sequence */ if (current_search_count < 0) { - cookie = 0; + cookie = -1; cookie_str = slapi_ch_strdup(""); } else { cookie = index;
0
9c36be0540beebaca2be300b53c63b1c238ba4a7
389ds/389-ds-base
Ticket 505 - use lock-free access name2asi and oid2asi table Bug Description: there is a high contention on the attr syntax locks triggered by syntax lookups for attribute types Fix Description: this fix does not provide a lock free hash table or change in the hash table implemenmtation. It addresses the issue by reducing the syntax lookups as far as possible. syntax lookups are either done at attribute initialization or during dn normalization when is_dn_syntax is checked. The areas changed are: - attribute initialization from str2entry_fast. The syntax fields are not initialized, this is done on demand when a_*plugin or a_flags is used. This allows the removal of the hashtable lookups and the global lock in str2entry_fast - reduce dn normalization. When reading an entry from the database all attributes with dn syntax are already normalized. No check cor dn syntax and dn normalization required - reuse srdn. In entryrdn_lookup_dn a Slapi_RDN is built from the entryrdn index, this can be reused to initialize the rdn of the entry, no further dn explode or normalize required. https://fedorahosted.org/389/ticket/505 Reviewed by: nhosoi (Thanks Noriko)
commit 9c36be0540beebaca2be300b53c63b1c238ba4a7 Author: Ludwig Krispenz <[email protected]> Date: Mon Dec 17 19:45:11 2012 +0100 Ticket 505 - use lock-free access name2asi and oid2asi table Bug Description: there is a high contention on the attr syntax locks triggered by syntax lookups for attribute types Fix Description: this fix does not provide a lock free hash table or change in the hash table implemenmtation. It addresses the issue by reducing the syntax lookups as far as possible. syntax lookups are either done at attribute initialization or during dn normalization when is_dn_syntax is checked. The areas changed are: - attribute initialization from str2entry_fast. The syntax fields are not initialized, this is done on demand when a_*plugin or a_flags is used. This allows the removal of the hashtable lookups and the global lock in str2entry_fast - reduce dn normalization. When reading an entry from the database all attributes with dn syntax are already normalized. No check cor dn syntax and dn normalization required - reuse srdn. In entryrdn_lookup_dn a Slapi_RDN is built from the entryrdn index, this can be reused to initialize the rdn of the entry, no further dn explode or normalize required. https://fedorahosted.org/389/ticket/505 Reviewed by: nhosoi (Thanks Noriko) diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c index 73892bff2..63142f5fa 100644 --- a/ldap/servers/slapd/attr.c +++ b/ldap/servers/slapd/attr.c @@ -229,6 +229,34 @@ slapi_attr_init(Slapi_Attr *a, const char *type) return slapi_attr_init_locking_optional(a, type, PR_TRUE); } +int +slapi_attr_init_syntax(Slapi_Attr *a) +{ + int rc = 1; + struct asyntaxinfo *asi = NULL; + char *tmp = 0; + const char *basetype= NULL; + char buf[SLAPD_TYPICAL_ATTRIBUTE_NAME_MAX_LENGTH]; + + basetype = buf; + tmp = slapi_attr_basetype(a->a_type, buf, sizeof(buf)); + if (tmp) { + basetype = buf; + } + asi = attr_syntax_get_by_name_with_default (basetype); + if (asi) { + rc = 0; + a->a_plugin = asi->asi_plugin; + a->a_flags = asi->asi_flags; + a->a_mr_eq_plugin = asi->asi_mr_eq_plugin; + a->a_mr_ord_plugin = asi->asi_mr_ord_plugin; + a->a_mr_sub_plugin = asi->asi_mr_sub_plugin; + } + if (tmp) + slapi_ch_free_string(&tmp); + return rc; +} + Slapi_Attr * slapi_attr_init_locking_optional(Slapi_Attr *a, const char *type, PRBool use_lock) { @@ -319,6 +347,20 @@ slapi_attr_init_locking_optional(Slapi_Attr *a, const char *type, PRBool use_loc return a; } +Slapi_Attr * +slapi_attr_init_nosyntax(Slapi_Attr *a, const char *type) +{ + + a->a_type = slapi_ch_strdup(type); + slapi_valueset_init(&a->a_present_values); + slapi_valueset_init(&a->a_deleted_values); + a->a_listtofree= NULL; + a->a_deletioncsn= NULL; + a->a_next= NULL; + + return a; +} + Slapi_Attr * slapi_attr_dup(const Slapi_Attr *attr) { @@ -410,6 +452,9 @@ slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v ) return( -1 ); } + if ( a->a_flags == 0 && a->a_plugin == NULL ) { + slapi_attr_init_syntax (a); + } ava.ava_type = a->a_type; ava.ava_value = *v; if (a->a_flags & SLAPI_ATTR_FLAG_NORMALIZED) { @@ -521,6 +566,9 @@ attr_get_present_values(const Slapi_Attr *a) int slapi_attr_get_flags( const Slapi_Attr *a, unsigned long *flags ) { + if ( a->a_flags == 0 && a->a_plugin == NULL ) { + slapi_attr_init_syntax (a); + } *flags = a->a_flags; return( 0 ); } @@ -528,6 +576,9 @@ slapi_attr_get_flags( const Slapi_Attr *a, unsigned long *flags ) int slapi_attr_flag_is_set( const Slapi_Attr *a, unsigned long flag ) { + if ( a->a_flags == 0 && a->a_plugin == NULL ) { + slapi_attr_init_syntax (a); + } return( a->a_flags & flag ); } @@ -536,6 +587,9 @@ slapi_attr_value_cmp( const Slapi_Attr *a, const struct berval *v1, const struct { int retVal; + if ( a->a_flags == 0 && a->a_plugin == NULL ) { + slapi_attr_init_syntax (a); + } if ( a->a_flags & SLAPI_ATTR_FLAG_CMP_BITBYBIT ) { int cmplen = ( v1->bv_len <= v2->bv_len ? v1->bv_len : v2->bv_len ); @@ -577,6 +631,9 @@ slapi_attr_value_cmp_ext(const Slapi_Attr *a, Slapi_Value *v1, Slapi_Value *v2) int retVal; const struct berval *bv2 = slapi_value_get_berval(v2); + if ( a->a_flags == 0 && a->a_plugin == NULL ) { + slapi_attr_init_syntax (a); + } if ( a->a_flags & SLAPI_ATTR_FLAG_CMP_BITBYBIT ) { const struct berval *bv1 = slapi_value_get_berval(v1); diff --git a/ldap/servers/slapd/attrlist.c b/ldap/servers/slapd/attrlist.c index e365f3d58..1f52bb874 100644 --- a/ldap/servers/slapd/attrlist.c +++ b/ldap/servers/slapd/attrlist.c @@ -87,6 +87,23 @@ attrlist_find_or_create_locking_optional(Slapi_Attr **alist, const char *type, S } return rc; } +int +attrlist_append_nosyntax_init(Slapi_Attr **alist, const char *type, Slapi_Attr ***a) +{ + int rc= 0; /* found */ + if ( *a==NULL ) + { + for ( *a = alist; **a != NULL; *a = &(**a)->a_next ); + } + + if( **a==NULL ) + { + **a = slapi_attr_new(); + slapi_attr_init_nosyntax(**a, type); + rc= 1; /* created */ + } + return rc; +} /* * attrlist_merge - merge the given type and value with the list of diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c index d7e4d04f4..8f360d32b 100644 --- a/ldap/servers/slapd/attrsyntax.c +++ b/ldap/servers/slapd/attrsyntax.c @@ -280,6 +280,15 @@ attr_syntax_get_by_name(const char *name) return attr_syntax_get_by_name_locking_optional(name, PR_TRUE); } +struct asyntaxinfo * +attr_syntax_get_by_name_with_default(const char *name) +{ +struct asyntaxinfo *asi = NULL; + asi = attr_syntax_get_by_name_locking_optional(name, PR_TRUE); + if (asi == NULL) + asi = attr_syntax_get_by_name(ATTR_WITH_OCTETSTRING_SYNTAX); + return asi; +} /* * A version of attr_syntax_get_by_name() that allows you to bypass using @@ -804,6 +813,9 @@ slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr) const char *syntaxoid = NULL; int dn_syntax = 0; /* not DN, by default */ + if ( attr->a_plugin == NULL ) { + slapi_attr_init_syntax (attr); + } if (attr && attr->a_plugin) { /* If not set, there is no way to get the info */ if ((syntaxoid = attr_get_syntax_oid(attr))) { dn_syntax = ((0 == strcmp(syntaxoid, NAMEANDOPTIONALUID_SYNTAX_OID)) diff --git a/ldap/servers/slapd/back-ldbm/id2entry.c b/ldap/servers/slapd/back-ldbm/id2entry.c index 4d9c1118a..dae558cb2 100644 --- a/ldap/servers/slapd/back-ldbm/id2entry.c +++ b/ldap/servers/slapd/back-ldbm/id2entry.c @@ -367,6 +367,7 @@ id2entry( backend *be, ID id, back_txn *txn, int *err ) ee = slapi_str2entry( data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN ); } else { char *normdn = NULL; + Slapi_RDN * srdn = NULL; struct backdn *bdn = dncache_find_id(&inst->inst_dncache, id); if (bdn) { normdn = slapi_ch_strdup(slapi_sdn_get_dn(bdn->dn_sdn)); @@ -375,7 +376,7 @@ id2entry( backend *be, ID id, back_txn *txn, int *err ) CACHE_RETURN(&inst->inst_dncache, &bdn); } else { Slapi_DN *sdn = NULL; - rc = entryrdn_lookup_dn(be, rdn, id, &normdn, txn); + rc = entryrdn_lookup_dn(be, rdn, id, &normdn, &srdn, txn); if (rc) { slapi_log_error(SLAPI_LOG_TRACE, ID2ENTRY, "id2entry: entryrdn look up failed " @@ -402,10 +403,11 @@ id2entry( backend *be, ID id, back_txn *txn, int *err ) "and set to dn cache (id %d)\n", normdn, id); } } - ee = slapi_str2entry_ext( (const char *)normdn, data.dptr, + ee = slapi_str2entry_ext( (const char *)normdn, (const Slapi_RDN *)srdn, data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN ); slapi_ch_free_string(&rdn); slapi_ch_free_string(&normdn); + slapi_rdn_free(&srdn); } } else { ee = slapi_str2entry( data.dptr, 0 ); diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c index 60dbb5f8b..54f815971 100644 --- a/ldap/servers/slapd/back-ldbm/import-threads.c +++ b/ldap/servers/slapd/back-ldbm/import-threads.c @@ -543,7 +543,7 @@ import_producer(void *param) } normdn = slapi_create_dn_string("%s", dn); slapi_ch_free_string(&dn); - e = slapi_str2entry_ext(normdn, estr, + e = slapi_str2entry_ext(normdn, NULL, estr, flags|SLAPI_STR2ENTRY_NO_ENTRYDN); slapi_ch_free_string(&normdn); } else { @@ -1046,7 +1046,7 @@ index_producer(void *param) CACHE_RETURN(&inst->inst_dncache, &bdn); } else { Slapi_DN *sdn = NULL; - rc = entryrdn_lookup_dn(be, rdn, temp_id, &normdn, NULL); + rc = entryrdn_lookup_dn(be, rdn, temp_id, &normdn, NULL, NULL); if (rc) { /* We cannot use the entryrdn index; * Compose dn from the entries in id2entry */ @@ -1103,7 +1103,7 @@ index_producer(void *param) "entryrdn_lookup_dn returned: %s, " "and set to dn cache\n", normdn); } - e = slapi_str2entry_ext(normdn, data.dptr, + e = slapi_str2entry_ext(normdn, NULL, data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN); slapi_ch_free_string(&rdn); } @@ -1408,7 +1408,7 @@ upgradedn_producer(void *param) CACHE_RETURN(&inst->inst_dncache, &bdn); } else { rc = entryrdn_lookup_dn(be, rdn, temp_id, - (char **)&normdn, NULL); + (char **)&normdn, NULL, NULL); if (rc) { /* We cannot use the entryrdn index; * Compose dn from the entries in id2entry */ @@ -1465,7 +1465,7 @@ upgradedn_producer(void *param) "entryrdn_lookup_dn returned: %s, " "and set to dn cache\n", normdn); } - e = slapi_str2entry_ext(normdn, data.dptr, + e = slapi_str2entry_ext(normdn, NULL, data.dptr, SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT); slapi_ch_free_string(&rdn); } @@ -3567,7 +3567,7 @@ import_get_and_add_parent_rdns(ImportWorkerInfo *info, "from Slapi_RDN\n", rdn, id); goto bail; } - e = slapi_str2entry_ext(normdn, data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN); + e = slapi_str2entry_ext(normdn, NULL, data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN); (*curr_entry)++; rc = index_set_entry_to_fifo(info, e, id, total_id, *curr_entry); if (rc) { diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c index 82806db98..d54d2a8ad 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c @@ -1162,6 +1162,7 @@ entryrdn_lookup_dn(backend *be, const char *rdn, ID id, char **dn, + Slapi_RDN **psrdn, back_txn *txn) { int rc = -1; @@ -1192,6 +1193,7 @@ entryrdn_lookup_dn(backend *be, } *dn = NULL; + if (psrdn) *psrdn = NULL; /* Open the entryrdn index */ rc = _entryrdn_open_index(be, &ai, &db); if (rc || (NULL == db)) { @@ -1348,7 +1350,11 @@ bail: } /* it is guaranteed that db is not NULL. */ dblayer_release_index_file(be, ai, db); - slapi_rdn_free(&srdn); + if (psrdn) { + *psrdn = srdn; + } else { + slapi_rdn_free(&srdn); + } slapi_ch_free_string(&nrdn); slapi_ch_free_string(&keybuf); slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG, diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c index 957ebf5dd..8ef1d5709 100644 --- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c +++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c @@ -1484,7 +1484,7 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb ) } else { int myrc = 0; Slapi_DN *sdn = NULL; - rc = entryrdn_lookup_dn(be, rdn, temp_id, &dn, NULL); + rc = entryrdn_lookup_dn(be, rdn, temp_id, &dn, NULL, NULL); if (rc) { /* We cannot use the entryrdn index; * Compose dn from the entries in id2entry */ @@ -1544,7 +1544,7 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb ) "and set to dn cache\n", dn); } } - ep->ep_entry = slapi_str2entry_ext( dn, data.dptr, + ep->ep_entry = slapi_str2entry_ext( dn, NULL, data.dptr, str2entry_options | SLAPI_STR2ENTRY_NO_ENTRYDN ); slapi_ch_free_string(&rdn); } @@ -2065,7 +2065,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb) } else { int myrc = 0; Slapi_DN *sdn = NULL; - rc = entryrdn_lookup_dn(be, rdn, temp_id, &dn, NULL); + rc = entryrdn_lookup_dn(be, rdn, temp_id, &dn, NULL, NULL); if (rc) { /* We cannot use the entryrdn index; * Compose dn from the entries in id2entry */ @@ -2133,7 +2133,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb) } } slapi_rdn_done(&psrdn); - ep->ep_entry = slapi_str2entry_ext( dn, data.dptr, + ep->ep_entry = slapi_str2entry_ext( dn, NULL, data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN ); slapi_ch_free_string(&rdn); } @@ -3307,7 +3307,7 @@ _get_and_add_parent_rdns(backend *be, "(rdn: %s, ID: %d) from Slapi_RDN\n", rdn, id); goto bail; } - ep->ep_entry = slapi_str2entry_ext( dn, data.dptr, + ep->ep_entry = slapi_str2entry_ext( dn, NULL, data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN ); ep->ep_id = id; slapi_ch_free_string(&dn); @@ -3437,7 +3437,7 @@ _export_or_index_parents(ldbm_instance *inst, if (!bdn) { /* we put pdn to dn cache, which could be used * in _get_and_add_parent_rdns */ - rc = entryrdn_lookup_dn(be, prdn, pid, &pdn, NULL); + rc = entryrdn_lookup_dn(be, prdn, pid, &pdn, NULL, NULL); if (0 == rc) { int myrc = 0; /* pdn is put in DN cache. No need to free it here, diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h index 7cbaff70a..f9c2c05b4 100644 --- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -704,6 +704,6 @@ int entryrdn_index_read_ext(backend *be, const Slapi_DN *sdn, ID *id, int flags, back_txn *txn); int entryrdn_rename_subtree(backend *be, const Slapi_DN *oldsdn, Slapi_RDN *newsrdn, const Slapi_DN *newsupsdn, ID id, back_txn *txn); int entryrdn_get_subordinates(backend *be, const Slapi_DN *sdn, ID id, IDList **subordinates, back_txn *txn); -int entryrdn_lookup_dn(backend *be, const char *rdn, ID id, char **dn, back_txn *txn); +int entryrdn_lookup_dn(backend *be, const char *rdn, ID id, char **dn, Slapi_RDN **psrdn, back_txn *txn); int entryrdn_get_parent(backend *be, const char *rdn, ID id, char **prdn, ID *pid, back_txn *txn); #endif diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c index 675f323c2..e30f03b93 100644 --- a/ldap/servers/slapd/entry.c +++ b/ldap/servers/slapd/entry.c @@ -178,7 +178,7 @@ str2entry_state_information_from_type(char *s,CSNSet **csnset,CSN **attributedel /* rawdn is not consumed. Caller needs to free it. */ static Slapi_Entry * -str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) +str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, int read_stateinfo ) { Slapi_Entry *e; char *next, *ptype=NULL; @@ -227,7 +227,9 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) /* get the read lock of name2asi for performance purpose. It reduces read locking by per-entry lock, instead of per-attribute. */ - attr_syntax_read_lock(); + /* attr_syntax_read_lock(); + * no longer needed since attr syntax is not initialized + */ while ( (s = ldif_getline( &next )) != NULL && attr_val_cnt < ENTRY_MAX_ATTRIBUTE_VALUE_COUNT ) @@ -310,7 +312,10 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) slapi_entry_set_normdn(e, normdn); } if ( NULL == slapi_entry_get_rdn_const( e )) { - if (normdn) { + if (srdn) { + /* we can use the rdn generated in entryrdn_lookup_dn */ + slapi_entry_set_srdn ( e, srdn ); + }else if (normdn) { /* normdn is just referred in slapi_entry_set_rdn. */ slapi_entry_set_rdn(e, normdn); } else { @@ -403,9 +408,9 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) e->e_uniqueid, value.bv_val, 0); }else{ /* name2asi will be locked in slapi_entry_set_uniqueid */ - attr_syntax_unlock_read(); + /* attr_syntax_unlock_read(); */ slapi_entry_set_uniqueid (e, PL_strndup(value.bv_val, value.bv_len)); - attr_syntax_read_lock(); + /* attr_syntax_read_lock();*/ } /* the memory below was not allocated by the slapi_ch_ functions */ if (freeval) slapi_ch_free_string(&value.bv_val); @@ -426,7 +431,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) switch(attr_state) { case ATTRIBUTE_PRESENT: - if(attrlist_find_or_create_locking_optional(&e->e_attrs, type.bv_val, &a, PR_FALSE)==0 /* Found */) + if(attrlist_append_nosyntax_init(&e->e_attrs, type.bv_val, &a)==0 /* Found */) { LDAPDebug (LDAP_DEBUG_ANY, "str2entry_fast: Error. Non-contiguous attribute values for %s\n", type.bv_val, 0, 0); PR_ASSERT(0); @@ -434,7 +439,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) } break; case ATTRIBUTE_DELETED: - if(attrlist_find_or_create_locking_optional(&e->e_deleted_attrs, type.bv_val, &a, PR_FALSE)==0 /* Found */) + if(attrlist_append_nosyntax_init(&e->e_deleted_attrs, type.bv_val, &a)==0 /* Found */) { LDAPDebug (LDAP_DEBUG_ANY, "str2entry_fast: Error. Non-contiguous deleted attribute values for %s\n", type.bv_val, 0, 0); PR_ASSERT(0); @@ -451,6 +456,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) /* moved the value setting code here to check Slapi_Attr 'a' * to retrieve the attribute syntax info */ svalue = value_new(NULL, CSN_TYPE_NONE, NULL); +#if 0 if (slapi_attr_is_dn_syntax_attr(*a)) { int rc = 0; char *dn_aval = NULL; @@ -483,6 +489,8 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) } else { slapi_value_set_berval(svalue, &value); } +#endif + slapi_value_set_berval(svalue, &value); /* the memory below was not allocated by the slapi_ch_ functions */ if (freeval) slapi_ch_free_string(&value.bv_val); svalue->v_csnset = valuecsnset; @@ -542,7 +550,9 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) } /* release read lock of name2asi, per-entry lock */ - attr_syntax_unlock_read(); + /* attr_syntax_unlock_read(); + * no longer locked since attr syntax is not initialized + */ /* If this is a tombstone, it requires a special treatment for rdn. */ if (e->e_flags & SLAPI_ENTRY_FLAG_TOMBSTONE) { @@ -1369,7 +1379,7 @@ slapi_str2entry( char *s, int flags ) } else { - e= str2entry_fast( NULL/*dn*/, s, flags, read_stateinfo ); + e= str2entry_fast( NULL/*dn*/, NULL/*rdn*/, s, flags, read_stateinfo ); } if (!e) return e; /* e == NULL */ @@ -1404,7 +1414,7 @@ slapi_str2entry( char *s, int flags ) * NOTE: the first arg "dn" should have been normalized before passing. */ Slapi_Entry * -slapi_str2entry_ext( const char *normdn, char *s, int flags ) +slapi_str2entry_ext( const char *normdn, const Slapi_RDN *srdn, char *s, int flags ) { Slapi_Entry *e; int read_stateinfo= ~( flags & SLAPI_STR2ENTRY_IGNORE_STATE ); @@ -1431,7 +1441,7 @@ slapi_str2entry_ext( const char *normdn, char *s, int flags ) } else { - e = str2entry_fast( normdn, s, + e = str2entry_fast( normdn, srdn, s, flags|SLAPI_STR2ENTRY_DN_NORMALIZED, read_stateinfo ); } if (!e) diff --git a/ldap/servers/slapd/plugin_syntax.c b/ldap/servers/slapd/plugin_syntax.c index 840fa7acf..5d1d6ccd9 100644 --- a/ldap/servers/slapd/plugin_syntax.c +++ b/ldap/servers/slapd/plugin_syntax.c @@ -134,6 +134,12 @@ plugin_call_syntax_filter_ava_sv( "=> plugin_call_syntax_filter_ava %s=%s\n", ava->ava_type, ava->ava_value.bv_val, 0 ); + if ( ( a->a_mr_eq_plugin == NULL ) && ( a->a_mr_ord_plugin == NULL ) && ( a->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + Slapi_Attr *t = a; + slapi_attr_init_syntax(t); + } + if ( ( a->a_mr_eq_plugin == NULL ) && ( a->a_mr_ord_plugin == NULL ) && ( a->a_plugin == NULL ) ) { LDAPDebug( LDAP_DEBUG_FILTER, "<= plugin_call_syntax_filter_ava no plugin for attr (%s)\n", @@ -242,6 +248,10 @@ plugin_call_syntax_filter_sub_sv( LDAPDebug( LDAP_DEBUG_FILTER, "=> plugin_call_syntax_filter_sub_sv\n", 0, 0, 0 ); + if ( ( a->a_mr_sub_plugin == NULL ) && ( a->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + slapi_attr_init_syntax(a); + } if ( ( a->a_mr_sub_plugin == NULL ) && ( a->a_plugin == NULL ) ) { LDAPDebug( LDAP_DEBUG_FILTER, "<= plugin_call_syntax_filter_sub_sv attribute (%s) has no substring matching rule or syntax plugin\n", @@ -397,7 +407,11 @@ slapi_entry_syntax_check( } i = slapi_entry_first_attr(e, &a); - + + if ( a && ( a->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + slapi_attr_init_syntax(a); + } while ((-1 != i) && a && (a->a_plugin != NULL)) { /* If no validate function is available for this type, just * assume that the value is valid. */ @@ -438,6 +452,10 @@ slapi_entry_syntax_check( prevattr = a; i = slapi_entry_next_attr(e, prevattr, &a); + if ( a && ( a->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + slapi_attr_init_syntax(a); + } } /* See if we need to set the error text in the pblock. */ @@ -605,6 +623,10 @@ slapi_attr_values2keys_sv_pb( LDAPDebug( LDAP_DEBUG_FILTER, "=> slapi_attr_values2keys_sv\n", 0, 0, 0 ); + if ( ( sattr->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + slapi_attr_init_syntax(sattr); + } switch (ftype) { case LDAP_FILTER_EQUALITY: @@ -773,6 +795,10 @@ slapi_attr_assertion2keys_ava_sv( LDAPDebug( LDAP_DEBUG_FILTER, "=> slapi_attr_assertion2keys_ava_sv\n", 0, 0, 0 ); + if ( ( sattr->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + slapi_attr_init_syntax(sattr); + } switch (ftype) { case LDAP_FILTER_EQUALITY: @@ -889,6 +915,10 @@ slapi_attr_assertion2keys_sub_sv( LDAPDebug( LDAP_DEBUG_FILTER, "=> slapi_attr_assertion2keys_sub_sv\n", 0, 0, 0 ); + if ( ( sattr->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + slapi_attr_init_syntax(sattr); + } if (sattr->a_mr_sub_plugin) { pi = sattr->a_mr_sub_plugin; @@ -945,6 +975,10 @@ slapi_attr_value_normalize_ext( if (!sattr) { sattr = slapi_attr_init(&myattr, type); } + if ( ( sattr->a_plugin == NULL ) ) { + /* could be lazy plugin initialization, get it now */ + slapi_attr_init_syntax(sattr); + } /* use the filter type to determine which matching rule to use */ switch (filter_type) { diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 3c83e3064..778b9160e 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -98,6 +98,7 @@ const char *attr_get_syntax_oid(const Slapi_Attr *attr); void attrlist_free(Slapi_Attr *alist); int attrlist_find_or_create(Slapi_Attr **alist, const char *type, Slapi_Attr ***a); int attrlist_find_or_create_locking_optional(Slapi_Attr **alist, const char *type, Slapi_Attr ***a, PRBool use_lock); +int attrlist_append_nosyntax_init(Slapi_Attr **alist, const char *type, Slapi_Attr ***a); void attrlist_merge( Slapi_Attr **alist, const char *type, struct berval **vals ); void attrlist_merge_valuearray( Slapi_Attr **alist, const char *type, Slapi_Value **vals ); int attrlist_delete( Slapi_Attr **attrs, const char *type ); @@ -131,6 +132,7 @@ void attr_syntax_all_clear_flag( unsigned long flag ); void attr_syntax_delete_all_not_flagged( unsigned long flag ); struct asyntaxinfo *attr_syntax_get_by_oid ( const char *oid ); struct asyntaxinfo *attr_syntax_get_by_name ( const char *name ); +struct asyntaxinfo *attr_syntax_get_by_name_with_default ( const char *name ); struct asyntaxinfo *attr_syntax_get_by_name_locking_optional ( const char *name, PRBool use_lock ); /* * Call attr_syntax_return() when you are done using a value returned diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index cc1d292b1..73ae477f1 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -844,9 +844,9 @@ void slapi_pblock_destroy( Slapi_PBlock *pb ); Slapi_Entry *slapi_str2entry( char *s, int flags ); /* - * Same as slapi_str2entry except passing dn as an argument + * Same as slapi_str2entry except passing optional dn and rdn structure as argument */ -Slapi_Entry *slapi_str2entry_ext( const char *dn, char *s, int flags ); +Slapi_Entry *slapi_str2entry_ext( const char *dn, const Slapi_RDN *srdn, char *s, int flags ); /*----------------------------- diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h index 7bd7f3eb1..b3888ef45 100644 --- a/ldap/servers/slapd/slapi-private.h +++ b/ldap/servers/slapd/slapi-private.h @@ -350,6 +350,8 @@ int entry_add_dncsn_ext(Slapi_Entry *entry, const CSN *csn, PRUint32 flags); /* attr.c */ Slapi_Attr *slapi_attr_init_locking_optional(Slapi_Attr *a, const char *type, PRBool use_lock); +Slapi_Attr *slapi_attr_init_nosyntax(Slapi_Attr *a, const char *type); +int slapi_attr_init_syntax(Slapi_Attr *a); int attr_set_csn( Slapi_Attr *a, const CSN *csn); int attr_set_deletion_csn( Slapi_Attr *a, const CSN *csn); const CSN *attr_get_deletion_csn(const Slapi_Attr *a);
0
e542902ae29495758a2e40efc4cec9182152d9a5
389ds/389-ds-base
Issue 4169 - UI - PF4 migration - database tables Description: Convert all the tables used by the database tab to PF4 relates: https://github.com/389ds/389-ds-base/issues/4169 Reviewed by: spichugi(Thanks!)
commit e542902ae29495758a2e40efc4cec9182152d9a5 Author: Mark Reynolds <[email protected]> Date: Tue Apr 6 15:42:16 2021 -0400 Issue 4169 - UI - PF4 migration - database tables Description: Convert all the tables used by the database tab to PF4 relates: https://github.com/389ds/389-ds-base/issues/4169 Reviewed by: spichugi(Thanks!) diff --git a/src/cockpit/389-console/src/database.jsx b/src/cockpit/389-console/src/database.jsx index cb10ebdb6..9b0378596 100644 --- a/src/cockpit/389-console/src/database.jsx +++ b/src/cockpit/389-console/src/database.jsx @@ -807,7 +807,7 @@ export class Database extends React.Component { const config = JSON.parse(content); let rows = []; for (let row of config.items) { - rows.push({"name": row}); + rows.push(row); } this.setState({ [suffix]: { @@ -837,7 +837,7 @@ export class Database extends React.Component { for (let item of config.items) { let index = item.attrs; let types = []; - let mrs = []; + let mrs = ""; if (index.nsindextype.length > 1) { types = index.nsindextype.join(', '); } else { @@ -851,9 +851,9 @@ export class Database extends React.Component { } } if (index.nssystemindex[0] == 'true') { - systemRows.push({'name': index.cn, 'types': [types], 'matchingrules': [mrs]}); + systemRows.push([index.cn[0], types, mrs]); } else { - rows.push({'name': index.cn, 'types': [types], 'matchingrules': [mrs]}); + rows.push([index.cn[0], types, mrs]); } } this.setState({ @@ -968,7 +968,7 @@ export class Database extends React.Component { const config = JSON.parse(content); let rows = []; for (let row of config.items) { - rows.push({"name": row}); + rows.push(row); } this.setState({ [suffix]: { @@ -1005,9 +1005,9 @@ export class Database extends React.Component { } } if (index.nssystemindex[0] == 'true') { - systemRows.push({'name': index.cn, 'types': [types], 'matchingrules': [mrs]}); + systemRows.push([index.cn[0], types, mrs]); } else { - rows.push({'name': index.cn, 'types': [types], 'matchingrules': [mrs]}); + rows.push([index.cn[0], types, mrs]); } } this.setState({ @@ -1075,7 +1075,7 @@ export class Database extends React.Component { const config = JSON.parse(content); let rows = []; for (let row of config.items) { - rows.push({'name': row[0], 'date': [row[1]], 'size': [row[2]], 'suffix': [row[3]]}); + rows.push([row[0], row[1], row[2], row[3]]); } this.setState({ LDIFRows: rows, @@ -1094,7 +1094,7 @@ export class Database extends React.Component { const config = JSON.parse(content); let rows = []; for (let row of config.items) { - rows.push({'name': row[0], 'date': [row[1]], 'size': [row[2]]}); + rows.push([row[0], row[1], row[2]]); } this.setState({ BackupRows: rows diff --git a/src/cockpit/389-console/src/ds.jsx b/src/cockpit/389-console/src/ds.jsx index ce50232b3..0cd0d7ecb 100644 --- a/src/cockpit/389-console/src/ds.jsx +++ b/src/cockpit/389-console/src/ds.jsx @@ -353,7 +353,7 @@ export class DSInstance extends React.Component { const config = JSON.parse(content); let rows = []; for (let row of config.items) { - rows.push({ name: row[0], date: [row[1]], size: [row[2]] }); + rows.push([row[0], row[1], row[2]]); } // Get the server version from the monitor cmd = ["dsconf", "-j", this.state.serverId, "monitor", "server"]; diff --git a/src/cockpit/389-console/src/dsModals.jsx b/src/cockpit/389-console/src/dsModals.jsx index a415cec24..765c385a8 100644 --- a/src/cockpit/389-console/src/dsModals.jsx +++ b/src/cockpit/389-console/src/dsModals.jsx @@ -11,7 +11,6 @@ import { ControlLabel, Form, Checkbox, - Spinner, Row, Col, } from "patternfly-react"; @@ -22,6 +21,7 @@ import { Modal, ModalVariant, // TextInput, + Spinner, noop } from "@patternfly/react-core"; @@ -503,7 +503,7 @@ export class CreateInstanceModal extends React.Component { createSpinner = ( <Row> <div className="ds-margin-top-lg ds-modal-spinner"> - <Spinner loading inline size="lg" /> + <Spinner size="lg" /> Creating instance... </div> </Row> @@ -807,7 +807,7 @@ export class SchemaReloadModal extends React.Component { spinner = ( <Row> <div className="ds-margin-top ds-modal-spinner"> - <Spinner loading inline size="md" /> + <Spinner size="lg" /> Reloading schema files... </div> </Row> @@ -865,6 +865,7 @@ export class ManageBackupsModal extends React.Component { showDelBackupSpinningModal: false, showBackupModal: false, backupSpinning: false, + refreshing: false, backupName: "", deleteBackup: "", errObj: {} @@ -937,11 +938,11 @@ export class ManageBackupsModal extends React.Component { }); } - showConfirmBackup(item) { + showConfirmBackup(name) { // call deleteLDIF this.setState({ showConfirmBackup: true, - backupName: item.name + backupName: name }); } @@ -952,10 +953,10 @@ export class ManageBackupsModal extends React.Component { }); } - showConfirmRestore(item) { + showConfirmRestore(name) { this.setState({ showConfirmRestore: true, - backupName: item.name + backupName: name }); } @@ -966,11 +967,11 @@ export class ManageBackupsModal extends React.Component { }); } - showConfirmBackupDelete(item) { + showConfirmBackupDelete(name) { // calls deleteBackup this.setState({ showConfirmBackupDelete: true, - backupName: item.name + backupName: name }); } @@ -1191,24 +1192,12 @@ export class ManageBackupsModal extends React.Component { } render() { - const { showModal, closeHandler, backups, reload, loadingBackup } = this.props; - - let backupSpinner = ""; - if (loadingBackup) { - backupSpinner = ( - <Row> - <div className="ds-margin-top-lg ds-modal-spinner"> - <Spinner loading inline size="lg" /> - Creating instance... - </div> - </Row> - ); - } + const { showModal, closeHandler, backups } = this.props; return ( <div> <Modal - variant={ModalVariant.small} + variant={ModalVariant.medium} title="Manage Backups" aria-labelledby="ds-modal" isOpen={showModal} @@ -1217,19 +1206,16 @@ export class ManageBackupsModal extends React.Component { <Button key="confirm" variant="primary" onClick={this.showBackupModal}> Create Backup </Button>, - <Button key="refresh" onClick={reload}> - Refresh Backups - </Button> ]} > <div className="ds-margin-top-xlg"> <BackupTable rows={backups} + key={backups} confirmRestore={this.showConfirmRestore} confirmDelete={this.showConfirmBackupDelete} /> </div> - {backupSpinner} </Modal> <BackupModal showModal={this.state.showBackupModal} diff --git a/src/cockpit/389-console/src/lib/database/attrEncryption.jsx b/src/cockpit/389-console/src/lib/database/attrEncryption.jsx index a93617a30..eec00a71e 100644 --- a/src/cockpit/389-console/src/lib/database/attrEncryption.jsx +++ b/src/cockpit/389-console/src/lib/database/attrEncryption.jsx @@ -5,9 +5,13 @@ import { EncryptedAttrTable } from "./databaseTables.jsx"; import { Row, Col, +} from "patternfly-react"; +import { Button, + // Form, + // FormGroup, noop -} from "patternfly-react"; +} from "@patternfly/react-core"; import PropTypes from "prop-types"; import { Typeahead } from "react-bootstrap-typeahead"; import { log_cmd } from "../tools.jsx"; @@ -31,10 +35,10 @@ export class AttrEncryption extends React.Component { this.delEncryptedAttr = this.delEncryptedAttr.bind(this); } - showConfirmAttrDelete (item) { + showConfirmAttrDelete (name) { this.setState({ showConfirmAttrDelete: true, - delAttr: item.name + delAttr: name }); } @@ -125,8 +129,9 @@ export class AttrEncryption extends React.Component { return ( <div className="ds-margin-top-lg"> <EncryptedAttrTable + key={this.props.rows} rows={this.props.rows} - loadModalHandler={this.showConfirmAttrDelete} + deleteAttr={this.showConfirmAttrDelete} /> <Row className="ds-margin-top"> <Col sm={6}> @@ -143,7 +148,7 @@ export class AttrEncryption extends React.Component { </Col> <Col sm={3} bsClass="ds-no-padding"> <Button - bsStyle="primary" + variant="primary" onClick={this.addEncryptedAttr} > Add Attribute diff --git a/src/cockpit/389-console/src/lib/database/backups.jsx b/src/cockpit/389-console/src/lib/database/backups.jsx index 8783e7e3a..647c82d01 100644 --- a/src/cockpit/389-console/src/lib/database/backups.jsx +++ b/src/cockpit/389-console/src/lib/database/backups.jsx @@ -182,11 +182,11 @@ export class Backups extends React.Component { }); } - showConfirmLDIFImport (item) { + showConfirmLDIFImport (name, suffix) { this.setState({ showConfirmLDIFImport: true, - ldifName: item.name, - ldifSuffix: item.suffix[0] + ldifName: name, + ldifSuffix: suffix }); } @@ -197,11 +197,11 @@ export class Backups extends React.Component { }); } - showConfirmLDIFDelete (item) { + showConfirmLDIFDelete (name) { // call deleteLDIF this.setState({ showConfirmLDIFDelete: true, - ldifName: item.name + ldifName: name }); } @@ -212,11 +212,11 @@ export class Backups extends React.Component { }); } - showConfirmBackup (item) { + showConfirmBackup (name) { // call deleteLDIF this.setState({ showConfirmBackup: true, - backupName: item.name, + backupName: name, }); } @@ -227,10 +227,10 @@ export class Backups extends React.Component { }); } - showConfirmRestore (item) { + showConfirmRestore (name) { this.setState({ showConfirmRestore: true, - backupName: item.name, + backupName: name, }); } @@ -241,11 +241,11 @@ export class Backups extends React.Component { }); } - showConfirmBackupDelete (item) { + showConfirmBackupDelete (name) { // calls deleteBackup this.setState({ showConfirmBackupDelete: true, - backupName: item.name, + backupName: name, }); } @@ -555,6 +555,7 @@ export class Backups extends React.Component { <TabPane eventKey={1}> <div className="ds-margin-top-xlg"> <BackupTable + key={this.props.backups} rows={this.props.backups} confirmRestore={this.showConfirmRestore} confirmDelete={this.showConfirmBackupDelete} @@ -581,6 +582,7 @@ export class Backups extends React.Component { <TabPane eventKey={2}> <div className="ds-margin-top-xlg"> <LDIFManageTable + key={this.props.ldifs} rows={this.props.ldifs} confirmImport={this.showConfirmLDIFImport} confirmDelete={this.showConfirmLDIFDelete} @@ -711,7 +713,7 @@ class ExportModal extends React.Component { spinner = <Row> <div className="ds-margin-top ds-modal-spinner"> - <Spinner loading inline size="md" />Exporting database... <font size="2">(You can safely close this window)</font> + <Spinner size="md" /> Exporting database... <font size="2">(You can safely close this window)</font> </div> </Row>; } @@ -736,20 +738,20 @@ class ExportModal extends React.Component { > <Form horizontal autoComplete="off"> <Row> - <Col sm={3}> + <Col sm={4}> <ControlLabel>Select Suffix</ControlLabel> </Col> - <Col sm={9}> + <Col sm={8}> <select id="ldifSuffix" onChange={handleChange}> {suffixList} </select> </Col> </Row> <Row className="ds-margin-top" title="Name of exported LDIF file, if left blank the data and time will be used as the file name"> - <Col sm={3}> + <Col sm={4}> <ControlLabel>LDIF File Name</ControlLabel> </Col> - <Col sm={9}> + <Col sm={8}> <FormControl type="text" id="ldifName" @@ -791,7 +793,7 @@ export class BackupModal extends React.Component { spinner = <Row> <div className="ds-margin-top ds-modal-spinner"> - <Spinner loading inline size="md" />Backing up databases... <font size="2">(You can safely close this window)</font> + <Spinner size="md" /> Backing up databases... <font size="2">(You can safely close this window)</font> </div> </Row>; } diff --git a/src/cockpit/389-console/src/lib/database/chaining.jsx b/src/cockpit/389-console/src/lib/database/chaining.jsx index 2b2f097c0..3c3718f54 100644 --- a/src/cockpit/389-console/src/lib/database/chaining.jsx +++ b/src/cockpit/389-console/src/lib/database/chaining.jsx @@ -508,7 +508,7 @@ export class ChainingDatabaseConfig extends React.Component { </div> </div> </div> - <h4 className="ds-margin-top ds-sub-header ds-center">Default Database Link Creation Settings</h4> + <h4 className="ds-margin-top-xlg ds-center">Default Database Link Creation Settings</h4> <hr /> <Form horizontal> <Row className="ds-margin-top"> diff --git a/src/cockpit/389-console/src/lib/database/databaseModal.jsx b/src/cockpit/389-console/src/lib/database/databaseModal.jsx index 46026267e..601e91940 100644 --- a/src/cockpit/389-console/src/lib/database/databaseModal.jsx +++ b/src/cockpit/389-console/src/lib/database/databaseModal.jsx @@ -197,7 +197,7 @@ class ExportModal extends React.Component { return ( <Modal - variant={ModalVariant.small} + variant={ModalVariant.medium} title="Export Database To LDIF File" isOpen={showModal} onClose={closeHandler} @@ -264,9 +264,9 @@ class ImportModal extends React.Component { </div> </Row>; } - for (let idx in rows) { - if (rows[idx].suffix == suffix) { - suffixRows.push(rows[idx]); + for (let row of rows) { + if (row[3] == suffix) { + suffixRows.push(row); } } diff --git a/src/cockpit/389-console/src/lib/database/databaseTables.jsx b/src/cockpit/389-console/src/lib/database/databaseTables.jsx index 533ea42c3..f8bef7040 100644 --- a/src/cockpit/389-console/src/lib/database/databaseTables.jsx +++ b/src/cockpit/389-console/src/lib/database/databaseTables.jsx @@ -1,14 +1,20 @@ import React from "react"; import { Button, - DropdownButton, - MenuItem, - actionHeaderCellFormatter, - sortableHeaderCellFormatter, - tableCellFormatter, + Pagination, + PaginationVariant, + SearchInput, noop -} from "patternfly-react"; -import { DSTable, DSShortTable } from "../dsTable.jsx"; +} from '@patternfly/react-core'; +import { + Table, + TableHeader, + TableBody, + TableVariant, + sortable, + SortByDirection, +} from '@patternfly/react-table'; +import TrashAltIcon from '@patternfly/react-icons/dist/js/icons/trash-alt-icon'; import PropTypes from "prop-types"; class ReferralTable extends React.Component { @@ -16,117 +22,112 @@ class ReferralTable extends React.Component { super(props); this.state = { - rowKey: "name", + page: 1, + perPage: 10, + value: '', + sortBy: {}, + rows: [], columns: [ - { - property: "name", - header: { - label: "Referral", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "actions", - header: { - label: "Actions", - props: { - index: 1, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 1 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.name[0]}> - <Button - bsStyle="primary" - onClick={() => { - this.props.loadModalHandler(rowData); - }} - > - Delete Referral - </Button> - </td> - ]; - } - ] - } - } - ] + { title: 'Referral', transforms: [sortable] }, + { props: { textCenter: true }, title: 'Delete Referral' }, + ], + }; + + this.onSetPage = (_event, pageNumber) => { + this.setState({ + page: pageNumber + }); + }; + + this.onPerPageSelect = (_event, perPage) => { + this.setState({ + perPage: perPage + }); }; - this.getColumns = this.getColumns.bind(this); - this.getSingleColumn = this.getSingleColumn.bind(this); + + this.onSort = this.onSort.bind(this); + this.getDeleteButton = this.getDeleteButton.bind(this); } - getSingleColumn () { - return [ - { - property: "msg", - header: { - label: "Referrals", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - ]; + getDeleteButton(name) { + return ( + <TrashAltIcon + className="ds-center" + onClick={() => { + this.props.deleteRef(name); + }} + title="Delete this referral" + /> + ); } - getColumns() { - return this.state.columns; + componentDidMount() { + let rows = []; + let columns = this.state.columns; + for (let refRow of this.props.rows) { + rows.push({ + cells: [refRow, { props: { textCenter: true }, title: this.getDeleteButton(refRow) }] + }); + } + if (rows.length == 0) { + rows = [{cells: ['No Referrals']}]; + columns = [{title: 'Referrals'}]; + } + this.setState({ + rows: rows, + columns: columns + }); } - render() { - let refTable; - if (this.props.rows.length == 0) { - refTable = <DSShortTable - getColumns={this.getSingleColumn} - rowKey={"msg"} - rows={[{msg: "No referrals"}]} - />; - } else { - refTable = <DSShortTable - getColumns={this.getColumns} - rowKey={this.state.rowKey} - rows={this.props.rows} - disableLoadingSpinner - />; + onSort(_event, index, direction) { + let rows = []; + let sortedRefs = [...this.props.rows]; + + // Sort the referrals and build the new rows + sortedRefs.sort(); + if (direction !== SortByDirection.asc) { + sortedRefs.reverse(); } + for (let refRow of sortedRefs) { + rows.push({ cells: [refRow, { props: { textCenter: true }, title: this.getDeleteButton(refRow) }] }); + } + + this.setState({ + sortBy: { + index, + direction + }, + rows: rows, + page: 1, + }); + } + + render() { + const { columns, rows, perPage, page, sortBy } = this.state; + return ( - <div> - {refTable} + <div className="ds-margin-top-lg"> + <Table + className="ds-margin-top" + aria-label="referral table" + cells={columns} + rows={rows} + variant={TableVariant.compact} + sortBy={sortBy} + onSort={this.onSort} + > + <TableHeader /> + <TableBody /> + </Table> + <Pagination + itemCount={this.props.rows.length} + widgetId="pagination-options-menu-bottom" + perPage={perPage} + page={page} + variant={PaginationVariant.bottom} + onSetPage={this.onSetPage} + onPerPageSelect={this.onPerPageSelect} + /> </div> ); } @@ -137,149 +138,144 @@ class IndexTable extends React.Component { super(props); this.state = { - searchField: "Indexes", - fieldsToSearch: ["name"], - rowKey: "name", + page: 1, + perPage: 10, + value: '', + sortBy: {}, + rows: [], columns: [ - { - property: "name", - header: { - label: "Attribute", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "types", - header: { - label: "Index Types", - props: { - index: 1, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 1 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "matchingrules", - header: { - label: "Matching Rules", - props: { - index: 2, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 2 - }, - formatters: [tableCellFormatter] - } - }, + { title: 'Attribute', transforms: [sortable] }, // name + { title: 'Indexing Types', transforms: [sortable] }, // types + { title: 'Matching Rules', transforms: [sortable] }, // matchingrules ], }; - if (this.props.editable) { - this.state.columns.push( - { - property: "actions", - header: { - props: { - index: 3, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 3 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.name[0]}> - <DropdownButton id={rowData.name[0]} - className="ds-action-button" - bsStyle="primary" title="Actions"> - <MenuItem eventKey="1" onClick={() => { - this.props.editIndex(rowData); - }} - > - Edit Index - </MenuItem> - <MenuItem eventKey="2" onClick={() => { - this.props.reindexIndex(rowData); - }} - > - Reindex Index - </MenuItem> - <MenuItem divider /> - <MenuItem eventKey="3" onClick={() => { - this.props.deleteIndex(rowData); - }} - > - Delete Index - </MenuItem> - </DropdownButton> - </td> - ]; - } - ] - } - } - ); - } - this.getColumns = this.getColumns.bind(this); - } // Constructor + this.onSetPage = (_event, pageNumber) => { + this.setState({ + page: pageNumber + }); + }; + + this.onPerPageSelect = (_event, perPage) => { + this.setState({ + perPage: perPage + }); + }; - getColumns() { - return this.state.columns; + this.onSort = this.onSort.bind(this); + this.onSearchChange = this.onSearchChange.bind(this); + } + + componentDidMount () { + // Copy the rows so we can handle sorting and searching + this.setState({rows: [...this.props.rows]}); + } + + actions() { + return [ + { + title: 'Edit Index', + onClick: (event, rowId, rowData, extra) => + this.props.editIndex(rowData) + }, + { + title: 'Reindex', + onClick: (event, rowId, rowData, extra) => + this.props.reindexIndex(rowData[0]) + }, + { + isSeparator: true + }, + { + title: 'Delete Index', + onClick: (event, rowId, rowData, extra) => + this.props.deleteIndex(rowData[0]) + } + ]; + } + + onSort(_event, index, direction) { + const sortedRows = this.state.rows.sort((a, b) => (a[index] < b[index] ? -1 : a[index] > b[index] ? 1 : 0)); + this.setState({ + sortBy: { + index, + direction + }, + rows: direction === SortByDirection.asc ? sortedRows : sortedRows.reverse() + }); + } + + onSearchChange(value, event) { + let rows = []; + let val = value.toLowerCase(); + for (let row of this.props.rows) { + if (val != "" && + row[0].indexOf(val) == -1 && + row[1].indexOf(val) == -1 && + row[2].indexOf(val) == -1) { + // Not a match, skip it + continue; + } + rows.push([row[0], row[1], row[2]]); + } + if (val == "") { + // reset rows + rows = [...this.props.rows]; + } + this.setState({ + rows: rows, + value: value, + page: 1, + }); } render() { + let rows = JSON.parse(JSON.stringify(this.state.rows)); // Deep copy + let columns = this.state.columns; + let has_rows = true; + let tableRows; + if (rows.length == 0) { + has_rows = false; + columns = [{title: 'Indexes'}]; + tableRows = [{cells: ['No Indexes']}]; + } else { + let startIdx = (this.state.perPage * this.state.page) - this.state.perPage; + tableRows = rows.splice(startIdx, this.state.perPage); + } return ( <div className="ds-margin-top-xlg"> - <DSTable - getColumns={this.getColumns} - fieldsToSearch={this.state.fieldsToSearch} - toolBarSearchField={this.state.searchField} - rowKey={this.state.rowKey} - rows={this.props.rows} - disableLoadingSpinner - toolBarPagination={[6, 12, 24, 48, 96]} - toolBarPaginationPerPage={6} + <SearchInput + className="ds-margin-top-xlg" + placeholder='Search indexes' + value={this.state.value} + onChange={this.onSearchChange} + onClear={(evt) => this.onSearchChange('', evt)} + /> + <Table + className="ds-margin-top" + aria-label="glue table" + cells={columns} + rows={tableRows} + variant={TableVariant.compact} + sortBy={this.state.sortBy} + onSort={this.onSort} + actions={has_rows && this.props.editable ? this.actions() : null} + dropdownPosition="right" + dropdownDirection="bottom" + > + <TableHeader /> + <TableBody /> + </Table> + <Pagination + itemCount={this.props.rows.length} + widgetId="pagination-options-menu-bottom" + perPage={this.state.perPage} + page={this.state.page} + variant={PaginationVariant.bottom} + onSetPage={this.onSetPage} + onPerPageSelect={this.onPerPageSelect} /> </div> - ); } } @@ -289,119 +285,112 @@ class EncryptedAttrTable extends React.Component { super(props); this.state = { - rowKey: "name", + page: 1, + perPage: 10, + value: '', + sortBy: {}, + rows: [], columns: [ - { - property: "name", - header: { - label: "Encrypted Attribute", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "actions", - header: { - label: "Actions", - props: { - index: 1, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 2 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.name[0]}> - <Button - bsStyle="primary" - onClick={() => { - this.props.loadModalHandler(rowData); - }} - > - Delete Attribute - </Button> - </td> - ]; - } - ] - } - } - ] + { title: 'Encrypted Attribute', transforms: [sortable] }, + { props: { textCenter: true }, title: 'Delete Attribute' }, + ], }; - this.getColumns = this.getColumns.bind(this); - this.getSingleColumn = this.getSingleColumn.bind(this); + + this.onSetPage = (_event, pageNumber) => { + this.setState({ + page: pageNumber + }); + }; + + this.onPerPageSelect = (_event, perPage) => { + this.setState({ + perPage: perPage + }); + }; + + this.onSort = this.onSort.bind(this); + this.getDeleteButton = this.getDeleteButton.bind(this); } - getSingleColumn () { - return [ - { - property: "msg", - header: { - label: "Encrypted Attributes", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - ]; + getDeleteButton(name) { + return ( + <TrashAltIcon + className="ds-center" + onClick={() => { + this.props.deleteAttr(name); + }} + title="Delete this attribute" + /> + ); } - getColumns() { - return this.state.columns; + componentDidMount() { + let rows = []; + let columns = this.state.columns; + for (let attrRow of this.props.rows) { + rows.push({ + cells: [attrRow, { props: { textCenter: true }, title: this.getDeleteButton(attrRow) }] + }); + } + if (rows.length == 0) { + rows = [{cells: ['No Attributes']}]; + columns = [{title: 'Encrypted Attribute'}]; + } + this.setState({ + rows: rows, + columns: columns + }); } - render() { - let attrTable; - if (this.props.rows.length == 0) { - attrTable = - <DSShortTable - getColumns={this.getSingleColumn} - rowKey={"msg"} - rows={[{msg: "No encrypted attributes"}]} - />; - } else { - attrTable = - <DSShortTable - getColumns={this.getColumns} - rowKey={this.state.rowKey} - rows={this.props.rows} - disableLoadingSpinner - />; + onSort(_event, index, direction) { + let rows = []; + let sortedAttrs = [...this.props.rows]; + + // Sort the referrals and build the new rows + sortedAttrs.sort(); + if (direction !== SortByDirection.asc) { + sortedAttrs.reverse(); + } + for (let attrRow of sortedAttrs) { + rows.push({ cells: [attrRow, { props: { textCenter: true }, title: this.getDeleteButton(attrRow) }] }); } + + this.setState({ + sortBy: { + index, + direction + }, + rows: rows, + page: 1, + }); + } + + render() { + const { columns, rows, perPage, page, sortBy } = this.state; + return ( - <div> - {attrTable} + <div className="ds-margin-top-lg"> + <Table + className="ds-margin-top" + aria-label="referral table" + cells={columns} + rows={rows} + variant={TableVariant.compact} + sortBy={sortBy} + onSort={this.onSort} + > + <TableHeader /> + <TableBody /> + </Table> + <Pagination + itemCount={this.props.rows.length} + widgetId="pagination-options-menu-bottom" + perPage={perPage} + page={page} + variant={PaginationVariant.bottom} + onSetPage={this.onSetPage} + onPerPageSelect={this.onPerPageSelect} + /> </div> ); } @@ -410,163 +399,126 @@ class EncryptedAttrTable extends React.Component { class LDIFTable extends React.Component { constructor(props) { super(props); + this.state = { - rowKey: "name", + page: 1, + perPage: 10, + value: '', + sortBy: {}, + rows: [], columns: [ - { - property: "name", - header: { - label: "LDIF File", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "date", - header: { - label: "Creation Date", - props: { - index: 1, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 1 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "size", - header: { - label: "Size", - props: { - index: 2, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 2 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "actions", - header: { - props: { - index: 3, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 3 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.name[0]}> - <Button - bsStyle="primary" - onClick={() => { - this.props.confirmImport(rowData); - }} - > - Import - </Button> - </td> - ]; - } - ] - } - } - ] + { title: 'LDIF File', transforms: [sortable] }, + { title: 'Creation Date', transforms: [sortable] }, + { title: 'File Size', transforms: [sortable] }, + { title: '' } + ], + }; + + this.onSetPage = (_event, pageNumber) => { + this.setState({ + page: pageNumber + }); + }; + + this.onPerPageSelect = (_event, perPage) => { + this.setState({ + perPage: perPage + }); }; - this.getColumns = this.getColumns.bind(this); - this.getSingleColumn = this.getSingleColumn.bind(this); + this.onSort = this.onSort.bind(this); + this.getImportButton = this.getImportButton.bind(this); } - getSingleColumn () { - return [ - { - property: "msg", - header: { - label: "LDIF Files", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - ]; + getImportButton(name) { + return ( + <Button + variant="primary" + onClick={() => { + this.props.confirmImport(name); + }} + title="Initialize the database with this LDIF file" + > + Import + </Button> + ); } - getColumns() { - return this.state.columns; + componentDidMount() { + let rows = []; + let columns = this.state.columns; + for (let ldifRow of this.props.rows) { + rows.push({ + cells: [ + ldifRow[0], ldifRow[1], ldifRow[2], + { props: { textCenter: true }, title: this.getImportButton(ldifRow[0]) } + ] + }); + } + if (rows.length == 0) { + rows = [{cells: ['No LDIF files']}]; + columns = [{title: 'LDIF File'}]; + } + this.setState({ + rows: rows, + columns: columns + }); } - render() { - let LDIFTable; - if (this.props.rows.length == 0) { - LDIFTable = <DSShortTable - getColumns={this.getSingleColumn} - rowKey={"msg"} - rows={[{msg: "No LDIF files"}]} - />; - } else { - LDIFTable = - <DSTable - noSearchBar - getColumns={this.getColumns} - rowKey={this.state.rowKey} - rows={this.props.rows} - toolBarPagination={[6, 12, 24, 48, 96]} - toolBarPaginationPerPage={6} - />; + onSort(_event, index, direction) { + let rows = []; + let sortedLDIF = [...this.props.rows]; + + // Sort the referrals and build the new rows + sortedLDIF.sort(); + if (direction !== SortByDirection.asc) { + sortedLDIF.reverse(); } + for (let ldifRow of sortedLDIF) { + rows.push({ cells: + [ + ldifRow[0], ldifRow[1], ldifRow[2], + { props: { textCenter: true }, title: this.getImportButton(ldifRow[0]) } + ] + }); + } + + this.setState({ + sortBy: { + index, + direction + }, + rows: rows, + page: 1, + }); + } + + render() { + const { columns, rows, perPage, page, sortBy } = this.state; + return ( - <div> - {LDIFTable} + <div className="ds-margin-top-lg"> + <Table + className="ds-margin-top" + aria-label="ldif table" + cells={columns} + rows={rows} + variant={TableVariant.compact} + sortBy={sortBy} + onSort={this.onSort} + > + <TableHeader /> + <TableBody /> + </Table> + <Pagination + itemCount={this.props.rows.length} + widgetId="pagination-options-menu-bottom" + perPage={perPage} + page={page} + variant={PaginationVariant.bottom} + onSetPage={this.onSetPage} + onPerPageSelect={this.onPerPageSelect} + /> </div> ); } @@ -577,193 +529,124 @@ class LDIFManageTable extends React.Component { super(props); this.state = { - rowKey: "name", + page: 1, + perPage: 10, + value: '', + sortBy: {}, + rows: [], columns: [ - { - property: "name", - header: { - label: "LDIF File", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "suffix", - header: { - label: "Suffix", - props: { - index: 1, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 1 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "date", - header: { - label: "Creation Date", - props: { - index: 2, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 2 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "size", - header: { - label: "Size", - props: { - index: 3, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 3 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "actions", - header: { - props: { - index: 4, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 4 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.name[0]}> - <DropdownButton id={rowData.name[0]} - className="ds-action-button" - bsStyle="primary" title="Actions"> - <MenuItem eventKey="1" onClick={() => { - this.props.confirmImport(rowData); - }} - > - Import LDIF File - </MenuItem> - - <MenuItem divider /> - <MenuItem eventKey="3" onClick={() => { - this.props.confirmDelete(rowData); - }} - > - Delete LDIF File - </MenuItem> - </DropdownButton> - </td> - ]; - } - ] - } - } + { title: 'LDIF File', transforms: [sortable] }, + { title: 'Suffix', transforms: [sortable] }, + { title: 'Creation Date', transforms: [sortable] }, + { title: 'File Size', transforms: [sortable] }, ], }; - this.getColumns = this.getColumns.bind(this); - this.getSingleColumn = this.getSingleColumn.bind(this); - } // Constructor + this.onSetPage = (_event, pageNumber) => { + this.setState({ + page: pageNumber + }); + }; + + this.onPerPageSelect = (_event, perPage) => { + this.setState({ + perPage: perPage + }); + }; + + this.onSort = this.onSort.bind(this); + } + + componentDidMount() { + let rows = []; + let columns = this.state.columns; + for (let ldifRow of this.props.rows) { + rows.push({ + cells: [ldifRow[0], ldifRow[3], ldifRow[1], ldifRow[2]] + }); + } + if (rows.length == 0) { + rows = [{cells: ['No LDIF files']}]; + columns = [{title: 'LDIF File'}]; + } + this.setState({ + rows: rows, + columns: columns + }); + } - getColumns() { - return this.state.columns; + onSort(_event, index, direction) { + let rows = []; + let sortedLDIF = [...this.props.rows]; + + // Sort the referrals and build the new rows + sortedLDIF.sort(); + if (direction !== SortByDirection.asc) { + sortedLDIF.reverse(); + } + for (let ldifRow of sortedLDIF) { + rows.push({ + cells: [ldifRow[0], ldifRow[3], ldifRow[1], ldifRow[2]] + }); + } + + this.setState({ + sortBy: { + index, + direction + }, + rows: rows, + page: 1, + }); } - getSingleColumn () { + actions() { return [ { - property: "msg", - header: { - label: "LDIF Files", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } + title: 'Import LDIF', + onClick: (event, rowId, rowData, extra) => + this.props.confirmImport(rowData.cells[0], rowData.cells[1]) + }, + { + title: 'Delete LDIF', + onClick: (event, rowId, rowData, extra) => + this.props.confirmDelete(rowData.cells[0]) }, ]; } render() { - let LDIFTable; + const { columns, rows, perPage, page, sortBy } = this.state; + let hasRows = true; if (this.props.rows.length == 0) { - LDIFTable = <DSShortTable - getColumns={this.getSingleColumn} - rowKey={"msg"} - rows={[{msg: "No LDIF files"}]} - />; - } else { - LDIFTable = - <DSTable - noSearchBar - getColumns={this.getColumns} - rowKey={this.state.rowKey} - rows={this.props.rows} - toolBarPagination={[6, 12, 24, 48, 96]} - toolBarPaginationPerPage={6} - />; + hasRows = false; } return ( - <div> - {LDIFTable} + <div className="ds-margin-top-lg"> + <Table + className="ds-margin-top" + aria-label="manage ldif table" + cells={columns} + rows={rows} + variant={TableVariant.compact} + sortBy={sortBy} + onSort={this.onSort} + actions={hasRows ? this.actions() : null} + dropdownPosition="right" + dropdownDirection="bottom" + > + <TableHeader /> + <TableBody /> + </Table> + <Pagination + itemCount={this.props.rows.length} + widgetId="pagination-options-menu-bottom" + perPage={perPage} + page={page} + variant={PaginationVariant.bottom} + onSetPage={this.onSetPage} + onPerPageSelect={this.onPerPageSelect} + /> </div> ); } @@ -774,351 +657,250 @@ class BackupTable extends React.Component { super(props); this.state = { - rowKey: "name", + page: 1, + perPage: 10, + value: '', + sortBy: {}, + rows: [], columns: [ - { - property: "name", - header: { - label: "Backup", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "date", - header: { - label: "Creation Date", - props: { - index: 1, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 1 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "size", - header: { - label: "Size", - props: { - index: 2, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 2 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "actions", - header: { - props: { - index: 3, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 3 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.name[0]}> - <DropdownButton id={rowData.name[0]} - className="ds-action-button" - bsStyle="primary" title="Actions"> - <MenuItem eventKey="1" onClick={() => { - this.props.confirmRestore(rowData); - }} - > - Restore Backup - </MenuItem> - - <MenuItem divider /> - <MenuItem eventKey="3" onClick={() => { - this.props.confirmDelete(rowData); - }} - > - Delete Backup - </MenuItem> - </DropdownButton> - </td> - ]; - } - ] - } - } + { title: 'Backup', transforms: [sortable] }, + { title: 'Creation Date', transforms: [sortable] }, + { title: 'Size', transforms: [sortable] }, ], }; - this.getColumns = this.getColumns.bind(this); - this.getSingleColumn = this.getSingleColumn.bind(this); - } // Constructor + this.onSetPage = (_event, pageNumber) => { + this.setState({ + page: pageNumber + }); + }; + + this.onPerPageSelect = (_event, perPage) => { + this.setState({ + perPage: perPage + }); + }; + + this.onSort = this.onSort.bind(this); + } + + componentDidMount() { + let rows = []; + let columns = this.state.columns; + for (let bakRow of this.props.rows) { + rows.push({ + cells: [bakRow[0], bakRow[1], bakRow[2]] + }); + } + if (rows.length == 0) { + rows = [{cells: ['No Backups']}]; + columns = [{title: 'Backups'}]; + } + this.setState({ + rows: rows, + columns: columns + }); + } + + onSort(_event, index, direction) { + let rows = []; + let sortedBaks = [...this.props.rows]; + + // Sort the referrals and build the new rows + sortedBaks.sort(); + if (direction !== SortByDirection.asc) { + sortedBaks.reverse(); + } + for (let bakRow of sortedBaks) { + rows.push({ + cells: [bakRow[0], bakRow[1], bakRow[2]] + }); + } - getColumns() { - return this.state.columns; + this.setState({ + sortBy: { + index, + direction + }, + rows: rows, + page: 1, + }); } - getSingleColumn () { + actions() { return [ { - property: "msg", - header: { - label: "Backup", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } + title: 'Restore Backup', + onClick: (event, rowId, rowData, extra) => + this.props.confirmRestore(rowData.cells[0]) + }, + { + title: 'Delete Backup', + onClick: (event, rowId, rowData, extra) => + this.props.confirmDelete(rowData.cells[0]) }, ]; } render() { - let backupTable; + const { columns, rows, perPage, page, sortBy } = this.state; + let hasRows = true; if (this.props.rows.length == 0) { - backupTable = <DSShortTable - getColumns={this.getSingleColumn} - rowKey={"msg"} - rows={[{msg: "No Backups"}]} - />; - } else { - backupTable = - <DSTable - id="backupTable" - noSearchBar - getColumns={this.getColumns} - rowKey={this.state.rowKey} - rows={this.props.rows} - toolBarPagination={[6, 12, 24, 48, 96]} - toolBarPaginationPerPage={6} - />; + hasRows = false; } return ( - <div> - {backupTable} + <div className="ds-margin-top-lg"> + <Table + className="ds-margin-top" + aria-label="backup table" + cells={columns} + rows={rows} + variant={TableVariant.compact} + sortBy={sortBy} + onSort={this.onSort} + actions={hasRows ? this.actions() : null} + dropdownPosition="right" + dropdownDirection="bottom" + > + <TableHeader /> + <TableBody /> + </Table> + <Pagination + itemCount={this.props.rows.length} + widgetId="pagination-options-menu-bottom" + perPage={perPage} + page={page} + variant={PaginationVariant.bottom} + onSetPage={this.onSetPage} + onPerPageSelect={this.onPerPageSelect} + /> </div> ); } } -export class PwpTable extends React.Component { +class PwpTable extends React.Component { constructor(props) { super(props); this.state = { - rowKey: "targetdn", + page: 1, + perPage: 10, + value: '', + sortBy: {}, + rows: [], columns: [ - { - property: "targetdn", - header: { - label: "Target DN", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "pwp_type", - header: { - label: "Policy Type", - props: { - index: 1, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 1 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "basedn", - header: { - label: "Suffix", - props: { - index: 2, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 2 - }, - formatters: [tableCellFormatter] - } - }, - - { - property: "actions", - header: { - props: { - index: 3, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 3 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.targetdn}> - <DropdownButton id={rowData.targetdn} - className="ds-action-button" - bsStyle="primary" title="Actions"> - <MenuItem eventKey="1" onClick={() => { - this.props.editPolicy( - rowData.targetdn, - ); - }} - > - Edit Policy - </MenuItem> - <MenuItem divider /> - <MenuItem eventKey="2" onClick={() => { - this.props.deletePolicy(rowData.targetdn); - }} - > - Delete Policy - </MenuItem> - </DropdownButton> - </td> - ]; - } - ] - } - } + { title: 'Target DN', transforms: [sortable] }, + { title: 'Policy Type', transforms: [sortable] }, + { title: 'Database Suffix', transforms: [sortable] }, ], }; - this.getColumns = this.getColumns.bind(this); - this.getSingleColumn = this.getSingleColumn.bind(this); - } // Constructor + this.onSetPage = (_event, pageNumber) => { + this.setState({ + page: pageNumber + }); + }; + + this.onPerPageSelect = (_event, perPage) => { + this.setState({ + perPage: perPage + }); + }; + + this.onSort = this.onSort.bind(this); + } + + componentDidMount() { + let rows = []; + let columns = this.state.columns; + for (let pwpRow of this.props.rows) { + rows.push({ + cells: [pwpRow[0], pwpRow[1], pwpRow[2]] + }); + } + if (rows.length == 0) { + rows = [{cells: ['No Local Policies']}]; + columns = [{title: 'Local Password Policies'}]; + } + this.setState({ + rows: rows, + columns: columns + }); + } + + onSort(_event, index, direction) { + let rows = []; + let sortedPwp = [...this.props.rows]; + + // Sort the referrals and build the new rows + sortedPwp.sort(); + if (direction !== SortByDirection.asc) { + sortedPwp.reverse(); + } + for (let pwpRow of sortedPwp) { + rows.push({ + cells: [pwpRow[0], pwpRow[1], pwpRow[2]] + }); + } - getColumns() { - return this.state.columns; + this.setState({ + sortBy: { + index, + direction + }, + rows: rows, + page: 1, + }); } - getSingleColumn () { + actions() { return [ { - property: "msg", - header: { - label: "Local Password Policies", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } + title: 'Edit Policy', + onClick: (event, rowId, rowData, extra) => + this.props.editPolicy(rowData.cells[0]) + }, + { + title: 'Delete policy', + onClick: (event, rowId, rowData, extra) => + this.props.deletePolicy(rowData.cells[0]) }, ]; } render() { - let PwpTable; + const { columns, rows, perPage, page, sortBy } = this.state; + let hasRows = true; if (this.props.rows.length == 0) { - PwpTable = <DSShortTable - getColumns={this.getSingleColumn} - rowKey={"msg"} - rows={[{msg: "No Policies"}]} - />; - } else { - PwpTable = - <DSTable - noSearchBar - getColumns={this.getColumns} - rowKey={this.state.rowKey} - rows={this.props.rows} - toolBarPagination={[6, 12, 24, 48, 96]} - toolBarPaginationPerPage={6} - />; + hasRows = false; } return ( - <div> - {PwpTable} + <div className="ds-margin-top-lg"> + <Table + className="ds-margin-top" + aria-label="pwp table" + cells={columns} + rows={rows} + variant={TableVariant.compact} + sortBy={sortBy} + onSort={this.onSort} + actions={hasRows ? this.actions() : null} + dropdownPosition="right" + dropdownDirection="bottom" + > + <TableHeader /> + <TableBody /> + </Table> + <Pagination + itemCount={this.props.rows.length} + widgetId="pagination-options-menu-bottom" + perPage={perPage} + page={page} + variant={PaginationVariant.bottom} + onSetPage={this.onSetPage} + onPerPageSelect={this.onPerPageSelect} + /> </div> ); } @@ -1174,12 +956,12 @@ LDIFManageTable.defaultProps = { ReferralTable.propTypes = { rows: PropTypes.array, - loadModalHandler: PropTypes.func + deleteRef: PropTypes.func }; ReferralTable.defaultProps = { rows: [], - loadModalHandler: noop + deleteRef: noop }; IndexTable.propTypes = { @@ -1199,16 +981,17 @@ IndexTable.defaultProps = { }; EncryptedAttrTable.propTypes = { - loadModalHandler: PropTypes.func, + deleteAttr: PropTypes.func, rows: PropTypes.array, }; EncryptedAttrTable.defaultProps = { - loadModalHandler: noop, + deleteAttr: noop, rows: [], }; export { + PwpTable, ReferralTable, IndexTable, EncryptedAttrTable, diff --git a/src/cockpit/389-console/src/lib/database/globalPwp.jsx b/src/cockpit/389-console/src/lib/database/globalPwp.jsx index 86fdb7306..b1693a43a 100644 --- a/src/cockpit/389-console/src/lib/database/globalPwp.jsx +++ b/src/cockpit/389-console/src/lib/database/globalPwp.jsx @@ -15,8 +15,20 @@ import { TabContainer, TabContent, TabPane, - Spinner, } from "patternfly-react"; +import { + Spinner, + // Button, + // Checkbox, + // Form, + // FormGroup, + // Tab, + // Tabs, + // TabTitleText, + // TextInput, + // Grid, + // GridItem, +} from "@patternfly/react-core"; import { Typeahead } from "react-bootstrap-typeahead"; import PropTypes from "prop-types"; @@ -472,6 +484,9 @@ export class GlobalPwPolicy extends React.Component { } loadGlobal() { + this.setState({ + loading: true + }); let cmd = [ "dsconf", "-j", this.props.serverId, "config", "get" ]; @@ -1042,7 +1057,10 @@ export class GlobalPwPolicy extends React.Component { } if (this.state.loading || !this.state.loaded) { - pwp_element = <Spinner loading size="md" />; + pwp_element = + <div className="ds-margin-top-xlg ds-center"> + <Spinner isSVG size="xl" /> + </div>; } else { pwp_element = <div> @@ -1323,7 +1341,7 @@ export class GlobalPwPolicy extends React.Component { Global Password Policy <Icon className="ds-left-margin ds-refresh" type="fa" name="refresh" title="Refresh global password policy settings" - onClick={this.reloadConfig} + onClick={this.loadGlobal} /> </ControlLabel> </Col> diff --git a/src/cockpit/389-console/src/lib/database/indexes.jsx b/src/cockpit/389-console/src/lib/database/indexes.jsx index 20901fe4f..57f47b2ab 100644 --- a/src/cockpit/389-console/src/lib/database/indexes.jsx +++ b/src/cockpit/389-console/src/lib/database/indexes.jsx @@ -269,31 +269,31 @@ export class SuffixIndexes extends React.Component { showEditIndexModal(item) { // Set the state types and matching Rules let currentMRS = []; - if (item.matchingrules !== undefined && - item.matchingrules.length > 0 && - item.matchingrules[0].length > 0) { - let parts = item.matchingrules[0].split(",").map(item => item.trim()); + if (item[2] !== undefined && + item[2].length > 0 && + item[2].length > 0) { + let parts = item[2].split(",").map(item => item.trim()); for (let part of parts) { currentMRS.push(part); } } this.setState({ - editIndexName: item.name[0], - types: item.types, + editIndexName: item[0], + types: item[1], mrs: currentMRS, _mrs: currentMRS, showEditIndexModal: true, errObj: {}, reindexOnAdd: false, - editIndexTypeEq: item.types[0].includes("eq"), - editIndexTypeSub: item.types[0].includes("sub"), - editIndexTypePres: item.types[0].includes("pres"), - editIndexTypeApprox: item.types[0].includes("approx"), - _eq: item.types[0].includes("eq"), - _sub: item.types[0].includes("sub"), - _pres: item.types[0].includes("pres"), - _approx: item.types[0].includes("approx"), + editIndexTypeEq: item[1].includes("eq"), + editIndexTypeSub: item[1].includes("sub"), + editIndexTypePres: item[1].includes("pres"), + editIndexTypeApprox: item[1].includes("approx"), + _eq: item[1].includes("eq"), + _sub: item[1].includes("sub"), + _pres: item[1].includes("pres"), + _approx: item[1].includes("approx"), }); } @@ -446,7 +446,7 @@ export class SuffixIndexes extends React.Component { showConfirmReindex(item) { this.setState({ - reindexAttrName: item.name[0], + reindexAttrName: item, showConfirmReindex: true }); } @@ -460,7 +460,7 @@ export class SuffixIndexes extends React.Component { showConfirmDeleteIndex(item) { this.setState({ - deleteAttrName: item.name[0], + deleteAttrName: item, showConfirmDeleteIndex: true }); } @@ -521,6 +521,7 @@ export class SuffixIndexes extends React.Component { <IndexTable editable rows={this.props.indexRows} + key={this.props.indexRows} editIndex={this.showEditIndexModal} reindexIndex={this.showConfirmReindex} deleteIndex={this.showConfirmDeleteIndex} @@ -714,7 +715,7 @@ class EditIndexModal extends React.Component { let attrTypes = ""; if (types != "" && types.length > 0) { - attrTypes = types[0].split(",").map(item => item.trim()); + attrTypes = types.split(",").map(item => item.trim()); } const currentMrs = mrs; diff --git a/src/cockpit/389-console/src/lib/database/localPwp.jsx b/src/cockpit/389-console/src/lib/database/localPwp.jsx index bd99e2b2a..1ad5b6705 100644 --- a/src/cockpit/389-console/src/lib/database/localPwp.jsx +++ b/src/cockpit/389-console/src/lib/database/localPwp.jsx @@ -1408,17 +1408,8 @@ export class LocalPwPolicy extends React.Component { } deletePolicy() { - // Start spinning - let new_rows = this.state.rows; - for (let row of new_rows) { - if (row.targetdn == this.state.deleteName) { - row.pwp_type = [<Spinner className="ds-lower-field" key={row.pwp_type} size="sm" />]; - row.basedn = [<Spinner className="ds-lower-field" key={row.basedn} size="sm" />]; - row.actions = [<Spinner className="ds-lower-field" key={row.targetdn} size="sm" />]; - } - } this.setState({ - rows: new_rows, + loading: true, editPolicy: false, }); @@ -1442,6 +1433,9 @@ export class LocalPwPolicy extends React.Component { } loadPolicies() { + this.setState({ + loading: true, + }); let cmd = [ "dsconf", "-j", this.props.serverId, "localpwp", "list" ]; @@ -1450,10 +1444,14 @@ export class LocalPwPolicy extends React.Component { .spawn(cmd, { superuser: true, err: "message" }) .done(content => { let policy_obj = JSON.parse(content); + let pwpRows = []; + for (let row of policy_obj.items) { + pwpRows.push([row.targetdn, row.pwp_type, row.basedn]); + } this.setState({ localActiveKey: 1, activeKey: 1, - rows: policy_obj.items, + rows: pwpRows, loaded: true, loading: false, editPolicy: false, @@ -2506,6 +2504,7 @@ export class LocalPwPolicy extends React.Component { <TabPane eventKey={1}> <div className="ds-margin-top-xlg"> <PwpTable + key={this.state.rows} rows={this.state.rows} editPolicy={this.loadLocal} deletePolicy={this.showDeletePolicy} @@ -2535,7 +2534,10 @@ export class LocalPwPolicy extends React.Component { </div>; if (this.state.loading || !this.state.loaded) { - body = <Spinner size="md" />; + body = + <div className="ds-margin-top-xlg ds-center"> + <Spinner isSVG size="xl" /> + </div>; } return ( @@ -2546,7 +2548,7 @@ export class LocalPwPolicy extends React.Component { Local Password Policies <Icon className="ds-left-margin ds-refresh" type="fa" name="refresh" title="Refresh the local password policies" - onClick={this.reloadConfig} + onClick={this.loadPolicies} disabled={this.state.loading} /> </ControlLabel> diff --git a/src/cockpit/389-console/src/lib/database/referrals.jsx b/src/cockpit/389-console/src/lib/database/referrals.jsx index e01e3946f..d19e4919d 100644 --- a/src/cockpit/389-console/src/lib/database/referrals.jsx +++ b/src/cockpit/389-console/src/lib/database/referrals.jsx @@ -52,7 +52,7 @@ export class SuffixReferrals extends React.Component { showConfirmRefDelete(item) { this.setState({ - removeRef: item.name, + removeRef: item, showConfirmRefDelete: true }); } @@ -221,16 +221,12 @@ export class SuffixReferrals extends React.Component { } render() { - let refs = []; - for (let row of this.props.rows) { - refs.push({name: row}); - } - return ( <div className="ds-sub-header"> <ReferralTable - rows={refs} - loadModalHandler={this.showConfirmRefDelete} + key={this.props.rows} + rows={this.props.rows} + deleteRef={this.showConfirmRefDelete} /> <button className="btn btn-primary ds-margin-top" onClick={this.showRefModal} type="button">Create Referral</button> <ConfirmPopup diff --git a/src/cockpit/389-console/src/lib/database/suffix.jsx b/src/cockpit/389-console/src/lib/database/suffix.jsx index 3de8d3736..f6062485a 100644 --- a/src/cockpit/389-console/src/lib/database/suffix.jsx +++ b/src/cockpit/389-console/src/lib/database/suffix.jsx @@ -196,11 +196,11 @@ export class Suffix extends React.Component { }); } - showConfirmLDIFImport (item) { + showConfirmLDIFImport (name) { // call deleteLDIF this.setState({ showConfirmLDIFImport: true, - importLDIFName: item.name, + importLDIFName: name, modalChecked: false, modalSpinning: false, }); diff --git a/src/cockpit/389-console/src/lib/database/vlvIndexes.jsx b/src/cockpit/389-console/src/lib/database/vlvIndexes.jsx index 097dc98dc..c771457c9 100644 --- a/src/cockpit/389-console/src/lib/database/vlvIndexes.jsx +++ b/src/cockpit/389-console/src/lib/database/vlvIndexes.jsx @@ -13,9 +13,6 @@ import { Col, ControlLabel, Form, - sortableHeaderCellFormatter, - actionHeaderCellFormatter, - tableCellFormatter, } from "patternfly-react"; import { Button, @@ -26,9 +23,17 @@ import { // TextInput, noop } from "@patternfly/react-core"; +import { + Table, + TableHeader, + TableBody, + TableVariant, + sortable, + SortByDirection, +} from '@patternfly/react-table'; +import TrashAltIcon from '@patternfly/react-icons/dist/js/icons/trash-alt-icon'; import PropTypes from "prop-types"; import { Typeahead } from "react-bootstrap-typeahead"; -import { DSShortTable } from "../dsTable.jsx"; export class VLVIndexes extends React.Component { constructor (props) { @@ -82,7 +87,6 @@ export class VLVIndexes extends React.Component { vlvScope: "subtree", vlvFilter: "", vlvSortList: [], - vlvSortRows: [], }); } @@ -127,7 +131,7 @@ export class VLVIndexes extends React.Component { let sortRows = []; let sortList = []; for (let vlvSort of item.sorts) { - sortRows.push({sortName: vlvSort.attrs.vlvsort[0]}); + sortRows.push(vlvSort.attrs.vlvsort[0]); sortList.push(vlvSort.attrs.vlvsort[0]); } this.setState({ @@ -138,13 +142,11 @@ export class VLVIndexes extends React.Component { vlvScope: this.getScopeKey(vlvAttrs.vlvscope[0]), vlvFilter: vlvAttrs.vlvfilter[0], vlvSortList: sortList, - vlvSortRows: sortRows, _vlvName: vlvAttrs.cn[0], _vlvBase: vlvAttrs.vlvbase[0], _vlvScope: this.getScopeKey(vlvAttrs.vlvscope[0]), _vlvFilter: vlvAttrs.vlvfilter[0], _vlvSortList: sortList, - _vlvSortRows: sortRows, }); break; } @@ -570,7 +572,7 @@ export class VLVIndexes extends React.Component { vlvBase={this.state.vlvBase} vlvScope={this.state.vlvScope} vlvFilter={this.state.vlvFilter} - vlvSortList={this.state.vlvSortRows} + vlvSortList={this.state.vlvSortList} /> <ConfirmPopup showModal={this.state.showDeleteConfirm} @@ -604,109 +606,40 @@ class AddVLVModal extends React.Component { this.state = { sortRows: sortRows, sortValue: "", - columns: [], + sortBy: {}, + rows: [], + columns: [ + { title: 'VLV Sort Indexes', transforms: [sortable] }, + { title: '' }, + ], edit: false, }; - this.getColumns = this.getColumns.bind(this); - this.getSingleColumn = this.getSingleColumn.bind(this); this.updateSorts = this.updateSorts.bind(this); this.handleVLVSortChange = this.handleVLVSortChange.bind(this); this.close = this.close.bind(this); this.save = this.save.bind(this); + this.onSort = this.onSort.bind(this); + this.getDeleteButton = this.getDeleteButton.bind(this); } - getSingleColumn () { - return [ - { - property: "msg", - header: { - label: "VLV Sort Indexes", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - ]; - } - - getColumns () { - return [ - { - property: "sortName", - header: { - label: "VLV Sort Indexes", - props: { - index: 0, - rowSpan: 1, - colSpan: 1, - sort: true - }, - transforms: [], - formatters: [], - customFormatters: [sortableHeaderCellFormatter] - }, - cell: { - props: { - index: 0 - }, - formatters: [tableCellFormatter] - } - }, - { - property: "actions", - header: { - label: "", - props: { - index: 1, - rowSpan: 1, - colSpan: 1 - }, - formatters: [actionHeaderCellFormatter] - }, - cell: { - props: { - index: 2 - }, - formatters: [ - (value, { rowData }) => { - return [ - <td key={rowData.sortName[0]}> - <Button - onClick={() => { - this.handleVLVSortChange( - rowData - ); - }} - > - Remove - </Button> - </td> - ]; - } - ] - } - } - ]; + getDeleteButton(name) { + return ( + <TrashAltIcon + className="ds-center" + onClick={() => { + this.handleVLVSortChange(name); + }} + title="Remove this VLV Sort Index" + /> + ); } - handleVLVSortChange(e) { + handleVLVSortChange(name) { // VLV index was removed from table let rows = this.state.sortRows; for (let i = 0; i < rows.length; i++) { - if (rows[i].sortName == e.sortName) { + if (rows[i] == name) { rows.splice(i, 1); this.setState({ sortRows: rows @@ -727,7 +660,7 @@ class AddVLVModal extends React.Component { updateSorts() { let rows = this.state.sortRows; if (this.state.sortValue != "") { - rows.push({sortName: this.state.sortValue}); + rows.push(this.state.sortValue); this.typeahead.getInstance().clear(); this.setState({ sortRows: rows, @@ -748,6 +681,23 @@ class AddVLVModal extends React.Component { this.props.closeHandler(); } + onSort(_event, index, direction) { + let sortedRows = [...this.state.sortRows]; + + // Sort and build the new rows + sortedRows.sort(); + if (direction !== SortByDirection.asc) { + sortedRows.reverse(); + } + this.setState({ + sortBy: { + index, + direction + }, + sortRows: sortedRows, + }); + } + render() { const { showModal, @@ -760,7 +710,8 @@ class AddVLVModal extends React.Component { let base = ""; let scope = "subtree"; let filter = ""; - let sortTable; + let rows = []; + let columns = this.state.columns; if (this.props.edit) { title = "Edit VLV Index"; @@ -768,10 +719,6 @@ class AddVLVModal extends React.Component { base = this.props.vlvBase; scope = this.props.vlvScope; filter = this.props.vlvFilter; - if (this.props.vlvSortList !== undefined) { - // {sortName: "value"}, - this.state.sortRows = this.props.vlvSortList; - } } else { // Create new index // this.state.sortRows = []; @@ -780,7 +727,7 @@ class AddVLVModal extends React.Component { } let vlvscope = - <Row> + <Row className="ds-margin-top"> <Col sm={3}> <ControlLabel>Search Scope</ControlLabel> </Col> @@ -795,17 +742,13 @@ class AddVLVModal extends React.Component { </Row>; if (this.state.sortRows.length == 0) { - sortTable = <DSShortTable - getColumns={this.getSingleColumn} - rowKey={"msg"} - rows={[{msg: "No sort indexes"}]} - />; + rows = [{cells: ['No sorting indexes']}]; + columns = [{title: 'VLV Sort Indexes'}]; } else { - sortTable = <DSShortTable - getColumns={this.getColumns} - rowKey={"sortName"} - rows={this.state.sortRows} - />; + // let sortRows = JSON.parse(JSON.stringify(this.state.sortRows)); + for (let row of this.state.sortRows) { + rows.push({ cells: [row, { props: { textCenter: true }, title: this.getDeleteButton(row) }] }); + } } return ( @@ -855,7 +798,18 @@ class AddVLVModal extends React.Component { <hr /> <div> <div className="ds-margin-top"> - {sortTable} + <Table + className="ds-margin-top" + aria-label="referral table" + cells={columns} + rows={rows} + variant={TableVariant.compact} + sortBy={this.state.sortBy} + onSort={this.onSort} + > + <TableHeader /> + <TableBody /> + </Table> <Typeahead multiple className="ds-margin-top" @@ -874,7 +828,7 @@ class AddVLVModal extends React.Component { <hr /> <Row> <Col sm={12}> - <Checkbox className="ds-float-right" id="reindexVLV" onChange={handleChange}> + <Checkbox id="reindexVLV" onChange={handleChange}> Index VLV on Save </Checkbox> </Col> diff --git a/src/cockpit/389-console/src/lib/monitor/monitorTables.jsx b/src/cockpit/389-console/src/lib/monitor/monitorTables.jsx index 56ea7e272..b6d476dce 100644 --- a/src/cockpit/389-console/src/lib/monitor/monitorTables.jsx +++ b/src/cockpit/389-console/src/lib/monitor/monitorTables.jsx @@ -1768,12 +1768,6 @@ class ReportConsumersTable extends React.Component { constructor(props) { super(props); this.state = { - fieldsToSearch: [ - "agmt-name", - "replica-enabled", - "replication-status", - "replication-lag-time" - ], sortBy: {}, rows: [], columns: [ diff --git a/src/lib389/lib389/pwpolicy.py b/src/lib389/lib389/pwpolicy.py index 8653cb195..1b654a4ac 100644 --- a/src/lib389/lib389/pwpolicy.py +++ b/src/lib389/lib389/pwpolicy.py @@ -8,6 +8,7 @@ import ldap from lib389._mapped_object import DSLdapObject, DSLdapObjects +from lib389.backend import Backends from lib389.config import Config from lib389.idm.account import Account from lib389.idm.nscontainer import nsContainers, nsContainer @@ -192,14 +193,20 @@ class PwPolicyManager(object): if not entry.exists(): raise ValueError('Can not get the password policy entry because the target dn does not exist') - # Get the parent DN - dn_comps = ldap.dn.explode_dn(entry.dn) - dn_comps.pop(0) - parentdn = ",".join(dn_comps) + try: + Backends(self._instance).get(dn) + # The DN is a base suffix, it has no parent + parentdn = dn + except: + # Ok, this is a not a suffix, get the parent DN + dn_comps = ldap.dn.explode_dn(entry.dn) + dn_comps.pop(0) + parentdn = ",".join(dn_comps) # Get the parent's policies pwp_entries = PwPolicyEntries(self._instance, parentdn) policies = pwp_entries.list() + for policy in policies: dn_comps = ldap.dn.explode_dn(policy.get_attr_val_utf8_l('cn')) dn_comps.pop(0)
0
aab44b2d78124736d6c9ea3fcf5b8bfa1a27d246
389ds/389-ds-base
Issue 6758 - Fix failing webUI tests Description: Fixing webUI tests that are failing due to recent changes. Removing xfail markers where bugs were fixed. Also includes minor changes in order to remove deprecation warnings. Removing code disabling automatic run of webUI tests. Relates: #6758 Author: Lenka Doudova Reviewed by: ???
commit aab44b2d78124736d6c9ea3fcf5b8bfa1a27d246 Author: Lenka Doudova <[email protected]> Date: Fri Apr 25 20:29:20 2025 +0200 Issue 6758 - Fix failing webUI tests Description: Fixing webUI tests that are failing due to recent changes. Removing xfail markers where bugs were fixed. Also includes minor changes in order to remove deprecation warnings. Removing code disabling automatic run of webUI tests. Relates: #6758 Author: Lenka Doudova Reviewed by: ??? diff --git a/.github/scripts/generate_matrix.py b/.github/scripts/generate_matrix.py index 8d67a1dc7..a75328f44 100644 --- a/.github/scripts/generate_matrix.py +++ b/.github/scripts/generate_matrix.py @@ -21,9 +21,6 @@ else: # Use tests from the source suites = next(os.walk('dirsrvtests/tests/suites/'))[1] - # Filter out webui because of broken tests - suites.remove('webui') - # Run each replication test module separately to speed things up suites.remove('replication') repl_tests = glob.glob('dirsrvtests/tests/suites/replication/*_test.py') diff --git a/dirsrvtests/tests/suites/webui/__init__.py b/dirsrvtests/tests/suites/webui/__init__.py index 8333d0d49..0dac412ed 100644 --- a/dirsrvtests/tests/suites/webui/__init__.py +++ b/dirsrvtests/tests/suites/webui/__init__.py @@ -102,7 +102,7 @@ def setup_login(page): page.click("#login-button") time.sleep(2) - if RHEL in distro.linux_distribution(): + if RHEL in distro.name(): page.wait_for_selector('text=Red Hat Directory Server') page.click('text=Red Hat Directory Server') else: @@ -165,17 +165,17 @@ def create_entry(frame, entry_type, entry_data): prepare_page_for_entry(frame, entry_type) if entry_type == 'User': - frame.get_by_role("button", name="Options menu").click() + frame.get_by_role("button", name="Basic Account").click() frame.get_by_role("option", name="Posix Account").click() frame.get_by_role("button", name="Next", exact=True).click() frame.get_by_role("button", name="Next", exact=True).click() - for row, value in enumerate(entry_data.values()): - if row > 5: + for row, value in enumerate(entry_data.values(), start=1): + if row > 6: break - frame.get_by_role("button", name=f"Place row {row} in edit mode").click() + frame.get_by_role("button", name=f"Edit row {row}").click() frame.get_by_role("textbox", name="_").fill(value) - frame.get_by_role("button", name=f"Save row edits for row {row}").click() + frame.get_by_role("button", name=f"Save edits of row {row}").click() elif entry_type == 'Group': frame.get_by_role("button", name="Next").click() @@ -184,9 +184,9 @@ def create_entry(frame, entry_type, entry_data): elif entry_type == 'Organizational Unit': frame.get_by_role("button", name="Next", exact=True).click() - frame.get_by_role("button", name="Place row 0 in edit mode").click() + frame.get_by_role("button", name="Edit row 1").click() frame.get_by_role("textbox", name="_").fill(entry_data['ou_name']) - frame.get_by_role("button", name="Save row edits for row 0").click() + frame.get_by_role("button", name="Save edits of row 1").click() elif entry_type == 'Role': frame.locator("#namingVal").fill(entry_data['role_name']) @@ -199,12 +199,12 @@ def create_entry(frame, entry_type, entry_data): frame.get_by_role("button", name="Next", exact=True).click() frame.get_by_role("checkbox", name="Select row 1").check() frame.get_by_role("button", name="Next", exact=True).click() - frame.get_by_role("button", name="Place row 0 in edit mode").click() + frame.get_by_role("button", name="Edit row 1").click() frame.get_by_role("textbox", name="_").fill(entry_data['uid']) - frame.get_by_role("button", name="Save row edits for row 0").click() - frame.get_by_role("button", name="Place row 1 in edit mode").click() + frame.get_by_role("button", name="Save edits of row 1").click() + frame.get_by_role("button", name="Edit row 2").click() frame.get_by_role("textbox", name="_").fill(entry_data['entry_name']) - frame.get_by_role("button", name="Save row edits for row 1").click() + frame.get_by_role("button", name="Save edits of row 2").click() finish_entry_creation(frame, entry_type, entry_data) diff --git a/dirsrvtests/tests/suites/webui/backup/backup_test.py b/dirsrvtests/tests/suites/webui/backup/backup_test.py index 26eae0fff..113bfaf82 100644 --- a/dirsrvtests/tests/suites/webui/backup/backup_test.py +++ b/dirsrvtests/tests/suites/webui/backup/backup_test.py @@ -22,7 +22,6 @@ pytest.importorskip('playwright') SERVER_ID = 'standalone1' [email protected](reason="Will fail because of bz2189181") def test_no_backup_dir(topology_st, page, browser_name): """ Test that instance is able to load when backup directory doesn't exist. diff --git a/dirsrvtests/tests/suites/webui/database/database_test.py b/dirsrvtests/tests/suites/webui/database/database_test.py index ef105d262..81937af53 100644 --- a/dirsrvtests/tests/suites/webui/database/database_test.py +++ b/dirsrvtests/tests/suites/webui/database/database_test.py @@ -71,7 +71,7 @@ def test_global_database_configuration_availability(topology_st, page, browser_n frame = check_frame_assignment(page, browser_name) instance = topology_st.standalone - if instance.get_db_lib() is 'mdb': + if instance.get_db_lib() == 'mdb': log.info('Check if element on Limits tab is loaded.') frame.get_by_role('tab', name='Database', exact=True).click() @@ -90,7 +90,7 @@ def test_global_database_configuration_availability(topology_st, page, browser_n log.info('Click on Advanced Settings tab and check if element is loaded') frame.get_by_role('tab', name='Advanced Settings', exact=True).click() assert frame.locator('#dbhomedir').is_visible() - elif instance.get_db_lib() is 'bdb': + elif instance.get_db_lib() == 'bdb': log.info('Check if element on Limits tab is loaded.') frame.get_by_role('tab', name='Database', exact=True).click() frame.get_by_text('ID List Scan Limit', exact=True).wait_for() @@ -291,7 +291,7 @@ def test_suffixes_policy_availability(topology_st, page, browser_name): log.info('Click on Suffixes and check if element is loaded.') frame.get_by_role('tab', name='Database', exact=True).click() - frame.locator('#dc\=example\,dc\=com').click() + frame.locator(r'#dc\=example\,dc\=com').click() frame.locator('#cachememsize').wait_for() assert frame.locator('#cachememsize').is_visible() @@ -355,7 +355,7 @@ def test_dictionary_check_checkbox(topology_st, page, browser_name): log.info('Disable dictionary check, reload tab and check that Dictionary Check checkbox is unchecked.') ppm.set_global_policy({"passworddictcheck": "off"}) ppm.set_global_policy({"passwordchecksyntax": "on"}) - frame.get_by_role('img', name="Refresh global password policy settings").click() + frame.get_by_role('button', name="Refresh global password policy settings").click() assert not frame.get_by_text('Dictionary Check').is_checked() diff --git a/dirsrvtests/tests/suites/webui/ldap_browser/ldap_browser_test.py b/dirsrvtests/tests/suites/webui/ldap_browser/ldap_browser_test.py index 0aab5c7c5..265cc9489 100644 --- a/dirsrvtests/tests/suites/webui/ldap_browser/ldap_browser_test.py +++ b/dirsrvtests/tests/suites/webui/ldap_browser/ldap_browser_test.py @@ -181,7 +181,6 @@ def test_create_and_delete_group(topology_st, page, browser_name): assert frame.get_by_role("button").filter(has_text=f"cn={test_data['group_name']}").count() == 0 [email protected](reason="DS6558") def test_create_and_delete_organizational_unit(topology_st, page, browser_name): """ Test to create and delete organizational unit diff --git a/dirsrvtests/tests/suites/webui/login/login_test.py b/dirsrvtests/tests/suites/webui/login/login_test.py index 08c92df17..a699a9a76 100644 --- a/dirsrvtests/tests/suites/webui/login/login_test.py +++ b/dirsrvtests/tests/suites/webui/login/login_test.py @@ -65,7 +65,7 @@ def test_login_no_instance(topology_st, page, browser_name): page.click('#login-button') time.sleep(2) - if RHEL in distro.linux_distribution(): + if RHEL in distro.name(): page.wait_for_selector('text=Red Hat Directory Server') assert page.is_visible('text=Red Hat Directory Server') log.info('Let us go to RHDS side tab page') diff --git a/dirsrvtests/tests/suites/webui/monitoring/monitoring_test.py b/dirsrvtests/tests/suites/webui/monitoring/monitoring_test.py index 6a1556c71..4104ed360 100644 --- a/dirsrvtests/tests/suites/webui/monitoring/monitoring_test.py +++ b/dirsrvtests/tests/suites/webui/monitoring/monitoring_test.py @@ -81,11 +81,11 @@ def test_server_statistics_visibility(topology_st, page, browser_name): log.info('Click on Disk Space tab and check if element is loaded.') frame.get_by_role('tab', name='Disk Space').click() - assert frame.get_by_role('button', name='Refresh').is_visible() + assert frame.get_by_text('Refresh').is_visible() log.info('Click on SNMP Counters tab and check if element is loaded.') frame.get_by_role('tab', name='SNMP Counters').click() - assert frame.get_by_text('Bytes Sent', exact=True).is_visible() + assert frame.get_by_text('Data Sent', exact=True).is_visible() def test_replication_visibility(topology_st, page, browser_name): @@ -132,7 +132,6 @@ def test_replication_visibility(topology_st, page, browser_name): assert frame.locator('#replication-suffix-dc\\=example\\,dc\\=com').is_visible() [email protected](reason="DS6557") def test_database_visibility(topology_st, page, browser_name): """ Test Database monitoring visibility @@ -150,16 +149,26 @@ def test_database_visibility(topology_st, page, browser_name): setup_login(page) time.sleep(1) frame = check_frame_assignment(page, browser_name) + instance = topology_st.standalone log.info('Click on Monitoring tab, then click on database button and check if element is loaded.') frame.get_by_role('tab', name='Monitoring', exact=True).click() + frame.get_by_label("Monitoring", exact=True).get_by_text("Database").click() + + log.info('Click on Database tab and check if element is loaded.') + if instance.get_db_lib() == 'bdb': + frame.get_by_role('tab', name='Normalized DN Cache').click() + + frame.get_by_text('NDN Cache Hit Ratio').wait_for() + assert frame.get_by_text('NDN Cache Hit Ratio').is_visible() + frame.locator('#dc\\=example\\,dc\\=com').click() frame.get_by_text('Entry Cache Hit Ratio').wait_for() assert frame.get_by_text('Entry Cache Hit Ratio').is_visible() - log.info('Click on DN Cache tab and check if element is loaded.') - frame.get_by_role('tab', name='DN Cache').click() - assert frame.get_by_text('DN Cache Hit Ratio').is_visible() + if instance.get_db_lib() == 'bdb': + frame.get_by_role('tab', name='DN Cache').click() + assert frame.get_by_text('DN Cache Hit Ratio').is_visible() def test_logging_visibility(topology_st, page, browser_name): @@ -197,28 +206,28 @@ def test_logging_visibility(topology_st, page, browser_name): log.info('Click on Monitoring tab, then click on Access Log button and check if element is loaded.') frame.get_by_role('tab', name='Monitoring', exact=True).click() frame.locator('#access-log-monitor').click() - frame.locator('#accesslog-area').wait_for() - assert frame.locator('#accesslog-area').is_visible() + frame.locator('#monitor-log-access-page').wait_for() + assert frame.locator('#monitor-log-access-page').is_visible() log.info('Click on Audit Log button and check if element is loaded.') frame.locator('#audit-log-monitor').click() - frame.locator('#auditlog-area').wait_for() - assert frame.locator('#auditlog-area').is_visible() + frame.locator('#monitor-log-audit-page').wait_for() + assert frame.locator('#monitor-log-audit-page').is_visible() log.info('Click on Audit Failure Log button and check if element is loaded.') frame.locator('#auditfail-log-monitor').click() - frame.locator('#auditfaillog-area').wait_for() - assert frame.locator('#auditfaillog-area').is_visible() + frame.locator('#monitor-log-auditfail-page').wait_for() + assert frame.locator('#monitor-log-auditfail-page').is_visible() log.info('Click on Errors Log button and check if element is loaded.') frame.locator('#error-log-monitor').click() - frame.locator('#errorslog-area').wait_for() - assert frame.locator('#errorslog-area').is_visible() + frame.locator('#monitor-log-errors-page').wait_for() + assert frame.locator('#monitor-log-errors-page').is_visible() log.info('Click on Security Log button and check if element is loaded.') frame.locator('#security-log-monitor').click() - frame.locator('#securitylog-area').wait_for() - assert frame.locator('#securitylog-area').is_visible() + frame.locator('#monitor-log-security-page').wait_for() + assert frame.locator('#monitor-log-security-page').is_visible() def test_create_credential_and_alias(topology_st, page, browser_name): diff --git a/dirsrvtests/tests/suites/webui/plugins/plugins_test.py b/dirsrvtests/tests/suites/webui/plugins/plugins_test.py index 849dedcf2..e4bd7f039 100644 --- a/dirsrvtests/tests/suites/webui/plugins/plugins_test.py +++ b/dirsrvtests/tests/suites/webui/plugins/plugins_test.py @@ -230,8 +230,8 @@ def test_memberof_plugin_visibility(topology_st, page, browser_name): frame.get_by_role('tab', name='Plugins', exact=True).click() frame.get_by_text('Plugin is disabledMemberOf').wait_for() frame.get_by_text('Plugin is disabledMemberOf').click() - frame.locator('#memberOfConfigEntry').wait_for() - assert frame.locator('#memberOfConfigEntry').is_visible() + frame.get_by_role('button', name='Create Config').wait_for() + assert frame.get_by_role('button', name='Create Config').is_visible() def test_ldap_pass_through_auth_plugin_visibility(topology_st, page, browser_name):
0
ab321cf1e538a78d3e05235dcd90a483af990a93
389ds/389-ds-base
Ticket 50004 - lib389 - improve X-ORIGIN schema parsing Bug Description: Schema parsing assumed X-ORIGIN was always in this format "X-ORIGIN '", but it can also be in other formats like: "X-ORIGIN (". So when it did not contain the original format we got list index errors. Fix Description: Loosen the format to " X-ORIGIN " which all the formats. Also: improve from UI schema error messages updated create_test for python3 https://pagure.io/389-ds-base/issue/50004 Reviewed by: firstyear & spichugi(Thanks!!)
commit ab321cf1e538a78d3e05235dcd90a483af990a93 Author: Mark Reynolds <[email protected]> Date: Fri Nov 2 17:20:31 2018 -0400 Ticket 50004 - lib389 - improve X-ORIGIN schema parsing Bug Description: Schema parsing assumed X-ORIGIN was always in this format "X-ORIGIN '", but it can also be in other formats like: "X-ORIGIN (". So when it did not contain the original format we got list index errors. Fix Description: Loosen the format to " X-ORIGIN " which all the formats. Also: improve from UI schema error messages updated create_test for python3 https://pagure.io/389-ds-base/issue/50004 Reviewed by: firstyear & spichugi(Thanks!!) diff --git a/dirsrvtests/create_test.py b/dirsrvtests/create_test.py index bf4abbd95..fd6df7b9c 100755 --- a/dirsrvtests/create_test.py +++ b/dirsrvtests/create_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # --- BEGIN COPYRIGHT BLOCK --- # Copyright (C) 2016 Red Hat, Inc. @@ -122,10 +122,11 @@ def check_id_uniqueness(id_value): for root, dirs, files in os.walk(tests_dir): for name in files: - with open(os.path.join(root, name), "r") as file: - for line in file: - if re.search(str(id_value), line): - return False + if name.endswith('.py'): + with open(os.path.join(root, name), "r") as cifile: + for line in cifile: + if re.search(str(id_value), line): + return False return True diff --git a/src/cockpit/389-console/src/schema.js b/src/cockpit/389-console/src/schema.js index c815a04cf..c1c3b8214 100644 --- a/src/cockpit/389-console/src/schema.js +++ b/src/cockpit/389-console/src/schema.js @@ -127,7 +127,7 @@ function load_schema_objects_to_select(object, select_id) { })); }); }).fail(function(select_data) { - console.log("failed: " + select_data.message); + console.log("Get schema failed: " + select_data.message); check_inst_alive(1); }); } @@ -219,7 +219,7 @@ function get_and_set_schema_tables() { }] }); }).fail(function(oc_data) { - console.log("failed: " + oc_data.message); + console.log("Get objectclasses failed: " + oc_data.message); check_inst_alive(1); }); @@ -342,12 +342,12 @@ function get_and_set_schema_tables() { }] }); }).fail(function(at_data) { - console.log("failed: " + at_data.message); + console.log("Get attributes failed: " + at_data.message); check_inst_alive(1); }); }).fail(function(syntax_data) { - console.log("failed: " + syntax_data.message); + console.log("Get syntaxes failed: " + syntax_data.message); check_inst_alive(1); }); @@ -379,7 +379,7 @@ function get_and_set_schema_tables() { console.log("Finished loading schema."); }).fail(function(mr_data) { - console.log("failed: " + mr_data.cmd); + console.log("Get matching rules failed: " + mr_data.cmd); check_inst_alive(1); }); } @@ -498,7 +498,7 @@ $(document).ready( function() { }). fail(function(oc_data) { popup_err("err", oc_data.message); - console.log("failed: " + oc_data.message); + console.log("Search objectclasses failed: " + oc_data.message); check_inst_alive(1); }); // Replace the option in 'Edit objectClass' window @@ -693,7 +693,7 @@ $(document).ready( function() { }). fail(function(at_data) { popup_err("err", at_data.message); - console.log("failed: " + at_data.message); + console.log("Query attributes failed: " + at_data.message); check_inst_alive(1); }); if (!edit) { diff --git a/src/lib389/lib389/schema.py b/src/lib389/lib389/schema.py index 409097722..8ad42e22b 100755 --- a/src/lib389/lib389/schema.py +++ b/src/lib389/lib389/schema.py @@ -13,6 +13,7 @@ import glob import ldap import ldif +import re from itertools import count from json import dumps as dump_json from operator import itemgetter @@ -41,7 +42,7 @@ ATTR_SYNTAXES = {"1.3.6.1.4.1.1466.115.121.1.5": "Binary", "1.3.6.1.4.1.1466.115.121.1.7": "Boolean", "1.3.6.1.4.1.1466.115.121.1.11": "Country String", "1.3.6.1.4.1.1466.115.121.1.12": "DN", - "1.3.6.1.4.1.1466.115.121.1.14": "Delivery Method", + "1.3.6.1.4.1.1466.115.121.1.14": "Delivery Method", "1.3.6.1.4.1.1466.115.121.1.15": "Directory String", "1.3.6.1.4.1.1466.115.121.1.21": "Enhanced Guide", "1.3.6.1.4.1.1466.115.121.1.22": "Facsimile", @@ -64,6 +65,9 @@ ATTR_SYNTAXES = {"1.3.6.1.4.1.1466.115.121.1.5": "Binary", "1.3.6.1.4.1.1466.115.121.1.52": "Telex Number"} +X_ORIGIN_REGEX = r'\'(.*?)\'' + + class Schema(DSLdapObject): """An object that represents the schema entry @@ -113,35 +117,46 @@ class Schema(DSLdapObject): return result def _get_schema_objects(self, object_model, json=False): + """Get all the schema objects for a specific model: Attribute, Objectclass, + or Matchingreule. + """ attr_name = self._get_attr_name_by_model(object_model) - results = self.get_attr_vals_utf8(attr_name) if json: - object_insts = [vars(object_model(obj_i)) for obj_i in results] - - for obj_i in object_insts: - # Add normalized name for sorting. Some matching rules don't have a name + object_insts = [] + for obj in results: + obj_i = vars(object_model(obj)) if len(obj_i["names"]) == 1: - obj_i['name'] = obj_i['names'][0] + obj_i['name'] = obj_i['names'][0].lower() obj_i['aliases'] = "" elif len(obj_i["names"]) > 1: - obj_i['name'] = obj_i['names'][0] + obj_i['name'] = obj_i['names'][0].lower() obj_i['aliases'] = obj_i['names'][1:] else: obj_i['name'] = "" + # Temporary workaround for X-ORIGIN in ObjectClass objects. # It should be removed after https://github.com/python-ldap/python-ldap/pull/247 is merged - if "x_origin" not in obj_i and object_model != MatchingRule: - for object_str in results: - if obj_i['names'] == vars(object_model(object_str))['names'] and "X-ORIGIN" in object_str: - obj_i['x_origin'] = object_str.split("X-ORIGIN '")[1].split("'")[0] - object_insts = sorted(object_insts, key=itemgetter('name')) - result = {'type': 'list', 'items': object_insts} + if " X-ORIGIN " in obj and obj_i['names'] == vars(object_model(obj))['names']: + remainder = obj.split(" X-ORIGIN ")[1] + if remainder[:1] == "(": + # Have multiple values + end = remainder.find(')') + vals = remainder[1:end] + vals = re.findall(X_ORIGIN_REGEX, vals) + # For now use the first value, but this should be a set (another bug in python-ldap) + obj_i['x_origin'] = vals[0] + else: + # Single X-ORIGIN value + obj_i['x_origin'] = obj.split(" X-ORIGIN ")[1].split("'")[1] + object_insts.append(obj_i) - return result + object_insts = sorted(object_insts, key=itemgetter('name')) + return {'type': 'list', 'items': object_insts} else: - return [object_model(obj_i) for obj_i in results] + object_insts = [object_model(obj_i) for obj_i in results] + return sorted(object_insts, key=lambda x: x.names, reverse=False) def _get_schema_object(self, name, object_model, json=False): objects = self._get_schema_objects(object_model, json=json) diff --git a/src/lib389/lib389/tests/cli/conf_schema_test.py b/src/lib389/lib389/tests/cli/conf_schema_test.py index e69de29bb..40a96afc6 100644 --- a/src/lib389/lib389/tests/cli/conf_schema_test.py +++ b/src/lib389/lib389/tests/cli/conf_schema_test.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/src/lib389/lib389/tests/schema_test.py b/src/lib389/lib389/tests/schema_test.py index 28daefe50..8f4e86ced 100644 --- a/src/lib389/lib389/tests/schema_test.py +++ b/src/lib389/lib389/tests/schema_test.py @@ -1,72 +1,121 @@ # --- BEGIN COPYRIGHT BLOCK --- -# Copyright (C) 2015 Red Hat, Inc. +# Copyright (C) 2018 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 import DirSrv -from lib389._constants import SER_HOST, SER_PORT, SER_SERVERID_PROP, LOCALHOST -from lib389.schema import Schema - -INSTANCE_PORT = 54321 -INSTANCE_SERVERID = 'standalone' - - -class TopologyInstance(object): - def __init__(self, instance): - instance.open() - self.instance = instance [email protected](scope="module") -def topology(request): - instance = DirSrv(verbose=False) - instance.log.debug("Instance allocated") - args = {SER_HOST: LOCALHOST, - SER_PORT: INSTANCE_PORT, - SER_SERVERID_PROP: INSTANCE_SERVERID} - instance.allocate(args) - if instance.exists(): - instance.delete() - instance.create() - instance.open() +import logging +import pytest +import os +from lib389._constants import * +from lib389.schema import Schema +from lib389.topologies import topology_st as topo - def fin(): - instance.delete() - request.addfinalizer(fin) +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__) - return TopologyInstance(instance) +def test_schema(topo): + """Basic schema querying test -def test_schema(topology): - must_expect = ['uidObject', 'account', 'posixAccount', 'shadowAccount'] + :id: 995acc60-243b-45b0-9c1c-12bbe6a2882f + :setup: Standalone Instance + :steps: + 1. Get attribute info for 'uid' + 2. Check the attribute is found in the expected objectclasses (must, may) + 3. Check that the 'account' objectclass is found + :expectedresults: + 1. Success + 2. Success + 3. Success + """ + must_expect = ['uidObject', 'account', 'posixAccount', 'shadowAccount', 'ipaUser', + 'sambaSamAccount'] may_expect = ['cosDefinition', 'inetOrgPerson', 'inetUser', - 'mailRecipient'] - attrtype, must, may = topology.instance.schema.query_attributetype('uid') + 'mailRecipient', 'nsOrgPerson', 'ipaUserOverride'] + attrtype, must, may = topo.standalone.schema.query_attributetype('uid') assert attrtype.names == ('uid', 'userid') for oc in must: assert oc.names[0] in must_expect for oc in may: assert oc.names[0] in may_expect - assert topology.instance.schema.query_objectclass('account').names == \ + assert topo.standalone.schema.query_objectclass('account').names == \ ('account', ) -def test_schema_reload(topology): - """Test that the appropriate task entry is created when reloading schema.""" - schema = Schema(topology.instance) + +def test_schema_reload(topo): + """Run a schema reload task + + :id: 995acc60-243b-45b0-9c1c-12bbe6a2882e + :setup: Standalone Instance + :steps: + 1. Add schema reload task + 2. Schema reload task succeeds + :expectedresults: + 1. Success + 2. Success + """ + + schema = Schema(topo.standalone) task = schema.reload() assert task.exists() task.wait() assert task.get_exit_code() == 0 +def test_x_origin(topo): + """ Test that the various forms of X-ORIGIN are handled correctly + + :id: 995acc60-243b-45b0-9c1c-12bbe6a2882d + :setup: Standalone Instance + :steps: + 1. Create schema file with specific/unique formats for X-ORIGIN + 2. Reload the schema file (schema reload task) + 3. List all attributes without error + 4. Confirm the expected results + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + """ + + # Create a custom schema file so we can tests specific formats + schema_file_name = topo.standalone.schemadir + '/98test.ldif' + schema_file = open(schema_file_name, "w") + testschema = ("dn: cn=schema\n" + + "attributetypes: ( 8.9.10.11.12.13.16 NAME 'testattr' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'USER_DEFINED' )\n" + + "attributetypes: ( 8.9.10.11.12.13.17 NAME 'testattrtwo' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN ( 'USER_DEFINED' 'should be not ignored!!' ) )\n") + schema_file.write(testschema) + schema_file.close() + + # Reload the schema + myschema = Schema(topo.standalone) + task = myschema.reload() + assert task.exists() + task.wait() + assert task.get_exit_code() == 0 + + # Now search attrs and make sure there are no errors + myschema.get_attributetypes() + myschema.get_objectclasses() + + # Check we have X-ORIGIN as expected + assert " 'USER_DEFINED' " in str(myschema.query_attributetype("testattr")) + assert " 'USER_DEFINED' " in str(myschema.query_attributetype("testattrtwo")) + + if __name__ == '__main__': # Run isolated # -s for DEBUG mode - import os CURRENT_FILE = os.path.realpath(__file__) - pytest.main("-s %s" % CURRENT_FILE) + pytest.main(["-s", CURRENT_FILE]) +
0
b2799df7aeae0f034846ca647e71134b23fa1ab5
389ds/389-ds-base
Bug 690090 - (cov#11974) Remove additional unused ACL functions There are a few more unused ACL functions to remove. One of these unused functions is causing coverity to report an error about memory corruption.
commit b2799df7aeae0f034846ca647e71134b23fa1ab5 Author: Nathan Kinder <[email protected]> Date: Thu Sep 9 15:04:53 2010 -0700 Bug 690090 - (cov#11974) Remove additional unused ACL functions There are a few more unused ACL functions to remove. One of these unused functions is causing coverity to report an error about memory corruption. diff --git a/lib/libaccess/acltools.cpp b/lib/libaccess/acltools.cpp index 28df59995..4e1274e28 100644 --- a/lib/libaccess/acltools.cpp +++ b/lib/libaccess/acltools.cpp @@ -1429,137 +1429,6 @@ char *errmsg; } -/* - * LOCAL FUNCTION - * - * Convert sub-expression to string. - */ - -static int -acl_expr_string( ACLExprOp_t logical, ACLExprStack_t *expr_stack ) -{ -char **expr_text; -char **prev_expr_text; -char *tmp; - - switch (logical) { - case ACL_EXPR_OP_NOT: - if ( expr_stack->stack_index < 1 ) { - printf("expression stack underflow.\n"); - return(ACLERRINTERNAL); - } - - expr_text = &expr_stack->expr_text[expr_stack->stack_index - 1]; - tmp = (char *) PERM_MALLOC(strlen(*expr_text) + 7); - if ( tmp == NULL ) - return(ACLERRNOMEM); - - if ( expr_stack->found_subexpression ) { - sprintf(tmp, "not (%s)", *expr_text); - expr_stack->found_subexpression = 0; - expr_stack->last_subexpression = expr_stack->stack_index - 1; - } else { - sprintf(tmp, "not %s", *expr_text); - } - - PERM_FREE(*expr_text); - *expr_text = tmp; - return(0); - - case ACL_EXPR_OP_AND: - case ACL_EXPR_OP_OR: - if ( expr_stack->stack_index < 2 ) { - printf("expression stack underflow.\n"); - return(ACLERRINTERNAL); - } - - expr_stack->stack_index--; - prev_expr_text = &expr_stack->expr_text[expr_stack->stack_index]; - expr_stack->stack_index--; - expr_text = &expr_stack->expr_text[expr_stack->stack_index]; - - tmp = (char *) PERM_MALLOC (strlen(*expr_text) - + strlen(*prev_expr_text) + 15); - if ( tmp == NULL ) - return(ACLERRNOMEM); - - if ( expr_stack->found_subexpression && - expr_stack->stack_index == expr_stack->last_subexpression && - logical == ACL_EXPR_OP_AND ) { - sprintf(tmp, "%s and\n (%s)", *expr_text, *prev_expr_text); - } else if ( expr_stack->found_subexpression && - expr_stack->stack_index == expr_stack->last_subexpression ) { - sprintf(tmp, "%s or\n (%s)", *expr_text, *prev_expr_text); - } else if ( logical == ACL_EXPR_OP_AND ) { - sprintf(tmp, "%s and\n %s", *expr_text, *prev_expr_text); - } else { - sprintf(tmp, "%s or\n %s", *expr_text, *prev_expr_text); - } - - expr_stack->found_subexpression++; - expr_stack->stack_index++; - PERM_FREE(*expr_text); - PERM_FREE(*prev_expr_text); - *expr_text = tmp; - *prev_expr_text = NULL; - return(0); - - default: - printf("Bad boolean logic value.\n"); - return(ACLERRINTERNAL); - } - -} - -/* - * LOCAL FUNCTION - * - * Reduce all sub-expressions to a single string. - */ - -static int -acl_reduce_expr_logic( ACLExprStack_t *expr_stack, ACLExprRaw_t *expr_raw ) -{ -char **expr_text; -char **prev_expr_text; -char *tmp; - - if (expr_raw->attr_name) { - if (expr_stack->stack_index >= ACL_EXPR_STACK ) { - printf("expression stack overflow."); - return(ACLERRINTERNAL); - } - - if ( expr_stack->found_subexpression && expr_stack->stack_index > 0 ) { - prev_expr_text = &expr_stack->expr_text[expr_stack->stack_index-1]; - tmp = (char *) PERM_MALLOC(strlen(*prev_expr_text) + 3); - sprintf(tmp, "(%s)", *prev_expr_text); - PERM_FREE(*prev_expr_text); - *prev_expr_text = tmp; - expr_stack->found_subexpression = 0; - expr_stack->last_subexpression = expr_stack->stack_index - 1; - } - - expr_stack->expr[expr_stack->stack_index] = expr_raw; - expr_text = &expr_stack->expr_text[expr_stack->stack_index]; - *expr_text = (char *) PERM_MALLOC(strlen(expr_raw->attr_name) - + strlen(expr_raw->attr_pattern) - + 7); - if ( *expr_text == NULL ) - return(ACLERRNOMEM); - - sprintf(*expr_text, "%s %s \"%s\"", expr_raw->attr_name, - acl_comp_string(expr_raw->comparator), - expr_raw->attr_pattern); - - expr_stack->stack_index++; - expr_stack->expr_text[expr_stack->stack_index] = NULL; - } else { - return(acl_expr_string(expr_raw->logical, expr_stack)); - } - return(0); -} - /* * Delete a named ACL from an ACL list
0
6714c45603a03ac8c2f1ef289aa390639676bdb5
389ds/389-ds-base
Issue: 50170 - composable object types for nsRole in lib389 Composable object types for nsRole in lib389 https://pagure.io/389-ds-base/issue/50170 Reviewed by: Ludwig Krispenz, William Brown, thierry bordaz
commit 6714c45603a03ac8c2f1ef289aa390639676bdb5 Author: Anuj Borah <[email protected]> Date: Wed Jan 16 20:36:15 2019 +0530 Issue: 50170 - composable object types for nsRole in lib389 Composable object types for nsRole in lib389 https://pagure.io/389-ds-base/issue/50170 Reviewed by: Ludwig Krispenz, William Brown, thierry bordaz diff --git a/dirsrvtests/tests/suites/roles/basic_test.py b/dirsrvtests/tests/suites/roles/basic_test.py new file mode 100644 index 000000000..6289d74f6 --- /dev/null +++ b/dirsrvtests/tests/suites/roles/basic_test.py @@ -0,0 +1,124 @@ +# --- 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 --- + +import pytest, os +from lib389._constants import PW_DM, DEFAULT_SUFFIX +from lib389.idm.user import UserAccount +from lib389.idm.organization import Organization +from lib389.idm.organizationalunit import OrganizationalUnit +from lib389.topologies import topology_st as topo +from lib389.idm.nsrole import nsFilterRoles + + +DNBASE = "o=acivattr,{}".format(DEFAULT_SUFFIX) +ENG_USER = "cn=enguser1,ou=eng,{}".format(DNBASE) +SALES_UESER = "cn=salesuser1,ou=sales,{}".format(DNBASE) +ENG_MANAGER = "cn=engmanager1,ou=eng,{}".format(DNBASE) +SALES_MANAGER = "cn=salesmanager1,ou=sales,{}".format(DNBASE) +SALES_OU = "ou=sales,{}".format(DNBASE) +ENG_OU = "ou=eng,{}".format(DNBASE) +FILTERROLESALESROLE = "cn=FILTERROLESALESROLE,{}".format(DNBASE) +FILTERROLEENGROLE = "cn=FILTERROLEENGROLE,{}".format(DNBASE) + + +def test_nsrole(topo): + ''' + :id: 8ada4064-786b-11e8-8634-8c16451d917b + :setup: server + :steps: + 1. Add test entry + 2. Add ACI + 3. Search nsconsole role + :expectedresults: + 1. Entry should be added + 2. Operation should succeed + 3. Operation should succeed + ''' + Organization(topo.standalone).create(properties={"o": "acivattr"}, basedn=DEFAULT_SUFFIX) + properties = { + 'ou': 'eng', + } + + ou = OrganizationalUnit(topo.standalone, "ou=eng,o=acivattr,{}".format(DEFAULT_SUFFIX)) + ou.create(properties=properties) + properties = {'ou': 'sales'} + ou = OrganizationalUnit(topo.standalone, "ou=sales,o=acivattr,{}".format(DEFAULT_SUFFIX)) + ou.create(properties=properties) + + roles = nsFilterRoles(topo.standalone, DNBASE) + roles.create(properties={'cn': 'FILTERROLEENGROLE', 'nsRoleFilter': 'cn=eng*'}) + roles.create(properties={'cn': 'FILTERROLESALESROLE', 'nsRoleFilter': 'cn=sales*'}) + + properties = { + 'uid': 'salesuser1', + 'cn': 'salesuser1', + 'sn': 'user', + 'uidNumber': '1000', + 'gidNumber': '2000', + 'homeDirectory': '/home/' + 'salesuser1', + 'userPassword': PW_DM + } + user = UserAccount(topo.standalone, 'cn=salesuser1,ou=sales,o=acivattr,{}'.format(DEFAULT_SUFFIX)) + user.create(properties=properties) + + properties = { + 'uid': 'salesmanager1', + 'cn': 'salesmanager1', + 'sn': 'user', + 'uidNumber': '1000', + 'gidNumber': '2000', + 'homeDirectory': '/home/' + 'salesmanager1', + 'userPassword': PW_DM, + } + user = UserAccount(topo.standalone, 'cn=salesmanager1,ou=sales,o=acivattr,{}'.format(DEFAULT_SUFFIX)) + user.create(properties=properties) + + properties = { + 'uid': 'enguser1', + 'cn': 'enguser1', + 'sn': 'user', + 'uidNumber': '1000', + 'gidNumber': '2000', + 'homeDirectory': '/home/' + 'enguser1', + 'userPassword': PW_DM + } + user = UserAccount(topo.standalone,'cn=enguser1,ou=eng,o=acivattr,{}'.format(DEFAULT_SUFFIX)) + user.create(properties=properties) + + properties = { + 'uid': 'engmanager1', + 'cn': 'engmanager1', + 'sn': 'user', + 'uidNumber': '1000', + 'gidNumber': '2000', + 'homeDirectory': '/home/' + 'engmanager1', + 'userPassword': PW_DM + } + user = UserAccount(topo.standalone, 'cn=engmanager1,ou=eng,o=acivattr,{}'.format(DEFAULT_SUFFIX)) + user.create(properties=properties) + + #user with cn=sales* will automatically memeber of nsfilterrole cn=filterrolesalesrole,o=acivattr,dc=example,dc=com + assert UserAccount(topo.standalone, 'cn=salesuser1,ou=sales,o=acivattr,dc=example,dc=com').get_attr_val_utf8( + 'nsrole') == 'cn=filterrolesalesrole,o=acivattr,dc=example,dc=com' + # same goes to SALES_MANAGER + assert UserAccount(topo.standalone, SALES_MANAGER).get_attr_val_utf8( + 'nsrole') == 'cn=filterrolesalesrole,o=acivattr,dc=example,dc=com' + # user with cn=eng* will automatically memeber of nsfilterrole cn=filterroleengrole,o=acivattr,dc=example,dc=com + assert UserAccount(topo.standalone, 'cn=enguser1,ou=eng,o=acivattr,dc=example,dc=com').get_attr_val_utf8( + 'nsrole') == 'cn=filterroleengrole,o=acivattr,dc=example,dc=com' + # same goes to ENG_MANAGER + assert UserAccount(topo.standalone, ENG_MANAGER).get_attr_val_utf8( + 'nsrole') == 'cn=filterroleengrole,o=acivattr,dc=example,dc=com' + for DN in [ENG_USER, SALES_UESER, ENG_MANAGER, SALES_MANAGER, FILTERROLESALESROLE, FILTERROLEENGROLE, ENG_OU, + SALES_OU, DNBASE]: + UserAccount(topo.standalone, DN).delete() + + +if __name__ == "__main__": + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s -v %s" % CURRENT_FILE) diff --git a/src/lib389/lib389/idm/nsrole.py b/src/lib389/lib389/idm/nsrole.py new file mode 100644 index 000000000..482837de3 --- /dev/null +++ b/src/lib389/lib389/idm/nsrole.py @@ -0,0 +1,70 @@ +# --- 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 ---- + + +from lib389._mapped_object import DSLdapObject, DSLdapObjects + + +class nsFilterRole(DSLdapObject): + """A single instance of nsfilter entry to create nsFIltered role. + + :param instance: An instance + :type instance: lib389.DirSrv + :param dn: Entry DN + :type dn: str + Usages: + user1 = 'cn=anuj,ou=people,dc=example,ed=com' + user2 = 'cn=unknownuser,ou=people,dc=example,ed=com' + role=nsFilterRole(topo.standalone,'cn=NameofRole,ou=People,dc=example,dc=com') + role_props={'cn':'Anuj', 'nsRoleFilter':'cn=anuj*'} + role.create(properties=role_props, basedn=SUFFIX) + The user1 entry matches the filter (possesses the cn=anuj* attribute with the value anuj) + therefore, it is a member of this filtered role automatically. + """ + def __init__(self, instance, dn=None): + super(nsFilterRole, self).__init__(instance, dn) + self._rdn_attribute = 'cn' + self._create_objectclasses = [ + 'top', + 'nsRoleDefinition', + 'nsComplexRoleDefinition', + 'nsFilteredRoleDefinition' + ] + + +class nsFilterRoles(DSLdapObjects): + """DSLdapObjects that represents all nsfiltertrole entries in suffix. + + This instance is used mainly for search operation nsfiltred role + + :param instance: An instance + :type instance: lib389.DirSrv + :param basedn: Suffix DN + :type basedn: str + :param rdn: The DN that will be combined wit basedn + :type rdn: str + Usages: + role_props={'cn':'Anuj', 'nsRoleFilter':'cn=*'} + nsFilterRoles(topo.standalone, DEFAULT_SUFFIX).create(properties=role_props) + nsFilterRoles(topo.standalone, DEFAULT_SUFFIX).list() + user1 = 'cn=anuj,ou=people,dc=example,ed=com' + user2 = 'uid=unknownuser,ou=people,dc=example,ed=com' + The user1 entry matches the filter (possesses the cn=* attribute with the value cn) + therefore, it is a member of this filtered role automatically. + """ + def __init__(self, instance, basedn): + super(nsFilterRoles, self).__init__(instance) + self._objectclasses = [ + 'top', + 'nsRoleDefinition', + 'nsComplexRoleDefinition', + 'nsFilteredRoleDefinition' + ] + self._filterattrs = ['cn'] + self._basedn = basedn + self._childobject = nsFilterRole
0
9fc10279fd79d602cda9e0250d96f32b8d005120
389ds/389-ds-base
Ticket 49075 - Adjust log severity levels Description: There were some levels that were set too severely for normal messages. Also in ssl.c we test if the cert db file exists before we try and chmod it. https://fedorahosted.org/389/ticket/49075 Reviewed by: nhosoi(Thanks!)
commit 9fc10279fd79d602cda9e0250d96f32b8d005120 Author: Mark Reynolds <[email protected]> Date: Wed Jan 4 16:54:20 2017 -0500 Ticket 49075 - Adjust log severity levels Description: There were some levels that were set too severely for normal messages. Also in ssl.c we test if the cert db file exists before we try and chmod it. https://fedorahosted.org/389/ticket/49075 Reviewed by: nhosoi(Thanks!) diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index 04d31b12b..683994f38 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -1473,11 +1473,11 @@ 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_NOTICE, "dblayer_start", "Resizing db cache size: %lu -> %lu\n", + slapi_log_err(SLAPI_LOG_INFO, "dblayer_start", "Resizing db cache size: %lu -> %lu\n", priv->dblayer_previous_cachesize, priv->dblayer_cachesize); } if (priv->dblayer_ncache != priv->dblayer_previous_ncache) { - slapi_log_err(SLAPI_LOG_NOTICE, "dblayer_start", "Resizing db cache count: %d -> %d\n", + slapi_log_err(SLAPI_LOG_INFO, "dblayer_start", "Resizing db cache count: %d -> %d\n", priv->dblayer_previous_ncache, priv->dblayer_ncache); } if (priv->dblayer_lock_config != priv->dblayer_previous_lock_config) { @@ -1989,7 +1989,7 @@ int dblayer_instance_start(backend *be, int mode) * but nsslapd-db-private-import-mem should work with import, * as well */ if (priv->dblayer_private_import_mem) { - slapi_log_err(SLAPI_LOG_WARNING, + slapi_log_err(SLAPI_LOG_INFO, "dblayer_instance_start", "Import is running with " "nsslapd-db-private-import-mem on; " "No other process is allowed to access the database\n"); @@ -5656,7 +5656,7 @@ dblayer_copyfile(char *source, char *destination, int overwrite, int mode) destination, strerror(errno)); goto error; } - slapi_log_err(SLAPI_LOG_BACKLDBM, + slapi_log_err(SLAPI_LOG_INFO, "dblayer_copyfile", "Copying %s to %s\n", source, destination); /* Loop round reading data and writing it */ while (1) diff --git a/ldap/servers/slapd/back-ldbm/dbverify.c b/ldap/servers/slapd/back-ldbm/dbverify.c index cb175bdf3..53c9f78df 100644 --- a/ldap/servers/slapd/back-ldbm/dbverify.c +++ b/ldap/servers/slapd/back-ldbm/dbverify.c @@ -159,7 +159,7 @@ dbverify_ext( ldbm_instance *inst, int verbose ) { if (verbose) { - slapi_log_err(SLAPI_LOG_ERR, "dbverify_ext", + slapi_log_err(SLAPI_LOG_INFO, "dbverify_ext", "%s: ok\n", dbdir); } } diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c index 055777842..5b814275d 100644 --- a/ldap/servers/slapd/back-ldbm/import-threads.c +++ b/ldap/servers/slapd/back-ldbm/import-threads.c @@ -1465,7 +1465,7 @@ upgradedn_producer(void *param) if (!chk_dn_norm && !chk_dn_norm_sp) { /* Nothing to do... */ - slapi_log_err(SLAPI_LOG_ERR, "upgradedn_producer", + slapi_log_err(SLAPI_LOG_INFO, "upgradedn_producer", "UpgradeDnFormat is not required.\n"); info->state = FINISHED; goto done; @@ -1526,7 +1526,7 @@ upgradedn_producer(void *param) if (0 != db_rval) { if (DB_NOTFOUND == db_rval) { - slapi_log_err(SLAPI_LOG_ERR, "upgradedn_producer", + slapi_log_err(SLAPI_LOG_INFO, "upgradedn_producer", "%s: Finished reading database\n", inst->inst_name); if (job->task) { slapi_task_log_notice(job->task, @@ -1604,7 +1604,7 @@ upgradedn_producer(void *param) pid, &id, &psrdn, &curr_entry); if (rc) { slapi_log_err(SLAPI_LOG_ERR, - "uptradedn: Failed to compose dn for " + "upgradedn: Failed to compose dn for " "(rdn: %s, ID: %d)\n", rdn, temp_id); slapi_ch_free_string(&rdn); slapi_rdn_done(&psrdn); @@ -2101,9 +2101,10 @@ upgradedn_producer(void *param) newesize = (slapi_entry_size(ep->ep_entry) + sizeof(struct backentry)); if (import_fifo_validate_capacity_or_expand(job, newesize) == 1) { - import_log_notice(job, SLAPI_LOG_ERR, "upgradedn_producer", "Skipping entry \"%s\"", + import_log_notice(job, SLAPI_LOG_NOTICE, "upgradedn_producer", "Skipping entry \"%s\"", slapi_entry_get_dn(e)); - import_log_notice(job, SLAPI_LOG_ERR, "upgradedn_producer", "REASON: entry too large (%lu bytes) for " + import_log_notice(job, SLAPI_LOG_NOTICE, "upgradedn_producer", + "REASON: entry too large (%lu bytes) for " "the buffer size (%lu bytes), and we were UNABLE to expand buffer.", (long unsigned int)newesize, (long unsigned int)job->fifo.bsize); backentry_free(&ep); diff --git a/ldap/servers/slapd/back-ldbm/instance.c b/ldap/servers/slapd/back-ldbm/instance.c index 84748548e..f79d048d2 100644 --- a/ldap/servers/slapd/back-ldbm/instance.c +++ b/ldap/servers/slapd/back-ldbm/instance.c @@ -249,9 +249,9 @@ ldbm_instance_start(backend *be) if (be->be_state != BE_STATE_STOPPED && be->be_state != BE_STATE_DELETED) { - slapi_log_err(SLAPI_LOG_TRACE, - "ldbm_instance_start", "Warning - backend is in a wrong state - %d\n", - be->be_state); + slapi_log_err(SLAPI_LOG_TRACE, "ldbm_instance_start", + "Warning - backend is in a wrong state - %d\n", + be->be_state); PR_Unlock (be->be_state_lock); return 0; } @@ -370,8 +370,9 @@ ldbm_instance_destructor(void **arg) { ldbm_instance *inst = (ldbm_instance *) *arg; - slapi_log_err(SLAPI_LOG_ERR, "ldbm_instance_destructor", "Destructor for instance %s called\n", - inst->inst_name); + slapi_log_err(SLAPI_LOG_TRACE, "ldbm_instance_destructor", + "Destructor for instance %s called\n", + inst->inst_name); slapi_counter_destroy(&(inst->inst_ref_count)); slapi_ch_free_string(&inst->inst_name); diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c index f6da41438..f35b3f190 100644 --- a/ldap/servers/slapd/ssl.c +++ b/ldap/servers/slapd/ssl.c @@ -25,6 +25,7 @@ #define NEED_TOK_PBE /* defines tokPBE and ptokPBE - see slap.h */ #include "slap.h" +#include <unistd.h> #include "svrcore.h" #include "fe.h" @@ -1288,27 +1289,39 @@ slapd_nss_init(int init_ssl, int config_available) secmoddb_file_name = slapi_ch_smprintf("%s/secmod.db", certdir); pkcs11txt_file_name = slapi_ch_smprintf("%s/pkcs11.txt", certdir); - if(chmod(cert8db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){ + if(access(cert8db_file_name, F_OK) == 0 && + chmod(cert8db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) + { slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", "slapd_nss_init - chmod failed for file %s error (%d) %s.\n", cert8db_file_name, errno, slapd_system_strerror(errno)); } - if(chmod(cert9db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){ + if(access(cert9db_file_name, F_OK) == 0 && + chmod(cert9db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) + { slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", "slapd_nss_init - chmod failed for file %s error (%d) %s.\n", cert9db_file_name, errno, slapd_system_strerror(errno)); } - if(chmod(key3db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){ + if(access(key3db_file_name, F_OK) == 0 && + chmod(key3db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) + { slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", "slapd_nss_init - chmod failed for file %s error (%d) %s.\n", key3db_file_name, errno, slapd_system_strerror(errno)); } - if(chmod(key4db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){ + if(access(key4db_file_name, F_OK) == 0 && + chmod(key4db_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) + { slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", "slapd_nss_init - chmod failed for file %s error (%d) %s.\n", key4db_file_name, errno, slapd_system_strerror(errno)); } - if(chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){ + if(access(secmoddb_file_name, F_OK) == 0 && + chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) + { slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", "slapd_nss_init - chmod failed for file %s error (%d) %s.\n", secmoddb_file_name, errno, slapd_system_strerror(errno)); } - if(chmod(pkcs11txt_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){ + if(access(pkcs11txt_file_name, F_OK) == 0 && + chmod(pkcs11txt_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) + { slapi_log_err(SLAPI_LOG_WARNING, "Security Initialization", "slapd_nss_init - chmod failed for file %s error (%d) %s.\n", pkcs11txt_file_name, errno, slapd_system_strerror(errno)); }
0
495ee204b7f124976dacd70a8cb72c1cfc8acef0
389ds/389-ds-base
Issue 51091 - healthcheck json report fails when mapping tree is deleted Description: We were passing the bename in bytes and not as a utf8 string. This caused the json dumping to fail. relates: https://pagure.io/389-ds-base/issue/51091 Reviewed by: firstyear(Thanks!)
commit 495ee204b7f124976dacd70a8cb72c1cfc8acef0 Author: Mark Reynolds <[email protected]> Date: Thu May 14 09:38:20 2020 -0400 Issue 51091 - healthcheck json report fails when mapping tree is deleted Description: We were passing the bename in bytes and not as a utf8 string. This caused the json dumping to fail. relates: https://pagure.io/389-ds-base/issue/51091 Reviewed by: firstyear(Thanks!) diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py index e472d3de5..4f752f414 100644 --- a/src/lib389/lib389/backend.py +++ b/src/lib389/lib389/backend.py @@ -11,7 +11,7 @@ import copy import ldap from lib389._constants import * from lib389.properties import * -from lib389.utils import normalizeDN, ensure_str, ensure_bytes, assert_c +from lib389.utils import normalizeDN, ensure_str, assert_c from lib389 import Entry # Need to fix this .... @@ -488,10 +488,10 @@ class Backend(DSLdapObject): # Check for the missing mapping tree. suffix = self.get_attr_val_utf8('nsslapd-suffix') - bename = self.get_attr_val_bytes('cn') + bename = self.get_attr_val_utf8('cn') try: mt = self._mts.get(suffix) - if mt.get_attr_val_bytes('nsslapd-backend') != bename and mt.get_attr_val('nsslapd-state') != ensure_bytes('backend'): + if mt.get_attr_val_utf8('nsslapd-backend') != bename and mt.get_attr_val_utf8('nsslapd-state') != 'backend': raise ldap.NO_SUCH_OBJECT("We have a matching suffix, but not a backend or correct database name.") except ldap.NO_SUCH_OBJECT: result = DSBLE0001
0
5a3bdc33620838585c4954014038698a72fbe4c5
389ds/389-ds-base
Issue 5217 - Simplify instance creation and administration by non root user (#5224)
commit 5a3bdc33620838585c4954014038698a72fbe4c5 Author: progier389 <[email protected]> Date: Thu Mar 24 15:59:54 2022 +0100 Issue 5217 - Simplify instance creation and administration by non root user (#5224) diff --git a/dirsrvtests/tests/suites/setup_ds/dscreate_test.py b/dirsrvtests/tests/suites/setup_ds/dscreate_test.py index d83d159fc..218343443 100644 --- a/dirsrvtests/tests/suites/setup_ds/dscreate_test.py +++ b/dirsrvtests/tests/suites/setup_ds/dscreate_test.py @@ -7,6 +7,11 @@ # --- END COPYRIGHT BLOCK --- import sys import pytest +import subprocess +import logging +import pwd +import re +from tempfile import TemporaryDirectory from lib389 import DirSrv from lib389.cli_base import LogCapture from lib389.instance.setup import SetupDs @@ -18,10 +23,17 @@ from lib389.utils import ds_is_older pytestmark = [pytest.mark.tier0, pytest.mark.skipif(ds_is_older('1.4.1.2'), reason="Needs a compatible systemd unit, see PR#50213")] +DEBUGGING = os.getenv('DEBUGGING', False) +if DEBUGGING: + logging.getLogger(__name__).setLevel(logging.DEBUG) +else: + logging.getLogger(__name__).setLevel(logging.INFO) +log = logging.getLogger(__name__) + INSTANCE_PORT = 54321 INSTANCE_SECURE_PORT = 54322 INSTANCE_SERVERID = 'standalone' -DEBUGGING = True +#DEBUGGING = True MAJOR, MINOR, _, _, _ = sys.version_info @@ -115,3 +127,133 @@ def test_setup_ds_minimal(topology): topology.standalone.start() # Okay, actually remove the instance remove_ds_instance(topology.standalone) + +def write_file(fname, pwd, is_runnable, lines): + log.debug(f'Creating file {fname} with:') + with open(fname, 'wt') as f: + for line in lines: + log.debug(line) + f.write(line+'\n') + os.chown(fname, pwd.pw_uid, pwd.pw_gid) + if (is_runnable): + os.chmod(fname, 0o755) + log.debug(f'End of file: {fname}') + +def test_setup_ds_as_non_root(): + """Test creating an instance as a non root user + + :id: c727998e-a960-11ec-898e-482ae39447e5 + :setup: no instance + :steps: + 1. Add linux user NON_ROOT_USER if it does not already exist + 2. Create a temporary directory + 3. Create test.sh script that + Set Paths + Run dscreate ds-root + Run dscreate from-file + Add a backend + Search users in backend and store output in a file + Stop the instance + 4. Create a dscreate template file + 5. Run su - NON_ROOT_USER test.sh + 6. Check that pid file exists and kill the associated process + 7. Check demo_user is in the search result + 8. Check that test.sh returned 0 + 9. (Implicit task): remove the temporary + + + :expectedresults: + 1. No error. + 2. No error. + 3. No error. + 4. No error. + 5. No error. + 6. Should fail to kill the process (That is supposed to be stopped) + 7. demo_user should be in search result + 8. return code should be 0 + 9. No error. + + """ + + # Add linux user NON_ROOT_USER if it does not already exist + NON_ROOT_USER='user1' + try: + pwd_nru = pwd.getpwnam(NON_ROOT_USER) + except KeyError: + subprocess.run(('/usr/sbin/useradd', NON_ROOT_USER)) + pwd_nru = pwd.getpwnam(NON_ROOT_USER) + + # Create a temporary directory + with TemporaryDirectory() as dir: + os.chown(dir, pwd_nru.pw_uid, pwd_nru.pw_gid) + # Prepare test script + if DEBUGGING: + dbg_script = ( + 'savedir()', + '{', + f' cp -R {dir} /tmp/dbg_test_setup_ds_as_non_root', + '}', + 'trap savedir exit', + 'trap savedir err', + ) + else: + dbg_script = ( ) + # Export current path and python path in test script + # to insure that right binary/libraries are used + path = os.environ['PATH'] + pythonpath = os.getenv('PYTHONPATH', '') + write_file(f'{dir}/test.sh', pwd_nru, True, ( + '#!/usr/bin/bash', + 'set -x', + *dbg_script, + f'export PATH="{dir}/bin:{path}:$PATH"', + f'export PYTHONPATH="{pythonpath}:$PYTHONPATH"', + 'set -e # Exit on error', + 'type dscreate', + f'dscreate ds-root {dir}/root {dir}/bin', + 'hash -d dscreate # Remove dscreate from hash to use the new one', + 'type dscreate', + f'dscreate from-file {dir}/t', + f'dsconf {INSTANCE_SERVERID} backend create --suffix dc=foo,dc=bar --be-name=foo --create-entries', + f'ldapsearch -x -H ldap://localhost:{INSTANCE_PORT} -D "cn=directory manager" -w {PW_DM} -b dc=foo,dc=bar "uid=*" | tee {dir}/search.out', + f'dsctl {INSTANCE_SERVERID} stop', + 'exit 0', + )) + # Prepare dscreate template + write_file(f'{dir}/t', pwd_nru, False, ( + '[general]', + '[slapd]', + f'port = {INSTANCE_PORT}', + f'instance_name = {INSTANCE_SERVERID}', + f'root_password = {PW_DM}', + f'secure_port = {INSTANCE_SECURE_PORT}', + '[backend-userroot]', + 'create_suffix_entry = True', + 'require_index = True', + 'sample_entries = yes', + 'suffix = dc=example,dc=com', + )) + # Run the script as NON_ROOT_USER + log.debug(f'Run script {dir}/test.sh as user {NON_ROOT_USER}') + result = subprocess.run(('/usr/bin/su', '-', NON_ROOT_USER, f'{dir}/test.sh'), capture_output=True, text=True) + log.info(f'test.sh stdout is: {str(result.stdout)}') + log.info(f'test.sh stderr is: {str(result.stderr)}') + + # Check that pid file exists + log.debug(f'Check that pid file {dir}/root/run/dirsrv/slapd-{INSTANCE_SERVERID}.pid exist') + pid_filename = f'{dir}/root/run/dirsrv/slapd-{INSTANCE_SERVERID}.pid' + with open(pid_filename, 'rt') as f: + pid = int(f.readline()) + assert pid>1 + # Signal the 389ds instance to stop (and raise an exception if we can do that) + # because the process should already be stopped. + log.debug(f'Check that instance with pid {pid} is stopped') + with pytest.raises(OSError) as e_info: + os.kill(pid, 15) + # Let check that demo_user is in the search result + log.debug(f'Check that {dir}/search.out contains with pid {pid} is stopped') + with open(f'{dir}/search.out', 'rt') as f: + assert(re.findall('demo_user', f.read())) + log.debug(f'Check that Wtest.sh finihed successfully.') + assert(result.returncode == 0) + # Instance got deleted by the with cleanup diff --git a/src/lib389/cli/dscreate b/src/lib389/cli/dscreate index c35525964..0b41166cc 100755 --- a/src/lib389/cli/dscreate +++ b/src/lib389/cli/dscreate @@ -14,12 +14,23 @@ import argparse, argcomplete import sys import signal import json +from textwrap import dedent from lib389 import DirSrv from lib389.cli_ctl import instance as cli_instance from lib389.cli_base import setup_script_logger from lib389.cli_base import format_error_to_dict -parser = argparse.ArgumentParser() + +epilog = """ + Example of install by a non root user: + PATH=$HOME/bin:$PATH # Should be in .profile + dscreate ds-root $HOME/mydsroot $HOME/bin + hash -d dscreate # bash command to insure new dscreate wrapper will be used + dscreate interactive + # Note: Make sure to use non priviledged port number (i.e > 1000) + """ + +parser = argparse.ArgumentParser(epilog=dedent(epilog), formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-v', '--verbose', help="Display verbose operation tracing during command execution", action='store_true', default=False, dest='verbose') @@ -40,9 +51,13 @@ interactive_parser.set_defaults(func=cli_instance.instance_create_interactive) template_parser = subparsers.add_parser('create-template', help="Display an example inf answer file, or provide a file name to write it to disk.") template_parser.add_argument('--advanced', action='store_true', default=False, help="Add advanced options to the template - changing the advanced options may make your instance install fail") -template_parser.add_argument('template_file', nargs="?", default=None, help="Write example template to this file") +template_parser.add_argument('template_file', nargs="?", default='None', help="Write example template to this file") template_parser.set_defaults(func=cli_instance.instance_example) +subtree_parser = subparsers.add_parser('ds-root', help="Prepare a root directory in which non root user can create, run and administer instances.") +subtree_parser.add_argument('root_dir', default=None, help="A directory that will be used as virtual root.") +subtree_parser.add_argument('bin_dir', nargs="?", default=None, help="A directory in which administration wrappers are installed. (Should be in PATH)") +subtree_parser.set_defaults(func=cli_instance.prepare_ds_root) argcomplete.autocomplete(parser) # handle a control-c gracefully diff --git a/src/lib389/lib389/cli_ctl/instance.py b/src/lib389/lib389/cli_ctl/instance.py index ae2bb1a88..2e289004b 100644 --- a/src/lib389/lib389/cli_ctl/instance.py +++ b/src/lib389/lib389/cli_ctl/instance.py @@ -7,8 +7,11 @@ # --- END COPYRIGHT BLOCK --- import os +import pwd +import grp import json import time +from shutil import copytree, copyfile from lib389 import DirSrv from lib389.instance.setup import SetupDs from lib389.utils import get_instance_list @@ -120,6 +123,135 @@ def instance_example(inst, log, args): return True +def prepare_ds_root(inst, log, args): + def get_dest(path): + # Compute the destination path from original path + if path.startswith('/usr/'): + return f'{args.root_dir}/{path[5:]}' + return f'{args.root_dir}/{path}' + + def copy_and_substitute(file, sub_list): + # Copy .inf file and apply all sub_list modifiers to each line + # Supported modifier are: + # (WORD, pattern, value) ==> Replace first occurance of pattern by value + # (LINE, pattern, value) ==> Replace line statring with pattern + # by: pattern = value + log.debug(f'Update {get_dest(file)} from {file}') + with open(file, 'rt') as fin: + with open(get_dest(file), 'wt') as fout: + for line in fin: + for k, p, v in sub_list: + if k == 'WORD': + line = line.replace(p, v, 1) + if k == 'LINE': + if line.startswith(p): + line = f'{p} = {v}\n' + fout.write(line) + + def copy_and_skip_entry(file, pattern_list): + # copy ldif file skipping entries containing a pattern from pattern_list + class Entry: + # Helper class to handle the ldif entries + def __init__(self): + self.skip = False + self.entry = "" + + def add_line(self, line): + self.entry += line + for p in pattern_list: + if p in line: + self.skip = True + + def write(self, fout): + if not self.skip: + fout.write(self.entry) + + log.debug(f'Update {get_dest(file)} from {file}') + with open(file, 'rt') as fin: + with open(get_dest(file), 'wt') as fout: + entry = Entry() + for line in fin: + entry.add_line(line) + if line == "\n": + entry.write(fout) + entry = Entry() + entry.write(fout) + + uid = os.getuid() + if uid == 0: + raise ValueError("ds-root subcommand should not be run by root user.") + user = pwd.getpwuid(uid).pw_name + group = grp.getgrgid(os.getgid()).gr_name + + # Perform consistency checks then create the wrappers + if args.bin_dir: + found = False + for path in os.environ['PATH'].split(':'): + if path.startswith('.'): + continue + if path == args.bin_dir: + found = True + break + if os.path.exists(f'{path}/dsconf'): + log.error(f'bin_dir argument should be before {path} in PATH') + return False + if not found: + log.error(f'bin_dir argument should be in PATH') + return False + os.makedirs(args.bin_dir, 0o755, True) + for wrapper in ['dsconf', 'dscreate', 'dsctl', 'dsidm']: + log.debug(f'Creating {args.bin_dir}/{wrapper} wrapper') + with open(f'{args.bin_dir}/{wrapper}', 'wt') as f: + f.write('#!/bin/sh\n') + f.write(f'export PATH="{args.root_dir}:$PATH"\n') + f.write(f'export PREFIX="{args.root_dir}"\n') + f.write(f'export INSTALL_PREFIX="{args.root_dir}"\n') + p = "${@}" + f.write(f'exec /usr/sbin/{wrapper} "{p}"\n') + os.chmod(f'{args.bin_dir}/{wrapper}', 0o755) + os.makedirs(args.root_dir, 0o700, True) + # Copy subtrees + for dir in ['/usr/share/dirsrv/', '/etc/dirsrv/config', '/etc/dirsrv/schema', ]: + destdir = get_dest(dir) + log.debug(f'Copying {dir} into {destdir}') + os.makedirs(destdir, 0o755, True) + copytree(dir, destdir, dirs_exist_ok=True) + # Create empty directories + for dir in ['/tmp', ]: + destdir = get_dest(dir) + log.debug(f'Creating directory {destdir}') + os.makedirs(destdir, 0o755, True) + # Copy binaries + for bin in ['/usr/sbin/ns-slapd']: + destbin = get_dest(bin) + log.debug(f'Copying {bin} into {destbin}') + os.makedirs(os.path.dirname(destbin), 0o755, True) + copyfile(bin, destbin) + # And finally, update the template files + for dse in ('/usr/share/dirsrv/data/template-dse-minimal.ldif', '/usr/share/dirsrv/data/template-dse.ldif'): + copy_and_skip_entry(dse, ('libpwdchan-plugin',)) + # Use PO and PF to escape { } in formatted strings + PO = '{' + PF = '}' + copy_and_substitute('/usr/share/dirsrv/inf/defaults.inf', ( + ('WORD', ' /', f' {args.root_dir}/'), + ('LINE', 'with_selinux', 'no'), + ('LINE', 'with_systemd', '0'), + ('LINE', 'user', user), + ('LINE', 'group', group), + ('LINE', 'prefix', args.root_dir), + ('LINE', 'bin_dir', '/usr/bin'), + ('LINE', 'sbin_dir', '/usr/sbin'), + ('LINE', 'lib_dir', '/usr/lib64'), + ('LINE', 'data_dir', f'{args.root_dir}/share'), + ('LINE', 'inst_dir', f'{args.root_dir}/lib64/slapd-{PO}instance_name{PF}'), + ('LINE', 'plugin_dir', '/usr/lib64/dirsrv/plugins'), + ('LINE', 'system_schema_dir', f'{args.root_dir}/share/dirsrv/schema'), + )) + + return True + + def instance_remove_all(log, args): """Remove all instances - clean sweep! """
0
b08fa7e6d4b2eae22eef4931af86353274ef3945
389ds/389-ds-base
Ticket 48846 - Older kernels do not expose memavailable Bug Description: Old kernels do not expose MemAvailable. As a result this would be 0, and would be the lowest value in the check. Fix Description: Check that our values for util_sys_pages is > 0 https://fedorahosted.org/389/ticket/48846 Author: wibrown Review by: nhosoi (Thanks!)
commit b08fa7e6d4b2eae22eef4931af86353274ef3945 Author: William Brown <[email protected]> Date: Fri May 20 22:34:57 2016 +1000 Ticket 48846 - Older kernels do not expose memavailable Bug Description: Old kernels do not expose MemAvailable. As a result this would be 0, and would be the lowest value in the check. Fix Description: Check that our values for util_sys_pages is > 0 https://fedorahosted.org/389/ticket/48846 Author: wibrown Review by: nhosoi (Thanks!) diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c index e7b02fa24..070a7dbfe 100644 --- a/ldap/servers/slapd/util.c +++ b/ldap/servers/slapd/util.c @@ -1670,15 +1670,15 @@ int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size (unsigned long)*pages, (unsigned long)*availpages, (unsigned long)freesize); } - if (rlimsize != RLIM_INFINITY && rlimsize < freesize && rlimsize < *pages) { + if (rlimsize != RLIM_INFINITY && rlimsize < freesize && rlimsize < *pages && rlimsize > 0) { LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using getrlim for availpages \n",0,0,0); *availpages = rlimsize; - } else if (*pages < freesize) { - LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using pages for availpages \n",0,0,0); - *availpages = *pages; - } else { + } else if (freesize < *pages && freesize > 0) { 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 pages for availpages \n",0,0,0); + *availpages = *pages; } }
0
fa74996f6e56c5035dc5e8392f4117aad944ee8e
389ds/389-ds-base
Fix missing import Reviewed by: one line commit rule
commit fa74996f6e56c5035dc5e8392f4117aad944ee8e Author: Viktor Ashirov <[email protected]> Date: Tue May 14 10:24:15 2019 +0200 Fix missing import Reviewed by: one line commit rule diff --git a/dirsrvtests/tests/suites/setup_ds/dscreate_test.py b/dirsrvtests/tests/suites/setup_ds/dscreate_test.py index 1c98b2aa1..b8a73dd85 100644 --- a/dirsrvtests/tests/suites/setup_ds/dscreate_test.py +++ b/dirsrvtests/tests/suites/setup_ds/dscreate_test.py @@ -15,6 +15,7 @@ from lib389.instance.setup import SetupDs from lib389.instance.remove import remove_ds_instance from lib389.instance.options import General2Base, Slapd2Base from lib389._constants import * +from lib389.utils import ds_is_older import tempfile
0
6a21e8e9be90de76549b8fb37dc744ca48234e00
389ds/389-ds-base
Trac Ticket #412 - memberof performance enhancement https://fedorahosted.org/389/ticket/412 Fix description: memberof.c: replaced DN strings with Slapi_DN and set the normalized info to Slapi_Value flags. It reduces the number of slaip_dn_normalize_ext call by ~25%. attr.c, slapi-plugin.h: introduced a new API slapi_attr_ value_cmp_ext which takes Slapi_Value instead of struct berval. By replacing with Slapi_Value, the value flag (e.g., normalized info) can be passed to the syntax plugin. value.c: changed slapi_value_compare to call slapi_attr_ value_cmp_ext instead of slapi_attr_value_cmp.
commit 6a21e8e9be90de76549b8fb37dc744ca48234e00 Author: Noriko Hosoi <[email protected]> Date: Tue Jul 17 17:26:09 2012 -0700 Trac Ticket #412 - memberof performance enhancement https://fedorahosted.org/389/ticket/412 Fix description: memberof.c: replaced DN strings with Slapi_DN and set the normalized info to Slapi_Value flags. It reduces the number of slaip_dn_normalize_ext call by ~25%. attr.c, slapi-plugin.h: introduced a new API slapi_attr_ value_cmp_ext which takes Slapi_Value instead of struct berval. By replacing with Slapi_Value, the value flag (e.g., normalized info) can be passed to the syntax plugin. value.c: changed slapi_value_compare to call slapi_attr_ value_cmp_ext instead of slapi_attr_value_cmp. diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c index fc4529d78..a2fdbd942 100644 --- a/ldap/servers/plugins/memberof/memberof.c +++ b/ldap/servers/plugins/memberof/memberof.c @@ -108,57 +108,60 @@ static int memberof_postop_close(Slapi_PBlock *pb); /* supporting cast */ static int memberof_oktodo(Slapi_PBlock *pb); -static char *memberof_getdn(Slapi_PBlock *pb); +static Slapi_DN *memberof_getsdn(Slapi_PBlock *pb); static int memberof_modop_one(Slapi_PBlock *pb, MemberOfConfig *config, int mod_op, - char *op_this, char *op_to); + Slapi_DN *op_this_sdn, Slapi_DN *op_to_sdn); static int memberof_modop_one_r(Slapi_PBlock *pb, MemberOfConfig *config, int mod_op, - char *group_dn, char *op_this, char *op_to, memberofstringll *stack); -static int memberof_add_one(Slapi_PBlock *pb, MemberOfConfig *config, char *addthis, - char *addto); -static int memberof_del_one(Slapi_PBlock *pb, MemberOfConfig *config, char *delthis, - char *delfrom); -static int memberof_mod_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, int mod, - char *groupdn, Slapi_Mod *smod); + Slapi_DN *group_sdn, Slapi_DN *op_this_sdn, Slapi_DN *op_to_sdn, + memberofstringll *stack); +static int memberof_add_one(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *addthis_sdn, Slapi_DN *addto_sdn); +static int memberof_del_one(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *delthis_sdn, Slapi_DN *delfrom_sdn); +static int memberof_mod_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, + int mod, Slapi_DN *group_sdn, Slapi_Mod *smod); static int memberof_add_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *groupdn, Slapi_Mod *smod); + Slapi_DN *group_sdn, Slapi_Mod *smod); static int memberof_del_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *groupdn, Slapi_Mod *smod); + Slapi_DN *group_sdn, Slapi_Mod *smod); static int memberof_mod_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, int mod, - char *groupdn, Slapi_Attr *attr); + Slapi_DN *group_sdn, Slapi_Attr *attr); static int memberof_mod_attr_list_r(Slapi_PBlock *pb, MemberOfConfig *config, - int mod, char *group_dn, char *op_this, Slapi_Attr *attr, memberofstringll *stack); + int mod, Slapi_DN *group_sdn, Slapi_DN *op_this_sdn, Slapi_Attr *attr, + memberofstringll *stack); static int memberof_add_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *groupdn, Slapi_Attr *attr); + Slapi_DN *group_sdn, Slapi_Attr *attr); static int memberof_del_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *groupdn, Slapi_Attr *attr); + Slapi_DN *group_sdn, Slapi_Attr *attr); static int memberof_moddn_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *pre_dn, char *post_dn, Slapi_Attr *attr); -static int memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group_dn); + Slapi_DN *pre_sdn, Slapi_DN *post_sdn, Slapi_Attr *attr); +static int memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *group_sdn); static void memberof_set_plugin_id(void * plugin_id); static void *memberof_get_plugin_id(); static int memberof_compare(MemberOfConfig *config, const void *a, const void *b); static int memberof_qsort_compare(const void *a, const void *b); static void memberof_load_array(Slapi_Value **array, Slapi_Attr *attr); -static void memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, char *dn); -static int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, +static void memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, Slapi_DN *sdn); +static int memberof_call_foreach_dn(Slapi_PBlock *pb, Slapi_DN *sdn, char **types, plugin_search_entry_callback callback, void *callback_data); static int memberof_is_direct_member(MemberOfConfig *config, Slapi_Value *groupdn, Slapi_Value *memberdn); static int memberof_is_grouping_attr(char *type, MemberOfConfig *config); -static Slapi_ValueSet *memberof_get_groups(MemberOfConfig *config, char *memberdn); -static int memberof_get_groups_r(MemberOfConfig *config, char *memberdn, +static Slapi_ValueSet *memberof_get_groups(MemberOfConfig *config, Slapi_DN *member_sdn); +static int memberof_get_groups_r(MemberOfConfig *config, Slapi_DN *member_sdn, memberof_get_groups_data *data); static int memberof_get_groups_callback(Slapi_Entry *e, void *callback_data); static int memberof_test_membership(Slapi_PBlock *pb, MemberOfConfig *config, - char *group_dn); + Slapi_DN *group_sdn); static int memberof_test_membership_callback(Slapi_Entry *e, void *callback_data); static int memberof_del_dn_type_callback(Slapi_Entry *e, void *callback_data); static int memberof_replace_dn_type_callback(Slapi_Entry *e, void *callback_data); static void memberof_replace_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, - char *pre_dn, char *post_dn); + Slapi_DN *pre_sdn, Slapi_DN *post_sdn); static int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, - int mod_op, char *group_dn, char *op_this, char *replace_with, char *op_to, - memberofstringll *stack); + int mod_op, Slapi_DN *group_sdn, Slapi_DN *op_this_sdn, + Slapi_DN *replace_with_sdn, Slapi_DN *op_to_sdn, memberofstringll *stack); static int memberof_task_add(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg); @@ -379,7 +382,7 @@ int memberof_postop_del(Slapi_PBlock *pb) { int ret = 0; MemberOfConfig configCopy = {0, 0, 0, 0}; - char *normdn; + Slapi_DN *sdn; void *caller_id = NULL; slapi_log_error( SLAPI_LOG_TRACE, MEMBEROF_PLUGIN_SUBSYSTEM, @@ -393,7 +396,7 @@ int memberof_postop_del(Slapi_PBlock *pb) return 0; } - if(memberof_oktodo(pb) && (normdn = memberof_getdn(pb))) + if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb))) { struct slapi_entry *e = NULL; @@ -413,7 +416,7 @@ int memberof_postop_del(Slapi_PBlock *pb) /* remove this DN from the * membership lists of groups */ - memberof_del_dn_from_groups(pb, &configCopy, normdn); + memberof_del_dn_from_groups(pb, &configCopy, sdn); /* is the entry of interest as a group? */ if(e && configCopy.group_filter && !slapi_filter_test_simple(e, configCopy.group_filter)) @@ -426,7 +429,7 @@ int memberof_postop_del(Slapi_PBlock *pb) { if (0 == slapi_entry_attr_find(e, configCopy.groupattrs[i], &attr)) { - memberof_del_attr_list(pb, &configCopy, normdn, attr); + memberof_del_attr_list(pb, &configCopy, sdn, attr); } } } @@ -449,7 +452,7 @@ typedef struct _memberof_del_dn_data /* Deletes a member dn from all groups that refer to it. */ static void -memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, char *dn) +memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, Slapi_DN *sdn) { int i = 0; char *groupattrs[2] = {0, 0}; @@ -459,12 +462,13 @@ memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, char *dn) * same grouping attribute. */ for (i = 0; config->groupattrs[i]; i++) { - memberof_del_dn_data data = {dn, config->groupattrs[i]}; + memberof_del_dn_data data = {(char *)slapi_sdn_get_dn(sdn), + config->groupattrs[i]}; groupattrs[0] = config->groupattrs[i]; - memberof_call_foreach_dn(pb, dn, groupattrs, - memberof_del_dn_type_callback, &data); + memberof_call_foreach_dn(pb, sdn, groupattrs, + memberof_del_dn_type_callback, &data); } } @@ -510,19 +514,18 @@ int memberof_del_dn_type_callback(Slapi_Entry *e, void *callback_data) * is a user, you'd want "type" to be "member". If "dn" is a group, you * could want type to be either "member" or "memberOf" depending on the case. */ -int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, +int memberof_call_foreach_dn(Slapi_PBlock *pb, Slapi_DN *sdn, char **types, plugin_search_entry_callback callback, void *callback_data) { Slapi_PBlock *search_pb = NULL; Slapi_DN *base_sdn = NULL; Slapi_Backend *be = NULL; - Slapi_DN *sdn = NULL; char *filter_str = NULL; char *cookie = NULL; int all_backends = memberof_config_get_all_backends(); int types_name_len = 0; int num_types = 0; - int dn_len = strlen(dn); + int dn_len = slapi_sdn_get_ndn_len(sdn); int rc = 0; int i = 0; @@ -550,7 +553,7 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, for (i = 0; types[i]; i++) { bytes_out += snprintf(filter_str + bytes_out, filter_str_len - bytes_out, - "(%s=%s)", types[i], dn); + "(%s=%s)", types[i], slapi_sdn_get_ndn(sdn)); } /* Add end of filter. */ @@ -558,7 +561,8 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, } else if (num_types == 1) { - filter_str = slapi_ch_smprintf("(%s=%s)", types[0], dn); + filter_str = + slapi_ch_smprintf("(%s=%s)", types[0], slapi_sdn_get_ndn(sdn)); } if(filter_str == NULL){ @@ -569,7 +573,6 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, be = slapi_get_first_backend(&cookie); while(be){ if(!all_backends){ - sdn = slapi_sdn_new_normdn_byref(dn); be = slapi_be_select(sdn); if(be == NULL){ break; @@ -596,7 +599,6 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, be = slapi_get_next_backend(cookie); } - slapi_sdn_free(&sdn); slapi_pblock_destroy(search_pb); slapi_ch_free((void **)&cookie); slapi_ch_free_string(&filter_str); @@ -632,16 +634,16 @@ int memberof_postop_modrdn(Slapi_PBlock *pb) MemberOfConfig configCopy = {0, 0, 0, 0}; struct slapi_entry *pre_e = NULL; struct slapi_entry *post_e = NULL; - char *pre_dn = 0; - char *post_dn = 0; + Slapi_DN *pre_sdn = 0; + Slapi_DN *post_sdn = 0; slapi_pblock_get( pb, SLAPI_ENTRY_PRE_OP, &pre_e ); slapi_pblock_get( pb, SLAPI_ENTRY_POST_OP, &post_e ); if(pre_e && post_e) { - pre_dn = slapi_entry_get_ndn(pre_e); - post_dn = slapi_entry_get_ndn(post_e); + pre_sdn = slapi_entry_get_sdn(pre_e); + post_sdn = slapi_entry_get_sdn(post_e); } /* copy config so it doesn't change out from under us */ @@ -653,7 +655,7 @@ int memberof_postop_modrdn(Slapi_PBlock *pb) memberof_lock(); /* update any downstream members */ - if(pre_dn && post_dn && configCopy.group_filter && + if(pre_sdn && post_sdn && configCopy.group_filter && !slapi_filter_test_simple(post_e, configCopy.group_filter)) { int i = 0; @@ -665,7 +667,8 @@ int memberof_postop_modrdn(Slapi_PBlock *pb) { if(0 == slapi_entry_attr_find(post_e, configCopy.groupattrs[i], &attr)) { - if(memberof_moddn_attr_list(pb, &configCopy, pre_dn, post_dn, attr) != 0){ + if(memberof_moddn_attr_list(pb, &configCopy, pre_sdn, + post_sdn, attr) != 0){ break; } } @@ -675,8 +678,8 @@ int memberof_postop_modrdn(Slapi_PBlock *pb) /* It's possible that this is an entry who is a member * of other group entries. We need to update any member * attributes to refer to the new name. */ - if (pre_dn && post_dn) { - memberof_replace_dn_from_groups(pb, &configCopy, pre_dn, post_dn); + if (pre_sdn && post_sdn) { + memberof_replace_dn_from_groups(pb, &configCopy, pre_sdn, post_sdn); } memberof_unlock(); @@ -701,7 +704,7 @@ typedef struct _replace_dn_data * to use post_dn instead. */ static void memberof_replace_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, - char *pre_dn, char *post_dn) + Slapi_DN *pre_sdn, Slapi_DN *post_sdn) { int i = 0; char *groupattrs[2] = {0, 0}; @@ -711,11 +714,13 @@ memberof_replace_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, * using the same grouping attribute. */ for (i = 0; config->groupattrs[i]; i++) { - replace_dn_data data = {pre_dn, post_dn, config->groupattrs[i]}; + replace_dn_data data = {(char *)slapi_sdn_get_ndn(pre_sdn), + (char *)slapi_sdn_get_ndn(post_sdn), + config->groupattrs[i]}; groupattrs[0] = config->groupattrs[i]; - memberof_call_foreach_dn(pb, pre_dn, groupattrs, + memberof_call_foreach_dn(pb, pre_sdn, groupattrs, memberof_replace_dn_type_callback, &data); } } @@ -785,7 +790,7 @@ int memberof_replace_dn_type_callback(Slapi_Entry *e, void *callback_data) int memberof_postop_modify(Slapi_PBlock *pb) { int ret = 0; - char *normdn = 0; + Slapi_DN *sdn = NULL; Slapi_Mods *smods = 0; Slapi_Mod *smod = 0; LDAPMod **mods; @@ -803,7 +808,7 @@ int memberof_postop_modify(Slapi_PBlock *pb) return 0; } - if(memberof_oktodo(pb) && (normdn = memberof_getdn(pb))) + if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb))) { int config_copied = 0; MemberOfConfig *mainConfig = 0; @@ -859,7 +864,7 @@ int memberof_postop_modify(Slapi_PBlock *pb) case LDAP_MOD_ADD: { /* add group DN to targets */ - memberof_add_smod_list(pb, &configCopy, normdn, smod); + memberof_add_smod_list(pb, &configCopy, sdn, smod); break; } @@ -871,12 +876,12 @@ int memberof_postop_modify(Slapi_PBlock *pb) * entry, which the replace code deals with. */ if (slapi_mod_get_num_values(smod) == 0) { - memberof_replace_list(pb, &configCopy, normdn); + memberof_replace_list(pb, &configCopy, sdn); } else { /* remove group DN from target values in smod*/ - memberof_del_smod_list(pb, &configCopy, normdn, smod); + memberof_del_smod_list(pb, &configCopy, sdn, smod); } break; } @@ -884,7 +889,7 @@ int memberof_postop_modify(Slapi_PBlock *pb) case LDAP_MOD_REPLACE: { /* replace current values */ - memberof_replace_list(pb, &configCopy, normdn); + memberof_replace_list(pb, &configCopy, sdn); break; } @@ -930,7 +935,7 @@ int memberof_postop_add(Slapi_PBlock *pb) { int ret = 0; int interested = 0; - char *normdn = 0; + Slapi_DN *sdn = 0; void *caller_id = NULL; slapi_log_error( SLAPI_LOG_TRACE, MEMBEROF_PLUGIN_SUBSYSTEM, @@ -944,7 +949,7 @@ int memberof_postop_add(Slapi_PBlock *pb) return 0; } - if(memberof_oktodo(pb) && (normdn = memberof_getdn(pb))) + if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb))) { MemberOfConfig *mainConfig = 0; MemberOfConfig configCopy = {0, 0, 0, 0}; @@ -976,7 +981,7 @@ int memberof_postop_add(Slapi_PBlock *pb) { if(0 == slapi_entry_attr_find(e, configCopy.groupattrs[i], &attr)) { - memberof_add_attr_list(pb, &configCopy, normdn, attr); + memberof_add_attr_list(pb, &configCopy, sdn, attr); } } @@ -1037,22 +1042,14 @@ bail: return ret; } -/* - * memberof_getdn() - * - * Get dn of target entry - * Note: slapi_sdn_get_dn returns normalized dn. - * - */ -char *memberof_getdn(Slapi_PBlock *pb) +static Slapi_DN * +memberof_getsdn(Slapi_PBlock *pb) { - const char *dn = 0; Slapi_DN *sdn = NULL; slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn); - dn = slapi_sdn_get_dn(sdn); /* returns norm dn */ - return (char *)dn; + return sdn; } /* @@ -1066,9 +1063,10 @@ char *memberof_getdn(Slapi_PBlock *pb) * Also, we must not delete entries that are a member of the group */ int memberof_modop_one(Slapi_PBlock *pb, MemberOfConfig *config, int mod_op, - char *op_this, char *op_to) + Slapi_DN *op_this_sdn, Slapi_DN *op_to_sdn) { - return memberof_modop_one_r(pb, config, mod_op, op_this, op_this, op_to, 0); + return memberof_modop_one_r(pb, config, mod_op, op_this_sdn, + op_this_sdn, op_to_sdn, 0); } /* memberof_modop_one_r() @@ -1077,19 +1075,21 @@ int memberof_modop_one(Slapi_PBlock *pb, MemberOfConfig *config, int mod_op, */ int memberof_modop_one_r(Slapi_PBlock *pb, MemberOfConfig *config, int mod_op, - char *group_dn, char *op_this, char *op_to, memberofstringll *stack) + Slapi_DN *group_sdn, Slapi_DN *op_this_sdn, Slapi_DN *op_to_sdn, + memberofstringll *stack) { return memberof_modop_one_replace_r( - pb, config, mod_op, group_dn, op_this, 0, op_to, stack); + pb, config, mod_op, group_sdn, op_this_sdn, 0, op_to_sdn, stack); } /* memberof_modop_one_replace_r() * * recursive function to perform above (with added replace arg) */ -int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, - int mod_op, char *group_dn, char *op_this, char *replace_with, - char *op_to, memberofstringll *stack) +int +memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, + int mod_op, Slapi_DN *group_sdn, Slapi_DN *op_this_sdn, + Slapi_DN *replace_with_sdn, Slapi_DN *op_to_sdn, memberofstringll *stack) { int rc = 0; LDAPMod mod; @@ -1098,12 +1098,16 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, char *val[2]; char *replace_val[2]; Slapi_PBlock *mod_pb = 0; - Slapi_DN *op_to_sdn = 0; 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); + /* 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, @@ -1112,7 +1116,6 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, } /* determine if this is a group op or single entry */ - op_to_sdn = slapi_sdn_new_normdn_byref(op_to); slapi_search_internal_get_entry( op_to_sdn, config->groupattrs, &e, memberof_get_plugin_id()); if(!e) @@ -1180,7 +1183,7 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, * entry. This will fix the references to * the missing group as well as the group * represented by op_this. */ - memberof_test_membership(pb, config, op_to); + memberof_test_membership(pb, config, op_to_sdn); } } slapi_free_search_results_internal(search_pb); @@ -1232,6 +1235,8 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, while(ll) { ll_dn_val = slapi_value_new_string(ll->dn); + /* ll->dn is case-normalized */ + slapi_value_set_flags(ll_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS); if(0 == memberof_compare(config, &ll_dn_val, &to_dn_val)) { @@ -1267,7 +1272,8 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, slapi_entry_attr_find( e, config->groupattrs[i], &members ); if(members) { - if(memberof_mod_attr_list_r(pb, config, mod_op, group_dn, op_this, members, ll) != 0){ + if(memberof_mod_attr_list_r(pb, config, mod_op, group_sdn, + op_this_sdn, members, ll) != 0){ rc = -1; goto bail; } @@ -1324,7 +1330,7 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, mods[1] = 0; } - val[0] = op_this; + val[0] = (char *)op_this; val[1] = 0; mod.mod_op = LDAP_MOD_REPLACE == mod_op?LDAP_MOD_DELETE:mod_op; mod.mod_type = config->memberof_attr; @@ -1332,7 +1338,7 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, if(LDAP_MOD_REPLACE == mod_op) { - replace_val[0] = replace_with; + replace_val[0] = (char *)slapi_sdn_get_ndn(replace_with_sdn); replace_val[1] = 0; replace_mod.mod_op = LDAP_MOD_ADD; @@ -1356,7 +1362,6 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config, } bail: - slapi_sdn_free(&op_to_sdn); slapi_value_free(&to_dn_val); slapi_value_free(&this_dn_val); slapi_entry_free(e); @@ -1370,9 +1375,11 @@ bail: * Add addthis DN to the memberof attribute of addto * */ -int memberof_add_one(Slapi_PBlock *pb, MemberOfConfig *config, char *addthis, char *addto) +int +memberof_add_one(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *addthis_sdn, Slapi_DN *addto_sdn) { - return memberof_modop_one(pb, config, LDAP_MOD_ADD, addthis, addto); + return memberof_modop_one(pb, config, LDAP_MOD_ADD, addthis_sdn, addto_sdn); } /* @@ -1381,9 +1388,11 @@ int memberof_add_one(Slapi_PBlock *pb, MemberOfConfig *config, char *addthis, ch * Delete delthis DN from the memberof attribute of delfrom * */ -int memberof_del_one(Slapi_PBlock *pb, MemberOfConfig *config, char *delthis, char *delfrom) +int +memberof_del_one(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *delthis_sdn, Slapi_DN *delfrom_sdn) { - return memberof_modop_one(pb, config, LDAP_MOD_DELETE, delthis, delfrom); + return memberof_modop_one(pb, config, LDAP_MOD_DELETE, delthis_sdn, delfrom_sdn); } /* @@ -1393,12 +1402,13 @@ int memberof_del_one(Slapi_PBlock *pb, MemberOfConfig *config, char *delthis, ch * */ int memberof_mod_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, int mod, - char *group_dn, Slapi_Mod *smod) + Slapi_DN *group_sdn, Slapi_Mod *smod) { int rc = 0; struct berval *bv = slapi_mod_get_first_value(smod); int last_size = 0; char *last_str = 0; + Slapi_DN *sdn = slapi_sdn_new(); while(bv) { @@ -1424,12 +1434,14 @@ int memberof_mod_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, int mod, memset(dn_str, 0, last_size); strncpy(dn_str, bv->bv_val, (size_t)bv->bv_len); + slapi_sdn_set_dn_byref(sdn, dn_str); - memberof_modop_one(pb, config, mod, group_dn, dn_str); + memberof_modop_one(pb, config, mod, group_sdn, sdn); bv = slapi_mod_get_next_value(smod); } + slapi_sdn_free(&sdn); if(last_str) slapi_ch_free_string(&last_str); @@ -1443,9 +1455,9 @@ int memberof_mod_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, int mod, * */ int memberof_add_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *groupdn, Slapi_Mod *smod) + Slapi_DN *group_sdn, Slapi_Mod *smod) { - return memberof_mod_smod_list(pb, config, LDAP_MOD_ADD, groupdn, smod); + return memberof_mod_smod_list(pb, config, LDAP_MOD_ADD, group_sdn, smod); } @@ -1456,9 +1468,9 @@ int memberof_add_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, * */ int memberof_del_smod_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *groupdn, Slapi_Mod *smod) + Slapi_DN *group_sdn, Slapi_Mod *smod) { - return memberof_mod_smod_list(pb, config, LDAP_MOD_DELETE, groupdn, smod); + return memberof_mod_smod_list(pb, config, LDAP_MOD_DELETE, group_sdn, smod); } /** @@ -1482,13 +1494,15 @@ void * memberof_get_plugin_id() * */ int memberof_mod_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, int mod, - char *group_dn, Slapi_Attr *attr) + Slapi_DN *group_sdn, Slapi_Attr *attr) { - return memberof_mod_attr_list_r(pb, config, mod, group_dn, group_dn, attr, 0); + return memberof_mod_attr_list_r(pb, config, mod, group_sdn, group_sdn, + attr, 0); } int memberof_mod_attr_list_r(Slapi_PBlock *pb, MemberOfConfig *config, int mod, - char *group_dn, char *op_this, Slapi_Attr *attr, memberofstringll *stack) + Slapi_DN *group_sdn, Slapi_DN *op_this_sdn, + Slapi_Attr *attr, memberofstringll *stack) { int rc = 0; Slapi_Value *val = 0; @@ -1496,8 +1510,10 @@ int memberof_mod_attr_list_r(Slapi_PBlock *pb, MemberOfConfig *config, int mod, int last_size = 0; char *last_str = 0; int hint = slapi_attr_first_value(attr, &val); + Slapi_DN *sdn = slapi_sdn_new(); - op_this_val = slapi_value_new_string(op_this); + op_this_val = slapi_value_new_string(slapi_sdn_get_ndn(op_this_sdn)); + slapi_value_set_flags(op_this_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS); while(val) { @@ -1532,14 +1548,17 @@ int memberof_mod_attr_list_r(Slapi_PBlock *pb, MemberOfConfig *config, int mod, /* If we're doing a replace (as we would in the MODRDN case), we need * to specify the new group DN value */ + slapi_sdn_set_normdn_byref(sdn, dn_str); /* dn_str is normalized */ if(mod == LDAP_MOD_REPLACE) { - memberof_modop_one_replace_r(pb, config, mod, group_dn, op_this, - group_dn, dn_str, stack); + memberof_modop_one_replace_r(pb, config, mod, group_sdn, + op_this_sdn, group_sdn, + sdn, stack); } else { - memberof_modop_one_r(pb, config, mod, group_dn, op_this, dn_str, stack); + memberof_modop_one_r(pb, config, mod, group_sdn, + op_this_sdn, sdn, stack); } } @@ -1548,6 +1567,7 @@ int memberof_mod_attr_list_r(Slapi_PBlock *pb, MemberOfConfig *config, int mod, slapi_value_free(&op_this_val); + slapi_sdn_free(&sdn); if(last_str) slapi_ch_free_string(&last_str); @@ -1560,10 +1580,10 @@ int memberof_mod_attr_list_r(Slapi_PBlock *pb, MemberOfConfig *config, int mod, * Add group DN to the memberof attribute of the list of targets * */ -int memberof_add_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, char *groupdn, - Slapi_Attr *attr) +int memberof_add_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *group_sdn, Slapi_Attr *attr) { - return memberof_mod_attr_list(pb, config, LDAP_MOD_ADD, groupdn, attr); + return memberof_mod_attr_list(pb, config, LDAP_MOD_ADD, group_sdn, attr); } /* @@ -1572,10 +1592,10 @@ int memberof_add_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group * Remove group DN from the memberof attribute of the list of targets * */ -int memberof_del_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, char *groupdn, - Slapi_Attr *attr) +int memberof_del_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *group_sdn, Slapi_Attr *attr) { - return memberof_mod_attr_list(pb, config, LDAP_MOD_DELETE, groupdn, attr); + return memberof_mod_attr_list(pb, config, LDAP_MOD_DELETE, group_sdn, attr); } /* @@ -1585,13 +1605,14 @@ int memberof_del_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group * */ int memberof_moddn_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, - char *pre_dn, char *post_dn, Slapi_Attr *attr) + Slapi_DN *pre_sdn, Slapi_DN *post_sdn, Slapi_Attr *attr) { int rc = 0; Slapi_Value *val = 0; int last_size = 0; char *last_str = 0; int hint = slapi_attr_first_value(attr, &val); + Slapi_DN *sdn = slapi_sdn_new(); while(val) { @@ -1619,12 +1640,14 @@ int memberof_moddn_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, strncpy(dn_str, bv->bv_val, (size_t)bv->bv_len); + slapi_sdn_set_normdn_byref(sdn, dn_str); /* dn_str is normalized */ memberof_modop_one_replace_r(pb, config, LDAP_MOD_REPLACE, - post_dn, pre_dn, post_dn, dn_str, 0); + post_sdn, pre_sdn, post_sdn, sdn, 0); hint = slapi_attr_next_value(attr, hint, &val); } + slapi_sdn_free(&sdn); if(last_str) slapi_ch_free_string(&last_str); @@ -1638,24 +1661,30 @@ int memberof_moddn_attr_list(Slapi_PBlock *pb, MemberOfConfig *config, * A Slapi_ValueSet* is returned. It is up to the caller to * free it. */ -Slapi_ValueSet *memberof_get_groups(MemberOfConfig *config, char *memberdn) +Slapi_ValueSet * +memberof_get_groups(MemberOfConfig *config, Slapi_DN *member_sdn) { - Slapi_Value *memberdn_val = slapi_value_new_string(memberdn); Slapi_ValueSet *groupvals = slapi_valueset_new(); + Slapi_Value *memberdn_val = + slapi_value_new_string(slapi_sdn_get_ndn(member_sdn)); + slapi_value_set_flags(memberdn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS); + memberof_get_groups_data data = {config, memberdn_val, &groupvals}; - memberof_get_groups_r(config, memberdn, &data); + memberof_get_groups_r(config, member_sdn, &data); slapi_value_free(&memberdn_val); return groupvals; } -int memberof_get_groups_r(MemberOfConfig *config, char *memberdn, memberof_get_groups_data *data) +int +memberof_get_groups_r(MemberOfConfig *config, Slapi_DN *member_sdn, + memberof_get_groups_data *data) { /* Search for any grouping attributes that point to memberdn. * For each match, add it to the list, recurse and do same search */ - return memberof_call_foreach_dn(NULL, memberdn, config->groupattrs, + return memberof_call_foreach_dn(NULL, member_sdn, config->groupattrs, memberof_get_groups_callback, data); } @@ -1665,7 +1694,8 @@ int memberof_get_groups_r(MemberOfConfig *config, char *memberdn, memberof_get_g */ int memberof_get_groups_callback(Slapi_Entry *e, void *callback_data) { - char *group_dn = slapi_entry_get_dn(e); + Slapi_DN *group_sdn = slapi_entry_get_sdn(e); + char *group_dn = slapi_entry_get_ndn(e); Slapi_Value *group_dn_val = 0; Slapi_ValueSet *groupvals = *((memberof_get_groups_data*)callback_data)->groupvals; int rc = 0; @@ -1685,6 +1715,8 @@ int memberof_get_groups_callback(Slapi_Entry *e, void *callback_data) } /* get the DN of the group */ group_dn_val = slapi_value_new_string(group_dn); + /* group_dn is case-normalized */ + slapi_value_set_flags(group_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS); /* check if e is the same as our original member entry */ if (0 == memberof_compare(((memberof_get_groups_data*)callback_data)->config, @@ -1725,7 +1757,7 @@ int memberof_get_groups_callback(Slapi_Entry *e, void *callback_data) /* now recurse to find parent groups of e */ memberof_get_groups_r(((memberof_get_groups_data*)callback_data)->config, - group_dn, callback_data); + group_sdn, callback_data); bail: return rc; @@ -1810,11 +1842,13 @@ static int memberof_is_grouping_attr(char *type, MemberOfConfig *config) * iterate until a pass fails to move a group over to member groups * remaining groups should be deleted */ -int memberof_test_membership(Slapi_PBlock *pb, MemberOfConfig *config, char *group_dn) +int +memberof_test_membership(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *group_sdn) { char *attrs[2] = {config->memberof_attr, 0}; - return memberof_call_foreach_dn(pb, group_dn, attrs, + return memberof_call_foreach_dn(pb, group_sdn, attrs, memberof_test_membership_callback , config); } @@ -1833,9 +1867,13 @@ int memberof_test_membership_callback(Slapi_Entry *e, void *callback_data) Slapi_Value **member_array = 0; Slapi_Value **candidate_array = 0; Slapi_Value *entry_dn = 0; + Slapi_DN *entry_sdn = 0; MemberOfConfig *config = (MemberOfConfig *)callback_data; + Slapi_DN *sdn = slapi_sdn_new(); - entry_dn = slapi_value_new_string(slapi_entry_get_dn(e)); + entry_sdn = slapi_entry_get_sdn(e); + entry_dn = slapi_value_new_string(slapi_entry_get_ndn(e)); + slapi_value_set_flags(entry_dn, SLAPI_ATTR_FLAG_NORMALIZED_CIS); if(0 == entry_dn) { @@ -1908,8 +1946,7 @@ int memberof_test_membership_callback(Slapi_Entry *e, void *callback_data) /* Check for a special value in this position * that indicates that the candidate was moved * to the member array. */ - if((void*)1 == - candidate_array[inner_index]) + if((void*)1 == candidate_array[inner_index]) { /* was moved, skip */ inner_index++; @@ -1955,11 +1992,9 @@ int memberof_test_membership_callback(Slapi_Entry *e, void *callback_data) continue; } - memberof_del_one( - 0, config, - (char*)slapi_value_get_string( - candidate_array[outer_index]), - (char*)slapi_value_get_string(entry_dn)); + slapi_sdn_set_normdn_byref(sdn, + slapi_value_get_string(candidate_array[outer_index])); + memberof_del_one(0, config, sdn, entry_sdn); outer_index++; } @@ -1980,6 +2015,7 @@ int memberof_test_membership_callback(Slapi_Entry *e, void *callback_data) } bail: + slapi_sdn_free(&sdn); slapi_value_free(&entry_dn); return rc; @@ -1991,7 +2027,9 @@ bail: * Perform replace the group DN list in the memberof attribute of the list of targets * */ -int memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group_dn) +int +memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, + Slapi_DN *group_sdn) { struct slapi_entry *pre_e = NULL; struct slapi_entry *post_e = NULL; @@ -2018,6 +2056,7 @@ int memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group_ Slapi_Value **post_array = 0; int pre_index = 0; int post_index = 0; + Slapi_DN *sdn = slapi_sdn_new(); /* create arrays of values */ if(pre_attr) @@ -2077,22 +2116,18 @@ int memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group_ if(pre_index == pre_total) { /* add the rest of post */ - memberof_add_one( - pb, config, - group_dn, - (char*)slapi_value_get_string( - post_array[post_index])); + slapi_sdn_set_normdn_byref(sdn, + slapi_value_get_string(post_array[post_index])); + memberof_add_one(pb, config, group_sdn, sdn); post_index++; } else if(post_index == post_total) { /* delete the rest of pre */ - memberof_del_one( - pb, config, - group_dn, - (char*)slapi_value_get_string( - pre_array[pre_index])); + slapi_sdn_set_normdn_byref(sdn, + slapi_value_get_string(pre_array[pre_index])); + memberof_del_one(pb, config, group_sdn, sdn); pre_index++; } @@ -2107,22 +2142,18 @@ int memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group_ if(cmp < 0) { /* delete pre array */ - memberof_del_one( - pb, config, - group_dn, - (char*)slapi_value_get_string( - pre_array[pre_index])); + slapi_sdn_set_normdn_byref(sdn, + slapi_value_get_string(pre_array[pre_index])); + memberof_del_one(pb, config, group_sdn, sdn); pre_index++; } else if(cmp > 0) { /* add post array */ - memberof_add_one( - pb, config, - group_dn, - (char*)slapi_value_get_string( - post_array[post_index])); + slapi_sdn_set_normdn_byref(sdn, + slapi_value_get_string(post_array[post_index])); + memberof_add_one(pb, config, group_sdn, sdn); post_index++; } @@ -2134,6 +2165,7 @@ int memberof_replace_list(Slapi_PBlock *pb, MemberOfConfig *config, char *group_ } } } + slapi_sdn_free(&sdn); slapi_ch_free((void **)&pre_array); slapi_ch_free((void **)&post_array); } @@ -2171,10 +2203,7 @@ int memberof_compare(MemberOfConfig *config, const void *a, const void *b) /* We only need to provide a Slapi_Attr here for it's syntax. We * already validated all grouping attributes to use the Distinguished * Name syntax, so we can safely just use the first attr. */ - return slapi_attr_value_cmp( - config->group_slapiattrs[0], - slapi_value_get_berval(val1), - slapi_value_get_berval(val2)); + return slapi_attr_value_cmp_ext(config->group_slapiattrs[0], val1, val2); } /* memberof_qsort_compare() @@ -2194,10 +2223,8 @@ int memberof_qsort_compare(const void *a, const void *b) /* We only need to provide a Slapi_Attr here for it's syntax. We * already validated all grouping attributes to use the Distinguished * Name syntax, so we can safely just use the first attr. */ - return slapi_attr_value_cmp( - qsortConfig->group_slapiattrs[0], - slapi_value_get_berval(val1), - slapi_value_get_berval(val2)); + return slapi_attr_value_cmp_ext(qsortConfig->group_slapiattrs[0], + val1, val2); } void memberof_lock() @@ -2401,14 +2428,13 @@ int memberof_fix_memberof(MemberOfConfig *config, char *dn, char *filter_str) int memberof_fix_memberof_callback(Slapi_Entry *e, void *callback_data) { int rc = 0; - char *dn = slapi_entry_get_dn(e); Slapi_DN *sdn = slapi_entry_get_sdn(e); MemberOfConfig *config = (MemberOfConfig *)callback_data; memberof_del_dn_data del_data = {0, config->memberof_attr}; Slapi_ValueSet *groups = 0; /* get a list of all of the groups this user belongs to */ - groups = memberof_get_groups(config, dn); + groups = memberof_get_groups(config, sdn); /* If we found some groups, replace the existing memberOf attribute * with the found values. */ diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c index 17a8f5c30..7fb613cd5 100644 --- a/ldap/servers/slapd/attr.c +++ b/ldap/servers/slapd/attr.c @@ -404,6 +404,7 @@ int slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v ) { struct ava ava; + unsigned long a_flags; if ( NULL == a ) { return( -1 ); @@ -412,7 +413,8 @@ slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v ) ava.ava_type = a->a_type; ava.ava_value = *v; if (a->a_flags & SLAPI_ATTR_FLAG_NORMALIZED) { - ava.ava_private = &a->a_flags; + a_flags = a->a_flags; + ava.ava_private = &a_flags; } else { ava.ava_private = NULL; } @@ -549,21 +551,56 @@ slapi_attr_value_cmp( const Slapi_Attr *a, const struct berval *v1, const struct } else { - Slapi_Attr a2; - struct ava ava; - Slapi_Value *cvals[2]; - Slapi_Value tmpcval; - - a2 = *a; - cvals[0] = &tmpcval; - cvals[0]->v_csnset = NULL; - cvals[0]->bv = *v1; - cvals[0]->v_flags = 0; - cvals[1] = NULL; - a2.a_present_values.va = cvals; /* JCM - PUKE */ - ava.ava_type = a->a_type; - ava.ava_value = *v2; - ava.ava_private = NULL; + Slapi_Attr a2; + struct ava ava; + Slapi_Value *cvals[2]; + Slapi_Value tmpcval; + + a2 = *a; + cvals[0] = &tmpcval; + cvals[0]->v_csnset = NULL; + cvals[0]->bv = *v1; + cvals[0]->v_flags = 0; + cvals[1] = NULL; + a2.a_present_values.va = cvals; /* JCM - PUKE */ + ava.ava_type = a->a_type; + ava.ava_value = *v2; + ava.ava_private = NULL; + retVal = plugin_call_syntax_filter_ava(&a2, LDAP_FILTER_EQUALITY, &ava); + } + return retVal; +} + +int +slapi_attr_value_cmp_ext(const Slapi_Attr *a, Slapi_Value *v1, Slapi_Value *v2) +{ + int retVal; + const struct berval *bv2 = slapi_value_get_berval(v2); + + if ( a->a_flags & SLAPI_ATTR_FLAG_CMP_BITBYBIT ) + { + const struct berval *bv1 = slapi_value_get_berval(v1); + return slapi_attr_value_cmp(a, bv1, bv2); + } + else + { + Slapi_Attr a2; + struct ava ava; + Slapi_Value *cvals[2]; + unsigned long v2_flags = v2->v_flags; + + a2 = *a; + cvals[0] = v1; + cvals[1] = NULL; + a2.a_present_values.va = cvals; /* JCM - PUKE */ + + ava.ava_type = a->a_type; + ava.ava_value = *bv2; + if (v2_flags) { + ava.ava_private = &v2_flags; + } else { + ava.ava_private = NULL; + } retVal = plugin_call_syntax_filter_ava(&a2, LDAP_FILTER_EQUALITY, &ava); } return retVal; diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 979b55832..192d6633d 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -3766,7 +3766,7 @@ int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags ); int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag ); /** - * Comare two values for a given attribute. + * Comare two bervals for a given attribute. * * \param attr Attribute used to determine how these values are compared; for * example, the syntax of the attribute may perform case-insensitive @@ -3785,6 +3785,27 @@ int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag ); */ int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, const struct berval *v2 ); +/** + * Comare two values for a given attribute. + * + * \param attr Attribute used to determine how these values are compared; for + * example, the syntax of the attribute may perform case-insensitive + * comparisons. + * \param v1 Pointer to the \c Slapi_Value structure containing the first value + * that you want to compare. + * \param v2 Pointer to the \c Slapi_Value structure containing the second value + * that you want to compare. + * \return \c 0 if the values are equal. + * \return \c -1 if the values are not equal. + * \see slapi_attr_add_value() + * \see slapi_attr_first_value() + * \see slapi_attr_next_value() + * \see slapi_attr_get_numvalues() + * \see slapi_attr_value_find() + * \see slapi_attr_value_cmp() + */ +int slapi_attr_value_cmp_ext(const Slapi_Attr *a, Slapi_Value *v1, Slapi_Value *v2); + /** * Determine if an attribute contains a given value. * diff --git a/ldap/servers/slapd/value.c b/ldap/servers/slapd/value.c index 73e5d20c2..7bd11be00 100644 --- a/ldap/servers/slapd/value.c +++ b/ldap/servers/slapd/value.c @@ -544,19 +544,19 @@ slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value int r= 0; if(v1!=NULL && v2!=NULL) { - r= slapi_attr_value_cmp( a, &v1->bv, &v2->bv); + r= slapi_attr_value_cmp_ext(a, (Slapi_Value *)v1, (Slapi_Value *)v2); } else if(v1!=NULL && v2==NULL) { - r= 1; /* v1>v2 */ + r= 1; /* v1>v2 */ } else if (v1==NULL && v2!=NULL) { - r= -1; /* v1<v2 */ + r= -1; /* v1<v2 */ } else /* (v1==NULL && v2==NULL) */ { - r= 0; /* The same */ + r= 0; /* The same */ } return r; }
0
06919f531a23297f076048ce174080ec07bbec9a
389ds/389-ds-base
Ticket 47640 - Fix coverity issues - part 3 12504 - resource leak - /ldap/servers/slapd/back-ldbm/import-threads.c 12499 - resource leak - /ldap/servers/slapd/passwd_extop.c 12497 - resource leak - /ldap/servers/slapd/mapping_tree.c 12496 - resource leak - /ldap/servers/slapd/mapping_tree.c 12495 - resource leak - /ldap/servers/plugins/replication/legacy_consumer.c 12493 - resource leak - /ldap/servers/slapd/tools/rsearch/sdattable.c 12492 - resource leak - /ldap/servers/slapd/tools/pwenc.c 12491 - resource leak - /ldap/servers/slapd/tools/mmldif.c https://fedorahosted.org/389/ticket/47740 Reviewed by: rmeggins(Thanks!)
commit 06919f531a23297f076048ce174080ec07bbec9a Author: Mark Reynolds <[email protected]> Date: Wed Mar 12 14:38:50 2014 -0400 Ticket 47640 - Fix coverity issues - part 3 12504 - resource leak - /ldap/servers/slapd/back-ldbm/import-threads.c 12499 - resource leak - /ldap/servers/slapd/passwd_extop.c 12497 - resource leak - /ldap/servers/slapd/mapping_tree.c 12496 - resource leak - /ldap/servers/slapd/mapping_tree.c 12495 - resource leak - /ldap/servers/plugins/replication/legacy_consumer.c 12493 - resource leak - /ldap/servers/slapd/tools/rsearch/sdattable.c 12492 - resource leak - /ldap/servers/slapd/tools/pwenc.c 12491 - resource leak - /ldap/servers/slapd/tools/mmldif.c https://fedorahosted.org/389/ticket/47740 Reviewed by: rmeggins(Thanks!) diff --git a/ldap/servers/plugins/replication/legacy_consumer.c b/ldap/servers/plugins/replication/legacy_consumer.c index 2440ce769..aa5a9b548 100644 --- a/ldap/servers/plugins/replication/legacy_consumer.c +++ b/ldap/servers/plugins/replication/legacy_consumer.c @@ -371,11 +371,12 @@ legacy_consumer_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi { if (mod_type == LDAP_MOD_REPLACE) { + slapi_ch_free_string(&legacy_consumer_replicationpw); legacy_consumer_replicationpw = config_copy_strval(config_attr_value); } else if (mod_type == LDAP_MOD_DELETE) { - legacy_consumer_replicationpw = NULL; + slapi_ch_free_string(&legacy_consumer_replicationpw); } else if (mod_type == LDAP_MOD_ADD) { @@ -387,6 +388,7 @@ legacy_consumer_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi } else { + slapi_ch_free_string(&legacy_consumer_replicationpw); legacy_consumer_replicationpw = config_copy_strval(config_attr_value); } } @@ -419,11 +421,8 @@ legacy_consumer_config_delete (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* en slapi_rwlock_wrlock (legacy_consumer_config_lock); if (legacy_consumer_replicationdn) slapi_sdn_free (&legacy_consumer_replicationdn); - if (legacy_consumer_replicationpw) - slapi_ch_free ((void**)&legacy_consumer_replicationpw); - + slapi_ch_free_string(&legacy_consumer_replicationpw); legacy_consumer_replicationdn = NULL; - legacy_consumer_replicationpw = NULL; slapi_rwlock_unlock (legacy_consumer_config_lock); *returncode = LDAP_SUCCESS; @@ -446,6 +445,7 @@ legacy_consumer_extract_config(Slapi_Entry* entry, char *returntext) legacy_consumer_replicationdn = slapi_sdn_new_dn_passin (arg); arg= slapi_entry_attr_get_charptr(entry,CONFIG_LEGACY_REPLICATIONPW_ATTRIBUTE); + slapi_ch_free_string(&legacy_consumer_replicationpw); legacy_consumer_replicationpw = arg; slapi_rwlock_unlock (legacy_consumer_config_lock); diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c index 6eae676e0..6fdc289ac 100644 --- a/ldap/servers/slapd/back-ldbm/import-threads.c +++ b/ldap/servers/slapd/back-ldbm/import-threads.c @@ -2621,6 +2621,7 @@ import_foreman(void *param) "of the duplicated entry %s; " "Entry ID: %d", orig_dn, fi->entry->ep_id); + slapi_ch_free_string(&orig_dn); goto cont; } new_entrydn = slapi_attr_new(); diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index d0801e781..e3146a9ca 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -1132,6 +1132,8 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor "Error: could not find parent for %s\n", slapi_entry_get_dn(entryAfter), 0, 0); slapi_sdn_free(&subtree); + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); *returncode = LDAP_UNWILLING_TO_PERFORM; return SLAPI_DSE_CALLBACK_ERROR; } @@ -1170,6 +1172,8 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor { free_mapping_tree_node_arrays(&backends, &be_names, &be_states, &be_list_count); slapi_sdn_free(&subtree); + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); *returncode = LDAP_UNWILLING_TO_PERFORM; return SLAPI_DSE_CALLBACK_ERROR; } @@ -1183,6 +1187,8 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor mtn_unlock(); free_mapping_tree_node_arrays(&backends, &be_names, &be_states, &be_list_count); slapi_sdn_free(&subtree); + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); return SLAPI_DSE_CALLBACK_ERROR; } @@ -1211,12 +1217,16 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "must use replace operation to change state\n"); *returncode = LDAP_UNWILLING_TO_PERFORM; slapi_sdn_free(&subtree); + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); return SLAPI_DSE_CALLBACK_ERROR; } if ((mods[i]->mod_bvalues == NULL) || (mods[i]->mod_bvalues[0] == NULL)) { slapi_sdn_free(&subtree); *returncode = LDAP_OPERATIONS_ERROR; + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); return SLAPI_DSE_CALLBACK_ERROR; } @@ -1230,6 +1240,8 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor { PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "need to set nsslapd-backend before moving to backend state\n"); slapi_sdn_free(&subtree); + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); *returncode = LDAP_UNWILLING_TO_PERFORM; return SLAPI_DSE_CALLBACK_ERROR; } @@ -1242,6 +1254,8 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor { PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "need to set nsslapd-referral before moving to referral state\n"); slapi_sdn_free(&subtree); + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); *returncode = LDAP_UNWILLING_TO_PERFORM; return SLAPI_DSE_CALLBACK_ERROR; } @@ -1280,6 +1294,8 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor *returncode = LDAP_UNWILLING_TO_PERFORM; mtn_unlock(); slapi_sdn_free(&subtree); + slapi_ch_free_string(&plugin_fct); + slapi_ch_free_string(&plugin_lib); return SLAPI_DSE_CALLBACK_ERROR; } @@ -1353,7 +1369,7 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op) || SLAPI_IS_MOD_ADD(mods[i]->mod_op)) { - const char *sval; + const char *sval; slapi_entry_attr_find(entryAfter, "nsslapd-distribution-root-update", &attr); slapi_attr_first_value(attr, &val); @@ -1365,13 +1381,13 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; } else { sval = slapi_value_get_string(val); - if (strcmp(sval,"reject") == 0) - plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; - else if (strcmp(sval,"local") == 0) - plugin_rootmode = CHAIN_ROOT_UPDATE_LOCAL; - else if (strcmp(sval,"referral") == 0) - plugin_rootmode = CHAIN_ROOT_UPDATE_REFERRAL; - } + if (strcmp(sval,"reject") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; + else if (strcmp(sval,"local") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_LOCAL; + else if (strcmp(sval,"referral") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_REFERRAL; + } } else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) { diff --git a/ldap/servers/slapd/passwd_extop.c b/ldap/servers/slapd/passwd_extop.c index af13bd89c..999a7af20 100644 --- a/ldap/servers/slapd/passwd_extop.c +++ b/ldap/servers/slapd/passwd_extop.c @@ -904,7 +904,6 @@ static char *passwd_name_list[] = { int passwd_modify_init( Slapi_PBlock *pb ) { char **argv; - char *oid; /* Get the arguments appended to the plugin extendedop directive. The first argument * (after the standard arguments for the directive) should contain the OID of the @@ -923,9 +922,8 @@ int passwd_modify_init( Slapi_PBlock *pb ) "OID is missing or is not %s\n", EXTOP_PASSWD_OID ); return( -1 ); } else { - oid = slapi_ch_strdup( argv[0] ); slapi_log_error( SLAPI_LOG_PLUGIN, "passwd_modify_init", - "Registering plug-in for Password Modify extended op %s.\n", oid ); + "Registering plug-in for Password Modify extended op %s.\n", argv[0] /* oid */); } /* Register the plug-in function as an extended operation diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c index 1f0197689..4213e655c 100644 --- a/ldap/servers/slapd/tools/mmldif.c +++ b/ldap/servers/slapd/tools/mmldif.c @@ -659,6 +659,7 @@ int mm_init(int argc, char * argv[]) slapd_ldap_debug = 65535; break; case 'o': + if(ofn) free (ofn); ofn = strdup(optarg); break; case 'h': @@ -677,6 +678,7 @@ int mm_init(int argc, char * argv[]) ofp = fopen(ofn, "w"); if (ofp == NULL) { perror(ofn); + free(ofn); return -1; } free(ofn); diff --git a/ldap/servers/slapd/tools/pwenc.c b/ldap/servers/slapd/tools/pwenc.c index d6b80cec1..998b43ac9 100644 --- a/ldap/servers/slapd/tools/pwenc.c +++ b/ldap/servers/slapd/tools/pwenc.c @@ -140,8 +140,10 @@ init_config(char *configdir) abs_configdir = rel2abspath( configdir ); if ( config_set_configdir( "configdir (-D)", abs_configdir, - errorbuf, 1) != LDAP_SUCCESS ) { + errorbuf, 1) != LDAP_SUCCESS ) + { fprintf( stderr, "%s\n", errorbuf ); + slapi_ch_free_string(&abs_configdir); return( NULL ); } slapi_ch_free_string(&abs_configdir); diff --git a/ldap/servers/slapd/tools/rsearch/sdattable.c b/ldap/servers/slapd/tools/rsearch/sdattable.c index c0274d001..18417a13e 100644 --- a/ldap/servers/slapd/tools/rsearch/sdattable.c +++ b/ldap/servers/slapd/tools/rsearch/sdattable.c @@ -141,27 +141,43 @@ int sdt_load(SDatTable *sdt, const char *filename) if (!fd) return 0; while (PR_Available(fd) > 0) { - int rval; - char temp[256]; - char *dn = NULL; - char *uid = NULL; - while (!(rval = PR_GetLine(fd, temp, 256))) { - char *p; - if (!strncasecmp(temp, "dn:", 3)) { - for (p = temp + 4; *p == ' ' || *p == '\t'; p++) ; - dn = strdup(p); - if (!dn) break; - } else if (!strncasecmp(temp, "uid:", 4)) { - for (p = temp + 5; *p == ' ' || *p == '\t'; p++) ; - uid = strdup(p); - if (!uid) break; - } - if (uid) { /* dn should come earlier than uid */ - if (!sdt_push(sdt, dn, uid)) goto out; - break; - } - } - if (rval) break; /* PR_GetLine failed */ + int rval; + int pushed = 0; + char temp[256]; + char *dn = NULL; + char *uid = NULL; + while (!(rval = PR_GetLine(fd, temp, 256))) { + char *p; + if (!strncasecmp(temp, "dn:", 3)) { + for (p = temp + 4; *p == ' ' || *p == '\t'; p++) ; + dn = strdup(p); + if (!dn) break; + } else if (!strncasecmp(temp, "uid:", 4)) { + for (p = temp + 5; *p == ' ' || *p == '\t'; p++) ; + uid = strdup(p); + if (!uid) break; + } + if (uid) { + /* dn should come earlier than uid - so both dn and uid must be set. */ + if (!sdt_push(sdt, dn, uid)){ + /* failure, free the dn and uid */ + free(dn); + free(uid); + goto out; + } + pushed = 1; + break; + } + } + if(!pushed){ + /* + * Entry might not have been a user entry with a uid, + * so free the dn just in case. + */ + if(dn) + free(dn); + } + if (rval) break; /* PR_GetLine failed */ } out: PR_Close(fd);
0
6580a9942e945699819570596977b60cd82d65ec
389ds/389-ds-base
Bug 514190 - setup-ds-admin.pl --debug does not log to file https://bugzilla.redhat.com/show_bug.cgi?id=514190 Resolves: bug 514190 Bug Description: setup-ds-admin.pl --debug does not log to file Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: Added a logDebug() method to the SetupLog class, used for logging debug messages. At startup time, the log used by the Setup or Migration object registers its log with the DSUtil code. When the DSUtil::debug() method is called, it will also call the logDebug() method of the DSUtil::log object if specified. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no
commit 6580a9942e945699819570596977b60cd82d65ec Author: Rich Megginson <[email protected]> Date: Tue Mar 1 19:53:01 2011 -0700 Bug 514190 - setup-ds-admin.pl --debug does not log to file https://bugzilla.redhat.com/show_bug.cgi?id=514190 Resolves: bug 514190 Bug Description: setup-ds-admin.pl --debug does not log to file Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: Added a logDebug() method to the SetupLog class, used for logging debug messages. At startup time, the log used by the Setup or Migration object registers its log with the DSUtil code. When the DSUtil::debug() method is called, it will also call the logDebug() method of the DSUtil::log object if specified. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in index e65f7e0e8..22f25dcfc 100644 --- a/ldap/admin/src/scripts/DSUtil.pm.in +++ b/ldap/admin/src/scripts/DSUtil.pm.in @@ -49,12 +49,12 @@ require Exporter; process_maptbl check_and_add_entry getMappedEntries addErr getHashedPassword debug createInfFromConfig shellEscape isValidServerID isValidUser isValidGroup makePaths getLogin getGroup - remove_tree remove_pidfile); + remove_tree remove_pidfile setDebugLog); @EXPORT_OK = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries process_maptbl check_and_add_entry getMappedEntries addErr getHashedPassword debug createInfFromConfig shellEscape isValidServerID isValidUser isValidGroup makePaths getLogin getGroup - remove_tree remove_pidfile); + remove_tree remove_pidfile setDebugLog); use strict; @@ -67,6 +67,8 @@ use File::Path qw(rmtree); use Carp; $DSUtil::debuglevel = 0; +$DSUtil::log = 0; + # use like this: # debug(3, "message"); # this will only print "message" if $debuglevel is 3 or higher (-ddd on the command line) @@ -74,9 +76,16 @@ sub debug { my ($level, @rest) = @_; if ($level <= $DSUtil::debuglevel) { print STDERR "+" x $level, @rest; + if ($DSUtil::log) { + $DSUtil::log->logDebug(@rest); + } } } +sub setDebugLog { + $DSUtil::log = shift; +} + # return true if the given port number is available, false otherwise sub portAvailable { my $port = shift; diff --git a/ldap/admin/src/scripts/Migration.pm.in b/ldap/admin/src/scripts/Migration.pm.in index 66618c8b3..42a92c137 100644 --- a/ldap/admin/src/scripts/Migration.pm.in +++ b/ldap/admin/src/scripts/Migration.pm.in @@ -210,6 +210,7 @@ sub init { $self->{logfile} = $logfile; $self->{crossplatform} = $crossplatform; $self->{log} = new SetupLog($self->{logfile}, "migrate"); + DSUtil::setDebugLog($self->{log}); $self->{start_servers} = 1; # start servers as soon as they are migrated # if user supplied inf file, use that to initialize if (defined($inffile)) { diff --git a/ldap/admin/src/scripts/Setup.pm.in b/ldap/admin/src/scripts/Setup.pm.in index 753062dbd..e154367b8 100644 --- a/ldap/admin/src/scripts/Setup.pm.in +++ b/ldap/admin/src/scripts/Setup.pm.in @@ -142,6 +142,7 @@ sub init { $self->{force} = $force; $self->{logfile} = $logfile; $self->{log} = new SetupLog($self->{logfile}); + DSUtil::setDebugLog($self->{log}); # if user supplied inf file, use that to initialize if (defined($inffile)) { $self->{inf} = new Inf($inffile); diff --git a/ldap/admin/src/scripts/SetupLog.pm b/ldap/admin/src/scripts/SetupLog.pm index 9ff3c32fe..fc06d2957 100644 --- a/ldap/admin/src/scripts/SetupLog.pm +++ b/ldap/admin/src/scripts/SetupLog.pm @@ -92,6 +92,14 @@ sub logMessage { print { $self->{fh} } $string; } +sub logDebug { + my ($self, @msg) = @_; + if (!$self->{fh}) { + return; + } + print { $self->{fh} } @msg; +} + sub levels { my $self = shift; return ($FATAL, $START, $SUCCESS, $WARN, $INFO, $DEBUG);
0
c61ee8e16c3e3ca91ffef725fadbeb0a62fb5e80
389ds/389-ds-base
Ticket #110 - RFE limiting root DN by host, IP, time of day, day of week RFE Description: There is no way to restrict when and where some one can attempt root DN binds. An intruder can brute force guess the password all day long until they succeed, especailly if the DS is publicly available. Fix Description: Created a new plugin, type "internalpreoperation" and an internal preop bind function. You can configure the plugin with some basic access control: rootdn-open-time: 0800 rootdn-close-time: 1700 rootdn-days-allowed: Mon, Tue, Wed, Thu, Fri rootdn-allow-host: *.redhat.com rootdn-allow-host: *.fedora.com rootdn-deny-host: dangerous.boracle.com rootdn-allow-ip: 127.0.0.1 rootdn-allow-ip: 2000:db8:de30::11 rootdn-deny-ip: 192.168.1.* As with our other ACL code, deny's always override the allow rules. https://fedorahosted.org/389/ticket/110 Reviewed by: richm(Thanks Rich!)
commit c61ee8e16c3e3ca91ffef725fadbeb0a62fb5e80 Author: Mark Reynolds <[email protected]> Date: Fri May 25 12:26:02 2012 -0400 Ticket #110 - RFE limiting root DN by host, IP, time of day, day of week RFE Description: There is no way to restrict when and where some one can attempt root DN binds. An intruder can brute force guess the password all day long until they succeed, especailly if the DS is publicly available. Fix Description: Created a new plugin, type "internalpreoperation" and an internal preop bind function. You can configure the plugin with some basic access control: rootdn-open-time: 0800 rootdn-close-time: 1700 rootdn-days-allowed: Mon, Tue, Wed, Thu, Fri rootdn-allow-host: *.redhat.com rootdn-allow-host: *.fedora.com rootdn-deny-host: dangerous.boracle.com rootdn-allow-ip: 127.0.0.1 rootdn-allow-ip: 2000:db8:de30::11 rootdn-deny-ip: 192.168.1.* As with our other ACL code, deny's always override the allow rules. https://fedorahosted.org/389/ticket/110 Reviewed by: richm(Thanks Rich!) diff --git a/Makefile.am b/Makefile.am index cf91842f4..d90cd4b16 100644 --- a/Makefile.am +++ b/Makefile.am @@ -205,7 +205,7 @@ serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \ libreferint-plugin.la libreplication-plugin.la libretrocl-plugin.la \ libroles-plugin.la libstatechange-plugin.la libsyntax-plugin.la \ libviews-plugin.la libschemareload-plugin.la libusn-plugin.la \ - libacctusability-plugin.la $(LIBACCTPOLICY_PLUGIN) \ + libacctusability-plugin.la librootdn-access-plugin.la $(LIBACCTPOLICY_PLUGIN) \ $(LIBPAM_PASSTHRU_PLUGIN) $(LIBDNA_PLUGIN) \ $(LIBBITWISE_PLUGIN) $(LIBPRESENCE_PLUGIN) @@ -821,6 +821,17 @@ libacl_plugin_la_LIBADD = libslapd.la libns-dshttpd.la $(LDAPSDK_LINK) $(NSPR_LI libacl_plugin_la_LDFLAGS = -avoid-version libacl_plugin_la_LINK = $(CXXLINK) -avoid-version +#------------------------ +# librootdn-access-plugin +#------------------------ +# +librootdn_access_plugin_la_SOURCES = ldap/servers/plugins/rootdn_access/rootdn_access.c + +librootdn_access_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) +librootdn_access_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +librootdn_access_plugin_la_LDFLAGS = -avoid-version + + #------------------------ # libautomember-plugin #------------------------ diff --git a/Makefile.in b/Makefile.in index ab2f65757..915e9784a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -581,6 +581,15 @@ libroles_plugin_la_OBJECTS = $(am_libroles_plugin_la_OBJECTS) libroles_plugin_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libroles_plugin_la_LDFLAGS) $(LDFLAGS) -o $@ +librootdn_access_plugin_la_DEPENDENCIES = libslapd.la \ + $(am__DEPENDENCIES_1) +am_librootdn_access_plugin_la_OBJECTS = ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo +librootdn_access_plugin_la_OBJECTS = \ + $(am_librootdn_access_plugin_la_OBJECTS) +librootdn_access_plugin_la_LINK = $(LIBTOOL) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(librootdn_access_plugin_la_LDFLAGS) \ + $(LDFLAGS) -o $@ libschemareload_plugin_la_DEPENDENCIES = libslapd.la \ $(am__DEPENDENCIES_1) am_libschemareload_plugin_la_OBJECTS = ldap/servers/plugins/schema_reload/libschemareload_plugin_la-schema_reload.lo @@ -1001,6 +1010,7 @@ SOURCES = $(libavl_a_SOURCES) $(libldaputil_a_SOURCES) \ $(libreferint_plugin_la_SOURCES) \ $(libreplication_plugin_la_SOURCES) \ $(libretrocl_plugin_la_SOURCES) $(libroles_plugin_la_SOURCES) \ + $(librootdn_access_plugin_la_SOURCES) \ $(libschemareload_plugin_la_SOURCES) $(libslapd_la_SOURCES) \ $(libstatechange_plugin_la_SOURCES) \ $(libsyntax_plugin_la_SOURCES) $(libusn_plugin_la_SOURCES) \ @@ -1033,6 +1043,7 @@ DIST_SOURCES = $(libavl_a_SOURCES) $(libldaputil_a_SOURCES) \ $(libreferint_plugin_la_SOURCES) \ $(libreplication_plugin_la_SOURCES) \ $(libretrocl_plugin_la_SOURCES) $(libroles_plugin_la_SOURCES) \ + $(librootdn_access_plugin_la_SOURCES) \ $(libschemareload_plugin_la_SOURCES) \ $(am__libslapd_la_SOURCES_DIST) \ $(libstatechange_plugin_la_SOURCES) \ @@ -1411,7 +1422,7 @@ serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \ libreferint-plugin.la libreplication-plugin.la libretrocl-plugin.la \ libroles-plugin.la libstatechange-plugin.la libsyntax-plugin.la \ libviews-plugin.la libschemareload-plugin.la libusn-plugin.la \ - libacctusability-plugin.la $(LIBACCTPOLICY_PLUGIN) \ + libacctusability-plugin.la librootdn-access-plugin.la $(LIBACCTPOLICY_PLUGIN) \ $(LIBPAM_PASSTHRU_PLUGIN) $(LIBDNA_PLUGIN) \ $(LIBBITWISE_PLUGIN) $(LIBPRESENCE_PLUGIN) @@ -1967,6 +1978,15 @@ libacl_plugin_la_LIBADD = libslapd.la libns-dshttpd.la $(LDAPSDK_LINK) $(NSPR_LI libacl_plugin_la_LDFLAGS = -avoid-version libacl_plugin_la_LINK = $(CXXLINK) -avoid-version +#------------------------ +# librootdn-access-plugin +#------------------------ +# +librootdn_access_plugin_la_SOURCES = ldap/servers/plugins/rootdn_access/rootdn_access.c +librootdn_access_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) +librootdn_access_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +librootdn_access_plugin_la_LDFLAGS = -avoid-version + #------------------------ # libautomember-plugin #------------------------ @@ -3784,6 +3804,17 @@ ldap/servers/plugins/roles/libroles_plugin_la-roles_plugin.lo: \ ldap/servers/plugins/roles/$(DEPDIR)/$(am__dirstamp) libroles-plugin.la: $(libroles_plugin_la_OBJECTS) $(libroles_plugin_la_DEPENDENCIES) $(libroles_plugin_la_LINK) -rpath $(serverplugindir) $(libroles_plugin_la_OBJECTS) $(libroles_plugin_la_LIBADD) $(LIBS) +ldap/servers/plugins/rootdn_access/$(am__dirstamp): + @$(MKDIR_P) ldap/servers/plugins/rootdn_access + @: > ldap/servers/plugins/rootdn_access/$(am__dirstamp) +ldap/servers/plugins/rootdn_access/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ldap/servers/plugins/rootdn_access/$(DEPDIR) + @: > ldap/servers/plugins/rootdn_access/$(DEPDIR)/$(am__dirstamp) +ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo: \ + ldap/servers/plugins/rootdn_access/$(am__dirstamp) \ + ldap/servers/plugins/rootdn_access/$(DEPDIR)/$(am__dirstamp) +librootdn-access-plugin.la: $(librootdn_access_plugin_la_OBJECTS) $(librootdn_access_plugin_la_DEPENDENCIES) + $(librootdn_access_plugin_la_LINK) -rpath $(serverplugindir) $(librootdn_access_plugin_la_OBJECTS) $(librootdn_access_plugin_la_LIBADD) $(LIBS) ldap/servers/plugins/schema_reload/$(am__dirstamp): @$(MKDIR_P) ldap/servers/plugins/schema_reload @: > ldap/servers/plugins/schema_reload/$(am__dirstamp) @@ -5017,6 +5048,8 @@ mostlyclean-compile: -rm -f ldap/servers/plugins/roles/libroles_plugin_la-roles_cache.lo -rm -f ldap/servers/plugins/roles/libroles_plugin_la-roles_plugin.$(OBJEXT) -rm -f ldap/servers/plugins/roles/libroles_plugin_la-roles_plugin.lo + -rm -f ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.$(OBJEXT) + -rm -f ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo -rm -f ldap/servers/plugins/schema_reload/libschemareload_plugin_la-schema_reload.$(OBJEXT) -rm -f ldap/servers/plugins/schema_reload/libschemareload_plugin_la-schema_reload.lo -rm -f ldap/servers/plugins/statechange/libstatechange_plugin_la-statechange.$(OBJEXT) @@ -5714,6 +5747,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/rever/$(DEPDIR)/libdes_plugin_la-rever.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/roles/$(DEPDIR)/libroles_plugin_la-roles_cache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/roles/$(DEPDIR)/libroles_plugin_la-roles_plugin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/rootdn_access/$(DEPDIR)/librootdn_access_plugin_la-rootdn_access.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/schema_reload/$(DEPDIR)/libschemareload_plugin_la-schema_reload.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/statechange/$(DEPDIR)/libstatechange_plugin_la-statechange.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/syntaxes/$(DEPDIR)/libsyntax_plugin_la-bin.Plo@am__quote@ @@ -7758,6 +7792,13 @@ ldap/servers/plugins/roles/libroles_plugin_la-roles_plugin.lo: ldap/servers/plug @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroles_plugin_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ldap/servers/plugins/roles/libroles_plugin_la-roles_plugin.lo `test -f 'ldap/servers/plugins/roles/roles_plugin.c' || echo '$(srcdir)/'`ldap/servers/plugins/roles/roles_plugin.c +ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo: ldap/servers/plugins/rootdn_access/rootdn_access.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(librootdn_access_plugin_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo -MD -MP -MF ldap/servers/plugins/rootdn_access/$(DEPDIR)/librootdn_access_plugin_la-rootdn_access.Tpo -c -o ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo `test -f 'ldap/servers/plugins/rootdn_access/rootdn_access.c' || echo '$(srcdir)/'`ldap/servers/plugins/rootdn_access/rootdn_access.c +@am__fastdepCC_TRUE@ $(am__mv) ldap/servers/plugins/rootdn_access/$(DEPDIR)/librootdn_access_plugin_la-rootdn_access.Tpo ldap/servers/plugins/rootdn_access/$(DEPDIR)/librootdn_access_plugin_la-rootdn_access.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ldap/servers/plugins/rootdn_access/rootdn_access.c' object='ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(librootdn_access_plugin_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ldap/servers/plugins/rootdn_access/librootdn_access_plugin_la-rootdn_access.lo `test -f 'ldap/servers/plugins/rootdn_access/rootdn_access.c' || echo '$(srcdir)/'`ldap/servers/plugins/rootdn_access/rootdn_access.c + ldap/servers/plugins/schema_reload/libschemareload_plugin_la-schema_reload.lo: ldap/servers/plugins/schema_reload/schema_reload.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libschemareload_plugin_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ldap/servers/plugins/schema_reload/libschemareload_plugin_la-schema_reload.lo -MD -MP -MF ldap/servers/plugins/schema_reload/$(DEPDIR)/libschemareload_plugin_la-schema_reload.Tpo -c -o ldap/servers/plugins/schema_reload/libschemareload_plugin_la-schema_reload.lo `test -f 'ldap/servers/plugins/schema_reload/schema_reload.c' || echo '$(srcdir)/'`ldap/servers/plugins/schema_reload/schema_reload.c @am__fastdepCC_TRUE@ $(am__mv) ldap/servers/plugins/schema_reload/$(DEPDIR)/libschemareload_plugin_la-schema_reload.Tpo ldap/servers/plugins/schema_reload/$(DEPDIR)/libschemareload_plugin_la-schema_reload.Plo @@ -9779,6 +9820,7 @@ clean-libtool: -rm -rf ldap/servers/plugins/retrocl/.libs ldap/servers/plugins/retrocl/_libs -rm -rf ldap/servers/plugins/rever/.libs ldap/servers/plugins/rever/_libs -rm -rf ldap/servers/plugins/roles/.libs ldap/servers/plugins/roles/_libs + -rm -rf ldap/servers/plugins/rootdn_access/.libs ldap/servers/plugins/rootdn_access/_libs -rm -rf ldap/servers/plugins/schema_reload/.libs ldap/servers/plugins/schema_reload/_libs -rm -rf ldap/servers/plugins/statechange/.libs ldap/servers/plugins/statechange/_libs -rm -rf ldap/servers/plugins/syntaxes/.libs ldap/servers/plugins/syntaxes/_libs @@ -10425,6 +10467,8 @@ distclean-generic: -rm -f ldap/servers/plugins/rever/$(am__dirstamp) -rm -f ldap/servers/plugins/roles/$(DEPDIR)/$(am__dirstamp) -rm -f ldap/servers/plugins/roles/$(am__dirstamp) + -rm -f ldap/servers/plugins/rootdn_access/$(DEPDIR)/$(am__dirstamp) + -rm -f ldap/servers/plugins/rootdn_access/$(am__dirstamp) -rm -f ldap/servers/plugins/schema_reload/$(DEPDIR)/$(am__dirstamp) -rm -f ldap/servers/plugins/schema_reload/$(am__dirstamp) -rm -f ldap/servers/plugins/statechange/$(DEPDIR)/$(am__dirstamp) @@ -10475,7 +10519,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libtool clean-local \ distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acct_usability/$(DEPDIR) ldap/servers/plugins/acctpolicy/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/automember/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/deref/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/linkedattrs/$(DEPDIR) ldap/servers/plugins/memberof/$(DEPDIR) ldap/servers/plugins/mep/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/schema_reload/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/usn/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) + -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acct_usability/$(DEPDIR) ldap/servers/plugins/acctpolicy/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/automember/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/deref/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/linkedattrs/$(DEPDIR) ldap/servers/plugins/memberof/$(DEPDIR) ldap/servers/plugins/mep/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/rootdn_access/$(DEPDIR) ldap/servers/plugins/schema_reload/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/usn/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -10531,7 +10575,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acct_usability/$(DEPDIR) ldap/servers/plugins/acctpolicy/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/automember/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/deref/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/linkedattrs/$(DEPDIR) ldap/servers/plugins/memberof/$(DEPDIR) ldap/servers/plugins/mep/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/schema_reload/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/usn/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) + -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acct_usability/$(DEPDIR) ldap/servers/plugins/acctpolicy/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/automember/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/deref/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/linkedattrs/$(DEPDIR) ldap/servers/plugins/memberof/$(DEPDIR) ldap/servers/plugins/mep/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/rootdn_access/$(DEPDIR) ldap/servers/plugins/schema_reload/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/usn/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in index 5107d72fe..ddf2b357b 100644 --- a/ldap/ldif/template-dse.ldif.in +++ b/ldap/ldif/template-dse.ldif.in @@ -734,6 +734,17 @@ nsslapd-plugintype: object nsslapd-pluginenabled: off nsslapd-plugin-depends-on-type: database +dn: cn=RootDN Access Control,cn=plugins,cn=config +objectclass: top +objectclass: nsSlapdPlugin +objectclass: extensibleObject +cn: RootDN Access Control +nsslapd-pluginpath: librootdn-access-plugin.so +nsslapd-plugininitfunc: rootdn_init +nsslapd-plugintype: internalpreoperation +nsslapd-pluginenabled: off +nsslapd-plugin-depends-on-type: database + dn: cn=ldbm database,cn=plugins,cn=config objectclass: top objectclass: nsSlapdPlugin diff --git a/ldap/servers/plugins/rootdn_access/rootdn_access.c b/ldap/servers/plugins/rootdn_access/rootdn_access.c new file mode 100644 index 000000000..7fb56151f --- /dev/null +++ b/ldap/servers/plugins/rootdn_access/rootdn_access.c @@ -0,0 +1,663 @@ +/** 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) 2012 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +/* + * Root DN Access Control plug-in + */ +#include "rootdn_access.h" +#include <nspr.h> +#include <time.h> +#include <ctype.h> + +/* + * Add an entry like the following to dse.ldif to enable this plugin: + * + * dn: cn=RootDN Access Control,cn=plugins,cn=config + * objectclass: top + * objectclass: nsSlapdPlugin + * objectclass: extensibleObject + * cn: RootDN Access Control + * nsslapd-pluginpath: librootdn-access-plugin.so + * nsslapd-plugininitfunc: rootdn_init + * nsslapd-plugintype: rootdnpreoperation + * nsslapd-pluginenabled: on + * nsslapd-plugin-depends-on-type: database + * nsslapd-pluginid: rootdn-access-control + * rootdn-open-time: 0800 + * rootdn-close-time: 1700 + * rootdn-days-allowed: Mon, Tue, Wed, Thu, Fri + * rootdn-allow-host: *.redhat.com + * rootdn-allow-host: *.fedora.com + * rootdn-deny-host: dangerous.boracle.com + * rootdn-allow-ip: 127.0.0.1 + * rootdn-allow-ip: 2000:db8:de30::11 + * rootdn-deny-ip: 192.168.1.* + * + */ + +/* + * Plugin Functions + */ +int rootdn_init(Slapi_PBlock *pb); +static int rootdn_start(Slapi_PBlock *pb); +static int rootdn_load_config(Slapi_PBlock *pb); +static int rootdn_check_access(Slapi_PBlock *pb); +static int rootdn_check_host_wildcard(char *host, char *client_host); +static int rootdn_check_ip_wildcard(char *ip, char *client_ip); +static int rootdn_preop_bind_init(Slapi_PBlock *pb); +char * strToLower(char *str); + +/* + * Plug-in globals + */ +static void *_PluginID = NULL; +static char *_PluginDN = NULL; +static int g_plugin_started = 0; +static int open_time = 0; +static int close_time = 0; +static char *daysAllowed = NULL; +static char **hosts = NULL; +static char **hosts_to_deny = NULL; +static char **ips = NULL; +static char **ips_to_deny = NULL; + +static Slapi_PluginDesc pdesc = { ROOTDN_FEATURE_DESC, + VENDOR, + DS_PACKAGE_VERSION, + ROOTDN_PLUGIN_DESC }; + +/* + * Plugin identity functions + */ +void +rootdn_set_plugin_id(void *pluginID) +{ + _PluginID = pluginID; +} + +void * +rootdn_get_plugin_id() +{ + return _PluginID; +} + +void +rootdn_set_plugin_dn(char *pluginDN) +{ + _PluginDN = pluginDN; +} + +char * +rootdn_get_plugin_dn() +{ + return _PluginDN; +} + + +int +rootdn_init(Slapi_PBlock *pb){ + int status = 0; + char *plugin_identity = NULL; + + slapi_log_error(SLAPI_LOG_TRACE, ROOTDN_PLUGIN_SUBSYSTEM, + "--> rootdn_init\n"); + + /* Store the plugin identity for later use. Used for internal operations. */ + slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity); + PR_ASSERT(plugin_identity); + rootdn_set_plugin_id(plugin_identity); + + /* Register callbacks */ + if(slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 || + slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, (void *) rootdn_start) != 0 || + slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *) &pdesc) != 0 ) + { + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_init: failed to register plugin\n"); + status = -1; + } + + /* for this plugin we don't want to skip over root dn's when binding */ + slapi_set_plugin_open_rootdn_bind(pb); + + if (!status && + slapi_register_plugin("internalpreoperation", /* op type */ + 1, /* Enabled */ + "rootdn_preop_bind_init", /* this function desc */ + rootdn_preop_bind_init, /* init func */ + ROOTDN_PLUGIN_DESC, /* plugin desc */ + NULL, /* ? */ + plugin_identity /* access control */ + )) { + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, + "rootdn_init: failed to register rootdn preoperation plugin\n"); + status = -1; + } + + /* + * Load the config + */ + if(rootdn_load_config(pb) != 0){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, + "rootdn_start: unable to load plug-in configuration\n"); + return -1; + } + + slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM,"<-- rootdn_init\n"); + return status; +} + +static int +rootdn_preop_bind_init(Slapi_PBlock *pb) +{ + if(slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN, (void *) rootdn_check_access) != 0){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM,"rootdn_preop_bind_init: " + "failed to register function\n"); + return -1; + } + + return 0; +} + +static int +rootdn_start(Slapi_PBlock *pb){ + /* Check if we're already started */ + if (g_plugin_started) { + goto done; + } + + slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "--> rootdn_start\n"); + + g_plugin_started = 1; + + slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "<-- rootdn_start\n"); + +done: + return 0; +} + +static int +rootdn_load_config(Slapi_PBlock *pb) +{ + Slapi_Entry *e = NULL; + char *openTime, *closeTime; + char hour[3], min[3]; + int result = 0; + int i; + + slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "--> rootdn_load_config\n"); + + if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &e) == 0) && e){ + /* + * Grab our plugin settings + */ + openTime = slapi_entry_attr_get_charptr(e, "rootdn-open-time"); + closeTime = slapi_entry_attr_get_charptr(e, "rootdn-close-time"); + daysAllowed = slapi_entry_attr_get_charptr(e, "rootdn-days-allowed"); + hosts = slapi_entry_attr_get_charray(e, "rootdn-allow-host"); + hosts_to_deny = slapi_entry_attr_get_charray(e, "rootdn-deny-host"); + ips = slapi_entry_attr_get_charray(e, "rootdn-allow-ip"); + ips_to_deny = slapi_entry_attr_get_charray(e, "rootdn-deny-ip"); + /* + * Validate out settings + */ + if(daysAllowed){ + if(strcspn(daysAllowed, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ,")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "invalid rootdn-days-allowed value (%s), must be all letters, and comma separators\n",closeTime); + slapi_ch_free_string(&daysAllowed); + return -1; + } + daysAllowed = strToLower(daysAllowed); + } + if(openTime){ + if (strcspn(openTime, "0123456789")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "invalid rootdn-open-time value (%s), must be all digits\n",openTime); + slapi_ch_free_string(&openTime); + return -1; + } + if(strlen(openTime) != 4){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "invalid format for rootdn-open-time value (%s). Should be HHMM\n", openTime); + slapi_ch_free_string(&openTime); + return -1; + } + /* + * convert the time to all seconds + */ + strncpy(hour, openTime,2); + strncpy(min, openTime+2,2); + open_time = (atoi(hour) * 3600) + (atoi(min) * 60); + } + if(closeTime){ + if (strcspn(closeTime, "0123456789")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "invalid rootdn-open-time value (%s), must be all digits, and should be HHMM\n",closeTime); + slapi_ch_free_string(&closeTime); + return -1; + } + if(strlen(closeTime) != 4){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "invalid format for rootdn-open-time value (%s), should be HHMM\n", closeTime); + slapi_ch_free_string(&closeTime); + return -1; + } + /* + * convert the time to all seconds + */ + + strncpy(hour, closeTime,2); + strncpy(min, closeTime+2,2); + close_time = (atoi(hour) * 3600) + (atoi(min) * 60); + } + if((openTime && closeTime == NULL) || (openTime == NULL && closeTime)){ + /* If you are using TOD access control, you must have a open and close time */ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "there must be a open and a close time\n"); + slapi_ch_free_string(&closeTime); + slapi_ch_free_string(&openTime); + return -1; + } + if(close_time && open_time && close_time <= open_time){ + /* Make sure the closing time is greater than the open time */ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "the close time must be greater than the open time\n"); + result = -1; + } + if(hosts){ + for(i = 0; hosts[i] != NULL; i++){ + if(strcspn(hosts[i], "0123456789.*-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "hostname (%s) contians invalid characters, skipping\n",hosts[i]); + slapi_ch_free_string(&hosts[i]); + hosts[i] = slapi_ch_strdup("!invalid"); + continue; + } + } + } + if(hosts_to_deny){ + for(i = 0; hosts_to_deny[i] != NULL; i++){ + if(strcspn(hosts_to_deny[i], "0123456789.*-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "hostname (%s) contians invalid characters, skipping\n",hosts_to_deny[i]); + slapi_ch_free_string(&hosts_to_deny[i]); + hosts_to_deny[i] = slapi_ch_strdup("!invalid"); + continue; + } + } + } + if(ips){ + for(i = 0; ips[i] != NULL; i++){ + if(strcspn(ips[i], "0123456789:ABCDEFabcdef.*")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "IP address contains invalid characters (%s), skipping\n", ips[i]); + slapi_ch_free_string(&ips[i]); + ips[i] = slapi_ch_strdup("!invalid"); + continue; + } + if(strstr(ips[i],":") == 0){ + /* + * IPv4 - make sure it's just numbers, dots, and wildcard + */ + if(strcspn(ips[i], "0123456789.*")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "IPv4 address contains invalid characters (%s), skipping\n", ips[i]); + slapi_ch_free_string(&ips[i]); + ips[i] = slapi_ch_strdup("!invalid"); + continue; + } + } + } + } + if(ips_to_deny){ + for(i = 0; ips_to_deny[i] != NULL; i++){ + if(strcspn(ips_to_deny[i], "0123456789:ABCDEFabcdef.*")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "IP address contains invalid characters (%s), skipping\n", ips_to_deny[i]); + slapi_ch_free_string(&ips_to_deny[i]); + ips_to_deny[i] = slapi_ch_strdup("!invalid"); + continue; + } + if(strstr(ips_to_deny[i],":") == 0){ + /* + * IPv4 - make sure it's just numbers, dots, and wildcard + */ + if(strcspn(ips_to_deny[i], "0123456789.*")){ + slapi_log_error(SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_load_config: " + "IPv4 address contains invalid characters (%s), skipping\n", ips_to_deny[i]); + slapi_ch_free_string(&ips_to_deny[i]); + ips_to_deny[i] = slapi_ch_strdup("!invalid"); + continue; + } + } + } + } + slapi_ch_free_string(&openTime); + slapi_ch_free_string(&closeTime); + } else { + /* failed to get the plugin entry */ + result = -1; + } + + slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "<-- rootdn_load_config (%d)\n", result); + + return result; +} + + +static int +rootdn_check_access(Slapi_PBlock *pb){ + PRNetAddr *client_addr = NULL; + PRHostEnt *host_entry = NULL; + time_t curr_time; + struct tm *timeinfo; + char *dnsName = NULL; + int isRoot = 0; + int rc = 0; + int i; + + /* + * Verify this is a root DN + */ + slapi_pblock_get ( pb, SLAPI_REQUESTOR_ISROOT, &isRoot ); + if(!isRoot){ + return 0; + } + /* + * grab the current time/info if we need it + */ + if(open_time || daysAllowed){ + time(&curr_time); + timeinfo = localtime(&curr_time); + } + /* + * First check TOD restrictions, continue through if we are in the open "window" + */ + if(open_time){ + int curr_total; + + curr_total = (timeinfo->tm_hour * 3600) + (timeinfo->tm_min * 60); + + if((curr_total < open_time) || (curr_total >= close_time)){ + slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: bind not in the " + "allowed time window\n"); + return -1; + } + } + /* + * Check if today is an allowed day + */ + if(daysAllowed){ + char *timestr; + char day[4]; + char *today = day; + + timestr = asctime(timeinfo); // DDD MMM dd hh:mm:ss YYYY + memmove(day, timestr, 3); // we only want the day + today = strToLower(today); + + if(!strstr(today, daysAllowed)){ + slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: bind not allowed for today\n"); + return -1; + } + } + /* + * Check the host restrictions, deny always overrides allow + */ + if(hosts || hosts_to_deny){ + char buf[PR_NETDB_BUF_SIZE]; + char *host; + + /* + * Get the client address + */ + client_addr = (PRNetAddr *)slapi_ch_malloc(sizeof(PRNetAddr)); + if ( slapi_pblock_get( pb, SLAPI_CONN_CLIENTNETADDR, client_addr ) != 0 ) { + slapi_log_error( SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: Could not get client address for hosts.\n" ); + rc = -1; + goto free_and_return; + } + /* + * Get the hostname from the client address + */ + host_entry = (PRHostEnt *)slapi_ch_malloc( sizeof(PRHostEnt) ); + if ( PR_GetHostByAddr(client_addr, buf, sizeof(buf), host_entry ) == PR_SUCCESS ) { + if ( host_entry->h_name != NULL ) { + /* copy the hostname */ + dnsName = slapi_ch_strdup( host_entry->h_name ); + } else { + /* no hostname */ + slapi_log_error( SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: client address missing hostname\n"); + rc = -1; + goto free_and_return; + } + } else { + slapi_log_error( SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: client IP address could not be resolved\n"); + rc = -1; + goto free_and_return; + } + /* + * Now we have our hostname, now do our checks + */ + if(hosts_to_deny){ + for(i = 0; hosts_to_deny[i] != NULL; i++){ + host = hosts_to_deny[i]; + /* check for wild cards */ + if(host[0] == '*'){ + if(rootdn_check_host_wildcard(host, dnsName) == 0){ + /* match, return failure */ + rc = -1; + goto free_and_return; + } + } else { + if(strcasecmp(host,dnsName) == 0){ + /* we have a match, return failure */ + rc = -1; + goto free_and_return; + } + } + } + rc = 0; + } + if(hosts){ + for(i = 0; hosts[i] != NULL; i++){ + host = hosts[i]; + /* check for wild cards */ + if(host[0] == '*'){ + if(rootdn_check_host_wildcard(host, dnsName) == 0){ + /* match */ + rc = 0; + goto free_and_return; + } + } else { + if(strcasecmp(host,dnsName) == 0){ + /* we have a match, */ + rc = 0; + goto free_and_return; + } + } + } + rc = -1; + } + } + /* + * Check the IP address restrictions, deny always overrides allow + */ + if(ips || ips_to_deny){ + char ip_str[256]; + char *ip; + int ip_len, i; + + if(client_addr == NULL){ + client_addr = (PRNetAddr *)slapi_ch_malloc(sizeof(PRNetAddr)); + if ( slapi_pblock_get( pb, SLAPI_CONN_CLIENTNETADDR, client_addr ) != 0 ) { + slapi_log_error( SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: Could not get client address for IP.\n" ); + rc = -1; + goto free_and_return; + } + } + /* + * Check if we are IPv4, so we can grab the correct IP addr for "ip_str" + */ + if ( PR_IsNetAddrType( client_addr, PR_IpAddrV4Mapped ) ) { + PRNetAddr v4addr; + memset( &v4addr, 0, sizeof( v4addr ) ); + v4addr.inet.family = PR_AF_INET; + v4addr.inet.ip = client_addr->ipv6.ip.pr_s6_addr32[3]; + if( PR_NetAddrToString( &v4addr, ip_str, sizeof( ip_str )) != PR_SUCCESS){ + slapi_log_error( SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: Could not get IPv4 from client address.\n" ); + rc = -1; + goto free_and_return; + } + } else { + if( PR_NetAddrToString(client_addr, ip_str, sizeof(ip_str)) != PR_SUCCESS){ + slapi_log_error( SLAPI_LOG_FATAL, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: Could not get IPv6 from client address.\n" ); + rc = -1; + goto free_and_return; + } + } + /* + * Now we have our IP address, do our checks + */ + if(ips_to_deny){ + for(i = 0; ips_to_deny[i] != NULL; i++){ + ip = ips_to_deny[i]; + ip_len = strlen(ip); + if(ip[ip_len - 1] == '*'){ + if(rootdn_check_ip_wildcard(ips_to_deny[i], ip_str) == 0){ + /* match, return failure */ + rc = -1; + goto free_and_return; + } + } else { + if(strcasecmp(ip_str, ip)==0){ + /* match, return failure */ + rc = -1; + goto free_and_return; + } + } + } + rc = 0; + } + if(ips){ + for(i = 0; ips[i] != NULL; i++){ + ip = ips[i]; + ip_len = strlen(ip); + if(ip[ip_len - 1] == '*'){ + if(rootdn_check_ip_wildcard(ip, ip_str) == 0){ + /* match, return success */ + rc = 0; + goto free_and_return; + } + } else { + if(strcasecmp(ip_str, ip)==0){ + /* match, return success */ + rc = 0; + goto free_and_return; + } + } + } + rc = -1; + } + } + +free_and_return: + slapi_ch_free((void **)&client_addr); + slapi_ch_free((void **)&host_entry); + slapi_ch_free_string(&dnsName); + + return rc; +} + +static int +rootdn_check_host_wildcard(char *host, char *client_host) +{ + int host_len = strlen(host); + int client_len = strlen(client_host); + int i, j; + /* + * Start at the end of the string and move backwards, and skip the first char "*" + */ + if(client_len < host_len){ + /* this can't be a match */ + return -1; + } + for(i = host_len - 1, j = client_len - 1; i > 0; i--, j--){ + if(host[i] != client_host[j]){ + return -1; + } + } + + return 0; +} + +static int +rootdn_check_ip_wildcard(char *ip, char *client_ip) +{ + int ip_len = strlen(ip); + int i; + /* + * Start at the beginning of the string and move forward, and skip the last char "*" + */ + if(strlen(client_ip) < ip_len){ + /* this can't be a match */ + return -1; + } + for(i = 0; i < ip_len - 1; i++){ + if(ip[i] != client_ip[i]){ + return -1; + } + } + + return 0; +} + +char * +strToLower(char *str){ + int i; + + for(i = 0; i < strlen(str); i++){ + str[i] = tolower(str[i]); + } + return str; +} + + diff --git a/ldap/servers/plugins/rootdn_access/rootdn_access.h b/ldap/servers/plugins/rootdn_access/rootdn_access.h new file mode 100644 index 000000000..80b8d4a5e --- /dev/null +++ b/ldap/servers/plugins/rootdn_access/rootdn_access.h @@ -0,0 +1,57 @@ +/** 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) 2011 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +/* + * Root DN access control plug-in header file + */ +#include "slapi-plugin.h" +#include <nspr.h> +#include <time.h> +#include <ctype.h> + +#define ROOTDN_PLUGIN_SUBSYSTEM "rootdn-access-control-plugin" +#define ROOTDN_FEATURE_DESC "Root DN Access Control" +#define ROOTDN_PLUGIN_DESC "Root DN Access Control plugin" +#define ROOTDN_PLUGIN_TYPE_DESC "Root DN Access Control plugin" + + + diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c index d725d5cc7..d4d3b4974 100644 --- a/ldap/servers/slapd/bind.c +++ b/ldap/servers/slapd/bind.c @@ -614,21 +614,41 @@ do_bind( Slapi_PBlock *pb ) Slapi_Value cv; slapi_value_init_berval(&cv,&cred); - /* right dn and passwd - authorize */ + /* + * Call pre bind root dn plugin for checking root dn access control. + * + * Do this before checking the password so that we give a consistent error, + * regardless if the password is correct or not. Or else it would still be + * possible to brute force guess the password even though access would still + * be denied. + */ + if (plugin_call_plugins(pb, SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN) != 0){ + send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL, + "RootDN access control violation", 0, NULL ); + slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsBindSecurityErrors); + value_done(&cv); + goto free_and_return; + } + /* + * Check the dn and password + */ if ( is_root_dn_pw( slapi_sdn_get_ndn(sdn), &cv )) { - bind_credentials_set( pb->pb_conn, SLAPD_AUTH_SIMPLE, - slapi_ch_strdup( slapi_sdn_get_ndn(sdn) ), + /* + * right dn and passwd - authorize + */ + bind_credentials_set( pb->pb_conn, SLAPD_AUTH_SIMPLE, slapi_ch_strdup(slapi_sdn_get_ndn(sdn)), NULL, NULL, NULL , NULL); - - /* right dn, wrong passwd - reject with invalid creds */ } else { - send_ldap_result( pb, LDAP_INVALID_CREDENTIALS, NULL, - NULL, 0, NULL ); + /* + * right dn, wrong passwd - reject with invalid credentials + */ + send_ldap_result( pb, LDAP_INVALID_CREDENTIALS, NULL, NULL, 0, NULL ); /* increment BindSecurityErrorcount */ slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsBindSecurityErrors); value_done(&cv); goto free_and_return; } + value_done(&cv); } diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index 76c031a93..4be8efd26 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -1062,6 +1062,14 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value ) (*(IFP *)value) = pblock->pb_plugin->plg_internal_post_delete; break; + /* rootDN pre bind operation plugin */ + case SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN: + if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) { + return( -1 ); + } + (*(IFP *)value) = pblock->pb_plugin->plg_internal_pre_bind; + break; + /* backend pre txn operation plugin */ case SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN: if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) { @@ -2620,6 +2628,12 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value ) } pblock->pb_plugin->plg_internal_pre_delete = (IFP) value; break; + case SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN: + if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) { + return( -1 ); + } + pblock->pb_plugin->plg_internal_pre_bind = (IFP) value; + break; /* internal postoperation plugin */ case SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN: diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c index 8aa95acee..436cc02e4 100644 --- a/ldap/servers/slapd/plugin.c +++ b/ldap/servers/slapd/plugin.c @@ -363,6 +363,7 @@ plugin_call_plugins( Slapi_PBlock *pb, int whichfunction ) case SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN: case SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN: case SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN: + case SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN: plugin_list_number= PLUGIN_LIST_INTERNAL_PREOPERATION; break; case SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN: @@ -387,6 +388,7 @@ plugin_call_plugins( Slapi_PBlock *pb, int whichfunction ) do_op = 1; /* always allow backend callbacks (even during startup) */ break; } + if(plugin_list_number!=-1 && do_op) { /* We stash the pblock plugin pointer to preserve the callers context */ @@ -1705,7 +1707,7 @@ plugin_get_type_and_list( } else if ( strcasecmp( plugintype, "index" ) == 0 ) { *type = SLAPI_PLUGIN_INDEX; plugin_list_index= PLUGIN_LIST_INDEX; - } else { + } else { return( 1 ); /* unknown plugin type - pass to backend */ } @@ -3205,3 +3207,10 @@ slapi_get_plugin_default_config(char *type, Slapi_ValueSet **valueset) return rc; } + +void +slapi_set_plugin_open_rootdn_bind(Slapi_PBlock *pb){ + struct pluginconfig *config = &pb->pb_plugin->plg_conf; + + ptd_set_special_data(&(config->plgc_bind_subtrees), PLGC_DATA_BIND_ROOT); +} diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 3138ed37b..d0f2b3365 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1004,11 +1004,13 @@ struct slapdplugin { IFP plg_un_internal_pre_modrdn; /* modrdn */ IFP plg_un_internal_pre_add; /* add */ IFP plg_un_internal_pre_delete; /* delete */ + IFP plg_un_internal_pre_bind; /* bind */ } plg_un_internal_pre; #define plg_internal_pre_modify plg_un.plg_un_internal_pre.plg_un_internal_pre_modify #define plg_internal_pre_modrdn plg_un.plg_un_internal_pre.plg_un_internal_pre_modrdn #define plg_internal_pre_add plg_un.plg_un_internal_pre.plg_un_internal_pre_add #define plg_internal_pre_delete plg_un.plg_un_internal_pre.plg_un_internal_pre_delete +#define plg_internal_pre_bind plg_un.plg_un_internal_pre.plg_un_internal_pre_bind /* internal post-operation plugin structure */ struct plg_un_internal_post_operation { diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 823652a73..63c37f027 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -6305,6 +6305,7 @@ typedef struct slapi_plugindesc { #define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421 #define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422 #define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423 +#define SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN 424 /* preoperation plugin to the backend */ #define SLAPI_PLUGIN_BE_PRE_ADD_FN 450 @@ -7078,6 +7079,8 @@ uint32_t slapi_str_to_u32(const char *s); */ uint64_t slapi_str_to_u64(const char *s); +void slapi_set_plugin_open_rootdn_bind(Slapi_PBlock *pb); + #ifdef __cplusplus } #endif
0
fe186737d67818189c9adefe2e63735eb55216d1
389ds/389-ds-base
Issue 5290 - Importing certificate chain files via "import-server-key-cert" no longer works (#5293) Description: Remove assertions from add_server_key_and_cert since pk12util has no issues importing certificate chain files Relates: https://github.com/389ds/389-ds-base/issues/5290 Reviewed by: droideck
commit fe186737d67818189c9adefe2e63735eb55216d1 Author: spike77453 <[email protected]> Date: Tue Jul 12 16:02:44 2022 +0200 Issue 5290 - Importing certificate chain files via "import-server-key-cert" no longer works (#5293) Description: Remove assertions from add_server_key_and_cert since pk12util has no issues importing certificate chain files Relates: https://github.com/389ds/389-ds-base/issues/5290 Reviewed by: droideck diff --git a/dirsrvtests/tests/suites/tls/tls_import_ca_chain_test.py b/dirsrvtests/tests/suites/tls/tls_import_ca_chain_test.py index 947fb8444..0be3a9aaa 100644 --- a/dirsrvtests/tests/suites/tls/tls_import_ca_chain_test.py +++ b/dirsrvtests/tests/suites/tls/tls_import_ca_chain_test.py @@ -40,15 +40,28 @@ def test_tls_import_chain(topology_st): 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) +def test_tls_import_chain_pk12util(topology_st): + """Test that importing certificate chain files via pk12util does not report + any errors + + :id: c38b2cf9-93f0-4168-ab23-c74ac21ad59f + + :steps: + 1. Attempt to import a ca chain + + :expectedresults: + 1. Chain is successfully imported, no errors raised + """ + + topology_st.standalone.stop() + tls = NssSsl(dirsrv=topology_st.standalone) + tls.reinit() + + tls.add_server_key_and_cert(KEY_FILE, CRT_CHAIN_FILE) + tls.add_server_key_and_cert(KEY_CHAIN_FILE, CRT_CHAIN_FILE) + tls.add_server_key_and_cert(KEY_FILE, KEY_CHAIN_FILE) diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py index 3561597b9..191c2a314 100644 --- a/src/lib389/lib389/nss_ssl.py +++ b/src/lib389/lib389/nss_ssl.py @@ -1039,9 +1039,6 @@ 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
9b702edb573ae2381255258a2499e3a71c5c77e2
389ds/389-ds-base
Ticket 49089 - List library build deps Bug Description: lslebodn notified us of: https://bugzilla.redhat.com/show_bug.cgi?id=1260190 https://lists.gnu.org/archive/html/automake/2010-03/msg00039.html This highlighted to me that we were not correctly tracking the dependencies of our build, where libslapd.la was not a dependency of the make targets for other plugins. It's better to be explicit! Fix Description: Add explicit dependencies lines to our makefile: That way there can be no mistakes during a compliation. https://fedorahosted.org/389/ticket/49089 Author: wibrown Review by: mreynolds (Thanks)
commit 9b702edb573ae2381255258a2499e3a71c5c77e2 Author: William Brown <[email protected]> Date: Fri Jan 13 10:34:39 2017 +1000 Ticket 49089 - List library build deps Bug Description: lslebodn notified us of: https://bugzilla.redhat.com/show_bug.cgi?id=1260190 https://lists.gnu.org/archive/html/automake/2010-03/msg00039.html This highlighted to me that we were not correctly tracking the dependencies of our build, where libslapd.la was not a dependency of the make targets for other plugins. It's better to be explicit! Fix Description: Add explicit dependencies lines to our makefile: That way there can be no mistakes during a compliation. https://fedorahosted.org/389/ticket/49089 Author: wibrown Review by: mreynolds (Thanks) diff --git a/Makefile.am b/Makefile.am index 5f27681ef..78248e5de 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1140,6 +1140,7 @@ libback_ldbm_la_SOURCES = ldap/servers/slapd/back-ldbm/ancestorid.c \ ldap/servers/slapd/back-ldbm/vlv_srch.c libback_ldbm_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) @db_inc@ +libback_ldbm_la_DEPENDENCIES = libslapd.la libback_ldbm_la_LIBADD = libslapd.la $(DB_LINK) $(LDAPSDK_LINK) $(NSPR_LINK) libback_ldbm_la_LDFLAGS = -avoid-version @@ -1153,6 +1154,7 @@ libacctpolicy_plugin_la_SOURCES = ldap/servers/plugins/acctpolicy/acct_config.c libacctpolicy_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libacctpolicy_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libacctpolicy_plugin_la_DEPENDENCIES = libslapd.la libacctpolicy_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1162,6 +1164,7 @@ libacctusability_plugin_la_SOURCES = ldap/servers/plugins/acct_usability/acct_us libacctusability_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libacctusability_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libacctusability_plugin_la_DEPENDENCIES = libslapd.la libacctusability_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1180,6 +1183,7 @@ libacl_plugin_la_SOURCES = ldap/servers/plugins/acl/acl.c \ ldap/servers/plugins/acl/aclutil.c libacl_plugin_la_CPPFLAGS = -I$(srcdir)/include/libaccess $(PLUGIN_CPPFLAGS) +libacl_plugin_la_DEPENDENCIES = libslapd.la libns-dshttpd.la libacl_plugin_la_LIBADD = libslapd.la libns-dshttpd.la $(LDAPSDK_LINK) $(NSPR_LINK) $(LIBCSTD) $(LIBCRUN) libacl_plugin_la_LDFLAGS = -avoid-version # libacl_plugin_la_LINK = $(CXXLINK) -avoid-version @@ -1191,6 +1195,7 @@ libaddn_plugin_la_SOURCES = ldap/servers/plugins/addn/addn.c libaddn_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libaddn_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libaddn_plugin_la_DEPENDENCIES = libslapd.la libaddn_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1201,6 +1206,7 @@ librootdn_access_plugin_la_SOURCES = ldap/servers/plugins/rootdn_access/rootdn_a librootdn_access_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) librootdn_access_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +librootdn_access_plugin_la_DEPENDENCIES = libslapd.la librootdn_access_plugin_la_LDFLAGS = -avoid-version @@ -1211,6 +1217,7 @@ libautomember_plugin_la_SOURCES = ldap/servers/plugins/automember/automember.c libautomember_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libautomember_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libautomember_plugin_la_DEPENDENCIES = libslapd.la libautomember_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1222,6 +1229,7 @@ libattr_unique_plugin_la_SOURCES = ldap/servers/plugins/uiduniq/7bit.c \ libattr_unique_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libattr_unique_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libattr_unique_plugin_la_DEPENDENCIES = libslapd.la libattr_unique_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1231,6 +1239,7 @@ libbitwise_plugin_la_SOURCES = ldap/servers/plugins/bitwise/bitwise.c libbitwise_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libbitwise_plugin_la_LIBADD = libslapd.la +libbitwise_plugin_la_DEPENDENCIES = libslapd.la libbitwise_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1264,6 +1273,7 @@ libchainingdb_plugin_la_SOURCES = ldap/servers/plugins/chainingdb/cb_abandon.c \ libchainingdb_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libchainingdb_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libchainingdb_plugin_la_DEPENDENCIES = libslapd.la libchainingdb_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1275,6 +1285,7 @@ libcollation_plugin_la_SOURCES = ldap/servers/plugins/collation/collate.c \ libcollation_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) @icu_inc@ libcollation_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) $(ICU_LINK) $(LIBCSTD) $(LIBCRUN) +libcollation_plugin_la_DEPENDENCIES = libslapd.la libcollation_plugin_la_LDFLAGS = -avoid-version # libcollation_plugin_la_LINK = $(CXXLINK) -avoid-version @@ -1286,6 +1297,7 @@ libcos_plugin_la_SOURCES = ldap/servers/plugins/cos/cos.c \ libcos_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libcos_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libcos_plugin_la_DEPENDENCIES = libslapd.la libcos_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1295,6 +1307,7 @@ libderef_plugin_la_SOURCES = ldap/servers/plugins/deref/deref.c libderef_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libderef_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libderef_plugin_la_DEPENDENCIES = libslapd.la libderef_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1305,6 +1318,7 @@ libpbe_plugin_la_SOURCES = ldap/servers/plugins/rever/pbe.c \ libpbe_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) @svrcore_inc@ libpbe_plugin_la_LIBADD = libslapd.la $(NSS_LINK) +libpbe_plugin_la_DEPENDENCIES = libslapd.la libpbe_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1314,6 +1328,7 @@ libdistrib_plugin_la_SOURCES = ldap/servers/plugins/distrib/distrib.c libdistrib_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libdistrib_plugin_la_LIBADD = libslapd.la +libdistrib_plugin_la_DEPENDENCIES = libslapd.la libdistrib_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1323,6 +1338,7 @@ libdna_plugin_la_SOURCES = ldap/servers/plugins/dna/dna.c libdna_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libdna_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libdna_plugin_la_DEPENDENCIES = libslapd.la libdna_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1333,6 +1349,7 @@ libhttp_client_plugin_la_SOURCES = ldap/servers/plugins/http/http_client.c \ libhttp_client_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libhttp_client_plugin_la_LIBADD = libslapd.la $(NSS_LINK) $(NSPR_LINK) +libhttp_client_plugin_la_DEPENDENCIES = libslapd.la libhttp_client_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1343,6 +1360,7 @@ liblinkedattrs_plugin_la_SOURCES = ldap/servers/plugins/linkedattrs/fixup_task.c liblinkedattrs_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) liblinkedattrs_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +liblinkedattrs_plugin_la_DEPENDENCIES = libslapd.la liblinkedattrs_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1352,6 +1370,7 @@ libmanagedentries_plugin_la_SOURCES = ldap/servers/plugins/mep/mep.c libmanagedentries_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libmanagedentries_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libmanagedentries_plugin_la_DEPENDENCIES = libslapd.la libmanagedentries_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1362,6 +1381,7 @@ libmemberof_plugin_la_SOURCES= ldap/servers/plugins/memberof/memberof.c \ libmemberof_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libmemberof_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libmemberof_plugin_la_DEPENDENCIES = libslapd.la libmemberof_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1374,6 +1394,7 @@ libpam_passthru_plugin_la_SOURCES = ldap/servers/plugins/pam_passthru/pam_ptconf libpam_passthru_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libpam_passthru_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) $(PAM_LINK) +libpam_passthru_plugin_la_DEPENDENCIES = libslapd.la libpam_passthru_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1388,6 +1409,7 @@ libpassthru_plugin_la_SOURCES = ldap/servers/plugins/passthru/ptbind.c \ libpassthru_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libpassthru_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libpassthru_plugin_la_DEPENDENCIES = libslapd.la libpassthru_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1401,6 +1423,7 @@ libposix_winsync_plugin_la_SOURCES = ldap/servers/plugins/posix-winsync/posix-wi libposix_winsync_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) -DWINSYNC_TEST_POSIX \ -I$(srcdir)/ldap/servers/plugins/replication libposix_winsync_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libposix_winsync_plugin_la_DEPENDENCIES = libslapd.la libposix_winsync_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1410,6 +1433,7 @@ libpresence_plugin_la_SOURCES = ldap/servers/plugins/presence/presence.c libpresence_plugin_la_CPPFLAGS = -I$(srcdir)/ldap/servers/plugins/http $(PLUGIN_CPPFLAGS) libpresence_plugin_la_LIBADD = libslapd.la +libpresence_plugin_la_DEPENDENCIES = libslapd.la libpresence_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1429,6 +1453,7 @@ libpwdstorage_plugin_la_SOURCES = ldap/servers/plugins/pwdstorage/clear_pwd.c \ libpwdstorage_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libpwdstorage_plugin_la_LIBADD = libslapd.la $(NSS_LINK) $(NSPR_LINK) $(LIBCRYPT) +libpwdstorage_plugin_la_DEPENDENCIES = libslapd.la libpwdstorage_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1441,6 +1466,7 @@ libcontentsync_plugin_la_SOURCES = ldap/servers/plugins/sync/sync_init.c \ libcontentsync_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libcontentsync_plugin_la_LIBADD = libslapd.la $(NSS_LINK) $(NSPR_LINK) $(LIBCRYPT) +libcontentsync_plugin_la_DEPENDENCIES = libslapd.la libcontentsync_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1450,6 +1476,7 @@ libreferint_plugin_la_SOURCES = ldap/servers/plugins/referint/referint.c libreferint_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libreferint_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libreferint_plugin_la_DEPENDENCIES = libslapd.la libreferint_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1514,6 +1541,7 @@ libreplication_plugin_la_SOURCES = ldap/servers/plugins/replication/cl5_api.c \ libreplication_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) @icu_inc@ @db_inc@ libreplication_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSS_LINK) $(NSPR_LINK) $(ICU_LINK) $(DB_LINK) +libreplication_plugin_la_DEPENDENCIES = libslapd.la libreplication_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1528,6 +1556,7 @@ libretrocl_plugin_la_SOURCES = ldap/servers/plugins/retrocl/retrocl.c \ libretrocl_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libretrocl_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libretrocl_plugin_la_DEPENDENCIES = libslapd.la libretrocl_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1538,6 +1567,7 @@ libroles_plugin_la_SOURCES = ldap/servers/plugins/roles/roles_cache.c \ libroles_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libroles_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libroles_plugin_la_DEPENDENCIES = libslapd.la libroles_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1547,6 +1577,7 @@ libschemareload_plugin_la_SOURCES = ldap/servers/plugins/schema_reload/schema_re libschemareload_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libschemareload_plugin_la_LIBADD = libslapd.la $(NSPR_LINK) +libschemareload_plugin_la_DEPENDENCIES = libslapd.la libschemareload_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1556,6 +1587,7 @@ libstatechange_plugin_la_SOURCES = ldap/servers/plugins/statechange/statechange. libstatechange_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libstatechange_plugin_la_LIBADD = libslapd.la +libstatechange_plugin_la_DEPENDENCIES = libslapd.la libstatechange_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1586,6 +1618,7 @@ libsyntax_plugin_la_SOURCES = ldap/servers/plugins/syntaxes/bin.c \ libsyntax_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libsyntax_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libsyntax_plugin_la_DEPENDENCIES = libslapd.la libsyntax_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1596,6 +1629,7 @@ libusn_plugin_la_SOURCES = ldap/servers/plugins/usn/usn.c \ libusn_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libusn_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libusn_plugin_la_DEPENDENCIES = libslapd.la libusn_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1605,6 +1639,7 @@ libviews_plugin_la_SOURCES = ldap/servers/plugins/views/views.c libviews_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libviews_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libviews_plugin_la_DEPENDENCIES = libslapd.la libviews_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1614,6 +1649,7 @@ libwhoami_plugin_la_SOURCES = ldap/servers/plugins/whoami/whoami.c libwhoami_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) libwhoami_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) +libwhoami_plugin_la_DEPENDENCIES = libslapd.la libwhoami_plugin_la_LDFLAGS = -avoid-version #------------------------ @@ -1698,6 +1734,7 @@ migratecred_bin_SOURCES = ldap/servers/slapd/tools/migratecred.c migratecred_bin_CPPFLAGS = $(AM_CPPFLAGS) @openldap_inc@ @ldapsdk_inc@ @nss_inc@ @nspr_inc@ migratecred_bin_LDADD = libslapd.la $(NSPR_LINK) $(NSS_LINK) $(SVRCORE_LINK) $(LDAPSDK_LINK) $(SASL_LINK) +migratecred_bin_DEPENDENCIES = libslapd.la #------------------------ # mmldif @@ -1706,6 +1743,7 @@ mmldif_bin_SOURCES = ldap/servers/slapd/tools/mmldif.c mmldif_bin_CPPFLAGS = $(AM_CPPFLAGS) @openldap_inc@ @ldapsdk_inc@ @nss_inc@ @nspr_inc@ mmldif_bin_LDADD = libslapd.la $(NSPR_LINK) $(NSS_LINK) $(SVRCORE_LINK) $(LDAPSDK_LINK_NOTHR) $(SASL_LINK) +mmldif_bin_DEPENDENCIES = libslapd.la #------------------------ # ns-slapd @@ -1759,6 +1797,7 @@ ns_slapd_CPPFLAGS = $(AM_CPPFLAGS) @sasl_inc@ @openldap_inc@ @ldapsdk_inc@ @nss_ @nspr_inc@ @svrcore_inc@ @systemd_inc@ ns_slapd_LDADD = libslapd.la libldaputil.a $(LDAPSDK_LINK) $(NSS_LINK) $(LIBADD_DL) \ $(NSPR_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LINK) +ns_slapd_DEPENDENCIES = libslapd.la # We need to link ns-slapd with the C++ compiler on HP-UX since we load # some C++ shared libraries (such as icu). if HPUX @@ -1774,6 +1813,7 @@ pwdhash_bin_SOURCES = ldap/servers/slapd/tools/pwenc.c pwdhash_bin_CPPFLAGS = $(AM_CPPFLAGS) @openldap_inc@ @ldapsdk_inc@ @nss_inc@ @nspr_inc@ pwdhash_bin_LDADD = libslapd.la $(NSPR_LINK) $(NSS_LINK) $(SVRCORE_LINK) $(LDAPSDK_LINK) $(SASL_LINK) +pwdhash_bin_DEPENDENCIES = libslapd.la #------------------------ # rsearch
0
65eeb67366c1a38260db5703e67f6a8b74f3aa00
389ds/389-ds-base
Removed ldaptags and Whos Online references
commit 65eeb67366c1a38260db5703e67f6a8b74f3aa00 Author: Nathan Kinder <[email protected]> Date: Tue Apr 19 19:59:07 2005 +0000 Removed ldaptags and Whos Online references diff --git a/ldap/clients/Makefile b/ldap/clients/Makefile index d255caf0f..8fd81ef15 100644 --- a/ldap/clients/Makefile +++ b/ldap/clients/Makefile @@ -49,13 +49,7 @@ BUILD_ROOT=../.. include $(BUILD_ROOT)/nsconfig.mk include $(BUILD_ROOT)/ldap/javarules.mk -all: _ldaptags _online _dsgw _dsmlgw - -_ldaptags: - cd ldaptags; $(MAKE) - -_online: - cd online; $(MAKE) +all: _dsgw _dsmlgw _dsgw: cd dsgw; $(MAKE) diff --git a/ldap/cm/Makefile b/ldap/cm/Makefile index 21ec1ddcd..3bba1b3ed 100644 --- a/ldap/cm/Makefile +++ b/ldap/cm/Makefile @@ -362,16 +362,6 @@ endif # USE_DSMLGW $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/ldif/*.ldif $(RELDIR)/bin/slapd/install/ldif $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/dsml/*.dsml $(RELDIR)/bin/slapd/install/dsml -# Package online and ldaptags only if they exist: they are only built on -# Solaris and NT but packaged on all platforms - if [ -d $(BUILD_DRIVE)$(BUILD_ROOT)/../dist/online ] ; then \ - $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/../dist/online/*.war $(RELDIR)/clients/slapd ; \ - $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/online/doc/*.html $(RELDIR)/clients/slapd ; \ - $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/online/ldif/*.ldif $(RELDIR)/clients/slapd ; \ - fi -# if [ -d $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/ldaptags ] ; then \ -# $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/ldaptags/doc/*.html $(RELDIR)/clients/slapd ; \ -# fi ### Package up the orgchart ### ifeq ($(USE_ORGCHART), 1)
0
d4eedec8e22e8973b71f560c4f2ab1232abbd91b
389ds/389-ds-base
Trac Ticket 51 - memory leaks in 389-ds-base-1.2.8.2-1.el5? https://fedorahosted.org/389/ticket/51 Fix description: Ran valgrind with the MMR+SASL servers and fixed leaks found in the test. [plugin/replication/repl5_connection.c] conn_connect could have overridden conn->ld without releasing it. This patch releases it if necessary. [slapd/dn.c] If DN normalization fails in slapi_sdn_get_dn, this patch releases the locally strdup'ed string. [slapd/modify.c, modutil.c] DN syntax attribute value is found in mods, it was normalized and replaced in slapi_mods_insert_at. It leaked the pre- noralized value. Instead, this patch normalizes mods in do_modify and frees it when the modify is done. [slapd/operation.c] modrdn_newsuperior_address.sdn was not release when the modrdn operaton is done. This patch adds the release code.
commit d4eedec8e22e8973b71f560c4f2ab1232abbd91b Author: Noriko Hosoi <[email protected]> Date: Fri Feb 3 12:55:28 2012 -0800 Trac Ticket 51 - memory leaks in 389-ds-base-1.2.8.2-1.el5? https://fedorahosted.org/389/ticket/51 Fix description: Ran valgrind with the MMR+SASL servers and fixed leaks found in the test. [plugin/replication/repl5_connection.c] conn_connect could have overridden conn->ld without releasing it. This patch releases it if necessary. [slapd/dn.c] If DN normalization fails in slapi_sdn_get_dn, this patch releases the locally strdup'ed string. [slapd/modify.c, modutil.c] DN syntax attribute value is found in mods, it was normalized and replaced in slapi_mods_insert_at. It leaked the pre- noralized value. Instead, this patch normalizes mods in do_modify and frees it when the modify is done. [slapd/operation.c] modrdn_newsuperior_address.sdn was not release when the modrdn operaton is done. This patch adds the release code. diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c index 4cf69d1d9..a074a9ff6 100644 --- a/ldap/servers/plugins/replication/repl5_connection.c +++ b/ldap/servers/plugins/replication/repl5_connection.c @@ -1085,6 +1085,11 @@ conn_connect(Repl_Connection *conn) secure ? "secure" : "non-secure", (secure == 2) ? " startTLS" : ""); /* shared = 1 because we will read results from a second thread */ + if (conn->ld) { + /* Since we call slapi_ldap_init, we must call slapi_ldap_unbind */ + /* ldap_unbind internally calls ldap_ld_free */ + slapi_ldap_unbind(conn->ld); + } conn->ld = slapi_ldap_init_ext(NULL, conn->hostname, conn->port, secure, 1, NULL); if (NULL == conn->ld) { @@ -1176,8 +1181,7 @@ close_connection_internal(Repl_Connection *conn) to use conn->ld */ if (NULL != conn->ld) { - /* Since we call slapi_ldap_init, - we must call slapi_ldap_unbind */ + /* Since we call slapi_ldap_init, we must call slapi_ldap_unbind */ slapi_ldap_unbind(conn->ld); } conn->ld = NULL; diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c index aeb24b357..568871fb3 100644 --- a/ldap/servers/slapd/dn.c +++ b/ldap/servers/slapd/dn.c @@ -2256,8 +2256,9 @@ slapi_sdn_get_dn(const Slapi_DN *sdn) ncsdn->flag = slapi_setbit_uchar(sdn->flag, FLAG_DN); PR_INCREMENT_COUNTER(slapi_sdn_counter_dn_created); PR_INCREMENT_COUNTER(slapi_sdn_counter_dn_exist); + } else { /* else (rc < 0); normalization failed. return NULL */ + slapi_ch_free_string(&udn); } - /* else (rc < 0); normzlization failed. return NULL */ return sdn->dn; } else { return NULL; diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c index 563512d5a..bffc788f2 100644 --- a/ldap/servers/slapd/modify.c +++ b/ldap/servers/slapd/modify.c @@ -142,6 +142,7 @@ do_modify( Slapi_PBlock *pb ) char *old_pw = NULL; /* remember the old password */ char *rawdn = NULL; int minssf_exclude_rootdse = 0; + LDAPMod **normalized_mods = NULL; LDAPDebug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 ); @@ -389,12 +390,22 @@ do_modify( Slapi_PBlock *pb ) mods = slapi_mods_get_ldapmods_passout (&smods); - slapi_pblock_set( pb, SLAPI_MODIFY_MODS, mods); + /* normalize the mods */ + normalized_mods = normalize_mods2bvals((const LDAPMod**)mods); + ldap_mods_free (mods, 1 /* Free the Array and the Elements */); + if (normalized_mods == NULL) { + op_shared_log_error_access(pb, "MOD", rawdn?rawdn:"", + "mod includes invalid dn format"); + send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL, + "mod includes invalid dn format", 0, NULL); + goto free_and_return; + } + slapi_pblock_set(pb, SLAPI_MODIFY_MODS, normalized_mods); op_shared_modify ( pb, pw_change, old_pw ); - slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods); - ldap_mods_free (mods, 1 /* Free the Array and the Elements */); + slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &normalized_mods); + ldap_mods_free (normalized_mods, 1 /* Free the Array and the Elements */); free_and_return:; slapi_ch_free ((void**)&rawdn); diff --git a/ldap/servers/slapd/modutil.c b/ldap/servers/slapd/modutil.c index 8216c0725..18b7fb67b 100644 --- a/ldap/servers/slapd/modutil.c +++ b/ldap/servers/slapd/modutil.c @@ -188,7 +188,6 @@ void slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos) { int i; - Slapi_Attr a = {0}; if (NULL == mod) { return; @@ -198,18 +197,6 @@ slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos) { smods->mods[i+1]= smods->mods[i]; } - slapi_attr_init(&a, mod->mod_type); - /* Check if the type of the to-be-added values has DN syntax or not. */ - if (slapi_attr_is_dn_syntax_attr(&a)) { - struct berval **mbvp = NULL; - for (mbvp = mod->mod_bvalues; mbvp && *mbvp; mbvp++) { - Slapi_DN *sdn = slapi_sdn_new_dn_byref((*mbvp)->bv_val); - (*mbvp)->bv_val = slapi_ch_strdup(slapi_sdn_get_dn(sdn)); - (*mbvp)->bv_len = slapi_sdn_get_ndn_len(sdn); - slapi_sdn_free(&sdn); - } - } - attr_done(&a); smods->mods[pos]= mod; smods->num_mods++; smods->mods[smods->num_mods]= NULL; diff --git a/ldap/servers/slapd/operation.c b/ldap/servers/slapd/operation.c index 1479ee9da..f5b16275e 100644 --- a/ldap/servers/slapd/operation.c +++ b/ldap/servers/slapd/operation.c @@ -481,6 +481,7 @@ operation_parameters_done (struct slapi_operation_parameters *sop) case SLAPI_OPERATION_MODRDN: slapi_ch_free((void **)&(sop->p.p_modrdn.modrdn_newrdn)); slapi_ch_free((void **)&(sop->p.p_modrdn.modrdn_newsuperior_address.uniqueid)); + slapi_sdn_free(&sop->p.p_modrdn.modrdn_newsuperior_address.sdn); ldap_mods_free(sop->p.p_modrdn.modrdn_mods, 1 /* Free the Array and the Elements */); sop->p.p_modrdn.modrdn_mods= NULL; break; diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c index df3f7ef4c..16ba40eb6 100644 --- a/ldap/servers/slapd/search.c +++ b/ldap/servers/slapd/search.c @@ -407,7 +407,7 @@ do_search( Slapi_PBlock *pb ) } free_and_return:; - if ( !psearch || rc < 0 ) { + if ( !psearch || rc != 0 ) { slapi_ch_free_string(&fstr); slapi_filter_free( filter, 1 ); charray_free( attrs ); /* passing NULL is fine */
0
ad640e96dd995583c65ff93d2af8f96efb2162f8
389ds/389-ds-base
Issue 48377 - Update file name for LD_PRELOAD Bug Description: We ship versioned libjemalloc.so.2, but LD_PRELOAD still uses unversioned file name. Fix Description: Update LD_PRELOAD to use versioned .so name. https://pagure.io/389-ds-base/issue/48377 Reviewed by: mreynolds (Thanks!)
commit ad640e96dd995583c65ff93d2af8f96efb2162f8 Author: Viktor Ashirov <[email protected]> Date: Wed Aug 8 12:52:23 2018 +0200 Issue 48377 - Update file name for LD_PRELOAD Bug Description: We ship versioned libjemalloc.so.2, but LD_PRELOAD still uses unversioned file name. Fix Description: Update LD_PRELOAD to use versioned .so name. https://pagure.io/389-ds-base/issue/48377 Reviewed by: mreynolds (Thanks!) diff --git a/ldap/admin/src/base-initconfig.in b/ldap/admin/src/base-initconfig.in index f9e9bdc26..57f995782 100644 --- a/ldap/admin/src/base-initconfig.in +++ b/ldap/admin/src/base-initconfig.in @@ -45,4 +45,4 @@ # fragmentation avoidance and scalable concurrency support. jemalloc # has been shown to have a significant positive impact on the Directory # Server's process size/growth. -LD_PRELOAD=@libdir@/@package_name@/lib/libjemalloc.so +LD_PRELOAD=@libdir@/@package_name@/lib/libjemalloc.so.2 diff --git a/man/man5/dirsrv.5 b/man/man5/dirsrv.5 index b82048493..e21ceab2f 100644 --- a/man/man5/dirsrv.5 +++ b/man/man5/dirsrv.5 @@ -34,7 +34,7 @@ dirsrv-localhost for the slapd-localhost instance. This file is in systemd EnvironmentFile format - see man systemd.exec .SH EXAMPLE -LD_PRELOAD=/usr/lib64/dirsrv/lib/libjemalloc.so +LD_PRELOAD=/usr/lib64/dirsrv/lib/libjemalloc.so.2 .SH AUTHOR
0
a333e683d6b15eafb5a098e581eb7a281b15137c
389ds/389-ds-base
Bug 630096 - (cov#15449,15450) Check return value of stat() We were not checking the return value of stat() before attempting to access the structure that stat fille in in the protect_db code. This patch checks the return value first.
commit a333e683d6b15eafb5a098e581eb7a281b15137c Author: Nathan Kinder <[email protected]> Date: Wed Sep 8 07:58:15 2010 -0700 Bug 630096 - (cov#15449,15450) Check return value of stat() We were not checking the return value of stat() before attempting to access the structure that stat fille in in the protect_db code. This patch checks the return value first. diff --git a/ldap/servers/slapd/protect_db.c b/ldap/servers/slapd/protect_db.c index c90c80012..ce113948b 100644 --- a/ldap/servers/slapd/protect_db.c +++ b/ldap/servers/slapd/protect_db.c @@ -205,10 +205,12 @@ make_sure_dir_exists(char *dir) slapdFrontendConfig->localuserinfo != NULL) { pw = slapdFrontendConfig->localuserinfo; if (chown(dir, pw->pw_uid, -1) == -1) { - stat(dir, &stat_buffer); - if (stat_buffer.st_uid != pw->pw_uid) { + if ((stat(dir, &stat_buffer) == 0) && (stat_buffer.st_uid != pw->pw_uid)) { LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, dir, 0, 0); return 1; + } else { + LDAPDebug(LDAP_DEBUG_ANY, STAT_ERROR, dir, errno, 0); + return 1; } } } @@ -242,8 +244,7 @@ add_this_process_to(char *dir_name) slapdFrontendConfig->localuserinfo != NULL) { pw = slapdFrontendConfig->localuserinfo; if (chown(file_name, pw->pw_uid, -1) == -1) { - stat(file_name, &stat_buffer); - if (stat_buffer.st_uid != pw->pw_uid) { + if ((stat(file_name, &stat_buffer) == 0) && (stat_buffer.st_uid != pw->pw_uid)) { LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, file_name, 0, 0); } } diff --git a/ldap/servers/slapd/protect_db.h b/ldap/servers/slapd/protect_db.h index 1def34c94..bbb5324f4 100644 --- a/ldap/servers/slapd/protect_db.h +++ b/ldap/servers/slapd/protect_db.h @@ -76,6 +76,9 @@ void remove_slapd_process(); #define CHOWN_WARNING "Warning - couldn't set the ownership for %s\n" /* file name */ +#define STAT_ERROR "Error - unable to stat %s (error %d)\n" + /* file name, error number */ + #define NO_SERVER_DUE_TO_SERVER "Unable to start slapd because it is already running as process %d\n" /* pid of running slapd process */
0
ba6ce79587ea422d84cf0a3ec476d15de87c6608
389ds/389-ds-base
Resolves: #339791 Summary: rhds71sp1 rhel3u6 - ns-slapd process dies with segmentation fault Description: ldap_utf8prev, LDAP_UTF8PREV, and LDAP_UTF8DEC were sometimes used without checking the returned pointer going back beyond the beginning of the string.
commit ba6ce79587ea422d84cf0a3ec476d15de87c6608 Author: Noriko Hosoi <[email protected]> Date: Wed Oct 24 18:41:15 2007 +0000 Resolves: #339791 Summary: rhds71sp1 rhel3u6 - ns-slapd process dies with segmentation fault Description: ldap_utf8prev, LDAP_UTF8PREV, and LDAP_UTF8DEC were sometimes used without checking the returned pointer going back beyond the beginning of the string. diff --git a/ldap/servers/plugins/acl/acllas.c b/ldap/servers/plugins/acl/acllas.c index 1b04215c7..b38150c2e 100644 --- a/ldap/servers/plugins/acl/acllas.c +++ b/ldap/servers/plugins/acl/acllas.c @@ -562,7 +562,10 @@ DS_LASUserDnEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator, /* ignore trailing whitespace */ len = strlen(user); ptr = user+len-1; - while(ldap_utf8isspace(ptr)){ *ptr = '\0'; LDAP_UTF8DEC(ptr); } + while(ptr >= user && ldap_utf8isspace(ptr)) { + *ptr = '\0'; + LDAP_UTF8DEC(ptr); + } } /* @@ -806,7 +809,10 @@ DS_LASGroupDnEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator, /* ignore trailing whitespace */ len = strlen(groupName); ptr = groupName+len-1; - while(ldap_utf8isspace(ptr)) { *ptr = '\0'; LDAP_UTF8DEC(ptr); } + while(ptr >= groupName && ldap_utf8isspace(ptr)) { + *ptr = '\0'; + LDAP_UTF8DEC(ptr); + } } /* @@ -966,7 +972,10 @@ DS_LASRoleDnEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator, /* ignore trailing whitespace */ len = strlen(role); ptr = role+len-1; - while(ldap_utf8isspace(ptr)) { *ptr = '\0'; LDAP_UTF8DEC(ptr); } + while(ptr >= role && ldap_utf8isspace(ptr)) { + *ptr = '\0'; + LDAP_UTF8DEC(ptr); + } } /* @@ -1118,7 +1127,10 @@ DS_LASUserDnAttrEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator, while(ldap_utf8isspace(attrName)) LDAP_UTF8INC(attrName); len = strlen(attrName); ptr = attrName+len-1; - while(ldap_utf8isspace(ptr)) { *ptr = '\0'; LDAP_UTF8DEC(ptr); } + while(ptr >= attrName && ldap_utf8isspace(ptr)) { + *ptr = '\0'; + LDAP_UTF8DEC(ptr); + } /* See if we have a parent[2].attr" rule */ @@ -1346,7 +1358,10 @@ DS_LASAuthMethodEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator, while(ldap_utf8isspace(attr)) LDAP_UTF8INC(attr); len = strlen(attr); ptr = attr+len-1; - while(ldap_utf8isspace(ptr)) { *ptr = '\0'; LDAP_UTF8DEC(ptr); } + while(ptr >= attr && ldap_utf8isspace(ptr)) { + *ptr = '\0'; + LDAP_UTF8DEC(ptr); + } slapi_log_error( SLAPI_LOG_ACL, plugin_name, "DS_LASAuthMethodEval:authtype:%s authmethod:%s\n", @@ -2124,7 +2139,10 @@ DS_LASGroupDnAttrEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator, while(ldap_utf8isspace(attrName)) LDAP_UTF8INC(attrName); len = strlen(attrName); ptr = attrName+len-1; - while(ldap_utf8isspace(ptr)) { *ptr = '\0'; LDAP_UTF8DEC(ptr); } + while(ptr >= attrName && ldap_utf8isspace(ptr)) { + *ptr = '\0'; + LDAP_UTF8DEC(ptr); + } slapi_log_error( SLAPI_LOG_ACL, plugin_name,"Attr:%s\n" , attrName, 0,0); diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c index 86a609256..36ed8456c 100644 --- a/ldap/servers/plugins/acl/aclparse.c +++ b/ldap/servers/plugins/acl/aclparse.c @@ -464,7 +464,7 @@ __aclp__sanity_check_acltxt (aci_t *aci_item, char *str) char *next; next = s + 12; s--; - while (s != str && ldap_utf8isspace(s)) LDAP_UTF8DEC(s); + while (s > str && ldap_utf8isspace(s)) LDAP_UTF8DEC(s); if (s && *s == ';') { /* We don't support authenticate stuff */ return ACL_INVALID_AUTHORIZATION; @@ -1542,9 +1542,12 @@ __acl_strip_trailing_space( char *str) { if (*str) { /* ignore trailing whitespace */ - len = strlen(str); - ptr = str+len-1; - while(ldap_utf8isspace(ptr)){ *ptr = '\0'; LDAP_UTF8DEC(ptr); } + len = strlen(str); + ptr = str+len-1; + while(ptr >= str && ldap_utf8isspace(ptr)) { + *ptr = '\0'; + LDAP_UTF8DEC(ptr); + } } } diff --git a/ldap/servers/plugins/syntaxes/value.c b/ldap/servers/plugins/syntaxes/value.c index f654686bf..f127b6b63 100644 --- a/ldap/servers/plugins/syntaxes/value.c +++ b/ldap/servers/plugins/syntaxes/value.c @@ -88,13 +88,14 @@ utf8isspace_fast( char* s ) */ void value_normalize( - char *s, - int syntax, + char *s, + int syntax, int trim_spaces ) { - char *d; - int prevspace, curspace; + char *head = s; + char *d; + int prevspace, curspace; if ( ! (syntax & SYNTAX_CIS) && ! (syntax & SYNTAX_CES) ) { return; @@ -107,10 +108,10 @@ value_normalize( d = s; if (trim_spaces) { - /* strip leading blanks */ - while (utf8isspace_fast(s)) { - LDAP_UTF8INC(s); - } + /* strip leading blanks */ + while (utf8isspace_fast(s)) { + LDAP_UTF8INC(s); + } } /* for int syntax, look for leading sign, then trim 0s */ @@ -167,8 +168,8 @@ value_normalize( /* compress multiple blanks */ if ( prevspace && curspace ) { - LDAP_UTF8INC(s); - continue; + LDAP_UTF8INC(s); + continue; } prevspace = curspace; if ( syntax & SYNTAX_CIS ) { @@ -177,28 +178,28 @@ value_normalize( s += ssz; d += dsz; } else { - char *np; - int sz; + char *np; + int sz; - np = ldap_utf8next(s); - if (np == NULL || np == s) break; - sz = np - s; - memmove(d,s,sz); - d += sz; - s += sz; + np = ldap_utf8next(s); + if (np == NULL || np == s) break; + sz = np - s; + memmove(d,s,sz); + d += sz; + s += sz; } } *d = '\0'; /* strip trailing blanks */ if (prevspace && trim_spaces) { - char *nd; + char *nd; - nd = ldap_utf8prev(d); - while (nd && utf8isspace_fast(nd)) { - d = nd; - nd = ldap_utf8prev(d); - *d = '\0'; - } + nd = ldap_utf8prev(d); + while (nd && nd >= head && utf8isspace_fast(nd)) { + d = nd; + nd = ldap_utf8prev(d); + *d = '\0'; + } } }
0
4350443d0b117914762479b92272bc67a3e62a05
389ds/389-ds-base
Bug(s) fixed: 158235 Bug Description: Phonebook/gateway: Object class violation - missing attribute "ntUserDomainId" required by object class "ntGroup" Reviewed by: David (Thanks!) Fix Description: 1) Change all places that use ntgroupdomainid to use ntuserdomainid instead 2) Get rid of support for NT domains. There were many places in the code that expected the nt user and nt group id to be prefixed with "domain:". Since we do not support domains anymore, I removed that code. Platforms tested: RHEL4 Flag Day: no Doc impact: Yes, but I believe David is changing those docs QA impact: need to test dsgw NT functionality New Tests integrated into TET: none
commit 4350443d0b117914762479b92272bc67a3e62a05 Author: Rich Megginson <[email protected]> Date: Fri May 20 15:52:44 2005 +0000 Bug(s) fixed: 158235 Bug Description: Phonebook/gateway: Object class violation - missing attribute "ntUserDomainId" required by object class "ntGroup" Reviewed by: David (Thanks!) Fix Description: 1) Change all places that use ntgroupdomainid to use ntuserdomainid instead 2) Get rid of support for NT domains. There were many places in the code that expected the nt user and nt group id to be prefixed with "domain:". Since we do not support domains anymore, I removed that code. Platforms tested: RHEL4 Flag Day: no Doc impact: Yes, but I believe David is changing those docs QA impact: need to test dsgw NT functionality New Tests integrated into TET: none diff --git a/ldap/clients/dsgw/config/display-ntgroup.html b/ldap/clients/dsgw/config/display-ntgroup.html index cbf6f782c..ef02876d8 100644 --- a/ldap/clients/dsgw/config/display-ntgroup.html +++ b/ldap/clients/dsgw/config/display-ntgroup.html @@ -156,9 +156,9 @@ New NT Group - </TD> <TD NOWRAP> <!-- IF "!Adding" --> -<!-- DS_ATTRIBUTE "attr=ntGroupDomainId" "syntax=ntgroupname" "cols=>16" "options=readonly" "defaultvalue=none" --> +<!-- DS_ATTRIBUTE "attr=ntUserDomainId" "syntax=ntgroupname" "cols=>16" "options=readonly" "defaultvalue=none" --> <!-- ELSE // Adding --> -<!-- DS_ATTRIBUTE "attr=ntGroupDomainId" "syntax=ntgroupname" "cols=>16" --> +<!-- DS_ATTRIBUTE "attr=ntUserDomainId" "syntax=ntgroupname" "cols=>16" --> <!-- ENDIF // Adding --> </TD></TR> @@ -180,20 +180,6 @@ New NT Group - <!-- ENDIF // Adding --> </TD></TR> -<TR> -<TD NOWRAP -<!-- IF "Displaying" --> - class="bold" -<!-- ENDIF --> ->NT Group Domain: -<!-- IF "!Displaying" --> -<B>*</B> -<!-- ENDIF --> -</TD> -<TD NOWRAP> -<!-- DS_ATTRIBUTE "attr=ntGroupDomainId" "syntax=ntdomain" "cols=>16" --> -</TD></TR> - <TR> <TD NOWRAP <!-- IF "Displaying" --> diff --git a/ldap/clients/dsgw/config/display-ntperson.html b/ldap/clients/dsgw/config/display-ntperson.html index ea112ebf1..a8ec9a4a4 100644 --- a/ldap/clients/dsgw/config/display-ntperson.html +++ b/ldap/clients/dsgw/config/display-ntperson.html @@ -330,7 +330,7 @@ showAimIcon(); <TABLE CELLSPACING="2" BGCOLOR=#FFFFFF WIDTH=95%> <TR> -<TH COLSPAN=4 align=left> +<TH COLSPAN=2 align=left> Windows NT Account Information</TH> </TR> @@ -344,35 +344,24 @@ Windows NT Account Information</TH> <B>*</B> <!-- ENDIF --> </TD> -<TD VALIGN="TOP" NOWRAP> +<TD VALIGN="TOP" ALIGN="LEFT" NOWRAP> <!-- IF "!Adding" --> <!-- DS_ATTRIBUTE "attr=nTUserDomainId" "syntax=ntuserid" "cols=>16" "options=readonly" --> <!-- ENDIF // Adding --> <!-- IF "Adding" --> <!-- DS_ATTRIBUTE "attr=nTUserDomainId" "syntax=ntuserid" "cols=>16" --> <!-- ENDIF // Adding --> -</TD> -<TD VALIGN="TOP" NOWRAP -<!-- IF "Displaying" --> - class="bold" -<!-- ENDIF --> ->NT Domain Name: -<!-- IF "!Displaying" --> -<B>*</B> -<!-- ENDIF --> -</TD><TD VALIGN="TOP" NOWRAP> -<!-- DS_ATTRIBUTE "attr=nTUserDomainId" "syntax=ntdomain" "cols=>16" --> </TD></TR> <INPUT TYPE="hidden" NAME="desc_uid" VALUE="user id"> <!-- PCONTEXT --> <TR> -<TD VALIGN="TOP" COLSPAN=2 NOWRAP +<TD VALIGN="TOP" NOWRAP <!-- IF "Displaying" --> class="bold" <!-- ENDIF --> >Delete NT Account if Person deleted:</TD> -<TD VALIGN="TOP" COLSPAN=2 NOWRAP> +<TD VALIGN="TOP" ALIGN="LEFT" NOWRAP> <!-- DS_ATTRIBUTE "syntax=bool" "type=radio" "true=Yes" "false=No" "defaultvalue=FALSE" "attr=nTUserDeleteAccount" --> </TD></TR> diff --git a/ldap/clients/dsgw/config/dsgwfilter.conf b/ldap/clients/dsgw/config/dsgwfilter.conf index e62ed85d3..fa9bd21a1 100644 --- a/ldap/clients/dsgw/config/dsgwfilter.conf +++ b/ldap/clients/dsgw/config/dsgwfilter.conf @@ -112,8 +112,7 @@ ".*" ". _" "(cn=%v1-))" "name is" "(cn=*%v1-*))" "name contains" "(cn~=%v1-))" "name sounds like" - "(ntgroupdomainid=%v:*))" "NT Domain name is" - "(ntgroupdomainid=*:%v))" "NT Group is" + "(ntuserdomainid=%v))" "NT Group is" "dsgw-organizations" "=" " " "(%v))" "LDAP filter is" @@ -179,8 +178,7 @@ ".*" ". " "(|(cn=%v1)(sn=%v1)))" "name is" "(ntuserlogonserver=%v))" "NT logon server is" - "(ntuserdomainid=%v:*))" "NT Domain name is" - "(ntuserdomainid=*:%v))" "NT username is" + "(ntuserdomainid=%v))" "NT username is" "(|(cn=*%v1*)(sn=*%v1*)(cn~=%v1)(sn~=%v1)))" "name sounds like or contains" # Do not remove this line, or place any directives after it. diff --git a/ldap/clients/dsgw/config/dsgwsearchprefs.conf b/ldap/clients/dsgw/config/dsgwsearchprefs.conf index 6321a34a0..57a8811d3 100644 --- a/ldap/clients/dsgw/config/dsgwsearchprefs.conf +++ b/ldap/clients/dsgw/config/dsgwsearchprefs.conf @@ -100,7 +100,6 @@ subtree "user id" "uid" 111111 "" "" "title" title 111111 "" "" "NT username" "ntuserdomainid" 110000 "" "" -"NT domain" "ntuserdomainid" 101000 "" "" "NT logon server" "ntuserlogonserver" 111111 "" "" END "is" "(%a=%v))" @@ -142,8 +141,7 @@ not-used-by-dsgw not-used-by-dsgw subtree "name" cn 111111 "" "" -"NT groupname" "ntgroupdomainid" 110000 "" "" -"NT domain" "ntgroupdomainid" 101000 "" "" +"NT groupname" "ntuserdomainid" 110000 "" "" "description" description 111111 "" "" "owner (DN)" "owner" 000011 "owner" "Owner" "member (DN)" "uniquemember" 000011 "" "" diff --git a/ldap/clients/dsgw/config/list-NT-Groups.html b/ldap/clients/dsgw/config/list-NT-Groups.html index 2631a000e..19c5d102c 100644 --- a/ldap/clients/dsgw/config/list-NT-Groups.html +++ b/ldap/clients/dsgw/config/list-NT-Groups.html @@ -59,9 +59,6 @@ <td class="boldbig"> LDAP Group Name </td> - <td class="boldbig"> - NT Domain Name - </td> <td class="boldbig"> NT Group Name </td> @@ -75,12 +72,9 @@ <tr valign="top" bgcolor="#FFFFFF"> <td > <!-- DS_ATTRIBUTE "attr=dn" "syntax=dn" --> - </td> - <td > -<!-- DS_ATTRIBUTE "attr=ntgroupdomainid" "syntax=ntdomain" --> </td> <td> -<!-- DS_ATTRIBUTE "attr=ntgroupdomainid" "syntax=ntgroupname" --> +<!-- DS_ATTRIBUTE "attr=ntuserdomainid" "syntax=ntgroupname" --> </td> <td > <!-- DS_ATTRIBUTE "attr=description" --> diff --git a/ldap/clients/dsgw/config/list-NT-People.html b/ldap/clients/dsgw/config/list-NT-People.html index 16e416b7d..c2f63f8de 100644 --- a/ldap/clients/dsgw/config/list-NT-People.html +++ b/ldap/clients/dsgw/config/list-NT-People.html @@ -92,9 +92,6 @@ document.write('<a href=\"aim:goim?Screenname=' + aimID.replace(/ /,"+") + '\">< <tr valign="top" bgcolor="#FFFFFF"> <td > <!-- DS_ATTRIBUTE "attr=dn" "syntax=dn" "hrefextra=onMouseOver=%22%0Awindow.status='Click here to view this entry in detail'; return true%22" --> - </td> - <td > -<!-- DS_ATTRIBUTE "attr=ntuserdomainid" "syntax=ntdomain" --> </td> <td> <!-- DS_ATTRIBUTE "attr=ntuserdomainid" "syntax=ntuserid" --> diff --git a/ldap/clients/dsgw/domodify.c b/ldap/clients/dsgw/domodify.c index 64daac864..0d935f01c 100644 --- a/ldap/clients/dsgw/domodify.c +++ b/ldap/clients/dsgw/domodify.c @@ -62,10 +62,7 @@ static int starts_with( char *s, char *startswith ); static char **post2multilinevals( char *postedval ); static char **post2vals( char *postedval ); static int require_oldpasswd( char *modifydn ); -static char *dsgw_processdomainid( LDAP *ld, char *dn, char *attr, char *val, int len); static int value_is_unique( LDAP *ld, char *dn, char *attr, char *value ); -static LDAPDomainIdStatus -dsgw_checkdomain_uniqueness( LDAP *ld, char *attr, char *val, int len); static int verbose = 0; static int quiet = 0; static int display_results_inline = 0; @@ -417,20 +414,14 @@ entry_modify_or_add( LDAP *ld, char *dn, int add, int *pwdchangedp ) { int lderr, i, j, opoffset, modop, mls, unique, unchanged_count; char *varname, *varvalue, *retval, *attr, *p, **vals, **unchanged_attrs; - char *userid = NULL, *oc_ntuser = NULL; - char userdomainid[512]; - - char *groupname = NULL; - char groupdomainid[512]; + char *ntuserid = NULL; LDAPMod **pmods; int msgid; LDAPMessage *res = NULL; char *errmsg = NULL; - - memset( userdomainid, 0, sizeof( userdomainid )); - memset( groupdomainid, 0, sizeof( groupdomainid )); + int isNtUser = 0; pmods = NULL; unchanged_attrs = NULL; @@ -476,26 +467,14 @@ entry_modify_or_add( LDAP *ld, char *dn, int add, int *pwdchangedp ) if ( starts_with( varname, "add_" )) { modop = LDAP_MOD_ADD; opoffset = 4; + attr = varname + opoffset; + if (!isNtUser && (strcasecmp(DSGW_OC_NTUSER, attr) == 0)) { + isNtUser = 1; + } } else if ( starts_with( varname, "replace_" )) { modop = LDAP_MOD_REPLACE; opoffset = 8; attr = varname + opoffset; - if( strcasecmp( DSGW_ATTRTYPE_NTUSERDOMAINID, attr) == 0) { - if( varvalue) { - if( !userid ) - userid = strdup( varvalue ); - else - strcpy( userdomainid, varvalue ); - } - } - if( strcasecmp( DSGW_ATTRTYPE_NTGROUPDOMAINID, attr) == 0) { - if( varvalue) { - if( !groupname ) - groupname = strdup( varvalue ); - else - strcpy( groupdomainid, varvalue ); - } - } } else if ( starts_with( varname, "delete_" )) { modop = LDAP_MOD_DELETE; opoffset = 7; @@ -516,22 +495,6 @@ entry_modify_or_add( LDAP *ld, char *dn, int add, int *pwdchangedp ) remove_modifyops( pmods, attr ); } } - } else if ( starts_with( varname, "replace_" )) { - modop = LDAP_MOD_REPLACE; - opoffset = 8; - attr = varname + opoffset; - if( strcasecmp( DSGW_ATTRTYPE_USERID, attr) == 0) - if( varvalue) - userid = strdup( varvalue ); - if( strcasecmp( DSGW_ATTRTYPE_NTUSERDOMAINID, attr) == 0) - if( varvalue) - strcpy( userdomainid, varvalue ); - if( strcasecmp( DSGW_ATTRTYPE_NTGROUPNAME, attr) == 0) - if( varvalue) - groupname = strdup( varvalue ); - if( strcasecmp( DSGW_ATTRTYPE_NTGROUPDOMAINID, attr) == 0) - if( varvalue) - strcpy( groupdomainid, varvalue ); } if ( opoffset >= 0 ) { @@ -576,72 +539,12 @@ entry_modify_or_add( LDAP *ld, char *dn, int add, int *pwdchangedp ) LDAP_SUCCESS ) { return( lderr ); } - if( strcasecmp( DSGW_OC_NTUSER, varvalue) == 0 && - modop == LDAP_MOD_ADD ) { - oc_ntuser = strdup( vals[ j ] ); - } - - if( strcasecmp( DSGW_ATTRTYPE_NTUSERDOMAINID, attr) == 0) { - if( modop == LDAP_MOD_ADD ) { - if( userid == NULL ) { - userid = strdup( vals[ j ] ); - break; - } else { - memset( userdomainid, 0, sizeof( userdomainid )); - PR_snprintf( userdomainid, 512, "%s%c%s", - vals[ j ], DSGW_NTDOMAINID_SEP, userid ); - if( dsgw_checkdomain_uniqueness( ld, attr, - userdomainid, strlen( userdomainid ) ) != - LDAPDomainIdStatus_Unique) { - dsgw_error( DSGW_ERR_DOMAINID_NOTUNIQUE, - NULL, 0, 0, NULL ); - return(LDAP_PARAM_ERROR); - } else { - /* don't free here because this is freed elsewhere */ - /* - free( vals[ j ] ); - */ - vals[ j ] = strdup( userdomainid ); - } - } - } else { - if(( retval = dsgw_processdomainid( ld, dn, attr, - vals[ j ], strlen( vals[ j ] ))) != 0) { - vals[ j ] = retval; - } - } - } - if( strcasecmp( DSGW_ATTRTYPE_NTGROUPDOMAINID, attr) == 0) { - if( modop == LDAP_MOD_ADD ) { - if( groupname == NULL ) { - groupname = strdup( vals[ j ] ); - break; - } else { - memset( groupdomainid, 0, sizeof( groupdomainid )); - PR_snprintf( groupdomainid, 512, "%s%c%s", - vals[ j ], DSGW_NTDOMAINID_SEP, groupname ); - if( dsgw_checkdomain_uniqueness( ld, attr, - groupdomainid, strlen( groupdomainid ) ) != - LDAPDomainIdStatus_Unique) { - dsgw_error( DSGW_ERR_DOMAINID_NOTUNIQUE, - NULL, 0, 0, NULL ); - return(LDAP_PARAM_ERROR); - } else { - /* don't free here because this is freed elsewhere */ - /* - free( vals[ j ] ); - */ - vals[ j ] = strdup( groupdomainid ); - } - } - } else { - if(( retval = dsgw_processdomainid( ld, dn, attr, - vals[ j ], strlen( vals[ j ] ))) != 0) { - vals[ j ] = retval; - } - } + if( isNtUser && (strcasecmp( DSGW_ATTRTYPE_NTUSERDOMAINID, attr) == 0)) { + if( !ntuserid ) { + ntuserid = strdup( vals[ j ] ); } + } addmodifyop( &pmods, modop, attr, vals[ j ], strlen( vals[ j ] )); } @@ -656,19 +559,14 @@ entry_modify_or_add( LDAP *ld, char *dn, int add, int *pwdchangedp ) free( varname ); } - if( oc_ntuser != NULL && - ((strlen( userdomainid ) == 0) || userid == NULL )) { - dsgw_error( DSGW_ERR_USERID_DOMAINID_REQUIRED, NULL, 0, 0, NULL ); - return(LDAP_PARAM_ERROR); - } - - if( strlen( userdomainid ) > 0 && userid == NULL ) { + /* if the admin is adding an NT person, there must be an ntuserid */ + if( (isNtUser) && (ntuserid == NULL) ) { dsgw_error( DSGW_ERR_USERID_REQUIRED, NULL, 0, 0, NULL ); return(LDAP_PARAM_ERROR); } - if( strlen( userdomainid ) > 0 && userid && - strlen( userid ) > MAX_NTUSERID_LEN) { + /* if an ntuserid is being added, it must be the correct length */ + if( (isNtUser) && ntuserid && (strlen( ntuserid ) > MAX_NTUSERID_LEN)) { dsgw_error( DSGW_ERR_USERID_MAXLEN_EXCEEDED, NULL, 0, 0, NULL ); return(LDAP_PARAM_ERROR); } @@ -1168,115 +1066,3 @@ value_is_unique( LDAP *ld, char *dn, char *attr, char *value ) return( rc ); } - - -/* - * Check that the domain:userid is unique in the directory. - */ -static LDAPDomainIdStatus -dsgw_checkdomain_uniqueness( LDAP *ld, char *attr, char *val, int len) -{ - int rc, count; - LDAPMessage *msgp = NULL; - char filter[256]; - - if( val == NULL ) - return LDAPDomainIdStatus_NullId; - - if( strcasecmp( attr, DSGW_ATTRTYPE_NTUSERDOMAINID ) == 0 ) { - PR_snprintf( filter, 256, "%s=%s", DSGW_ATTRTYPE_NTUSERDOMAINID, val ); - } else if ( strcasecmp( attr, DSGW_ATTRTYPE_NTGROUPDOMAINID ) == 0 ) { - PR_snprintf( filter, 256, "%s=%s", DSGW_ATTRTYPE_NTGROUPDOMAINID, val ); - } else { - return LDAPDomainIdStatus_NullAttr; - } - - if (( rc = ldap_search_s( ld, gc->gc_ldapsearchbase, LDAP_SCOPE_SUBTREE, - filter, NULL, 0, &msgp )) == LDAP_SUCCESS) { - count = (msgp == NULL) ? 0 : ldap_count_entries( ld, msgp ); - if ( count > 0 ) { - return LDAPDomainIdStatus_Nonunique; - } else { - return LDAPDomainIdStatus_Unique; - } - } else { - return LDAPDomainIdStatus_Nonunique; - } -} - - -/* - * Add the current value of uid in the entry to the ntdomain id before - * further processing of the domain id. - */ -static char * -dsgw_processdomainid( LDAP *ld, char *dn, char *attr, char *val, int len) -{ - int rc, count; - LDAPMessage *msgp = NULL; - LDAPMessage *entry; - char **attrlist, *attrs[ 2 ]; - char *value, *newval; - char *pch, **vals; - - if( strcasecmp( attr, DSGW_ATTRTYPE_NTUSERDOMAINID ) != 0 && - strcasecmp( attr, DSGW_ATTRTYPE_NTGROUPDOMAINID ) != 0 ) - return( NULL ); - - attrs[ 0 ] = NULL; - attrs[ 1 ] = NULL; - attrlist = attrs; - - if(( rc = ldap_search_s( ld, dn, LDAP_SCOPE_BASE, "(objectclass=*)", attrlist, - 0, &msgp )) != LDAP_SUCCESS && rc != LDAP_NO_SUCH_OBJECT) - { - return( NULL ); - } - - count = (msgp == NULL) ? 0 : ldap_count_entries( ld, msgp ); - - if( count > 0 ) - { - entry = ldap_first_entry( ld, msgp ); - if( entry ) - { - - if(( vals = ldap_get_values( ld, entry, - strcasecmp( attr, DSGW_ATTRTYPE_NTUSERDOMAINID )? - DSGW_ATTRTYPE_NTGROUPDOMAINID : - DSGW_ATTRTYPE_NTUSERDOMAINID )) != NULL) - { - if( vals[0] != NULL ) - { - value = dsgw_ch_strdup( vals[0] ); - newval = dsgw_ch_malloc( len + strlen( value ) +1 ); - strcpy( newval, val ); - pch = strchr( value, DSGW_NTDOMAINID_SEP ); - if( pch ) - { - strcat( newval, pch ); - return( newval ); - } - } - } - } - } - return NULL; -} - - - - - - - - - - - - - - - - - diff --git a/ldap/clients/dsgw/dsgw.h b/ldap/clients/dsgw/dsgw.h index 186a93446..a35d2fb73 100644 --- a/ldap/clients/dsgw/dsgw.h +++ b/ldap/clients/dsgw/dsgw.h @@ -172,8 +172,6 @@ extern char *countri; /* The language chosen by libsi18n. */ #define DSGW_OC_NTUSER "ntuser" -#define DSGW_ATTRTYPE_NTGROUPDOMAINID "nTGroupDomainId" -#define DSGW_ATTRTYPE_NTGROUPNAME "nTGroupName" #define DSGW_ATTRTYPE_AIMSTATUSTEXT "nsaimstatustext" #if defined( XP_WIN32 ) diff --git a/ldap/clients/dsgw/entrydisplay.c b/ldap/clients/dsgw/entrydisplay.c index 33b62e11a..3a1bbb295 100644 --- a/ldap/clients/dsgw/entrydisplay.c +++ b/ldap/clients/dsgw/entrydisplay.c @@ -273,7 +273,6 @@ struct attr_handler attrhandlers[] = { { "ces", str_display, str_edit, CASE_EXACT }, { "bool", bool_display, bool_edit, CASE_INSENSITIVE }, { "time", time_display, str_edit, CASE_INSENSITIVE }, - { "ntdomain", ntdomain_display, str_edit, CASE_INSENSITIVE }, { "ntuserid", ntuserid_display, str_edit, CASE_INSENSITIVE }, { "ntgroupname", ntuserid_display, str_edit, CASE_INSENSITIVE }, { "binvalue", binvalue_display, str_edit, CASE_INSENSITIVE }, @@ -1381,22 +1380,9 @@ output_text_elements( int argc, char **argv, char *attr, char **vals, valcount = 0; } else { for ( valcount = 0; vals[ valcount ] != NULL; ++valcount ) { - char *syntax = get_arg_by_name( DSGW_ATTRARG_SYNTAX, argc, argv ); - if ( syntax && 0 == strcasecmp( syntax, "ntdomain" )) { - char *pch = (char *)strchr( vals[ valcount ], DSGW_NTDOMAINID_SEP ); - if( pch ) - *pch = (char )NULL; - } - if ( syntax && ( 0 == strcasecmp( syntax, "ntuserid" ) || 0 == strcasecmp( syntax, "ntgroupname") ) ) { - char *pch = (char *)strchr( vals[ valcount ], DSGW_NTDOMAINID_SEP ); - if( pch ) - { - pch++; - vals[ valcount] = pch; - } - } + /* just count vals */ + } } - } fields = numfields( argc, argv, valcount ); element_sizes( argc, argv, vals, valcount, NULL, &cols ); @@ -1732,13 +1718,11 @@ ntuserid_display( struct dsgw_attrdispinfo *adip ) { int i; - /* Write values with a break (<BR>) separating them, after ":" */ for ( i = 0; adip->adi_vals[ i ] != NULL; ++i ) { if ( !did_output_as_special( adip->adi_argc, adip->adi_argv, adip->adi_vals[ i ], adip->adi_vals[ i ] )) { - char *pch = strchr( adip->adi_vals[ i ], DSGW_NTDOMAINID_SEP ); + char *pch = adip->adi_vals[ i ]; if( pch ) { - pch++; if ((adip->adi_opts & DSGW_ATTROPT_QUOTED ) != 0 ) { dsgw_emits( "\"" );
0
53d0e17018d7a69bd30b2bc1415e2a72f0198e0a
389ds/389-ds-base
Issue 5299 - jemalloc 5.3 released Description: Bump jemalloc version to 5.3.0 https://github.com/jemalloc/jemalloc/releases/tag/5.3.0 Fixes: https://github.com/389ds/389-ds-base/issues/5299 Reviewed by: @droideck (Thanks!)
commit 53d0e17018d7a69bd30b2bc1415e2a72f0198e0a Author: Viktor Ashirov <[email protected]> Date: Tue May 17 09:12:53 2022 +0200 Issue 5299 - jemalloc 5.3 released Description: Bump jemalloc version to 5.3.0 https://github.com/jemalloc/jemalloc/releases/tag/5.3.0 Fixes: https://github.com/389ds/389-ds-base/issues/5299 Reviewed by: @droideck (Thanks!) diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index 7e91854b5..6d68a7303 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -4,7 +4,7 @@ %global bundle_jemalloc __BUNDLE_JEMALLOC__ %if %{bundle_jemalloc} %global jemalloc_name jemalloc -%global jemalloc_ver 5.2.1 +%global jemalloc_ver 5.3.0 %endif # This is used in certain builds to help us know if it has extra features.
0
73fdd3b8945a34cc3d386c697e4e99560ba7997a
389ds/389-ds-base
Bug 543080 - Bitwise plugin fails to return the exact matched entries for Bitwise search filter https://bugzilla.redhat.com/show_bug.cgi?id=543080 Resolves: bug 543080 Bug Description: Bitwise plugin fails to return the exact matched entries for Bitwise search filter Reviewed by: nhosoi (Thanks!) Branch: HEAD Fix Description: The Microsoft Windows AD bitwise filters do not work exactly like the usual bitwise AND (&) and OR (|) operators. For the AND case the matching rule is true only if all bits from the value given in the filter value match the value from the entry. For the OR case, the matching rule is true if any bits from the value given in the filter match the value from the entry. For the AND case, this means that even though (a & b) is True, if (a & b) != b, the matching rule will return False. For the OR case, this means that even though (a | b) is True, this may be because there are bits in a. But we only care about bits in a that are also in b. So we do (a & b) - this will return what we want, which is to return True if any of the bits in b are also in a. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no
commit 73fdd3b8945a34cc3d386c697e4e99560ba7997a Author: Rich Megginson <[email protected]> Date: Tue Jan 26 09:51:05 2010 -0700 Bug 543080 - Bitwise plugin fails to return the exact matched entries for Bitwise search filter https://bugzilla.redhat.com/show_bug.cgi?id=543080 Resolves: bug 543080 Bug Description: Bitwise plugin fails to return the exact matched entries for Bitwise search filter Reviewed by: nhosoi (Thanks!) Branch: HEAD Fix Description: The Microsoft Windows AD bitwise filters do not work exactly like the usual bitwise AND (&) and OR (|) operators. For the AND case the matching rule is true only if all bits from the value given in the filter value match the value from the entry. For the OR case, the matching rule is true if any bits from the value given in the filter match the value from the entry. For the AND case, this means that even though (a & b) is True, if (a & b) != b, the matching rule will return False. For the OR case, this means that even though (a | b) is True, this may be because there are bits in a. But we only care about bits in a that are also in b. So we do (a & b) - this will return what we want, which is to return True if any of the bits in b are also in a. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/servers/plugins/bitwise/bitwise.c b/ldap/servers/plugins/bitwise/bitwise.c index 7c88c93b2..01c05fd22 100644 --- a/ldap/servers/plugins/bitwise/bitwise.c +++ b/ldap/servers/plugins/bitwise/bitwise.c @@ -124,10 +124,24 @@ internal_bitwise_filter_match(void* obj, Slapi_Entry* entry, Slapi_Attr* attr, i rc = LDAP_CONSTRAINT_VIOLATION; } else { int result; + /* The Microsoft Windows AD bitwise operators do not work exactly + as the plain old C bitwise operators work. For the AND case + the matching rule is true only if all bits from the given value + match the value from the entry. For the OR case, the matching + rule is true if any bits from the given value match the value + from the entry. + For the AND case, this means that even though (a & b) is True, + if (a & b) != b, the matching rule will return False. + For the OR case, this means that even though (a | b) is True, + this may be because there are bits in a. But we only care + about bits in a that are also in b. So we do (a & b) - this + will return what we want, which is to return True if any of + the bits in b are also in a. + */ if (op == BITWISE_OP_AND) { - result = (a & b); + result = ((a & b) == b); /* all the bits in the given value are found in the value from the entry */ } else if (op == BITWISE_OP_OR) { - result = (a | b); + result = (a & b); /* any of the bits in b are also in a */ } if (result) { rc = 0;
0
5729040f8032b537a00dfcc832282084d89460ea
389ds/389-ds-base
Bug 201275 - Make SASL EXTERNAL bind obey account lock This patch makes SASL EXTERNAL binds obey the account lock. The previous code was allowing the bind through even if the account was locked. This patch was contributed by Ulf Weltman of Hewlett Packard.
commit 5729040f8032b537a00dfcc832282084d89460ea Author: Nathan Kinder <[email protected]> Date: Wed Dec 2 14:03:47 2009 -0800 Bug 201275 - Make SASL EXTERNAL bind obey account lock This patch makes SASL EXTERNAL binds obey the account lock. The previous code was allowing the bind through even if the account was locked. This patch was contributed by Ulf Weltman of Hewlett Packard. diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c index abb027a6b..79d8c5cfb 100644 --- a/ldap/servers/slapd/bind.c +++ b/ldap/servers/slapd/bind.c @@ -39,6 +39,7 @@ * Contributors: * Hewlett-Packard Development Company, L.P. * Bugfix for bug #193297 + * Bugfix for bug #201275 * * END COPYRIGHT BLOCK **/ @@ -424,6 +425,17 @@ do_bind( Slapi_PBlock *pb ) goto free_and_return; } + if (!isroot ) { + /* check if the account is locked */ + bind_target_entry = get_entry(pb, pb->pb_conn->c_external_dn); + if ( bind_target_entry != NULL && check_account_lock(pb, bind_target_entry, + pw_response_requested, 0 /*not account_inactivation_only*/ ) == 1) { + /* call postop plugins */ + plugin_call_plugins( pb, SLAPI_PLUGIN_POST_BIND_FN ); + goto free_and_return; + } + } + /* * copy external credentials into connection structure */
0
ef3d90459a0f43c8e3692cb7ea2cfafe73eb3ba9
389ds/389-ds-base
move the out pointer back if continuation lines were removed when putting ldif data with the no wrap option, if we removed some continuation lines, we have to move the output data pointer back since the continuation line markers are removed in place
commit ef3d90459a0f43c8e3692cb7ea2cfafe73eb3ba9 Author: Rich Megginson <[email protected]> Date: Tue Aug 24 10:16:36 2010 -0600 move the out pointer back if continuation lines were removed when putting ldif data with the no wrap option, if we removed some continuation lines, we have to move the output data pointer back since the continuation line markers are removed in place diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c index d411d777a..d8fe13dea 100644 --- a/ldap/servers/slapd/ldaputil.c +++ b/ldap/servers/slapd/ldaputil.c @@ -390,6 +390,7 @@ slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const cha } *dest++ = *src; } + *out = dest; /* move 'out' back if we removed some continuation lines */ } #else ldif_put_type_and_value_with_options( out, (char *)t, (char *)val, vlen, options );
0
b43145218dccc8c9c16ecadad80f94bf58c73d57
389ds/389-ds-base
Ticket #47463 - IDL-style can become mismatched during partial restoration Description by telackey: When doing a partial/FRI restoration the database files are copied key-by-key. This is necessary to reset the LSNs so the restored files can merge into the existing DB environment (cf. dblayer_copy_ file_resetlsns()) in a recoverable way. However, dblayer_copy_file_keybykey() does not set the comparison function before calling DB->put(), which means that the restored files will not necessarily be using the proper function. While all the keys are technically present, indexed searches can still fail to return relevant results because the key order is significant when intersecting the results with the other indices. Note: The bug was reported and the patch was provided by telackey. (Thank you, Thomas!) Additional fix by nhosoi: The entryrdn index uses its special dup compare function. The dup compare function is set when the restoring index file is entryrdn. https://fedorahosted.org/389/ticket/47463 Reviewed by rmeggins (Thank you, Rich!)
commit b43145218dccc8c9c16ecadad80f94bf58c73d57 Author: Noriko Hosoi <[email protected]> Date: Fri Sep 27 17:58:03 2013 -0700 Ticket #47463 - IDL-style can become mismatched during partial restoration Description by telackey: When doing a partial/FRI restoration the database files are copied key-by-key. This is necessary to reset the LSNs so the restored files can merge into the existing DB environment (cf. dblayer_copy_ file_resetlsns()) in a recoverable way. However, dblayer_copy_file_keybykey() does not set the comparison function before calling DB->put(), which means that the restored files will not necessarily be using the proper function. While all the keys are technically present, indexed searches can still fail to return relevant results because the key order is significant when intersecting the results with the other indices. Note: The bug was reported and the patch was provided by telackey. (Thank you, Thomas!) Additional fix by nhosoi: The entryrdn index uses its special dup compare function. The dup compare function is set when the restoring index file is entryrdn. https://fedorahosted.org/389/ticket/47463 Reviewed by rmeggins (Thank you, Rich!) diff --git a/ldap/servers/slapd/back-ldbm/dbhelp.c b/ldap/servers/slapd/back-ldbm/dbhelp.c index 116583140..29c024718 100644 --- a/ldap/servers/slapd/back-ldbm/dbhelp.c +++ b/ldap/servers/slapd/back-ldbm/dbhelp.c @@ -49,7 +49,13 @@ #include "back-ldbm.h" #include "dblayer.h" -static int dblayer_copy_file_keybykey(DB_ENV *env, char *source_file_name, char *destination_file_name, int overwrite, dblayer_private *priv) +static int +dblayer_copy_file_keybykey(DB_ENV *env, + char *source_file_name, + char *destination_file_name, + int overwrite, + dblayer_private *priv, + ldbm_instance *inst) { int retval = 0; int retval_cleanup = 0; @@ -62,6 +68,7 @@ static int dblayer_copy_file_keybykey(DB_ENV *env, char *source_file_name, char int cursor_flag = 0; int finished = 0; int mode = 0; + char *p = NULL; LDAPDebug( LDAP_DEBUG_TRACE, "=> dblayer_copy_file_keybykey\n", 0, 0, 0 ); @@ -119,6 +126,40 @@ static int dblayer_copy_file_keybykey(DB_ENV *env, char *source_file_name, char LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_keybykey, set_pagesize error %d: %s\n", retval, db_strerror(retval), 0); goto error; } + + /* TEL 20130412: Make sure to set the dup comparison function if needed. + * We key our decision off of the presence of new IDL and dup flags on + * the source database. This is similar dblayer_open_file, except that + * we don't have the attribute info index mask for VLV. That should be OK + * since the DB_DUP and DB_DUPSORT flags wouldn't have been toggled on + * unless they passed the check on the source. + */ + /* Entryrdn index has its own dup compare function */ + if ((p = PL_strcasestr(source_file_name, LDBM_ENTRYRDN_STR)) && + (*(p + sizeof(LDBM_ENTRYRDN_STR) - 1) == '.')) { + /* entryrdn.db */ + struct attrinfo *ai = NULL; + ainfo_get(inst->inst_be, LDBM_ENTRYRDN_STR, &ai); + if (ai->ai_dup_cmp_fn) { + /* If set, use the special dup compare callback */ + retval = destination_file->set_dup_compare(destination_file, ai->ai_dup_cmp_fn); + if (retval) { + LDAPDebug2Args(LDAP_DEBUG_ANY, + "dblayer_copy_file_keybykey(entryrdn), set_dup_compare error %d: %s\n", + retval, db_strerror(retval)); + goto error; + } + } + } else if (idl_get_idl_new() && (dbflags & DB_DUP) && (dbflags & DB_DUPSORT)) { + retval = destination_file->set_dup_compare(destination_file, idl_new_compare_dups); + if (retval) { + LDAPDebug2Args(LDAP_DEBUG_ANY, + "dblayer_copy_file_keybykey, set_dup_compare error %d: %s\n", + retval, db_strerror(retval)); + goto error; + } + } + retval = (destination_file->open)(destination_file, NULL, destination_file_name, NULL, dbtype, DB_CREATE | DB_EXCL, mode); if (retval) { LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_keybykey, Open error %d: %s\n", retval, db_strerror(retval), 0); @@ -190,7 +231,13 @@ error: return retval; } -int dblayer_copy_file_resetlsns(char *home_dir ,char *source_file_name, char *destination_file_name, int overwrite, dblayer_private *priv) +int +dblayer_copy_file_resetlsns(char *home_dir, + char *source_file_name, + char *destination_file_name, + int overwrite, + dblayer_private *priv, + ldbm_instance *inst) { int retval = 0; DB_ENV *env = NULL; @@ -205,7 +252,7 @@ int dblayer_copy_file_resetlsns(char *home_dir ,char *source_file_name, char *de goto out; } /* Do the copy */ - retval = dblayer_copy_file_keybykey(env, source_file_name, destination_file_name, overwrite, priv); + retval = dblayer_copy_file_keybykey(env, source_file_name, destination_file_name, overwrite, priv, inst); if (retval) { LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_resetlsns: Copy not completed successfully.", 0, 0, 0); } diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index 013d1c0b2..4102d3c78 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -3617,17 +3617,17 @@ dblayer_txn_begin_ext(struct ldbminfo *li, back_txnid parent_txn, back_txn *txn, { /* this txn is now our current transaction for current operations and new parent for any nested transactions created */ - if (use_lock && log_flush_thread) { - int txn_id = new_txn.back_txn_txn->id(new_txn.back_txn_txn); - PR_Lock(sync_txn_log_flush); - txn_in_progress_count++; - LDAPDebug(LDAP_DEBUG_BACKLDBM, "txn_begin: batchcount: %d, txn_in_progress: %d, curr_txn: %x\n", trans_batch_count, txn_in_progress_count, txn_id); - PR_Unlock(sync_txn_log_flush); - } - dblayer_push_pvt_txn(&new_txn); - if (txn) { - txn->back_txn_txn = new_txn.back_txn_txn; - } + if (use_lock && log_flush_thread) { + int txn_id = new_txn.back_txn_txn->id(new_txn.back_txn_txn); + PR_Lock(sync_txn_log_flush); + txn_in_progress_count++; + LDAPDebug(LDAP_DEBUG_BACKLDBM, "txn_begin: batchcount: %d, txn_in_progress: %d, curr_txn: %x\n", trans_batch_count, txn_in_progress_count, txn_id); + PR_Unlock(sync_txn_log_flush); + } + dblayer_push_pvt_txn(&new_txn); + if (txn) { + txn->back_txn_txn = new_txn.back_txn_txn; + } } } else { @@ -3655,16 +3655,16 @@ dblayer_txn_begin(backend *be, back_txnid parent_txn, back_txn *txn) struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private; int rc = 0; if (DBLOCK_INSIDE_TXN(li)) { - rc = dblayer_txn_begin_ext(li,parent_txn,txn,PR_TRUE); - if (!rc && SERIALLOCK(li)) { + rc = dblayer_txn_begin_ext(li,parent_txn,txn,PR_TRUE); + if (!rc && SERIALLOCK(li)) { dblayer_lock_backend(be); - } + } } else { - if (SERIALLOCK(li)) { + if (SERIALLOCK(li)) { dblayer_lock_backend(be); - } - rc = dblayer_txn_begin_ext(li,parent_txn,txn,PR_TRUE); - if (rc && SERIALLOCK(li)) { + } + rc = dblayer_txn_begin_ext(li,parent_txn,txn,PR_TRUE); + if (rc && SERIALLOCK(li)) { dblayer_unlock_backend(be); } } @@ -3678,8 +3678,8 @@ int dblayer_txn_commit_ext(struct ldbminfo *li, back_txn *txn, PRBool use_lock) dblayer_private *priv = NULL; DB_TXN *db_txn = NULL; back_txn *cur_txn = NULL; - int txn_id = 0; - int txn_batch_slot = 0; + int txn_id = 0; + int txn_batch_slot = 0; PR_ASSERT(NULL != li); @@ -3783,15 +3783,15 @@ dblayer_txn_commit(backend *be, back_txn *txn) struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private; int rc; if (DBLOCK_INSIDE_TXN(li)) { - if (SERIALLOCK(li)) { - dblayer_unlock_backend(be); + if (SERIALLOCK(li)) { + dblayer_unlock_backend(be); } - rc = dblayer_txn_commit_ext(li,txn,PR_TRUE); + rc = dblayer_txn_commit_ext(li,txn,PR_TRUE); } else { - rc = dblayer_txn_commit_ext(li,txn,PR_TRUE); - if (SERIALLOCK(li)) { + rc = dblayer_txn_commit_ext(li,txn,PR_TRUE); + if (SERIALLOCK(li)) { dblayer_unlock_backend(be); - } + } } return rc; } @@ -3823,13 +3823,13 @@ int dblayer_txn_abort_ext(struct ldbminfo *li, back_txn *txn, PRBool use_lock) priv->dblayer_env && priv->dblayer_enable_transactions) { - int txn_id = db_txn->id(db_txn); - if ( use_lock && log_flush_thread) { - PR_Lock(sync_txn_log_flush); - txn_in_progress_count--; - PR_Unlock(sync_txn_log_flush); - LDAPDebug(LDAP_DEBUG_BACKLDBM, "txn_abort : batchcount: %d, txn_in_progress: %d, curr_txn: %x\n", trans_batch_count, txn_in_progress_count, txn_id); - } + int txn_id = db_txn->id(db_txn); + if ( use_lock && log_flush_thread) { + PR_Lock(sync_txn_log_flush); + txn_in_progress_count--; + PR_Unlock(sync_txn_log_flush); + LDAPDebug(LDAP_DEBUG_BACKLDBM, "txn_abort : batchcount: %d, txn_in_progress: %d, curr_txn: %x\n", trans_batch_count, txn_in_progress_count, txn_id); + } return_value = TXN_ABORT(db_txn); /* if we were given a transaction, and it is the same as the current transaction in progress, pop it off the stack @@ -3874,14 +3874,14 @@ dblayer_txn_abort(backend *be, back_txn *txn) int rc; if (DBLOCK_INSIDE_TXN(li)) { if (SERIALLOCK(li)) { - dblayer_unlock_backend(be); - } - rc = dblayer_txn_abort_ext(li, txn, PR_TRUE); + dblayer_unlock_backend(be); + } + rc = dblayer_txn_abort_ext(li, txn, PR_TRUE); } else { - rc = dblayer_txn_abort_ext(li, txn, PR_TRUE); + rc = dblayer_txn_abort_ext(li, txn, PR_TRUE); if (SERIALLOCK(li)) { - dblayer_unlock_backend(be); - } + dblayer_unlock_backend(be); + } } return rc; } @@ -4567,9 +4567,9 @@ static int log_flush_threadmain(void *param) interval_flush = PR_MillisecondsToInterval(trans_batch_txn_min_sleep); interval_wait = PR_MillisecondsToInterval(trans_batch_txn_max_sleep); interval_def = PR_MillisecondsToInterval(300); /*used while no txn or txn batching */ - /* LK this is only needed if online change of - * of txn config is supported ??? - */ + /* LK this is only needed if online change of + * of txn config is supported ??? + */ while ((!priv->dblayer_stop_threads) && (log_flush_thread)){ if (priv->dblayer_enable_transactions){ if (trans_batch_limit > 0) { @@ -5932,6 +5932,7 @@ dblayer_copy_directory(struct ldbminfo *li, char inst_dir[MAXPATHLEN]; char sep; int suffix_len = 0; + ldbm_instance *inst = NULL; if (!src_dir || '\0' == *src_dir) { @@ -5955,6 +5956,14 @@ dblayer_copy_directory(struct ldbminfo *li, else relative_instance_name++; + inst = ldbm_instance_find_by_name(li, relative_instance_name); + if (NULL == inst) { + LDAPDebug(LDAP_DEBUG_ANY, "Backend instance \"%s\" does not exist; " + "Instance path %s could be invalid.\n", + relative_instance_name, src_dir, 0); + return return_value; + } + if (is_fullpath(src_dir)) { new_src_dir = src_dir; @@ -5962,15 +5971,6 @@ dblayer_copy_directory(struct ldbminfo *li, else { int len; - ldbm_instance *inst = - ldbm_instance_find_by_name(li, relative_instance_name); - if (NULL == inst) - { - LDAPDebug(LDAP_DEBUG_ANY, "Backend instance \"%s\" does not exist; " - "Instance path %s could be invalid.\n", - relative_instance_name, src_dir, 0); - return return_value; - } inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, inst_dir, MAXPATHLEN); @@ -6090,13 +6090,12 @@ dblayer_copy_directory(struct ldbminfo *li, /* If the file is a database file, and resetlsns is set, then we need to do a key by key copy */ /* PL_strcmp takes NULL arg */ if (resetlsns && - (PL_strcmp(LDBM_FILENAME_SUFFIX, strrchr(filename1, '.')) - == 0)) { + (PL_strcmp(LDBM_FILENAME_SUFFIX, strrchr(filename1, '.')) == 0)) { return_value = dblayer_copy_file_resetlsns(src_dir, filename1, filename2, - 0, priv); + 0, priv, inst); } else { return_value = dblayer_copyfile(filename1, filename2, - 0, priv->dblayer_file_mode); + 0, priv->dblayer_file_mode); } slapi_ch_free((void**)&filename1); slapi_ch_free((void**)&filename2); @@ -6819,6 +6818,7 @@ int dblayer_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task, char * PR_Lock(li->li_config_mutex); /* dblayer_home_directory is freed in dblayer_post_close. * li_directory needs to live beyond dblayer. */ + slapi_ch_free_string(&priv->dblayer_home_directory); priv->dblayer_home_directory = slapi_ch_strdup(li->li_directory); priv->dblayer_cachesize = li->li_dbcachesize; priv->dblayer_ncache = li->li_dbncache; diff --git a/ldap/servers/slapd/back-ldbm/dblayer.h b/ldap/servers/slapd/back-ldbm/dblayer.h index c382a9813..e1a178efc 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.h +++ b/ldap/servers/slapd/back-ldbm/dblayer.h @@ -202,7 +202,7 @@ int dblayer_make_private_simple_env(char *db_home_dir, DB_ENV **env); /* Copy a database file, preserving all its contents (used to reset the LSNs in the file in order to move * it from one transacted environment to another. */ -int dblayer_copy_file_resetlsns(char *home_dir, char *source_file_name, char *destination_file_name, int overwrite, dblayer_private *priv); +int dblayer_copy_file_resetlsns(char *home_dir, char *source_file_name, char *destination_file_name, int overwrite, dblayer_private *priv, ldbm_instance *inst); /* Turn on the various logging and debug options for DB */ void dblayer_set_env_debugging(DB_ENV *pEnv, dblayer_private *priv);
0
c8e821c11ec22c2b67cbaf0fa3f587778db223d9
389ds/389-ds-base
Bug 703703 - setup-ds-admin.pl asks for legal agreement to a non-existant file https://bugzilla.redhat.com/show_bug.cgi?id=703703 Resolves: bug 703703 Bug Description: setup-ds-admin.pl asks for legal agreement to a non-existant file Reviewed by: nkinder (Thanks!) Branch: master Fix Description: According to the Red Hat Legal department, we do not need to display or ask the user to accept the EULA any more. The EULA dialog and text has been removed. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: Yes - will need a slight amendment to the Install Guide.
commit c8e821c11ec22c2b67cbaf0fa3f587778db223d9 Author: Rich Megginson <[email protected]> Date: Mon Jun 20 13:07:12 2011 -0600 Bug 703703 - setup-ds-admin.pl asks for legal agreement to a non-existant file https://bugzilla.redhat.com/show_bug.cgi?id=703703 Resolves: bug 703703 Bug Description: setup-ds-admin.pl asks for legal agreement to a non-existant file Reviewed by: nkinder (Thanks!) Branch: master Fix Description: According to the Red Hat Legal department, we do not need to display or ask the user to accept the EULA any more. The EULA dialog and text has been removed. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: Yes - will need a slight amendment to the Install Guide. diff --git a/ldap/admin/src/scripts/SetupDialogs.pm.in b/ldap/admin/src/scripts/SetupDialogs.pm.in index a1c1a02a4..ee2838d68 100644 --- a/ldap/admin/src/scripts/SetupDialogs.pm.in +++ b/ldap/admin/src/scripts/SetupDialogs.pm.in @@ -62,22 +62,6 @@ my $welcome = new DialogYesNo ( ['dialog_welcome_prompt'], ); -my $license = new DialogYesNo ( - $EXPRESS, - 'dialog_license_text', - 0, - sub { - my $self = shift; - my $ans = shift; - my $res = $self->handleResponse($ans); - if ($res == $DialogManager::NEXT) { - $res = $DialogManager::ERR if (!$self->isYes()); - } - return $res; - }, - ['dialog_license_prompt'] -); - my $dsktune = new DialogYesNo ( $EXPRESS, 'dialog_dsktune_text', @@ -278,7 +262,7 @@ my $usergroup = new Dialog ( sub getDialogs { - return ($welcome, $license, $dsktune, $setuptype, $hostdlg, $usergroup); + return ($welcome, $dsktune, $setuptype, $hostdlg, $usergroup); } sub getRegDialogs { diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in index 4c4c7979c..ee616e892 100644 --- a/ldap/admin/src/scripts/setup-ds.res.in +++ b/ldap/admin/src/scripts/setup-ds.res.in @@ -12,11 +12,6 @@ dialog_welcome_text = This program will set up the %s Directory Server.\n\nIt is dialog_welcome_prompt = Would you like to continue with set up? -# ----------- License Dialog Resource ----------- -dialog_license_text = BY SETTING UP AND USING THIS SOFTWARE YOU ARE CONSENTING TO BE BOUND BY\nAND ARE BECOMING A PARTY TO THE AGREEMENT FOUND IN THE\nLICENSE.TXT FILE. IF YOU DO NOT AGREE TO ALL OF THE TERMS\nOF THIS AGREEMENT, PLEASE DO NOT SET UP OR USE THIS SOFTWARE.\n\n - -dialog_license_prompt = Do you agree to the license terms? - # ----------- dsktune Dialog Resource ----------- dialog_dsktune_text = Your system has been scanned for potential problems, missing patches,\ etc. The following output is a report of the items found that need to\
0
b59faa43518613e2f0a893c5a7491e1801d8be5b
389ds/389-ds-base
Ticket 51161 - fix SLE15.2 install issps Bug Description: On SLE15.2 the hostname is almost always set incorrectly which can break the install. Newer versions of systemd encode utf8 in their command output that trips up the log subsystem. Fix Description: We have to set SER_HOST rather than using the default which is socket.gethostname() from init.py. Discard the special utf8 encodings in the log output for systemd https://pagure.io/389-ds-base/issue/51161 Author: William Brown <[email protected]> Review by: mreynolds (Thanks!)
commit b59faa43518613e2f0a893c5a7491e1801d8be5b Author: William Brown <[email protected]> Date: Thu Jun 18 14:01:48 2020 +1000 Ticket 51161 - fix SLE15.2 install issps Bug Description: On SLE15.2 the hostname is almost always set incorrectly which can break the install. Newer versions of systemd encode utf8 in their command output that trips up the log subsystem. Fix Description: We have to set SER_HOST rather than using the default which is socket.gethostname() from init.py. Discard the special utf8 encodings in the log output for systemd https://pagure.io/389-ds-base/issue/51161 Author: William Brown <[email protected]> Review by: mreynolds (Thanks!) diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py index bc8c6e765..418b71b57 100644 --- a/src/lib389/lib389/instance/setup.py +++ b/src/lib389/lib389/instance/setup.py @@ -805,7 +805,9 @@ class SetupDs(object): args = ' '.join(ensure_list_str(result.args)) stdout = ensure_str(result.stdout) stderr = ensure_str(result.stderr) - self.log.debug(f"CMD: {args} ; STDOUT: {stdout} ; STDERR: {stderr}") + # Systemd encodes some odd charecters into it's symlink output on newer versions which + # can trip up the logger. + self.log.debug(f"CMD: {args} ; STDOUT: {stdout} ; STDERR: {stderr}".encode("utf-8")) # Setup tmpfiles_d tmpfile_d = ds_paths.tmpfiles_d + "/dirsrv-" + slapd['instance_name'] + ".conf" @@ -832,7 +834,16 @@ class SetupDs(object): if self.containerised: ds_instance.systemd_override = general['systemd'] + # By default SUSE does something extremely silly - it creates a hostname + # that CANT be resolved by DNS. As a result this causes all installs to + # fail. We need to guarantee that we only connect to localhost here, as + # it's the only stable and guaranteed way to connect to the instance + # at this point. + # + # Alternately, we could use ldapi instead, which would prevent the need + # to configure a temp root pw in the setup phase. args = { + SER_HOST: "localhost", SER_PORT: slapd['port'], SER_SERVERID_PROP: slapd['instance_name'], SER_ROOT_DN: slapd['root_dn'],
0
7f63e4c1671d931bdf7e5291726311d43265c6f1
389ds/389-ds-base
Ticket #548 - RFE: Allow AD password sync to update shadowLastChange Description: When passwordMinAge, passwordMaxAge, passwordWarning, etc. are changed in a password policy, the corresponding shadow values are also adjusted. See this comment for more details. https://fedorahosted.org/389/ticket/548#comment:19 This patch checks the current shadow values with the one from the password policy, and if they don't match, it replaces the shadow value with the one from the password policy. Author: nhosoi Review: wibrown
commit 7f63e4c1671d931bdf7e5291726311d43265c6f1 Author: Noriko Hosoi <[email protected]> Date: Tue Jan 19 11:16:37 2016 -0800 Ticket #548 - RFE: Allow AD password sync to update shadowLastChange Description: When passwordMinAge, passwordMaxAge, passwordWarning, etc. are changed in a password policy, the corresponding shadow values are also adjusted. See this comment for more details. https://fedorahosted.org/389/ticket/548#comment:19 This patch checks the current shadow values with the one from the password policy, and if they don't match, it replaces the shadow value with the one from the password policy. Author: nhosoi Review: wibrown diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c index 4c0beccdc..28d30551e 100644 --- a/ldap/servers/slapd/modify.c +++ b/ldap/servers/slapd/modify.c @@ -496,7 +496,7 @@ slapi_modify_internal_set_pb_ext(Slapi_PBlock *pb, const Slapi_DN *sdn, if (pb == NULL || sdn == NULL || mods == NULL) { slapi_log_error(SLAPI_LOG_FATAL, NULL, - "slapi_modify_internal_set_pb: NULL parameter\n"); + "slapi_modify_internal_set_pb_ext: NULL parameter\n"); return; } diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c index 0237264fd..41a1b3749 100644 --- a/ldap/servers/slapd/opshared.c +++ b/ldap/servers/slapd/opshared.c @@ -1454,10 +1454,12 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result, continue; } /* Adding shadow password attrs. */ - add_shadow_ext_password_attrs(pb, e); + add_shadow_ext_password_attrs(pb, &e); if (process_entry(pb, e, send_result)) { /* shouldn't send this entry */ + slapi_entry_free(pb->pb_pw_entry); + pb->pb_pw_entry = NULL; continue; } @@ -1483,6 +1485,8 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result, pb->pb_op->o_status = SLAPI_OP_STATUS_ABANDONED; break; } + slapi_entry_free(pb->pb_pw_entry); + pb->pb_pw_entry = NULL; if (pagesize == *pnentries) { /* PAGED RESULTS: reached the pagesize */ diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 2c6a7af29..7a2ddde1f 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -937,7 +937,8 @@ void add_password_attrs( Slapi_PBlock *pb, Operation *op, Slapi_Entry *e ); void mod_allowchange_aci(char *val); void pw_mod_allowchange_aci(int pw_prohibit_change); void pw_add_allowchange_aci(Slapi_Entry *e, int pw_prohibit_change); -void add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry *e); + +int add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e); /* * pw_retry.c diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c index a6574ace5..f728e1075 100644 --- a/ldap/servers/slapd/pw.c +++ b/ldap/servers/slapd/pw.c @@ -2843,108 +2843,156 @@ pw_get_ext_size(Slapi_Entry *entry, size_t *size) return LDAP_SUCCESS; } -void -add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry *e) +int +add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e) { const char *dn = NULL; passwdPolicy *pwpolicy = NULL; time_t shadowval = 0; time_t exptime = 0; - struct berval bv; - struct berval *bvals[2]; - - if (!e) { - return; + Slapi_Mods *smods = NULL; + LDAPMod **mods; + long sval; + int mod_num = 0; + char *shmin = NULL; + char *shmax = NULL; + char *shwarn = NULL; + char *shexp = NULL; + int rc = 0; + + if (!e && !*e) { + return rc; } - dn = slapi_entry_get_ndn(e); + dn = slapi_entry_get_ndn(*e); if (!dn) { - return; + return rc; } - if (!slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS, "shadowAccount")) { + if (!slapi_entry_attr_hasvalue(*e, SLAPI_ATTR_OBJECTCLASS, "shadowAccount")) { /* Not a shadowAccount; nothing to do. */ - return; + return rc; } if (operation_is_flag_set(pb->pb_op, OP_FLAG_INTERNAL)) { /* external only */ - return; + return rc; } pwpolicy = new_passwdPolicy(pb, dn); if (!pwpolicy) { - return; + return rc; } LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> add_shadow_password_attrs\n"); - bvals[0] = &bv; - bvals[1] = NULL; - /* shadowMin - the minimum number of days required between password changes. */ - if (!slapi_entry_attr_exists(e, "shadowMin")) { - if (pwpolicy->pw_minage > 0) { - shadowval = pwpolicy->pw_minage / _SEC_PER_DAY; - } else { - shadowval = 0; + if (pwpolicy->pw_minage > 0) { + shadowval = pwpolicy->pw_minage / _SEC_PER_DAY; + } else { + shadowval = 0; + } + shmin = slapi_entry_attr_get_charptr(*e, "shadowMin"); + if (shmin) { + sval = strtol(shmin, NULL, 0); + if (sval != shadowval) { + slapi_ch_free_string(&shmin); + shmin = slapi_ch_smprintf("%ld", shadowval); + mod_num++; } - bv.bv_val = slapi_ch_smprintf("%ld", shadowval); - bv.bv_len = strlen(bv.bv_val); - slapi_entry_attr_merge(e, "shadowMin", bvals); - slapi_ch_free_string(&bv.bv_val); + } else { + mod_num++; + shmin = slapi_ch_smprintf("%ld", shadowval); } /* shadowMax - the maximum number of days for which the user password remains valid. */ - if (!slapi_entry_attr_exists(e, "shadowMax")) { - if (pwpolicy->pw_maxage > 0) { - shadowval = pwpolicy->pw_maxage / _SEC_PER_DAY; - exptime = time_plus_sec(current_time(), pwpolicy->pw_maxage); - } else { - shadowval = 99999; + if (pwpolicy->pw_maxage > 0) { + shadowval = pwpolicy->pw_maxage / _SEC_PER_DAY; + exptime = time_plus_sec(current_time(), pwpolicy->pw_maxage); + } else { + shadowval = 99999; + } + shmax = slapi_entry_attr_get_charptr(*e, "shadowMax"); + if (shmax) { + sval = strtol(shmax, NULL, 0); + if (sval != shadowval) { + slapi_ch_free_string(&shmax); + shmax = slapi_ch_smprintf("%ld", shadowval); + mod_num++; } - bv.bv_val = slapi_ch_smprintf("%ld", shadowval); - bv.bv_len = strlen(bv.bv_val); - slapi_entry_attr_replace(e, "shadowMax", bvals); - slapi_ch_free_string(&bv.bv_val); + } else { + mod_num++; + shmax = slapi_ch_smprintf("%ld", shadowval); } /* shadowWarning - the number of days of advance warning given to the user before the user password expires. */ - if (!slapi_entry_attr_exists(e, "shadowWarning")) { - if (pwpolicy->pw_warning > 0) { - shadowval = pwpolicy->pw_warning / _SEC_PER_DAY; - } else { - shadowval = 0; + if (pwpolicy->pw_warning > 0) { + shadowval = pwpolicy->pw_warning / _SEC_PER_DAY; + } else { + shadowval = 0; + } + shwarn = slapi_entry_attr_get_charptr(*e, "shadowWarning"); + if (shwarn) { + sval = strtol(shwarn, NULL, 0); + if (sval != shadowval) { + slapi_ch_free_string(&shwarn); + shwarn = slapi_ch_smprintf("%ld", shadowval); + mod_num++; } - bv.bv_val = slapi_ch_smprintf("%ld", shadowval); - bv.bv_len = strlen(bv.bv_val); - slapi_entry_attr_replace(e, "shadowWarning", bvals); - slapi_ch_free_string(&bv.bv_val); + } else { + mod_num++; + shwarn = slapi_ch_smprintf("%ld", shadowval); } /* shadowExpire - the date on which the user login will be disabled. */ - if (exptime && !slapi_entry_attr_exists(e, "shadowExpire")) { + if (exptime) { + shexp = slapi_entry_attr_get_charptr(*e, "shadowExpire"); exptime /= _SEC_PER_DAY; - bv.bv_val = slapi_ch_smprintf("%ld", exptime); - bv.bv_len = strlen(bv.bv_val); - slapi_entry_attr_replace(e, "shadowExpire", bvals); - slapi_ch_free_string(&bv.bv_val); + if (shexp) { + sval = strtol(shexp, NULL, 0); + if (sval != exptime) { + slapi_ch_free_string(&shexp); + shexp = slapi_ch_smprintf("%ld", shadowval); + mod_num++; + } + } else { + mod_num++; + shexp = slapi_ch_smprintf("%ld", exptime); + } + } + smods = slapi_mods_new(); + slapi_mods_init(smods, mod_num); + if (shmin) { + slapi_mods_add(smods, LDAP_MOD_REPLACE, "shadowMin", strlen(shmin), shmin); + slapi_ch_free_string(&shmin); + } + if (shmax) { + slapi_mods_add(smods, LDAP_MOD_REPLACE, "shadowMax", strlen(shmax), shmax); + slapi_ch_free_string(&shmax); + } + if (shwarn) { + slapi_mods_add(smods, LDAP_MOD_REPLACE, "shadowWarning", strlen(shwarn), shwarn); + slapi_ch_free_string(&shwarn); + } + if (shexp) { + slapi_mods_add(smods, LDAP_MOD_REPLACE, "shadowExpire", strlen(shexp), shexp); + slapi_ch_free_string(&shexp); + } + /* Apply the mods to create the resulting entry. */ + mods = slapi_mods_get_ldapmods_byref(smods); + if (mods) { + Slapi_Entry *sentry = slapi_entry_dup(*e); + rc = slapi_entry_apply_mods(sentry, mods); + pb->pb_pw_entry = sentry; + *e = sentry; } + slapi_mods_free(&smods); #if 0 /* These 2 attributes are no need (or not able) to auto-fill. */ /* * shadowInactive - the number of days of inactivity allowed for the user. * Password Policy does not have the corresponding parameter. + * + * shadowFlag - not currently in use. */ - shadowval = 0; - bv.bv_val = slapi_ch_smprintf("%ld", shadowval); - bv.bv_len = strlen(bv.bv_val); - slapi_entry_attr_replace(e, "shadowInactive", bvals); - slapi_ch_free_string(&bv.bv_val); - - /* shadowFlag - not currently in use. */ - bv.bv_val = slapi_ch_smprintf("%d", 0); - bv.bv_len = strlen(bv.bv_val); - slapi_entry_attr_replace(e, "shadowFlag", bvals); - slapi_ch_free_string(&bv.bv_val); #endif LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- add_shadow_password_attrs\n"); - return; + return rc; } diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c index cd58f50ae..5acff94c2 100644 --- a/ldap/servers/slapd/result.c +++ b/ldap/servers/slapd/result.c @@ -238,7 +238,7 @@ int send_ldap_intermediate( Slapi_PBlock *pb, LDAPControl **ectrls, rc = ber_put_seq( ber ); } if ( rc == LBER_ERROR ) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 0\n", 0, 0, 0 ); ber_free( ber, 1 /* freebuf */ ); goto log_and_return; } @@ -595,7 +595,7 @@ send_ldap_result_ext( } if ( rc == LBER_ERROR ) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 1\n", 0, 0, 0 ); if (flush_ber_element == 1) { /* we alloced the ber */ ber_free( ber, 1 /* freebuf */ ); @@ -857,13 +857,13 @@ send_ldapv3_referral( rc = ber_printf( ber, "s", urls[i]->bv_val ); } if ( rc == LBER_ERROR ) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 2\n", 0, 0, 0 ); send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf", 0, NULL ); return( -1 ); } if ( ber_printf( ber, "}}" ) == LBER_ERROR ) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 3\n", 0, 0, 0 ); send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf", 0, NULL ); return( -1 ); @@ -980,7 +980,7 @@ encode_attr_2( #endif if (ber_printf(ber, "{s[", returned_type?returned_type:attribute_type) == -1) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 4\n", 0, 0, 0 ); ber_free( ber, 1 ); send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf type", 0, NULL); @@ -994,7 +994,7 @@ encode_attr_2( if ( ber_printf( ber, "o", v->bv.bv_val,v->bv.bv_len ) == -1 ) { LDAPDebug( LDAP_DEBUG_ANY, - "ber_printf failed\n", 0, 0, 0 ); + "ber_printf failed 5\n", 0, 0, 0 ); ber_free( ber, 1 ); send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf value", 0, NULL ); @@ -1005,7 +1005,7 @@ encode_attr_2( } if ( ber_printf( ber, "]}" ) == -1 ) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 6\n", 0, 0, 0 ); ber_free( ber, 1 ); send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf type end", 0, NULL ); @@ -1549,7 +1549,7 @@ send_ldap_search_entry_ext( LDAP_RES_SEARCH_ENTRY, slapi_entry_get_dn_const(e) ); if ( rc == -1 ) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 7\n", 0, 0, 0 ); send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf dn", 0, NULL ); goto cleanup; @@ -1663,7 +1663,7 @@ send_ldap_search_entry_ext( } if ( rc == -1 ) { - LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed 8\n", 0, 0, 0 ); send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf entry end", 0, NULL ); goto cleanup; diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index c4bae763c..5bb9252a9 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1735,6 +1735,7 @@ typedef struct slapi_pblock { /* For ACI Target Check */ int pb_aci_target_check; /* this flag prevents duplicate checking of ACI's target existence */ + struct slapi_entry *pb_pw_entry; /* stash dup'ed entry that shadow info is added/replaced */ } slapi_pblock; /* index if substrlens */
0
b05e86a1004cccbe0573b3268b7c8a428323967e
389ds/389-ds-base
Resolves: #195305, #195307 Summary: [195305] make new_task() non-static Changes: provide slapi_new_task and slapi_destroy_task as slapi APIs Summary: [195307] task registration by plugins is wiped by task_init() Changes: clean up old tasks before plugin_startall
commit b05e86a1004cccbe0573b3268b7c8a428323967e Author: Noriko Hosoi <[email protected]> Date: Thu Dec 14 23:16:54 2006 +0000 Resolves: #195305, #195307 Summary: [195305] make new_task() non-static Changes: provide slapi_new_task and slapi_destroy_task as slapi APIs Summary: [195307] task registration by plugins is wiped by task_init() Changes: clean up old tasks before plugin_startall diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 5a6aa1116..e0f0203d3 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -1056,6 +1056,13 @@ main( int argc, char **argv) LDAPDebug( LDAP_DEBUG_PLUGIN, "Password Modify plugin registered.\n", 0, 0, 0 ); + /* Cleanup old tasks that may still be in the DSE from a previous + session. Call before plugin_startall since cleanup needs to be + done before plugin_startall where user defined task plugins could + be started. + */ + task_cleanup(); + plugin_startall(argc, argv, 1 /* Start Backends */, 1 /* Start Globals */); if (housekeeping_start((time_t)0, NULL) == NULL) { exit (1); diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index 39c971dcf..5667b0b42 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -2445,7 +2445,8 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb, /* return next backend, increment index */ *be = target_node->mtn_be[*index]; if(*be==NULL) { - if (target_node->mtn_be_states[*index] == SLAPI_BE_STATE_DELETE) { + if (NULL != target_node->mtn_be_states && + target_node->mtn_be_states[*index] == SLAPI_BE_STATE_DELETE) { /* This MTN is being deleted */ *be = defbackend_get_backend(); } else { @@ -2816,7 +2817,7 @@ slapi_on_internal_backends(const Slapi_DN *sdn) /* Some of the operations are not allowed from the plugins * but default to specialized use of those operations - * e.g rootDse search, NetscapeRoot searches + * e.g rootDse search, ConfigRoot searches * cn=config, cn=schema etc */ diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index e5ff2bba4..0149556aa 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -150,7 +150,9 @@ typedef struct slapi_rdn Slapi_RDN; typedef struct slapi_mod Slapi_Mod; typedef struct slapi_mods Slapi_Mods; typedef struct slapi_componentid Slapi_ComponentId; - +/* Online tasks interface (to support import, export, etc) */ +typedef struct _slapi_task Slapi_Task; +typedef int (*TaskCallbackFn)(Slapi_Task *task); /* * The default thread stacksize for nspr21 is 64k (except on IRIX! It's 32k!). @@ -1187,7 +1189,59 @@ typedef int (*roles_check_fn_type)(Slapi_Entry *entry_to_check, Slapi_DN *role_d int slapi_role_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present); void slapi_register_role_check(roles_check_fn_type check_fn); +/* DSE */ +/* Front end configuration */ +typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *, + int *, char*, void *); + +/****************************************************************************** + * Online tasks interface (to support import, export, etc) + * After some cleanup, we could consider making these public. + */ + +/* task states */ +#define SLAPI_TASK_SETUP 0 +#define SLAPI_TASK_RUNNING 1 +#define SLAPI_TASK_FINISHED 2 +#define SLAPI_TASK_CANCELLED 3 + +/* task flags (set by the task-control code) */ +#define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */ + +int slapi_task_register_handler(const char *name, dseCallbackFn func); +void slapi_task_status_changed(Slapi_Task *task); +void slapi_task_log_status(Slapi_Task *task, char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 2, 3))); +#else + ; +#endif +void slapi_task_log_notice(Slapi_Task *task, char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 2, 3))); +#else + ; +#endif + +/* + * slapi_new_task: create new task, fill in DN, and setup modify callback + * argument: + * dn: task dn + * result: + * Success: Slapi_Task object + * Failure: NULL + */ +Slapi_Task *slapi_new_task(const char *dn); + +/* slapi_destroy_task: destroy a task + * argument: + * task: task to destroy + * result: + * none + */ +void slapi_destroy_task(void *arg); +/* End of interface to support online tasks **********************************/ /* Binder-based (connection centric) resource limits */ /* diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h index ba6dfc37c..848f1019c 100644 --- a/ldap/servers/slapd/slapi-private.h +++ b/ldap/servers/slapd/slapi-private.h @@ -744,6 +744,7 @@ int slapi_lookup_instance_name_by_suffix(char *suffix, /* begin and end the task subsystem */ void task_init(void); void task_shutdown(void); +void task_cleanup(void); /* for reversible encyrption */ #define SLAPI_MB_CREDENTIALS "nsmultiplexorcredentials" @@ -1033,11 +1034,6 @@ int slapi_uniqueIDGenerateFromNameString(char **uId, * JCMREPL - Added for the replication plugin. */ -/* Front end configuration */ - -typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *, - int *, char*, void *); - /* * Note: DSE callback functions MUST return one of these three values: * @@ -1177,23 +1173,10 @@ int slapd_re_init( void ); /***** End of items added for the replication plugin. ***********************/ - /****************************************************************************** * Online tasks interface (to support import, export, etc) * After some cleanup, we could consider making these public. */ -typedef struct _slapi_task Slapi_Task; -typedef int (*TaskCallbackFn)(Slapi_Task *task); - -/* task states */ -#define SLAPI_TASK_SETUP 0 -#define SLAPI_TASK_RUNNING 1 -#define SLAPI_TASK_FINISHED 2 -#define SLAPI_TASK_CANCELLED 3 - -/* task flags (set by the task-control code) */ -#define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */ - struct _slapi_task { struct _slapi_task *next; char *task_dn; @@ -1212,26 +1195,8 @@ struct _slapi_task { TaskCallbackFn destructor; /* task entry is being destroyed */ int task_refcount; }; - -int slapi_task_register_handler(const char *name, dseCallbackFn func); -void slapi_task_status_changed(Slapi_Task *task); -void slapi_task_log_status(Slapi_Task *task, char *format, ...) -#ifdef __GNUC__ - __attribute__ ((format (printf, 2, 3))); -#else - ; -#endif - -void slapi_task_log_notice(Slapi_Task *task, char *format, ...) -#ifdef __GNUC__ - __attribute__ ((format (printf, 2, 3))); -#else - ; -#endif - /* End of interface to support online tasks **********************************/ - void DS_Sleep(PRIntervalTime ticks); /* macro to specify the behavior of upgradedb */ diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c index 13ff15657..629933b37 100644 --- a/ldap/servers/slapd/task.c +++ b/ldap/servers/slapd/task.c @@ -78,8 +78,9 @@ static int task_deny(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg); static int task_generic_destructor(Slapi_Task *task); -/* create new task, fill in DN, and setup modify callback */ -static Slapi_Task *new_task(const char *dn) +/* create a new task, fill in DN, and setup modify callback */ +static Slapi_Task * +new_task(const char *dn) { Slapi_Task *task = (Slapi_Task *)slapi_ch_calloc(1, sizeof(Slapi_Task)); @@ -109,7 +110,8 @@ static Slapi_Task *new_task(const char *dn) } /* called by the event queue to destroy a task */ -static void destroy_task(time_t when, void *arg) +static void +destroy_task(time_t when, void *arg) { Slapi_Task *task = (Slapi_Task *)arg; Slapi_Task *t1; @@ -150,6 +152,31 @@ static void destroy_task(time_t when, void *arg) slapi_ch_free((void **)&task); } +/* + * slapi_new_task: create a new task, fill in DN, and setup modify callback + * argument: + * dn: task dn + * result: + * Success: Slapi_Task object + * Failure: NULL + */ +Slapi_Task * +slapi_new_task(const char *dn) +{ + return new_task(dn); +} + +/* slapi_destroy_task: destroy a task + * argument: + * task: task to destroy + * result: + * none + */ +void +slapi_destroy_task(void *arg) +{ + destroy_task(1, arg); +} /********** some useful helper functions **********/ @@ -1539,12 +1566,11 @@ void slapi_task_status_changed(Slapi_Task *task) } } - /* cleanup old tasks that may still be in the DSE from a previous session * (this can happen if the server crashes [no matter how unlikely we like * to think that is].) */ -static void cleanup_old_tasks(void) +void task_cleanup(void) { Slapi_PBlock *pb = slapi_pblock_new(); Slapi_Entry **entries = NULL; @@ -1691,8 +1717,6 @@ void task_init(void) return; } - cleanup_old_tasks(); - slapi_task_register_handler("import", task_import_add); slapi_task_register_handler("export", task_export_add); slapi_task_register_handler("backup", task_backup_add);
0
ed231df0143d61f6274705a73a617b14e1060613
389ds/389-ds-base
Issue 5278 - CLI - dsidm asks for the old password on password reset Description: If we are chaning a password as Root DN we don't need the old password relates: https://github.com/389ds/389-ds-base/issues/5278 Reviewed by: progier(Thanks!)
commit ed231df0143d61f6274705a73a617b14e1060613 Author: Mark Reynolds <[email protected]> Date: Fri Dec 16 11:39:52 2022 -0500 Issue 5278 - CLI - dsidm asks for the old password on password reset Description: If we are chaning a password as Root DN we don't need the old password relates: https://github.com/389ds/389-ds-base/issues/5278 Reviewed by: progier(Thanks!) diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 68ff5d6ea..b45beedfc 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -65,7 +65,8 @@ from lib389.utils import ( format_cmd_list, get_default_db_lib, selinux_present, - selinux_label_port) + selinux_label_port, + get_user_is_root) from lib389.paths import Paths from lib389.nss_ssl import NssSsl from lib389.tasks import BackupTask, RestoreTask @@ -3484,3 +3485,20 @@ class DirSrv(SimpleLDAPObject, object): task.create(properties=task_properties) return task + + def is_rootdn_bound(self): + # Return True if root DN is authenticated for this DirSrv instance + if self.state != DIRSRV_STATE_ONLINE: + return False + + if self.binddn is None and get_user_is_root(): + # ldapi + return True + + if self.binddn is not None: + # Bind DN provided, is it the root DN? + rootdn = self.config.get_attr_val_utf8_l('nsslapd-rootdn') + if self.binddn.lower() == rootdn: + return True + + return False diff --git a/src/lib389/lib389/cli_idm/account.py b/src/lib389/lib389/cli_idm/account.py index ed376ac66..fd03576e5 100644 --- a/src/lib389/lib389/cli_idm/account.py +++ b/src/lib389/lib389/cli_idm/account.py @@ -145,11 +145,18 @@ def reset_password(inst, basedn, log, args): def change_password(inst, basedn, log, args): dn = _get_dn_arg(args.dn, msg="Enter dn to change password") - cur_password = _get_arg(args.current_password, hidden=True, confirm=False, msg="Enter current password for %s" % dn) - new_password = _get_arg(args.new_password, hidden=True, confirm=True, msg="Enter new password for %s" % dn) accounts = Accounts(inst, basedn) acct = accounts.get(dn=dn) - acct.change_password(cur_password, new_password) + + if not inst.is_rootdn_bound(): + cur_password = _get_arg(args.current_password, hidden=True, confirm=False, msg="Enter current password for %s" % dn) + new_password = _get_arg(args.new_password, hidden=True, confirm=True, msg="Enter new password for %s" % dn) + acct.change_password(cur_password, new_password) + if inst.is_rootdn_bound(): + # is root/rootdn do not prompt for old password + new_password = _get_arg(args.new_password, hidden=True, confirm=True, msg="Enter new password for %s" % dn) + acct.reset_password(new_password) + log.info('changed password for %s' % dn)
0
85a78741dfeb636a1cf7cced1576278e65f5bb58
389ds/389-ds-base
Ticket #47571 - targetattr ACIs ignore subtype Description: Subtypes in targetattr, userattr in aci as well as filter and attribute list in the search are supported. * If targetattr contains subtypes, the base type only as well as other subtypes are not allowed to access (or denied to access). * If userattr contains subtypes, the base type as well as other subtypes in entries do not match the userattr value. * If attribute list in search has a base type attribute, and a targetattr has a type with subtypes, then only the subtyped value is returned. E.g., attribute list: sn targetattr: sn;en ==> sn;en: <sn-en-value> and sn;en;phonetic: <sn-en-phonetic-value> are returned but sn or sn;fr is not. If attribute list has a type with subtype, then if the targetattr allows the subtype, the value is returned. E.g., attribute list: sn;en targetattr: sn;en ==> sn;en: <sn-en-value> and sn;en;phonetic: <sn-en-phonetic-value> are returned but sn or sn;fr is not. 1) slapd/attr.c * slapi_attr_type_cmp assumed the subtype order in 2 args are identical, but it is not always guaranteed. Removed the assumption. * Added another compare type SLAPI_TYPE_CMP_SUBTYPES to comp_cmp which is called by slapi_attr_type_cmp to support full subtypes comparison. 2) plugin/acl.c: * Changed to call slapi_attr_type_cmp with human readable macros, e.g., SLAPI_TYPE_CMP_BASE, SLAPI_TYPE_CMP_SUBTYPE, etc. * Replaced strcasecmp with slapi_attr_type_cmp for attribute type comparison. * Changed to call slapi_attr_type_cmp with SLAPI_TYPE_CMP_SUBTYPES (full subtype comparison) in acl__get_attrEval, where the next attribute to compare is determined. 3) slapd/search.c,result.c send_all_attrs/send_specific_attrs use a dontsendattr array to control the duplicate attribute types. Replaced the logic with a simpler one by creating an charray with no duplicates. https://fedorahosted.org/389/ticket/47571 Reviewed by [email protected] (Thank you, Thierry!)
commit 85a78741dfeb636a1cf7cced1576278e65f5bb58 Author: Noriko Hosoi <[email protected]> Date: Fri Jan 10 11:06:02 2014 -0800 Ticket #47571 - targetattr ACIs ignore subtype Description: Subtypes in targetattr, userattr in aci as well as filter and attribute list in the search are supported. * If targetattr contains subtypes, the base type only as well as other subtypes are not allowed to access (or denied to access). * If userattr contains subtypes, the base type as well as other subtypes in entries do not match the userattr value. * If attribute list in search has a base type attribute, and a targetattr has a type with subtypes, then only the subtyped value is returned. E.g., attribute list: sn targetattr: sn;en ==> sn;en: <sn-en-value> and sn;en;phonetic: <sn-en-phonetic-value> are returned but sn or sn;fr is not. If attribute list has a type with subtype, then if the targetattr allows the subtype, the value is returned. E.g., attribute list: sn;en targetattr: sn;en ==> sn;en: <sn-en-value> and sn;en;phonetic: <sn-en-phonetic-value> are returned but sn or sn;fr is not. 1) slapd/attr.c * slapi_attr_type_cmp assumed the subtype order in 2 args are identical, but it is not always guaranteed. Removed the assumption. * Added another compare type SLAPI_TYPE_CMP_SUBTYPES to comp_cmp which is called by slapi_attr_type_cmp to support full subtypes comparison. 2) plugin/acl.c: * Changed to call slapi_attr_type_cmp with human readable macros, e.g., SLAPI_TYPE_CMP_BASE, SLAPI_TYPE_CMP_SUBTYPE, etc. * Replaced strcasecmp with slapi_attr_type_cmp for attribute type comparison. * Changed to call slapi_attr_type_cmp with SLAPI_TYPE_CMP_SUBTYPES (full subtype comparison) in acl__get_attrEval, where the next attribute to compare is determined. 3) slapd/search.c,result.c send_all_attrs/send_specific_attrs use a dontsendattr array to control the duplicate attribute types. Replaced the logic with a simpler one by creating an charray with no duplicates. https://fedorahosted.org/389/ticket/47571 Reviewed by [email protected] (Thank you, Thierry!) diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c index a8b4dde7a..3c1db3625 100644 --- a/ldap/servers/plugins/acl/acl.c +++ b/ldap/servers/plugins/acl/acl.c @@ -549,15 +549,14 @@ acl_access_allowed( ** Check if we can use any cached information to determine ** access to this resource */ - if ( (access & SLAPI_ACL_SEARCH) && - (ret_val = acl__match_handlesFromCache ( aclpb , attr, access)) != -1) { + if ((access & SLAPI_ACL_SEARCH) && + (ret_val = acl__match_handlesFromCache(aclpb, attr, access)) != -1) { /* means got a result: allowed or not*/ if (ret_val == LDAP_SUCCESS ) { - decision_reason.reason = ACL_REASON_EVALCONTEXT_CACHED_ALLOW; + decision_reason.reason = ACL_REASON_EVALCONTEXT_CACHED_ALLOW; } else if (ret_val == LDAP_INSUFFICIENT_ACCESS) { - decision_reason.reason = - ACL_REASON_EVALCONTEXT_CACHED_NOT_ALLOWED; + decision_reason.reason = ACL_REASON_EVALCONTEXT_CACHED_NOT_ALLOWED; } goto cleanup_and_ret; } @@ -1058,7 +1057,8 @@ acl_read_access_allowed_on_entry ( slapi_ch_free ( (void **) &aclpb->aclpb_Evalattr); aclpb->aclpb_Evalattr = slapi_ch_malloc(len+1); } - PL_strncpyz (aclpb->aclpb_Evalattr, attr_type, len); + /* length needs to have 1 for '\0' */ + PL_strncpyz (aclpb->aclpb_Evalattr, attr_type, len+1); #ifdef DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES if ( attr_index >= 0 ) { /* @@ -1191,38 +1191,36 @@ acl_read_access_allowed_on_attr ( } /* - * Am I a anonymous dude ? then we can use our anonympous profile + * Am I anonymous? then we can use our anonympous profile * We don't require the aclpb to have been initialized for anom stuff - * - */ + */ slapi_pblock_get (pb, SLAPI_REQUESTOR_DN ,&clientDn ); - if ( clientDn && *clientDn == '\0' ) { - ret_val = aclanom_match_profile ( pb, aclpb, e, attr, - SLAPI_ACL_READ ); + if (clientDn && (*clientDn == '\0')) { + ret_val = aclanom_match_profile (pb, aclpb, e, attr, SLAPI_ACL_READ); TNF_PROBE_1_DEBUG(acl_read_access_allowed_on_attr_end ,"ACL","", - tnf_string,anon_decision,""); - if (ret_val != -1 ) return ret_val; + tnf_string,anon_decision,""); + if (ret_val != -1) { + return ret_val; + } } /* Then I must have a access to the entry. */ aclpb->aclpb_state |= ACLPB_ACCESS_ALLOWED_ON_ENTRY; - if ( aclpb->aclpb_state & ACLPB_MATCHES_ALL_ACLS ) { + if (aclpb->aclpb_state & ACLPB_MATCHES_ALL_ACLS) { ret_val = acl__attr_cached_result (aclpb, attr, SLAPI_ACL_READ); - if (ret_val != -1 ) { + if (ret_val != -1) { slapi_log_error(SLAPI_LOG_ACL, plugin_name, - "MATCHED HANDLE:dn:%s attr: %s val:%d\n", - n_edn, attr, ret_val ); - if ( ret_val == LDAP_SUCCESS) { - decision_reason.reason = - ACL_REASON_EVALCONTEXT_CACHED_ALLOW; + "MATCHED HANDLE:dn:%s attr: %s val:%d\n", + n_edn, attr, ret_val ); + if (ret_val == LDAP_SUCCESS) { + decision_reason.reason = ACL_REASON_EVALCONTEXT_CACHED_ALLOW; } else { - decision_reason.reason = - ACL_REASON_EVALCONTEXT_CACHED_NOT_ALLOWED; - } + decision_reason.reason = ACL_REASON_EVALCONTEXT_CACHED_NOT_ALLOWED; + } goto acl_access_allowed_on_attr_Exit; - } else { + } else { aclpb->aclpb_state |= ACLPB_COPY_EVALCONTEXT; } } @@ -1258,50 +1256,54 @@ acl_read_access_allowed_on_attr ( ** -- access is allowed on phone ** -- Don't know about the rest. Need to evaluate. */ - - if ( slapi_attr_type_cmp (attr, aclpb->aclpb_Evalattr, 1) == 0) { + if (slapi_attr_type_cmp(aclpb->aclpb_Evalattr, attr, SLAPI_TYPE_CMP_SUBTYPE) == 0) { /* from now on we need to evaluate access on ** rest of the attrs. */ - aclpb->aclpb_state &= ~ACLPB_ACCESS_ALLOWED_ON_A_ATTR; TNF_PROBE_1_DEBUG(acl_read_access_allowed_on_attr_end ,"ACL","", - tnf_string,aclp_Evalattr1,""); - + tnf_string,aclp_Evalattr1,""); return LDAP_SUCCESS; - } else { - /* - * Here, the attr that implied access to the entry (aclpb_Evalattr), - * is not - * the one we currently want evaluated--so - * we need to evaluate access to attr--so fall through. - */ } - } else if (aclpb->aclpb_state & ACLPB_ACCESS_ALLOWED_USERATTR) { + /* + * Here, the attr that implied access to the entry (aclpb_Evalattr), + * is not + * the one we currently want evaluated--so + * we need to evaluate access to attr--so fall through. + */ + + } else if (aclpb->aclpb_state & ACLPB_ACCESS_ALLOWED_USERATTR) { /* Only skip evaluation on the user attr on which we have ** evaluated before. */ - if ( slapi_attr_type_cmp (attr, aclpb->aclpb_Evalattr, 1) == 0) { + if (slapi_attr_type_cmp(aclpb->aclpb_Evalattr, attr, SLAPI_TYPE_CMP_SUBTYPE) == 0) { aclpb->aclpb_state &= ~ACLPB_ACCESS_ALLOWED_USERATTR; TNF_PROBE_1_DEBUG(acl_read_access_allowed_on_attr_end ,"ACL","", - tnf_string,aclp_Evalattr2,""); + tnf_string,aclp_Evalattr2,""); return LDAP_SUCCESS; } } /* we need to evaluate the access on this attr */ + /* + * targetattr=sn;en + * search attribute list: cn sn + * ==> + * attr: cn sn;en + * aclpb_Evalattr: sn;en + */ return ( acl_access_allowed(pb, e, attr, val, access) ); /* This exit point prints a summary and returns ret_val */ acl_access_allowed_on_attr_Exit: - /* print summary if loglevel set */ + /* print summary if loglevel set */ if ( slapi_is_loglevel_set(loglevel) ) { print_access_control_summary( "on attr", ret_val, clientDn, aclpb, acl_access2str(SLAPI_ACL_READ), - attr, n_edn, &decision_reason); + attr, n_edn, &decision_reason); } TNF_PROBE_0_DEBUG(acl_read_access_allowed_on_attr_end ,"ACL",""); @@ -1697,8 +1699,9 @@ acl_modified (Slapi_PBlock *pb, int optype, Slapi_DN *e_sdn, void *change) mods = (LDAPMod **) change; - for (j=0; mods[j] != NULL; j++) { - if (strcasecmp(mods[j]->mod_type, aci_attr_type) == 0) { + for (j=0; mods && mods[j]; j++) { + if (slapi_attr_type_cmp(mods[j]->mod_type, aci_attr_type, + SLAPI_TYPE_CMP_SUBTYPE) == 0) { /* Got an aci to mod in this list of mods, so * take the acicache lock for the whole list of mods, @@ -2165,7 +2168,7 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * } else { dn_matched = ACL_TRUE; } - + if (aci->aci_type & ACI_TARGET_NOT) { matches = (dn_matched ? ACL_FALSE : ACL_TRUE); } else { @@ -2347,7 +2350,7 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * * of the attribute in the entry--otherwise you * could satisfy the filter and then put loads of other * values in on the back of it. - */ + */ sval=NULL; attrVal=NULL; @@ -2356,18 +2359,16 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * while(k != -1 && !done) { attrVal = slapi_value_get_berval(sval); - if ( acl__make_filter_test_entry( - &aclpb->aclpb_filter_test_entry, - attrFilter->attr_str, - (struct berval *)attrVal) == LDAP_SUCCESS ) { - - attr_matched= acl__test_filter( - aclpb->aclpb_filter_test_entry, - attrFilter->filter, - 1 /* Do filter sense evaluation below */ - ); + if (acl__make_filter_test_entry(&aclpb->aclpb_filter_test_entry, + attrFilter->attr_str, + (struct berval *)attrVal) == LDAP_SUCCESS ) { + + attr_matched = acl__test_filter(aclpb->aclpb_filter_test_entry, + attrFilter->filter, + 1 /* Do filter sense evaluation below */ + ); done = !attr_matched; - slapi_entry_free( aclpb->aclpb_filter_test_entry ); + slapi_entry_free( aclpb->aclpb_filter_test_entry ); } k= slapi_attr_next_value(attr_ptr, k, &sval); @@ -2379,8 +2380,8 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * * of the attribute in the entry satisfied the filter. * Otherwise, attr_matched is ACL_FALSE and not every * value satisfied the filter, so we will teminate the - * scan of the filter list. - */ + * scan of the filter list. + */ } @@ -2391,9 +2392,9 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * * Here, we've applied all the applicable filters to the entry. * Each one must have been satisfied by all the values of the attribute. * The result of this is stored in attr_matched. - */ + */ -#if 0 +#if 0 /* * Don't support a notion of "add != " or "del != " * at the moment. @@ -2415,12 +2416,10 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * goto acl__resource_match_aci_EXIT; } - } else if ( ((aclpb->aclpb_access & ACLPB_SLAPI_ACL_WRITE_ADD) && - (aci->aci_type & ACI_TARGET_ATTR_ADD_FILTERS)) || - ((aclpb->aclpb_access & ACLPB_SLAPI_ACL_WRITE_DEL) && - (aci->aci_type & ACI_TARGET_ATTR_DEL_FILTERS)) ) { - - + } else if ( ((aclpb->aclpb_access & ACLPB_SLAPI_ACL_WRITE_ADD) && + (aci->aci_type & ACI_TARGET_ATTR_ADD_FILTERS)) || + ((aclpb->aclpb_access & ACLPB_SLAPI_ACL_WRITE_DEL) && + (aci->aci_type & ACI_TARGET_ATTR_DEL_FILTERS)) ) { /* * Here, it's a modify add/del and we have attr filters. * So, we need to scan the add/del filter list to find the filter @@ -2436,15 +2435,11 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * int found = 0; if ((aclpb->aclpb_access & ACLPB_SLAPI_ACL_WRITE_ADD) && - (aci->aci_type & ACI_TARGET_ATTR_ADD_FILTERS)) { - + (aci->aci_type & ACI_TARGET_ATTR_ADD_FILTERS)) { attrFilterArray = aci->targetAttrAddFilters; - } else if ((aclpb->aclpb_access & ACLPB_SLAPI_ACL_WRITE_DEL) && - (aci->aci_type & ACI_TARGET_ATTR_DEL_FILTERS)) { - + (aci->aci_type & ACI_TARGET_ATTR_DEL_FILTERS)) { attrFilterArray = aci->targetAttrDelFilters; - } @@ -2456,12 +2451,12 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * num_attrs = 0; while (attrFilterArray[num_attrs] && !found) { - attrFilter = attrFilterArray[num_attrs]; + attrFilter = attrFilterArray[num_attrs]; /* If this filter applies to the attribute, stop. */ if ((aclpb->aclpb_curr_attrEval) && - slapi_attr_type_cmp ( aclpb->aclpb_curr_attrEval->attrEval_name, - attrFilter->attr_str, 1) == 0) { + slapi_attr_type_cmp(aclpb->aclpb_curr_attrEval->attrEval_name, + attrFilter->attr_str, SLAPI_TYPE_CMP_SUBTYPE) == 0) { found = 1; } num_attrs++; @@ -2475,17 +2470,16 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * if (found) { - if ( acl__make_filter_test_entry( - &aclpb->aclpb_filter_test_entry, - aclpb->aclpb_curr_attrEval->attrEval_name, - aclpb->aclpb_curr_attrVal) == LDAP_SUCCESS ) { + if (acl__make_filter_test_entry(&aclpb->aclpb_filter_test_entry, + aclpb->aclpb_curr_attrEval->attrEval_name, + aclpb->aclpb_curr_attrVal) == LDAP_SUCCESS ) { attr_matched= acl__test_filter(aclpb->aclpb_filter_test_entry, attrFilter->filter, 1 /* Do filter sense evaluation below */ - ); - slapi_entry_free( aclpb->aclpb_filter_test_entry ); - } + ); + slapi_entry_free( aclpb->aclpb_filter_test_entry ); + } /* No need to look further */ if (attr_matched == ACL_FALSE) { @@ -2500,7 +2494,7 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * */ attr_matched_in_targetattrfilters = 1; - } + } } /* targetvaluefilters */ @@ -2572,7 +2566,7 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * * bother to look at the attrlist. */ - if (!attr_matched_in_targetattrfilters) { + if (!attr_matched_in_targetattrfilters) { /* match target attr */ if ((c_attrEval) && @@ -2587,10 +2581,13 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int * num_attrs = 0; while (attrArray[num_attrs] && !attr_matched) { - attr = attrArray[num_attrs]; - if (attr->attr_type & ACL_ATTR_STRING) { - if (slapi_attr_type_cmp ( res_attr, - attr->u.attr_str, 1) == 0) { + attr = attrArray[num_attrs]; + if (attr->attr_type & ACL_ATTR_STRING) { + /* + * res_attr: attr type to eval (e.g., filter "(sn;en=*)") + * attr->u.attr_str: targetattr value (e.g., sn;en) + */ + if (slapi_attr_type_cmp(attr->u.attr_str, res_attr, SLAPI_TYPE_CMP_SUBTYPE) == 0) { attr_matched = ACL_TRUE; *a_matched = ACL_TRUE; } @@ -3518,7 +3515,7 @@ acl__attr_cached_result (struct acl_pblock *aclpb, char *attr, int access ) if ( a_eval == NULL ) continue; - if (strcasecmp ( attr, a_eval->attrEval_name ) == 0 ) { + if (slapi_attr_type_cmp(a_eval->attrEval_name, attr, SLAPI_TYPE_CMP_SUBTYPE) == 0) { if ( access & SLAPI_ACL_SEARCH ) { if (a_eval->attrEval_s_status < ACL_ATTREVAL_DETERMINISTIC ) { if ( a_eval->attrEval_s_status & ACL_ATTREVAL_SUCCESS) @@ -3708,8 +3705,9 @@ acl_copyEval_context ( struct acl_pblock *aclpb, aclEvalContext *src, continue; for ( j = 0; j < dest->acle_numof_attrs; j++ ) { - if ( strcasecmp ( src->acle_attrEval[i].attrEval_name, - dest->acle_attrEval[j].attrEval_name ) == 0 ) { + if (slapi_attr_type_cmp(src->acle_attrEval[i].attrEval_name, + dest->acle_attrEval[j].attrEval_name, + SLAPI_TYPE_CMP_SUBTYPE) == 0) { /* We have it. skip it. */ attr_exists = 1; dd_slot = j; @@ -3751,8 +3749,7 @@ acl_copyEval_context ( struct acl_pblock *aclpb, aclEvalContext *src, (size_t)src->acle_numof_tmatched_handles, sizeof( int ), acl__cmp ); for (i=0; i < src->acle_numof_tmatched_handles; i++ ) { - dest->acle_handles_matched_target[i] = - src->acle_handles_matched_target[i]; + dest->acle_handles_matched_target[i] = src->acle_handles_matched_target[i]; } if ( src->acle_numof_tmatched_handles ) { @@ -3917,9 +3914,12 @@ acl__get_attrEval ( struct acl_pblock *aclpb, char *attr ) /* Go thru and see if we have the attr already */ for (j=0; j < c_ContextEval->acle_numof_attrs; j++) { c_attrEval = &c_ContextEval->acle_attrEval[j]; - - if ( c_attrEval && - slapi_attr_type_cmp ( c_attrEval->attrEval_name, attr, 1) == 0 ) { + + if (c_attrEval && + /* attr: e.g., filter "(sn;en=*)" / attr list / attr in entry */ + /* This compare must check all subtypes. "sn" vs. "sn;fr" should return 1 */ + slapi_attr_type_cmp(c_attrEval->attrEval_name, + attr, SLAPI_TYPE_CMP_SUBTYPES) == 0) { aclpb->aclpb_curr_attrEval = c_attrEval; break; } diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c index 266538f91..9c26fc73d 100644 --- a/ldap/servers/plugins/acl/aclparse.c +++ b/ldap/servers/plugins/acl/aclparse.c @@ -2224,8 +2224,7 @@ static int type_compare( Slapi_Filter *f, void *arg) { if (slapi_filter_get_attribute_type( f, &filter_type) == 0) { t = slapi_attr_syntax_normalize(t); filter_type = slapi_attr_syntax_normalize(filter_type); - - if (slapi_attr_type_cmp(filter_type, t, 1) == 0) { + if (slapi_attr_type_cmp(filter_type, t, SLAPI_TYPE_CMP_BASE) == 0) { rc = SLAPI_FILTER_SCAN_CONTINUE; } diff --git a/ldap/servers/plugins/acl/aclplugin.c b/ldap/servers/plugins/acl/aclplugin.c index 0766560d6..8ae634c41 100644 --- a/ldap/servers/plugins/acl/aclplugin.c +++ b/ldap/servers/plugins/acl/aclplugin.c @@ -374,11 +374,11 @@ acl_access_allowed_main ( Slapi_PBlock *pb, Slapi_Entry *e, char **attrs, if (attrs && *attrs) attr = attrs[0]; - if (ACLPLUGIN_ACCESS_READ_ON_ENTRY == flags) + if (ACLPLUGIN_ACCESS_READ_ON_ENTRY == flags) { rc = acl_read_access_allowed_on_entry ( pb, e, attrs, access); - else if ( ACLPLUGIN_ACCESS_READ_ON_ATTR == flags) { + } else if ( ACLPLUGIN_ACCESS_READ_ON_ATTR == flags) { if (attr == NULL) { - slapi_log_error( SLAPI_LOG_PLUGIN, plugin_name, "Missing attribute\n" ); + slapi_log_error( SLAPI_LOG_PLUGIN, plugin_name, "Missing attribute\n" ); rc = LDAP_OPERATIONS_ERROR; } else { rc = acl_read_access_allowed_on_attr ( pb, e, attr, val, access); diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c index b9cbe1765..ef3fa10b3 100644 --- a/ldap/servers/slapd/attr.c +++ b/ldap/servers/slapd/attr.c @@ -76,8 +76,12 @@ typedef struct slapi_attr_value_index { * find the next component of an attribute type. */ static const char * -next_comp( const char *s ) +next_comp( const char *sp ) { + char *s = (char *)sp; + if (NULL == s) { + return( NULL ); + } while ( *s && *s != ';' ) { s++; } @@ -93,14 +97,30 @@ next_comp( const char *s ) * compare two components of an attribute type. */ static int -comp_cmp( const char *s1, const char *s2 ) +comp_cmp( const char *s1p, const char *s2p ) { - while ( *s1 && *s1 != ';' && tolower( *s1 ) == tolower( *s2 ) ) { + char *s1 = (char *)s1p; + char *s2 = (char *)s2p; + if (NULL == s1) { + if (s2) { + return 1; + } + return 0; + } + if (NULL == s2) { + if (s1) { + return 1; + } + return 0; + } + while ( *s1 && (*s1 != ';') && + *s2 && (*s2 != ';') && + tolower( *s1 ) == tolower( *s2 ) ) { s1++, s2++; } if ( *s1 != *s2 ) { - if ( (*s1 == '\0' || *s1 == ';') && - (*s2 == '\0' || *s2 == ';') ) { + if ((*s1 == '\0' || *s1 == ';') && + (*s2 == '\0' || *s2 == ';')) { return( 0 ); } else { return( 1 ); @@ -115,16 +135,18 @@ slapi_attr_type_cmp( const char *a1, const char *a2, int opt ) { int rc= 0; - switch ( opt ) { - case SLAPI_TYPE_CMP_EXACT: /* compare base name + options as given */ - rc = strcasecmp( a1, a2 ); + switch ( opt ) { + case SLAPI_TYPE_CMP_EXACT: /* compare base name + options as given */ + rc = strcasecmp( a1, a2 ); break; - case SLAPI_TYPE_CMP_BASE: /* ignore options on both names - compare base names only */ + case SLAPI_TYPE_CMP_BASE: /* ignore options on both names - compare base names only */ rc = comp_cmp( a1, a2 ); - break; + break; - case SLAPI_TYPE_CMP_SUBTYPE: /* ignore options on second name that are not in first name */ + case SLAPI_TYPE_CMP_SUBTYPE: /* ignore options on second name that are not in first name */ + { + const char *b2 = a2; /* * first, check that the base types match */ @@ -134,24 +156,73 @@ slapi_attr_type_cmp( const char *a1, const char *a2, int opt ) } /* * next, for each component in a1, make sure there is a - * matching component in a2. the order must be the same, - * so we can keep looking where we left off each time in a2 + * matching component in a2. */ rc = 0; - for ( a1 = next_comp( a1 ); a1 != NULL; a1 = next_comp( a1 ) ) { - for ( a2 = next_comp( a2 ); a2 != NULL; - a2 = next_comp( a2 ) ) { - if ( comp_cmp( a1, a2 ) == 0 ) { + for ( a1 = next_comp( a1 ); a1; a1 = next_comp( a1 ) ) { + for ( b2 = next_comp( b2 ); b2; b2 = next_comp( b2 ) ) { + if ( comp_cmp( a1, b2 ) == 0 ) { break; } } - if ( a2 == NULL ) { + if ( b2 == NULL ) { rc = 1; break; } + b2 = a2; } - break; - } + break; + } + case SLAPI_TYPE_CMP_SUBTYPES: /* Both share the same subtypes */ + { + const char *b1 = a1; + const char *b2 = a2; + /* + * first, check that the base types match + */ + if (comp_cmp(a1, a2) != 0) { + rc = 1; + break; + } + /* + * next, for each component in a1, make sure there is a + * matching component in a2. + */ + rc = 0; + for (b1 = next_comp(b1); b1; b1 = next_comp(b1)) { + for (b2 = next_comp(b2); b2; b2 = next_comp(b2)) { + if (comp_cmp(b1, b2) == 0) { + break; + } + } + if (b2 == NULL) { + rc = 1; + break; + } + b2 = a2; + } + if (0 == rc) { + b1 = a1; + b2 = a2; + /* + * next, for each component in a2, make sure there is a + * matching component in a1. + */ + for (b2 = next_comp(b2); b2; b2 = next_comp(b2)) { + for (b1 = next_comp(b1); b1; b1 = next_comp(b1)) { + if (comp_cmp(b1, b2) == 0) { + break; + } + } + if (b1 == NULL) { + rc = 1; + break; + } + b1 = a1; + } + } + } /* SLAPI_TYPE_CMP_SUBTYPES */ + } /* switch (opt) */ return( rc ); } diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c index 655717fe2..ef4179d4f 100644 --- a/ldap/servers/slapd/result.c +++ b/ldap/servers/slapd/result.c @@ -1002,17 +1002,17 @@ encode_attr_2( attrs[0] = (char*)attribute_type; #if !defined(DISABLE_ACL_CHECK) - if ( plugin_call_acl_plugin (pb, e, attrs, NULL, SLAPI_ACL_READ, - ACLPLUGIN_ACCESS_READ_ON_ATTR, NULL ) != LDAP_SUCCESS ) { + if (plugin_call_acl_plugin(pb, e, attrs, NULL, SLAPI_ACL_READ, + ACLPLUGIN_ACCESS_READ_ON_ATTR, NULL) != LDAP_SUCCESS) { return( 0 ); } #endif - if ( ber_printf( ber, "{s[", returned_type ) == -1 ) { + if (ber_printf(ber, "{s[", returned_type?returned_type:attribute_type) == -1) { LDAPDebug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); ber_free( ber, 1 ); - send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, - "ber_printf type", 0, NULL ); + send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, + "ber_printf type", 0, NULL); return( -1 ); } @@ -1146,7 +1146,7 @@ static const char *idds_map_attrt_v3( /* Helper functions */ -static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_PBlock *pb,BerElement *ber,int attrsonly,int ldapversion,int *dontsendattr, int real_attrs_only, int some_named_attrs) +static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_PBlock *pb,BerElement *ber,int attrsonly,int ldapversion, int real_attrs_only, int some_named_attrs) { int i = 0; int rc = 0; @@ -1259,10 +1259,11 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_ &attr_free_flags, &item_count ); - if (0 == rc && item_count > 0) { + if ((0 == rc) && (item_count > 0)) { for(iter=0; iter<item_count; iter++) { + int skipit; if ( rc != 0 ) { /* we hit an error - we need to free all of the stuff allocated by slapi_vattr_namespace_values_get_sp */ @@ -1274,31 +1275,28 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_ name_to_return = actual_type_name[iter]; } - /* - * The dontsendattr array is used to track whether attributes - * that were explicitly requested by the client have been - * returned. Check here to see if the attribute we just - * arranged to send back was explicitly requested, and if so, - * set its dontsendattr flag so the send_specific_attrs() - * function does not return it a second time. - */ - for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) { - if ( !dontsendattr[i] && slapi_attr_type_cmp( current_type_name, attrs[i], SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) { - /* Client is also asking for an attr which is in '*', zap it. */ - dontsendattr[i]= 1; + /* If current_type_name is in attrs, we could rely on send_specific_attrs. */ + skipit = 0; + for (i = 0; attrs && attrs[i]; i++) { + if (slapi_attr_type_cmp(current_type_name, attrs[i], SLAPI_TYPE_CMP_SUBTYPE) == 0) { + skipit = 1; + break; } } - rc = encode_attr_2( pb, ber, e, values[iter], attrsonly, current_type_name, name_to_return ); - - if (rewrite_rfc1274 != 0) { - v2name = idds_map_attrt_v3(current_type_name); - if (v2name != NULL) { - /* also return values with RFC1274 attr name */ - rc = encode_attr_2(pb, ber, e, values[iter], - attrsonly, - current_type_name, - v2name); + if (!skipit) { + rc = encode_attr_2(pb, ber, e, values[iter], attrsonly, + current_type_name, name_to_return ); + + if (rewrite_rfc1274 != 0) { + v2name = idds_map_attrt_v3(current_type_name); + if (v2name != NULL) { + /* also return values with RFC1274 attr name */ + rc = encode_attr_2(pb, ber, e, values[iter], + attrsonly, + current_type_name, + v2name); + } } } @@ -1329,137 +1327,143 @@ exit: return rc; } -int send_specific_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_PBlock *pb,BerElement *ber,int attrsonly,int ldapversion,int *dontsendattr, int real_attrs_only) +/* + * attrs need to expand including the subtypes found in the entry + * e.g., if "sn" is no the attrs and 'e' has sn, sn;en, and sn;fr, + * attrs should have sn, sn;en, and sn;fr, as well. + */ +int +send_specific_attrs(Slapi_Entry *e, char **attrs, Slapi_Operation *op, + Slapi_PBlock *pb, BerElement *ber, int attrsonly, + int ldapversion, int real_attrs_only) { - int i,j = 0; + int i = 0; int rc = 0; int vattr_flags = 0; vattr_context *ctx; + char **attrs_ext = NULL; + char **my_searchattrs = NULL; - if(real_attrs_only == SLAPI_SEND_VATTR_FLAG_REALONLY) + if (real_attrs_only == SLAPI_SEND_VATTR_FLAG_REALONLY) { vattr_flags = SLAPI_REALATTRS_ONLY; - else - { + } else { vattr_flags = SLAPI_VIRTUALATTRS_REQUEST_POINTERS; if(real_attrs_only == SLAPI_SEND_VATTR_FLAG_VIRTUALONLY) vattr_flags |= SLAPI_VIRTUALATTRS_ONLY; } + + /* Create a copy of attrs with no duplicates */ + if (attrs) { + for (i = 0; attrs[i]; i++) { + if (!charray_inlist(attrs_ext, attrs[i])) { + slapi_ch_array_add(&attrs_ext, slapi_ch_strdup(attrs[i])); + slapi_ch_array_add(&my_searchattrs, slapi_ch_strdup(op->o_searchattrs[i])); + } + } + } + if (attrs_ext) { + attrs = attrs_ext; + } - for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) - { + for ( i = 0; attrs && attrs[i] != NULL; i++ ) { char *current_type_name = attrs[i]; - if(!dontsendattr[i]) { - Slapi_ValueSet **values = NULL; - int attr_free_flags = 0; - char *name_to_return = NULL; - char **actual_type_name= NULL; - int *type_name_disposition = 0; - int item_count = 0; - int iter = 0; - Slapi_DN *namespace_dn; - Slapi_Backend *backend=0; - - /* - * Here we call the computed attribute code to see whether - * the requested attribute is to be computed. - * The subroutine compute_attribute calls encode_attr on our behalf, in order - * to avoid the inefficiency of returning a complex structure - * which we'd have to free - */ - rc = compute_attribute(attrs[i],pb,ber,e,attrsonly,op->o_searchattrs[i]); - if (0 == rc) { - continue; /* Means this was a computed attr and we prcessed it OK. */ - } - if (-1 != rc) { - /* Means that some error happened */ - return rc; - } - else { - rc = 0; /* Means that we just didn't recognize this as a computed attr */ - } - - /* get the namespace dn */ - slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&backend); - namespace_dn = (Slapi_DN*)slapi_be_getsuffix(backend, 0); + Slapi_ValueSet **values = NULL; + int attr_free_flags = 0; + char *name_to_return = NULL; + char **actual_type_name= NULL; + int *type_name_disposition = 0; + int item_count = 0; + int iter = 0; + Slapi_DN *namespace_dn; + Slapi_Backend *backend=0; - /* Get the attribute value from the vattr service */ - /* ctx will be freed by attr_context_ungrok() */ - ctx = vattr_context_new ( pb ); - rc = slapi_vattr_namespace_values_get_sp( - ctx, - e, - namespace_dn, - current_type_name, - &values, - &type_name_disposition, - &actual_type_name, - vattr_flags, - &attr_free_flags, - &item_count - ); - if (0 == rc && item_count > 0) { + /* + * Here we call the computed attribute code to see whether + * the requested attribute is to be computed. + * The subroutine compute_attribute calls encode_attr on our behalf, in order + * to avoid the inefficiency of returning a complex structure + * which we'd have to free + */ + rc = compute_attribute(attrs[i], pb, ber, e, attrsonly, my_searchattrs[i]); + if (0 == rc) { + continue; /* Means this was a computed attr and we prcessed it OK. */ + } + if (-1 != rc) { + /* Means that some error happened */ + return rc; + } + else { + rc = 0; /* Means that we just didn't recognize this as a computed attr */ + } - for(iter=0; iter<item_count; iter++) - { - if ( rc != 0 ) { - /* we hit an error - we need to free all of the stuff allocated by - slapi_vattr_namespace_values_get_sp */ - slapi_vattr_values_free(&(values[iter]), &(actual_type_name[iter]), attr_free_flags); + /* get the namespace dn */ + slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&backend); + namespace_dn = (Slapi_DN*)slapi_be_getsuffix(backend, 0); + + /* Get the attribute value from the vattr service */ + /* This call handles subtype, as well. + * e.g., current_type_name: cn + * ==> + * item_count: 5; actual_type_name: cn;sub0, ..., cn;sub4 */ + /* ctx will be freed by attr_context_ungrok() */ + ctx = vattr_context_new ( pb ); + rc = slapi_vattr_namespace_values_get_sp( + ctx, + e, + namespace_dn, + current_type_name, + &values, + &type_name_disposition, + &actual_type_name, + vattr_flags, + &attr_free_flags, + &item_count + ); + if ((0 == rc) && (item_count > 0)) { + for (iter = 0; iter < item_count; iter++) { + if ( rc != 0 ) { + /* we hit an error - we need to free all of the stuff allocated by + slapi_vattr_namespace_values_get_sp */ + slapi_vattr_values_free(&(values[iter]), &(actual_type_name[iter]), attr_free_flags); + continue; + } + if (SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE == type_name_disposition[iter]) { + name_to_return = actual_type_name[iter]; + if ((iter > 0) && charray_inlist(attrs, name_to_return)) { + /* subtype retrieved by slapi_vattr_namespace_values_get_sp is + * included in the attr list. Skip the dup. */ continue; } - if (SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE == type_name_disposition[iter]) { - name_to_return = actual_type_name[iter]; - } else { - name_to_return = op->o_searchattrs[i]; - } - - /* - * The client may have specified a list of attributes - * with duplicates, 'cn cn cn'. - * We need to determine which of any duplicates take precedence - * For subtypes, the attribute which is most generic should be - * returned (since it will also trigger the return of the less - * generic attribute subtypes. - */ - for ( j = i+1; attrs[j] != NULL && dontsendattr[i]==0; j++ ) - { - if ( !dontsendattr[j] && slapi_attr_type_cmp( attrs[j], actual_type_name[iter], SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) - { - /* discover which is the more generic attribute and cancel the other*/ - int attrbase = slapi_attr_type_cmp( attrs[j], current_type_name, SLAPI_TYPE_CMP_EXACT ); - - if(attrbase >= 0) - dontsendattr[j]= 1; - else - dontsendattr[i]= 1; /* the current value is superceeded later */ - } - } - - /* we may have just cancelled ourselves so check */ - if(!dontsendattr[i]) - rc = encode_attr_2( pb, ber, e, values[iter], attrsonly, current_type_name, name_to_return ); - - slapi_vattr_values_free(&(values[iter]), &(actual_type_name[iter]), attr_free_flags); + } else { + name_to_return = my_searchattrs[i]; } - slapi_ch_free((void**)&actual_type_name); - slapi_ch_free((void**)&type_name_disposition); - slapi_ch_free((void**)&values); - if ( rc != 0 ) { - goto exit; - } + /* need to pass actual_type_name (e.g., sn;en to evaluate the ACL */ + rc = encode_attr_2(pb, ber, e, values[iter], attrsonly, + actual_type_name[iter], name_to_return); + + slapi_vattr_values_free(&(values[iter]), &(actual_type_name[iter]), attr_free_flags); + } - } else { - /* if we got here, then either values is NULL or values contains no elements - either way we can free it */ - slapi_ch_free((void**)&values); - slapi_ch_free((void**)&actual_type_name); - slapi_ch_free((void**)&type_name_disposition); - rc = 0; + slapi_ch_free((void**)&actual_type_name); + slapi_ch_free((void**)&type_name_disposition); + slapi_ch_free((void**)&values); + if ( rc != 0 ) { + goto exit; } - } + + } else { + /* if we got here, then either values is NULL or values contains no elements + either way we can free it */ + slapi_ch_free((void**)&values); + slapi_ch_free((void**)&actual_type_name); + slapi_ch_free((void**)&type_name_disposition); + rc = 0; + } } exit: + slapi_ch_array_free(attrs_ext); + slapi_ch_array_free(my_searchattrs); return rc; } @@ -1482,7 +1486,6 @@ send_ldap_search_entry_ext( BerElement *ber = NULL; int i, rc = 0, logit = 0; int alluserattrs, noattrs, some_named_attrs; - int *dontsendattr= NULL; Slapi_Operation *operation; int real_attrs_only = 0; LDAPControl **ctrlp = 0; @@ -1596,11 +1599,6 @@ send_ldap_search_entry_ext( "Accepting illegal other attributes specified with " "special \"1.1\" attribute\n", 0, 0, 0 ); } - /* - * We maintain a flag array so that we can remove requests - * for duplicate attributes. - */ - dontsendattr = (int*) slapi_ch_calloc( i+1, sizeof(int) ); } @@ -1625,12 +1623,13 @@ send_ldap_search_entry_ext( /* look through each attribute in the entry */ if ( alluserattrs ) { - rc = send_all_attrs(e,attrs,op,pb,ber,attrsonly,conn->c_ldapversion,dontsendattr, real_attrs_only, some_named_attrs); + rc = send_all_attrs(e, attrs, op, pb, ber, attrsonly, conn->c_ldapversion, + real_attrs_only, some_named_attrs); } /* if the client explicitly specified a list of attributes look through each attribute requested */ if( (rc == 0) && (attrs!=NULL) && !noattrs) { - rc = send_specific_attrs(e,attrs,op,pb,ber,attrsonly,conn->c_ldapversion,dontsendattr,real_attrs_only); + rc = send_specific_attrs(e,attrs,op,pb,ber,attrsonly,conn->c_ldapversion,real_attrs_only); } /* Append effective rights to the stream of attribute list */ @@ -1738,7 +1737,6 @@ cleanup: ldap_controls_free(searchctrlp); } ber_free( ber, 1 ); - slapi_ch_free( (void **) &dontsendattr ); LDAPDebug( LDAP_DEBUG_TRACE, "<= send_ldap_search_entry\n", 0, 0, 0 ); return( rc ); @@ -2153,7 +2151,6 @@ encode_read_entry (Slapi_PBlock *pb, Slapi_Entry *e, char **attrs, int alluserat LDAPControl **ctrlp = NULL; struct berval *bv = NULL; BerElement *ber = NULL; - int *dontsendattr = NULL; int real_attrs_only = 0; int rc = 0; @@ -2191,13 +2188,12 @@ encode_read_entry (Slapi_PBlock *pb, Slapi_Entry *e, char **attrs, int alluserat * for duplicate attributes. We also need to set o_searchattrs * for the attribute processing, as modify op's don't have search attrs. */ - dontsendattr = (int*) slapi_ch_calloc( attr_count+1, sizeof(int) ); op->o_searchattrs = attrs; /* Send all the attributes */ if ( alluserattrs ) { rc = send_all_attrs(e, attrs, op, pb, ber, 0, conn->c_ldapversion, - dontsendattr, real_attrs_only, attr_count); + real_attrs_only, attr_count); if(rc){ goto cleanup; } @@ -2205,8 +2201,7 @@ encode_read_entry (Slapi_PBlock *pb, Slapi_Entry *e, char **attrs, int alluserat /* Send a specified list of attributes */ if( attrs != NULL) { - rc = send_specific_attrs(e, attrs, op, pb, ber, 0, conn->c_ldapversion, - dontsendattr, real_attrs_only); + rc = send_specific_attrs(e, attrs, op, pb, ber, 0, conn->c_ldapversion, real_attrs_only); if(rc){ goto cleanup; } @@ -2222,7 +2217,6 @@ encode_read_entry (Slapi_PBlock *pb, Slapi_Entry *e, char **attrs, int alluserat cleanup: ber_free( ber, 1 ); - slapi_ch_free( (void **) &dontsendattr ); if(rc != 0){ return NULL; } else { diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c index 59c4afb4f..29729bb8d 100644 --- a/ldap/servers/slapd/search.c +++ b/ldap/servers/slapd/search.c @@ -246,7 +246,15 @@ do_search( Slapi_PBlock *pb ) } if ( attrs != NULL ) { - int aciin = 0; + char *normaci = slapi_attr_syntax_normalize("aci"); + int replace_aci = 0; + if (0 == strcasecmp(normaci, "aci")) { + /* normaci is identical to "aci" */ + slapi_ch_free_string(&normaci); + normaci = slapi_ch_strdup("aci"); + } else { + replace_aci = 1; + } /* * . store gerattrs if any * . add "aci" once if "*" is given @@ -274,13 +282,25 @@ do_search( Slapi_PBlock *pb ) charray_merge_nodup(&gerattrs, dummyary, 1); /* null terminate the attribute name at the @ after it has been copied */ *p = '\0'; - } - else if ( !aciin && strcasecmp(attrs[i], LDAP_ALL_USER_ATTRS) == 0 ) - { - charray_add(&attrs, slapi_attr_syntax_normalize("aci")); - aciin = 1; + } else if (strcmp(attrs[i], LDAP_ALL_USER_ATTRS /* '*' */) == 0) { + if (!charray_inlist(attrs, normaci)) { + charray_add(&attrs, normaci); /* consumed */ + normaci = NULL; + } + } else if (replace_aci && (strcasecmp(attrs[i], "aci") == 0)) { + slapi_ch_free_string(&attrs[i]); + if (charray_inlist(attrs, normaci)) { /* attrlist: "*" "aci" */ + int j = i; + for (; attrs[j]; j++) { /* Shift the rest by 1 */ + attrs[j] = attrs[j+1]; + } + } else { /* attrlist: "aci" "*" */ + attrs[i] = normaci; /* consumed */ + normaci = NULL; + } } } + slapi_ch_free_string(&normaci); if (config_get_return_orig_type_switch()) { /* return the original type, e.g., "sn (surname)" */ @@ -376,6 +396,7 @@ free_and_return:; if ( !psearch || rc != 0 ) { slapi_ch_free_string(&fstr); slapi_filter_free( filter, 1 ); + slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, &attrs ); charray_free( attrs ); /* passing NULL is fine */ charray_free( gerattrs ); /* passing NULL is fine */ /* diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index f3856ad63..cfac7c60b 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -4091,6 +4091,7 @@ int slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v ); * \arg #SLAPI_TYPE_CMP_EXACT * \arg #SLAPI_TYPE_CMP_BASE * \arg #SLAPI_TYPE_CMP_SUBTYPE + * \arg #SLAPI_TYPE_CMP_SUBTYPES * \return \c 0 if the type names are equal. * \return A non-zero value if the type names are not equal. * \see slapi_attr_type2plugin() @@ -4122,6 +4123,13 @@ int slapi_attr_type_cmp( const char *t1, const char *t2, int opt ); */ #define SLAPI_TYPE_CMP_SUBTYPE 2 +/** + * Compare types including subtypes in the both args. + * + * \see slapi_attr_type_cmp() + */ +#define SLAPI_TYPE_CMP_SUBTYPES 3 + /** * Compare two attribute names to determine if they represent the same value. *
0
2afb0e3a78bf4706ba7baab9136fa8c1cf1ba973
389ds/389-ds-base
Issue 5938 - Attribute Names changed to lowercase after adding the Attributes (#5940) Bug Description: When working with the web console to edit the attributes with capital and lowercase letters in their names. The capital letters within the names of an attribute change whenever the attributes are added to an object class. Fix Description: Presevrer the case in both UI and CLI when doing edit/add/list operations. Fixes: https://github.com/389ds/389-ds-base/issues/5938 Reviewed by: @progier389 (Thanks!)
commit 2afb0e3a78bf4706ba7baab9136fa8c1cf1ba973 Author: Simon Pichugin <[email protected]> Date: Wed Oct 4 16:58:05 2023 -0700 Issue 5938 - Attribute Names changed to lowercase after adding the Attributes (#5940) Bug Description: When working with the web console to edit the attributes with capital and lowercase letters in their names. The capital letters within the names of an attribute change whenever the attributes are added to an object class. Fix Description: Presevrer the case in both UI and CLI when doing edit/add/list operations. Fixes: https://github.com/389ds/389-ds-base/issues/5938 Reviewed by: @progier389 (Thanks!) diff --git a/src/cockpit/389-console/src/lib/schema/schemaTables.jsx b/src/cockpit/389-console/src/lib/schema/schemaTables.jsx index b3a7e8699..c5f5242f7 100644 --- a/src/cockpit/389-console/src/lib/schema/schemaTables.jsx +++ b/src/cockpit/389-console/src/lib/schema/schemaTables.jsx @@ -760,7 +760,7 @@ class MatchingRulesTable extends React.Component { let name = ""; // Check for matches of all the parts if (row.names.length > 0) { - name = row.name[0].toLowerCase(); + name = row.name[0]; } if (val !== "" && name.indexOf(val) === -1 && row.oid[0].indexOf(val) === -1 && diff --git a/src/lib389/lib389/schema.py b/src/lib389/lib389/schema.py index fba117058..ece018ad4 100755 --- a/src/lib389/lib389/schema.py +++ b/src/lib389/lib389/schema.py @@ -128,10 +128,10 @@ class Schema(DSLdapObject): for obj in results: obj_i = vars(object_model(obj)) if len(obj_i["names"]) == 1: - obj_i['name'] = obj_i['names'][0].lower() + obj_i['name'] = obj_i['names'][0] obj_i['aliases'] = None elif len(obj_i["names"]) > 1: - obj_i['name'] = obj_i['names'][0].lower() + obj_i['name'] = obj_i['names'][0] obj_i['aliases'] = obj_i['names'][1:] else: obj_i['name'] = "" @@ -641,7 +641,7 @@ class SchemaLegacy(object): results.getValues('objectClasses')] for oc in objectclasses: # Add normalized name for sorting - oc['name'] = oc['names'][0].lower() + oc['name'] = oc['names'][0] objectclasses = sorted(objectclasses, key=itemgetter('name')) result = {'type': 'list', 'items': objectclasses} return dump_json(result) @@ -663,7 +663,7 @@ class SchemaLegacy(object): results.getValues('attributeTypes')] for attr in attributetypes: # Add normalized name for sorting - attr['name'] = attr['names'][0].lower() + attr['name'] = attr['names'][0] attributetypes = sorted(attributetypes, key=itemgetter('name')) result = {'type': 'list', 'items': attributetypes} return dump_json(result) @@ -683,7 +683,7 @@ class SchemaLegacy(object): for mr in matchingRules: # Add normalized name for sorting if mr['names']: - mr['name'] = mr['names'][0].lower() + mr['name'] = mr['names'][0] else: mr['name'] = "" matchingRules = sorted(matchingRules, key=itemgetter('name')) @@ -768,7 +768,6 @@ class SchemaLegacy(object): # filter our set of all attribute types. objectclasses = self.get_objectclasses() attributetypes = self.get_attributetypes() - attributetypename = attributetypename.lower() attributetype = [at for at in attributetypes if attributetypename.lower() in @@ -795,9 +794,9 @@ class SchemaLegacy(object): must = [vars(oc) for oc in must] # Add normalized 'name' for sorting for oc in may: - oc['name'] = oc['names'][0].lower() + oc['name'] = oc['names'][0] for oc in must: - oc['name'] = oc['names'][0].lower() + oc['name'] = oc['names'][0] may = sorted(may, key=itemgetter('name')) must = sorted(must, key=itemgetter('name')) result = {'type': 'schema',
0
ff132b866b1637e53737d3bac8ae98a77425e847
389ds/389-ds-base
Resolves: bug 476891 Bug Description: Replication: Server to Server Connection Error: SASL(-1): generic failure: All-whitespace username. Reviewed by: nkinder (Thanks!) Fix Description: 1) SASL/DIGEST-MD5 needs both username and authid 2) The username and authid in this context are always a bind DN - they must have the "dn:" prefix in order for the SASL mapping to work 3) gssapi (kerberos) sets both username and authid to NULL Platforms tested: RHEL5 Flag Day: no Doc impact: no
commit ff132b866b1637e53737d3bac8ae98a77425e847 Author: Rich Megginson <[email protected]> Date: Wed Dec 17 20:47:36 2008 +0000 Resolves: bug 476891 Bug Description: Replication: Server to Server Connection Error: SASL(-1): generic failure: All-whitespace username. Reviewed by: nkinder (Thanks!) Fix Description: 1) SASL/DIGEST-MD5 needs both username and authid 2) The username and authid in this context are always a bind DN - they must have the "dn:" prefix in order for the SASL mapping to work 3) gssapi (kerberos) sets both username and authid to NULL Platforms tested: RHEL5 Flag Day: no Doc impact: no diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c index 648775066..2b6ac7d62 100644 --- a/ldap/servers/slapd/util.c +++ b/ldap/servers/slapd/util.c @@ -1247,6 +1247,7 @@ ldap_sasl_set_interact_vals(LDAP *ld, const char *mech, const char *authid, const char *realm) { ldapSaslInteractVals *vals = NULL; + char *idprefix = ""; vals = (ldapSaslInteractVals *) slapi_ch_calloc(1, sizeof(ldapSaslInteractVals)); @@ -1261,8 +1262,12 @@ ldap_sasl_set_interact_vals(LDAP *ld, const char *mech, const char *authid, ldap_get_option(ld, LDAP_OPT_X_SASL_MECH, &vals->mech); } + if (vals->mech && !strcasecmp(vals->mech, "DIGEST-MD5")) { + idprefix = "dn:"; /* prefix name and id with this string */ + } + if (authid) { /* use explicit passed in value */ - vals->authid = slapi_ch_strdup(authid); + vals->authid = slapi_ch_smprintf("%s%s", idprefix, authid); } else { /* use option value if any */ ldap_get_option(ld, LDAP_OPT_X_SASL_AUTHCID, &vals->authid); if (!vals->authid) { @@ -1272,7 +1277,7 @@ ldap_sasl_set_interact_vals(LDAP *ld, const char *mech, const char *authid, } if (username) { /* use explicit passed in value */ - vals->username = slapi_ch_strdup(username); + vals->username = slapi_ch_smprintf("%s%s", idprefix, username); } else { /* use option value if any */ ldap_get_option(ld, LDAP_OPT_X_SASL_AUTHZID, &vals->username); if (!vals->username) { /* use default sasl value */ @@ -1413,7 +1418,7 @@ slapd_ldap_sasl_interactive_bind( int tries = 0; while (tries < 2) { - void *defaults = ldap_sasl_set_interact_vals(ld, mech, NULL, bindid, + void *defaults = ldap_sasl_set_interact_vals(ld, mech, bindid, bindid, creds, NULL); /* have to first set the defaults used by the callback function */ /* call the bind function */ @@ -1941,8 +1946,9 @@ set_krb5_creds( cc_env_name); } - /* use NULL as username */ + /* use NULL as username and authid */ slapi_ch_free_string(&vals->username); + slapi_ch_free_string(&vals->authid); cleanup: krb5_free_unparsed_name(ctx, princ_name);
0
cc8ab6e3dda8d8bf0715a56dce31011a0ebd4c4a
389ds/389-ds-base
Ticket 48765 - Change default ports for standalone topology Bug description: Some ports defined in _constants.py are invalid, because they're bigger than 65535. Fix description: Change default ports for standalone topology with a range of ports 38930-38969. https://fedorahosted.org/389/ticket/48765 Author: vashirov Reviewed by: mreynolds (Thanks!)
commit cc8ab6e3dda8d8bf0715a56dce31011a0ebd4c4a Author: Viktor Ashirov <[email protected]> Date: Fri Mar 11 16:53:06 2016 +0100 Ticket 48765 - Change default ports for standalone topology Bug description: Some ports defined in _constants.py are invalid, because they're bigger than 65535. Fix description: Change default ports for standalone topology with a range of ports 38930-38969. https://fedorahosted.org/389/ticket/48765 Author: vashirov Reviewed by: mreynolds (Thanks!) diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py index 5fdbe7b09..e2c835fda 100644 --- a/src/lib389/lib389/_constants.py +++ b/src/lib389/lib389/_constants.py @@ -231,184 +231,184 @@ PASSWORD = 'password' # Standalone topology - 10 instances HOST_STANDALONE = LOCALHOST -PORT_STANDALONE = 31389 +PORT_STANDALONE = 38931 SERVERID_STANDALONE = 'standalone' HOST_STANDALONE2 = LOCALHOST -PORT_STANDALONE2 = 32389 +PORT_STANDALONE2 = 38932 SERVERID_STANDALONE2 = 'standalone_2' HOST_STANDALONE3 = LOCALHOST -PORT_STANDALONE3 = 33389 +PORT_STANDALONE3 = 38933 SERVERID_STANDALONE3 = 'standalone_3' HOST_STANDALONE4 = LOCALHOST -PORT_STANDALONE4 = 34389 +PORT_STANDALONE4 = 38934 SERVERID_STANDALONE4 = 'standalone_4' HOST_STANDALONE5 = LOCALHOST -PORT_STANDALONE5 = 35389 +PORT_STANDALONE5 = 38935 SERVERID_STANDALONE5 = 'standalone_5' HOST_STANDALONE6 = LOCALHOST -PORT_STANDALONE6 = 36389 +PORT_STANDALONE6 = 38936 SERVERID_STANDALONE6 = 'standalone_6' HOST_STANDALONE7 = LOCALHOST -PORT_STANDALONE7 = 37389 +PORT_STANDALONE7 = 38937 SERVERID_STANDALONE7 = 'standalone_7' HOST_STANDALONE8 = LOCALHOST -PORT_STANDALONE8 = 38389 +PORT_STANDALONE8 = 38939 SERVERID_STANDALONE8 = 'standalone_8' HOST_STANDALONE9 = LOCALHOST -PORT_STANDALONE9 = 39389 +PORT_STANDALONE9 = 38939 SERVERID_STANDALONE9 = 'standalone_9' HOST_STANDALONE10 = LOCALHOST -PORT_STANDALONE10 = 30389 +PORT_STANDALONE10 = 38930 SERVERID_STANDALONE10 = 'standalone_10' # Replication topology: 10 masters, 10 hubs, 10 consumers HOST_MASTER_1 = LOCALHOST -PORT_MASTER_1 = 41389 +PORT_MASTER_1 = 38941 SERVERID_MASTER_1 = 'master_1' REPLICAID_MASTER_1 = 1 HOST_MASTER_2 = LOCALHOST -PORT_MASTER_2 = 42389 +PORT_MASTER_2 = 38942 SERVERID_MASTER_2 = 'master_2' REPLICAID_MASTER_2 = 2 HOST_MASTER_3 = LOCALHOST -PORT_MASTER_3 = 43389 +PORT_MASTER_3 = 38943 SERVERID_MASTER_3 = 'master_3' REPLICAID_MASTER_3 = 3 HOST_MASTER_4 = LOCALHOST -PORT_MASTER_4 = 44389 +PORT_MASTER_4 = 38944 SERVERID_MASTER_4 = 'master_4' REPLICAID_MASTER_4 = 4 HOST_MASTER_5 = LOCALHOST -PORT_MASTER_5 = 45389 +PORT_MASTER_5 = 38945 SERVERID_MASTER_5 = 'master_5' REPLICAID_MASTER_5 = 5 HOST_MASTER_6 = LOCALHOST -PORT_MASTER_6 = 46389 +PORT_MASTER_6 = 38946 SERVERID_MASTER_6 = 'master_6' REPLICAID_MASTER_6 = 6 HOST_MASTER_7 = LOCALHOST -PORT_MASTER_7 = 47389 +PORT_MASTER_7 = 38947 SERVERID_MASTER_7 = 'master_7' REPLICAID_MASTER_7 = 7 HOST_MASTER_8 = LOCALHOST -PORT_MASTER_8 = 48389 +PORT_MASTER_8 = 38948 SERVERID_MASTER_8 = 'master_8' REPLICAID_MASTER_8 = 8 HOST_MASTER_9 = LOCALHOST -PORT_MASTER_9 = 49389 +PORT_MASTER_9 = 38949 SERVERID_MASTER_9 = 'master_9' REPLICAID_MASTER_9 = 9 HOST_MASTER_10 = LOCALHOST -PORT_MASTER_10 = 40389 +PORT_MASTER_10 = 38940 SERVERID_MASTER_10 = 'master_10' REPLICAID_MASTER_10 = 10 HOST_HUB_1 = LOCALHOST -PORT_HUB_1 = 51389 +PORT_HUB_1 = 38951 SERVERID_HUB_1 = 'hub_1' REPLICAID_HUB_1 = 65535 HOST_HUB_2 = LOCALHOST -PORT_HUB_2 = 52389 +PORT_HUB_2 = 38952 SERVERID_HUB_2 = 'hub_2' REPLICAID_HUB_2 = 65535 HOST_HUB_3 = LOCALHOST -PORT_HUB_3 = 53389 +PORT_HUB_3 = 38953 SERVERID_HUB_3 = 'hub_3' REPLICAID_HUB_3 = 65535 HOST_HUB_4 = LOCALHOST -PORT_HUB_4 = 54389 +PORT_HUB_4 = 38954 SERVERID_HUB_4 = 'hub_4' REPLICAID_HUB_4 = 65535 HOST_HUB_5 = LOCALHOST -PORT_HUB_5 = 55389 +PORT_HUB_5 = 38955 SERVERID_HUB_5 = 'hub_5' REPLICAID_HUB_5 = 65535 HOST_HUB_6 = LOCALHOST -PORT_HUB_6 = 56389 +PORT_HUB_6 = 38956 SERVERID_HUB_6 = 'hub_6' REPLICAID_HUB_6 = 65535 HOST_HUB_7 = LOCALHOST -PORT_HUB_7 = 57389 +PORT_HUB_7 = 38957 SERVERID_HUB_7 = 'hub_7' REPLICAID_HUB_7 = 65535 HOST_HUB_8 = LOCALHOST -PORT_HUB_8 = 58389 +PORT_HUB_8 = 38958 SERVERID_HUB_8 = 'hub_8' REPLICAID_HUB_8 = 65535 HOST_HUB_9 = LOCALHOST -PORT_HUB_9 = 59389 +PORT_HUB_9 = 38959 SERVERID_HUB_9 = 'hub_9' REPLICAID_HUB_9 = 65535 HOST_HUB_10 = LOCALHOST -PORT_HUB_10 = 50389 +PORT_HUB_10 = 38950 SERVERID_HUB_10 = 'hub_10' REPLICAID_HUB_10 = 65535 HOST_CONSUMER_1 = LOCALHOST -PORT_CONSUMER_1 = 61389 +PORT_CONSUMER_1 = 38961 SERVERID_CONSUMER_1 = 'consumer_1' HOST_CONSUMER_2 = LOCALHOST -PORT_CONSUMER_2 = 62389 +PORT_CONSUMER_2 = 38962 SERVERID_CONSUMER_2 = 'consumer_2' HOST_CONSUMER_3 = LOCALHOST -PORT_CONSUMER_3 = 63389 +PORT_CONSUMER_3 = 38963 SERVERID_CONSUMER_3 = 'consumer_3' HOST_CONSUMER_4 = LOCALHOST -PORT_CONSUMER_4 = 64389 +PORT_CONSUMER_4 = 38964 SERVERID_CONSUMER_4 = 'consumer_4' HOST_CONSUMER_5 = LOCALHOST -PORT_CONSUMER_5 = 65389 +PORT_CONSUMER_5 = 38965 SERVERID_CONSUMER_5 = 'consumer_5' HOST_CONSUMER_6 = LOCALHOST -PORT_CONSUMER_6 = 66389 +PORT_CONSUMER_6 = 38966 SERVERID_CONSUMER_6 = 'consumer_6' HOST_CONSUMER_7 = LOCALHOST -PORT_CONSUMER_7 = 67389 +PORT_CONSUMER_7 = 38967 SERVERID_CONSUMER_7 = 'consumer_7' HOST_CONSUMER_8 = LOCALHOST -PORT_CONSUMER_8 = 68389 +PORT_CONSUMER_8 = 38968 SERVERID_CONSUMER_8 = 'consumer_8' HOST_CONSUMER_9 = LOCALHOST -PORT_CONSUMER_9 = 69389 +PORT_CONSUMER_9 = 38969 SERVERID_CONSUMER_9 = 'consumer_9' HOST_CONSUMER_10 = LOCALHOST -PORT_CONSUMER_10 = 60389 +PORT_CONSUMER_10 = 38960 SERVERID_CONSUMER_10 = 'consumer_10' # Each defined instance above must be added in that list
0
281c027117dd5bdc0914d2606ef53f4032a1899d
389ds/389-ds-base
Issue 6141 - freeipa test_topology_TestCASpecificRUVs is failing (#6144) On lmdb, vlv search using a value instead of range may fail (set target on first record instead of smallest record whose key is greater of equal to the wanted value). The reason is that a test is inverted when walking the cursor to find the record position so the loop end after first iteration. Also fix a coverity scan warning Issue: #6141 Reviewed by: @tbordaz
commit 281c027117dd5bdc0914d2606ef53f4032a1899d Author: progier389 <[email protected]> Date: Wed Apr 10 15:10:22 2024 +0200 Issue 6141 - freeipa test_topology_TestCASpecificRUVs is failing (#6144) On lmdb, vlv search using a value instead of range may fail (set target on first record instead of smallest record whose key is greater of equal to the wanted value). The reason is that a test is inverted when walking the cursor to find the record position so the loop end after first iteration. Also fix a coverity scan warning Issue: #6141 Reviewed by: @tbordaz diff --git a/dirsrvtests/tests/suites/vlv/regression_test.py b/dirsrvtests/tests/suites/vlv/regression_test.py index ca13a8837..873eada20 100644 --- a/dirsrvtests/tests/suites/vlv/regression_test.py +++ b/dirsrvtests/tests/suites/vlv/regression_test.py @@ -900,6 +900,45 @@ def test_vlv_scope_one_on_two_backends(vlv_setup_with_two_backend): check_vlv_search(conn, offset=6, basedn=tmpd['suffix']) +def test_vlv_by_keyword(freeipa): + """Test vlv search by keyword instead of by range + + :id: 0e74bbf6-f5c6-11ee-b086-482ae39447e5 + :setup: Standalone instance with freeipa test config. + :steps: + 1. Perform a vlv search returning the six entries with + highest serialno that is lesser or equal than "0210" + 2. Check that the 6 expected entries are returned. + :expectedresults: + 1. Should Success. + 2. Should Success. + """ + + inst = freeipa.standalone + conn = open_new_ldapi_conn(inst.serverid) + basedn = 'ou=certificateRepository,ou=ca,o=ipaca' + + vlv_control = VLVRequestControl(criticality=True, + before_count=5, + after_count=0, + offset=None, + content_count=None, + greater_than_or_equal='0211', + context_id=None) + + sss_control = SSSRequestControl(criticality=True, ordering_rules=['serialno']) + result = conn.search_ext_s( + base=basedn, + scope=ldap.SCOPE_ONELEVEL, + filterstr='(certStatus=*)', + serverctrls=[vlv_control, sss_control] + ) + assert len(result) == 6 + dns = [ dn for dn,entry in result ] + for idx in range(6,12): + assert f'cn={idx},ou=certificateRepository,ou=ca,o=ipaca' in dns + + if __name__ == "__main__": # Run isolated # -s for DEBUG mode diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c index 848a09fa3..457c5ed60 100644 --- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c +++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c @@ -2338,17 +2338,17 @@ int dbmdb_cursor_get_recno(dbi_cursor_t *cursor, MDB_val *dbmdb_key, MDB_val *db rc = MDB_CURSOR_OPEN(mdb_cursor_txn(cursor->cur), mdb_cursor_dbi(cursor->cur), &newcur); } if (rc == 0) { - rc = MDB_CURSOR_GET(newcur, &rce->key, &rce-> data, MDB_SET); + rc = MDB_CURSOR_GET(newcur, &rce->key, &rce->data, MDB_SET); } while (rc == 0) { cmpres = dbmdb_cmp_dbi_record(mdb_cursor_dbi(cursor->cur), &curpos_key, &curpos_data, &rce->key, &rce->data); - if (cmpres >= 0) { + if (cmpres <= 0) { break; } rce->recno++; rc = MDB_CURSOR_GET(newcur, &rce->key, &rce->data, MDB_NEXT); } - if (cmpres > 0) { + if (cmpres < 0) { rc = MDB_NOTFOUND; } if (rc == 0) { diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c index 0290e38ec..2a7747dfa 100644 --- a/ldap/servers/slapd/back-ldbm/vlv.c +++ b/ldap/servers/slapd/back-ldbm/vlv.c @@ -384,7 +384,9 @@ vlv_rebuild_scope_filter(backend *be) (void *)plugin_get_default_component_id(), 0); slapi_pblock_set(pb, SLAPI_BACKEND, be); slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database); - slapi_pblock_set(pb, SLAPI_TXN, txn->back_txn_txn); + if (txn) { + slapi_pblock_set(pb, SLAPI_TXN, txn->back_txn_txn); + } slapi_rwlock_wrlock(be->vlvSearchList_lock); for (p = be->vlvSearchList; p != NULL; p = p->vlv_next) {
0
adc4cf311c9d4d191372273cb5296b118b690e61
389ds/389-ds-base
Ticket #48822 - (389-ds-base-1.3.5) Fixing coverity issues. Description: Invalid Dereference - FORWARD_NULL: slapd/schema.c:4758:5: deref_parm: Directly dereferencing parameter "oc". ==> Fixed so that null oc never be passed to parse_objclass_str. - FORWARD_NULL: slapd/pw.c:2880: var_deref_op: Dereferencing null pointer "e". ==> Fixed the logic error. - REVERSE_INULL: slapd/extendop.c:384: check_after_deref: Null-checking "be_pb" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. ==> Removed the unnecessary NULL check. - FORWARD_NULL: slapd/entry.c:2118:2: deref_parm: Directly dereferencing parameter "e". ==> Fixed so that null e never be passed to referint_validate_config. - FORWARD_NULL: slapd/back-ldbm/ldif2ldbm.c:1166: var_deref_op: Dereferencing null pointer "be". ==> Added a null check for be. - REVERSE_INULL: plugins/acl/aclutil.c:221: check_after_deref: Null-checking "dn" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. ==> Moved the null dn check prior to all the dn access. https://fedorahosted.org/389/ticket/48822 Reviewed by [email protected] (Thank you, William!!)
commit adc4cf311c9d4d191372273cb5296b118b690e61 Author: Noriko Hosoi <[email protected]> Date: Thu May 5 14:05:00 2016 -0700 Ticket #48822 - (389-ds-base-1.3.5) Fixing coverity issues. Description: Invalid Dereference - FORWARD_NULL: slapd/schema.c:4758:5: deref_parm: Directly dereferencing parameter "oc". ==> Fixed so that null oc never be passed to parse_objclass_str. - FORWARD_NULL: slapd/pw.c:2880: var_deref_op: Dereferencing null pointer "e". ==> Fixed the logic error. - REVERSE_INULL: slapd/extendop.c:384: check_after_deref: Null-checking "be_pb" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. ==> Removed the unnecessary NULL check. - FORWARD_NULL: slapd/entry.c:2118:2: deref_parm: Directly dereferencing parameter "e". ==> Fixed so that null e never be passed to referint_validate_config. - FORWARD_NULL: slapd/back-ldbm/ldif2ldbm.c:1166: var_deref_op: Dereferencing null pointer "be". ==> Added a null check for be. - REVERSE_INULL: plugins/acl/aclutil.c:221: check_after_deref: Null-checking "dn" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. ==> Moved the null dn check prior to all the dn access. https://fedorahosted.org/389/ticket/48822 Reviewed by [email protected] (Thank you, William!!) diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c index b0e9d715c..5915e8852 100644 --- a/ldap/servers/plugins/acl/aclutil.c +++ b/ldap/servers/plugins/acl/aclutil.c @@ -217,8 +217,12 @@ aclutil_print_err (int rv , const Slapi_DN *sdn, const struct berval* val, { size_t newsize; const char *dn = slapi_sdn_get_dn(sdn); - newsize = strlen(dn) + strlen(str) + 200; - if (dn && (newsize > sizeof(line))) { + if (dn) { + newsize = strlen(dn) + strlen(str) + 200; + } else { + newsize = strlen(str) + 208; /* for "NULL" */ + } + if (newsize > sizeof(line)) { /* * if (str_length + dn_length + 200 char message) > (BUFSIZ + 200) line * we have to make space for a bigger line... diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c index 047851524..5885a7636 100644 --- a/ldap/servers/plugins/referint/referint.c +++ b/ldap/servers/plugins/referint/referint.c @@ -1699,6 +1699,11 @@ referint_validate_config(Slapi_PBlock *pb) slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn); slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &pre_entry); + if (!pre_entry) { + slapi_log_error(SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM, "referint_validate_config: Null pre op entry.\n"); + rc = LDAP_OPERATIONS_ERROR; + goto bail; + } if (referint_sdn_config_cmp(sdn) == 0 && slapi_sdn_compare(sdn, referint_get_plugin_area()) ){ /* diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c index c59d55913..0b2eab271 100644 --- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c +++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c @@ -1163,10 +1163,14 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb ) slapi_pblock_set(pb, SLAPI_BACKEND, be); } else { slapi_pblock_get(pb, SLAPI_BACKEND, &be); + if (!be) { + LDAPDebug0Args(LDAP_DEBUG_ANY, "No backend\n"); + return_value = -1; + goto bye; + } inst = (ldbm_instance *)be->be_instance_info; - - if (NULL == inst) { - LDAPDebug(LDAP_DEBUG_ANY, "Unknown ldbm instance\n", 0, 0, 0); + if (!inst) { + LDAPDebug0Args(LDAP_DEBUG_ANY, "Unknown ldbm instance\n"); return_value = -1; goto bye; } diff --git a/ldap/servers/slapd/extendop.c b/ldap/servers/slapd/extendop.c index 5154602f1..0a6a739f0 100644 --- a/ldap/servers/slapd/extendop.c +++ b/ldap/servers/slapd/extendop.c @@ -381,9 +381,7 @@ do_extended( Slapi_PBlock *pb ) slapi_log_error(SLAPI_LOG_FATAL, NULL, "extendop.c abort with result %d \n", txn_rc); } } /* txn_rc */ - if (be_pb != NULL) { - slapi_pblock_destroy(be_pb); /* Clean up after ourselves */ - } + slapi_pblock_destroy(be_pb); /* Clean up after ourselves */ } /* if be */ } diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c index 703c9e9c7..17938b579 100644 --- a/ldap/servers/slapd/pw.c +++ b/ldap/servers/slapd/pw.c @@ -2879,7 +2879,7 @@ add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e) char *shexp = NULL; int rc = 0; - if (!e && !*e) { + if (!e || !*e) { return rc; } dn = slapi_entry_get_ndn(*e); diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c index 52c1495ef..7689aa915 100644 --- a/ldap/servers/slapd/schema.c +++ b/ldap/servers/slapd/schema.c @@ -4506,6 +4506,9 @@ parse_objclass_str ( const char *input, struct objclass **oc, char *errorbuf, int i, j; int rc = 0; + if (!oc) { + return LDAP_PARAM_ERROR; + } if (config_get_enquote_sup_oc()) { parser_flags |= LDAP_SCHEMA_ALLOW_QUOTED; } else if (getenv("LDAP_SCHEMA_ALLOW_QUOTED")) {
0
6941dbd1516d892d8a19d4de9c344248011cc35d
389ds/389-ds-base
Ticket 48163 - Read schema from multiple locations Bug Description: We provide system schema that should not be altered or changed. This schema tends to be version specific to ds versions also. As a result, it would be good to move system schema to /usr, and keep custom or changing schema in /etc. Fix Description: This adds a new configure option, systemschemadir, which provides the location of system schema to the schema.c file. Additionally, get priority filelist is altered to be able to prioritise over a number of directories to form the filelist. This leaves the only schema element in /etc as /etc/dirsrv/schema/99user.ldif https://fedorahosted.org/389/ticket/48163 Author: wibrown Review by: mreynolds (Thanks!)
commit 6941dbd1516d892d8a19d4de9c344248011cc35d Author: William Brown <[email protected]> Date: Tue May 3 14:23:26 2016 +1000 Ticket 48163 - Read schema from multiple locations Bug Description: We provide system schema that should not be altered or changed. This schema tends to be version specific to ds versions also. As a result, it would be good to move system schema to /usr, and keep custom or changing schema in /etc. Fix Description: This adds a new configure option, systemschemadir, which provides the location of system schema to the schema.c file. Additionally, get priority filelist is altered to be able to prioritise over a number of directories to form the filelist. This leaves the only schema element in /etc as /etc/dirsrv/schema/99user.ldif https://fedorahosted.org/389/ticket/48163 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/Makefile.am b/Makefile.am index 9cf30eee9..a140f73ca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,8 @@ endif PATH_DEFINES = -DLOCALSTATEDIR="\"$(localstatedir)\"" -DSYSCONFDIR="\"$(sysconfdir)\"" \ -DLIBDIR="\"$(libdir)\"" -DBINDIR="\"$(bindir)\"" \ -DDATADIR="\"$(datadir)\"" -DDOCDIR="\"$(docdir)\"" \ - -DSBINDIR="\"$(sbindir)\"" -DPLUGINDIR="\"$(serverplugindir)\"" -DTEMPLATEDIR="\"$(sampledatadir)\"" + -DSBINDIR="\"$(sbindir)\"" -DPLUGINDIR="\"$(serverplugindir)\"" \ + -DTEMPLATEDIR="\"$(sampledatadir)\"" -DSYSTEMSCHEMADIR="\"$(systemschemadir)\"" AM_CPPFLAGS = $(DEBUG_DEFINES) $(GCCSEC_DEFINES) $(ASAN_DEFINES) $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES) $(SYSTEMD_DEFINES) PLUGIN_CPPFLAGS = $(AM_CPPFLAGS) @openldap_inc@ @ldapsdk_inc@ @nss_inc@ @nspr_inc@ @systemd_inc@ @@ -184,6 +185,7 @@ selinux-built/dirsrv.fc: selinux-built prefixdir = @prefixdir@ configdir = $(sysconfdir)@configdir@ sampledatadir = $(datadir)@sampledatadir@ +systemschemadir = $(datadir)@systemschemadir@ propertydir = $(datadir)@propertydir@ schemadir = $(sysconfdir)@schemadir@ serverdir = $(libdir)@serverdir@ @@ -552,7 +554,7 @@ sampledata_DATA = ldap/admin/src/scripts/DSSharedLib \ $(srcdir)/ldap/schema/60sendmail.ldif \ $(LIBPRESENCE_SCHEMA) -schema_DATA = $(srcdir)/ldap/schema/00core.ldif \ +systemschema_DATA = $(srcdir)/ldap/schema/00core.ldif \ $(srcdir)/ldap/schema/01core389.ldif \ $(srcdir)/ldap/schema/02common.ldif \ $(srcdir)/ldap/schema/05rfc2927.ldif \ @@ -585,9 +587,10 @@ schema_DATA = $(srcdir)/ldap/schema/00core.ldif \ $(srcdir)/ldap/schema/60sudo.ldif \ $(srcdir)/ldap/schema/60trust.ldif \ $(srcdir)/ldap/schema/60nss-ldap.ldif \ - $(srcdir)/ldap/schema/99user.ldif \ $(LIBACCTPOLICY_SCHEMA) +schema_DATA = $(srcdir)/ldap/schema/99user.ldif + sbin_SCRIPTS = ldap/admin/src/scripts/setup-ds.pl \ ldap/admin/src/scripts/migrate-ds.pl \ ldap/admin/src/scripts/remove-ds.pl \ @@ -1822,6 +1825,7 @@ fixupcmd = sed \ -e 's,@infdir\@,$(infdir),g' \ -e 's,@mibdir\@,$(mibdir),g' \ -e 's,@templatedir\@,$(sampledatadir),g' \ + -e 's,@systemschemadir\@,$(systemschemadir),g' \ -e 's,@package_name\@,$(PACKAGE_NAME),g' \ -e 's,@instconfigdir\@,$(instconfigdir),g' \ -e 's,@enable_ldapi\@,$(enable_ldapi),g' \ @@ -1893,6 +1897,7 @@ fixupcmd = sed \ -e 's,@infdir\@,$(infdir),g' \ -e 's,@mibdir\@,$(mibdir),g' \ -e 's,@templatedir\@,$(sampledatadir),g' \ + -e 's,@systemschemadir\@,$(systemschemadir),g' \ -e 's,@package_name\@,$(PACKAGE_NAME),g' \ -e 's,@instconfigdir\@,$(instconfigdir),g' \ -e 's,@enable_ldapi\@,$(enable_ldapi),g' \ diff --git a/configure.ac b/configure.ac index 57b5b2936..d07e00fb0 100644 --- a/configure.ac +++ b/configure.ac @@ -297,6 +297,8 @@ if test "$with_fhs_opt" = "yes"; then # relative to datadir sampledatadir=/data # relative to datadir + systemschemadir=/schema + # relative to datadir scripttemplatedir=/script-templates # relative to datadir updatedir=/updates @@ -331,6 +333,8 @@ else # relative to datadir sampledatadir=/$PACKAGE_NAME/data # relative to datadir + systemschemadir=/$PACKAGE_NAME/schema + # relative to datadir scripttemplatedir=/$PACKAGE_NAME/script-templates # relative to datadir updatedir=/$PACKAGE_NAME/updates @@ -424,6 +428,7 @@ fi AC_SUBST(prefixdir) AC_SUBST(configdir) AC_SUBST(sampledatadir) +AC_SUBST(systemschemadir) AC_SUBST(propertydir) AC_SUBST(schemadir) AC_SUBST(serverdir) diff --git a/ldap/servers/slapd/getfilelist.c b/ldap/servers/slapd/getfilelist.c index 0884045d1..3b3f02f29 100644 --- a/ldap/servers/slapd/getfilelist.c +++ b/ldap/servers/slapd/getfilelist.c @@ -38,28 +38,50 @@ struct data_wrapper { const char *dirname; }; +struct path_wrapper { + char *path; + char *filename; + int order; +}; + static int -add_file_to_list(caddr_t data, caddr_t arg) -{ - struct data_wrapper *dw = (struct data_wrapper *)arg; - if (dw) { - /* max is number of entries; the range of n is 0 - max-1 */ - PR_ASSERT(dw->n <= dw->max); - PR_ASSERT(dw->list); - PR_ASSERT(data); - /* this strdup is free'd by free_filelist */ - dw->list[dw->n++] = slapi_ch_smprintf("%s/%s", dw->dirname, data); - return 0; - } +path_wrapper_cmp(struct path_wrapper *p1, struct path_wrapper *p2) { + if (p1->order < p2->order) { + /* p1 is "earlier" so put it first */ + return -1; + } else if (p1->order > p2->order) { + return 1; + } + return strcmp(p1->filename, p2->filename); +} - return -1; +static int +path_wrapper_free(caddr_t data) { + struct path_wrapper *p = (struct path_wrapper *)data; + if (p != NULL) { + slapi_ch_free_string(&(p->path)); + slapi_ch_free_string(&(p->filename)); + slapi_ch_free((void **)&p); + } + return 0; } static int -free_string(caddr_t data) +add_file_to_list(caddr_t data, caddr_t arg) { - slapi_ch_free((void **)&data); - return 0; + struct data_wrapper *dw = (struct data_wrapper *)arg; + struct path_wrapper *pw = (struct path_wrapper *)data; + if (dw) { + /* max is number of entries; the range of n is 0 - max-1 */ + PR_ASSERT(dw->n <= dw->max); + PR_ASSERT(dw->list); + PR_ASSERT(data); + /* this strdup is free'd by free_filelist */ + dw->list[dw->n++] = slapi_ch_strdup(pw->path); + return 0; + } + + return -1; } static int @@ -72,7 +94,7 @@ file_is_type_x(const char *dirname, const char *filename, PRFileType x) inf.type == x) status = 1; - slapi_ch_free((void **)&fullpath); + slapi_ch_free_string(&fullpath); return status; } @@ -126,79 +148,106 @@ matches(const char *filename, const char *pattern) * interpreter style regular expression. For example, to get all files ending * in .ldif, use ".*\\.ldif" instead of "*.ldif" * The return value is a NULL terminated array of names. + * + * This takes an array of directories is order of lowest to highest pref to + * search. So if you have: + * a/ + * 00file + * 10file + * b/ + * 05file + * 15file + * These will be order in preference: + * 00file, 10file, 05file, 15file */ char ** get_filelist( - const char *dirname, /* directory path; if NULL, uses "." */ - const char *pattern, /* grep (not shell!) file pattern regex */ - int hiddenfiles, /* if true, return hidden files and directories too */ - int nofiles, /* if true, do not return files */ - int nodirs /* if true, do not return directories */ + const char **dirnames, /* list of directory paths; if NULL, uses "." */ + const char *pattern, /* grep (not shell!) file pattern regex */ + int hiddenfiles, /* if true, return hidden files and directories too */ + int nofiles, /* if true, do not return files */ + int nodirs, /* if true, do not return directories */ + int dirnames_size /* Size of the dirnames array */ ) { - Avlnode *filetree = 0; - PRDir *dirptr = 0; - PRDirEntry *dirent = 0; - PRDirFlags dirflags = PR_SKIP_BOTH & PR_SKIP_HIDDEN; - char **retval = 0; - int num = 0; - struct data_wrapper dw; - - if (!dirname) - dirname = "."; - - if (hiddenfiles) - dirflags = PR_SKIP_BOTH; - - if (!(dirptr = PR_OpenDir(dirname))) { - return NULL; - } - - /* read the directory entries into an ascii sorted avl tree */ - for (dirent = PR_ReadDir(dirptr, dirflags); dirent ; - dirent = PR_ReadDir(dirptr, dirflags)) { - - if (nofiles && is_a_file(dirname, dirent->name)) - continue; - - if (nodirs && is_a_dir(dirname, dirent->name)) - continue; - - if (1 == matches(dirent->name, pattern)) { - /* this strdup is free'd by free_string */ - char *newone = slapi_ch_strdup(dirent->name); - avl_insert(&filetree, newone, strcmp, 0); - num++; - } - } - PR_CloseDir(dirptr); - - /* allocate space for the list */ - retval = (char **)slapi_ch_calloc(num+1, sizeof(char *)); - - /* traverse the avl tree and copy the filenames into the list */ - dw.list = retval; - dw.n = 0; - dw.max = num; - dw.dirname = dirname; - (void)avl_apply(filetree, add_file_to_list, &dw, -1, AVL_INORDER); - retval[num] = 0; /* set last entry to null */ - - /* delete the avl tree and all its data */ - avl_free(filetree, free_string); - - return retval; + Avlnode *filetree = 0; + PRDir *dirptr = 0; + PRDirEntry *dirent = 0; + PRDirFlags dirflags = PR_SKIP_BOTH & PR_SKIP_HIDDEN; + char **retval = NULL; + const char *dirname = NULL; + int num = 0; + int i = 0; + struct data_wrapper dw; + struct path_wrapper *pw_ptr = NULL; + + + if (hiddenfiles) { + dirflags = PR_SKIP_BOTH; + } + + for (i = 0; i < dirnames_size; i++) { + dirname = dirnames[i]; + /* wibrown - I feel this is a bad default */ + if (dirname == NULL) { + dirname = "."; + } + if (!(dirptr = PR_OpenDir(dirname))) { + continue; + } + /* read the directory entries into an ascii sorted avl tree */ + for (dirent = PR_ReadDir(dirptr, dirflags); dirent ; + dirent = PR_ReadDir(dirptr, dirflags)) { + + if (nofiles && is_a_file(dirname, dirent->name)) + continue; + + if (nodirs && is_a_dir(dirname, dirent->name)) + continue; + + if (1 == matches(dirent->name, pattern)) { + /* this strdup is free'd by path_wrapper_free */ + pw_ptr = (struct path_wrapper *)slapi_ch_malloc(sizeof(struct path_wrapper)); + pw_ptr->path = slapi_ch_smprintf("%s/%s", dirname, dirent->name); + pw_ptr->filename = slapi_ch_strdup(dirent->name); + pw_ptr->order = i; + avl_insert(&filetree, pw_ptr, path_wrapper_cmp, 0); + num++; + } + } + PR_CloseDir(dirptr); + } + + /* allocate space for the list */ + if (num > 0) { + retval = (char **)slapi_ch_calloc(num+1, sizeof(char *)); + + /* traverse the avl tree and copy the filenames into the list */ + dw.list = retval; + dw.n = 0; + dw.max = num; + dw.dirname = dirname; + (void)avl_apply(filetree, add_file_to_list, &dw, -1, AVL_INORDER); + retval[num] = 0; /* set last entry to null */ + + /* delete the avl tree and all its data */ + } + + avl_free(filetree, path_wrapper_free); + + return retval; } void free_filelist(char **filelist) { - int ii; - for (ii = 0; filelist && filelist[ii]; ++ii) - slapi_ch_free((void **)&filelist[ii]); + int ii; + for (ii = 0; filelist && filelist[ii]; ++ii) { + slapi_ch_free_string(&(filelist[ii])); + } - slapi_ch_free((void **)&filelist); + slapi_ch_free((void **)&filelist); } /** @@ -215,21 +264,22 @@ free_filelist(char **filelist) * under /etc/rcX.d/ */ char ** -get_priority_filelist(const char *directory, const char *pattern) +get_priority_filelist(const char **directories, const char *pattern, int dirnames_size) { - char *basepattern = "^[0-9][0-9]"; - char *genericpattern = ".*"; /* used if pattern is null */ - char *bigpattern = 0; - char **retval = 0; + char *basepattern = "^[0-9][0-9]"; + char *genericpattern = ".*"; /* used if pattern is null */ + char *bigpattern = 0; + char **retval = 0; - if (!pattern) - pattern = genericpattern; + if (!pattern) { + pattern = genericpattern; + } - bigpattern = slapi_ch_smprintf("%s%s", basepattern, pattern); + bigpattern = slapi_ch_smprintf("%s%s", basepattern, pattern); - retval = get_filelist(directory, bigpattern, 0, 0, 1); + retval = get_filelist(directories, bigpattern, 0, 0, 1, dirnames_size); - slapi_ch_free((void **)&bigpattern); + slapi_ch_free_string(&bigpattern); - return retval; + return retval; } diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 2cdee6a7c..d2841ebbf 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -1369,14 +1369,15 @@ int plugin_get_log_audit (const struct slapdplugin *plugin); * getfilelist.c */ char **get_filelist( - const char *dirname, /* directory path; if NULL, uses "." */ - const char *pattern, /* regex pattern, not shell style wildcard */ - int hiddenfiles, /* if true, return hidden files and directories too */ - int nofiles, /* if true, do not return files */ - int nodirs /* if true, do not return directories */ + const char **dirnames, /* directory paths; if NULL, uses "." */ + const char *pattern, /* regex pattern, not shell style wildcard */ + int hiddenfiles, /* if true, return hidden files and directories too */ + int nofiles, /* if true, do not return files */ + int nodirs, /* if true, do not return directories */ + int dirnames_size ); void free_filelist(char **filelist); -char **get_priority_filelist(const char *directory, const char *pattern); +char **get_priority_filelist(const char **directories, const char *pattern, int dirnames_size); /* this interface is exposed to be used by internal operations. */ diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c index f50f57381..35c798197 100644 --- a/ldap/servers/slapd/schema.c +++ b/ldap/servers/slapd/schema.c @@ -868,36 +868,34 @@ slapi_entry_schema_check_ext( Slapi_PBlock *pb, Slapi_Entry *e, int repl_check ) i = slapi_entry_first_attr(e, &a); while (-1 != i && 0 == ret) { - if (is_extensible_object == 0 && - unknown_class == 0 && - !slapi_attr_flag_is_set(a, SLAPI_ATTR_FLAG_OPATTR)) - { - char *attrtype; - slapi_attr_get_type(a, &attrtype); - if (oc_check_allowed_sv(pb, e, attrtype, oclist) != 0) - { - ret = 1; - } - } - - if ( slapi_attr_flag_is_set( a, SLAPI_ATTR_FLAG_SINGLE ) ) { - if (slapi_valueset_count(&a->a_present_values) > 1) - { - slapi_log_err(SLAPI_LOG_ERR, - "slapi_entry_schema_check_ext", "Entry \"%s\" single-valued attribute \"%s\" has multiple values\n", - slapi_entry_get_dn_const(e), - a->a_type); - if (pb) { - PR_snprintf( errtext, sizeof( errtext ), - "single-valued attribute \"%s\" has multiple values\n", - a->a_type ); - slapi_pblock_set( pb, SLAPI_PB_RESULT_TEXT, errtext ); - } - ret = 1; - } - } - prevattr = a; - i = slapi_entry_next_attr(e, prevattr, &a); + if (is_extensible_object == 0 && + unknown_class == 0 && + !slapi_attr_flag_is_set(a, SLAPI_ATTR_FLAG_OPATTR)) + { + char *attrtype; + slapi_attr_get_type(a, &attrtype); + if (oc_check_allowed_sv(pb, e, attrtype, oclist) != 0) + { + ret = 1; + } + } + + if ( slapi_attr_flag_is_set( a, SLAPI_ATTR_FLAG_SINGLE ) ) { + if (slapi_valueset_count(&a->a_present_values) > 1) + { + slapi_log_err(SLAPI_LOG_ERR, "slapi_entry_schema_check_ext", "Entry \"%s\" single-valued attribute \"%s\" has multiple values\n", + slapi_entry_get_dn_const(e), a->a_type); + if (pb) { + PR_snprintf( errtext, sizeof( errtext ), + "single-valued attribute \"%s\" has multiple values\n", + a->a_type ); + slapi_pblock_set( pb, SLAPI_PB_RESULT_TEXT, errtext ); + } + ret = 1; + } + } + prevattr = a; + i = slapi_entry_next_attr(e, prevattr, &a); } } @@ -5272,6 +5270,8 @@ init_schema_dse_ext(char *schemadir, Slapi_Backend *be, char *userschematmpfile = 0; char **filelist = 0; char *myschemadir = NULL; + /* SYSTEMSCHEMADIR is set out of the makefile.am -D, from configure.ac */ + char *myschemadirs[2] = {SYSTEMSCHEMADIR, NULL}; Slapi_DN schema; if (NULL == local_pschemadse) @@ -5296,61 +5296,65 @@ init_schema_dse_ext(char *schemadir, Slapi_Backend *be, myschemadir = schemadir; } - filelist = get_priority_filelist(myschemadir, ".*ldif$"); - if (!filelist || !*filelist) - { - slapi_log_err(SLAPI_LOG_ERR, "init_schema_dse_ext", - "No schema files were found in the directory %s\n", myschemadir); - free_filelist(filelist); - rc = 0; - } - else - { - /* figure out the last file in the list; it is the user schema */ - int ii = 0; - while (filelist[ii]) ++ii; - userschemafile = filelist[ii-1]; - userschematmpfile = slapi_ch_smprintf("%s.tmp", userschemafile); - } + myschemadirs[1] = myschemadir; - if(rc) - { - *local_pschemadse = dse_new_with_filelist(userschemafile, - userschematmpfile, NULL, NULL, myschemadir, filelist); - } - PR_ASSERT(*local_pschemadse); - if ((rc = (*local_pschemadse != NULL)) != 0) - { - /* pass schema_flags as arguments */ - dse_register_callback(*local_pschemadse, - DSE_OPERATION_READ, DSE_FLAG_PREOP, &schema, - LDAP_SCOPE_BASE, NULL, - load_schema_dse, (void *)&schema_flags, NULL); - } - slapi_ch_free_string(&userschematmpfile); - if (NULL == schemadir) - slapi_ch_free_string(&myschemadir); /* allocated in this function */ + // Make this take an array of strings? + filelist = get_priority_filelist((const char **)myschemadirs, ".*ldif$", 2); + if (!filelist || !*filelist) + { + slapi_log_err(SLAPI_LOG_ERR, "init_schema_dse_ext", + "No schema files were found in the directory %s\n", myschemadir); + free_filelist(filelist); + rc = 0; + } + else + { + /* figure out the last file in the list; it is the user schema */ + int ii = 0; + while (filelist[ii]) ++ii; + userschemafile = filelist[ii-1]; + userschematmpfile = slapi_ch_smprintf("%s.tmp", userschemafile); + } - if(rc) - { - char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE] = {0}; - char *attr_str; - int dont_write = 1; - int merge = 1; - int dont_dup_check = 1; - Slapi_PBlock pb = {0}; - /* don't write out the file when reading */ - slapi_pblock_set(&pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, (void*)&dont_write); - /* duplicate entries are allowed */ - slapi_pblock_set(&pb, SLAPI_DSE_MERGE_WHEN_ADDING, (void*)&merge); - /* use the non duplicate checking str2entry */ - slapi_pblock_set(&pb, SLAPI_DSE_DONT_CHECK_DUPS, (void*)&dont_dup_check); - /* borrow the task flag space */ - slapi_pblock_set(&pb, SLAPI_SCHEMA_FLAGS, (void*)&schema_flags); - - /* add the objectclass attribute so we can do some basic schema - checking during initialization; this will be overridden when - its "real" definition is read from the schema conf files */ + if(rc) + { + *local_pschemadse = dse_new_with_filelist(userschemafile, + userschematmpfile, NULL, NULL, myschemadir, filelist); + } + PR_ASSERT(*local_pschemadse); + if ((rc = (*local_pschemadse != NULL)) != 0) + { + /* pass schema_flags as arguments */ + dse_register_callback(*local_pschemadse, + DSE_OPERATION_READ, DSE_FLAG_PREOP, &schema, + LDAP_SCOPE_BASE, NULL, + load_schema_dse, (void *)&schema_flags, NULL); + } + slapi_ch_free_string(&userschematmpfile); + if (NULL == schemadir) + slapi_ch_free_string(&myschemadir); /* allocated in this function */ + + if(rc) + { + char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE] = {0}; + char *attr_str; + int dont_write = 1; + int merge = 1; + int dont_dup_check = 1; + Slapi_PBlock pb = {0}; + memset(&pb, 0, sizeof(pb)); + /* don't write out the file when reading */ + slapi_pblock_set(&pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, (void*)&dont_write); + /* duplicate entries are allowed */ + slapi_pblock_set(&pb, SLAPI_DSE_MERGE_WHEN_ADDING, (void*)&merge); + /* use the non duplicate checking str2entry */ + slapi_pblock_set(&pb, SLAPI_DSE_DONT_CHECK_DUPS, (void*)&dont_dup_check); + /* borrow the task flag space */ + slapi_pblock_set(&pb, SLAPI_SCHEMA_FLAGS, (void*)&schema_flags); + + /* add the objectclass attribute so we can do some basic schema + checking during initialization; this will be overridden when + its "real" definition is read from the schema conf files */ #ifdef USE_OPENLDAP attr_str = "( 2.5.4.0 NAME 'objectClass' "
0
52cd39a7df741b31428cd52baea48be79ffa2f61
389ds/389-ds-base
Issue 31 - Initial MemberOf plugin support Description: Add initial support for MemberOf by implementing the basic methods for configuring the plugin and writing dsconf hooks to manage it from the cli. https://pagure.io/lib389/issue/31 Author: Ilias95 Review by: wibrown (Thank you very much!)
commit 52cd39a7df741b31428cd52baea48be79ffa2f61 Author: Ilias Stamatis <[email protected]> Date: Thu Jun 8 04:20:43 2017 +0300 Issue 31 - Initial MemberOf plugin support Description: Add initial support for MemberOf by implementing the basic methods for configuring the plugin and writing dsconf hooks to manage it from the cli. https://pagure.io/lib389/issue/31 Author: Ilias95 Review by: wibrown (Thank you very much!) diff --git a/src/lib389/cli/dsconf b/src/lib389/cli/dsconf index e6cb95d0d..a114afbdd 100755 --- a/src/lib389/cli/dsconf +++ b/src/lib389/cli/dsconf @@ -22,6 +22,7 @@ from lib389.cli_conf import backend as cli_backend from lib389.cli_conf import plugin as cli_plugin from lib389.cli_conf import schema as cli_schema from lib389.cli_conf import lint as cli_lint +from lib389.cli_conf.plugins import memberof as cli_memberof from lib389.cli_base import disconnect_instance, connect_instance from lib389.cli_base.dsrc import dsrc_to_ldap, dsrc_arg_concat @@ -63,6 +64,7 @@ if __name__ == '__main__': cli_schema.create_parser(subparsers) cli_lint.create_parser(subparsers) cli_plugin.create_parser(subparsers) + cli_memberof.create_parser(subparsers) args = parser.parse_args() diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py index 38e52f962..c307cf2c4 100644 --- a/src/lib389/lib389/_mapped_object.py +++ b/src/lib389/lib389/_mapped_object.py @@ -184,6 +184,15 @@ class DSLdapObject(DSLogging): # Do a mod_delete on the value. self.set(key, value, action=ldap.MOD_DELETE) + def remove_all(self, key): + """Remove all values defined by key (if possible). + + If an attribute is multi-valued AND required all values except one will + be deleted. + """ + for val in self.get_attr_vals(key): + self.remove(key, val) + # 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)) diff --git a/src/lib389/lib389/cli_conf/plugin.py b/src/lib389/lib389/cli_conf/plugin.py index 8736c3eb1..2d02f8775 100644 --- a/src/lib389/lib389/cli_conf/plugin.py +++ b/src/lib389/lib389/cli_conf/plugin.py @@ -61,6 +61,21 @@ def plugin_disable(inst, basedn, log, args, warn=True): def plugin_configure(inst, basedn, log, args): pass +def generic_show(inst, basedn, log, args): + """Display plugin configuration.""" + plugin = args.plugin_cls(inst) + log.info(plugin.display()) + +def generic_enable(inst, basedn, log, args): + plugin = args.plugin_cls(inst) + plugin.enable() + log.info("Enabled %s", plugin.rdn) + +def generic_disable(inst, basedn, log, args): + plugin = args.plugin_cls(inst) + plugin.disable() + log.info("Disabled %s", plugin.rdn) + def create_parser(subparsers): plugin_parser = subparsers.add_parser('plugin', help="Manage plugins available on the server") diff --git a/src/lib389/lib389/cli_conf/plugins/__init__.py b/src/lib389/lib389/cli_conf/plugins/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/lib389/lib389/cli_conf/plugins/memberof.py b/src/lib389/lib389/cli_conf/plugins/memberof.py new file mode 100644 index 000000000..ceaecadbf --- /dev/null +++ b/src/lib389/lib389/cli_conf/plugins/memberof.py @@ -0,0 +1,240 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016-2017 Red Hat, Inc. +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import ldap + +from lib389.plugins import MemberOfPlugin +from lib389.cli_conf.plugin import generic_enable, generic_disable, generic_show + + +def manage_attr(inst, basedn, log, args): + if args.value is not None: + set_attr(inst, basedn, log, args) + else: + display_attr(inst, basedn, log, args) + +def display_attr(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + log.info(plugin.get_attr_formatted()) + +def set_attr(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + try: + plugin.set_attr(args.value) + except ldap.UNWILLING_TO_PERFORM: + log.error('Error: Illegal value "{}". Failed to set.'.format(args.value)) + else: + log.info('memberOfAttr set to "{}"'.format(args.value)) + +def display_groupattr(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + log.info(plugin.get_groupattr_formatted()) + +def add_groupattr(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + try: + plugin.add_groupattr(args.value) + except ldap.UNWILLING_TO_PERFORM: + log.error('Error: Illegal value "{}". Failed to add.'.format(args.value)) + except ldap.TYPE_OR_VALUE_EXISTS: + log.info('Value "{}" already exists.'.format(args.value)) + else: + log.info('successfully added memberOfGroupAttr value "{}"'.format(args.value)) + +def remove_groupattr(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + try: + plugin.remove_groupattr(args.value) + except ldap.UNWILLING_TO_PERFORM: + log.error("Error: Failed to delete. memberOfGroupAttr is required.") + except ldap.NO_SUCH_ATTRIBUTE as ex: + log.error('Error: Failed to delete. No value "{0}" found.'.format(args.value)) + else: + log.info('successfully removed memberOfGroupAttr value "{}"'.format(args.value)) + +def display_allbackends(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + val = plugin.get_allbackends_formatted() + if not val: + log.info("memberOfAllBackends is not set") + else: + log.info(val) + +def enable_allbackends(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + plugin.enable_allbackends() + log.info("memberOfAllBackends enabled successfully") + +def disable_allbackends(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + plugin.disable_allbackends() + log.info("memberOfAllBackends disabled successfully") + +def manage_autoaddoc(inst, basedn, log, args): + if args.value == "del": + remove_autoaddoc(inst, basedn, log, args) + elif args.value is not None: + set_autoaddoc(inst, basedn, log, args) + else: + display_autoaddoc(inst, basedn, log, args) + +def display_autoaddoc(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + val = plugin.get_autoaddoc_formatted() + if not val: + log.info("memberOfAutoAddOc is not set") + else: + log.info(val) + +def set_autoaddoc(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + d = {'nsmemberof': 'nsMemberOf', 'inetuser': 'inetUser', 'inetadmin': 'inetAdmin'} + plugin.set_autoaddoc(d[args.value]) + log.info('memberOfAutoAddOc set to "{}"'.format(d[args.value])) + +def remove_autoaddoc(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + if not plugin.get_autoaddoc(): + log.info("memberOfAutoAddOc was not set") + else: + plugin.remove_autoaddoc() + log.info("memberOfAutoAddOc attribute deleted") + +def display_scope(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + val = plugin.get_entryscope_formatted() + if not val: + log.info("memberOfEntryScope is not set") + else: + log.info(val) + +def add_scope(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + try: + plugin.add_entryscope(args.value) + except ldap.UNWILLING_TO_PERFORM as ex: + if "is also listed as an exclude suffix" in ex.args[0]['info']: + log.error('Error: Include suffix ({0}) is also listed as an exclude suffix.'.format(args.value)) + else: + log.error('Error: Invalid DN "{}". Failed to add.'.format(args.value)) + except ldap.TYPE_OR_VALUE_EXISTS: + log.info('Value "{}" already exists.'.format(args.value)) + else: + log.info('successfully added memberOfEntryScope value "{}"'.format(args.value)) + +def remove_scope(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + try: + plugin.remove_entryscope(args.value) + except ldap.NO_SUCH_ATTRIBUTE as ex: + log.error('Error: Failed to delete. No value "{0}" found.'.format(args.value)) + else: + log.info('successfully removed memberOfEntryScope value "{}"'.format(args.value)) + +def display_excludescope(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + val = plugin.get_excludescope_formatted() + if not val: + log.info("memberOfEntryScopeExcludeSubtree is not set") + else: + log.info(val) + +def add_excludescope(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + try: + plugin.add_excludescope(args.value) + except ldap.UNWILLING_TO_PERFORM as ex: + if "is also listed as an exclude suffix" in ex.args[0]['info']: + log.error('Error: Suffix ({0}) is listed in entry scope.'.format(args.value)) + else: + log.error('Error: Invalid DN "{}". Failed to add.'.format(args.value)) + except ldap.TYPE_OR_VALUE_EXISTS: + log.info('Value "{}" already exists.'.format(args.value)) + else: + log.info('successfully added memberOfEntryScopeExcludeSubtree value "{}"'.format(args.value)) + +def remove_excludescope(inst, basedn, log, args): + plugin = MemberOfPlugin(inst) + try: + plugin.remove_excludescope(args.value) + except ldap.NO_SUCH_ATTRIBUTE as ex: + log.error('Error: Failed to delete. No value "{0}" found.'.format(args.value)) + else: + log.info('successfully removed memberOfEntryScopeExcludeSubtree value "{}"'.format(args.value)) + +def fixup(inst, basedn, log, args): + """Run the fix-up task for memberof plugin.""" + pass + +def create_parser(subparsers): + memberof_parser = subparsers.add_parser('memberof', help='Manage and configure MemberOf plugin') + + subcommands = memberof_parser.add_subparsers(help='action') + + show_parser = subcommands.add_parser('show', help='display memberof plugin configuration') + show_parser.set_defaults(func=generic_show, plugin_cls=MemberOfPlugin) + + enable_parser = subcommands.add_parser('enable', help='enable memberof plugin') + enable_parser.set_defaults(func=generic_enable, plugin_cls=MemberOfPlugin) + + disable_parser = subcommands.add_parser('disable', help='disable memberof plugin') + disable_parser.set_defaults(func=generic_disable, plugin_cls=MemberOfPlugin) + + attr_parser = subcommands.add_parser('attr', help='get or set memberofattr') + attr_parser.set_defaults(func=manage_attr) + attr_parser.add_argument('value', nargs='?', help='The value to set as memberofattr') + + groupattr_parser = subcommands.add_parser('groupattr', help='get or manage memberofgroupattr') + groupattr_parser.set_defaults(func=display_groupattr) + # argparse doesn't support optional subparsers in python2! + groupattr_subcommands = groupattr_parser.add_subparsers(help='action') + add_groupattr_parser = groupattr_subcommands.add_parser('add', help='add memberofgroupattr value') + add_groupattr_parser.set_defaults(func=add_groupattr) + add_groupattr_parser.add_argument('value', help='The value to add in memberofgroupattr') + del_groupattr_parser = groupattr_subcommands.add_parser('del', help='remove memberofgroupattr value') + del_groupattr_parser.set_defaults(func=remove_groupattr) + del_groupattr_parser.add_argument('value', help='The value to remove from memberofgroupattr') + + allbackends_parser = subcommands.add_parser('allbackends', help='get or manage memberofallbackends') + allbackends_parser.set_defaults(func=display_allbackends) + # argparse doesn't support optional subparsers in python2! + allbackends_subcommands = allbackends_parser.add_subparsers(help='action') + on_allbackends_parser = allbackends_subcommands.add_parser('on', help='enable all backends for memberof') + on_allbackends_parser.set_defaults(func=enable_allbackends) + off_allbackends_parser = allbackends_subcommands.add_parser('off', help='disable all backends for memberof') + off_allbackends_parser.set_defaults(func=disable_allbackends) + + autoaddoc_parser = subcommands.add_parser('autoaddoc', help='get or set memberofautoaddoc') + autoaddoc_parser.set_defaults(func=manage_autoaddoc) + autoaddoc_parser.add_argument('value', nargs='?', choices=['nsmemberof', 'inetuser', 'inetadmin', 'del'], + type=str.lower, help='The value to set as memberofautoaddoc or del to remove the attribute') + + scope_parser = subcommands.add_parser('scope', help='get or manage memberofentryscope') + scope_parser.set_defaults(func=display_scope) + # argparse doesn't support optional subparsers in python2! + scope_subcommands = scope_parser.add_subparsers(help='action') + add_scope_parser = scope_subcommands.add_parser('add', help='add memberofentryscope value') + add_scope_parser.set_defaults(func=add_scope) + add_scope_parser.add_argument('value', help='The value to add in memberofentryscope') + del_scope_parser = scope_subcommands.add_parser('del', help='remove memberofentryscope value') + del_scope_parser.set_defaults(func=remove_scope) + del_scope_parser.add_argument('value', help='The value to remove from memberofentryscope') + + exclude_parser = subcommands.add_parser('exclude', help='get or manage memberofentryscopeexcludesubtree') + exclude_parser.set_defaults(func=display_excludescope) + # argparse doesn't support optional subparsers in python2! + exclude_subcommands = exclude_parser.add_subparsers(help='action') + add_exclude_parser = exclude_subcommands.add_parser('add', help='add memberofentryscopeexcludesubtree value') + add_exclude_parser.set_defaults(func=add_excludescope) + add_exclude_parser.add_argument('value', help='The value to add in memberofentryscopeexcludesubtree') + del_exclude_parser = exclude_subcommands.add_parser('del', help='remove memberofentryscopeexcludesubtree value') + del_exclude_parser.set_defaults(func=remove_excludescope) + del_exclude_parser.add_argument('value', help='The value to remove from memberofentryscopeexcludesubtree') + + fixup_parser = subcommands.add_parser('fixup', help='run the fix-up task for memberof plugin') + fixup_parser.set_defaults(func=fixup) diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py index 0a46d3588..bde4c92ac 100644 --- a/src/lib389/lib389/plugins.py +++ b/src/lib389/lib389/plugins.py @@ -150,8 +150,102 @@ class RolesPlugin(Plugin): super(RolesPlugin, self).__init__(instance, dn, batch) class MemberOfPlugin(Plugin): + _plugin_properties = { + 'cn' : 'MemberOf Plugin', + 'nsslapd-pluginEnabled' : 'off', + 'nsslapd-pluginPath' : 'libmemberof-plugin', + 'nsslapd-pluginInitfunc' : 'memberof_postop_init', + 'nsslapd-pluginType' : 'betxnpostoperation', + 'nsslapd-plugin-depends-on-type' : 'database', + 'nsslapd-pluginId' : 'memberof', + 'nsslapd-pluginVendor' : '389 Project', + 'nsslapd-pluginVersion' : '1.3.7.0', + 'nsslapd-pluginDescription' : 'memberof plugin', + 'memberOfGroupAttr' : 'member', + 'memberOfAttr' : 'memberOf', + } + def __init__(self, instance, dn="cn=MemberOf Plugin,cn=plugins,cn=config", batch=False): super(MemberOfPlugin, self).__init__(instance, dn, batch) + self._create_objectclasses = ['top', 'nsSlapdPlugin', 'extensibleObject'] + + def get_attr(self): + return self.get_attr_val('memberofattr') + + def get_attr_formatted(self): + return self.display_attr('memberofattr') + + def set_attr(self, attr): + self.set('memberofattr', attr) + + def get_groupattr(self): + return self.get_attr_vals('memberofgroupattr') + + def get_groupattr_formatted(self): + return self.display_attr('memberofgroupattr') + + def add_groupattr(self, attr): + self.add('memberofgroupattr', attr) + + def remove_groupattr(self, attr): + self.remove('memberofgroupattr', attr) + + def get_allbackends(self): + return self.get_attr_val('memberofallbackends') + + def get_allbackends_formatted(self): + return self.display_attr('memberofallbackends') + + def enable_allbackends(self): + self.set('memberofallbackends', 'on') + + def disable_allbackends(self): + self.set('memberofallbackends', 'off') + + def get_autoaddoc(self): + return self.get_attr_val('memberofautoaddoc') + + def get_autoaddoc_formatted(self): + return self.display_attr('memberofautoaddoc') + + def set_autoaddoc(self, object_class): + self.set('memberofautoaddoc', object_class) + + def remove_autoaddoc(self): + self.remove_all('memberofautoaddoc') + + def get_entryscope(self, formatted=False): + return self.get_attr_vals('memberofentryscope') + + def get_entryscope_formatted(self): + return self.display_attr('memberofentryscope') + + def add_entryscope(self, attr): + self.add('memberofentryscope', attr) + + def remove_entryscope(self, attr): + self.remove('memberofentryscope', attr) + + # def remove_all_entryscope(self): + # self.remove_all('memberofentryscope') + + def get_excludescope(self): + return self.get_attr_vals('memberofentryscopeexcludesubtree') + + def get_excludescope_formatted(self): + return self.display_attr('memberofentryscopeexcludesubtree') + + def add_excludescope(self, attr): + self.add('memberofentryscopeexcludesubtree', attr) + + def remove_excludescope(self, attr): + self.remove('memberofentryscopeexcludesubtree', attr) + + # def remove_all_excludescope(self): + # self.remove_all('memberofentryscopeexcludesubtree') + + def fixup(self): + pass class RetroChangelogPlugin(Plugin): def __init__(self, instance, dn="cn=Retro Changelog Plugin,cn=plugins,cn=config", batch=False): diff --git a/src/lib389/lib389/tests/cli/conf_plugins/__init__.py b/src/lib389/lib389/tests/cli/conf_plugins/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/lib389/lib389/tests/cli/conf_plugins/memberof_test.py b/src/lib389/lib389/tests/cli/conf_plugins/memberof_test.py new file mode 100644 index 000000000..4c8296ab9 --- /dev/null +++ b/src/lib389/lib389/tests/cli/conf_plugins/memberof_test.py @@ -0,0 +1,422 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2016-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.tests.cli import topology as default_topology +from lib389.cli_base import LogCapture, FakeArgs +from lib389.plugins import MemberOfPlugin +from lib389.cli_conf.plugins import memberof as memberof_cli + + [email protected](scope="module") +def topology(request): + topology = default_topology(request) + + plugin = MemberOfPlugin(topology.standalone) + # no memberof entry exists by default + plugin.create() + + # At the moment memberof plugin needs to be enabled in order to perform + # syntax checking. Additionally, we have to restart the server in order + # for the action of enabling the pluging to take effect. + plugin.enable() + topology.standalone.restart() + topology.logcap.flush() + + return topology + + +def test_set_attr_with_legal_value(topology): + args = FakeArgs() + + args.value = "memberOf" + memberof_cli.manage_attr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfAttr set to") + topology.logcap.flush() + + args.value = None + memberof_cli.manage_attr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": memberOf") + topology.logcap.flush() + +def test_set_attr_with_illegal_value(topology): + args = FakeArgs() + + args.value = "whatever" + memberof_cli.manage_attr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("Failed to set") + topology.logcap.flush() + +def test_set_groupattr_with_legal_value(topology): + args = FakeArgs() + + args.value = "uniqueMember" + memberof_cli.add_groupattr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully added memberOfGroupAttr value") + topology.logcap.flush() + + memberof_cli.display_groupattr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": uniqueMember") + topology.logcap.flush() + +def test_set_groupattr_with_value_that_already_exists(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "uniqueMember" in plugin.get_groupattr(): + plugin.add_groupattr("uniqueMember") + + args = FakeArgs() + + args.value = "uniqueMember" + memberof_cli.add_groupattr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("already exists") + topology.logcap.flush() + +def test_set_groupattr_with_illegal_value(topology): + args = FakeArgs() + + args.value = "whatever" + memberof_cli.add_groupattr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("Illegal value") + topology.logcap.flush() + +def test_remove_groupattr_with_value_that_exists(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "uniqueMember" in plugin.get_groupattr(): + plugin.add_groupattr("uniqueMember") + + args = FakeArgs() + + args.value = "uniqueMember" + memberof_cli.remove_groupattr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully removed memberOfGroupAttr value") + topology.logcap.flush() + + memberof_cli.display_groupattr(topology.standalone, None, topology.logcap.log, args) + assert not topology.logcap.contains(": uniqueMember") + topology.logcap.flush() + +def test_remove_groupattr_with_value_that_doesnt_exist(topology): + args = FakeArgs() + + args.value = "whatever" + memberof_cli.remove_groupattr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains('No value "{0}" found'.format(args.value)) + topology.logcap.flush() + +def test_try_remove_all_groupattr_values(topology): + plugin = MemberOfPlugin(topology.standalone) + # make sure "member" value exists and it is the only one + assert "member" in plugin.get_groupattr() # exists from default + assert len(plugin.get_groupattr()) == 1 + + args = FakeArgs() + + args.value = "member" + memberof_cli.remove_groupattr(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("Error: Failed to delete. memberOfGroupAttr is required.") + topology.logcap.flush() + +def test_get_allbackends_when_not_set(topology): + args = FakeArgs() + + memberof_cli.display_allbackends(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfAllBackends is not set") + topology.logcap.flush() + +def test_enable_allbackends(topology): + args = FakeArgs() + + memberof_cli.enable_allbackends(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("enabled successfully") + topology.logcap.flush() + + memberof_cli.display_allbackends(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": on") + topology.logcap.flush() + +def test_disable_all_backends(topology): + args = FakeArgs() + + memberof_cli.disable_allbackends(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("disabled successfully") + topology.logcap.flush() + + memberof_cli.display_allbackends(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": off") + topology.logcap.flush() + +def test_set_autoaddoc(topology): + args = FakeArgs() + + # argparse makes sure that only choices 'nsmemberof', 'inetuser', 'inetadmin', 'del' are allowed + args.value = "nsmemberof" + memberof_cli.manage_autoaddoc(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfAutoAddOc set to") + topology.logcap.flush() + + args.value = None + memberof_cli.manage_autoaddoc(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": nsMemberOf") + topology.logcap.flush() + +def test_remove_autoaddoc(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not plugin.get_autoaddoc(): + plugin.set_autoaddoc("nsmemberof") + + args = FakeArgs() + + # argparse makes sure that only choices 'nsmemberof', 'inetuser', 'inetadmin', 'del' are allowed + args.value = "del" + memberof_cli.manage_autoaddoc(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfAutoAddOc attribute deleted") + topology.logcap.flush() + + args.value = None + memberof_cli.manage_autoaddoc(topology.standalone, None, topology.logcap.log, args) + assert not topology.logcap.contains(": nsMemberOf") + topology.logcap.flush() + +def test_remove_autoaddoc_when_not_set(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if plugin.get_autoaddoc(): + plugin.remove_autoaddoc() + + args = FakeArgs() + + args.value = "del" + memberof_cli.manage_autoaddoc(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfAutoAddOc was not set") + topology.logcap.flush() + +def test_get_autoaddoc_when_not_set(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if plugin.get_autoaddoc(): + plugin.remove_autoaddoc() + + args = FakeArgs() + + args.value = None + memberof_cli.manage_autoaddoc(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfAutoAddOc is not set") + topology.logcap.flush() + +def test_get_entryscope_when_not_set(topology): + args = FakeArgs() + + args.value = None + memberof_cli.display_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfEntryScope is not set") + topology.logcap.flush() + +def test_add_entryscope_with_legal_value(topology): + args = FakeArgs() + + args.value = "dc=example,dc=com" + memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully added memberOfEntryScope value") + topology.logcap.flush() + + args.value = None + memberof_cli.display_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": dc=example,dc=com") + topology.logcap.flush() + + args.value = "a=b" + memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully added memberOfEntryScope value") + topology.logcap.flush() + + args.value = None + memberof_cli.display_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": dc=example,dc=com") + assert topology.logcap.contains(": a=b") + topology.logcap.flush() + +def test_add_entryscope_with_illegal_value(topology): + args = FakeArgs() + + args.value = "whatever" + memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("Error: Invalid DN") + topology.logcap.flush() + +def test_add_entryscope_with_existing_value(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "dc=example,dc=com" in plugin.get_entryscope(): + plugin.add_entryscope("dc=example,dc=com") + + args = FakeArgs() + + args.value = "dc=example,dc=com" + memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains('Value "{}" already exists'.format(args.value)) + topology.logcap.flush() + +def test_remove_entryscope_with_existing_value(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "a=b" in plugin.get_entryscope(): + plugin.add_entryscope("a=b") + if not "dc=example,dc=com" in plugin.get_entryscope(): + plugin.add_entryscope("dc=example,dc=com") + + args = FakeArgs() + + args.value = "a=b" + memberof_cli.remove_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully removed memberOfEntryScope value") + topology.logcap.flush() + + args.value = None + memberof_cli.display_scope(topology.standalone, None, topology.logcap.log, args) + assert not topology.logcap.contains(": a=b") + topology.logcap.flush() + + # THIS MAKES THE SERVER CRASH!!! + # caused when trying to remove all memberofentryscope values + + # args.value = "dc=example,dc=com" + # memberof_cli.remove_scope(topology.standalone, None, topology.logcap.log, args) + # assert topology.logcap.contains("successfully removed value") + # topology.logcap.flush() + +def test_remove_entryscope_with_non_existing_value(topology): + args = FakeArgs() + + args.value = "whatever" + memberof_cli.remove_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains('No value "{0}" found'.format(args.value)) + topology.logcap.flush() + +def test_get_excludescope_when_not_set(topology): + args = FakeArgs() + + args.value = None + memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("memberOfEntryScopeExcludeSubtree is not set") + topology.logcap.flush() + +def test_add_excludescope_with_legal_value(topology): + args = FakeArgs() + + args.value = "ou=People,dc=example,dc=com" + memberof_cli.add_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully added memberOfEntryScopeExcludeSubtree value") + topology.logcap.flush() + + args.value = None + memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": ou=People,dc=example,dc=com") + topology.logcap.flush() + + args.value = "a=b" + memberof_cli.add_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully added memberOfEntryScopeExcludeSubtree value") + topology.logcap.flush() + + args.value = None + memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": ou=People,dc=example,dc=com") + assert topology.logcap.contains(": a=b") + topology.logcap.flush() + +def test_add_excludescope_with_illegal_value(topology): + args = FakeArgs() + + args.value = "whatever" + memberof_cli.add_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("Error: Invalid DN") + topology.logcap.flush() + +def test_add_excludescope_with_existing_value(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "ou=People,dc=example,dc=com" in plugin.get_excludescope(): + plugin.add_excludescope("ou=People,dc=example,dc=com") + + args = FakeArgs() + + args.value = "ou=People,dc=example,dc=com" + memberof_cli.add_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains('Value "{}" already exists'.format(args.value)) + topology.logcap.flush() + +def test_remove_excludescope_with_existing_value(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "a=b" in plugin.get_excludescope(): + plugin.add_excludescope("a=b") + if not "ou=People,dc=example,dc=com" in plugin.get_excludescope(): + plugin.add_excludescope("ou=People,dc=example,dc=com") + + args = FakeArgs() + + args.value = "a=b" + memberof_cli.remove_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("successfully removed memberOfEntryScopeExcludeSubtree value") + topology.logcap.flush() + + args.value = None + memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains(": ou=People,dc=example,dc=com") + assert not topology.logcap.contains(": a=b") + topology.logcap.flush() + + # THIS MAKES THE SERVER CRASH!!! + # caused when trying to remove all memberofentryscopeexcludesubtree values + + # args.value = "ou=People,dc=example,dc=com" + # memberof_cli.remove_excludescope(topology.standalone, None, topology.logcap.log, args) + # assert topology.logcap.contains("successfully removed value") + # topology.logcap.flush() + +def test_remove_excludescope_with_non_existing_value(topology): + args = FakeArgs() + + args.value = "whatever" + memberof_cli.remove_excludescope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains('No value "{0}" found'.format(args.value)) + topology.logcap.flush() + +def test_add_entryscope_with_value_that_exists_in_excludescope(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "dc=example,dc=com" in plugin.get_entryscope(): + plugin.add_entryscope("dc=example,dc=com") + if not "ou=People,dc=example,dc=com" in plugin.get_excludescope(): + plugin.add_excludescope("ou=People,dc=example,dc=com") + + args = FakeArgs() + + args.value = "ou=People,dc=example,dc=com" + memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("is also listed as an exclude suffix") + topology.logcap.flush() + +def test_add_excludescope_with_value_that_exists_in_entryscope(topology): + plugin = MemberOfPlugin(topology.standalone) + # setup test + if not "dc=example,dc=com" in plugin.get_entryscope(): + plugin.add_entryscope("dc=example,dc=com") + if not "ou=People,dc=example,dc=com" in plugin.get_excludescope(): + plugin.add_excludescope("ou=People,dc=example,dc=com") + + args = FakeArgs() + + args.value = "ou=People,dc=example,dc=com" + memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args) + assert topology.logcap.contains("is also listed as an exclude suffix") + topology.logcap.flush()
0
387ea34462d4e6c198f9a005217990dd08578765
389ds/389-ds-base
Ticket 47851 - Add function to retrieve dirsrvtests data directory Description: In 389-ds-base source a new data directory was created: ds/dirsrvtests/data This is used to store LDIF files, backups, etc. In order to access these files, regardless of where the script is run from, we need a function to return the correct full path to the data directory. Reviewed by: nhosoi(Thanks!)
commit 387ea34462d4e6c198f9a005217990dd08578765 Author: Mark Reynolds <[email protected]> Date: Thu Jul 10 15:18:37 2014 -0400 Ticket 47851 - Add function to retrieve dirsrvtests data directory Description: In 389-ds-base source a new data directory was created: ds/dirsrvtests/data This is used to store LDIF files, backups, etc. In order to access these files, regardless of where the script is run from, we need a function to return the correct full path to the data directory. Reviewed by: nhosoi(Thanks!) diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 6be581eb1..29d654303 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -414,7 +414,7 @@ class DirSrv(SimpleLDAPObject): self.groupid = args.get(SER_GROUP_ID, self.userid) self.backupdir = args.get(SER_BACKUP_INST_DIR, DEFAULT_BACKUPDIR) self.prefix = args.get(SER_DEPLOYED_DIR, None) - + # Those variables needs to be revisited (sroot for 64 bits) #self.sroot = os.path.join(self.prefix, "lib/dirsrv") #self.errlog = os.path.join(self.prefix, "var/log/dirsrv/slapd-%s/errors" % self.serverid) @@ -1892,4 +1892,31 @@ class DirSrv(SimpleLDAPObject): XXX moved to brooker.Config """ return self.config.enable_ssl(secport, secargs) - + + def getDataDir(self, filename): + """ + @param filename - the name of the test script calling this function + @return - absolute path of the dirsrvtests data directory, or 'None' on error + + Return the shared data directory relative to the ticket filename. + The caller should always use "__file__" as the argument to this function. + + Get the script name from the filename that was provided: + + 'ds/dirsrvtests/tickets/ticket_#####_test.py' --> 'ticket_#####_test.py' + + Get the full path to the filename, and convert it to the data directory: + + '/home/user/389-ds-base/ds/dirsrvtests/tickets/ticket_#####_test.py' --> + '/home/user/389-ds-base/ds/dirsrvtests/data/' + """ + + if os.path.exists(filename): + script_name = os.path.basename(filename) + if script_name: + data_dir = os.path.abspath(filename).replace('tickets/' + script_name, 'data/') + if data_dir: + return data_dir + + return None +
0
fa6ff3ab22b705bb2d6b4b8aefcf7082e4200c1e
389ds/389-ds-base
Bug(s) fixed: 166229, 166081 Bug Description: slapd crashes during SASL authentication Reviewed by: Noriko (Thanks!) Branch: HEAD and Directory71RtmBranch Fix Description: When we build cyrus-sasl on RHEL, we tell it to use berkeley db for its sasldb database. It uses whatever version of berkeley db is installed in the system. On RHEL3, this is usually libdb-4.1. However, at runtime, slapd uses 4.2, leading to conflicts. This doesn't happen on RHEL4 because it already has 4.2 on it. The db is used to lookup auxiliary properties (auxprop) related to the user, such as password or whatever. This happens in sasl after the user is looked up. In our server, the way we use it, we don't care about these auxprops, or we get them in another way. If you don't tell sasl which auxprop plugin you want to use, it tries to use all of them, which means it will attempt to use the sasldb plugin, which will lead to the crash. The solution is to add our own auxprop plugin which is just a dummy that does nothing, and tell sasl to use our plugin. Platforms tested: RHEL3, RHEL4 Flag Day: no Doc impact: no QA impact: retest New Tests integrated into TET: none
commit fa6ff3ab22b705bb2d6b4b8aefcf7082e4200c1e Author: Rich Megginson <[email protected]> Date: Thu Nov 3 15:31:38 2005 +0000 Bug(s) fixed: 166229, 166081 Bug Description: slapd crashes during SASL authentication Reviewed by: Noriko (Thanks!) Branch: HEAD and Directory71RtmBranch Fix Description: When we build cyrus-sasl on RHEL, we tell it to use berkeley db for its sasldb database. It uses whatever version of berkeley db is installed in the system. On RHEL3, this is usually libdb-4.1. However, at runtime, slapd uses 4.2, leading to conflicts. This doesn't happen on RHEL4 because it already has 4.2 on it. The db is used to lookup auxiliary properties (auxprop) related to the user, such as password or whatever. This happens in sasl after the user is looked up. In our server, the way we use it, we don't care about these auxprops, or we get them in another way. If you don't tell sasl which auxprop plugin you want to use, it tries to use all of them, which means it will attempt to use the sasldb plugin, which will lead to the crash. The solution is to add our own auxprop plugin which is just a dummy that does nothing, and tell sasl to use our plugin. Platforms tested: RHEL3, RHEL4 Flag Day: no Doc impact: no QA impact: retest New Tests integrated into TET: none diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c index a38d07e70..9f991204b 100644 --- a/ldap/servers/slapd/saslbind.c +++ b/ldap/servers/slapd/saslbind.c @@ -95,6 +95,56 @@ void sasl_mutex_free(void *mutex) * sasl library callbacks */ +/* + * We've added this auxprop stuff as a workaround for RHDS bug 166229 + * and FDS bug 166081. The problem is that sasldb is configured and + * enabled by default, but we don't want or need to use it. What + * happens after canon_user is that sasl looks up any auxiliary + * properties of that user. If you don't tell sasl which auxprop + * plug-in to use, it tries all of them, including sasldb. In order + * to avoid this, we create a "dummy" auxprop plug-in with the name + * "iDS" and tell sasl to use this plug-in for auxprop lookups. + * The reason we don't need auxprops is because when we grab the user's + * entry from the internal database, at the same time we get any other + * properties we need - it's more efficient that way. + */ +static void ids_auxprop_lookup(void *glob_context __attribute__((unused)), + sasl_server_params_t *sparams __attribute__((unused)), + unsigned flags __attribute__((unused)), + const char *user __attribute__((unused)), + unsigned ulen __attribute__((unused))) +{ + /* do nothing - we don't need auxprops - we just do this to avoid + sasldb_auxprop_lookup */ +} + +static sasl_auxprop_plug_t ids_auxprop_plugin = { + 0, /* Features */ + 0, /* spare */ + NULL, /* glob_context */ + NULL, /* auxprop_free */ + ids_auxprop_lookup, /* auxprop_lookup */ + "iDS", /* name */ + NULL /* auxprop_store */ +}; + +int ids_auxprop_plug_init(const sasl_utils_t *utils __attribute__((unused)), + int max_version, + int *out_version, + sasl_auxprop_plug_t **plug, + const char *plugname __attribute__((unused))) +{ + if(!out_version || !plug) return SASL_BADPARAM; + + if(max_version < SASL_AUXPROP_PLUG_VERSION) return SASL_BADVERS; + + *out_version = SASL_AUXPROP_PLUG_VERSION; + + *plug = &ids_auxprop_plugin; + + return SASL_OK; +} + static int ids_sasl_getopt( void *context, const char *plugin_name, @@ -121,6 +171,8 @@ static int ids_sasl_getopt( if (LDAPDebugLevelIsSet(LDAP_DEBUG_TRACE)) { *result = "6"; /* SASL_LOG_TRACE */ } + } else if (strcasecmp(option, "auxprop_plugin") == 0) { + *result = "iDS"; } if (*result) *len = strlen(*result); @@ -576,6 +628,8 @@ int ids_sasl_init(void) #endif #endif + result = sasl_auxprop_add_plugin("iDS", ids_auxprop_plug_init); + LDAPDebug( LDAP_DEBUG_TRACE, "<= ids_sasl_init\n", 0, 0, 0 ); return result;
0
89160f7aa5007a553fb4cc8e69bb9c61d6c2899a
389ds/389-ds-base
Issue 5526 - RFE - Improve saslauthd migration options (#5528) Bug Description: We should improve our migration paths from openldap to allow the commonly used saslauthd plugin. Fix Description: This adds the import transform to convert users to use the nsSaslauthId field. This also adds a helper in migration to enable the plugins as needed. Finally this also adds some hardening to pam_pta. fixes: https://github.com/389ds/389-ds-base/issues/5526 Author: William Brown <[email protected]> Review by: @progier389
commit 89160f7aa5007a553fb4cc8e69bb9c61d6c2899a Author: Firstyear <[email protected]> Date: Thu Nov 24 09:55:46 2022 +1000 Issue 5526 - RFE - Improve saslauthd migration options (#5528) Bug Description: We should improve our migration paths from openldap to allow the commonly used saslauthd plugin. Fix Description: This adds the import transform to convert users to use the nsSaslauthId field. This also adds a helper in migration to enable the plugins as needed. Finally this also adds some hardening to pam_pta. fixes: https://github.com/389ds/389-ds-base/issues/5526 Author: William Brown <[email protected]> Review by: @progier389 diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config.ldif new file mode 100644 index 000000000..e9b19f154 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config.ldif @@ -0,0 +1,39 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 7edbd1a7 +dn: cn=config +objectClass: olcGlobal +cn: config +olcConfigFile: /etc/openldap/slapd.conf +olcConfigDir: /root/slapd.d +olcAttributeOptions: lang- +olcAuthzPolicy: none +olcConcurrency: 0 +olcConnMaxPending: 100 +olcConnMaxPendingAuth: 1000 +olcGentleHUP: FALSE +olcIdleTimeout: 0 +olcIndexSubstrIfMaxLen: 4 +olcIndexSubstrIfMinLen: 2 +olcIndexSubstrAnyLen: 4 +olcIndexSubstrAnyStep: 2 +olcIndexIntLen: 4 +olcListenerThreads: 1 +olcLocalSSF: 71 +olcLogLevel: 0 +olcReadOnly: FALSE +olcSaslSecProps: noplain,noanonymous +olcSockbufMaxIncoming: 262143 +olcSockbufMaxIncomingAuth: 16777215 +olcThreads: 16 +olcTLSCRLCheck: none +olcTLSVerifyClient: never +olcTLSProtocolMin: 0.0 +olcToolThreads: 1 +olcWriteTimeout: 0 +structuralObjectClass: olcGlobal +entryUUID: 7ed3eeea-f8e9-103c-8ebf-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=module{0}.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=module{0}.ldif new file mode 100644 index 000000000..b7cfd8698 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=module{0}.ldif @@ -0,0 +1,16 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 5a12264a +dn: cn=module{0} +objectClass: olcModuleList +cn: module{0} +olcModuleLoad: {0}back_mdb.la +olcModuleLoad: {1}memberof.la +olcModuleLoad: {2}refint.la +olcModuleLoad: {3}unique.la +structuralObjectClass: olcModuleList +entryUUID: 7ed3fc32-f8e9-103c-8ec0-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema.ldif new file mode 100644 index 000000000..8c54f94ba --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema.ldif @@ -0,0 +1,669 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 84ab7aa0 +dn: cn=schema +objectClass: olcSchemaConfig +cn: schema +olcObjectIdentifier: OLcfg 1.3.6.1.4.1.4203.1.12.2 +olcObjectIdentifier: OLcfgAt OLcfg:3 +olcObjectIdentifier: OLcfgGlAt OLcfgAt:0 +olcObjectIdentifier: OLcfgBkAt OLcfgAt:1 +olcObjectIdentifier: OLcfgDbAt OLcfgAt:2 +olcObjectIdentifier: OLcfgOvAt OLcfgAt:3 +olcObjectIdentifier: OLcfgCtAt OLcfgAt:4 +olcObjectIdentifier: OLcfgOc OLcfg:4 +olcObjectIdentifier: OLcfgGlOc OLcfgOc:0 +olcObjectIdentifier: OLcfgBkOc OLcfgOc:1 +olcObjectIdentifier: OLcfgDbOc OLcfgOc:2 +olcObjectIdentifier: OLcfgOvOc OLcfgOc:3 +olcObjectIdentifier: OLcfgCtOc OLcfgOc:4 +olcObjectIdentifier: OMsyn 1.3.6.1.4.1.1466.115.121.1 +olcObjectIdentifier: OMsBoolean OMsyn:7 +olcObjectIdentifier: OMsDN OMsyn:12 +olcObjectIdentifier: OMsDirectoryString OMsyn:15 +olcObjectIdentifier: OMsIA5String OMsyn:26 +olcObjectIdentifier: OMsInteger OMsyn:27 +olcObjectIdentifier: OMsOID OMsyn:38 +olcObjectIdentifier: OMsOctetString OMsyn:40 +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' X-BINARY-TRA + NSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' X-NOT-HU + MAN-READABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Descrip + tion' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' X-NOT-HUMAN-REA + DABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' X-NOT-HUMAN-RE + ADABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' X-BINARY- + TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' X-BI + NARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' X-B + INARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.666.11.10.2.1 DESC 'X.509 AttributeCerti + ficate' X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' ) +olcLdapSyntaxes: ( 1.2.36.79672281.1.5.0 DESC 'RDN' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Desc + ription' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule De + scription' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone N + umber' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' X-NOT-HUMAN-READ + ABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' X-NOT-HUMAN-REA + DABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Acc + ess Points' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Descrip + tion' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Des + cription' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID + ' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description + ' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Descript + ion' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' + ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' + ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' + ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' + X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Iden + tifier' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Descripti + on' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definitio + n' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Descripti + on' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' + ) +olcLdapSyntaxes: ( 1.3.6.1.1.1.0.0 DESC 'RFC2307 NIS Netgroup Triple' ) +olcLdapSyntaxes: ( 1.3.6.1.1.1.0.1 DESC 'RFC2307 Boot Parameter' ) +olcLdapSyntaxes: ( 1.3.6.1.1.15.1 DESC 'Certificate Exact Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.1.15.2 DESC 'Certificate Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.1.15.3 DESC 'Certificate Pair Exact Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.1.15.4 DESC 'Certificate Pair Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.1.15.5 DESC 'Certificate List Exact Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.1.15.6 DESC 'Certificate List Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.1.15.7 DESC 'Algorithm Identifier' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.666.11.10.2.2 DESC 'AttributeCertificate + Exact Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.666.11.10.2.3 DESC 'AttributeCertificate + Assertion' ) +olcLdapSyntaxes: ( 1.3.6.1.1.16.1 DESC 'UUID' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.666.11.2.1 DESC 'CSN' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.666.11.2.4 DESC 'CSN SID' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.1.1.1 DESC 'OpenLDAP void' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.666.2.7 DESC 'OpenLDAP authz' ) +olcLdapSyntaxes: ( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' + ) +olcAttributeTypes: ( 2.5.4.0 NAME 'objectClass' DESC 'RFC4512: object classe + s of the entity' EQUALITY objectIdentifierMatch SYNTAX 1.3.6.1.4.1.1466.115 + .121.1.38 ) +olcAttributeTypes: ( 2.5.21.9 NAME 'structuralObjectClass' DESC 'RFC4512: st + ructural object class of entry' EQUALITY objectIdentifierMatch SYNTAX 1.3.6 + .1.4.1.1466.115.121.1.38 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryO + peration ) +olcAttributeTypes: ( 2.5.18.1 NAME 'createTimestamp' DESC 'RFC4512: time whi + ch object was created' EQUALITY generalizedTimeMatch ORDERING generalizedTi + meOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE NO-USER-M + ODIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.18.2 NAME 'modifyTimestamp' DESC 'RFC4512: time whi + ch object was last modified' EQUALITY generalizedTimeMatch ORDERING general + izedTimeOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE NO- + USER-MODIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.18.3 NAME 'creatorsName' DESC 'RFC4512: name of cre + ator' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 + SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.18.4 NAME 'modifiersName' DESC 'RFC4512: name of la + st modifier' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.12 + 1.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.18.9 NAME 'hasSubordinates' DESC 'X.501: entry has + children' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE- + VALUE NO-USER-MODIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.18.10 NAME 'subschemaSubentry' DESC 'RFC4512: name + of controlling subschema entry' EQUALITY distinguishedNameMatch SYNTAX 1.3. + 6.1.4.1.1466.115.121.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE directory + Operation ) +olcAttributeTypes: ( 2.5.18.12 NAME 'collectiveAttributeSubentries' DESC 'RF + C3671: collective attribute subentries' EQUALITY distinguishedNameMatch SYN + TAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION USAGE directoryOpera + tion ) +olcAttributeTypes: ( 2.5.18.7 NAME 'collectiveExclusions' DESC 'RFC3671: col + lective attribute exclusions' EQUALITY objectIdentifierMatch SYNTAX 1.3.6.1 + .4.1.1466.115.121.1.38 USAGE directoryOperation ) +olcAttributeTypes: ( 1.3.6.1.1.20 NAME 'entryDN' DESC 'DN of the entry' EQUA + LITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VAL + UE NO-USER-MODIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 1.3.6.1.1.16.4 NAME 'entryUUID' DESC 'UUID of the entry + ' EQUALITY UUIDMatch ORDERING UUIDOrderingMatch SYNTAX 1.3.6.1.1.16.1 SINGL + E-VALUE NO-USER-MODIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' DESC 'change s + equence number of the entry content' EQUALITY CSNMatch ORDERING CSNOrdering + Match SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} SINGLE-VALUE NO-USER-MODIFICAT + ION USAGE directoryOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' DESC 'change + sequence number of the entry naming (RDN)' EQUALITY CSNMatch ORDERING CSNO + rderingMatch SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} SINGLE-VALUE NO-USER-MO + DIFICATION USAGE directoryOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.23 NAME 'syncreplCookie' DESC 's + yncrepl Cookie for shadow copy' EQUALITY octetStringMatch ORDERING octetStr + ingOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE NO-USER- + MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.25 NAME 'contextCSN' DESC 'the l + argest committed CSN of a context' EQUALITY CSNMatch ORDERING CSNOrderingMa + tch SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} NO-USER-MODIFICATION USAGE dSAOp + eration ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' DESC 'RFC45 + 12: alternative servers' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOper + ation ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.120.5 NAME 'namingContexts' DESC ' + RFC4512: naming contexts' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOpe + ration ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.120.13 NAME 'supportedControl' DES + C 'RFC4512: supported controls' SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE + dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.120.7 NAME 'supportedExtension' DE + SC 'RFC4512: supported extended operations' SYNTAX 1.3.6.1.4.1.1466.115.121 + .1.38 USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.120.15 NAME 'supportedLDAPVersion' + DESC 'RFC4512: supported LDAP versions' SYNTAX 1.3.6.1.4.1.1466.115.121.1. + 27 USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.120.14 NAME 'supportedSASLMechanis + ms' DESC 'RFC4512: supported SASL mechanisms' SYNTAX 1.3.6.1.4.1.1466.115.1 + 21.1.15 USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.1.3.5 NAME 'supportedFeatures' DESC 'R + FC4512: features supported by the server' EQUALITY objectIdentifierMatch SY + NTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.10 NAME 'monitorContext' DESC 'm + onitor context' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115 + .121.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.1.12.2.1 NAME 'configContext' DESC 'co + nfig context' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.1 + 21.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.1.4 NAME 'vendorName' DESC 'RFC3045: name of im + plementation vendor' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.12 + 1.1.15 SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.1.5 NAME 'vendorVersion' DESC 'RFC3045: version + of implementation' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121 + .1.15 SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 2.5.18.5 NAME 'administrativeRole' DESC 'RFC3672: admin + istrative role' EQUALITY objectIdentifierMatch SYNTAX 1.3.6.1.4.1.1466.115. + 121.1.38 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.18.6 NAME 'subtreeSpecification' DESC 'RFC3672: sub + tree specification' SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 SINGLE-VALUE USAGE + directoryOperation ) +olcAttributeTypes: ( 2.5.21.1 NAME 'dITStructureRules' DESC 'RFC4512: DIT st + ructure rules' EQUALITY integerFirstComponentMatch SYNTAX 1.3.6.1.4.1.1466. + 115.121.1.17 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.21.2 NAME 'dITContentRules' DESC 'RFC4512: DIT cont + ent rules' EQUALITY objectIdentifierFirstComponentMatch SYNTAX 1.3.6.1.4.1. + 1466.115.121.1.16 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.21.4 NAME 'matchingRules' DESC 'RFC4512: matching r + ules' EQUALITY objectIdentifierFirstComponentMatch SYNTAX 1.3.6.1.4.1.1466. + 115.121.1.30 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.21.5 NAME 'attributeTypes' DESC 'RFC4512: attribute + types' EQUALITY objectIdentifierFirstComponentMatch SYNTAX 1.3.6.1.4.1.146 + 6.115.121.1.3 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.21.6 NAME 'objectClasses' DESC 'RFC4512: object cla + sses' EQUALITY objectIdentifierFirstComponentMatch SYNTAX 1.3.6.1.4.1.1466. + 115.121.1.37 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.21.7 NAME 'nameForms' DESC 'RFC4512: name forms ' E + QUALITY objectIdentifierFirstComponentMatch SYNTAX 1.3.6.1.4.1.1466.115.121 + .1.35 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.21.8 NAME 'matchingRuleUse' DESC 'RFC4512: matching + rule uses' EQUALITY objectIdentifierFirstComponentMatch SYNTAX 1.3.6.1.4.1 + .1466.115.121.1.31 USAGE directoryOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' DESC 'R + FC4512: LDAP syntaxes' EQUALITY objectIdentifierFirstComponentMatch SYNTAX + 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation ) +olcAttributeTypes: ( 2.5.4.1 NAME ( 'aliasedObjectName' 'aliasedEntryName' ) + DESC 'RFC4512: name of aliased object' EQUALITY distinguishedNameMatch SYN + TAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) +olcAttributeTypes: ( 2.16.840.1.113730.3.1.34 NAME 'ref' DESC 'RFC3296: subo + rdinate referral URL' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.1 + 21.1.15 USAGE distributedOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.1.3.1 NAME 'entry' DESC 'OpenLDAP ACL + entry pseudo-attribute' SYNTAX 1.3.6.1.4.1.4203.1.1.1 SINGLE-VALUE NO-USER- + MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.1.3.2 NAME 'children' DESC 'OpenLDAP A + CL children pseudo-attribute' SYNTAX 1.3.6.1.4.1.4203.1.1.1 SINGLE-VALUE NO + -USER-MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.8 NAME ( 'authzTo' 'saslAuthzTo' + ) DESC 'proxy authorization targets' EQUALITY authzMatch SYNTAX 1.3.6.1.4. + 1.4203.666.2.7 USAGE distributedOperation X-ORDERED 'VALUES' ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.9 NAME ( 'authzFrom' 'saslAuthzF + rom' ) DESC 'proxy authorization sources' EQUALITY authzMatch SYNTAX 1.3.6. + 1.4.1.4203.666.2.7 USAGE distributedOperation X-ORDERED 'VALUES' ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' DESC 'RFC258 + 9: entry time-to-live' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE NO + -USER-MODIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 1.3.6.1.4.1.1466.101.119.4 NAME 'dynamicSubtrees' DESC + 'RFC2589: dynamic subtrees' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MO + DIFICATION USAGE dSAOperation ) +olcAttributeTypes: ( 2.5.4.49 NAME 'distinguishedName' DESC 'RFC4519: common + supertype of DN attributes' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1 + .4.1.1466.115.121.1.12 ) +olcAttributeTypes: ( 2.5.4.41 NAME 'name' DESC 'RFC4519: common supertype of + name attributes' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} ) +olcAttributeTypes: ( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC4519: commo + n name(s) for which the entity is known by' SUP name ) +olcAttributeTypes: ( 0.9.2342.19200300.100.1.1 NAME ( 'uid' 'userid' ) DESC + 'RFC4519: user identifier' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstr + ingsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: ( 1.3.6.1.1.1.1.0 NAME 'uidNumber' DESC 'RFC2307: An inte + ger uniquely identifying a user in an administrative domain' EQUALITY integ + erMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +olcAttributeTypes: ( 1.3.6.1.1.1.1.1 NAME 'gidNumber' DESC 'RFC2307: An inte + ger uniquely identifying a group in an administrative domain' EQUALITY inte + gerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +olcAttributeTypes: ( 2.5.4.35 NAME 'userPassword' DESC 'RFC4519/2307: passwo + rd of user' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{ + 128} ) +olcAttributeTypes: ( 1.3.6.1.4.1.250.1.57 NAME 'labeledURI' DESC 'RFC2079: U + niform Resource Identifier with optional label' EQUALITY caseExactMatch SYN + TAX 1.3.6.1.4.1.1466.115.121.1.15 ) +olcAttributeTypes: ( 2.5.4.13 NAME 'description' DESC 'RFC4519: descriptive + information' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNT + AX 1.3.6.1.4.1.1466.115.121.1.15{1024} ) +olcAttributeTypes: ( 2.5.4.34 NAME 'seeAlso' DESC 'RFC4519: DN of related ob + ject' SUP distinguishedName ) +olcAttributeTypes: ( OLcfgGlAt:78 NAME 'olcConfigFile' DESC 'File for slapd + configuration directives' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryStrin + g SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:79 NAME 'olcConfigDir' DESC 'Directory for sl + apd configuration backend' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryStri + ng SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:1 NAME 'olcAccess' DESC 'Access Control List' + EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:86 NAME 'olcAddContentAcl' DESC 'Check ACLs a + gainst content of Add ops' SYNTAX OMsBoolean SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:2 NAME 'olcAllows' DESC 'Allowed set of depre + cated features' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:3 NAME 'olcArgsFile' DESC 'File for slapd com + mand line options' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryString SINGL + E-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:5 NAME 'olcAttributeOptions' EQUALITY caseIgn + oreMatch SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:4 NAME 'olcAttributeTypes' DESC 'OpenLDAP att + ributeTypes' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNT + AX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' EQUALITY caseIgnore + Match SYNTAX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:7 NAME 'olcAuthzPolicy' EQUALITY caseIgnoreMa + tch SYNTAX OMsDirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:8 NAME 'olcAuthzRegexp' EQUALITY caseIgnoreMa + tch SYNTAX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:9 NAME 'olcBackend' DESC 'A type of backend' + EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED ' + SIBLINGS' ) +olcAttributeTypes: ( OLcfgGlAt:10 NAME 'olcConcurrency' SYNTAX OMsInteger SI + NGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:11 NAME 'olcConnMaxPending' SYNTAX OMsInteger + SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' SYNTAX OMsInt + eger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:13 NAME 'olcDatabase' DESC 'The backend type + for a database instance' SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' ) +olcAttributeTypes: ( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' SYNTAX OMsDN S + INGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:15 NAME 'olcDisallows' EQUALITY caseIgnoreMat + ch SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:16 NAME 'olcDitContentRules' DESC 'OpenLDAP D + IT content rules' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch + SYNTAX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgDbAt:0.20 NAME 'olcExtraAttrs' EQUALITY caseIgnore + Match SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:17 NAME 'olcGentleHUP' SYNTAX OMsBoolean SING + LE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.17 NAME 'olcHidden' SYNTAX OMsBoolean SINGL + E-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:18 NAME 'olcIdleTimeout' SYNTAX OMsInteger SI + NGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:19 NAME 'olcInclude' SUP labeledURI ) +olcAttributeTypes: ( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' SYNTAX OMsIn + teger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' SYNTAX OMsIn + teger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' SYNTAX OMsInte + ger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' SYNTAX OMsInt + eger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:84 NAME 'olcIndexIntLen' SYNTAX OMsInteger SI + NGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.4 NAME 'olcLastMod' SYNTAX OMsBoolean SINGL + E-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' DESC 'OpenLDAP ldap + Syntax' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX OM + sDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgDbAt:0.5 NAME 'olcLimits' EQUALITY caseIgnoreMatch + SYNTAX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:93 NAME 'olcListenerThreads' SYNTAX OMsIntege + r SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:26 NAME 'olcLocalSSF' SYNTAX OMsInteger SINGL + E-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:27 NAME 'olcLogFile' SYNTAX OMsDirectoryStrin + g SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:28 NAME 'olcLogLevel' EQUALITY caseIgnoreMatc + h SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' SYNTAX OMsInteger + SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.16 NAME 'olcMirrorMode' SYNTAX OMsBoolean S + INGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:30 NAME 'olcModuleLoad' EQUALITY caseIgnoreMa + tch SYNTAX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:31 NAME 'olcModulePath' SYNTAX OMsDirectorySt + ring SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.18 NAME 'olcMonitoring' SYNTAX OMsBoolean S + INGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:32 NAME 'olcObjectClasses' DESC 'OpenLDAP obj + ect classes' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNT + AX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:33 NAME 'olcObjectIdentifier' EQUALITY caseIg + noreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX OMsDirectoryString X-ORDE + RED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:34 NAME 'olcOverlay' SUP olcDatabase SINGLE-V + ALUE X-ORDERED 'SIBLINGS' ) +olcAttributeTypes: ( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' SYNTAX O + MsDirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:36 NAME 'olcPasswordHash' EQUALITY caseIgnore + Match SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:37 NAME 'olcPidFile' SYNTAX OMsDirectoryStrin + g SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:38 NAME 'olcPlugin' EQUALITY caseIgnoreMatch + SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:39 NAME 'olcPluginLogFile' SYNTAX OMsDirector + yString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:40 NAME 'olcReadOnly' SYNTAX OMsBoolean SINGL + E-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:41 NAME 'olcReferral' SUP labeledURI SINGLE-V + ALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.7 NAME 'olcReplica' SUP labeledURI EQUALITY + caseIgnoreMatch X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' SYNTAX OMsDirect + oryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:44 NAME 'olcReplicaPidFile' SYNTAX OMsDirecto + ryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:45 NAME 'olcReplicationInterval' SYNTAX OMsIn + teger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:46 NAME 'olcReplogFile' SYNTAX OMsDirectorySt + ring SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:47 NAME 'olcRequires' EQUALITY caseIgnoreMatc + h SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:48 NAME 'olcRestrict' EQUALITY caseIgnoreMatc + h SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:49 NAME 'olcReverseLookup' SYNTAX OMsBoolean + SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.8 NAME 'olcRootDN' EQUALITY distinguishedNa + meMatch SYNTAX OMsDN SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:51 NAME 'olcRootDSE' EQUALITY caseIgnoreMatch + SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgDbAt:0.9 NAME 'olcRootPW' SYNTAX OMsDirectoryStrin + g SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:89 NAME 'olcSaslAuxprops' SYNTAX OMsDirectory + String SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:53 NAME 'olcSaslHost' SYNTAX OMsDirectoryStri + ng SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:54 NAME 'olcSaslRealm' SYNTAX OMsDirectoryStr + ing SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:56 NAME 'olcSaslSecProps' SYNTAX OMsDirectory + String SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:58 NAME 'olcSchemaDN' EQUALITY distinguishedN + ameMatch SYNTAX OMsDN SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:59 NAME 'olcSecurity' EQUALITY caseIgnoreMatc + h SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:81 NAME 'olcServerID' EQUALITY caseIgnoreMatc + h SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:60 NAME 'olcSizeLimit' SYNTAX OMsDirectoryStr + ing SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' SYNTAX OMsInt + eger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' SYNTAX OM + sInteger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:83 NAME 'olcSortVals' DESC 'Attributes whose + values will always be sorted' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryS + tring ) +olcAttributeTypes: ( OLcfgDbAt:0.15 NAME 'olcSubordinate' SYNTAX OMsDirector + yString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.10 NAME 'olcSuffix' EQUALITY distinguishedN + ameMatch SYNTAX OMsDN ) +olcAttributeTypes: ( OLcfgDbAt:0.19 NAME 'olcSyncUseSubentry' DESC 'Store sy + nc context in a subentry' SYNTAX OMsBoolean SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.11 NAME 'olcSyncrepl' EQUALITY caseIgnoreMa + tch SYNTAX OMsDirectoryString X-ORDERED 'VALUES' ) +olcAttributeTypes: ( OLcfgGlAt:90 NAME 'olcTCPBuffer' DESC 'Custom TCP buffe + r size' SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgGlAt:66 NAME 'olcThreads' SYNTAX OMsInteger SINGLE + -VALUE ) +olcAttributeTypes: ( OLcfgGlAt:67 NAME 'olcTimeLimit' SYNTAX OMsDirectoryStr + ing ) +olcAttributeTypes: ( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' SYNTAX OMsD + irectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' SYNTAX OMsD + irectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' SYNTAX OMsDir + ectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' SYNTAX OMs + DirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' SYNTAX OMsDirecto + ryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' SYNTAX OMsDirectoryS + tring SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:82 NAME 'olcTLSCRLFile' SYNTAX OMsDirectorySt + ring SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:74 NAME 'olcTLSRandFile' SYNTAX OMsDirectoryS + tring SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' SYNTAX OMsDirect + oryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' SYNTAX OMsDirecto + ryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' SYNTAX OMsDirecto + ryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgGlAt:80 NAME 'olcToolThreads' SYNTAX OMsInteger SI + NGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.12 NAME 'olcUpdateDN' SYNTAX OMsDN SINGLE-V + ALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.13 NAME 'olcUpdateRef' SUP labeledURI EQUAL + ITY caseIgnoreMatch ) +olcAttributeTypes: ( OLcfgGlAt:88 NAME 'olcWriteTimeout' SYNTAX OMsInteger S + INGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.1 NAME 'olcDbDirectory' DESC 'Directory for + database content' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryString SINGL + E-VALUE ) +olcAttributeTypes: ( 1.3.6.1.4.1.4203.666.1.5 NAME 'OpenLDAPaci' DESC 'OpenL + DAP access control information (experimental)' EQUALITY OpenLDAPaciMatch SY + NTAX 1.3.6.1.4.1.4203.666.2.1 USAGE directoryOperation ) +olcAttributeTypes: ( OLcfgDbAt:1.2 NAME 'olcDbCheckpoint' DESC 'Database che + ckpoint interval in kbytes and minutes' SYNTAX OMsDirectoryString SINGLE-VA + LUE ) +olcAttributeTypes: ( OLcfgDbAt:1.4 NAME 'olcDbNoSync' DESC 'Disable synchron + ous database writes' SYNTAX OMsBoolean SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:12.3 NAME 'olcDbEnvFlags' DESC 'Database envi + ronment flags' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgDbAt:0.2 NAME 'olcDbIndex' DESC 'Attribute index p + arameters' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryString ) +olcAttributeTypes: ( OLcfgDbAt:12.1 NAME 'olcDbMaxReaders' DESC 'Maximum num + ber of threads that may access the DB concurrently' SYNTAX OMsInteger SINGL + E-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:12.2 NAME 'olcDbMaxSize' DESC 'Maximum size o + f DB in bytes' SYNTAX OMsInteger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:0.3 NAME 'olcDbMode' DESC 'Unix permissions o + f database files' SYNTAX OMsDirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:12.5 NAME 'olcDbRtxnSize' DESC 'Number of ent + ries to process in one read transaction' SYNTAX OMsInteger SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgDbAt:1.9 NAME 'olcDbSearchStack' DESC 'Depth of se + arch stack in IDLs' SYNTAX OMsInteger SINGLE-VALUE ) +olcAttributeTypes: ( 1.2.840.113556.1.2.102 NAME 'memberOf' DESC 'Group that + the entry belongs to' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1 + 466.115.121.1.12 USAGE dSAOperation X-ORIGIN 'iPlanet Delegated Administrat + or' ) +olcAttributeTypes: ( OLcfgOvAt:18.0 NAME 'olcMemberOfDN' DESC 'DN to be used + as modifiersName' SYNTAX OMsDN SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:18.1 NAME 'olcMemberOfDangling' DESC 'Behavio + r with respect to dangling members, constrained to ignore, drop, error' SYN + TAX OMsDirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:18.2 NAME 'olcMemberOfRefInt' DESC 'Take care + of referential integrity' SYNTAX OMsBoolean SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:18.3 NAME 'olcMemberOfGroupOC' DESC 'Group ob + jectClass' SYNTAX OMsDirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:18.4 NAME 'olcMemberOfMemberAD' DESC 'member + attribute' SYNTAX OMsDirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:18.5 NAME 'olcMemberOfMemberOfAD' DESC 'membe + rOf attribute' SYNTAX OMsDirectoryString SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:18.7 NAME 'olcMemberOfDanglingError' DESC 'Er + ror code returned in case of dangling back reference' SYNTAX OMsDirectorySt + ring SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:11.1 NAME 'olcRefintAttribute' DESC 'Attribut + es for referential integrity' EQUALITY caseIgnoreMatch SYNTAX OMsDirectoryS + tring ) +olcAttributeTypes: ( OLcfgOvAt:11.2 NAME 'olcRefintNothing' DESC 'Replacemen + t DN to supply when needed' SYNTAX OMsDN SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:11.3 NAME 'olcRefintModifiersName' DESC 'The + DN to use as modifiersName' SYNTAX OMsDN SINGLE-VALUE ) +olcAttributeTypes: ( OLcfgOvAt:10.1 NAME 'olcUniqueBase' DESC 'Subtree for u + niqueness searches' EQUALITY distinguishedNameMatch SYNTAX OMsDN SINGLE-VAL + UE ) +olcAttributeTypes: ( OLcfgOvAt:10.2 NAME 'olcUniqueIgnore' DESC 'Attributes + for which uniqueness shall not be enforced' EQUALITY caseIgnoreMatch ORDERI + NG caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX OMsDirec + toryString ) +olcAttributeTypes: ( OLcfgOvAt:10.3 NAME 'olcUniqueAttribute' DESC 'Attribut + es for which uniqueness shall be enforced' EQUALITY caseIgnoreMatch ORDERIN + G caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX OMsDirect + oryString ) +olcAttributeTypes: ( OLcfgOvAt:10.4 NAME 'olcUniqueStrict' DESC 'Enforce uni + queness of null values' EQUALITY booleanMatch SYNTAX OMsBoolean SINGLE-VALU + E ) +olcAttributeTypes: ( OLcfgOvAt:10.5 NAME 'olcUniqueURI' DESC 'List of keywor + ds and LDAP URIs for a uniqueness domain' EQUALITY caseExactMatch ORDERING + caseExactOrderingMatch SUBSTR caseExactSubstringsMatch SYNTAX OMsDirectoryS + tring ) +olcObjectClasses: ( 2.5.6.0 NAME 'top' DESC 'top of the superclass chain' AB + STRACT MUST objectClass ) +olcObjectClasses: ( 1.3.6.1.4.1.1466.101.120.111 NAME 'extensibleObject' DES + C 'RFC4512: extensible object' SUP top AUXILIARY ) +olcObjectClasses: ( 2.5.6.1 NAME 'alias' DESC 'RFC4512: an alias' SUP top ST + RUCTURAL MUST aliasedObjectName ) +olcObjectClasses: ( 2.16.840.1.113730.3.2.6 NAME 'referral' DESC 'namedref: + named subordinate referral' SUP top STRUCTURAL MUST ref ) +olcObjectClasses: ( 1.3.6.1.4.1.4203.1.4.1 NAME ( 'OpenLDAProotDSE' 'LDAProo + tDSE' ) DESC 'OpenLDAP Root DSE object' SUP top STRUCTURAL MAY cn ) +olcObjectClasses: ( 2.5.17.0 NAME 'subentry' DESC 'RFC3672: subentry' SUP to + p STRUCTURAL MUST ( cn $ subtreeSpecification ) ) +olcObjectClasses: ( 2.5.20.1 NAME 'subschema' DESC 'RFC4512: controlling sub + schema (sub)entry' AUXILIARY MAY ( dITStructureRules $ nameForms $ dITConte + ntRules $ objectClasses $ attributeTypes $ matchingRules $ matchingRuleUse + ) ) +olcObjectClasses: ( 2.5.17.2 NAME 'collectiveAttributeSubentry' DESC 'RFC367 + 1: collective attribute subentry' AUXILIARY ) +olcObjectClasses: ( 1.3.6.1.4.1.1466.101.119.2 NAME 'dynamicObject' DESC 'RF + C2589: Dynamic Object' SUP top AUXILIARY ) +olcObjectClasses: ( 1.3.6.1.4.1.4203.666.3.4 NAME 'glue' DESC 'Glue Entry' S + UP top STRUCTURAL ) +olcObjectClasses: ( 1.3.6.1.4.1.4203.666.3.5 NAME 'syncConsumerSubentry' DES + C 'Persistent Info for SyncRepl Consumer' AUXILIARY MAY syncreplCookie ) +olcObjectClasses: ( 1.3.6.1.4.1.4203.666.3.6 NAME 'syncProviderSubentry' DES + C 'Persistent Info for SyncRepl Producer' AUXILIARY MAY contextCSN ) +olcObjectClasses: ( OLcfgGlOc:0 NAME 'olcConfig' DESC 'OpenLDAP configuratio + n object' SUP top ABSTRACT ) +olcObjectClasses: ( OLcfgGlOc:1 NAME 'olcGlobal' DESC 'OpenLDAP Global confi + guration options' SUP olcConfig STRUCTURAL MAY ( cn $ olcConfigFile $ olcCo + nfigDir $ olcAllows $ olcArgsFile $ olcAttributeOptions $ olcAuthIDRewrite + $ olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ olcConnMaxPending $ ol + cConnMaxPendingAuth $ olcDisallows $ olcGentleHUP $ olcIdleTimeout $ olcInd + exSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ olcIndexSubstrAnyLen $ olcIndex + SubstrAnyStep $ olcIndexIntLen $ olcListenerThreads $ olcLocalSSF $ olcLogF + ile $ olcLogLevel $ olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFi + le $ olcPluginLogFile $ olcReadOnly $ olcReferral $ olcReplogFile $ olcRequ + ires $ olcRestrict $ olcReverseLookup $ olcRootDSE $ olcSaslAuxprops $ olcS + aslHost $ olcSaslRealm $ olcSaslSecProps $ olcSecurity $ olcServerID $ olcS + izeLimit $ olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ olcTCPBuffer + $ olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ olcTLSCACertificat + ePath $ olcTLSCertificateFile $ olcTLSCertificateKeyFile $ olcTLSCipherSuit + e $ olcTLSCRLCheck $ olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFil + e $ olcTLSCRLFile $ olcTLSProtocolMin $ olcToolThreads $ olcWriteTimeout $ + olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ olcDitContentR + ules $ olcLdapSyntaxes ) ) +olcObjectClasses: ( OLcfgGlOc:2 NAME 'olcSchemaConfig' DESC 'OpenLDAP schema + object' SUP olcConfig STRUCTURAL MAY ( cn $ olcObjectIdentifier $ olcLdapS + yntaxes $ olcAttributeTypes $ olcObjectClasses $ olcDitContentRules ) ) +olcObjectClasses: ( OLcfgGlOc:3 NAME 'olcBackendConfig' DESC 'OpenLDAP Backe + nd-specific options' SUP olcConfig STRUCTURAL MUST olcBackend ) +olcObjectClasses: ( OLcfgGlOc:4 NAME 'olcDatabaseConfig' DESC 'OpenLDAP Data + base-specific options' SUP olcConfig STRUCTURAL MUST olcDatabase MAY ( olcH + idden $ olcSuffix $ olcSubordinate $ olcAccess $ olcAddContentAcl $ olcLast + Mod $ olcLimits $ olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ + olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ olcReplo + gFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ olcSchemaDN $ o + lcSecurity $ olcSizeLimit $ olcSyncUseSubentry $ olcSyncrepl $ olcTimeLimit + $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ olcMonitoring $ olcExtraAtt + rs ) ) +olcObjectClasses: ( OLcfgGlOc:5 NAME 'olcOverlayConfig' DESC 'OpenLDAP Overl + ay-specific options' SUP olcConfig STRUCTURAL MUST olcOverlay ) +olcObjectClasses: ( OLcfgGlOc:6 NAME 'olcIncludeFile' DESC 'OpenLDAP configu + ration include file' SUP olcConfig STRUCTURAL MUST olcInclude MAY ( cn $ ol + cRootDSE ) ) +olcObjectClasses: ( OLcfgGlOc:7 NAME 'olcFrontendConfig' DESC 'OpenLDAP fron + tend configuration' AUXILIARY MAY ( olcDefaultSearchBase $ olcPasswordHash + $ olcSortVals ) ) +olcObjectClasses: ( OLcfgGlOc:8 NAME 'olcModuleList' DESC 'OpenLDAP dynamic + module info' SUP olcConfig STRUCTURAL MAY ( cn $ olcModulePath $ olcModuleL + oad ) ) +olcObjectClasses: ( OLcfgDbOc:2.1 NAME 'olcLdifConfig' DESC 'LDIF backend co + nfiguration' SUP olcDatabaseConfig STRUCTURAL MUST olcDbDirectory ) +olcObjectClasses: ( OLcfgDbOc:12.1 NAME 'olcMdbConfig' DESC 'MDB backend con + figuration' SUP olcDatabaseConfig STRUCTURAL MUST olcDbDirectory MAY ( olcD + bCheckpoint $ olcDbEnvFlags $ olcDbNoSync $ olcDbIndex $ olcDbMaxReaders $ + olcDbMaxSize $ olcDbMode $ olcDbSearchStack $ olcDbRtxnSize ) ) +olcObjectClasses: ( OLcfgOvOc:18.1 NAME 'olcMemberOf' DESC 'Member-of config + uration' SUP olcOverlayConfig STRUCTURAL MAY ( olcMemberOfDN $ olcMemberOfD + angling $ olcMemberOfDanglingError $ olcMemberOfRefInt $ olcMemberOfGroupOC + $ olcMemberOfMemberAD $ olcMemberOfMemberOfAD ) ) +olcObjectClasses: ( OLcfgOvOc:11.1 NAME 'olcRefintConfig' DESC 'Referential + integrity configuration' SUP olcOverlayConfig STRUCTURAL MAY ( olcRefintAtt + ribute $ olcRefintNothing $ olcRefintModifiersName ) ) +olcObjectClasses: ( OLcfgOvOc:10.1 NAME 'olcUniqueConfig' DESC 'Attribute va + lue uniqueness configuration' SUP olcOverlayConfig STRUCTURAL MAY ( olcUniq + ueBase $ olcUniqueIgnore $ olcUniqueAttribute $ olcUniqueStrict $ olcUnique + URI ) ) +structuralObjectClass: olcSchemaConfig +entryUUID: 7ed44174-f8e9-103c-8ec1-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={0}core.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={0}core.ldif new file mode 100644 index 000000000..f7a431310 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={0}core.ldif @@ -0,0 +1,247 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 49e5af84 +dn: cn={0}core +objectClass: olcSchemaConfig +cn: {0}core +olcAttributeTypes: {0}( 2.5.4.2 NAME 'knowledgeInformation' DESC 'RFC2256: k + nowledge information' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115. + 121.1.15{32768} ) +olcAttributeTypes: {1}( 2.5.4.4 NAME ( 'sn' 'surname' ) DESC 'RFC2256: last + (family) name(s) for which the entity is known by' SUP name ) +olcAttributeTypes: {2}( 2.5.4.5 NAME 'serialNumber' DESC 'RFC2256: serial nu + mber of the entity' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMat + ch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{64} ) +olcAttributeTypes: {3}( 2.5.4.6 NAME ( 'c' 'countryName' ) DESC 'RFC4519: tw + o-letter ISO-3166 country code' SUP name SYNTAX 1.3.6.1.4.1.1466.115.121.1. + 11 SINGLE-VALUE ) +olcAttributeTypes: {4}( 2.5.4.7 NAME ( 'l' 'localityName' ) DESC 'RFC2256: l + ocality which this object resides in' SUP name ) +olcAttributeTypes: {5}( 2.5.4.8 NAME ( 'st' 'stateOrProvinceName' ) DESC 'RF + C2256: state or province which this object resides in' SUP name ) +olcAttributeTypes: {6}( 2.5.4.9 NAME ( 'street' 'streetAddress' ) DESC 'RFC2 + 256: street address of this object' EQUALITY caseIgnoreMatch SUBSTR caseIgn + oreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +olcAttributeTypes: {7}( 2.5.4.10 NAME ( 'o' 'organizationName' ) DESC 'RFC22 + 56: organization this object belongs to' SUP name ) +olcAttributeTypes: {8}( 2.5.4.11 NAME ( 'ou' 'organizationalUnitName' ) DESC + 'RFC2256: organizational unit this object belongs to' SUP name ) +olcAttributeTypes: {9}( 2.5.4.12 NAME 'title' DESC 'RFC2256: title associate + d with the entity' SUP name ) +olcAttributeTypes: {10}( 2.5.4.14 NAME 'searchGuide' DESC 'RFC2256: search g + uide, deprecated by enhancedSearchGuide' SYNTAX 1.3.6.1.4.1.1466.115.121.1. + 25 ) +olcAttributeTypes: {11}( 2.5.4.15 NAME 'businessCategory' DESC 'RFC2256: bus + iness category' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch S + YNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +olcAttributeTypes: {12}( 2.5.4.16 NAME 'postalAddress' DESC 'RFC2256: postal + address' EQUALITY caseIgnoreListMatch SUBSTR caseIgnoreListSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 ) +olcAttributeTypes: {13}( 2.5.4.17 NAME 'postalCode' DESC 'RFC2256: postal co + de' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6. + 1.4.1.1466.115.121.1.15{40} ) +olcAttributeTypes: {14}( 2.5.4.18 NAME 'postOfficeBox' DESC 'RFC2256: Post O + ffice Box' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX + 1.3.6.1.4.1.1466.115.121.1.15{40} ) +olcAttributeTypes: {15}( 2.5.4.19 NAME 'physicalDeliveryOfficeName' DESC 'RF + C2256: Physical Delivery Office Name' EQUALITY caseIgnoreMatch SUBSTR caseI + gnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +olcAttributeTypes: {16}( 2.5.4.20 NAME 'telephoneNumber' DESC 'RFC2256: Tele + phone Number' EQUALITY telephoneNumberMatch SUBSTR telephoneNumberSubstring + sMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.50{32} ) +olcAttributeTypes: {17}( 2.5.4.21 NAME 'telexNumber' DESC 'RFC2256: Telex Nu + mber' SYNTAX 1.3.6.1.4.1.1466.115.121.1.52 ) +olcAttributeTypes: {18}( 2.5.4.22 NAME 'teletexTerminalIdentifier' DESC 'RFC + 2256: Teletex Terminal Identifier' SYNTAX 1.3.6.1.4.1.1466.115.121.1.51 ) +olcAttributeTypes: {19}( 2.5.4.23 NAME ( 'facsimileTelephoneNumber' 'fax' ) + DESC 'RFC2256: Facsimile (Fax) Telephone Number' SYNTAX 1.3.6.1.4.1.1466.11 + 5.121.1.22 ) +olcAttributeTypes: {20}( 2.5.4.24 NAME 'x121Address' DESC 'RFC2256: X.121 Ad + dress' EQUALITY numericStringMatch SUBSTR numericStringSubstringsMatch SYNT + AX 1.3.6.1.4.1.1466.115.121.1.36{15} ) +olcAttributeTypes: {21}( 2.5.4.25 NAME 'internationaliSDNNumber' DESC 'RFC22 + 56: international ISDN number' EQUALITY numericStringMatch SUBSTR numericSt + ringSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.36{16} ) +olcAttributeTypes: {22}( 2.5.4.26 NAME 'registeredAddress' DESC 'RFC2256: re + gistered postal address' SUP postalAddress SYNTAX 1.3.6.1.4.1.1466.115.121. + 1.41 ) +olcAttributeTypes: {23}( 2.5.4.27 NAME 'destinationIndicator' DESC 'RFC2256: + destination indicator' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstring + sMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{128} ) +olcAttributeTypes: {24}( 2.5.4.28 NAME 'preferredDeliveryMethod' DESC 'RFC22 + 56: preferred delivery method' SYNTAX 1.3.6.1.4.1.1466.115.121.1.14 SINGLE- + VALUE ) +olcAttributeTypes: {25}( 2.5.4.29 NAME 'presentationAddress' DESC 'RFC2256: + presentation address' EQUALITY presentationAddressMatch SYNTAX 1.3.6.1.4.1. + 1466.115.121.1.43 SINGLE-VALUE ) +olcAttributeTypes: {26}( 2.5.4.30 NAME 'supportedApplicationContext' DESC 'R + FC2256: supported application context' EQUALITY objectIdentifierMatch SYNTA + X 1.3.6.1.4.1.1466.115.121.1.38 ) +olcAttributeTypes: {27}( 2.5.4.31 NAME 'member' DESC 'RFC2256: member of a g + roup' SUP distinguishedName ) +olcAttributeTypes: {28}( 2.5.4.32 NAME 'owner' DESC 'RFC2256: owner (of the + object)' SUP distinguishedName ) +olcAttributeTypes: {29}( 2.5.4.33 NAME 'roleOccupant' DESC 'RFC2256: occupan + t of role' SUP distinguishedName ) +olcAttributeTypes: {30}( 2.5.4.36 NAME 'userCertificate' DESC 'RFC2256: X.50 + 9 user certificate, use ;binary' EQUALITY certificateExactMatch SYNTAX 1.3. + 6.1.4.1.1466.115.121.1.8 ) +olcAttributeTypes: {31}( 2.5.4.37 NAME 'cACertificate' DESC 'RFC2256: X.509 + CA certificate, use ;binary' EQUALITY certificateExactMatch SYNTAX 1.3.6.1. + 4.1.1466.115.121.1.8 ) +olcAttributeTypes: {32}( 2.5.4.38 NAME 'authorityRevocationList' DESC 'RFC22 + 56: X.509 authority revocation list, use ;binary' SYNTAX 1.3.6.1.4.1.1466.1 + 15.121.1.9 ) +olcAttributeTypes: {33}( 2.5.4.39 NAME 'certificateRevocationList' DESC 'RFC + 2256: X.509 certificate revocation list, use ;binary' SYNTAX 1.3.6.1.4.1.14 + 66.115.121.1.9 ) +olcAttributeTypes: {34}( 2.5.4.40 NAME 'crossCertificatePair' DESC 'RFC2256: + X.509 cross certificate pair, use ;binary' SYNTAX 1.3.6.1.4.1.1466.115.121 + .1.10 ) +olcAttributeTypes: {35}( 2.5.4.42 NAME ( 'givenName' 'gn' ) DESC 'RFC2256: f + irst name(s) for which the entity is known by' SUP name ) +olcAttributeTypes: {36}( 2.5.4.43 NAME 'initials' DESC 'RFC2256: initials of + some or all of names, but not the surname(s).' SUP name ) +olcAttributeTypes: {37}( 2.5.4.44 NAME 'generationQualifier' DESC 'RFC2256: + name qualifier indicating a generation' SUP name ) +olcAttributeTypes: {38}( 2.5.4.45 NAME 'x500UniqueIdentifier' DESC 'RFC2256: + X.500 unique identifier' EQUALITY bitStringMatch SYNTAX 1.3.6.1.4.1.1466.1 + 15.121.1.6 ) +olcAttributeTypes: {39}( 2.5.4.46 NAME 'dnQualifier' DESC 'RFC2256: DN quali + fier' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR case + IgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 ) +olcAttributeTypes: {40}( 2.5.4.47 NAME 'enhancedSearchGuide' DESC 'RFC2256: + enhanced search guide' SYNTAX 1.3.6.1.4.1.1466.115.121.1.21 ) +olcAttributeTypes: {41}( 2.5.4.48 NAME 'protocolInformation' DESC 'RFC2256: + protocol information' EQUALITY protocolInformationMatch SYNTAX 1.3.6.1.4.1. + 1466.115.121.1.42 ) +olcAttributeTypes: {42}( 2.5.4.50 NAME 'uniqueMember' DESC 'RFC2256: unique + member of a group' EQUALITY uniqueMemberMatch SYNTAX 1.3.6.1.4.1.1466.115.1 + 21.1.34 ) +olcAttributeTypes: {43}( 2.5.4.51 NAME 'houseIdentifier' DESC 'RFC2256: hous + e identifier' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYN + TAX 1.3.6.1.4.1.1466.115.121.1.15{32768} ) +olcAttributeTypes: {44}( 2.5.4.52 NAME 'supportedAlgorithms' DESC 'RFC2256: + supported algorithms' SYNTAX 1.3.6.1.4.1.1466.115.121.1.49 ) +olcAttributeTypes: {45}( 2.5.4.53 NAME 'deltaRevocationList' DESC 'RFC2256: + delta revocation list; use ;binary' SYNTAX 1.3.6.1.4.1.1466.115.121.1.9 ) +olcAttributeTypes: {46}( 2.5.4.54 NAME 'dmdName' DESC 'RFC2256: name of DMD' + SUP name ) +olcAttributeTypes: {47}( 2.5.4.65 NAME 'pseudonym' DESC 'X.520(4th): pseudon + ym for the object' SUP name ) +olcAttributeTypes: {48}( 0.9.2342.19200300.100.1.3 NAME ( 'mail' 'rfc822Mail + box' ) DESC 'RFC1274: RFC822 Mailbox' EQUALITY caseIgnoreIA5Match SUBSTR ca + seIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} ) +olcAttributeTypes: {49}( 0.9.2342.19200300.100.1.25 NAME ( 'dc' 'domainCompo + nent' ) DESC 'RFC1274/2247: domain component' EQUALITY caseIgnoreIA5Match S + UBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SIN + GLE-VALUE ) +olcAttributeTypes: {50}( 0.9.2342.19200300.100.1.37 NAME 'associatedDomain' + DESC 'RFC1274: domain associated with object' EQUALITY caseIgnoreIA5Match S + UBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {51}( 1.2.840.113549.1.9.1 NAME ( 'email' 'emailAddress' + 'pkcs9email' ) DESC 'RFC3280: legacy attribute for email addresses in DNs' + EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3. + 6.1.4.1.1466.115.121.1.26{128} ) +olcObjectClasses: {0}( 2.5.6.2 NAME 'country' DESC 'RFC2256: a country' SUP + top STRUCTURAL MUST c MAY ( searchGuide $ description ) ) +olcObjectClasses: {1}( 2.5.6.3 NAME 'locality' DESC 'RFC2256: a locality' SU + P top STRUCTURAL MAY ( street $ seeAlso $ searchGuide $ st $ l $ descriptio + n ) ) +olcObjectClasses: {2}( 2.5.6.4 NAME 'organization' DESC 'RFC2256: an organiz + ation' SUP top STRUCTURAL MUST o MAY ( userPassword $ searchGuide $ seeAlso + $ businessCategory $ x121Address $ registeredAddress $ destinationIndicato + r $ preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $ tel + ephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNumber $ street + $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOfficeName $ + st $ l $ description ) ) +olcObjectClasses: {3}( 2.5.6.5 NAME 'organizationalUnit' DESC 'RFC2256: an o + rganizational unit' SUP top STRUCTURAL MUST ou MAY ( userPassword $ searchG + uide $ seeAlso $ businessCategory $ x121Address $ registeredAddress $ desti + nationIndicator $ preferredDeliveryMethod $ telexNumber $ teletexTerminalId + entifier $ telephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNu + mber $ street $ postOfficeBox $ postalCode $ postalAddress $ physicalDelive + ryOfficeName $ st $ l $ description ) ) +olcObjectClasses: {4}( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP to + p STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAls + o $ description ) ) +olcObjectClasses: {5}( 2.5.6.7 NAME 'organizationalPerson' DESC 'RFC2256: an + organizational person' SUP person STRUCTURAL MAY ( title $ x121Address $ r + egisteredAddress $ destinationIndicator $ preferredDeliveryMethod $ telexNu + mber $ teletexTerminalIdentifier $ telephoneNumber $ internationaliSDNNumbe + r $ facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $ postal + Address $ physicalDeliveryOfficeName $ ou $ st $ l ) ) +olcObjectClasses: {6}( 2.5.6.8 NAME 'organizationalRole' DESC 'RFC2256: an o + rganizational role' SUP top STRUCTURAL MUST cn MAY ( x121Address $ register + edAddress $ destinationIndicator $ preferredDeliveryMethod $ telexNumber $ + teletexTerminalIdentifier $ telephoneNumber $ internationaliSDNNumber $ fac + simileTelephoneNumber $ seeAlso $ roleOccupant $ preferredDeliveryMethod $ + street $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOffic + eName $ ou $ st $ l $ description ) ) +olcObjectClasses: {7}( 2.5.6.9 NAME 'groupOfNames' DESC 'RFC2256: a group of + names (DNs)' SUP top STRUCTURAL MUST ( member $ cn ) MAY ( businessCategor + y $ seeAlso $ owner $ ou $ o $ description ) ) +olcObjectClasses: {8}( 2.5.6.10 NAME 'residentialPerson' DESC 'RFC2256: an r + esidential person' SUP person STRUCTURAL MUST l MAY ( businessCategory $ x1 + 21Address $ registeredAddress $ destinationIndicator $ preferredDeliveryMet + hod $ telexNumber $ teletexTerminalIdentifier $ telephoneNumber $ internati + onaliSDNNumber $ facsimileTelephoneNumber $ preferredDeliveryMethod $ stree + t $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOfficeName + $ st $ l ) ) +olcObjectClasses: {9}( 2.5.6.11 NAME 'applicationProcess' DESC 'RFC2256: an + application process' SUP top STRUCTURAL MUST cn MAY ( seeAlso $ ou $ l $ de + scription ) ) +olcObjectClasses: {10}( 2.5.6.12 NAME 'applicationEntity' DESC 'RFC2256: an + application entity' SUP top STRUCTURAL MUST ( presentationAddress $ cn ) MA + Y ( supportedApplicationContext $ seeAlso $ ou $ o $ l $ description ) ) +olcObjectClasses: {11}( 2.5.6.13 NAME 'dSA' DESC 'RFC2256: a directory syste + m agent (a server)' SUP applicationEntity STRUCTURAL MAY knowledgeInformati + on ) +olcObjectClasses: {12}( 2.5.6.14 NAME 'device' DESC 'RFC2256: a device' SUP + top STRUCTURAL MUST cn MAY ( serialNumber $ seeAlso $ owner $ ou $ o $ l $ + description ) ) +olcObjectClasses: {13}( 2.5.6.15 NAME 'strongAuthenticationUser' DESC 'RFC22 + 56: a strong authentication user' SUP top AUXILIARY MUST userCertificate ) +olcObjectClasses: {14}( 2.5.6.16 NAME 'certificationAuthority' DESC 'RFC2256 + : a certificate authority' SUP top AUXILIARY MUST ( authorityRevocationList + $ certificateRevocationList $ cACertificate ) MAY crossCertificatePair ) +olcObjectClasses: {15}( 2.5.6.17 NAME 'groupOfUniqueNames' DESC 'RFC2256: a + group of unique names (DN and Unique Identifier)' SUP top STRUCTURAL MUST ( + uniqueMember $ cn ) MAY ( businessCategory $ seeAlso $ owner $ ou $ o $ de + scription ) ) +olcObjectClasses: {16}( 2.5.6.18 NAME 'userSecurityInformation' DESC 'RFC225 + 6: a user security information' SUP top AUXILIARY MAY supportedAlgorithms ) +olcObjectClasses: {17}( 2.5.6.16.2 NAME 'certificationAuthority-V2' SUP cert + ificationAuthority AUXILIARY MAY deltaRevocationList ) +olcObjectClasses: {18}( 2.5.6.19 NAME 'cRLDistributionPoint' SUP top STRUCTU + RAL MUST cn MAY ( certificateRevocationList $ authorityRevocationList $ del + taRevocationList ) ) +olcObjectClasses: {19}( 2.5.6.20 NAME 'dmd' SUP top STRUCTURAL MUST dmdName + MAY ( userPassword $ searchGuide $ seeAlso $ businessCategory $ x121Address + $ registeredAddress $ destinationIndicator $ preferredDeliveryMethod $ tel + exNumber $ teletexTerminalIdentifier $ telephoneNumber $ internationaliSDNN + umber $ facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $ po + stalAddress $ physicalDeliveryOfficeName $ st $ l $ description ) ) +olcObjectClasses: {20}( 2.5.6.21 NAME 'pkiUser' DESC 'RFC2587: a PKI user' S + UP top AUXILIARY MAY userCertificate ) +olcObjectClasses: {21}( 2.5.6.22 NAME 'pkiCA' DESC 'RFC2587: PKI certificate + authority' SUP top AUXILIARY MAY ( authorityRevocationList $ certificateRe + vocationList $ cACertificate $ crossCertificatePair ) ) +olcObjectClasses: {22}( 2.5.6.23 NAME 'deltaCRL' DESC 'RFC2587: PKI user' SU + P top AUXILIARY MAY deltaRevocationList ) +olcObjectClasses: {23}( 1.3.6.1.4.1.250.3.15 NAME 'labeledURIObject' DESC 'R + FC2079: object that contains the URI attribute type' SUP top AUXILIARY MAY + labeledURI ) +olcObjectClasses: {24}( 0.9.2342.19200300.100.4.19 NAME 'simpleSecurityObjec + t' DESC 'RFC1274: simple security object' SUP top AUXILIARY MUST userPasswo + rd ) +olcObjectClasses: {25}( 1.3.6.1.4.1.1466.344 NAME 'dcObject' DESC 'RFC2247: + domain component object' SUP top AUXILIARY MUST dc ) +olcObjectClasses: {26}( 1.3.6.1.1.3.1 NAME 'uidObject' DESC 'RFC2377: uid ob + ject' SUP top AUXILIARY MUST uid ) +structuralObjectClass: olcSchemaConfig +entryUUID: 7ed45fa6-f8e9-103c-8ec2-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={1}cosine.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={1}cosine.ldif new file mode 100644 index 000000000..63892e1d3 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={1}cosine.ldif @@ -0,0 +1,178 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 90794340 +dn: cn={1}cosine +objectClass: olcSchemaConfig +cn: {1}cosine +olcAttributeTypes: {0}( 0.9.2342.19200300.100.1.2 NAME 'textEncodedORAddress + ' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1. + 4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {1}( 0.9.2342.19200300.100.1.4 NAME 'info' DESC 'RFC1274: + general information' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsM + atch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{2048} ) +olcAttributeTypes: {2}( 0.9.2342.19200300.100.1.5 NAME ( 'drink' 'favouriteD + rink' ) DESC 'RFC1274: favorite drink' EQUALITY caseIgnoreMatch SUBSTR case + IgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {3}( 0.9.2342.19200300.100.1.6 NAME 'roomNumber' DESC 'RF + C1274: room number' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMat + ch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {4}( 0.9.2342.19200300.100.1.7 NAME 'photo' DESC 'RFC1274 + : photo (G3 fax)' SYNTAX 1.3.6.1.4.1.1466.115.121.1.23{25000} ) +olcAttributeTypes: {5}( 0.9.2342.19200300.100.1.8 NAME 'userClass' DESC 'RFC + 1274: category of user' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstring + sMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {6}( 0.9.2342.19200300.100.1.9 NAME 'host' DESC 'RFC1274: + host computer' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch S + YNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {7}( 0.9.2342.19200300.100.1.10 NAME 'manager' DESC 'RFC1 + 274: DN of manager' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466 + .115.121.1.12 ) +olcAttributeTypes: {8}( 0.9.2342.19200300.100.1.11 NAME 'documentIdentifier' + DESC 'RFC1274: unique identifier of document' EQUALITY caseIgnoreMatch SUB + STR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {9}( 0.9.2342.19200300.100.1.12 NAME 'documentTitle' DESC + 'RFC1274: title of document' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSub + stringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {10}( 0.9.2342.19200300.100.1.13 NAME 'documentVersion' D + ESC 'RFC1274: version of document' EQUALITY caseIgnoreMatch SUBSTR caseIgno + reSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {11}( 0.9.2342.19200300.100.1.14 NAME 'documentAuthor' DE + SC 'RFC1274: DN of author of document' EQUALITY distinguishedNameMatch SYNT + AX 1.3.6.1.4.1.1466.115.121.1.12 ) +olcAttributeTypes: {12}( 0.9.2342.19200300.100.1.15 NAME 'documentLocation' + DESC 'RFC1274: location of document original' EQUALITY caseIgnoreMatch SUBS + TR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {13}( 0.9.2342.19200300.100.1.20 NAME ( 'homePhone' 'home + TelephoneNumber' ) DESC 'RFC1274: home telephone number' EQUALITY telephone + NumberMatch SUBSTR telephoneNumberSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.1 + 15.121.1.50 ) +olcAttributeTypes: {14}( 0.9.2342.19200300.100.1.21 NAME 'secretary' DESC 'R + FC1274: DN of secretary' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1 + .1466.115.121.1.12 ) +olcAttributeTypes: {15}( 0.9.2342.19200300.100.1.22 NAME 'otherMailbox' SYNT + AX 1.3.6.1.4.1.1466.115.121.1.39 ) +olcAttributeTypes: {16}( 0.9.2342.19200300.100.1.26 NAME 'aRecord' EQUALITY + caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {17}( 0.9.2342.19200300.100.1.27 NAME 'mDRecord' EQUALITY + caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {18}( 0.9.2342.19200300.100.1.28 NAME 'mXRecord' EQUALITY + caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {19}( 0.9.2342.19200300.100.1.29 NAME 'nSRecord' EQUALITY + caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {20}( 0.9.2342.19200300.100.1.30 NAME 'sOARecord' EQUALIT + Y caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {21}( 0.9.2342.19200300.100.1.31 NAME 'cNAMERecord' EQUAL + ITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {22}( 0.9.2342.19200300.100.1.38 NAME 'associatedName' DE + SC 'RFC1274: DN of entry associated with domain' EQUALITY distinguishedName + Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) +olcAttributeTypes: {23}( 0.9.2342.19200300.100.1.39 NAME 'homePostalAddress' + DESC 'RFC1274: home postal address' EQUALITY caseIgnoreListMatch SUBSTR ca + seIgnoreListSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 ) +olcAttributeTypes: {24}( 0.9.2342.19200300.100.1.40 NAME 'personalTitle' DES + C 'RFC1274: personal title' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubst + ringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {25}( 0.9.2342.19200300.100.1.41 NAME ( 'mobile' 'mobileT + elephoneNumber' ) DESC 'RFC1274: mobile telephone number' EQUALITY telephon + eNumberMatch SUBSTR telephoneNumberSubstringsMatch SYNTAX 1.3.6.1.4.1.1466. + 115.121.1.50 ) +olcAttributeTypes: {26}( 0.9.2342.19200300.100.1.42 NAME ( 'pager' 'pagerTel + ephoneNumber' ) DESC 'RFC1274: pager telephone number' EQUALITY telephoneNu + mberMatch SUBSTR telephoneNumberSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115 + .121.1.50 ) +olcAttributeTypes: {27}( 0.9.2342.19200300.100.1.43 NAME ( 'co' 'friendlyCou + ntryName' ) DESC 'RFC1274: friendly country name' EQUALITY caseIgnoreMatch + SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) +olcAttributeTypes: {28}( 0.9.2342.19200300.100.1.44 NAME 'uniqueIdentifier' + DESC 'RFC1274: unique identifer' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4. + 1.1466.115.121.1.15{256} ) +olcAttributeTypes: {29}( 0.9.2342.19200300.100.1.45 NAME 'organizationalStat + us' DESC 'RFC1274: organizational status' EQUALITY caseIgnoreMatch SUBSTR c + aseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {30}( 0.9.2342.19200300.100.1.46 NAME 'janetMailbox' DESC + 'RFC1274: Janet mailbox' EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5S + ubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} ) +olcAttributeTypes: {31}( 0.9.2342.19200300.100.1.47 NAME 'mailPreferenceOpti + on' DESC 'RFC1274: mail preference option' SYNTAX 1.3.6.1.4.1.1466.115.121. + 1.27 ) +olcAttributeTypes: {32}( 0.9.2342.19200300.100.1.48 NAME 'buildingName' DESC + 'RFC1274: name of building' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubs + tringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +olcAttributeTypes: {33}( 0.9.2342.19200300.100.1.49 NAME 'dSAQuality' DESC ' + RFC1274: DSA Quality' SYNTAX 1.3.6.1.4.1.1466.115.121.1.19 SINGLE-VALUE ) +olcAttributeTypes: {34}( 0.9.2342.19200300.100.1.50 NAME 'singleLevelQuality + ' DESC 'RFC1274: Single Level Quality' SYNTAX 1.3.6.1.4.1.1466.115.121.1.13 + SINGLE-VALUE ) +olcAttributeTypes: {35}( 0.9.2342.19200300.100.1.51 NAME 'subtreeMinimumQual + ity' DESC 'RFC1274: Subtree Mininum Quality' SYNTAX 1.3.6.1.4.1.1466.115.12 + 1.1.13 SINGLE-VALUE ) +olcAttributeTypes: {36}( 0.9.2342.19200300.100.1.52 NAME 'subtreeMaximumQual + ity' DESC 'RFC1274: Subtree Maximun Quality' SYNTAX 1.3.6.1.4.1.1466.115.12 + 1.1.13 SINGLE-VALUE ) +olcAttributeTypes: {37}( 0.9.2342.19200300.100.1.53 NAME 'personalSignature' + DESC 'RFC1274: Personal Signature (G3 fax)' SYNTAX 1.3.6.1.4.1.1466.115.12 + 1.1.23 ) +olcAttributeTypes: {38}( 0.9.2342.19200300.100.1.54 NAME 'dITRedirect' DESC + 'RFC1274: DIT Redirect' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1. + 1466.115.121.1.12 ) +olcAttributeTypes: {39}( 0.9.2342.19200300.100.1.55 NAME 'audio' DESC 'RFC12 + 74: audio (u-law)' SYNTAX 1.3.6.1.4.1.1466.115.121.1.4{25000} ) +olcAttributeTypes: {40}( 0.9.2342.19200300.100.1.56 NAME 'documentPublisher' + DESC 'RFC1274: publisher of document' EQUALITY caseIgnoreMatch SUBSTR case + IgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) +olcObjectClasses: {0}( 0.9.2342.19200300.100.4.4 NAME ( 'pilotPerson' 'newPi + lotPerson' ) SUP person STRUCTURAL MAY ( userid $ textEncodedORAddress $ rf + c822Mailbox $ favouriteDrink $ roomNumber $ userClass $ homeTelephoneNumber + $ homePostalAddress $ secretary $ personalTitle $ preferredDeliveryMethod + $ businessCategory $ janetMailbox $ otherMailbox $ mobileTelephoneNumber $ + pagerTelephoneNumber $ organizationalStatus $ mailPreferenceOption $ person + alSignature ) ) +olcObjectClasses: {1}( 0.9.2342.19200300.100.4.5 NAME 'account' SUP top STRU + CTURAL MUST userid MAY ( description $ seeAlso $ localityName $ organizatio + nName $ organizationalUnitName $ host ) ) +olcObjectClasses: {2}( 0.9.2342.19200300.100.4.6 NAME 'document' SUP top STR + UCTURAL MUST documentIdentifier MAY ( commonName $ description $ seeAlso $ + localityName $ organizationName $ organizationalUnitName $ documentTitle $ + documentVersion $ documentAuthor $ documentLocation $ documentPublisher ) ) +olcObjectClasses: {3}( 0.9.2342.19200300.100.4.7 NAME 'room' SUP top STRUCTU + RAL MUST commonName MAY ( roomNumber $ description $ seeAlso $ telephoneNum + ber ) ) +olcObjectClasses: {4}( 0.9.2342.19200300.100.4.9 NAME 'documentSeries' SUP t + op STRUCTURAL MUST commonName MAY ( description $ seeAlso $ telephonenumber + $ localityName $ organizationName $ organizationalUnitName ) ) +olcObjectClasses: {5}( 0.9.2342.19200300.100.4.13 NAME 'domain' SUP top STRU + CTURAL MUST domainComponent MAY ( associatedName $ organizationName $ descr + iption $ businessCategory $ seeAlso $ searchGuide $ userPassword $ locality + Name $ stateOrProvinceName $ streetAddress $ physicalDeliveryOfficeName $ p + ostalAddress $ postalCode $ postOfficeBox $ streetAddress $ facsimileTeleph + oneNumber $ internationalISDNNumber $ telephoneNumber $ teletexTerminalIden + tifier $ telexNumber $ preferredDeliveryMethod $ destinationIndicator $ reg + isteredAddress $ x121Address ) ) +olcObjectClasses: {6}( 0.9.2342.19200300.100.4.14 NAME 'RFC822localPart' SUP + domain STRUCTURAL MAY ( commonName $ surname $ description $ seeAlso $ tel + ephoneNumber $ physicalDeliveryOfficeName $ postalAddress $ postalCode $ po + stOfficeBox $ streetAddress $ facsimileTelephoneNumber $ internationalISDNN + umber $ telephoneNumber $ teletexTerminalIdentifier $ telexNumber $ preferr + edDeliveryMethod $ destinationIndicator $ registeredAddress $ x121Address ) + ) +olcObjectClasses: {7}( 0.9.2342.19200300.100.4.15 NAME 'dNSDomain' SUP domai + n STRUCTURAL MAY ( ARecord $ MDRecord $ MXRecord $ NSRecord $ SOARecord $ C + NAMERecord ) ) +olcObjectClasses: {8}( 0.9.2342.19200300.100.4.17 NAME 'domainRelatedObject' + DESC 'RFC1274: an object related to an domain' SUP top AUXILIARY MUST asso + ciatedDomain ) +olcObjectClasses: {9}( 0.9.2342.19200300.100.4.18 NAME 'friendlyCountry' SUP + country STRUCTURAL MUST friendlyCountryName ) +olcObjectClasses: {10}( 0.9.2342.19200300.100.4.20 NAME 'pilotOrganization' + SUP ( organization $ organizationalUnit ) STRUCTURAL MAY buildingName ) +olcObjectClasses: {11}( 0.9.2342.19200300.100.4.21 NAME 'pilotDSA' SUP dsa S + TRUCTURAL MAY dSAQuality ) +olcObjectClasses: {12}( 0.9.2342.19200300.100.4.22 NAME 'qualityLabelledData + ' SUP top AUXILIARY MUST dsaQuality MAY ( subtreeMinimumQuality $ subtreeMa + ximumQuality ) ) +structuralObjectClass: olcSchemaConfig +entryUUID: 7ed48b0c-f8e9-103c-8ec3-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={2}inetorgperson.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={2}inetorgperson.ldif new file mode 100644 index 000000000..85a358e1d --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={2}inetorgperson.ldif @@ -0,0 +1,49 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 c2e2b45e +dn: cn={2}inetorgperson +objectClass: olcSchemaConfig +cn: {2}inetorgperson +olcAttributeTypes: {0}( 2.16.840.1.113730.3.1.1 NAME 'carLicense' DESC 'RFC2 + 798: vehicle license or registration plate' EQUALITY caseIgnoreMatch SUBSTR + caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) +olcAttributeTypes: {1}( 2.16.840.1.113730.3.1.2 NAME 'departmentNumber' DESC + 'RFC2798: identifies a department within an organization' EQUALITY caseIgn + oreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1 + .15 ) +olcAttributeTypes: {2}( 2.16.840.1.113730.3.1.241 NAME 'displayName' DESC 'R + FC2798: preferred name to be used when displaying entries' EQUALITY caseIgn + oreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1 + .15 SINGLE-VALUE ) +olcAttributeTypes: {3}( 2.16.840.1.113730.3.1.3 NAME 'employeeNumber' DESC ' + RFC2798: numerically identifies an employee within an organization' EQUALIT + Y caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466. + 115.121.1.15 SINGLE-VALUE ) +olcAttributeTypes: {4}( 2.16.840.1.113730.3.1.4 NAME 'employeeType' DESC 'RF + C2798: type of employment for a person' EQUALITY caseIgnoreMatch SUBSTR cas + eIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) +olcAttributeTypes: {5}( 0.9.2342.19200300.100.1.60 NAME 'jpegPhoto' DESC 'RF + C2798: a JPEG image' SYNTAX 1.3.6.1.4.1.1466.115.121.1.28 ) +olcAttributeTypes: {6}( 2.16.840.1.113730.3.1.39 NAME 'preferredLanguage' DE + SC 'RFC2798: preferred written or spoken language for a person' EQUALITY ca + seIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115. + 121.1.15 SINGLE-VALUE ) +olcAttributeTypes: {7}( 2.16.840.1.113730.3.1.40 NAME 'userSMIMECertificate' + DESC 'RFC2798: PKCS#7 SignedData used to support S/MIME' SYNTAX 1.3.6.1.4. + 1.1466.115.121.1.5 ) +olcAttributeTypes: {8}( 2.16.840.1.113730.3.1.216 NAME 'userPKCS12' DESC 'RF + C2798: personal identity information, a PKCS #12 PFX' SYNTAX 1.3.6.1.4.1.14 + 66.115.121.1.5 ) +olcObjectClasses: {0}( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson' DESC 'RF + C2798: Internet Organizational Person' SUP organizationalPerson STRUCTURAL + MAY ( audio $ businessCategory $ carLicense $ departmentNumber $ displayNam + e $ employeeNumber $ employeeType $ givenName $ homePhone $ homePostalAddre + ss $ initials $ jpegPhoto $ labeledURI $ mail $ manager $ mobile $ o $ page + r $ photo $ roomNumber $ secretary $ uid $ userCertificate $ x500uniqueIden + tifier $ preferredLanguage $ userSMIMECertificate $ userPKCS12 ) ) +structuralObjectClass: olcSchemaConfig +entryUUID: 7ed4987c-f8e9-103c-8ec4-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={3}rfc2307bis.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={3}rfc2307bis.ldif new file mode 100644 index 000000000..7f86655f9 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={3}rfc2307bis.ldif @@ -0,0 +1,155 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 3dd68676 +dn: cn={3}rfc2307bis +objectClass: olcSchemaConfig +cn: {3}rfc2307bis +olcAttributeTypes: {0}( 1.3.6.1.1.1.1.2 NAME 'gecos' DESC 'The GECOS field; + the common name' EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5Substrings + Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +olcAttributeTypes: {1}( 1.3.6.1.1.1.1.3 NAME 'homeDirectory' DESC 'The absol + ute path to the home directory' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4 + .1.1466.115.121.1.26 SINGLE-VALUE ) +olcAttributeTypes: {2}( 1.3.6.1.1.1.1.4 NAME 'loginShell' DESC 'The path to + the login shell' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121 + .1.26 SINGLE-VALUE ) +olcAttributeTypes: {3}( 1.3.6.1.1.1.1.5 NAME 'shadowLastChange' EQUALITY int + egerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {4}( 1.3.6.1.1.1.1.6 NAME 'shadowMin' EQUALITY integerMat + ch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {5}( 1.3.6.1.1.1.1.7 NAME 'shadowMax' EQUALITY integerMat + ch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {6}( 1.3.6.1.1.1.1.8 NAME 'shadowWarning' EQUALITY intege + rMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {7}( 1.3.6.1.1.1.1.9 NAME 'shadowInactive' EQUALITY integ + erMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {8}( 1.3.6.1.1.1.1.10 NAME 'shadowExpire' EQUALITY intege + rMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {9}( 1.3.6.1.1.1.1.11 NAME 'shadowFlag' EQUALITY integerM + atch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {10}( 1.3.6.1.1.1.1.12 NAME 'memberUid' EQUALITY caseExac + tIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {11}( 1.3.6.1.1.1.1.13 NAME 'memberNisNetgroup' EQUALITY + caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.146 + 6.115.121.1.26 ) +olcAttributeTypes: {12}( 1.3.6.1.1.1.1.14 NAME 'nisNetgroupTriple' DESC 'Net + group triple' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1 + .26 ) +olcAttributeTypes: {13}( 1.3.6.1.1.1.1.15 NAME 'ipServicePort' DESC 'Service + port number' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SI + NGLE-VALUE ) +olcAttributeTypes: {14}( 1.3.6.1.1.1.1.16 NAME 'ipServiceProtocol' DESC 'Ser + vice protocol name' SUP name ) +olcAttributeTypes: {15}( 1.3.6.1.1.1.1.17 NAME 'ipProtocolNumber' DESC 'IP p + rotocol number' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +olcAttributeTypes: {16}( 1.3.6.1.1.1.1.18 NAME 'oncRpcNumber' DESC 'ONC RPC + number' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-V + ALUE ) +olcAttributeTypes: {17}( 1.3.6.1.1.1.1.19 NAME 'ipHostNumber' DESC 'IPv4 add + resses as a dotted decimal omitting leading zeros or IPv6 addresses + as defined in RFC2373' SUP name ) +olcAttributeTypes: {18}( 1.3.6.1.1.1.1.20 NAME 'ipNetworkNumber' DESC 'IP ne + twork as a dotted decimal, eg. 192.168, omitting leading zeros' SUP + name SINGLE-VALUE ) +olcAttributeTypes: {19}( 1.3.6.1.1.1.1.21 NAME 'ipNetmaskNumber' DESC 'IP ne + tmask as a dotted decimal, eg. 255.255.255.0, omitting leading zeros + ' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-V + ALUE ) +olcAttributeTypes: {20}( 1.3.6.1.1.1.1.22 NAME 'macAddress' DESC 'MAC addres + s in maximal, colon separated hex notation, eg. 00:00:92:90:ee:e2' E + QUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {21}( 1.3.6.1.1.1.1.23 NAME 'bootParameter' DESC 'rpc.boo + tparamd parameter' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.1 + 21.1.26 ) +olcAttributeTypes: {22}( 1.3.6.1.1.1.1.24 NAME 'bootFile' DESC 'Boot image n + ame' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {23}( 1.3.6.1.1.1.1.26 NAME 'nisMapName' DESC 'Name of a + A generic NIS map' SUP name ) +olcAttributeTypes: {24}( 1.3.6.1.1.1.1.27 NAME 'nisMapEntry' DESC 'A generic + NIS entry' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch S + YNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +olcAttributeTypes: {25}( 1.3.6.1.1.1.1.28 NAME 'nisPublicKey' DESC 'NIS publ + ic key' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SING + LE-VALUE ) +olcAttributeTypes: {26}( 1.3.6.1.1.1.1.29 NAME 'nisSecretKey' DESC 'NIS secr + et key' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SING + LE-VALUE ) +olcAttributeTypes: {27}( 1.3.6.1.1.1.1.30 NAME 'nisDomain' DESC 'NIS domain' + EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {28}( 1.3.6.1.1.1.1.31 NAME 'automountMapName' DESC 'auto + mount Map Name' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMat + ch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +olcAttributeTypes: {29}( 1.3.6.1.1.1.1.32 NAME 'automountKey' DESC 'Automoun + t Key value' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +olcAttributeTypes: {30}( 1.3.6.1.1.1.1.33 NAME 'automountInformation' DESC ' + Automount information' EQUALITY caseExactIA5Match SUBSTR caseExactIA5Substr + ingsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +olcObjectClasses: {0}( 1.3.6.1.1.1.2.0 NAME 'posixAccount' DESC 'Abstraction + of an account with POSIX attributes' SUP top AUXILIARY MUST ( cn $ uid $ u + idNumber $ gidNumber $ homeDirectory ) MAY ( userPassword $ loginShell $ ge + cos $ description ) ) +olcObjectClasses: {1}( 1.3.6.1.1.1.2.1 NAME 'shadowAccount' DESC 'Additional + attributes for shadow passwords' SUP top AUXILIARY MUST uid MAY ( userPass + word $ description $ shadowLastChange $ shadowMin $ shadowMax $ shadowWarni + ng $ shadowInactive $ shadowExpire $ shadowFlag ) ) +olcObjectClasses: {2}( 1.3.6.1.1.1.2.2 NAME 'posixGroup' DESC 'Abstraction o + f a group of accounts' SUP top AUXILIARY MUST gidNumber MAY ( userPassword + $ memberUid $ description ) ) +olcObjectClasses: {3}( 1.3.6.1.1.1.2.3 NAME 'ipService' DESC 'Abstraction an + Internet Protocol service. Maps an IP port and protocol (such as tc + p or udp) to one or more names; the distinguished value of th + e cn attribute denotes the services canonical name' SUP top STRUCTUR + AL MUST ( cn $ ipServicePort $ ipServiceProtocol ) MAY description ) +olcObjectClasses: {4}( 1.3.6.1.1.1.2.4 NAME 'ipProtocol' DESC 'Abstraction o + f an IP protocol. Maps a protocol number to one or more names. The d + istinguished value of the cn attribute denotes the protocols canonic + al name' SUP top STRUCTURAL MUST ( cn $ ipProtocolNumber ) MAY description + ) +olcObjectClasses: {5}( 1.3.6.1.1.1.2.5 NAME 'oncRpc' DESC 'Abstraction of an + Open Network Computing (ONC) [RFC1057] Remote Procedure Call (RPC) b + inding. This class maps an ONC RPC number to a name. The distin + guished value of the cn attribute denotes the RPC services canonical + name' SUP top STRUCTURAL MUST ( cn $ oncRpcNumber ) MAY description ) +olcObjectClasses: {6}( 1.3.6.1.1.1.2.6 NAME 'ipHost' DESC 'Abstraction of a + host, an IP device. The distinguished value of the cn attribute deno + tes the hosts canonical name. Device SHOULD be used as a structural + class' SUP top AUXILIARY MUST ( cn $ ipHostNumber ) MAY ( userPassword $ l + $ description $ manager ) ) +olcObjectClasses: {7}( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' DESC 'Abstraction of + a network. The distinguished value of the cn attribute denotes the + networks canonical name' SUP top STRUCTURAL MUST ipNetworkNumber MAY ( cn $ + ipNetmaskNumber $ l $ description $ manager ) ) +olcObjectClasses: {8}( 1.3.6.1.1.1.2.8 NAME 'nisNetgroup' DESC 'Abstraction + of a netgroup. May refer to other netgroups' SUP top STRUCTURAL MUST cn MAY + ( nisNetgroupTriple $ memberNisNetgroup $ description ) ) +olcObjectClasses: {9}( 1.3.6.1.1.1.2.9 NAME 'nisMap' DESC 'A generic abstrac + tion of a NIS map' SUP top STRUCTURAL MUST nisMapName MAY description ) +olcObjectClasses: {10}( 1.3.6.1.1.1.2.10 NAME 'nisObject' DESC 'An entry in + a NIS map' SUP top STRUCTURAL MUST ( cn $ nisMapEntry $ nisMapName ) MAY de + scription ) +olcObjectClasses: {11}( 1.3.6.1.1.1.2.11 NAME 'ieee802Device' DESC 'A device + with a MAC address; device SHOULD be used as a structural class' SU + P top AUXILIARY MAY macAddress ) +olcObjectClasses: {12}( 1.3.6.1.1.1.2.12 NAME 'bootableDevice' DESC 'A devic + e with boot parameters; device SHOULD be used as a structural class' + SUP top AUXILIARY MAY ( bootFile $ bootParameter ) ) +olcObjectClasses: {13}( 1.3.6.1.1.1.2.14 NAME 'nisKeyObject' DESC 'An object + with a public and secret key' SUP top AUXILIARY MUST ( cn $ nisPublicKey $ + nisSecretKey ) MAY ( uidNumber $ description ) ) +olcObjectClasses: {14}( 1.3.6.1.1.1.2.15 NAME 'nisDomainObject' DESC 'Associ + ates a NIS domain with a naming context' SUP top AUXILIARY MUST nisDomain ) +olcObjectClasses: {15}( 1.3.6.1.1.1.2.16 NAME 'automountMap' SUP top STRUCTU + RAL MUST automountMapName MAY description ) +olcObjectClasses: {16}( 1.3.6.1.1.1.2.17 NAME 'automount' DESC 'Automount in + formation' SUP top STRUCTURAL MUST ( automountKey $ automountInformation ) + MAY description ) +olcObjectClasses: {17}( 1.3.6.1.4.1.5322.13.1.1 NAME 'namedObject' SUP top S + TRUCTURAL MAY cn ) +structuralObjectClass: olcSchemaConfig +entryUUID: 7ed4a4a2-f8e9-103c-8ec5-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={4}yast.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={4}yast.ldif new file mode 100644 index 000000000..cc0f1e998 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/cn=schema/cn={4}yast.ldif @@ -0,0 +1,108 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 4ad098e5 +dn: cn={4}yast +objectClass: olcSchemaConfig +cn: {4}yast +olcObjectIdentifier: {0}SUSE 1.3.6.1.4.1.7057 +olcObjectIdentifier: {1}SUSE.YaST SUSE:10.1 +olcObjectIdentifier: {2}SUSE.YaST.ModuleConfig SUSE:10.1.2 +olcObjectIdentifier: {3}SUSE.YaST.ModuleConfig.OC SUSE.YaST.ModuleConfig:1 +olcObjectIdentifier: {4}SUSE.YaST.ModuleConfig.Attr SUSE.YaST.ModuleConfig:2 +olcAttributeTypes: {0}( SUSE.YaST.ModuleConfig.Attr:2 NAME 'suseDefaultBase' + DESC 'Base DN where new Objects should be created by default' EQUALITY dis + tinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) +olcAttributeTypes: {1}( SUSE.YaST.ModuleConfig.Attr:3 NAME 'suseNextUniqueId + ' DESC 'Next unused unique ID, can be used to generate directory wide uniqe + IDs' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4. + 1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {2}( SUSE.YaST.ModuleConfig.Attr:4 NAME 'suseMinUniqueId' + DESC 'lower Border for Unique IDs' EQUALITY integerMatch ORDERING integerO + rderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {3}( SUSE.YaST.ModuleConfig.Attr:5 NAME 'suseMaxUniqueId' + DESC 'upper Border for Unique IDs' EQUALITY integerMatch ORDERING integerO + rderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +olcAttributeTypes: {4}( SUSE.YaST.ModuleConfig.Attr:6 NAME 'suseDefaultTempl + ate' DESC 'The DN of a template that should be used by default' EQUALITY di + stinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) +olcAttributeTypes: {5}( SUSE.YaST.ModuleConfig.Attr:7 NAME 'suseSearchFilter + ' DESC 'Search filter to localize Objects' SYNTAX 1.3.6.1.4.1.1466.115.121. + 1.15 SINGLE-VALUE ) +olcAttributeTypes: {6}( SUSE.YaST.ModuleConfig.Attr:11 NAME 'suseDefaultValu + e' DESC 'an Attribute-Value-Assertions to define defaults for specific Attr + ibutes' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) +olcAttributeTypes: {7}( SUSE.YaST.ModuleConfig.Attr:12 NAME 'suseNamingAttri + bute' DESC 'AttributeType that should be used as the RDN' EQUALITY caseIgno + reIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +olcAttributeTypes: {8}( SUSE.YaST.ModuleConfig.Attr:15 NAME 'suseSecondaryGr + oup' DESC 'seconday group DN' EQUALITY distinguishedNameMatch SYNTAX 1.3.6. + 1.4.1.1466.115.121.1.12 ) +olcAttributeTypes: {9}( SUSE.YaST.ModuleConfig.Attr:16 NAME 'suseMinPassword + Length' DESC 'minimum Password length for new users' EQUALITY integerMatch + ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-V + ALUE ) +olcAttributeTypes: {10}( SUSE.YaST.ModuleConfig.Attr:17 NAME 'suseMaxPasswor + dLength' DESC 'maximum Password length for new users' EQUALITY integerMatch + ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE- + VALUE ) +olcAttributeTypes: {11}( SUSE.YaST.ModuleConfig.Attr:18 NAME 'susePasswordHa + sh' DESC 'Hash method to use for new users' EQUALITY caseIgnoreIA5Match SYN + TAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +olcAttributeTypes: {12}( SUSE.YaST.ModuleConfig.Attr:19 NAME 'suseSkelDir' D + ESC '' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {13}( SUSE.YaST.ModuleConfig.Attr:20 NAME 'susePlugin' DE + SC 'plugin to use upon user/ group creation' EQUALITY caseIgnoreMatch SYNTA + X 1.3.6.1.4.1.1466.115.121.1.15 ) +olcAttributeTypes: {14}( SUSE.YaST.ModuleConfig.Attr:21 NAME 'suseMapAttribu + te' DESC '' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) +olcAttributeTypes: {15}( SUSE.YaST.ModuleConfig.Attr:22 NAME 'suseImapServer + ' DESC '' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SIN + GLE-VALUE ) +olcAttributeTypes: {16}( SUSE.YaST.ModuleConfig.Attr:23 NAME 'suseImapAdmin' + DESC '' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SING + LE-VALUE ) +olcAttributeTypes: {17}( SUSE.YaST.ModuleConfig.Attr:24 NAME 'suseImapDefaul + tQuota' DESC '' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 + SINGLE-VALUE ) +olcAttributeTypes: {18}( SUSE.YaST.ModuleConfig.Attr:25 NAME 'suseImapUseSsl + ' DESC '' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE- + VALUE ) +olcObjectClasses: {0}( SUSE.YaST.ModuleConfig.OC:2 NAME 'suseModuleConfigura + tion' DESC 'Contains configuration of Management Modules' SUP top STRUCTURA + L MUST cn MAY suseDefaultBase ) +olcObjectClasses: {1}( SUSE.YaST.ModuleConfig.OC:3 NAME 'suseUserConfigurati + on' DESC 'Configuration of user management tools' SUP suseModuleConfigurati + on STRUCTURAL MAY ( suseMinPasswordLength $ suseMaxPasswordLength $ susePas + swordHash $ suseSkelDir $ suseNextUniqueId $ suseMinUniqueId $ suseMaxUniqu + eId $ suseDefaultTemplate $ suseSearchFilter $ suseMapAttribute ) ) +olcObjectClasses: {2}( SUSE.YaST.ModuleConfig.OC:4 NAME 'suseObjectTemplate' + DESC 'Base Class for Object-Templates' SUP top STRUCTURAL MUST cn MAY ( su + sePlugin $ suseDefaultValue $ suseNamingAttribute ) ) +olcObjectClasses: {3}( SUSE.YaST.ModuleConfig.OC:5 NAME 'suseUserTemplate' D + ESC 'User object template' SUP suseObjectTemplate STRUCTURAL MUST cn MAY su + seSecondaryGroup ) +olcObjectClasses: {4}( SUSE.YaST.ModuleConfig.OC:6 NAME 'suseGroupTemplate' + DESC 'Group object template' SUP suseObjectTemplate STRUCTURAL MUST cn ) +olcObjectClasses: {5}( SUSE.YaST.ModuleConfig.OC:7 NAME 'suseGroupConfigurat + ion' DESC 'Configuration of user management tools' SUP suseModuleConfigurat + ion STRUCTURAL MAY ( suseNextUniqueId $ suseMinUniqueId $ suseMaxUniqueId $ + suseDefaultTemplate $ suseSearchFilter $ suseMapAttribute ) ) +olcObjectClasses: {6}( SUSE.YaST.ModuleConfig.OC:8 NAME 'suseCaConfiguration + ' DESC 'Configuration of CA management tools' SUP suseModuleConfiguration S + TRUCTURAL ) +olcObjectClasses: {7}( SUSE.YaST.ModuleConfig.OC:9 NAME 'suseDnsConfiguratio + n' DESC 'Configuration of mail server management tools' SUP suseModuleConfi + guration STRUCTURAL ) +olcObjectClasses: {8}( SUSE.YaST.ModuleConfig.OC:10 NAME 'suseDhcpConfigurat + ion' DESC 'Configuration of DHCP server management tools' SUP suseModuleCon + figuration STRUCTURAL ) +olcObjectClasses: {9}( SUSE.YaST.ModuleConfig.OC:11 NAME 'suseMailConfigurat + ion' DESC 'Configuration of IMAP user management tools' SUP suseModuleConfi + guration STRUCTURAL MUST ( suseImapServer $ suseImapAdmin $ suseImapDefault + Quota $ suseImapUseSsl ) ) +structuralObjectClass: olcSchemaConfig +entryUUID: 7ed4b19a-f8e9-103c-8ec6-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={-1}frontend.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={-1}frontend.ldif new file mode 100644 index 000000000..58c387735 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={-1}frontend.ldif @@ -0,0 +1,25 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 5f134215 +dn: olcDatabase={-1}frontend +objectClass: olcDatabaseConfig +objectClass: olcFrontendConfig +olcDatabase: {-1}frontend +olcAccess: {0}to dn.base="" by * read +olcAccess: {1}to dn.base="cn=subschema" by * read +olcAccess: {2}to attrs=userPassword,userPKCS12 by self write by * auth +olcAccess: {3}to attrs=shadowLastChange by self write by * read +olcAccess: {4}to * by * read +olcAddContentAcl: FALSE +olcLastMod: TRUE +olcMaxDerefDepth: 0 +olcReadOnly: FALSE +olcSchemaDN: cn=Subschema +olcSyncUseSubentry: FALSE +olcMonitoring: FALSE +structuralObjectClass: olcDatabaseConfig +entryUUID: 7ed4b9b0-f8e9-103c-8ec7-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={0}config.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={0}config.ldif new file mode 100644 index 000000000..4301e84f9 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={0}config.ldif @@ -0,0 +1,20 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 6008748c +dn: olcDatabase={0}config +objectClass: olcDatabaseConfig +olcDatabase: {0}config +olcAccess: {0}to * by * none +olcAddContentAcl: TRUE +olcLastMod: TRUE +olcMaxDerefDepth: 15 +olcReadOnly: FALSE +olcRootDN: cn=config +olcSyncUseSubentry: FALSE +olcMonitoring: FALSE +structuralObjectClass: olcDatabaseConfig +entryUUID: 7ed4bea6-f8e9-103c-8ec8-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb.ldif new file mode 100644 index 000000000..3db6ba0f5 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb.ldif @@ -0,0 +1,31 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 1bf297e7 +dn: olcDatabase={1}mdb +objectClass: olcDatabaseConfig +objectClass: olcMdbConfig +olcDatabase: {1}mdb +olcSuffix: dc=ldapdom,dc=net +olcAddContentAcl: FALSE +olcLastMod: TRUE +olcMaxDerefDepth: 15 +olcReadOnly: FALSE +olcRootDN: cn=root,dc=ldapdom,dc=net +olcRootPW:: cGFzcw== +olcSyncUseSubentry: FALSE +olcMonitoring: FALSE +olcDbDirectory: /tmp/ldap +olcDbCheckpoint: 1024 5 +olcDbNoSync: FALSE +olcDbIndex: objectClass eq +olcDbMaxReaders: 0 +olcDbMaxSize: 10485760 +olcDbMode: 0600 +olcDbSearchStack: 16 +olcDbRtxnSize: 10000 +structuralObjectClass: olcMdbConfig +entryUUID: 7ed4c48c-f8e9-103c-8ec9-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={0}memberof.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={0}memberof.ldif new file mode 100644 index 000000000..f338491cc --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={0}memberof.ldif @@ -0,0 +1,15 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 4d7b0d30 +dn: olcOverlay={0}memberof +objectClass: olcOverlayConfig +objectClass: olcMemberOf +olcOverlay: {0}memberof +olcMemberOfDangling: ignore +olcMemberOfRefInt: FALSE +structuralObjectClass: olcMemberOf +entryUUID: 7ed4c928-f8e9-103c-8eca-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={1}unique.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={1}unique.ldif new file mode 100644 index 000000000..e996e5259 --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={1}unique.ldif @@ -0,0 +1,14 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 6651500c +dn: olcOverlay={1}unique +objectClass: olcOverlayConfig +objectClass: olcUniqueConfig +olcOverlay: {1}unique +olcUniqueURI: ldap:///?mail?sub? +structuralObjectClass: olcUniqueConfig +entryUUID: 7ed4e9d0-f8e9-103c-8ecb-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={2}refint.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={2}refint.ldif new file mode 100644 index 000000000..d62cf883c --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/slapd.d/cn=config/olcDatabase={1}mdb/olcOverlay={2}refint.ldif @@ -0,0 +1,15 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 e78c9fea +dn: olcOverlay={2}refint +objectClass: olcOverlayConfig +objectClass: olcRefintConfig +olcOverlay: {2}refint +olcRefintAttribute: member +olcRefintNothing: cn=admin,dc=example,dc=com +structuralObjectClass: olcRefintConfig +entryUUID: 7ed4ee94-f8e9-103c-8ecc-e51fa20c07f9 +creatorsName: cn=config +createTimestamp: 20221115042701Z +entryCSN: 20221115042701.652581Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20221115042701Z diff --git a/dirsrvtests/tests/data/openldap_2_389/saslauthd/suffix.ldif b/dirsrvtests/tests/data/openldap_2_389/saslauthd/suffix.ldif new file mode 100644 index 000000000..02e99887b --- /dev/null +++ b/dirsrvtests/tests/data/openldap_2_389/saslauthd/suffix.ldif @@ -0,0 +1,130 @@ +dn: dc=ldapdom,dc=net +dc: ldapdom +objectClass: top +objectClass: domain +structuralObjectClass: domain +entryUUID: 1901b5a4-f8e7-103c-8e7f-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.831536Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + +dn: ou=UnixUser,dc=ldapdom,dc=net +ou: People +ou: UnixUser +objectClass: top +objectClass: organizationalUnit +structuralObjectClass: organizationalUnit +entryUUID: 1901c6fc-f8e7-103c-8e80-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.832003Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + +dn: ou=UnixGroup,dc=ldapdom,dc=net +ou: Group +ou: UnixGroup +objectClass: top +objectClass: organizationalUnit +structuralObjectClass: organizationalUnit +entryUUID: 1901d26e-f8e7-103c-8e81-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.832297Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + +dn: uid=testuser1,ou=UnixUser,dc=ldapdom,dc=net +objectClass: account +objectClass: posixAccount +objectClass: top +objectClass: shadowAccount +uid: testuser1 +cn: testuser1 +userPassword:: e1NBU0x9d2lsbGlhbUBpZG0uYmxhY2toYXRzLm5ldC5hdQ== +loginShell: /bin/bash +uidNumber: 9000 +gidNumber: 8000 +homeDirectory: /tmp +structuralObjectClass: account +entryUUID: 1901e196-f8e7-103c-8e82-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.832685Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + +dn: uid=testuser2,ou=UnixUser,dc=ldapdom,dc=net +objectClass: account +objectClass: posixAccount +objectClass: top +objectClass: shadowAccount +uid: testuser2 +cn: testuser2 +userPassword:: e2NyeXB0fSQ2JDdzeXFxLkVRJDY4aU9XRjBCVFdDMjRhS0Uwcko4Y1V0UGQyQ + 3M3SGtydXdqRWlrY0pBRDVkTk5FZ01NSjVKazd3MnNDMmhZVXdOMnM2NXNyVFFUVTgzQUR0Mi50 + NGww +loginShell: /bin/bash +uidNumber: 9001 +gidNumber: 8000 +homeDirectory: /tmp +structuralObjectClass: account +entryUUID: 1901e920-f8e7-103c-8e83-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.832878Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + +dn: cn=group1,ou=UnixGroup,dc=ldapdom,dc=net +objectClass: groupOfNames +objectClass: posixGroup +objectClass: top +cn: group1 +gidNumber: 8000 +member: uid=testuser1,ou=UnixUser,dc=ldapdom,dc=net +member: uid=testuser2,ou=UnixUser,dc=ldapdom,dc=net +memberUid: 9000 +memberUid: 9001 +structuralObjectClass: groupOfNames +entryUUID: 1901f154-f8e7-103c-8e84-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.833088Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + +dn: cn=group2,ou=UnixGroup,dc=ldapdom,dc=net +objectClass: groupOfNames +objectClass: posixGroup +objectClass: top +cn: group2 +gidNumber: 8001 +member: uid=testuser1,ou=UnixUser,dc=ldapdom,dc=net +memberUid: 9000 +structuralObjectClass: groupOfNames +entryUUID: 1901fa28-f8e7-103c-8e85-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.833314Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + +dn: cn=group3,ou=UnixGroup,dc=ldapdom,dc=net +objectClass: groupOfNames +objectClass: posixGroup +objectClass: top +cn: group3 +gidNumber: 8002 +member: uid=testuser2,ou=UnixUser,dc=ldapdom,dc=net +memberUid: 9001 +structuralObjectClass: groupOfNames +entryUUID: 1902084c-f8e7-103c-8e86-bd7408fb505a +creatorsName: cn=root,dc=ldapdom,dc=net +createTimestamp: 20221115040951Z +entryCSN: 20221115040951.833676Z#000000#000#000000 +modifiersName: cn=root,dc=ldapdom,dc=net +modifyTimestamp: 20221115040951Z + diff --git a/ldap/schema/30ns-common.ldif b/ldap/schema/30ns-common.ldif index d820c4e09..a5fadf3be 100644 --- a/ldap/schema/30ns-common.ldif +++ b/ldap/schema/30ns-common.ldif @@ -58,6 +58,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2342 NAME 'nsSshPublicKey' DESC 'An nsSs attributeTypes: ( 2.16.840.1.113730.3.1.2343 NAME 'legalName' DESC 'An individuals legalName' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN '389 Directory Server Project' ) attributeTypes: ( 2.16.840.1.113730.3.1.2376 NAME 'nsslapd-authenticateAsDN' DESC 'LDAPI mapping DN' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE X-ORIGIN '389 Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.2377 NAME 'nsslapd-ldapiUsername' DESC 'LDAPI mapping system username' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN '389 Directory Server' ) +attributeTypes: ( 1.3.6.1.4.1.7057.20.2 NAME 'nsSaslauthId' DESC 'A map from a user to a saslauthd identity' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN '389 Directory Server' ) objectClasses: ( nsAdminDomain-oid NAME 'nsAdminDomain' DESC 'Netscape defined objectclass' SUP organizationalUnit MAY ( nsAdminDomainName ) X-ORIGIN 'Netscape' ) objectClasses: ( nsHost-oid NAME 'nsHost' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( serverHostName $ description $ l $ nsHostLocation $ nsHardwarePlatform $ nsOsVersion ) X-ORIGIN 'Netscape' ) objectClasses: ( nsAdminGroup-oid NAME 'nsAdminGroup' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsAdminGroupName $ description $ nsConfigRoot $ nsAdminSIEDN ) X-ORIGIN 'Netscape' ) @@ -79,3 +80,5 @@ objectClasses: ( 2.16.840.1.113730.3.2.334 NAME 'nsOrgPerson' DESC 'A representa X-ORIGIN '389 Directory Server Project' ) objectClasses: ( 2.16.840.1.113730.3.2.338 NAME 'nsLDAPIAuthMap' DESC 'LDAPI authentication DN mapping' SUP top MUST ( cn $ nsslapd-ldapiUsername $ nsslapd-authenticateAsDN ) MAY ( description ) X-ORIGIN '389 Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.339 NAME 'nsLDAPIFixedAuthMap' DESC 'LDAPI fixed authentication DN mapping' SUP top MUST ( cn $ uidNumber $ gidNumber $ nsslapd-authenticateAsDN ) MAY ( description ) X-ORIGIN '389 Directory Server' ) +objectClasses: ( 1.3.6.1.4.1.7057.20.3 NAME 'nsSaslauthAccount' DESC 'Allow this account to pass through auth to saslauthd' SUP top AUXILIARY MAY ( nsSaslauthId ) X-ORIGIN '389 Directory Server Project' ) + diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c index 39488e7f4..5d8ea4829 100644 --- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c +++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c @@ -234,13 +234,13 @@ do_one_pam_auth( PRBool module_thread_safe /* if not thread safe, make sure only one thread auth at a time */ ) { - MyStrBuf pam_id; + MyStrBuf pam_id = {0}; const char *binddn = NULL; Slapi_DN *bindsdn = NULL; int rc = PAM_SUCCESS; int retcode = LDAP_SUCCESS; - pam_handle_t *pam_handle; - struct my_pam_conv_str my_data; + pam_handle_t *pam_handle = NULL; + struct my_pam_conv_str my_data = {0}; struct pam_conv my_pam_conv = {pam_conv_func, NULL}; char *errmsg = NULL; /* free with PR_smprintf_free */ int locked = 0; @@ -268,6 +268,17 @@ do_one_pam_auth( goto done; /* skip the pam stuff */ } + /* + * We need to check for pam_service as null, because if it is then pam_start will fail + * before it allocates pam_handle. This causes pam_end to segfault as the pam_handle is + * invalid. + */ + if (pam_service == NULL) { + errmsg = PR_smprintf("Pam service is invalid. Contact system administrator."); + retcode = LDAP_UNWILLING_TO_PERFORM; /* user inactivated */ + goto done; /* skip the pam stuff */ + } + if (!pam_id.str) { errmsg = PR_smprintf("Bind DN [%s] is invalid or not found", binddn); retcode = LDAP_NO_SUCH_OBJECT; /* user unknown */ @@ -427,8 +438,8 @@ int pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg) { int rc = LDAP_SUCCESS; - MyStrBuf pam_id_attr; /* avoid malloc if possible */ - MyStrBuf pam_service; /* avoid malloc if possible */ + MyStrBuf pam_id_attr = {0}; /* avoid malloc if possible */ + MyStrBuf pam_service = {0}; /* avoid malloc if possible */ int method1, method2, method3; PRBool final_method; PRBool fallback = PR_FALSE; @@ -445,7 +456,7 @@ pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg) init_my_str_buf(&pam_service, cfg->pamptconfig_service); fallback = cfg->pamptconfig_fallback; - + module_thread_safe = cfg->pamptconfig_thread_safe; slapi_pblock_get(pb, SLAPI_REQCONTROLS, &reqctrls); diff --git a/src/lib389/lib389/migrate/plan.py b/src/lib389/lib389/migrate/plan.py index 98fc8e553..89677c716 100644 --- a/src/lib389/lib389/migrate/plan.py +++ b/src/lib389/lib389/migrate/plan.py @@ -10,7 +10,7 @@ from lib389.schema import Schema, Resolver from lib389.backend import Backends from lib389.migrate.openldap.config import olOverlayType -from lib389.plugins import MemberOfPlugin, ReferentialIntegrityPlugin, AttributeUniquenessPlugins +from lib389.plugins import MemberOfPlugin, ReferentialIntegrityPlugin, AttributeUniquenessPlugins, PassThroughAuthenticationPlugin, PAMPassThroughAuthPlugin, PAMPassThroughAuthConfigs import ldap import os from ldif import LDIFParser @@ -140,6 +140,21 @@ class ImportTransformer(LDIFParser): # Not found, move on. pass + # If userPassword is present AND it is a SASL map, then we migrate it to the nsSaslauthId + # type to prevent account password confusion. + try: + pw_a = amap['userpassword'] + pw = entry[pw_a][0] + if pw.startswith(b'{SASL}'): + entry.pop(pw_a) + sasl_id = pw.replace(b'{SASL}', b'') + # Add the marker objectClass and the map attr + entry[oc_a] += [b'nsSaslauthAccount'] + entry['nsSaslauthId'] = [sasl_id] + except: + # Not found, move on. + pass + # Write it out self.writer.unparse(dn, entry) @@ -457,6 +472,72 @@ class PluginPwdPolicyAudit(MigrationAction): log.info(f" * [ ] - Enable Password Policy for new accounts in {self.suffix}. See `dsconf {self.inst_name} localpwp --help` ") +class PluginPassThroughDisable(MigrationAction): + def __init__(self): + pass + + def apply(self, inst): + pta = PassThroughAuthenticationPlugin(inst) + pta.disable() + + def __unicode__(self): + return "PluginPassThroughDisable" + + def display_plan(self, log): + log.info(f" * Plugin:PassThrough Disable") + + def display_post(self, log): + pass + + +class PluginPAMPassThroughEnable(MigrationAction): + def __init__(self): + pass + + def apply(self, inst): + pta = PAMPassThroughAuthPlugin(inst) + pta.enable() + + def __unicode__(self): + return "PAMPassThroughAuthPlugin" + + def display_plan(self, log): + log.info(f" * Plugin:PamPassThrough Enable") + + def display_post(self, log): + pass + + +class PluginPAMPassThroughConfigure(MigrationAction): + def __init__(self, suffix): + self.suffix = suffix + + def apply(self, inst): + ptas = PAMPassThroughAuthConfigs(inst) + # PAMPassThroughAuthConfig + pta = ptas.ensure_state(properties = { + 'cn': 'saslauthd', + 'pamService': 'saslauthd', + 'pamIncludeSuffix': self.suffix, + 'pamFilter': '(objectClass=nsSaslauthAccount)', + 'pamIdAttr': 'nsSaslauthId', + 'pamIDMapMethod': 'ENTRY', + 'pamSecure': 'TRUE', + 'pamFallback': 'FALSE', + 'pamModuleIsThreadSafe': 'TRUE', + 'pamMissingSuffix': 'ALLOW', + }) + + def __unicode__(self): + return "PluginPAMPassThroughConfigure" + + def display_plan(self, log): + log.info(f" * Plugin:PamPassThrough Configure") + + def display_post(self, log): + log.info(f" * [ ] - Review Plugin:PAMPassThrough Migrated SASLauthd Configuration is Correct") + + class PluginUnknownManual(MigrationAction): def __init__(self, overlay): self.overlay = overlay @@ -721,6 +802,12 @@ class Migration(object): self.plan.append(PluginPwdPolicyAudit(oldb.suffix, self.inst.serverid)) else: raise Exception("Unknown overlay type, this is a bug!") + # We can't programatically detect the use of sasl authd. We can however + # create a configuration that "isn't harmful" in the case it's not used, + # and that does work in the case that it is present. + self.plan.append(PluginPassThroughDisable()) + self.plan.append(PluginPAMPassThroughEnable()) + self.plan.append(PluginPAMPassThroughConfigure(oldb.suffix)) def _gen_db_plan(self): diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py index 5e1155ef7..1b59bc2b5 100644 --- a/src/lib389/lib389/plugins.py +++ b/src/lib389/lib389/plugins.py @@ -1532,7 +1532,7 @@ class PAMPassThroughAuthConfigs(DSLdapObjects): def __init__(self, instance, basedn="cn=PAM Pass Through Auth,cn=plugins,cn=config"): super(PAMPassThroughAuthConfigs, self).__init__(instance) - self._objectclasses = ['top', 'extensibleObject', 'nsslapdplugin', 'pamConfig'] + self._objectclasses = ['top', 'extensibleObject', 'pamConfig'] self._filterattrs = ['cn'] self._scope = ldap.SCOPE_ONELEVEL self._childobject = PAMPassThroughAuthConfig
0
e8f50642bd3e19ad528b453850304611ab86506d
389ds/389-ds-base
Bug 545620 - Password cannot start with minus sign https://bugzilla.redhat.com/show_bug.cgi?id=545620 Previously getopt would interpret initial '-' in root password as an option which could lead to setup failure. Now a special argument '--' has been added before the password to distinguish it from other options.
commit e8f50642bd3e19ad528b453850304611ab86506d Author: Endi S. Dewata <[email protected]> Date: Wed Mar 3 13:25:45 2010 -0600 Bug 545620 - Password cannot start with minus sign https://bugzilla.redhat.com/show_bug.cgi?id=545620 Previously getopt would interpret initial '-' in root password as an option which could lead to setup failure. Now a special argument '--' has been added before the password to distinguish it from other options. diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in index 7e846d739..79586dbbd 100644 --- a/ldap/admin/src/scripts/DSUtil.pm.in +++ b/ldap/admin/src/scripts/DSUtil.pm.in @@ -736,7 +736,7 @@ sub getHashedPassword { if ($alg) { $cmd .= " -s $alg"; } - $cmd .= " " . shellEscape($pwd); + $cmd .= " -- " . shellEscape($pwd); my $hashedpwd = `$cmd`; chomp($hashedpwd);
0
a79ae70df6b20cd288fca511f784c414e8c52df4
389ds/389-ds-base
Ticket 49072 - validate memberof fixup task args Bug Description: If an invalid base dn, or invalid filter was provided in the task there was no way to tell thathte task actually failed. Fix Description: Log an error, and properly update the task status/exit code when an error occurs. Added CI test (also fixed some issues in the dynamic plugins test suite). https://fedorahosted.org/389/ticket/49072 Reviewed by: nhosoi(Thanks!)
commit a79ae70df6b20cd288fca511f784c414e8c52df4 Author: Mark Reynolds <[email protected]> Date: Tue Dec 20 14:59:02 2016 -0500 Ticket 49072 - validate memberof fixup task args Bug Description: If an invalid base dn, or invalid filter was provided in the task there was no way to tell thathte task actually failed. Fix Description: Log an error, and properly update the task status/exit code when an error occurs. Added CI test (also fixed some issues in the dynamic plugins test suite). https://fedorahosted.org/389/ticket/49072 Reviewed by: nhosoi(Thanks!) diff --git a/dirsrvtests/tests/suites/dynamic-plugins/plugin_tests.py b/dirsrvtests/tests/suites/dynamic-plugins/plugin_tests.py index b8bf477b0..99559cc4b 100644 --- a/dirsrvtests/tests/suites/dynamic-plugins/plugin_tests.py +++ b/dirsrvtests/tests/suites/dynamic-plugins/plugin_tests.py @@ -96,6 +96,7 @@ def test_dependency(inst, plugin): ################################################################################ def wait_for_task(conn, task_dn): finished = False + exitcode = 0 count = 0 while count < 60: try: @@ -105,6 +106,7 @@ def wait_for_task(conn, task_dn): assert False if task_entry[0].hasAttr('nstaskexitcode'): # task is done + exitcode = task_entry[0].nsTaskExitCode finished = True break except ldap.LDAPError as e: @@ -117,6 +119,8 @@ def wait_for_task(conn, task_dn): log.fatal('wait_for_task: Task (%s) did not complete!' % task_dn) assert False + return exitcode + ################################################################################ # @@ -1416,9 +1420,82 @@ def test_memberof(inst, args=None): log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) assert False - # Enable the plugin, and run the task + # Enable memberof plugin inst.plugins.enable(name=PLUGIN_MEMBER_OF) + ############################################################# + # Test memberOf fixup arg validation: Test the DN and filter + ############################################################# + + # + # Test bad/nonexistant DN + # + TASK_DN = 'cn=task-' + str(int(time.time())) + ',' + DN_MBO_TASK + try: + inst.add_s(Entry((TASK_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'basedn': DEFAULT_SUFFIX + "bad", + 'filter': 'objectclass=top'}))) + except ldap.LDAPError as e: + log.fatal('test_memberof: Failed to add task(bad dn): error ' + + e.message['desc']) + assert False + + exitcode = wait_for_task(inst, TASK_DN) + if exitcode == "0": + # We should an error + log.fatal('test_memberof: Task with invalid DN still reported success') + assert False + + # + # Test invalid DN syntax + # + TASK_DN = 'cn=task-' + str(int(time.time())) + ',' + DN_MBO_TASK + try: + inst.add_s(Entry((TASK_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'basedn': "bad", + 'filter': 'objectclass=top'}))) + except ldap.LDAPError as e: + log.fatal('test_memberof: Failed to add task(invalid dn syntax): ' + + e.message['desc']) + assert False + + exitcode = wait_for_task(inst, TASK_DN) + if exitcode == "0": + # We should an error + log.fatal('test_memberof: Task with invalid DN syntax still reported' + + ' success') + assert False + + # + # Test bad filter (missing closing parenthesis) + # + TASK_DN = 'cn=task-' + str(int(time.time())) + ',' + DN_MBO_TASK + try: + inst.add_s(Entry((TASK_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'basedn': DEFAULT_SUFFIX, + 'filter': '(objectclass=top'}))) + except ldap.LDAPError as e: + log.fatal('test_memberof: Failed to add task(bad filter: error ' + + e.message['desc']) + assert False + + exitcode = wait_for_task(inst, TASK_DN) + if exitcode == "0": + # We should an error + log.fatal('test_memberof: Task with invalid filter still reported ' + + 'success') + assert False + + #################################################### + # Test fixup works + #################################################### + + # + # Run the task and validate that it worked + # TASK_DN = 'cn=task-' + str(int(time.time())) + ',' + DN_MBO_TASK try: inst.add_s(Entry((TASK_DN, { diff --git a/dirsrvtests/tests/suites/dynamic-plugins/stress_tests.py b/dirsrvtests/tests/suites/dynamic-plugins/stress_tests.py index f98812c16..a869e9804 100644 --- a/dirsrvtests/tests/suites/dynamic-plugins/stress_tests.py +++ b/dirsrvtests/tests/suites/dynamic-plugins/stress_tests.py @@ -88,8 +88,9 @@ class DelUsers(threading.Thread): try: conn.delete_s(USER_DN) except ldap.LDAPError as e: - log.fatal('DeleteUsers: failed to delete (' + USER_DN + ') error: ' + e.message['desc']) - assert False + if e == ldap.UNAVAILABLE or e == ldap.SERVER_DOWN: + log.fatal('DeleteUsers: failed to delete (' + USER_DN + ') error: ' + e.message['desc']) + assert False idx += 1 @@ -115,11 +116,10 @@ class AddUsers(threading.Thread): conn.add_s(Entry((GROUP_DN, {'objectclass': 'top groupOfNames groupOfUniqueNames extensibleObject'.split(), 'uid': 'user' + str(idx)}))) - except ldap.ALREADY_EXISTS: - pass except ldap.LDAPError as e: - log.fatal('AddUsers: failed to add group (' + USER_DN + ') error: ' + e.message['desc']) - assert False + if e == ldap.UNAVAILABLE or e == ldap.SERVER_DOWN: + log.fatal('AddUsers: failed to add group (' + USER_DN + ') error: ' + e.message['desc']) + assert False log.info('AddUsers - Adding ' + str(NUM_USERS) + ' entries (' + self.rdnval + ')...') @@ -129,16 +129,18 @@ class AddUsers(threading.Thread): conn.add_s(Entry((USER_DN, {'objectclass': 'top extensibleObject'.split(), 'uid': 'user' + str(idx)}))) except ldap.LDAPError as e: - log.fatal('AddUsers: failed to add (' + USER_DN + ') error: ' + e.message['desc']) - assert False + if e == ldap.UNAVAILABLE or e == ldap.SERVER_DOWN: + log.fatal('AddUsers: failed to add (' + USER_DN + ') error: ' + e.message['desc']) + assert False if self.addToGroup: # Add the user to the group try: conn.modify_s(GROUP_DN, [(ldap.MOD_ADD, 'uniquemember', USER_DN)]) except ldap.LDAPError as e: - log.fatal('AddUsers: Failed to add user' + USER_DN + ' to group: error ' + e.message['desc']) - assert False + if e == ldap.UNAVAILABLE or e == ldap.SERVER_DOWN: + log.fatal('AddUsers: Failed to add user' + USER_DN + ' to group: error ' + e.message['desc']) + assert False idx += 1 diff --git a/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py b/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py index 24114244b..e55bc85e2 100644 --- a/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py +++ b/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py @@ -250,7 +250,8 @@ def test_dynamic_plugins(topology_st): except: log.info('Stress test failed!') - repl_fail(replica_inst) + if replication_run: + repl_fail(replica_inst) stress_count += 1 log.info('####################################################################') diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c index e0573a75f..802816396 100644 --- a/ldap/servers/plugins/memberof/memberof.c +++ b/ldap/servers/plugins/memberof/memberof.c @@ -68,6 +68,13 @@ typedef struct _memberof_get_groups_data Slapi_ValueSet **group_norm_vals; } memberof_get_groups_data; +typedef struct _task_data +{ + char *dn; + char *bind_dn; + char *filter_str; +} task_data; + /*** function prototypes ***/ /* exported functions */ @@ -145,7 +152,7 @@ static void memberof_task_destructor(Slapi_Task *task); static const char *fetch_attr(Slapi_Entry *e, const char *attrname, const char *default_val); static void memberof_fixup_task_thread(void *arg); -static int memberof_fix_memberof(MemberOfConfig *config, char *dn, char *filter_str); +static int memberof_fix_memberof(MemberOfConfig *config, Slapi_Task *task, task_data *td); static int memberof_fix_memberof_callback(Slapi_Entry *e, void *callback_data); static int memberof_entry_in_scope(MemberOfConfig *config, Slapi_DN *sdn); static int memberof_add_objectclass(char *auto_add_oc, const char *dn); @@ -2641,13 +2648,6 @@ void memberof_unlock() } } -typedef struct _task_data -{ - char *dn; - char *bind_dn; - char *filter_str; -} task_data; - void memberof_fixup_task_thread(void *arg) { MemberOfConfig configCopy = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -2661,7 +2661,7 @@ void memberof_fixup_task_thread(void *arg) } slapi_task_inc_refcount(task); slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM, - "memberof_fixup_task_thread - refcount incremented.\n" ); + "memberof_fixup_task_thread - refcount incremented.\n" ); /* Fetch our task data from the task */ td = (task_data *)slapi_task_get_data(task); @@ -2672,7 +2672,8 @@ void memberof_fixup_task_thread(void *arg) slapi_task_log_notice(task, "Memberof task starts (arg: %s) ...\n", td->filter_str); slapi_log_err(SLAPI_LOG_INFO, MEMBEROF_PLUGIN_SUBSYSTEM, - "memberof_fixup_task_thread - Memberof task starts (arg: %s) ...\n", td->filter_str); + "memberof_fixup_task_thread - Memberof task starts (filter: \"%s\") ...\n", + td->filter_str); /* We need to get the config lock first. Trying to get the * config lock after we already hold the op lock can cause @@ -2687,7 +2688,7 @@ void memberof_fixup_task_thread(void *arg) if (usetxn) { Slapi_DN *sdn = slapi_sdn_new_dn_byref(td->dn); - Slapi_Backend *be = slapi_be_select(sdn); + Slapi_Backend *be = slapi_be_select_exact(sdn); slapi_sdn_free(&sdn); if (be) { fixup_pb = slapi_pblock_new(); @@ -2695,12 +2696,17 @@ void memberof_fixup_task_thread(void *arg) rc = slapi_back_transaction_begin(fixup_pb); if (rc) { slapi_log_err(SLAPI_LOG_ERR, MEMBEROF_PLUGIN_SUBSYSTEM, - "memberof_fixup_task_thread - Failed to start transaction\n"); + "memberof_fixup_task_thread - Failed to start transaction\n"); + goto done; } } else { slapi_log_err(SLAPI_LOG_ERR, MEMBEROF_PLUGIN_SUBSYSTEM, - "memberof_fixup_task_thread - Failed to get be backend from %s\n", - td->dn); + "memberof_fixup_task_thread - Failed to get be backend from (%s)\n", + td->dn); + slapi_task_log_notice(task, "Memberof task - Failed to get be backend from (%s)\n", + td->dn); + rc = -1; + goto done; } } @@ -2708,13 +2714,14 @@ void memberof_fixup_task_thread(void *arg) memberof_lock(); /* do real work */ - rc = memberof_fix_memberof(&configCopy, td->dn, td->filter_str); + rc = memberof_fix_memberof(&configCopy, task, td); /* release the memberOf operation lock */ memberof_unlock(); +done: if (usetxn && fixup_pb) { - if (rc) { /* failes */ + if (rc) { /* failed */ slapi_back_transaction_abort(fixup_pb); } else { slapi_back_transaction_commit(fixup_pb); @@ -2726,8 +2733,6 @@ void memberof_fixup_task_thread(void *arg) slapi_task_log_notice(task, "Memberof task finished."); slapi_task_log_status(task, "Memberof task finished."); slapi_task_inc_progress(task); - slapi_log_err(SLAPI_LOG_INFO, MEMBEROF_PLUGIN_SUBSYSTEM, - "memberof_fixup_task_thread - Memberof task finished (arg: %s) ...\n", td->filter_str); /* this will queue the destruction of the task */ slapi_task_finish(task, rc); @@ -2845,13 +2850,13 @@ memberof_task_destructor(Slapi_Task *task) "memberof_task_destructor <--\n" ); } -int memberof_fix_memberof(MemberOfConfig *config, char *dn, char *filter_str) +int memberof_fix_memberof(MemberOfConfig *config, Slapi_Task *task, task_data *td) { int rc = 0; Slapi_PBlock *search_pb = slapi_pblock_new(); - slapi_search_internal_set_pb(search_pb, dn, - LDAP_SCOPE_SUBTREE, filter_str, 0, 0, + slapi_search_internal_set_pb(search_pb, td->dn, + LDAP_SCOPE_SUBTREE, td->filter_str, 0, 0, 0, 0, memberof_get_plugin_id(), 0); @@ -2860,6 +2865,16 @@ int memberof_fix_memberof(MemberOfConfig *config, char *dn, char *filter_str) config, 0, memberof_fix_memberof_callback, 0); + if (rc){ + char *errmsg; + int result; + + slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result); + errmsg = ldap_err2string(result); + slapi_log_err(SLAPI_LOG_ERR, MEMBEROF_PLUGIN_SUBSYSTEM, + "memberof_fix_memberof - Failed (%s)\n", errmsg ); + slapi_task_log_notice(task, "Memberof task failed (%s)\n", errmsg ); + } slapi_pblock_destroy(search_pb); diff --git a/ldap/servers/slapd/plugin_internal_op.c b/ldap/servers/slapd/plugin_internal_op.c index 8cbdf0673..966a71fe5 100644 --- a/ldap/servers/slapd/plugin_internal_op.c +++ b/ldap/servers/slapd/plugin_internal_op.c @@ -726,7 +726,7 @@ search_internal_callback_pb (Slapi_PBlock *pb, void *callback_data, if (ifstr == NULL || (scope != LDAP_SCOPE_BASE && scope != LDAP_SCOPE_ONELEVEL && scope != LDAP_SCOPE_SUBTREE)) { - opresult = LDAP_PARAM_ERROR; + opresult = LDAP_PARAM_ERROR; slapi_pblock_set(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); return -1; } @@ -743,19 +743,19 @@ search_internal_callback_pb (Slapi_PBlock *pb, void *callback_data, op->o_search_referral_handler = internal_ref_entry_callback; filter = slapi_str2filter((fstr = slapi_ch_strdup(ifstr))); - if(scope == LDAP_SCOPE_BASE) { - filter->f_flags |= (SLAPI_FILTER_LDAPSUBENTRY | - SLAPI_FILTER_TOMBSTONE | SLAPI_FILTER_RUV); + if (NULL == filter) { + int result = LDAP_FILTER_ERROR; + send_ldap_result(pb, result, NULL, NULL, 0, NULL); + slapi_pblock_set(pb, SLAPI_PLUGIN_INTOP_RESULT, &result); + rc = -1; + goto done; } - if (NULL == filter) - { - send_ldap_result(pb, LDAP_FILTER_ERROR, NULL, NULL, 0, NULL); - rc = -1; - goto done; + if (scope == LDAP_SCOPE_BASE) { + filter->f_flags |= (SLAPI_FILTER_LDAPSUBENTRY | + SLAPI_FILTER_TOMBSTONE | SLAPI_FILTER_RUV); } filter_normalize(filter); - slapi_pblock_set(pb, SLAPI_SEARCH_FILTER, filter); slapi_pblock_set(pb, SLAPI_REQCONTROLS, controls); @@ -783,11 +783,8 @@ search_internal_callback_pb (Slapi_PBlock *pb, void *callback_data, slapi_pblock_get(pb, SLAPI_SEARCH_FILTER, &filter); done: - slapi_ch_free((void **) & fstr); - if (filter != NULL) - { - slapi_filter_free(filter, 1 /* recurse */); - } + slapi_ch_free_string(&fstr); + slapi_filter_free(filter, 1 /* recurse */); slapi_pblock_get(pb, SLAPI_SEARCH_ATTRS, &tmp_attrs); slapi_ch_array_free(tmp_attrs); slapi_pblock_set(pb, SLAPI_SEARCH_ATTRS, NULL);
0
0073de611b08f6027dfcdde79335db149020a4a9
389ds/389-ds-base
Resolves: #250702 Summary: not all the addresses associated with listenhost are bound to listen sockets (comment #10)
commit 0073de611b08f6027dfcdde79335db149020a4a9 Author: Noriko Hosoi <[email protected]> Date: Fri Aug 3 22:14:41 2007 +0000 Resolves: #250702 Summary: not all the addresses associated with listenhost are bound to listen sockets (comment #10) diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 3ad3d82c1..667cf05c1 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -127,9 +127,6 @@ static int writesignalpipe = SLAPD_INVALID_SOCKET; static int readsignalpipe = SLAPD_INVALID_SOCKET; #define FDS_SIGNAL_PIPE 0 -#define FDS_N_TCPS 1 -#define FDS_S_TCPS 2 -#define FDS_I_UNIX 3 static int get_configured_connection_table_size(); #ifdef RESOLVER_NEEDS_LOW_FILE_DESCRIPTORS @@ -139,12 +136,12 @@ static void get_loopback_by_addr( void ); #ifdef XP_WIN32 static int createlistensocket(unsigned short port, const PRNetAddr *listenaddr); #endif -static PRFileDesc *createprlistensocket(unsigned short port, - const PRNetAddr *listenaddr, int secure, int local); +static PRFileDesc **createprlistensockets(unsigned short port, + PRNetAddr **listenaddr, int secure, int local); static const char *netaddr2string(const PRNetAddr *addr, char *addrbuf, size_t addrbuflen); static void set_shutdown (int); -static void setup_pr_read_pds(Connection_Table *ct, PRFileDesc *n_tcps, PRFileDesc *s_tcps, PRFileDesc *i_unix, PRIntn *num_to_read); +static void setup_pr_read_pds(Connection_Table *ct, PRFileDesc **n_tcps, PRFileDesc **s_tcps, PRFileDesc **i_unix, PRIntn *num_to_read); #ifdef HPUX10 static void* catch_signals(); @@ -373,7 +370,7 @@ static int handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_ #ifdef _WIN32 static void unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, int n_tcps, PRFileDesc *s_tcps); #else -static void unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, PRFileDesc *n_tcps, PRFileDesc *s_tcps, PRFileDesc *i_unix); +static void unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, PRFileDesc **n_tcps, PRFileDesc **s_tcps, PRFileDesc **i_unix); #endif static int write_pid_file(); static int init_shutdown_detect(); @@ -396,14 +393,14 @@ int daemon_pre_setuid_init(daemon_ports_t *ports) ports->n_socket = createlistensocket((unsigned short)ports->n_port, &ports->n_listenaddr); #else - ports->n_socket = createprlistensocket(ports->n_port, - &ports->n_listenaddr, 0, 0); + ports->n_socket = createprlistensockets(ports->n_port, + ports->n_listenaddr, 0, 0); #endif } if ( config_get_security() && (0 != ports->s_port) ) { - ports->s_socket = createprlistensocket((unsigned short)ports->s_port, - &ports->s_listenaddr, 1, 0); + ports->s_socket = createprlistensockets((unsigned short)ports->s_port, + ports->s_listenaddr, 1, 0); #ifdef XP_WIN32 ports->s_socket_native = PR_FileDesc2NativeHandle(ports->s_socket); #endif @@ -418,7 +415,7 @@ int daemon_pre_setuid_init(daemon_ports_t *ports) #if defined(ENABLE_LDAPI) /* ldapi */ if(0 != ports->i_port) { - ports->i_socket = createprlistensocket(1, &ports->i_listenaddr, 0, 1); + ports->i_socket = createprlistensockets(1, ports->i_listenaddr, 0, 1); } #endif /* ENABLE_LDAPI */ #endif @@ -486,12 +483,14 @@ void slapd_daemon( daemon_ports_t *ports ) #if defined( XP_WIN32 ) int n_tcps = 0; int s_tcps_native = 0; + PRFileDesc *s_tcps = NULL; #else - PRFileDesc *n_tcps = NULL; PRFileDesc *tcps = 0; - PRFileDesc *i_unix = 0; + PRFileDesc **n_tcps = NULL; + PRFileDesc **s_tcps = NULL; + PRFileDesc **i_unix = NULL; + PRFileDesc **fdesp = NULL; #endif - PRFileDesc *s_tcps = NULL; PRIntn num_poll = 0; PRIntervalTime pr_timeout = PR_MillisecondsToInterval(slapd_wakeup_timer); PRThread *time_thread_p; @@ -576,44 +575,59 @@ void slapd_daemon( daemon_ports_t *ports ) g_set_shutdown( SLAPI_SHUTDOWN_EXIT ); } #else - if ( n_tcps != NULL - && PR_Listen( n_tcps, DAEMON_LISTEN_SIZE ) == PR_FAILURE) { - PRErrorCode prerr = PR_GetError(); - char addrbuf[ 256 ]; - - slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon", - "PR_Listen() on %s port %d failed: %s error %d (%s)\n", - netaddr2string(&ports->n_listenaddr, addrbuf, sizeof(addrbuf)), - ports->n_port, SLAPI_COMPONENT_NAME_NSPR, prerr, - slapd_pr_strerror( prerr )); - g_set_shutdown( SLAPI_SHUTDOWN_EXIT ); + if ( n_tcps != NULL ) { + PRFileDesc **fdesp; + PRNetAddr **nap = ports->n_listenaddr; + for (fdesp = n_tcps; fdesp && *fdesp; fdesp++, nap++) { + if ( PR_Listen( *fdesp, DAEMON_LISTEN_SIZE ) == PR_FAILURE ) { + PRErrorCode prerr = PR_GetError(); + char addrbuf[ 256 ]; + + slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon", + "PR_Listen() on %s port %d failed: %s error %d (%s)\n", + netaddr2string(*nap, addrbuf, sizeof(addrbuf)), + ports->n_port, SLAPI_COMPONENT_NAME_NSPR, prerr, + slapd_pr_strerror( prerr )); + g_set_shutdown( SLAPI_SHUTDOWN_EXIT ); + } + } } #endif - if ( s_tcps != NULL - && PR_Listen( s_tcps, DAEMON_LISTEN_SIZE ) == PR_FAILURE ) { - PRErrorCode prerr = PR_GetError(); - char addrbuf[ 256 ]; - - slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon", - "PR_Listen() on %s port %d failed: %s error %d (%s)\n", - netaddr2string(&ports->s_listenaddr, addrbuf, sizeof(addrbuf)), - ports->s_port, SLAPI_COMPONENT_NAME_NSPR, prerr, - slapd_pr_strerror( prerr )); - g_set_shutdown( SLAPI_SHUTDOWN_EXIT ); + if ( s_tcps != NULL ) { + PRFileDesc **fdesp; + PRNetAddr **sap = ports->s_listenaddr; + for (fdesp = s_tcps; fdesp && *fdesp; fdesp++, sap++) { + if ( PR_Listen( *fdesp, DAEMON_LISTEN_SIZE ) == PR_FAILURE ) { + PRErrorCode prerr = PR_GetError(); + char addrbuf[ 256 ]; + + slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon", + "PR_Listen() on %s port %d failed: %s error %d (%s)\n", + netaddr2string(*sap, addrbuf, sizeof(addrbuf)), + ports->s_port, SLAPI_COMPONENT_NAME_NSPR, prerr, + slapd_pr_strerror( prerr )); + g_set_shutdown( SLAPI_SHUTDOWN_EXIT ); + } + } } #if !defined( XP_WIN32 ) #if defined(ENABLE_LDAPI) - if( i_unix != NULL && - PR_Listen(i_unix, DAEMON_LISTEN_SIZE) == PR_FAILURE) { - PRErrorCode prerr = PR_GetError(); - slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon", - "listen() on %s failed: error %d (%s)\n", - ports->i_listenaddr.local.path, - prerr, - slapd_pr_strerror( prerr )); - g_set_shutdown( SLAPI_SHUTDOWN_EXIT ); + if( i_unix != NULL ) { + PRFileDesc **fdesp; + PRNetAddr **iap = ports->i_listenaddr; + for (fdesp = i_unix; fdesp && *fdesp; fdesp++, iap++) { + if ( PR_Listen(*fdesp, DAEMON_LISTEN_SIZE) == PR_FAILURE) { + PRErrorCode prerr = PR_GetError(); + slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon", + "listen() on %s failed: error %d (%s)\n", + (*iap)->local.path, + prerr, + slapd_pr_strerror( prerr )); + g_set_shutdown( SLAPI_SHUTDOWN_EXIT ); + } + } } #endif /* ENABLE_LDAPI */ #endif @@ -632,6 +646,7 @@ void slapd_daemon( daemon_ports_t *ports ) int select_return = 0; int secure = 0; /* is a new connection an SSL one ? */ int local = 0; /* is new connection an ldapi one? */ + int i; #ifndef _WIN32 PRErrorCode prerr; @@ -680,21 +695,44 @@ void slapd_daemon( daemon_ports_t *ports ) clear_signal(&readfds); #else tcps = NULL; - /* info for n_tcps is always in fd[FDS_N_TCPS] and info for s_tcps is always - * in fd[FDS_S_TCPS] */ - if( n_tcps != NULL && - the_connection_table->fd[FDS_N_TCPS].out_flags & SLAPD_POLL_FLAGS ) { - tcps = n_tcps; - } else if ( s_tcps != NULL && - the_connection_table->fd[FDS_S_TCPS].out_flags & SLAPD_POLL_FLAGS ) { - tcps = s_tcps; - secure = 1; + /* info for n_tcps is always in fd[n_tcps ~ n_tcpe] */ + if( NULL != n_tcps ) { + for (i = the_connection_table->n_tcps; + i < the_connection_table->n_tcpe; i++) { + if (the_connection_table->fd[i].out_flags & + SLAPD_POLL_FLAGS ) { + /* tcps = n_tcps[i - the_connection_table->n_tcps]; */ + tcps = the_connection_table->fd[i].fd; + break; + } + } + } + /* info for s_tcps is always in fd[s_tcps ~ s_tcpe] */ + if ( NULL == tcps && NULL != s_tcps ) { + for (i = the_connection_table->s_tcps; + i < the_connection_table->s_tcpe; i++) { + if (the_connection_table->fd[i].out_flags & + SLAPD_POLL_FLAGS ) { + /* tcps = s_tcps[i - the_connection_table->s_tcps]; */ + tcps = the_connection_table->fd[i].fd; + secure = 1; + break; + } + } } #if defined(ENABLE_LDAPI) - else if ( i_unix != 0 && - the_connection_table->fd[FDS_I_UNIX].out_flags & SLAPD_POLL_FLAGS ) { - tcps = i_unix; - local = 1; + /* info for i_unix is always in fd[i_unixs ~ i_unixe] */ + if ( NULL == tcps && NULL != i_unix ) { + for (i = the_connection_table->i_unixs; + i < the_connection_table->i_unixe; i++) { + if (the_connection_table->fd[i].out_flags & + SLAPD_POLL_FLAGS ) { + /* tcps = i_unix[i - the_connection_table->i_unixs]; */ + tcps = the_connection_table->fd[i].fd; + local = 1; + break; + } + } } #endif /* ENABLE_LDAPI */ @@ -723,20 +761,45 @@ void slapd_daemon( daemon_ports_t *ports ) if ( n_tcps != SLAPD_INVALID_SOCKET ) { closesocket( n_tcps ); } + if ( s_tcps != NULL ) { + PR_Close( s_tcps ); + } #else - if ( n_tcps != NULL ) { - PR_Close( n_tcps ); + for (fdesp = n_tcps; fdesp && *fdesp; fdesp++) { + PR_Close( *fdesp ); } + slapi_ch_free ((void**)&n_tcps); - if ( i_unix != NULL ) { - PR_Close( i_unix ); + for (fdesp = i_unix; fdesp && *fdesp; fdesp++) { + PR_Close( *fdesp ); } + slapi_ch_free ((void**)&i_unix); -#endif + for (fdesp = s_tcps; fdesp && *fdesp; fdesp++) { + PR_Close( *fdesp ); + } + slapi_ch_free ((void**)&s_tcps); - if ( s_tcps != NULL ) { - PR_Close( s_tcps ); + /* freeing NetAddrs */ + { + PRNetAddr **nap; + for (nap = ports->n_listenaddr; nap && *nap; nap++) { + slapi_ch_free ((void**)nap); + } + slapi_ch_free ((void**)&ports->n_listenaddr); + + for (nap = ports->s_listenaddr; nap && *nap; nap++) { + slapi_ch_free ((void**)nap); + } + slapi_ch_free ((void**)&ports->s_listenaddr); +#if defined(ENABLE_LDAPI) + for (nap = ports->i_listenaddr; nap && *nap; nap++) { + slapi_ch_free ((void**)nap); + } + slapi_ch_free ((void**)&ports->i_listenaddr); +#endif } +#endif /* Might compete with housecleaning thread, but so far so good */ be_flushall(); @@ -988,8 +1051,9 @@ static void setup_read_fds(Connection_Table *ct, fd_set *readfds, int n_tcps, in #endif /* _WIN32 */ static int first_time_setup_pr_read_pds = 1; +static int listen_addr_count = 0; static void -setup_pr_read_pds(Connection_Table *ct, PRFileDesc *n_tcps, PRFileDesc *s_tcps, PRFileDesc *i_unix, PRIntn *num_to_read) +setup_pr_read_pds(Connection_Table *ct, PRFileDesc **n_tcps, PRFileDesc **s_tcps, PRFileDesc **i_unix, PRIntn *num_to_read) { Connection *c= NULL; Connection *next= NULL; @@ -1001,19 +1065,19 @@ setup_pr_read_pds(Connection_Table *ct, PRFileDesc *n_tcps, PRFileDesc *s_tcps, int max_threads_per_conn = config_get_maxthreadsperconn(); accept_new_connections = ((ct->size - g_get_current_conn_count()) - > slapdFrontendConfig->reservedescriptors); + > slapdFrontendConfig->reservedescriptors); if ( ! accept_new_connections ) { if ( last_accept_new_connections ) { LDAPDebug( LDAP_DEBUG_ANY, "Not listening for new " - "connections - too many fds open\n", 0, 0, 0 ); + "connections - too many fds open\n", 0, 0, 0 ); /* reinitialize n_tcps and s_tcps to the pds */ first_time_setup_pr_read_pds = 1; } } else { if ( ! last_accept_new_connections && - last_accept_new_connections != -1 ) { + last_accept_new_connections != -1 ) { LDAPDebug( LDAP_DEBUG_ANY, "Listening for new " - "connections again\n", 0, 0, 0 ); + "connections again\n", 0, 0, 0 ); /* reinitialize n_tcps and s_tcps to the pds */ first_time_setup_pr_read_pds = 1; } @@ -1021,91 +1085,116 @@ setup_pr_read_pds(Connection_Table *ct, PRFileDesc *n_tcps, PRFileDesc *s_tcps, last_accept_new_connections = accept_new_connections; - /* initialize the mapping from connection table entries to fds entries */ + /* initialize the mapping from connection table entries to fds entries */ if (first_time_setup_pr_read_pds) { int i; - for (i = 0; i < ct->size; i++) - { - ct->c[i].c_fdi = SLAPD_INVALID_SOCKET_INDEX; - } + for (i = 0; i < ct->size; i++) + { + ct->c[i].c_fdi = SLAPD_INVALID_SOCKET_INDEX; + } - /* The fds entry for n_tcps is always FDS_N_TCPS */ - if (n_tcps != NULL && accept_new_connections) - { - ct->fd[FDS_N_TCPS].fd = n_tcps; - ct->fd[FDS_N_TCPS].in_flags = SLAPD_POLL_FLAGS; - ct->fd[FDS_N_TCPS].out_flags = 0; - LDAPDebug( LDAP_DEBUG_HOUSE, - "listening for connections on %d\n", socketdesc, 0, 0 ); - } else { - ct->fd[FDS_N_TCPS].fd = NULL; - } + /* The fds entry for the signalpipe is always FDS_SIGNAL_PIPE (== 0) */ + count = FDS_SIGNAL_PIPE; +#if !defined(_WIN32) + ct->fd[count].fd = signalpipe[0]; + ct->fd[count].in_flags = SLAPD_POLL_FLAGS; + ct->fd[count].out_flags = 0; +#else + ct->fd[count].fd = NULL; +#endif + count++; + + /* The fds entry for n_tcps starts with n_tcps and less than n_tcpe */ + ct->n_tcps = count; + if (n_tcps != NULL && accept_new_connections) + { + PRFileDesc **fdesc = NULL; + for (fdesc = n_tcps; fdesc && *fdesc; fdesc++, count++) { + ct->fd[count].fd = *fdesc; + ct->fd[count].in_flags = SLAPD_POLL_FLAGS; + ct->fd[count].out_flags = 0; + LDAPDebug( LDAP_DEBUG_HOUSE, + "listening for connections on %d\n", socketdesc, 0, 0 ); + } + } else { + ct->fd[count].fd = NULL; + count++; + } + ct->n_tcpe = count; + + ct->s_tcps = count; + /* The fds entry for s_tcps starts with s_tcps and less than s_tcpe */ + if (s_tcps != NULL && accept_new_connections) + { + PRFileDesc **fdesc = NULL; + for (fdesc = s_tcps; fdesc && *fdesc; fdesc++, count++) { + ct->fd[count].fd = *fdesc; + ct->fd[count].in_flags = SLAPD_POLL_FLAGS; + ct->fd[count].out_flags = 0; + LDAPDebug( LDAP_DEBUG_HOUSE, + "listening for SSL connections on %d\n", socketdesc, 0, 0 ); + } + } else { + ct->fd[count].fd = NULL; + count++; + } + ct->s_tcpe = count; - /* The fds entry for s_tcps is always FDS_S_TCPS */ - if (s_tcps != NULL && accept_new_connections) - { - ct->fd[FDS_S_TCPS].fd = s_tcps; - ct->fd[FDS_S_TCPS].in_flags = SLAPD_POLL_FLAGS; - ct->fd[FDS_S_TCPS].out_flags = 0; - LDAPDebug( LDAP_DEBUG_HOUSE, - "listening for SSL connections on %d\n", socketdesc, 0, 0 ); - } else { - ct->fd[FDS_S_TCPS].fd = NULL; - } #if !defined(_WIN32) - /* The fds entry for i_unix is always FDS_I_UNIX */ - if (i_unix != NULL && accept_new_connections) - { - ct->fd[FDS_I_UNIX].fd = i_unix; - ct->fd[FDS_I_UNIX].in_flags = SLAPD_POLL_FLAGS; - ct->fd[FDS_I_UNIX].out_flags = 0; - LDAPDebug( LDAP_DEBUG_HOUSE, - "listening for LDAPI connections on %d\n", socketdesc, 0, 0 ); - } else { - ct->fd[FDS_I_UNIX].fd = NULL; - } - - /* The fds entry for the signalpipe is always FDS_SIGNAL_PIPE */ - ct->fd[FDS_SIGNAL_PIPE].fd = signalpipe[0]; - ct->fd[FDS_SIGNAL_PIPE].in_flags = SLAPD_POLL_FLAGS; - ct->fd[FDS_SIGNAL_PIPE].out_flags = 0; -#else - ct->fd[FDS_SIGNAL_PIPE].fd = NULL; +#if defined(ENABLE_LDAPI) + ct->i_unixs = count; + /* The fds entry for i_unix starts with i_unixs and less than i_unixe */ + if (i_unix != NULL && accept_new_connections) + { + PRFileDesc **fdesc = NULL; + for (fdesc = i_unix; fdesc && *fdesc; fdesc++, count++) { + ct->fd[count].fd = *fdesc; + ct->fd[count].in_flags = SLAPD_POLL_FLAGS; + ct->fd[count].out_flags = 0; + LDAPDebug( LDAP_DEBUG_HOUSE, + "listening for LDAPI connections on %d\n", socketdesc, 0, 0 ); + } + } else { + ct->fd[count].fd = NULL; + count++; + } + ct->i_unixe = count; #endif - first_time_setup_pr_read_pds = 0; +#endif + + first_time_setup_pr_read_pds = 0; + listen_addr_count = count; } - /* count is the number of entries we've place in the fds array. - * we always put n_tcps in slot FDS_N_TCPS, s_tcps in slot - * FDS_S_TCPS and the signal pipe in slot FDS_SIGNAL_PIPE - * and i_unix in FDS_I_UNIX - * so we now set count to 4 */ - count = 4; - - /* Walk down the list of active connections to find + /* count is the number of entries we've place in the fds array. + * listen_addr_count is counted up when + * first_time_setup_pr_read_pds is TURE. */ + count = listen_addr_count; + + /* Walk down the list of active connections to find * out which connections we should poll over. If a connection * is no longer in use, we should remove it from the linked * list. */ c = connection_table_get_first_active_connection (ct); while (c) - { - next = connection_table_get_next_active_connection (ct, c); - if ( c->c_mutex == NULL ) - { - connection_table_move_connection_out_of_active_list(ct,c); - } - else - { - PR_Lock( c->c_mutex ); + { + next = connection_table_get_next_active_connection (ct, c); + if ( c->c_mutex == NULL ) + { + connection_table_move_connection_out_of_active_list(ct,c); + } + else + { + PR_Lock( c->c_mutex ); if (c->c_flags & CONN_FLAG_CLOSING) { - /* A worker thread has marked that this connection - * should be closed by calling disconnect_server. + /* A worker thread has marked that this connection + * should be closed by calling disconnect_server. * move this connection out of the active list * the last thread to use the connection will close it - */ + */ connection_table_move_connection_out_of_active_list(ct,c); } else if ( c->c_sd == SLAPD_INVALID_SOCKET ) @@ -1119,18 +1208,18 @@ setup_pr_read_pds(Connection_Table *ct, PRFileDesc *n_tcps, PRFileDesc *s_tcps, { ct->fd[count].fd = c->c_prfd; ct->fd[count].in_flags = SLAPD_POLL_FLAGS; - /* slot i of the connection table is mapped to slot - * count of the fds array */ - c->c_fdi = count; - count++; + /* slot i of the connection table is mapped to slot + * count of the fds array */ + c->c_fdi = count; + count++; } - else + else { - c->c_fdi = SLAPD_INVALID_SOCKET_INDEX; - } + c->c_fdi = SLAPD_INVALID_SOCKET_INDEX; + } } PR_Unlock( c->c_mutex ); - } + } c = next; } @@ -2021,8 +2110,8 @@ entry_map_free: slapi_pblock_destroy(search_pb); slapi_ch_free_string(&filter); slapi_ch_free_string(&utype); - slapi_ch_free_string(&gtype); - slapi_ch_free_string(&base_dn); + slapi_ch_free_string(&gtype); + slapi_ch_free_string(&base_dn); } if(ret && 0 == uid) @@ -2363,7 +2452,7 @@ static void unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, int n_tcps, PRFileDesc *s_tcps) #else static void -unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, PRFileDesc *n_tcps, PRFileDesc *s_tcps, PRFileDesc *i_unix) +unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, PRFileDesc **n_tcps, PRFileDesc **s_tcps, PRFileDesc **i_unix) #endif { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); @@ -2407,30 +2496,57 @@ unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, PRFileDesc *n_tcps, P */ #if !defined( XP_WIN32 ) if ( n_tcps != NULL ) { /* standard LDAP */ -#else - if ( n_tcps != SLAPD_INVALID_SOCKET ) { /* standard LDAP */ -#endif + PRNetAddr **nap = NULL; + int isfirsttime = 1; + + for (nap = ports->n_listenaddr; nap && *nap; nap++) { + if (isfirsttime) { + LDAPDebug( LDAP_DEBUG_ANY, + "slapd started. Listening on %s port %d for LDAP requests\n", + netaddr2string(*nap, addrbuf, sizeof(addrbuf)), + ports->n_port, 0 ); + isfirsttime = 0; + } else { + LDAPDebug( LDAP_DEBUG_ANY, + "Listening on %s port %d for LDAP requests\n", + netaddr2string(*nap, addrbuf, sizeof(addrbuf)), + ports->n_port, 0 ); + } + } + } + + if ( s_tcps != NULL ) { /* LDAP over SSL; separate port */ + PRNetAddr **sap = NULL; + for (sap = ports->s_listenaddr; sap && *sap; sap++) { + LDAPDebug( LDAP_DEBUG_ANY, + "Listening on %s port %d for LDAPS requests\n", + netaddr2string(*sap, addrbuf, sizeof(addrbuf)), + ports->s_port, 0 ); + } + } +#else + if ( n_tcps != SLAPD_INVALID_SOCKET ) { /* standard LDAP; XP_WIN32 */ LDAPDebug( LDAP_DEBUG_ANY, - "slapd started. Listening on %s port %d for LDAP requests\n", + "slapd started. Listening on %s port %d for LDAP requests\n", netaddr2string(&ports->n_listenaddr, addrbuf, sizeof(addrbuf)), ports->n_port, 0 ); } if ( s_tcps != NULL ) { /* LDAP over SSL; separate port */ LDAPDebug( LDAP_DEBUG_ANY, - "Listening on %s port %d for LDAPS requests\n", + "Listening on %s port %d for LDAPS requests\n", netaddr2string(&ports->s_listenaddr, addrbuf, sizeof(addrbuf)), ports->s_port, 0 ); } +#endif #if !defined( XP_WIN32 ) #if defined(ENABLE_LDAPI) if ( i_unix != NULL ) { /* LDAPI */ + PRNetAddr **iap = ports->i_listenaddr; LDAPDebug( LDAP_DEBUG_ANY, - "Listening on %s for LDAPI requests\n", - ports->i_listenaddr.local.path, - 0, 0 ); + "Listening on %s for LDAPI requests\n", (*iap)->local.path, 0, 0 ); } #endif /* ENABLE_LDAPI */ #endif @@ -2619,26 +2735,29 @@ createlistensocket(unsigned short port, const PRNetAddr *listenaddr) return tcps; failed: - WSACleanup(); - exit( 1 ); + WSACleanup(); + exit( 1 ); suppressed: - return -1; + return -1; } /* createlistensocket */ #endif /* XP_WIN32 */ -static PRFileDesc * -createprlistensocket(PRUint16 port, const PRNetAddr *listenaddr, +static PRFileDesc ** +createprlistensockets(PRUint16 port, PRNetAddr **listenaddr, int secure, int local) { - PRFileDesc *sock; + PRFileDesc **sock; PRNetAddr sa_server; PRErrorCode prerr = 0; PRSocketOptionData pr_socketoption; char addrbuf[ 256 ]; - char *logname = "createprlistensocket"; - int socktype = PR_AF_INET6; - char *socktype_s = "PR_AF_INET"; + char *logname = "createprlistensockets"; + int sockcnt = 0; + int socktype; + char *socktype_s = NULL; + PRNetAddr **lap; + int i; if (!port) goto suppressed; @@ -2649,61 +2768,79 @@ createprlistensocket(PRUint16 port, const PRNetAddr *listenaddr, socktype = PR_AF_LOCAL; socktype_s = "PR_AF_LOCAL"; } -#endif /* ENABLE_LDAPI */ +#endif - /* create TCP socket */ - if ((sock = PR_OpenTCPSocket(socktype)) == SLAPD_INVALID_SOCKET) { - prerr = PR_GetError(); - slapi_log_error(SLAPI_LOG_FATAL, logname, - "PR_OpenTCPSocket(%s) failed: %s error %d (%s)\n", - socktype_s, - SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); - goto failed; + /* need to know the count */ + sockcnt = 0; + for (lap = listenaddr; lap && *lap; lap++) { + sockcnt++; } - pr_socketoption.option = PR_SockOpt_Reuseaddr; - pr_socketoption.value.reuse_addr = 1; - if ( PR_SetSocketOption(sock, &pr_socketoption ) == PR_FAILURE) { - prerr = PR_GetError(); + if (0 == sockcnt) { slapi_log_error(SLAPI_LOG_FATAL, logname, - "PR_SetSocketOption(PR_SockOpt_Reuseaddr) failed: %s error %d (%s)\n", - SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror( prerr )); + "There is no address to listen\n"); goto failed; } + sock = (PRFileDesc **)slapi_ch_calloc(sockcnt + 1, sizeof(PRFileDesc *)); + pr_socketoption.option = PR_SockOpt_Reuseaddr; + pr_socketoption.value.reuse_addr = 1; + for (i = 0, lap = listenaddr; lap && *lap && i < sockcnt; i++, lap++) { + /* create TCP socket */ + socktype = PR_NetAddrFamily(*lap); + if (PR_AF_INET6 == socktype) { + socktype_s = "PR_AF_INET6"; + } else { + socktype_s = "PR_AF_INET"; + } + if ((sock[i] = PR_OpenTCPSocket(socktype)) == SLAPD_INVALID_SOCKET) { + prerr = PR_GetError(); + slapi_log_error(SLAPI_LOG_FATAL, logname, + "PR_OpenTCPSocket(%s) failed: %s error %d (%s)\n", + socktype_s, + SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); + goto failed; + } - /* set up listener address, including port */ - memcpy(&sa_server, listenaddr, sizeof(sa_server)); + if ( PR_SetSocketOption(sock[i], &pr_socketoption ) == PR_FAILURE) { + prerr = PR_GetError(); + slapi_log_error(SLAPI_LOG_FATAL, logname, + "PR_SetSocketOption(PR_SockOpt_Reuseaddr) failed: %s error %d (%s)\n", + SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror( prerr )); + goto failed; + } - if(!local) - PRLDAP_SET_PORT( &sa_server, port ); + /* set up listener address, including port */ + memcpy(&sa_server, *lap, sizeof(sa_server)); - if ( PR_Bind(sock, &sa_server) == PR_FAILURE) { - prerr = PR_GetError(); if(!local) - { - slapi_log_error(SLAPI_LOG_FATAL, logname, - "PR_Bind() on %s port %d failed: %s error %d (%s)\n", - netaddr2string(&sa_server, addrbuf, sizeof(addrbuf)), port, - SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); - } + PRLDAP_SET_PORT( &sa_server, port ); + + if ( PR_Bind(sock[i], &sa_server) == PR_FAILURE) { + prerr = PR_GetError(); + if(!local) + { + slapi_log_error(SLAPI_LOG_FATAL, logname, + "PR_Bind() on %s port %d failed: %s error %d (%s)\n", + netaddr2string(&sa_server, addrbuf, sizeof(addrbuf)), port, + SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); + } #if defined(ENABLE_LDAPI) - else - { - slapi_log_error(SLAPI_LOG_FATAL, logname, - "PR_Bind() on %s file %s failed: %s error %d (%s)\n", - netaddr2string(&sa_server, addrbuf, sizeof(addrbuf)), - sa_server.local.path, - SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); - } + else + { + slapi_log_error(SLAPI_LOG_FATAL, logname, + "PR_Bind() on %s file %s failed: %s error %d (%s)\n", + netaddr2string(&sa_server, addrbuf, sizeof(addrbuf)), + sa_server.local.path, + SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); + } #endif /* ENABLE_LDAPI */ - - goto failed; + goto failed; + } } #if defined(ENABLE_LDAPI) - if(local) - { - if(chmod(listenaddr->local.path, + if(local) { /* ldapi */ + if(chmod((*listenaddr)->local.path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) { slapi_log_error(SLAPI_LOG_FATAL, logname, "err: %d", errno); @@ -2721,7 +2858,7 @@ failed: suppressed: return (PRFileDesc *)-1; -} /* createprlistensocket */ +} /* createprlistensockets */ /* @@ -2729,36 +2866,63 @@ suppressed: * Returns: 0 if successful and -1 if not (after logging an error message). */ int -slapd_listenhost2addr(const char *listenhost, PRNetAddr *addr) +slapd_listenhost2addr(const char *listenhost, PRNetAddr ***addr) { - char *logname = "slapd_listenhost2addr"; - PRErrorCode prerr = 0; - int rval = 0; + char *logname = "slapd_listenhost2addr"; + PRErrorCode prerr = 0; + int rval = 0; + PRNetAddr *netaddr = (PRNetAddr *)slapi_ch_calloc(1, sizeof(PRNetAddr)); PR_ASSERT( addr != NULL ); + *addr = NULL; if (NULL == listenhost) { /* listen on all interfaces */ - if ( PR_SUCCESS != PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, addr)) { + if ( PR_SUCCESS != PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, netaddr)) { prerr = PR_GetError(); slapi_log_error( SLAPI_LOG_FATAL, logname, "PR_SetNetAddr(PR_IpAddrAny) failed - %s error %d (%s)\n", SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); rval = -1; + slapi_ch_free ((void**)&netaddr); } - } else if (PR_SUCCESS == PR_StringToNetAddr(listenhost, addr)) { + *addr = (PRNetAddr **)slapi_ch_calloc(2, sizeof (PRNetAddr *)); + *addr[0] = netaddr; + } else if (PR_SUCCESS == PR_StringToNetAddr(listenhost, netaddr)) { /* PR_StringNetAddr newer than NSPR v4.6.2 supports both IPv4&v6 */; + *addr = (PRNetAddr **)slapi_ch_calloc(2, sizeof (PRNetAddr *)); + *addr[0] = netaddr; } else { PRAddrInfo *infop = PR_GetAddrInfoByName( listenhost, PR_AF_UNSPEC, (PR_AI_ADDRCONFIG|PR_AI_NOCANONNAME) ); if ( NULL != infop ) { - memset( addr, 0, sizeof( PRNetAddr )); - if ( NULL == PR_EnumerateAddrInfo( NULL, infop, 0, addr )) { + void *iter = NULL; + int addrcnt = 0; + int i = 0; + memset( netaddr, 0, sizeof( PRNetAddr )); + /* need to count the address, first */ + while ( (iter = PR_EnumerateAddrInfo( iter, infop, 0, netaddr )) + != NULL ) { + addrcnt++; + } + if ( 0 == addrcnt ) { slapi_log_error( SLAPI_LOG_FATAL, logname, "PR_EnumerateAddrInfo for %s failed - %s error %d (%s)\n", listenhost, SLAPI_COMPONENT_NAME_NSPR, prerr, slapd_pr_strerror(prerr)); rval = -1; + } else { + *addr = (PRNetAddr **)slapi_ch_calloc(addrcnt + 1, sizeof (PRNetAddr *)); + iter = NULL; /* from the beginning */ + memset( netaddr, 0, sizeof( PRNetAddr )); + for ( i = 0; i < addrcnt; i++ ) { + iter = PR_EnumerateAddrInfo( iter, infop, 0, netaddr ); + if ( NULL == iter ) { + break; + } + *addr[i] = netaddr; + netaddr = (PRNetAddr *)slapi_ch_calloc(1, sizeof(PRNetAddr)); + } } PR_FreeAddrInfo( infop ); } else { @@ -2915,20 +3079,15 @@ get_configured_connection_table_size() return size; } - - - PRFileDesc * get_ssl_listener_fd() { PRFileDesc * listener; - listener = the_connection_table->fd[FDS_S_TCPS].fd; + listener = the_connection_table->fd[the_connection_table->s_tcps].fd; return listener; } - - int configure_pr_socket( PRFileDesc **pr_socket, int secure, int local ) { int ns = 0; diff --git a/ldap/servers/slapd/fe.h b/ldap/servers/slapd/fe.h index a92327c82..7ded15efc 100644 --- a/ldap/servers/slapd/fe.h +++ b/ldap/servers/slapd/fe.h @@ -134,6 +134,16 @@ struct connection_table /* An array of connections, file descriptors, and a mapping between them. */ Connection *c; struct POLL_STRUCT *fd; + int n_tcps; /* standard socket start index in fd */ + int n_tcpe; /* standard socket last ( +1 ) index in fd */ + int s_tcps; /* ssl socket start index in fd */ + int s_tcpe; /* ssl socket last ( +1 ) in fd */ +#ifndef XP_WIN32 +#if defined(ENABLE_LDAPI) + int i_unixs; /* unix socket start index in fd */ + int i_unixe; /* unix socket last ( +1 ) in fd */ +#endif /* ENABLE_LDAPI */ +#endif PRLock *table_mutex; }; typedef struct connection_table Connection_Table; @@ -166,7 +176,7 @@ int signal_listner(); int daemon_pre_setuid_init(daemon_ports_t *ports); void slapd_daemon( daemon_ports_t *ports ); void daemon_register_connection(); -int slapd_listenhost2addr( const char *listenhost, PRNetAddr *addr ); +int slapd_listenhost2addr( const char *listenhost, PRNetAddr ***addr ); int daemon_register_reslimits( void ); int secure_read_function( int ignore , void *buffer, int count, struct lextiof_socket_private *handle ); int secure_write_function( int ignore, const void *buffer, int count, struct lextiof_socket_private *handle ); diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index d735261ed..9a5987dcf 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -846,13 +846,15 @@ main( int argc, char **argv) (slapd_exemode == SLAPD_EXEMODE_REFERRAL)) { ports_info.n_port = (unsigned short)n_port; if ( slapd_listenhost2addr( config_get_listenhost(), - &ports_info.n_listenaddr ) != 0 ) { + &ports_info.n_listenaddr ) != 0 || + ports_info.n_listenaddr == NULL ) { return(1); } ports_info.s_port = (unsigned short)s_port; if ( slapd_listenhost2addr( config_get_securelistenhost(), - &ports_info.s_listenaddr ) != 0 ) { + &ports_info.s_listenaddr ) != 0 || + ports_info.s_listenaddr == NULL ) { return(1); } @@ -861,11 +863,13 @@ main( int argc, char **argv) config_get_ldapi_filename() != 0) { i_port = ports_info.i_port = 1; /* flag ldapi as on */ - ports_info.i_listenaddr.local.family = PR_AF_LOCAL; - PL_strncpyz(ports_info.i_listenaddr.local.path, + ports_info.i_listenaddr = (PRNetAddr **)slapi_ch_calloc(2, sizeof(PRNetAddr *)); + *ports_info.i_listenaddr = (PRNetAddr *)slapi_ch_calloc(1, sizeof(PRNetAddr)); + (*ports_info.i_listenaddr)->local.family = PR_AF_LOCAL; + PL_strncpyz((*ports_info.i_listenaddr)->local.path, config_get_ldapi_filename(), - sizeof(ports_info.i_listenaddr.local.path)); - unlink(ports_info.i_listenaddr.local.path); + sizeof((*ports_info.i_listenaddr)->local.path)); + unlink((*ports_info.i_listenaddr)->local.path); } #endif /* ENABLE_LDAPI */ @@ -919,10 +923,15 @@ main( int argc, char **argv) if ((slapd_exemode == SLAPD_EXEMODE_SLAPD) || (slapd_exemode == SLAPD_EXEMODE_REFERRAL)) { - if ( init_ssl && ( 0 != slapd_ssl_init2(&ports_info.s_socket, 0) ) ) { - LDAPDebug(LDAP_DEBUG_ANY, + if ( init_ssl ) { + PRFileDesc **sock; + for (sock = ports_info.s_socket; sock && *sock; sock++) { + if ( 0 != slapd_ssl_init2(sock, 0) ) { + LDAPDebug(LDAP_DEBUG_ANY, "ERROR: SSL Initialization phase 2 Failed.\n", 0, 0, 0 ); - exit( 1 ); + exit( 1 ); + } + } } } diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 1be6c20e4..4f9c91acd 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1456,20 +1456,21 @@ typedef struct ref_array { typedef struct daemon_ports_s { int n_port; int s_port; - PRNetAddr n_listenaddr; - PRNetAddr s_listenaddr; + PRNetAddr **n_listenaddr; + PRNetAddr **s_listenaddr; #if defined( XP_WIN32 ) int n_socket; int s_socket_native; #else - PRFileDesc *n_socket; + PRFileDesc **n_socket; +#if defined(ENABLE_LDAPI) /* ldapi */ - PRNetAddr i_listenaddr; + PRNetAddr **i_listenaddr; int i_port; /* used as a flag only */ - PRFileDesc *i_socket; - + PRFileDesc **i_socket; +#endif #endif - PRFileDesc *s_socket; + PRFileDesc **s_socket; } daemon_ports_t;
0
762219a35005914c6c088d915ac9346ce7e28512
389ds/389-ds-base
Ticket bz1358565 - clear and unsalted password types are vulnerable to timing attack Bug Description: Clear and unsalted password types were vulnerable to a timing attack. This is due to the use of memcmp and strcmp in their comparison. Fix Description: Add a constant time memcmp function, that does not shortcircuit. Change all password comparison to use the constant time check. For the clear scheme, alter the way we do the check to prevent length disclosure timing attacks. This resolves CVE-2016-5405 https://bugzilla.redhat.com/show_bug.cgi?id=1358565 https://access.redhat.com/security/cve/CVE-2016-5405 Author: wibrown Review by: nhosoi (Thanks!) (cherry picked from commit 9dcaa4a0c866d8696e0a2616ccf962af2833f0b8)
commit 762219a35005914c6c088d915ac9346ce7e28512 Author: William Brown <[email protected]> Date: Thu Jul 21 13:22:30 2016 +1000 Ticket bz1358565 - clear and unsalted password types are vulnerable to timing attack Bug Description: Clear and unsalted password types were vulnerable to a timing attack. This is due to the use of memcmp and strcmp in their comparison. Fix Description: Add a constant time memcmp function, that does not shortcircuit. Change all password comparison to use the constant time check. For the clear scheme, alter the way we do the check to prevent length disclosure timing attacks. This resolves CVE-2016-5405 https://bugzilla.redhat.com/show_bug.cgi?id=1358565 https://access.redhat.com/security/cve/CVE-2016-5405 Author: wibrown Review by: nhosoi (Thanks!) (cherry picked from commit 9dcaa4a0c866d8696e0a2616ccf962af2833f0b8) diff --git a/ldap/servers/slapd/ch_malloc.c b/ldap/servers/slapd/ch_malloc.c index 8f4697062..52ccb64e8 100644 --- a/ldap/servers/slapd/ch_malloc.c +++ b/ldap/servers/slapd/ch_malloc.c @@ -123,7 +123,7 @@ slapi_ch_memalign(size_t size, size_t alignment) int oserr = errno; oom_occurred(); - slapi_log_error(SLAPI_LOG_ERR, SLAPD_MODULE, + slapi_log_err(SLAPI_LOG_ERR, SLAPD_MODULE, "malloc of %lu bytes failed; OS error %d (%s)%s\n", size, oserr, slapd_system_strerror( oserr ), oom_advice ); exit( 1 ); @@ -349,13 +349,12 @@ slapi_ct_memcmp( const void *p1, const void *p2, size_t n) int result = 0; const unsigned char *_p1 = (const unsigned char *)p1; const unsigned char *_p2 = (const unsigned char *)p2; - size_t i; if (_p1 == NULL || _p2 == NULL) { return 2; } - for (i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { if (_p1[i] ^ _p2[i]) { result = 1; }
0
3ffcb34e5d03791273360d031f512913228dd04f
389ds/389-ds-base
Issue 5842 - Add log buffering for error log Description: Adding log buffering for error log. Also refactored and cleaned up some of the code. relates: https://github.com/389ds/389-ds-base/issues/5842 Reviewed by: tbordaz & progier (Thanks!!)
commit 3ffcb34e5d03791273360d031f512913228dd04f Author: Mark Reynolds <[email protected]> Date: Fri Nov 8 08:36:12 2024 -0500 Issue 5842 - Add log buffering for error log Description: Adding log buffering for error log. Also refactored and cleaned up some of the code. relates: https://github.com/389ds/389-ds-base/issues/5842 Reviewed by: tbordaz & progier (Thanks!!) diff --git a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py index 8670db312..209d63b5d 100644 --- a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py +++ b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py @@ -1369,9 +1369,47 @@ def test_missing_backend_suffix(topology_st, request): log.info('Restore dse.ldif') topology_st.standalone.stop() shutil.copy(dse_ldif + '.correct', dse_ldif) + topology_st.standalone.start() request.addfinalizer(fin) + +def test_errorlog_buffering(topology_st, request): + """Test log buffering works as expected when on or off + + :id: 324ec5ed-c8ec-49fe-ab20-8c8cbfedca41 + :setup: Standalone Instance + :steps: + 1. Set buffering on + 2. Reset logs and restart the server + 3. Check for logging that should be buffered (not found) + 4. Disable buffering + 5. Reset logs and restart the server + 6. Check for logging that should be found + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + """ + + # Configure instance + inst = topology_st.standalone + inst.config.replace('nsslapd-errorlog-logbuffering', 'on') + inst.deleteErrorLogs(restart=True) + + time.sleep(1) + assert not inst.ds_error_log.match(".*slapd_daemon - slapd started.*") + + inst.config.replace('nsslapd-errorlog-logbuffering', 'off') + inst.deleteErrorLogs(restart=True) + + time.sleep(1) + assert inst.ds_error_log.match(".*slapd_daemon - slapd started.*") + + if __name__ == '__main__': # Run isolated # -s for DEBUG mode diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 3eb0d9fe5..6af49a54f 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -186,6 +186,7 @@ slapi_onoff_t init_securitylog_compress_enabled; slapi_onoff_t init_auditlog_compress_enabled; slapi_onoff_t init_auditfaillog_compress_enabled; slapi_onoff_t init_errorlog_compress_enabled; +slapi_onoff_t init_errorlogbuffering; slapi_onoff_t init_accesslog_logging_enabled; slapi_onoff_t init_accesslogbuffering; slapi_onoff_t init_securitylog_logging_enabled; @@ -848,6 +849,10 @@ static struct config_get_and_set NULL, 0, (void **)&global_slapdFrontendConfig.securitylogbuffering, CONFIG_ON_OFF, NULL, &init_securitylogbuffering, NULL}, + {CONFIG_ERRORLOG_BUFFERING_ATTRIBUTE, config_set_errorlogbuffering, + NULL, 0, + (void **)&global_slapdFrontendConfig.errorlogbuffering, + CONFIG_ON_OFF, NULL, &init_errorlogbuffering, NULL}, {CONFIG_CSNLOGGING_ATTRIBUTE, config_set_csnlogging, NULL, 0, (void **)&global_slapdFrontendConfig.csnlogging, @@ -1910,6 +1915,7 @@ FrontendConfig_init(void) cfg->errorlog_exptimeunit = slapi_ch_strdup(SLAPD_INIT_LOG_EXPTIMEUNIT); cfg->errorloglevel = SLAPD_DEFAULT_FE_ERRORLOG_LEVEL; init_errorlog_compress_enabled = cfg->errorlog_compress = LDAP_OFF; + init_errorlogbuffering = cfg->errorlogbuffering = LDAP_OFF; init_auditlog_logging_enabled = cfg->auditlog_logging_enabled = LDAP_OFF; cfg->auditlog_log_format = slapi_ch_strdup(SLAPD_INIT_AUDITLOG_LOG_FORMAT); @@ -7852,6 +7858,21 @@ config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, return retVal; } +int32_t +config_set_errorlogbuffering(const char *attrname, char *value, char *errorbuf, int apply) +{ + int32_t retVal = LDAP_SUCCESS; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + + retVal = config_set_onoff(attrname, + value, + &(slapdFrontendConfig->errorlogbuffering), + errorbuf, + apply); + + return retVal; +} + int32_t config_set_auditlogbuffering(const char *attrname, char *value, char *errorbuf, int apply) { diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index bd6bbca33..8352f4abd 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -48,6 +48,8 @@ struct logbufinfo *logbuf_accum; static struct logging_opts loginfo; static int detached = 0; +typedef int open_log(int32_t state, int32_t flags); + //extern int slapd_ldap_debug; /* @@ -121,11 +123,12 @@ static int vslapd_log_security(const char *log_data); static void log_convert_time(time_t ctime, char *tbuf, int type); static time_t log_reverse_convert_time(char *tbuf); static LogBufferInfo *log_create_buffer(size_t sz); -static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, char *msg2, size_t size2); +static void log_append_access_buffer(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, char *msg2, size_t size2); static void log_append_security_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size); static void log_append_audit_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size); static void log_append_auditfail_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size); -static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now); +static void log_append_error_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size, int locked); +static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now, int locked); static void log_write_title(LOGFD fp); static void log__error_emergency(const char *errstr, int reopen, int locked); static void vslapd_log_emergency_error(LOGFD fp, const char *msg, int locked); @@ -235,6 +238,8 @@ slapd_log_error_proc_internal( * LOG_WRITE_NOW(fd, buffer, size, headersize, err) writes into a LOGFD and * flushes the buffer if necessary * LOG_CLOSE(fd) closes the logfile + * + * Note - the LOG_WRITE macros set "rc" */ #define LOG_OPEN_APPEND(fd, filename, mode) \ (((fd) = PR_Open((filename), PR_WRONLY | PR_APPEND | PR_CREATE_FILE, \ @@ -243,30 +248,36 @@ slapd_log_error_proc_internal( (((fd) = PR_Open((filename), PR_WRONLY | PR_TRUNCATE | \ PR_CREATE_FILE, \ mode)) != NULL) -#define LOG_WRITE(fd, buffer, size, headersize) \ - if (slapi_write_buffer((fd), (buffer), (PRInt32)(size)) != (PRInt32)(size)) { \ - PRErrorCode prerr = PR_GetError(); \ - syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer) + (headersize)); \ - } -#define LOG_WRITE_NOW(fd, buffer, size, headersize, err) \ - do { \ - (err) = 0; \ - if (slapi_write_buffer((fd), (buffer), (PRInt32)(size)) != (PRInt32)(size)) { \ - PRErrorCode prerr = PR_GetError(); \ - syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer) + (headersize)); \ - (err) = prerr; \ - } \ - /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \ - PR_Sync(fd); \ +#define LOG_WRITE(fd, buffer, size, headersize) \ + if (slapi_write_buffer((fd), (buffer), (PRInt32)(size)) != (PRInt32)(size)) { \ + PRErrorCode prerr = PR_GetError(); \ + syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", \ + prerr, slapd_pr_strerror(prerr), (buffer) + (headersize)); \ + rc = -1; \ + } +#define LOG_WRITE_NOW(fd, buffer, size, headersize, err) \ + do { \ + (err) = 0; \ + if (slapi_write_buffer((fd), (buffer), (PRInt32)(size)) != (PRInt32)(size)) { \ + PRErrorCode prerr = PR_GetError(); \ + syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", \ + prerr, slapd_pr_strerror(prerr), (buffer) + (headersize)); \ + (err) = prerr; \ + rc = -1; \ + } \ + /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \ + PR_Sync(fd); \ } while (0) -#define LOG_WRITE_NOW_NO_ERR(fd, buffer, size, headersize) \ - do { \ - if (slapi_write_buffer((fd), (buffer), (PRInt32)(size)) != (PRInt32)(size)) { \ - PRErrorCode prerr = PR_GetError(); \ - syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer) + (headersize)); \ - } \ - /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \ - PR_Sync(fd); \ +#define LOG_WRITE_NOW_NO_ERR(fd, buffer, size, headersize) \ + do { \ + if (slapi_write_buffer((fd), (buffer), (PRInt32)(size)) != (PRInt32)(size)) { \ + PRErrorCode prerr = PR_GetError(); \ + syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", \ + prerr, slapd_pr_strerror(prerr), (buffer) + (headersize)); \ + rc = -1; \ + } \ + /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \ + PR_Sync(fd); \ } while (0) #define LOG_CLOSE(fd) \ PR_Close((fd)) @@ -418,6 +429,10 @@ g_log_init() if ((loginfo.log_error_rwlock = slapi_new_rwlock()) == NULL) { exit(-1); } + loginfo.log_error_buffer = log_create_buffer(LOG_BUFFER_MAXSIZE); + if ((loginfo.log_error_buffer->lock = PR_NewLock()) == NULL) { + exit(-1); + } /* AUDIT LOG */ loginfo.log_audit_state = cfg->auditlog_logging_enabled; @@ -2245,12 +2260,16 @@ log_write_title(LOGFD fp) char *buildnum = config_get_buildnum(); char buff[512]; int bufflen = sizeof(buff); + int rc = 0; PR_snprintf(buff, bufflen, "\t%s B%s\n", fe_cfg->versionstring ? fe_cfg->versionstring : CAPBRAND "-Directory/" DS_PACKAGE_VERSION, buildnum ? buildnum : ""); LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0); - + if (rc != 0) { + slapi_ch_free((void **)&buildnum); + return; + } if (fe_cfg->localhost) { PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n", fe_cfg->localhost, @@ -2276,7 +2295,6 @@ log_write_title(LOGFD fp) int error_log_openf(char *pathname, int locked) { - int rv = 0; int logfile_type = 0; @@ -2314,7 +2332,6 @@ error_log_openf(char *pathname, int locked) int audit_log_openf(char *pathname, int locked) { - int rv = 0; int logfile_type = 0; @@ -2355,7 +2372,6 @@ audit_log_openf(char *pathname, int locked) int auditfail_log_openf(char *pathname, int locked) { - int rv = 0; int logfile_type = 0; @@ -2408,7 +2424,7 @@ vslapd_log_audit(const char *log_data, PRBool json_format) */ if (msg_len > SLAPI_LOG_BUFSIZ) { PR_Lock(loginfo.log_audit_buffer->lock); - log_flush_buffer(loginfo.log_audit_buffer, SLAPD_AUDIT_LOG, 0); + log_flush_buffer(loginfo.log_audit_buffer, SLAPD_AUDIT_LOG, 0, 1); LogBufferInfo lbi; lbi.top = (char *)log_data; @@ -2416,7 +2432,7 @@ vslapd_log_audit(const char *log_data, PRBool json_format) lbi.maxsize = msg_len; lbi.lock = NULL; lbi.refcount = 0; - log_flush_buffer(&lbi, SLAPD_AUDIT_LOG, 0); + log_flush_buffer(&lbi, SLAPD_AUDIT_LOG, 0, 1); PR_Unlock(loginfo.log_audit_buffer->lock); return 0; @@ -2495,7 +2511,7 @@ log_append_audit_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size) (tnl >= loginfo.log_audit_rotationsyncclock && loginfo.log_audit_rotationsync_enabled)) { - log_flush_buffer(lbi, SLAPD_AUDIT_LOG, 0 /* do not sync to disk */); + log_flush_buffer(lbi, SLAPD_AUDIT_LOG, 0 /* do not sync to disk */, 1); } insert_point = lbi->current; lbi->current += size; @@ -2512,7 +2528,7 @@ log_append_audit_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size) /* If we are asked to sync to disk immediately, do so */ if (!slapdFrontendConfig->auditlogbuffering) { PR_Lock(lbi->lock); - log_flush_buffer(lbi, SLAPD_AUDIT_LOG, 1 /* sync to disk now */); + log_flush_buffer(lbi, SLAPD_AUDIT_LOG, 1 /* sync to disk now */, 1); PR_Unlock(lbi->lock); } } @@ -2539,7 +2555,7 @@ vslapd_log_auditfail(const char *log_data, PRBool json_format) */ if (msg_len > SLAPI_LOG_BUFSIZ) { PR_Lock(loginfo.log_auditfail_buffer->lock); - log_flush_buffer(loginfo.log_auditfail_buffer, SLAPD_AUDITFAIL_LOG, 0); + log_flush_buffer(loginfo.log_auditfail_buffer, SLAPD_AUDITFAIL_LOG, 0, 1); LogBufferInfo lbi; lbi.top = (char *)log_data; @@ -2547,7 +2563,7 @@ vslapd_log_auditfail(const char *log_data, PRBool json_format) lbi.maxsize = msg_len; lbi.lock = NULL; lbi.refcount = 0; - log_flush_buffer(&lbi, SLAPD_AUDITFAIL_LOG, 0); + log_flush_buffer(&lbi, SLAPD_AUDITFAIL_LOG, 0, 1); PR_Unlock(loginfo.log_auditfail_buffer->lock); return 0; @@ -2626,7 +2642,7 @@ log_append_auditfail_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t si (tnl >= loginfo.log_auditfail_rotationsyncclock && loginfo.log_auditfail_rotationsync_enabled)) { - log_flush_buffer(lbi, SLAPD_AUDITFAIL_LOG, 0 /* do not sync to disk */); + log_flush_buffer(lbi, SLAPD_AUDITFAIL_LOG, 0 /* do not sync to disk */, 1); } insert_point = lbi->current; lbi->current += size; @@ -2643,7 +2659,7 @@ log_append_auditfail_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t si /* If we are asked to sync to disk immediately, do so */ if (!slapdFrontendConfig->auditlogbuffering) { PR_Lock(lbi->lock); - log_flush_buffer(lbi, SLAPD_AUDITFAIL_LOG, 1 /* sync to disk now */); + log_flush_buffer(lbi, SLAPD_AUDITFAIL_LOG, 1 /* sync to disk now */, 1); PR_Unlock(lbi->lock); } } @@ -2803,6 +2819,44 @@ get_log_sev_name(int loglevel, char *sev_name) return ""; } +static void +log_append_error_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size, int locked) +{ + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + char *insert_point = NULL; + + /* While holding the lock, we determine if there is space in the buffer for our payload, + and if we need to flush. + */ + PR_Lock(lbi->lock); + if (((lbi->current - lbi->top) + size > lbi->maxsize) || + (tnl >= loginfo.log_error_rotationsyncclock && + loginfo.log_error_rotationsync_enabled)) + { + log_flush_buffer(lbi, SLAPD_ERROR_LOG, 0 /* do not sync to disk */, + locked); + } + insert_point = lbi->current; + lbi->current += size; + /* Increment the copy refcount */ + slapi_atomic_incr_64(&(lbi->refcount), __ATOMIC_RELEASE); + PR_Unlock(lbi->lock); + + /* Now we can copy without holding the lock */ + memcpy(insert_point, msg, size); + + /* Decrement the copy refcount */ + slapi_atomic_decr_64(&(lbi->refcount), __ATOMIC_RELEASE); + + /* If we are asked to sync to disk immediately, do so */ + if (!slapdFrontendConfig->errorlogbuffering) { + PR_Lock(lbi->lock); + log_flush_buffer(lbi, SLAPD_ERROR_LOG, 1 /* sync to disk now */, + locked); + PR_Unlock(lbi->lock); + } +} + static int vslapd_log_error( LOGFD fp, @@ -2812,13 +2866,12 @@ vslapd_log_error( va_list ap, int locked) { + time_t tnl = slapi_current_utc_time(); char buffer[SLAPI_LOG_BUFSIZ]; struct timespec tsnow; char sev_name[10]; int blen = TBUFSIZE; char *vbuf = NULL; - int header_len = 0; - int err = 0; if (vasprintf(&vbuf, fmt, ap) == -1) { log__error_emergency("vslapd_log_error, Unable to format message", 1, locked); @@ -2841,23 +2894,21 @@ vslapd_log_error( return -1; } - /* Bug 561525: to be able to remove timestamp to not over pollute syslog, we may need - to skip the timestamp part of the message. - The size of the header is: - the size of the time string - + size of space - + size of one char (sign) - + size of 2 char - + size of 2 char - + size of [ - + size of ] - */ - - /* Due to the change to use format_localTime_log, this is now blen */ - header_len = blen; + /* + * To be able to remove timestamp to not over pollute the syslog, we may + * need to skip the timestamp part of the message. + * + * The size of the header is: + * the size of the time string + * + size of space + * + size of one char (sign) + * + size of 2 char + * + size of 2 char + * + size of [ + * + size of ] + */ - /* blen = strlen(buffer); */ - /* This truncates again .... But we have the nice smprintf above! */ + /* This truncates again... But we have the nice smprintf from above! */ if (subsystem == NULL) { snprintf(buffer + blen, sizeof(buffer) - blen, "- %s - %s", get_log_sev_name(sev_level, sev_name), vbuf); @@ -2867,28 +2918,12 @@ vslapd_log_error( } buffer[sizeof(buffer) - 1] = '\0'; - - if (fp) - do { - int size = strlen(buffer); - (err) = 0; - if (slapi_write_buffer((fp), (buffer), (size)) != (size)) { - PRErrorCode prerr = PR_GetError(); - syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer) + (header_len)); - (err) = prerr; - } - /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ - PR_Sync(fp); - } while (0); - else /* stderr is always unbuffered */ - fprintf(stderr, "%s", buffer); - - if (err) { - PR_snprintf(buffer, sizeof(buffer), - "Writing to the errors log failed. Exiting..."); - log__error_emergency(buffer, 1, locked); - /* failed to write to the errors log. should not continue. */ - g_set_shutdown(SLAPI_SHUTDOWN_EXIT); + if (fp) { + log_append_error_buffer(tnl, loginfo.log_error_buffer, buffer, + strlen(buffer), locked); + } else { + /* stderr is always unbuffered */ + fprintf(stderr, "%s", buffer); } slapi_ch_free_string(&vbuf); @@ -3060,7 +3095,9 @@ vslapd_log_access(const char *fmt, va_list ap) * someone is trying to do something bad. */ vlen = strlen(vbuf); /* Truncated length */ memcpy(&vbuf[vlen-4], "...\n", 4); /* Replace last characters with three dots and a new line character */ - slapi_log_err(SLAPI_LOG_ERR, "vslapd_log_access", "Insufficient buffer capacity to fit timestamp and message! The line in the access log was truncated\n"); + slapi_log_err(SLAPI_LOG_ERR, "vslapd_log_access", + "Insufficient buffer capacity to fit timestamp and message! " + "The line in the access log was truncated\n"); rc = -1; } @@ -3068,7 +3105,7 @@ vslapd_log_access(const char *fmt, va_list ap) STAP_PROBE(ns-slapd, vslapd_log_access__prepared); #endif - log_append_buffer2(tnl, loginfo.log_access_buffer, buffer, blen, vbuf, vlen); + log_append_access_buffer(tnl, loginfo.log_access_buffer, buffer, blen, vbuf, vlen); #ifdef SYSTEMTAP STAP_PROBE(ns-slapd, vslapd_log_access__buffer); @@ -3191,13 +3228,13 @@ access_log_openf(char *pathname, int locked) static int log__open_accesslogfile(int logfile_state, int locked) { - time_t now; LOGFD fp; LOGFD fpinfo = NULL; char tbuf[TBUFSIZE]; struct logfileinfo *logp; char buffer[BUFSIZ]; + int rc; if (!locked) LOG_ACCESS_LOCK_WRITE(); @@ -3326,8 +3363,12 @@ log__open_accesslogfile(int logfile_state, int locked) PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%" PRId64 ")\n", PREVLOGFILE, loginfo.log_access_file, tbuf, logp->l_ctime, logp->l_size); LOG_WRITE(fpinfo, buffer, strlen(buffer), 0); + if (rc != 0) { + break; + } logp = logp->l_next; } + /* Close the info file. We need only when we need to rotate to the ** next log file. */ @@ -3351,13 +3392,13 @@ log__open_accesslogfile(int logfile_state, int locked) static int log__open_securitylogfile(int logfile_state, int locked) { - time_t now; LOGFD fp; LOGFD fpinfo = NULL; char tbuf[TBUFSIZE]; struct logfileinfo *logp; char buffer[BUFSIZ]; + int rc; if (!locked) LOG_SECURITY_LOCK_WRITE(); @@ -3490,8 +3531,12 @@ log__open_securitylogfile(int logfile_state, int locked) PREVLOGFILE, loginfo.log_security_file, tbuf, logp->l_ctime, logp->l_size); LOG_WRITE(fpinfo, buffer, strlen(buffer), 0); + if (rc != 0) { + break; + } logp = logp->l_next; } + /* Close the info file. We need only when we need to rotate to the ** next log file. */ @@ -3906,7 +3951,7 @@ log_append_security_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t siz (tnl >= loginfo.log_security_rotationsyncclock && loginfo.log_security_rotationsync_enabled)) { - log_flush_buffer(lbi, SLAPD_SECURITY_LOG, 0 /* do not sync to disk */); + log_flush_buffer(lbi, SLAPD_SECURITY_LOG, 0 /* do not sync to disk */, 1); } insert_point = lbi->current; lbi->current += size; @@ -3923,7 +3968,7 @@ log_append_security_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t siz /* If we are asked to sync to disk immediately, do so */ if (!slapdFrontendConfig->securitylogbuffering) { PR_Lock(lbi->lock); - log_flush_buffer(lbi, SLAPD_SECURITY_LOG, 1 /* sync to disk now */); + log_flush_buffer(lbi, SLAPD_SECURITY_LOG, 1 /* sync to disk now */, 1); PR_Unlock(lbi->lock); } } @@ -5039,7 +5084,6 @@ log__extract_logheader(FILE *fp, long *f_ctime, PRInt64 *f_size, PRBool *compres *compressed = PR_TRUE; } } - return LOG_CONTINUE; } @@ -5871,8 +5915,9 @@ log__audit_rotationinfof(char *pathname) */ while ((rval = log__extract_logheader(fp, &f_ctime, &f_size, &compressed)) == LOG_CONTINUE) { /* first we would get the main log info */ - if (f_ctime == 0 && f_size == 0) + if (f_ctime == 0 && f_size == 0) { continue; + } time(&now); if (main_log) { @@ -6054,7 +6099,6 @@ log__error_emergency(const char *errstr, int reopen, int locked) static int log__open_errorlogfile(int logfile_state, int locked) { - time_t now; LOGFD fp = NULL; LOGFD fpinfo = NULL; @@ -6185,6 +6229,7 @@ log__open_errorlogfile(int logfile_state, int locked) /* we have all the information */ if (!locked) LOG_ERROR_UNLOCK_WRITE(); + return LOG_SUCCESS; } @@ -6225,8 +6270,12 @@ log__open_errorlogfile(int logfile_state, int locked) PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%" PRId64 "d)\n", PREVLOGFILE, loginfo.log_error_file, tbuf, logp->l_ctime, logp->l_size); LOG_WRITE(fpinfo, buffer, strlen(buffer), 0); + if (rc != 0) { + break; + } logp = logp->l_next; } + /* Close the info file. We need only when we need to rotate to the ** next log file. */ @@ -6250,13 +6299,13 @@ log__open_errorlogfile(int logfile_state, int locked) static int log__open_auditlogfile(int logfile_state, int locked) { - time_t now; LOGFD fp; LOGFD fpinfo = NULL; char tbuf[TBUFSIZE]; struct logfileinfo *logp; char buffer[BUFSIZ]; + int rc; if (!locked) LOG_AUDIT_LOCK_WRITE(); @@ -6380,8 +6429,12 @@ log__open_auditlogfile(int logfile_state, int locked) PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%" PRId64 "d)\n", PREVLOGFILE, loginfo.log_audit_file, tbuf, logp->l_ctime, logp->l_size); LOG_WRITE(fpinfo, buffer, strlen(buffer), 0); + if (rc != 0) { + break; + } logp = logp->l_next; } + /* Close the info file. We need only when we need to rotate to the ** next log file. */ @@ -6395,6 +6448,7 @@ log__open_auditlogfile(int logfile_state, int locked) LOG_AUDIT_UNLOCK_WRITE(); return LOG_SUCCESS; } + /****************************************************************************** * log__open_auditfaillogfile * @@ -6404,13 +6458,13 @@ log__open_auditlogfile(int logfile_state, int locked) static int log__open_auditfaillogfile(int logfile_state, int locked) { - time_t now; LOGFD fp; LOGFD fpinfo = NULL; char tbuf[TBUFSIZE]; struct logfileinfo *logp; char buffer[BUFSIZ]; + int rc; if (!locked) LOG_AUDITFAIL_LOCK_WRITE(); @@ -6534,8 +6588,12 @@ log__open_auditfaillogfile(int logfile_state, int locked) PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%" PRId64 "d)\n", PREVLOGFILE, loginfo.log_auditfail_file, tbuf, logp->l_ctime, logp->l_size); LOG_WRITE(fpinfo, buffer, strlen(buffer), 0); + if (rc != 0) { + break; + } logp = logp->l_next; } + /* Close the info file. We need only when we need to rotate to the ** next log file. */ @@ -6586,7 +6644,7 @@ log_create_buffer(size_t sz) * systems. */ static void -log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, char *msg2, size_t size2) +log_append_access_buffer(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, char *msg2, size_t size2) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); size_t size = size1 + size2; @@ -6601,7 +6659,7 @@ log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, cha loginfo.log_access_rotationsync_enabled)) { log_flush_buffer(lbi, SLAPD_ACCESS_LOG, - 0 /* do not sync to disk right now */); + 0 /* do not sync to disk right now */, 1); } insert_point = lbi->current; lbi->current += size; @@ -6619,162 +6677,211 @@ log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, cha /* If we are asked to sync to disk immediately, do so */ if (!slapdFrontendConfig->accesslogbuffering) { PR_Lock(lbi->lock); - log_flush_buffer(lbi, SLAPD_ACCESS_LOG, 1 /* sync to disk now */); + log_flush_buffer(lbi, SLAPD_ACCESS_LOG, 1 /* sync to disk now */, 1); PR_Unlock(lbi->lock); } } +static time_t +log_update_sync_clock(int32_t log_type, int32_t secs) +{ + switch (log_type) { + case SLAPD_ACCESS_LOG: + loginfo.log_access_rotationsyncclock += PR_ABS(secs); + return loginfo.log_access_rotationsyncclock; + case SLAPD_SECURITY_LOG: + loginfo.log_security_rotationsyncclock += PR_ABS(secs); + return loginfo.log_security_rotationsyncclock; + case SLAPD_AUDIT_LOG: + loginfo.log_audit_rotationsyncclock += PR_ABS(secs); + return loginfo.log_audit_rotationsyncclock; + case SLAPD_AUDITFAIL_LOG: + loginfo.log_auditfail_rotationsyncclock += PR_ABS(secs); + return loginfo.log_auditfail_rotationsyncclock; + case SLAPD_ERROR_LOG: + loginfo.log_error_rotationsyncclock += PR_ABS(secs); + return loginfo.log_error_rotationsyncclock; + default: + return 0; + } +} + +static void +log_state_remove_need_title(int32_t log_type) +{ + switch (log_type) { + case SLAPD_ACCESS_LOG: + loginfo.log_access_state &= ~LOGGING_NEED_TITLE; + break; + case SLAPD_SECURITY_LOG: + loginfo.log_security_state &= ~LOGGING_NEED_TITLE; + break; + case SLAPD_AUDIT_LOG: + loginfo.log_audit_state &= ~LOGGING_NEED_TITLE; + break; + case SLAPD_AUDITFAIL_LOG: + loginfo.log_auditfail_state &= ~LOGGING_NEED_TITLE; + break; + case SLAPD_ERROR_LOG: + loginfo.log_error_state &= ~LOGGING_NEED_TITLE; + break; + } +} + +static int32_t +log_refresh_state(int32_t log_type) +{ + switch (log_type) { + case SLAPD_ACCESS_LOG: + return loginfo.log_access_state; + case SLAPD_SECURITY_LOG: + return loginfo.log_security_state; + case SLAPD_AUDIT_LOG: + return loginfo.log_audit_state; + case SLAPD_AUDITFAIL_LOG: + return loginfo.log_auditfail_state; + case SLAPD_ERROR_LOG: + return loginfo.log_error_state; + default: + return 0; + } +} /* this function assumes the lock is already acquired */ /* if sync_now is non-zero, data is flushed to physical storage */ static void -log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now) +log_flush_buffer(LogBufferInfo *lbi, int log_type, int sync_now, int locked) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + LOGFD fd; + char *log_name; + char *log_file = NULL; + time_t rotation_sync_clock; + time_t log_ctime; + int32_t rotationtime_secs; + int32_t log_state; + PRBool log_buffering = PR_FALSE; + open_log *open_log_file = NULL; + int rc = 0; - if (type == SLAPD_ACCESS_LOG) { - /* It is only safe to flush once any other threads which are copying are finished */ - while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { - /* It's ok to sleep for a while because we only flush every second or so */ - DS_Sleep(PR_MillisecondsToInterval(1)); - } + /* + * It is only safe to flush once all other threads which are copying are + * finished + */ + while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { + /* It's ok to sleep for a while because we only flush every second or so */ + DS_Sleep(PR_MillisecondsToInterval(1)); + } - if ((lbi->current - lbi->top) == 0) - return; + if ((lbi->current - lbi->top) == 0) { + return; + } - if (log__needrotation(loginfo.log_access_fdes, - SLAPD_ACCESS_LOG) == LOG_ROTATE) { - if (log__open_accesslogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, - "log_flush_buffer", "Unable to open access file:%s\n", - loginfo.log_access_file); - lbi->current = lbi->top; /* reset counter to prevent overwriting rest of lbi struct */ - return; - } - while (loginfo.log_access_rotationsyncclock <= loginfo.log_access_ctime) { - loginfo.log_access_rotationsyncclock += PR_ABS(loginfo.log_access_rotationtime_secs); - } - } + switch (log_type) { + case SLAPD_ACCESS_LOG: + open_log_file = &log__open_accesslogfile; + fd = loginfo.log_access_fdes; + log_file = loginfo.log_access_file; + rotation_sync_clock = loginfo.log_access_rotationsyncclock; + log_ctime = loginfo.log_access_ctime; + rotationtime_secs = loginfo.log_access_rotationtime_secs; + log_state = loginfo.log_access_state; + log_buffering = slapdFrontendConfig->accesslogbuffering ? PR_TRUE : PR_FALSE; + log_name = "access"; + break; - if (loginfo.log_access_state & LOGGING_NEED_TITLE) { - log_write_title(loginfo.log_access_fdes); - loginfo.log_access_state &= ~LOGGING_NEED_TITLE; - } - if (!sync_now && slapdFrontendConfig->accesslogbuffering) { - LOG_WRITE(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0); - } else { - LOG_WRITE_NOW_NO_ERR(loginfo.log_access_fdes, lbi->top, - lbi->current - lbi->top, 0); - } - lbi->current = lbi->top; - } else if (type == SLAPD_SECURITY_LOG) { - /* It is only safe to flush once any other threads which are copying are finished */ - while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { - /* It's ok to sleep for a while because we only flush every second or so */ - DS_Sleep(PR_MillisecondsToInterval(1)); - } + case SLAPD_SECURITY_LOG: + open_log_file = &log__open_securitylogfile; + fd = loginfo.log_security_fdes; + log_file = loginfo.log_security_file; + rotation_sync_clock = loginfo.log_security_rotationsyncclock; + log_ctime = loginfo.log_security_ctime; + rotationtime_secs = loginfo.log_security_rotationtime_secs; + log_state = loginfo.log_security_state; + log_buffering = slapdFrontendConfig->securitylogbuffering ? PR_TRUE : PR_FALSE; + log_name = "security audit"; + break; - if ((lbi->current - lbi->top) == 0) { - return; - } + case SLAPD_AUDIT_LOG: + open_log_file = &log__open_auditlogfile; + fd = loginfo.log_audit_fdes; + log_file = loginfo.log_audit_file; + rotation_sync_clock = loginfo.log_audit_rotationsyncclock; + log_ctime = loginfo.log_audit_ctime; + rotationtime_secs = loginfo.log_audit_rotationtime_secs; + log_state = loginfo.log_audit_state; + log_buffering = slapdFrontendConfig->auditlogbuffering ? PR_TRUE : PR_FALSE; + log_name = "audit"; + break; - if (log__needrotation(loginfo.log_security_fdes, SLAPD_SECURITY_LOG) == LOG_ROTATE) { - if (log__open_securitylogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, - "log_flush_buffer", "Unable to open security audit file:%s\n", - loginfo.log_security_file); - lbi->current = lbi->top; /* reset counter to prevent overwriting rest of lbi struct */ - return; - } - while (loginfo.log_security_rotationsyncclock <= loginfo.log_security_ctime) { - loginfo.log_security_rotationsyncclock += PR_ABS(loginfo.log_security_rotationtime_secs); - } - } + case SLAPD_AUDITFAIL_LOG: + open_log_file = &log__open_auditfaillogfile; + fd = loginfo.log_auditfail_fdes; + log_file = loginfo.log_auditfail_file; + rotation_sync_clock = loginfo.log_auditfail_rotationsyncclock; + log_ctime = loginfo.log_auditfail_ctime; + rotationtime_secs = loginfo.log_auditfail_rotationtime_secs; + log_state = loginfo.log_auditfail_state; + /* Audit fail log still uses the audit log buffering setting */ + log_buffering = slapdFrontendConfig->auditlogbuffering ? PR_TRUE : PR_FALSE; + log_name = "audit fail"; + break; - if (loginfo.log_security_state & LOGGING_NEED_TITLE) { - log_write_title(loginfo.log_security_fdes); - loginfo.log_security_state &= ~LOGGING_NEED_TITLE; - } + case SLAPD_ERROR_LOG: + open_log_file = &log__open_errorlogfile; + fd = loginfo.log_error_fdes; + log_file = loginfo.log_error_file; + rotation_sync_clock = loginfo.log_error_rotationsyncclock; + log_ctime = loginfo.log_error_ctime; + rotationtime_secs = loginfo.log_error_rotationtime_secs; + log_state = loginfo.log_error_state; + log_buffering = slapdFrontendConfig->errorlogbuffering ? PR_TRUE : PR_FALSE; + log_name = "error"; + break; - if (!sync_now && slapdFrontendConfig->securitylogbuffering) { - LOG_WRITE(loginfo.log_security_fdes, lbi->top, lbi->current - lbi->top, 0); - } else { - LOG_WRITE_NOW_NO_ERR(loginfo.log_security_fdes, lbi->top, - lbi->current - lbi->top, 0); - } - lbi->current = lbi->top; - } else if (type == SLAPD_AUDIT_LOG) { - /* It is only safe to flush once any other threads which are copying are finished */ - while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { - /* It's ok to sleep for a while because we only flush every second or so */ - DS_Sleep(PR_MillisecondsToInterval(1)); - } + default: + return; + } - if ((lbi->current - lbi->top) == 0) { + if (log__needrotation(fd, log_type) == LOG_ROTATE) { + if (open_log_file(LOGFILE_NEW, 1) != LOG_SUCCESS) { + slapi_log_err(SLAPI_LOG_ERR, + "log_flush_buffer", "Unable to open %s file: %s\n", + log_name, log_file); + /* reset counter to prevent overwriting rest of lbi struct */ + lbi->current = lbi->top; return; } - - if (log__needrotation(loginfo.log_audit_fdes, SLAPD_AUDIT_LOG) == LOG_ROTATE) { - if (log__open_auditlogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, - "log_flush_buffer", "Unable to open audit file:%s\n", - loginfo.log_audit_file); - lbi->current = lbi->top; /* reset counter to prevent overwriting rest of lbi struct */ - return; - } - while (loginfo.log_audit_rotationsyncclock <= loginfo.log_audit_ctime) { - loginfo.log_audit_rotationsyncclock += PR_ABS(loginfo.log_audit_rotationtime_secs); - } - } - - if (loginfo.log_audit_state & LOGGING_NEED_TITLE) { - log_write_title(loginfo.log_audit_fdes); - loginfo.log_audit_state &= ~LOGGING_NEED_TITLE; - } - - if (!sync_now && slapdFrontendConfig->auditlogbuffering) { - LOG_WRITE(loginfo.log_audit_fdes, lbi->top, lbi->current - lbi->top, 0); - } else { - LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, lbi->top, - lbi->current - lbi->top, 0); - } - lbi->current = lbi->top; - } else if (type == SLAPD_AUDITFAIL_LOG) { - /* It is only safe to flush once any other threads which are copying are finished */ - while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { - /* It's ok to sleep for a while because we only flush every second or so */ - DS_Sleep(PR_MillisecondsToInterval(1)); - } - - if ((lbi->current - lbi->top) == 0) { - return; + while (rotation_sync_clock <= log_ctime) { + rotation_sync_clock = log_update_sync_clock(log_type, + rotationtime_secs); } + log_state = log_refresh_state(log_type); + } - if (log__needrotation(loginfo.log_auditfail_fdes, SLAPD_AUDITFAIL_LOG) == LOG_ROTATE) { - if (log__open_auditfaillogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, - "log_flush_buffer", "Unable to open auditfail file:%s\n", - loginfo.log_audit_file); - lbi->current = lbi->top; /* reset counter to prevent overwriting rest of lbi struct */ - return; - } - while (loginfo.log_auditfail_rotationsyncclock <= loginfo.log_auditfail_ctime) { - loginfo.log_auditfail_rotationsyncclock += PR_ABS(loginfo.log_auditfail_rotationtime_secs); - } - } + if (log_state & LOGGING_NEED_TITLE) { + log_write_title(fd); + log_state_remove_need_title(log_type); + } - if (loginfo.log_auditfail_state & LOGGING_NEED_TITLE) { - log_write_title(loginfo.log_auditfail_fdes); - loginfo.log_auditfail_state &= ~LOGGING_NEED_TITLE; - } + if (!sync_now && log_buffering) { + LOG_WRITE(fd, lbi->top, lbi->current - lbi->top, 0); + } else { + LOG_WRITE_NOW_NO_ERR(fd, lbi->top, lbi->current - lbi->top, 0); + } + lbi->current = lbi->top; - if (!sync_now && slapdFrontendConfig->auditlogbuffering) { - LOG_WRITE(loginfo.log_auditfail_fdes, lbi->top, lbi->current - lbi->top, 0); - } else { - LOG_WRITE_NOW_NO_ERR(loginfo.log_auditfail_fdes, lbi->top, - lbi->current - lbi->top, 0); - } - lbi->current = lbi->top; + /* + * If we fail to write to the error log we must shutdown the server. + * The LOG_WRITE macros set "rc" + */ + if (log_type == SLAPD_ERROR_LOG && rc != 0) { + char buffer[SLAPI_LOG_BUFSIZ]; + PR_snprintf(buffer, sizeof(buffer), + "Writing to the errors log failed. Exiting..."); + log__error_emergency(buffer, 1, locked); + /* failed to write to the errors log. should not continue. */ + g_set_shutdown(SLAPI_SHUTDOWN_EXIT); } } @@ -6783,20 +6890,24 @@ logs_flush() { LOG_ACCESS_LOCK_WRITE(); log_flush_buffer(loginfo.log_access_buffer, SLAPD_ACCESS_LOG, - 1 /* sync to disk now */); + 1 /* sync to disk now */, 1 /* locked*/); LOG_ACCESS_UNLOCK_WRITE(); LOG_SECURITY_LOCK_WRITE(); log_flush_buffer(loginfo.log_security_buffer, SLAPD_SECURITY_LOG, - 1 /* sync to disk now */); + 1 /* sync to disk now */, 1 /* locked*/); LOG_SECURITY_UNLOCK_WRITE(); LOG_AUDIT_LOCK_WRITE(); log_flush_buffer(loginfo.log_audit_buffer, SLAPD_AUDIT_LOG, - 1 /* sync to disk now */); + 1 /* sync to disk now */, 1 /* locked*/); LOG_AUDIT_UNLOCK_WRITE(); LOG_AUDITFAIL_LOCK_WRITE(); log_flush_buffer(loginfo.log_auditfail_buffer, SLAPD_AUDITFAIL_LOG, - 1 /* sync to disk now */); + 1 /* sync to disk now */, 1 /* locked*/); LOG_AUDITFAIL_UNLOCK_WRITE(); + LOG_ERROR_LOCK_WRITE(); + log_flush_buffer(loginfo.log_error_buffer, SLAPD_ERROR_LOG, + 1 /* sync to disk now */, 1 /* locked*/); + LOG_ERROR_UNLOCK_WRITE(); } /* @@ -6942,5 +7053,5 @@ check_log_max_size(char *maxdiskspace_str, /************************************************************************************/ -/* E N D */ +/* E N D */ /************************************************************************************/ diff --git a/ldap/servers/slapd/log.h b/ldap/servers/slapd/log.h index d2e1d65b1..efe8422de 100644 --- a/ldap/servers/slapd/log.h +++ b/ldap/servers/slapd/log.h @@ -183,7 +183,8 @@ struct logging_opts time_t log_error_ctime; /* log creation time */ LogFileInfo *log_error_logchain; /* all the logs info */ char *log_errorinfo_file; /* error log rotation info file */ - Slapi_RWLock *log_error_rwlock; /* lock on error*/ + Slapi_RWLock *log_error_rwlock; /* lock on error */ + LogBufferInfo *log_error_buffer; /* buffer for error log */ /* These are audit log specific */ int log_audit_state; diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index a267637d7..a0346b41e 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -386,6 +386,7 @@ int config_set_validate_cert_switch(const char *attrname, char *value, char *err int config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply); int config_set_auditlogbuffering(const char *attrname, char *value, char *errorbuf, int apply); int config_set_securitylogbuffering(const char *attrname, char *value, char *errorbuf, int apply); +int config_set_errorlogbuffering(const char *attrname, char *value, char *errorbuf, int apply); int config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply); int config_set_force_sasl_external(const char *attrname, char *value, char *errorbuf, int apply); int config_set_entryusn_global(const char *attrname, char *value, char *errorbuf, int apply); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index fc81d08ea..ff2530e57 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -2317,6 +2317,7 @@ typedef struct _slapdEntryPoints #define CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE "nsslapd-accesslog-logbuffering" #define CONFIG_SECURITYLOG_BUFFERING_ATTRIBUTE "nsslapd-securitylog-logbuffering" #define CONFIG_AUDITLOG_BUFFERING_ATTRIBUTE "nsslapd-auditlog-logbuffering" +#define CONFIG_ERRORLOG_BUFFERING_ATTRIBUTE "nsslapd-errorlog-logbuffering" #define CONFIG_CSNLOGGING_ATTRIBUTE "nsslapd-csnlogging" #define CONFIG_RETURN_EXACT_CASE_ATTRIBUTE "nsslapd-return-exact-case" #define CONFIG_RESULT_TWEAK_ATTRIBUTE "nsslapd-result-tweak" @@ -2578,6 +2579,7 @@ typedef struct _slapdFrontendConfig int errorloglevel; slapi_onoff_t external_libs_debug_enabled; slapi_onoff_t errorlog_compress; + slapi_onoff_t errorlogbuffering; /* AUDIT LOG */ char *auditlog; /* replication audit file */
0
2c9fcdd8cb8c12b65ad379517ddbc11525dbdaf3
389ds/389-ds-base
Add the package plugin dir to the DirvSrv object
commit 2c9fcdd8cb8c12b65ad379517ddbc11525dbdaf3 Author: Mark Reynolds <[email protected]> Date: Tue Aug 4 15:45:45 2015 -0400 Add the package plugin dir to the DirvSrv object diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 90785f4b1..e40acddef 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -238,6 +238,12 @@ class DirSrv(SimpleLDAPObject): self.errlog).group(1) if not instdir: instdir = self.confdir + + # parse the lib dir, and so set the plugin dir + self.instdir = instdir + self.libdir = self.instdir.replace('slapd-%s' % self.inst, '') + self.plugindir = self.libdir + 'plugins' + if self.verbose: log.debug("instdir=%r" % instdir) log.debug("Entry: %r" % ent)
0
e7d9bdd341b360048e62c0d01894da0281503488
389ds/389-ds-base
Ticket #281 - TLS not working with latest openldap https://fedorahosted.org/389/ticket/281 Resolves: Ticket #281 Bug Description: TLS not working with latest openldap Reviewed by: nkinder (Thanks!) Branch: master Fix Description: The previous fix did not take into account ssl client auth. The way openldap ssl init works now is that you must set all of the ssl parameters before creating the new ctx. Since slapi_ldap_init_ext() does not know if client auth will be used, we have to do all of the ssl init in slapi_ldap_bind. Doing setup_ol_tls_conn() again will free the old TLS context and parameters. It is a little more time consuming in the clientauth case, but is safer and saves time in the other cases. Platforms tested: RHEL6 x86_64, Fedora 16 Flag Day: no Doc impact: no
commit e7d9bdd341b360048e62c0d01894da0281503488 Author: Rich Megginson <[email protected]> Date: Tue Feb 21 20:21:36 2012 -0700 Ticket #281 - TLS not working with latest openldap https://fedorahosted.org/389/ticket/281 Resolves: Ticket #281 Bug Description: TLS not working with latest openldap Reviewed by: nkinder (Thanks!) Branch: master Fix Description: The previous fix did not take into account ssl client auth. The way openldap ssl init works now is that you must set all of the ssl parameters before creating the new ctx. Since slapi_ldap_init_ext() does not know if client auth will be used, we have to do all of the ssl init in slapi_ldap_bind. Doing setup_ol_tls_conn() again will free the old TLS context and parameters. It is a little more time consuming in the clientauth case, but is safer and saves time in the other cases. Platforms tested: RHEL6 x86_64, Fedora 16 Flag Day: no Doc impact: no diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c index 10d7907b2..545c70364 100644 --- a/ldap/servers/slapd/ldaputil.c +++ b/ldap/servers/slapd/ldaputil.c @@ -557,6 +557,59 @@ slapi_ldif_parse_line( return rc; } +#if defined(USE_OPENLDAP) +static int +setup_ol_tls_conn(LDAP *ld, int clientauth) +{ + char *certdir = config_get_certdir(); + int optval = 0; + int ssl_strength = 0; + int rc = 0; + + if (config_get_ssl_check_hostname()) { + ssl_strength = LDAP_OPT_X_TLS_HARD; + } else { + /* verify certificate only */ + ssl_strength = LDAP_OPT_X_TLS_NEVER; + } + + if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &ssl_strength))) { + slapi_log_error(SLAPI_LOG_FATAL, "setup_ol_tls_conn", + "failed: unable to set REQUIRE_CERT option to %d\n", ssl_strength); + } + /* tell it where our cert db is */ + if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_CACERTDIR, certdir))) { + slapi_log_error(SLAPI_LOG_FATAL, "setup_ol_tls_conn", + "failed: unable to set CACERTDIR option to %s\n", certdir); + } + slapi_ch_free_string(&certdir); +#if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) + optval = LDAP_OPT_X_TLS_PROTOCOL_SSL3; + if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_PROTOCOL_MIN, &optval))) { + slapi_log_error(SLAPI_LOG_FATAL, "setup_ol_tls_conn", + "failed: unable to set minimum TLS protocol level to SSL3\n"); + } +#endif /* LDAP_OPT_X_TLS_PROTOCOL_MIN */ + if (clientauth) { + rc = slapd_SSL_client_auth(ld); + if (rc) { + slapi_log_error(SLAPI_LOG_FATAL, "setup_ol_tls_conn", + "failed: unable to setup connection for TLS/SSL EXTERNAL client cert authentication - %d\n", rc); + } + } + + /* have to do this last - this creates the new TLS handle and sets/copies + all of the parameters set above into that TLS handle context - note + that optval is ignored - what matters is that it is not NULL */ + if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_NEWCTX, &optval))) { + slapi_log_error(SLAPI_LOG_FATAL, "setup_ol_tls_conn", + "failed: unable to create new TLS context\n"); + } + + return rc; +} +#endif /* defined(USE_OPENLDAP) */ + /* Perform LDAP init and return an LDAP* handle. If ldapurl is given, that is used as the basis for the protocol, host, port, and whether @@ -784,9 +837,11 @@ slapi_ldap_init_ext( */ if (secure > 0) { #if defined(USE_OPENLDAP) - char *certdir = config_get_certdir(); - int optval = 0; -#endif /* !USE_OPENLDAP */ + if (setup_ol_tls_conn(ld, 0)) { + slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_init_ext", + "failed: unable to set SSL/TLS options\n"); + } +#else int ssl_strength = 0; LDAP *myld = NULL; @@ -799,43 +854,12 @@ slapi_ldap_init_ext( if (config_get_ssl_check_hostname()) { /* check hostname against name in certificate */ -#if defined(USE_OPENLDAP) - ssl_strength = LDAP_OPT_X_TLS_HARD; -#else /* !USE_OPENLDAP */ ssl_strength = LDAPSSL_AUTH_CNCHECK; -#endif /* !USE_OPENLDAP */ } else { /* verify certificate only */ -#if defined(USE_OPENLDAP) - ssl_strength = LDAP_OPT_X_TLS_NEVER; -#else /* !USE_OPENLDAP */ ssl_strength = LDAPSSL_AUTH_CERT; -#endif /* !USE_OPENLDAP */ } -#if defined(USE_OPENLDAP) - if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &ssl_strength))) { - slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_init_ext", - "failed: unable to set REQUIRE_CERT option to %d\n", ssl_strength); - } - /* tell it where our cert db is */ - if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_CACERTDIR, certdir))) { - slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_init_ext", - "failed: unable to set CACERTDIR option to %s\n", certdir); - } - slapi_ch_free_string(&certdir); -#if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) - optval = LDAP_OPT_X_TLS_PROTOCOL_SSL3; - if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_PROTOCOL_MIN, &optval))) { - slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_init_ext", - "failed: unable to set minimum TLS protocol level to SSL3\n"); - } -#endif /* LDAP_OPT_X_TLS_PROTOCOL_MIN */ - if ((rc = ldap_set_option(ld, LDAP_OPT_X_TLS_NEWCTX, &optval))) { - slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_init_ext", - "failed: unable to create new TLS context\n"); - } -#else /* !USE_OPENLDAP */ if ((rc = ldapssl_set_strength(myld, ssl_strength)) || (rc = ldapssl_set_option(myld, SSL_ENABLE_SSL2, PR_FALSE)) || (rc = ldapssl_set_option(myld, SSL_ENABLE_SSL3, PR_TRUE)) || @@ -960,10 +984,15 @@ slapi_ldap_bind( ldap_set_option(ld, LDAP_OPT_CLIENT_CONTROLS, NULL); if ((secure > 0) && mech && !strcmp(mech, LDAP_SASL_EXTERNAL)) { +#if defined(USE_OPENLDAP) + /* we already set up a tls context in slapi_ldap_init_ext() - this will + free those old settings and context and create a new one */ + rc = setup_ol_tls_conn(ld, 1); +#else /* SSL connections will use the server's security context and cert for client auth */ rc = slapd_SSL_client_auth(ld); - +#endif if (rc != 0) { slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_bind", "Error: could not configure the server for cert " @@ -973,7 +1002,7 @@ slapi_ldap_bind( } else { slapi_log_error(SLAPI_LOG_SHELL, "slapi_ldap_bind", "Set up conn to use client auth\n"); - } + } bvcreds.bv_val = NULL; /* ignore username and passed in creds */ bvcreds.bv_len = 0; /* for external auth */ bindid = NULL;
0
77227f11981047ec10c6f59e08a0089dddd6f9e6
389ds/389-ds-base
[158263] Performance Counter, labels removed. Need to update online help to match
commit 77227f11981047ec10c6f59e08a0089dddd6f9e6 Author: Noriko Hosoi <[email protected]> Date: Fri May 20 17:48:36 2005 +0000 [158263] Performance Counter, labels removed. Need to update online help to match diff --git a/ldap/docs/dirhlp/help/statustab_performance.htm b/ldap/docs/dirhlp/help/statustab_performance.htm index 725760fb7..dedf12f17 100644 --- a/ldap/docs/dirhlp/help/statustab_performance.htm +++ b/ldap/docs/dirhlp/help/statustab_performance.htm @@ -103,40 +103,6 @@ Use this tab to monitor your server's current activities. If the server is not r <b>Server version. </b>Identifies the current server version. </p> <p class="text"> -<a name="28909"> </a> -<b>Configuration DN. </b>Identifies the distinguished name you can use to obtain these results using the <code>ldapsearch</code> command-line utility. -</p> -<p class="text"> -<a name="28910"> </a> -<b>Data version. </b>Provides identification information for the server's data area. The information here is relevant if your server supplies replicated data to consumer servers. The information supplied is: -</p> -<ul> - -<li> -Server host name, -<a name="28911"> </a> -<img src="/manual/en/slapd/help/pixel.gif" align="top" height="22" alt="" /> -</li> - -<li> -Server port number, -<a name="28912"> </a> -<img src="/manual/en/slapd/help/pixel.gif" align="top" height="22" alt="" /> -</li> - -<li> -Database generation number, and -<a name="28913"> </a> -<img src="/manual/en/slapd/help/pixel.gif" align="top" height="22" alt="" /> -</li> - -<li> -Current change log number. -<a name="28914"> </a> -<img src="/manual/en/slapd/help/pixel.gif" align="top" height="22" alt="" /> -</li> -</ul> -<p class="text"> <a name="28915"> </a> <b>Startup time on server. </b>Date and time the server started. </p>
0
a6f66e7fcbd5d17d975cc2ac65806d7c64571254
389ds/389-ds-base
Ticket #47659 - ldbm_usn_init: Valgrind reports Invalid read / SIGSEGV Bug description: A suffix mapping tree could exist without the corresponding backend. The existing code did not properly check the backend returned from slapi_mapping_tree_find_backend_for_sdn. When NULL backend is returned, it triggers the NULL pointer dereference. Fix description: This patch added a NULL backend check to usn_get_last_usn, and moved a logging to the if clause where the backend is not NULL. https://fedorahosted.org/389/ticket/47659 Reviewed by [email protected] (Thank you, Rich!!)
commit a6f66e7fcbd5d17d975cc2ac65806d7c64571254 Author: Noriko Hosoi <[email protected]> Date: Mon Jan 27 15:15:01 2014 -0800 Ticket #47659 - ldbm_usn_init: Valgrind reports Invalid read / SIGSEGV Bug description: A suffix mapping tree could exist without the corresponding backend. The existing code did not properly check the backend returned from slapi_mapping_tree_find_backend_for_sdn. When NULL backend is returned, it triggers the NULL pointer dereference. Fix description: This patch added a NULL backend check to usn_get_last_usn, and moved a logging to the if clause where the backend is not NULL. https://fedorahosted.org/389/ticket/47659 Reviewed by [email protected] (Thank you, Rich!!) diff --git a/ldap/servers/slapd/back-ldbm/ldbm_usn.c b/ldap/servers/slapd/back-ldbm/ldbm_usn.c index 7c11a68bc..1ca16b170 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_usn.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_usn.c @@ -80,10 +80,11 @@ ldbm_usn_init(struct ldbminfo *li) for ( sdn = slapi_get_first_suffix( &node, 0 ); sdn != NULL; sdn = slapi_get_next_suffix_ext( &node, 0 )) { be = slapi_mapping_tree_find_backend_for_sdn(sdn); - slapi_log_error(SLAPI_LOG_BACKLDBM, "ldbm_usn_init", - "backend: %s%s\n", be->be_name, isglobal?" (global mode)":""); rc = usn_get_last_usn(be, &last_usn); if (0 == rc) { /* only when the last usn is available */ + slapi_log_error(SLAPI_LOG_BACKLDBM, "ldbm_usn_init", + "backend: %s%s\n", be->be_name, + isglobal?" (global mode)":""); if (isglobal) { if (isfirst) { li->li_global_usn_counter = slapi_counter_new(); @@ -126,7 +127,7 @@ usn_get_last_usn(Slapi_Backend *be, PRUint64 *last_usn) DBT value; PRInt64 signed_last_usn; - if (NULL == last_usn) { + if ((NULL == be) || (NULL == last_usn)) { return rc; }
0
5a3a6e50b2ca825711707475434cf0b5f8a5ea56
389ds/389-ds-base
Ticket 4224 - openldap can become confused with entryuuid Bug Description: OpenLDAP server as a syncrepl consumed enforces the condition that syncUUID in ldap messages must match the entryuuid of the entry. This is not in the RFC but it affects this one situation. Fix Description: To resolve this, we enforce that entryuuid is a requirement to the openldap syncrepl mode. Only entries with an entryuuid can be sent to openldap. Additionally, this mode is disabled by default by a configuration parameter "syncrepl-allow-openldap" in the content sync plugin config. Fixes: https://github.com/389ds/389-ds-base/issues/4224 Author: William Brown <[email protected]> Review by: @tbordaz (Thanks!)
commit 5a3a6e50b2ca825711707475434cf0b5f8a5ea56 Author: William Brown <[email protected]> Date: Wed Sep 16 14:29:19 2020 +1000 Ticket 4224 - openldap can become confused with entryuuid Bug Description: OpenLDAP server as a syncrepl consumed enforces the condition that syncUUID in ldap messages must match the entryuuid of the entry. This is not in the RFC but it affects this one situation. Fix Description: To resolve this, we enforce that entryuuid is a requirement to the openldap syncrepl mode. Only entries with an entryuuid can be sent to openldap. Additionally, this mode is disabled by default by a configuration parameter "syncrepl-allow-openldap" in the content sync plugin config. Fixes: https://github.com/389ds/389-ds-base/issues/4224 Author: William Brown <[email protected]> Review by: @tbordaz (Thanks!) diff --git a/dirsrvtests/tests/suites/syncrepl_plugin/__init__.py b/dirsrvtests/tests/suites/syncrepl_plugin/__init__.py index 8baa7355d..112b4f485 100644 --- a/dirsrvtests/tests/suites/syncrepl_plugin/__init__.py +++ b/dirsrvtests/tests/suites/syncrepl_plugin/__init__.py @@ -144,7 +144,7 @@ def syncstate_assert(st, sync): # Find the primary uuid we expect to see in syncrepl. # This will be None if not present. acc_uuid = account.get_attr_val_utf8('entryuuid') - if acc_uuid is None: + if not sync.openldap: nsid = account.get_attr_val_utf8('nsuniqueid') # nsunique has a diff format, so we change it up. # 431cf081-b44311ea-83fdb082-f24d490e @@ -173,7 +173,7 @@ def syncstate_assert(st, sync): assert 1 == len(sync.entries.keys()) assert 1 == len(sync.present) #################################### - ## assert sync.present == [acc_uuid] + assert sync.present == [acc_uuid] assert 0 == len(sync.delete) if sync.openldap: assert True == sync.refdel @@ -191,7 +191,7 @@ def syncstate_assert(st, sync): assert 1 == len(sync.entries.keys()) assert 1 == len(sync.present) #################################### - ## assert sync.present == [acc_uuid] + assert sync.present == [acc_uuid] assert 0 == len(sync.delete) if sync.openldap: assert True == sync.refdel @@ -210,13 +210,17 @@ def syncstate_assert(st, sync): assert 1 == len(sync.entries.keys()) assert 1 == len(sync.present) #################################### - ## assert sync.present == [acc_uuid] + assert sync.present == [acc_uuid] assert 0 == len(sync.delete) if sync.openldap: assert True == sync.refdel else: assert False == sync.refdel + # import time + # print("attach now ....") + # time.sleep(45) + ## Modrdn (out of scope, then back into scope) account.rename('uid=test1_modrdn', newsuperior=DEFAULT_SUFFIX) @@ -228,11 +232,14 @@ def syncstate_assert(st, sync): log.debug(f"sd: {sync.delete}, sp: {sync.present} sek: {sync.entries.keys()}") assert 0 == len(sync.entries.keys()) assert 0 == len(sync.present) - assert 0 == len(sync.delete) + ## WARNING: This test MAY FAIL here if you do not have a new enough python-ldap + # due to an ASN.1 parsing bug. You require at least python-ldap 3.3.1 + assert 1 == len(sync.delete) + assert sync.delete == [acc_uuid] if sync.openldap: assert True == sync.refdel else: - assert True == sync.refdel + assert False == sync.refdel # Put it back account.rename('uid=test1_modrdn', newsuperior=OU_PEOPLE) @@ -244,7 +251,7 @@ def syncstate_assert(st, sync): assert 1 == len(sync.entries.keys()) assert 1 == len(sync.present) #################################### - ## assert sync.present == [acc_uuid] + assert sync.present == [acc_uuid] assert 0 == len(sync.delete) if sync.openldap: assert True == sync.refdel @@ -254,10 +261,6 @@ def syncstate_assert(st, sync): ## Delete account.delete() - # import time - # print("attach now ....") - # time.sleep(45) - # Check log.debug("*test* del") sync.syncrepl_search(base=OU_PEOPLE) @@ -270,11 +273,11 @@ def syncstate_assert(st, sync): log.debug(f"sd: {sync.delete}, sp: {sync.present} sek: {sync.entries.keys()}") assert 0 == len(sync.entries.keys()) assert 0 == len(sync.present) - assert 0 == len(sync.delete) + assert 1 == len(sync.delete) + assert sync.delete == [acc_uuid] #################################### - ## assert sync.delete == [acc_uuid] if sync.openldap: assert True == sync.refdel else: - assert True == sync.refdel + assert False == sync.refdel diff --git a/dirsrvtests/tests/suites/syncrepl_plugin/openldap_test.py b/dirsrvtests/tests/suites/syncrepl_plugin/openldap_test.py index bc4ecb145..2a9e1e7fe 100644 --- a/dirsrvtests/tests/suites/syncrepl_plugin/openldap_test.py +++ b/dirsrvtests/tests/suites/syncrepl_plugin/openldap_test.py @@ -17,6 +17,7 @@ from lib389.paths import Paths from lib389.utils import ds_is_older from lib389.plugins import RetroChangelogPlugin, ContentSyncPlugin from lib389._constants import * +from lib389.plugins import EntryUUIDPlugin from . import ISyncRepl, syncstate_assert @@ -25,7 +26,8 @@ pytestmark = pytest.mark.tier1 log = logging.getLogger(__name__) [email protected](ds_is_older('1.4.4.0'), reason="Sync repl does not support openldap compat in older versions") [email protected](ldap.__version__ < '3.3.1' or not default_paths.rust_enabled or ds_is_older('1.4.4.0'), + reason="Sync repl does not support openldap compat in older versions, and without entryuuid") def test_syncrepl_openldap(topology): """ Test basic functionality of the openldap syncrepl compatability handler. @@ -45,18 +47,25 @@ def test_syncrepl_openldap(topology): 1. Success """ st = topology.standalone + # Ensure entryuuid is setup + plug = EntryUUIDPlugin(st) + task = plug.fixup(DEFAULT_SUFFIX) + task.wait() + st.config.loglevel(vals=(ErrorLog.DEFAULT,ErrorLog.PLUGIN)) + assert(task.is_complete() and task.get_exit_code() == 0) + # Enable RetroChangelog. rcl = RetroChangelogPlugin(st) rcl.enable() # Set the default targetid - rcl.replace('nsslapd-attribute', 'nsuniqueid:targetUniqueId') + rcl.add('nsslapd-attribute', 'nsuniqueid:targetUniqueId') + rcl.add('nsslapd-attribute', 'entryuuid:targetEntryUUID') # Enable sync repl csp = ContentSyncPlugin(st) + csp.add('syncrepl-allow-openldap', 'on') csp.enable() # Restart DS st.restart() - # log.error("+++++++++++") - # time.sleep(60) # Setup the syncer sync = ISyncRepl(st, openldap=True) # Run the checks diff --git a/ldap/servers/plugins/sync/sync.h b/ldap/servers/plugins/sync/sync.h index 9aa113553..5e93c276d 100644 --- a/ldap/servers/plugins/sync/sync.h +++ b/ldap/servers/plugins/sync/sync.h @@ -16,7 +16,6 @@ #include <stdio.h> #include <string.h> -#include <stdbool.h> #include "slap.h" #include "slapi-plugin.h" #include "slapi-private.h" @@ -30,6 +29,8 @@ #define SYNC_BETXN_PREOP_DESC "content-sync-betxn-preop-subplugin" #define SYNC_BE_POSTOP_DESC "content-sync-be-post-subplugin" +#define SYNC_ALLOW_OPENLDAP_COMPAT "syncrepl-allow-openldap" + #define OP_FLAG_SYNC_PERSIST 0x01 #define E_SYNC_REFRESH_REQUIRED 0x1000 @@ -37,6 +38,7 @@ #define CL_ATTR_CHANGENUMBER "changenumber" #define CL_ATTR_ENTRYDN "targetDn" #define CL_ATTR_UNIQUEID "targetUniqueId" +#define CL_ATTR_ENTRYUUID "targetEntryUUID" #define CL_ATTR_CHGTYPE "changetype" #define CL_ATTR_NEWSUPERIOR "newsuperior" #define CL_SRCH_BASE "cn=changelog" @@ -48,12 +50,13 @@ typedef struct sync_cookie char *cookie_client_signature; char *cookie_server_signature; unsigned long cookie_change_info; - bool openldap_compat; + PRBool openldap_compat; } Sync_Cookie; typedef struct sync_update { char *upd_uuid; + char *upd_euuid; int upd_chgtype; Slapi_Entry *upd_e; } Sync_UpdateNode; @@ -67,6 +70,7 @@ typedef struct sync_callback unsigned long change_start; int cb_err; Sync_UpdateNode *cb_updates; + PRBool openldap_compat; } Sync_CallBackData; /* Pending list flags @@ -101,6 +105,7 @@ typedef struct OPERATION_PL_CTX OPERATION_PL_CTX_T * get_thread_primary_op(void); void set_thread_primary_op(OPERATION_PL_CTX_T *op); +void sync_register_allow_openldap_compat(PRBool allow); int sync_register_operation_extension(void); int sync_unregister_operation_entension(void); @@ -115,7 +120,7 @@ int sync_add_persist_post_op(Slapi_PBlock *pb); int sync_update_persist_betxn_pre_op(Slapi_PBlock *pb); int sync_parse_control_value(struct berval *psbvp, ber_int_t *mode, int *reload, char **cookie); -int sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Cookie *cookie); +int sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Cookie *cookie, PRBool openldap_compat); int sync_create_sync_done_control(LDAPControl **ctrlp, int refresh, char *cookie); int sync_intermediate_msg(Slapi_PBlock *pb, int tag, Sync_Cookie *cookie, char **uuids); int sync_result_msg(Slapi_PBlock *pb, Sync_Cookie *cookie); @@ -123,13 +128,14 @@ int sync_result_err(Slapi_PBlock *pb, int rc, char *msg); Sync_Cookie *sync_cookie_create(Slapi_PBlock *pb, Sync_Cookie *client_cookie); void sync_cookie_update(Sync_Cookie *cookie, Slapi_Entry *ec); -Sync_Cookie *sync_cookie_parse(char *cookie, bool *cookie_refresh); +Sync_Cookie *sync_cookie_parse(char *cookie, PRBool *cookie_refresh, PRBool *allow_openldap_compat); int sync_cookie_isvalid(Sync_Cookie *testcookie, Sync_Cookie *refcookie); void sync_cookie_free(Sync_Cookie **freecookie); char *sync_cookie2str(Sync_Cookie *cookie); int sync_number2int(char *nrstr); unsigned long sync_number2ulong(char *nrstr); char *sync_nsuniqueid2uuid(const char *nsuniqueid); +char *sync_entryuuid2uuid(const char *nsuniqueid); int sync_is_active(Slapi_Entry *e, Slapi_PBlock *pb); int sync_is_active_scope(const Slapi_DN *dn, Slapi_PBlock *pb); @@ -137,9 +143,9 @@ int sync_is_active_scope(const Slapi_DN *dn, Slapi_PBlock *pb); int sync_refresh_update_content(Slapi_PBlock *pb, Sync_Cookie *client_cookie, Sync_Cookie *session_cookie); int sync_refresh_initial_content(Slapi_PBlock *pb, int persist, PRThread *tid, Sync_Cookie *session_cookie); int sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data); -int sync_send_entry_from_changelog(Slapi_PBlock *pb, int chg_req, char *uniqueid); +int sync_send_entry_from_changelog(Slapi_PBlock *pb, int chg_req, char *uniqueid, Sync_Cookie *session_cookie); void sync_send_deleted_entries(Slapi_PBlock *pb, Sync_UpdateNode *upd, int chg_count, Sync_Cookie *session_cookie); -void sync_send_modified_entries(Slapi_PBlock *pb, Sync_UpdateNode *upd, int chg_count); +void sync_send_modified_entries(Slapi_PBlock *pb, Sync_UpdateNode *upd, int chg_count, Sync_Cookie *session_cookie); int sync_persist_initialize(int argc, char **argv); PRThread *sync_persist_add(Slapi_PBlock *pb); diff --git a/ldap/servers/plugins/sync/sync_init.c b/ldap/servers/plugins/sync/sync_init.c index 74af14512..621147c59 100644 --- a/ldap/servers/plugins/sync/sync_init.c +++ b/ldap/servers/plugins/sync/sync_init.c @@ -25,7 +25,7 @@ sync_init(Slapi_PBlock *pb) char *plugin_identity = NULL; int rc = 0; - slapi_log_err(SLAPI_LOG_TRACE, SYNC_PLUGIN_SUBSYSTEM, + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "--> sync_init\n"); /** @@ -168,12 +168,36 @@ sync_start(Slapi_PBlock *pb) { int argc; char **argv; + Slapi_Entry *e = NULL; + PRBool allow_openldap_compat = PR_FALSE; slapi_register_supported_control(LDAP_CONTROL_SYNC, SLAPI_OPERATION_SEARCH); - slapi_log_err(SLAPI_LOG_TRACE, SYNC_PLUGIN_SUBSYSTEM, + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "--> sync_start\n"); + if (slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e) != 0) { + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, " sync_start, no config found, that's okay 👍\n"); + } + + if (e) { + /* Do we allow openldap sync? */ + Slapi_Attr *chattr = NULL; + if (slapi_entry_attr_find(e, SYNC_ALLOW_OPENLDAP_COMPAT, &chattr) == 0) { + Slapi_Value *sval = NULL; + slapi_attr_first_value(chattr, &sval); + + const struct berval *value = slapi_value_get_berval(sval); + if (NULL != value && NULL != value->bv_val && '\0' != value->bv_val[0]) { + if (strcasecmp(value->bv_val, "on") == 0) { + allow_openldap_compat = PR_TRUE; + } + } + } + } + + sync_register_allow_openldap_compat(allow_openldap_compat); + if (slapi_pblock_get(pb, SLAPI_PLUGIN_ARGC, &argc) != 0 || slapi_pblock_get(pb, SLAPI_PLUGIN_ARGV, &argv) != 0) { slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, @@ -242,4 +266,4 @@ set_thread_primary_op(OPERATION_PL_CTX_T *op) PR_SetThreadPrivate(thread_primary_op, (void *) head); } head->next = op; -} \ No newline at end of file +} diff --git a/ldap/servers/plugins/sync/sync_persist.c b/ldap/servers/plugins/sync/sync_persist.c index 40d7521cd..d83df7625 100644 --- a/ldap/servers/plugins/sync/sync_persist.c +++ b/ldap/servers/plugins/sync/sync_persist.c @@ -436,11 +436,11 @@ sync_queue_change(OPERATION_PL_CTX_T *operation) } /* Were there any matches? */ if (matched) { - slapi_log_err(SLAPI_LOG_TRACE, SYNC_PLUGIN_SUBSYSTEM, "sync_queue_change - enqueued entry " + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_queue_change - enqueued entry " "\"%s\" on %d request listeners\n", slapi_entry_get_dn_const(e), matched); } else { - slapi_log_err(SLAPI_LOG_TRACE, SYNC_PLUGIN_SUBSYSTEM, "sync_queue_change - entry " + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_queue_change - entry " "\"%s\" not enqueued on any request search listeners\n", slapi_entry_get_dn_const(e)); } @@ -919,9 +919,10 @@ sync_send_results(void *arg) break; } ectrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *)); - if (req->req_cookie) + if (req->req_cookie) { sync_cookie_update(req->req_cookie, ec); - sync_create_state_control(ec, &ectrls[0], chg_type, req->req_cookie); + } + sync_create_state_control(ec, &ectrls[0], chg_type, req->req_cookie, PR_FALSE); rc = slapi_send_ldap_search_entry(req->req_pblock, ec, ectrls, noattrs ? noattrs : attrs, attrsonly); diff --git a/ldap/servers/plugins/sync/sync_refresh.c b/ldap/servers/plugins/sync/sync_refresh.c index 28963cc02..248514496 100644 --- a/ldap/servers/plugins/sync/sync_refresh.c +++ b/ldap/servers/plugins/sync/sync_refresh.c @@ -12,6 +12,7 @@ static SyncOpInfo *new_SyncOpInfo(int flag, PRThread *tid, Sync_Cookie *cookie); static int sync_extension_type; static int sync_extension_handle; +static PRBool allow_openldap_compat; static SyncOpInfo *sync_get_operation_extension(Slapi_PBlock *pb); static void sync_set_operation_extension(Slapi_PBlock *pb, SyncOpInfo *spec); @@ -68,7 +69,7 @@ sync_srch_refresh_pre_search(Slapi_PBlock *pb) char *cookie = NULL; int32_t mode = 1; int32_t refresh = 0; - bool cookie_refresh = 0; + PRBool cookie_refresh = PR_FALSE; if (sync_parse_control_value(psbvp, &mode, &refresh, &cookie) != LDAP_SUCCESS) { @@ -89,7 +90,7 @@ sync_srch_refresh_pre_search(Slapi_PBlock *pb) * when using their changelog mode. As a result, we parse the cookie to handle this * shenangians to determine if this is valid. */ - client_cookie = sync_cookie_parse(cookie, &cookie_refresh); + client_cookie = sync_cookie_parse(cookie, &cookie_refresh, &allow_openldap_compat); /* * we need to return a cookie in the result message * indicating a state to be used in future sessions @@ -105,6 +106,13 @@ sync_srch_refresh_pre_search(Slapi_PBlock *pb) * to catch the mods while the refresh is done */ if (mode == 3) { + if (client_cookie && client_cookie->openldap_compat == PR_TRUE) { + /* We don't allow this. */ + rc = LDAP_UNWILLING_TO_PERFORM; + sync_result_err(pb, rc, "Invalid session state, openldap compat not supported with persistence"); + goto error_return; + } + /* Launch the thread. */ tid = sync_persist_add(pb); if (tid) sync_persist = 1; @@ -258,9 +266,13 @@ sync_srch_refresh_pre_entry(Slapi_PBlock *pb) rc = 0; /* nothing to do */ } else if (info->send_flag & SYNC_FLAG_ADD_STATE_CTRL) { Slapi_Entry *e; + PRBool openldap_compat = PR_FALSE; + if (info->cookie) { + openldap_compat = info->cookie->openldap_compat; + } slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY, &e); LDAPControl **ctrl = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *)); - sync_create_state_control(e, &ctrl[0], LDAP_SYNC_ADD, NULL); + rc = sync_create_state_control(e, &ctrl[0], LDAP_SYNC_ADD, NULL, openldap_compat); slapi_pblock_set(pb, SLAPI_SEARCH_CTRLS, ctrl); } return (rc); @@ -287,10 +299,12 @@ sync_free_update_nodes(Sync_UpdateNode **updates, int count) int i; for (i = 0; i < count; i++) { - if ((*updates)[i].upd_uuid) - slapi_ch_free((void **)&((*updates)[i].upd_uuid)); - if ((*updates)[i].upd_e) + /* ch free checks for null for us. */ + slapi_ch_free((void **)&((*updates)[i].upd_uuid)); + slapi_ch_free((void **)&((*updates)[i].upd_euuid)); + if ((*updates)[i].upd_e) { slapi_entry_free((*updates)[i].upd_e); + } } slapi_ch_free((void **)updates); } @@ -324,6 +338,7 @@ sync_refresh_update_content(Slapi_PBlock *pb, Sync_Cookie *client_cookie, Sync_C cb_data.orig_pb = pb; cb_data.change_start = client_cookie->cookie_change_info; + cb_data.openldap_compat = server_cookie->openldap_compat; /* * The client has already seen up to AND including change_info, so this should @@ -342,9 +357,16 @@ sync_refresh_update_content(Slapi_PBlock *pb, Sync_Cookie *client_cookie, Sync_C * for me in the tests, but the sync repl tests now correctly work and reflect the behaviour * expected. */ - filter = slapi_ch_smprintf("(&(changenumber>=%lu)(changenumber<=%lu))", - client_cookie->cookie_change_info + 1, - server_cookie->cookie_change_info); + if (server_cookie->openldap_compat) { + /* In openldap compat we only want items that have an entryuuid, else we can't sync them */ + filter = slapi_ch_smprintf("(&(changenumber>=%lu)(changenumber<=%lu)(" CL_ATTR_ENTRYUUID "=*))", + client_cookie->cookie_change_info + 1, + server_cookie->cookie_change_info); + } else { + filter = slapi_ch_smprintf("(&(changenumber>=%lu)(changenumber<=%lu))", + client_cookie->cookie_change_info + 1, + server_cookie->cookie_change_info); + } slapi_search_internal_set_pb( seq_pb, CL_SRCH_BASE, @@ -364,7 +386,7 @@ sync_refresh_update_content(Slapi_PBlock *pb, Sync_Cookie *client_cookie, Sync_C * and the modified entries as single entries */ sync_send_deleted_entries(pb, cb_data.cb_updates, chg_count, server_cookie); - sync_send_modified_entries(pb, cb_data.cb_updates, chg_count); + sync_send_modified_entries(pb, cb_data.cb_updates, chg_count, server_cookie); sync_free_update_nodes(&cb_data.cb_updates, chg_count); slapi_ch_free((void **)&filter); @@ -388,6 +410,28 @@ sync_refresh_initial_content(Slapi_PBlock *pb, int sync_persist, PRThread *tid, */ SyncOpInfo *info; + if (sc->openldap_compat == PR_TRUE) { + /* + * If this is true we need to adjust the filter to + * include a wrapping entryuuid condition. This is + * because openldap demands entryuuid == syncuuid so + * we must only send entries with an entryuuid. + */ + struct slapi_filter *filter = NULL; + slapi_pblock_get(pb, SLAPI_SEARCH_FILTER, (void *)&filter); + PR_ASSERT(filter); + /* We need to alloc this due to how str2filter manips the str. If it's + * static we cause a segfault because it's in a protected section. + */ + char *buf = slapi_ch_strdup("(entryUUID=*)"); + struct slapi_filter *euuid_filter = slapi_str2filter(buf); + PR_ASSERT(euuid_filter); + struct slapi_filter *wrapped_filter = slapi_filter_join(LDAP_FILTER_AND, filter, euuid_filter); + PR_ASSERT(wrapped_filter); + slapi_pblock_set(pb, SLAPI_SEARCH_FILTER, (void *)wrapped_filter); + slapi_ch_free_string(&buf); + } + if (sync_persist) { info = new_SyncOpInfo(SYNC_FLAG_ADD_STATE_CTRL | SYNC_FLAG_SEND_INTERMEDIATE | @@ -502,6 +546,7 @@ int sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data) { char *uniqueid = NULL; + char *entryuuid = NULL; char *chgtype = NULL; char *chgnr = NULL; int chg_req; @@ -518,9 +563,21 @@ sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data) if (uniqueid == NULL) { slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - Retro Changelog does not provide nsuniquedid." - "Check RCL plugin configuration.\n"); + "Check 'cn=Retro Changelog Plugin,cn=plugins,cn=config' contains 'nsslapd-attribute: nsuniqueid:targetUniqueId'\n"); return (1); } + + /* If we were requested to do openldap mode, get the targetEntryUuid too */ + if (cb->openldap_compat == PR_TRUE) { + entryuuid = sync_get_attr_value_from_entry(cl_entry, CL_ATTR_ENTRYUUID); + if (entryuuid == NULL) { + slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, + "sync_read_entry_from_changelog - Retro Changelog does not provide entryuuid." + "Check 'cn=Retro Changelog Plugin,cn=plugins,cn=config' contains 'nsslapd-attribute: entryuuid:targetEntryUUID'\n"); + return (1); + } + } + chgnr = sync_get_attr_value_from_entry(cl_entry, CL_ATTR_CHANGENUMBER); chgnum = sync_number2ulong(chgnr); if (SYNC_INVALID_CHANGENUM == chgnum) { @@ -528,6 +585,7 @@ sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data) "sync_read_entry_from_changelog - Change number provided by Retro Changelog is invalid: %s\n", chgnr); slapi_ch_free_string(&chgnr); slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); return (1); } if (chgnum < cb->change_start) { @@ -537,6 +595,7 @@ sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data) chgnr, cb->change_start); slapi_ch_free_string(&chgnr); slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); return (1); } index = chgnum - cb->change_start; @@ -544,21 +603,28 @@ sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data) chg_req = sync_str2chgreq(chgtype); switch (chg_req) { case LDAP_REQ_ADD: + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_ADD\n", uniqueid); /* nsuniqueid cannot exist, just add reference */ cb->cb_updates[index].upd_chgtype = LDAP_REQ_ADD; cb->cb_updates[index].upd_uuid = uniqueid; + cb->cb_updates[index].upd_euuid = entryuuid; break; case LDAP_REQ_MODIFY: /* check if we have seen this uuid already */ prev = sync_find_ref_by_uuid(cb->cb_updates, index, uniqueid); if (prev == -1) { + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_MODIFY\n", uniqueid); cb->cb_updates[index].upd_chgtype = LDAP_REQ_MODIFY; cb->cb_updates[index].upd_uuid = uniqueid; + cb->cb_updates[index].upd_euuid = entryuuid; } else { /* was add or mod, keep it */ - cb->cb_updates[index].upd_uuid = 0; + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_MODIFY (already queued)\n", uniqueid); + cb->cb_updates[index].upd_uuid = NULL; + cb->cb_updates[index].upd_euuid = NULL; cb->cb_updates[index].upd_chgtype = 0; slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); } break; case LDAP_REQ_MODRDN: { @@ -592,31 +658,43 @@ sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data) if (old_scope && new_scope) { /* nothing changed, it's just a MOD */ if (prev == -1) { + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_MODRDN\n", uniqueid); cb->cb_updates[index].upd_chgtype = LDAP_REQ_MODIFY; cb->cb_updates[index].upd_uuid = uniqueid; + cb->cb_updates[index].upd_euuid = entryuuid; } else { - cb->cb_updates[index].upd_uuid = 0; + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_MODRDN (already queued)\n", uniqueid); + cb->cb_updates[index].upd_uuid = NULL; + cb->cb_updates[index].upd_euuid = NULL; cb->cb_updates[index].upd_chgtype = 0; slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); } } else if (old_scope) { /* it was moved out of scope, handle as DEL */ if (prev == -1) { + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_MODRDN -> LDAP_REQ_DELETE\n", uniqueid); cb->cb_updates[index].upd_chgtype = LDAP_REQ_DELETE; cb->cb_updates[index].upd_uuid = uniqueid; + cb->cb_updates[index].upd_euuid = entryuuid; cb->cb_updates[index].upd_e = sync_deleted_entry_from_changelog(cl_entry); } else { + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_MODRDN -> LDAP_REQ_DELETE (already queued)\n", uniqueid); cb->cb_updates[prev].upd_chgtype = LDAP_REQ_DELETE; cb->cb_updates[prev].upd_e = sync_deleted_entry_from_changelog(cl_entry); slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); } } else if (new_scope) { /* moved into scope, handle as ADD */ + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_MODRDN -> LDAP_REQ_ADD\n", uniqueid); cb->cb_updates[index].upd_chgtype = LDAP_REQ_ADD; cb->cb_updates[index].upd_uuid = uniqueid; + cb->cb_updates[index].upd_euuid = entryuuid; } else { /* nothing to do */ slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); } slapi_sdn_free(&original_dn); break; @@ -625,27 +703,36 @@ sync_read_entry_from_changelog(Slapi_Entry *cl_entry, void *cb_data) /* check if we have seen this uuid already */ prev = sync_find_ref_by_uuid(cb->cb_updates, index, uniqueid); if (prev == -1) { + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_DELETE\n", uniqueid); cb->cb_updates[index].upd_chgtype = LDAP_REQ_DELETE; cb->cb_updates[index].upd_uuid = uniqueid; + cb->cb_updates[index].upd_euuid = entryuuid; cb->cb_updates[index].upd_e = sync_deleted_entry_from_changelog(cl_entry); } else { /* if it was added since last cookie state, we - * can ignoere it */ + * can ignore it */ if (cb->cb_updates[prev].upd_chgtype == LDAP_REQ_ADD) { + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_DELETE -> NO-OP\n", uniqueid); slapi_ch_free_string(&(cb->cb_updates[prev].upd_uuid)); cb->cb_updates[prev].upd_uuid = NULL; + cb->cb_updates[prev].upd_euuid = NULL; cb->cb_updates[index].upd_uuid = NULL; + cb->cb_updates[index].upd_euuid = NULL; } else { /* ignore previous mod */ + slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "sync_read_entry_from_changelog - %s LDAP_REQ_DELETE (already queued, updating)\n", uniqueid); cb->cb_updates[index].upd_uuid = NULL; + cb->cb_updates[index].upd_euuid = NULL; cb->cb_updates[prev].upd_chgtype = LDAP_REQ_DELETE; cb->cb_updates[prev].upd_e = sync_deleted_entry_from_changelog(cl_entry); } slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); } break; default: slapi_ch_free_string(&uniqueid); + slapi_ch_free_string(&entryuuid); } slapi_ch_free_string(&chgtype); slapi_ch_free_string(&chgnr); @@ -660,12 +747,19 @@ sync_send_deleted_entries(Slapi_PBlock *pb, Sync_UpdateNode *upd, int chg_count, char *syncUUIDs[SYNC_MAX_DELETED_UUID_BATCH + 1] = {0}; size_t uuid_index = 0; + PR_ASSERT(cookie); + syncUUIDs[0] = NULL; for (size_t index = 0; index < chg_count; index++) { - if (upd[index].upd_chgtype == LDAP_REQ_DELETE && - upd[index].upd_uuid) { + if (upd[index].upd_chgtype == LDAP_REQ_DELETE && upd[index].upd_uuid) { if (uuid_index < SYNC_MAX_DELETED_UUID_BATCH) { - syncUUIDs[uuid_index] = sync_nsuniqueid2uuid(upd[index].upd_uuid); + if (upd[index].upd_euuid) { + /* Only occurs in openldap mode, swap to the entryuuid */ + syncUUIDs[uuid_index] = sync_entryuuid2uuid(upd[index].upd_euuid); + } else { + /* Normal mode */ + syncUUIDs[uuid_index] = sync_nsuniqueid2uuid(upd[index].upd_uuid); + } uuid_index++; } else { /* max number of uuids to be sent in one sync info message */ @@ -692,24 +786,21 @@ sync_send_deleted_entries(Slapi_PBlock *pb, Sync_UpdateNode *upd, int chg_count, } void -sync_send_modified_entries(Slapi_PBlock *pb, Sync_UpdateNode *upd, int chg_count) +sync_send_modified_entries(Slapi_PBlock *pb, Sync_UpdateNode *upd, int chg_count, Sync_Cookie *cookie) { - int index; - - for (index = 0; index < chg_count; index++) { - if (upd[index].upd_chgtype != LDAP_REQ_DELETE && - upd[index].upd_uuid) - - sync_send_entry_from_changelog(pb, upd[index].upd_chgtype, upd[index].upd_uuid); + for (size_t index = 0; index < chg_count; index++) { + if (upd[index].upd_chgtype != LDAP_REQ_DELETE && upd[index].upd_uuid) { + sync_send_entry_from_changelog(pb, upd[index].upd_chgtype, upd[index].upd_uuid, cookie); + } } } int -sync_send_entry_from_changelog(Slapi_PBlock *pb, int chg_req __attribute__((unused)), char *uniqueid) +sync_send_entry_from_changelog(Slapi_PBlock *pb, int chg_req __attribute__((unused)), char *uniqueid, Sync_Cookie *cookie) { Slapi_Entry *db_entry = NULL; int chg_type = LDAP_SYNC_ADD; - int rv; + int rv = LDAP_SUCCESS; Slapi_PBlock *search_pb = NULL; Slapi_Entry **entries = NULL; char *origbase; @@ -724,20 +815,27 @@ sync_send_entry_from_changelog(Slapi_PBlock *pb, int chg_req __attribute__((unus slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &rv); if (rv == LDAP_SUCCESS) { slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries); - if (entries) + if (entries) { db_entry = *entries; /* there can only be one */ + } } if (db_entry && sync_is_entry_in_scope(pb, db_entry)) { LDAPControl **ctrl = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *)); - sync_create_state_control(db_entry, &ctrl[0], chg_type, NULL); + rv = sync_create_state_control(db_entry, &ctrl[0], chg_type, NULL, cookie->openldap_compat); + if (rv != LDAP_SUCCESS) { + ldap_controls_free(ctrl); + slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, "Terminating sync_send_entry_from_changelog due to error code -> %d\n", rv); + goto senddone; + } slapi_send_ldap_search_entry(pb, db_entry, ctrl, NULL, 0); ldap_controls_free(ctrl); } +senddone: slapi_free_search_results_internal(search_pb); slapi_pblock_destroy(search_pb); slapi_ch_free((void **)&filter); - return (0); + return rv; } static SyncOpInfo * @@ -796,6 +894,13 @@ sync_set_operation_extension(Slapi_PBlock *pb, SyncOpInfo *spec) sync_extension_handle, (void *)spec); } +void +sync_register_allow_openldap_compat(PRBool allow) +{ + /* This is synced by virtue of the plugin locking/loading. */ + allow_openldap_compat = allow; +} + int sync_register_operation_extension(void) { diff --git a/ldap/servers/plugins/sync/sync_util.c b/ldap/servers/plugins/sync/sync_util.c index a385ef8ba..dc7f49fac 100644 --- a/ldap/servers/plugins/sync/sync_util.c +++ b/ldap/servers/plugins/sync/sync_util.c @@ -78,6 +78,39 @@ sync_parse_control_value(struct berval *psbvp, ber_int_t *mode, int *reload, cha return (rc); } +char * +sync_entryuuid2uuid(const char *entryuuid) +{ + char *uuid; + char u[17] = {0}; + + u[0] = slapi_str_to_u8(entryuuid); + u[1] = slapi_str_to_u8(entryuuid + 2); + u[2] = slapi_str_to_u8(entryuuid + 4); + u[3] = slapi_str_to_u8(entryuuid + 6); + + u[4] = slapi_str_to_u8(entryuuid + 9); + u[5] = slapi_str_to_u8(entryuuid + 11); + + u[6] = slapi_str_to_u8(entryuuid + 14); + u[7] = slapi_str_to_u8(entryuuid + 16); + + u[8] = slapi_str_to_u8(entryuuid + 19); + u[9] = slapi_str_to_u8(entryuuid + 21); + + u[10] = slapi_str_to_u8(entryuuid + 24); + u[11] = slapi_str_to_u8(entryuuid + 26); + u[12] = slapi_str_to_u8(entryuuid + 28); + u[13] = slapi_str_to_u8(entryuuid + 30); + u[14] = slapi_str_to_u8(entryuuid + 32); + u[15] = slapi_str_to_u8(entryuuid + 34); + + uuid = slapi_ch_malloc(sizeof(u)); + memcpy(uuid, u, sizeof(u)); + + return (uuid); +} + char * sync_nsuniqueid2uuid(const char *nsuniqueid) { @@ -126,7 +159,7 @@ sync_nsuniqueid2uuid(const char *nsuniqueid) * */ int -sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Cookie *cookie) +sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Cookie *cookie, PRBool openldap_compat) { int rc; BerElement *ber; @@ -141,9 +174,26 @@ sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Co *ctrlp = NULL; - slapi_entry_attr_find(e, SLAPI_ATTR_UNIQUEID, &attr); - slapi_attr_first_value(attr, &val); - uuid = sync_nsuniqueid2uuid(slapi_value_get_string(val)); + if (openldap_compat) { + slapi_entry_attr_find(e, SLAPI_ATTR_ENTRYUUID, &attr); + if (!attr) { + /* + * We can't proceed from here. We are in openldap mode, but some entries don't + * have their UUID. This means that the tree could be corrupted on the openldap + * server, so we have to stop now. + */ + slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, + "sync_create_state_control - Some entries are missing entryUUID. Unable to proceed. You may need to re-run the entryuuid fixup\n"); + return (LDAP_OPERATIONS_ERROR); + } + slapi_attr_first_value(attr, &val); + uuid = sync_entryuuid2uuid(slapi_value_get_string(val)); + } else { + slapi_entry_attr_find(e, SLAPI_ATTR_UNIQUEID, &attr); + slapi_attr_first_value(attr, &val); + uuid = sync_nsuniqueid2uuid(slapi_value_get_string(val)); + } + if ((rc = ber_printf(ber, "{eo", type, uuid, 16)) != -1) { if (cookie) { char *cookiestr = sync_cookie2str(cookie); @@ -574,7 +624,7 @@ sync_cookie_create(Slapi_PBlock *pb, Sync_Cookie *client_cookie) sc->cookie_client_signature = slapi_ch_strdup(client_cookie->cookie_client_signature); sc->cookie_server_signature = NULL; } else { - sc->openldap_compat = false; + sc->openldap_compat = PR_FALSE; sc->cookie_server_signature = sync_cookie_get_server_info(pb); sc->cookie_client_signature = sync_cookie_get_client_info(pb); } @@ -608,7 +658,7 @@ sync_cookie_update(Sync_Cookie *sc, Slapi_Entry *ec) } Sync_Cookie * -sync_cookie_parse(char *cookie, bool *cookie_refresh) +sync_cookie_parse(char *cookie, PRBool *cookie_refresh, PRBool *allow_openldap_compat) { char *p = NULL; char *q = NULL; @@ -616,7 +666,7 @@ sync_cookie_parse(char *cookie, bool *cookie_refresh) /* This is an rfc compliant initial refresh request */ if (cookie == NULL || *cookie == '\0') { - *cookie_refresh = 1; + *cookie_refresh = PR_TRUE; return NULL; } @@ -625,16 +675,21 @@ sync_cookie_parse(char *cookie, bool *cookie_refresh) sc = (Sync_Cookie *)slapi_ch_calloc(1, sizeof(Sync_Cookie)); if (strncmp(cookie, "rid=", 4) == 0) { + if (*allow_openldap_compat != PR_TRUE) { + slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, "sync_cookie_parse - An openldap sync request was made, but " SYNC_ALLOW_OPENLDAP_COMPAT " is false\n"); + slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, "sync_cookie_parse - To enable this run 'dsconf <instance> plugin contentsync set --allow-openldap on'\n"); + goto error_return; + } /* * We are in openldap mode. * The cookies are: * rid=123,csn=20200525051329.534174Z#000000#000#000000 */ - sc->openldap_compat = true; + sc->openldap_compat = PR_TRUE; p = strchr(q, ','); if (p == NULL) { /* No CSN following the rid, must be an init request. */ - *cookie_refresh = 1; + *cookie_refresh = PR_TRUE; /* We need to keep the client rid though */ sc->cookie_client_signature = slapi_ch_strdup(q); /* server sig and change info do not need to be set. */ diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 61f6df49e..5c7486a29 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -418,6 +418,7 @@ PR_fprintf(struct PRFileDesc *fd, const char *fmt, ...) #define SLAPI_ATTR_DN "dn" #define SLAPI_ATTR_RDN "rdn" #define SLAPI_ATTR_PARENTID "parentid" +#define SLAPI_ATTR_ENTRYUUID "entryuuid" #define SLAPI_ATTR_UNIQUEID_LENGTH 10 #define SLAPI_ATTR_OBJECTCLASS_LENGTH 11 #define SLAPI_ATTR_VALUE_TOMBSTONE_LENGTH 11 diff --git a/src/lib389/lib389/cli_conf/__init__.py b/src/lib389/lib389/cli_conf/__init__.py index b74247d9a..dd0763d3f 100644 --- a/src/lib389/lib389/cli_conf/__init__.py +++ b/src/lib389/lib389/cli_conf/__init__.py @@ -52,8 +52,30 @@ def generic_object_add(dsldap_objects_class, inst, log, args, arg_to_attr, dn=No return new_object +def generic_object_add_attr(dsldap_object, log, args, arg_to_attr): + """Add an attribute to the entry. This differs to 'edit' as edit uses replace, + and this allows multivalues to be added. + + dsldap_object should be a single instance of DSLdapObject with a set dn + """ + log = log.getChild('generic_object_add_attr') + # Gather the attributes + attrs = _args_to_attrs(args, arg_to_attr) + + modlist = [] + for attr, value in attrs.items(): + if not isinstance(value, list): + value = [value] + modlist.append((ldap.MOD_ADD, attr, value)) + if len(modlist) > 0: + dsldap_object.apply_mods(modlist) + log.info("Successfully changed the %s", dsldap_object.dn) + else: + raise ValueError("There is nothing to set in the %s plugin entry" % dsldap_object.dn) + + def generic_object_edit(dsldap_object, log, args, arg_to_attr): - """Create an entry using DSLdapObject interface + """Replace or delete an attribute on an entry. dsldap_object should be a single instance of DSLdapObject with a set dn """ diff --git a/src/lib389/lib389/cli_conf/plugins/contentsync.py b/src/lib389/lib389/cli_conf/plugins/contentsync.py index 86698e307..fb1e4bae7 100644 --- a/src/lib389/lib389/cli_conf/plugins/contentsync.py +++ b/src/lib389/lib389/cli_conf/plugins/contentsync.py @@ -7,9 +7,37 @@ # --- END COPYRIGHT BLOCK --- from lib389.plugins import ContentSyncPlugin -from lib389.cli_conf import add_generic_plugin_parsers +from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit, generic_object_add_attr + +arg_to_attr = { + 'allow_openldap': 'syncrepl-allow-openldap', +} + +def contentsync_edit(inst, basedn, log, args): + log = log.getChild('contentsync_edit') + plugin = ContentSyncPlugin(inst) + generic_object_edit(plugin, log, args, arg_to_attr) + + +def contentsync_add(inst, basedn, log, args): + log = log.getChild('contentsync_add') + plugin = ContentSyncPlugin(inst) + generic_object_add_attr(plugin, log, args, arg_to_attr) + + +def _add_parser_args(parser): + parser.add_argument('--allow-openldap', choices=['on', 'off'], type=str.lower, + help='Allows openldap servers to act as read only consumers of this server via syncrepl') def create_parser(subparsers): contentsync_parser = subparsers.add_parser('contentsync', help='Manage and configure Content Sync Plugin (aka syncrepl)') subcommands = contentsync_parser.add_subparsers(help='action') add_generic_plugin_parsers(subcommands, ContentSyncPlugin) + + edit = subcommands.add_parser('set', help='Edit the plugin') + edit.set_defaults(func=contentsync_edit) + _add_parser_args(edit) + + addp = subcommands.add_parser('add', help='Add attributes to the plugin') + addp.set_defaults(func=contentsync_add) + _add_parser_args(addp) diff --git a/src/lib389/lib389/cli_conf/plugins/retrochangelog.py b/src/lib389/lib389/cli_conf/plugins/retrochangelog.py index 2fcaf20ef..c09203f4a 100644 --- a/src/lib389/lib389/cli_conf/plugins/retrochangelog.py +++ b/src/lib389/lib389/cli_conf/plugins/retrochangelog.py @@ -7,7 +7,7 @@ # --- END COPYRIGHT BLOCK --- from lib389.plugins import RetroChangelogPlugin -from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit +from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit, generic_object_add_attr arg_to_attr = { 'is_replicated': 'isReplicated', @@ -24,6 +24,12 @@ def retrochangelog_edit(inst, basedn, log, args): generic_object_edit(plugin, log, args, arg_to_attr) +def retrochangelog_add(inst, basedn, log, args): + log = log.getChild('retrochangelog_add') + plugin = RetroChangelogPlugin(inst) + generic_object_add_attr(plugin, log, args, arg_to_attr) + + def _add_parser_args(parser): parser.add_argument('--is-replicated', choices=['TRUE', 'FALSE'], type=str.upper, help='Sets a flag to indicate on a change in the changelog whether the change is newly made ' @@ -51,4 +57,7 @@ def create_parser(subparsers): edit.set_defaults(func=retrochangelog_edit) _add_parser_args(edit) + addp = subcommands.add_parser('add', help='Add attributes to the plugin') + addp.set_defaults(func=retrochangelog_add) + _add_parser_args(addp)
0
e306a2d4dc226eb7539ff935cfc4f89aca4bef3e
389ds/389-ds-base
Issue 49586 - Add py3 support to plugins test suite Description: Added py3 support by explicitly changing strings to bytes. Added code for creating a new connection to make ldap communicate on localhost. https://pagure.io/389-ds-base/issue/49586 Reviewed by: spichugi
commit e306a2d4dc226eb7539ff935cfc4f89aca4bef3e Author: Akshay Adhikari <[email protected]> Date: Fri Apr 13 13:39:14 2018 +0530 Issue 49586 - Add py3 support to plugins test suite Description: Added py3 support by explicitly changing strings to bytes. Added code for creating a new connection to make ldap communicate on localhost. https://pagure.io/389-ds-base/issue/49586 Reviewed by: spichugi diff --git a/dirsrvtests/tests/suites/plugins/accpol_test.py b/dirsrvtests/tests/suites/plugins/accpol_test.py index 2539bc041..b6de0e608 100644 --- a/dirsrvtests/tests/suites/plugins/accpol_test.py +++ b/dirsrvtests/tests/suites/plugins/accpol_test.py @@ -33,13 +33,13 @@ def accpol_global(topology_st, request): topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) try: topology_st.standalone.plugins.enable(name=PLUGIN_ACCT_POLICY) - topology_st.standalone.modify_s(ACCPOL_DN, [(ldap.MOD_REPLACE, 'nsslapd-pluginarg0', ACCP_CONF)]) - topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', 'yes')]) - topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'stateattrname', 'lastLoginTime')]) - topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'altstateattrname', 'createTimestamp')]) - topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'specattrname', 'acctPolicySubentry')]) - topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'limitattrname', 'accountInactivityLimit')]) - topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'accountInactivityLimit', '12')]) + topology_st.standalone.modify_s(ACCPOL_DN, [(ldap.MOD_REPLACE, 'nsslapd-pluginarg0', ensure_bytes(ACCP_CONF))]) + topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', b'yes')]) + topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'stateattrname', b'lastLoginTime')]) + topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'altstateattrname', b'createTimestamp')]) + topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'specattrname', b'acctPolicySubentry')]) + topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'limitattrname', b'accountInactivityLimit')]) + topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'accountInactivityLimit', b'12')]) topology_st.standalone.config.set('passwordexp', 'on') topology_st.standalone.config.set('passwordmaxage', '400') topology_st.standalone.config.set('passwordwarning', '1') @@ -136,14 +136,14 @@ def userpw_reset(topology_st, suffix, subtree, userid, nousrs, bindusr, bindpw, if (bindusr == "DirMgr"): topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) try: - topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', newpasw)]) + topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', ensure_bytes(newpasw))]) except ldap.LDAPError as e: log.error('Unable to reset userPassword for user-{}'.format(userdn)) raise e elif (bindusr == "RegUsr"): topology_st.standalone.simple_bind_s(userdn, bindpw) try: - topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', newpasw)]) + topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', ensure_bytes(newpasw))]) except ldap.LDAPError as e: log.error('Unable to reset userPassword for user-{}'.format(userdn)) raise e @@ -173,7 +173,7 @@ def nsact_inact(topology_st, suffix, subtree, userid, nousrs, command, expected) except subprocess.CalledProcessError as err: output = err.output log.info('output: {}'.format(output)) - assert expected in output + assert ensure_bytes(expected) in output nousrs = nousrs - 1 time.sleep(1) @@ -184,7 +184,7 @@ def modify_attr(topology_st, base_dn, attr_name, attr_val): log.info('Modify attribute value for a given DN') topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) try: - topology_st.standalone.modify_s(base_dn, [(ldap.MOD_REPLACE, attr_name, attr_val)]) + topology_st.standalone.modify_s(base_dn, [(ldap.MOD_REPLACE, attr_name, ensure_bytes(attr_val))]) except ldap.LDAPError as e: log.error('Failed to replace lastLoginTime attribute for user-{} {}'.format(userdn, e.message['desc'])) assert False @@ -217,7 +217,7 @@ def add_time_attr(topology_st, suffix, subtree, userid, nousrs, attr_name): usrrdn = '{}{}'.format(userid, nousrs) userdn = 'uid={},{},{}'.format(usrrdn, subtree, suffix) try: - topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, new_attr_val)]) + topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, ensure_bytes(new_attr_val))]) except ldap.LDAPError as e: log.error('Failed to add/replace {} attribute to-{}, for user-{}'.format(attr_name, new_attr_val, userdn)) raise e @@ -235,7 +235,7 @@ def modusr_attr(topology_st, suffix, subtree, userid, nousrs, attr_name, attr_va usrrdn = '{}{}'.format(userid, nousrs) userdn = 'uid={},{},{}'.format(usrrdn, subtree, suffix) try: - topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, attr_value)]) + topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, ensure_bytes(attr_value))]) except ldap.LDAPError as e: log.error('Failed to add/replace {} attribute to-{}, for user-{}'.format(attr_name, attr_value, userdn)) raise e diff --git a/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py b/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py index 7b80667ce..f9905f959 100644 --- a/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py +++ b/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py @@ -24,7 +24,7 @@ def test_attr_uniqueness_init(topology_st): Enable dynamic plugins - makes things easier ''' try: - topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')]) + topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')]) except ldap.LDAPError as e: log.fatal('Failed to enable dynamic plugin!' + e.message['desc']) assert False @@ -40,7 +40,7 @@ def test_attr_uniqueness(topology_st): # try: topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config', - [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', 'uid')]) + [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'uid')]) except ldap.LDAPError as e: log.fatal('test_attr_uniqueness: Failed to configure plugin for "uid": error ' + e.message['desc']) @@ -78,7 +78,7 @@ def test_attr_uniqueness(topology_st): # try: topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config', - [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', 'mail')]) + [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'mail')]) except ldap.LDAPError as e: log.fatal('test_attr_uniqueness: Failed to configure plugin for "mail": error ' + e.message['desc']) @@ -105,9 +105,9 @@ def test_attr_uniqueness(topology_st): # try: topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config', - [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', 'mail'), + [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'mail'), (ldap.MOD_ADD, 'uniqueness-attribute-name', - 'mailAlternateAddress')]) + b'mailAlternateAddress')]) except ldap.LDAPError as e: log.error('test_attr_uniqueness: Failed to reconfigure plugin for "mail mailAlternateAddress": error ' + e.message['desc']) diff --git a/dirsrvtests/tests/suites/plugins/dna_test.py b/dirsrvtests/tests/suites/plugins/dna_test.py index e084cdd20..370867e25 100644 --- a/dirsrvtests/tests/suites/plugins/dna_test.py +++ b/dirsrvtests/tests/suites/plugins/dna_test.py @@ -58,8 +58,8 @@ def test_basic(topology_st): }))) except ldap.ALREADY_EXISTS: try: - topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaNextValue', '1'), - (ldap.MOD_REPLACE, 'dnaMagicRegen', '-1')]) + topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaNextValue', b'1'), + (ldap.MOD_REPLACE, 'dnaMagicRegen', b'-1')]) except ldap.LDAPError as e: log.fatal('test_dna: Failed to set the DNA plugin: error ' + e.message['desc']) assert False @@ -96,7 +96,7 @@ def test_basic(topology_st): # Test the magic regen value try: - topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', '-1')]) + topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', b'-1')]) except ldap.LDAPError as e: log.fatal('test_dna: Failed to set the magic reg value: error ' + e.message['desc']) assert False @@ -116,7 +116,7 @@ def test_basic(topology_st): ################################################################################ try: - topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaMagicRegen', '-2')]) + topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaMagicRegen', b'-2')]) except ldap.LDAPError as e: log.fatal('test_dna: Failed to set the magic reg value to -2: error ' + e.message['desc']) assert False @@ -127,7 +127,7 @@ def test_basic(topology_st): # Test the magic regen value try: - topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', '-2')]) + topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', b'-2')]) except ldap.LDAPError as e: log.fatal('test_dna: Failed to set the magic reg value: error ' + e.message['desc']) assert False diff --git a/dirsrvtests/tests/suites/plugins/memberof_test.py b/dirsrvtests/tests/suites/plugins/memberof_test.py index 4958a3c2c..882f55710 100644 --- a/dirsrvtests/tests/suites/plugins/memberof_test.py +++ b/dirsrvtests/tests/suites/plugins/memberof_test.py @@ -37,84 +37,82 @@ def _set_memberofgroupattr_add(topology_st, values): topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_ADD, PLUGIN_MEMBEROF_GRP_ATTR, - values)]) + ensure_bytes(values))]) def _get_user_rdn(ext): - return "uid=%s_%s" % (USER_RDN, ext) - + return ensure_bytes("uid=%s_%s" % (USER_RDN, ext)) def _get_user_dn(ext): - return "%s,%s" % (_get_user_rdn(ext), USERS_CONTAINER) + return ensure_bytes("%s,%s" % (ensure_str(_get_user_rdn(ext)), USERS_CONTAINER)) def _get_group_rdn(ext): - return "cn=%s_%s" % (GROUP_RDN, ext) + return ensure_bytes("cn=%s_%s" % (GROUP_RDN, ext)) def _get_group_dn(ext): - return "%s,%s" % (_get_group_rdn(ext), GROUPS_CONTAINER) + return ensure_bytes("%s,%s" % (ensure_str(_get_group_rdn(ext)), GROUPS_CONTAINER)) def _create_user(topology_st, ext): - user_dn = _get_user_dn(ext) + user_dn = ensure_str(_get_user_dn(ext)) topology_st.standalone.add_s(Entry((user_dn, { 'objectclass': 'top extensibleObject'.split(), - 'uid': _get_user_rdn(ext) + 'uid': ensure_str(_get_user_rdn(ext)) }))) log.info("Create user %s" % user_dn) - return user_dn + return ensure_bytes(user_dn) def _delete_user(topology_st, ext): - user_dn = _get_user_dn(ext) + user_dn = ensure_str(_get_user_dn(ext)) topology_st.standalone.delete_s(user_dn) log.info("Delete user %s" % user_dn) def _create_group(topology_st, ext): - group_dn = _get_group_dn(ext) + group_dn = ensure_str(_get_group_dn(ext)) topology_st.standalone.add_s(Entry((group_dn, { 'objectclass': 'top groupOfNames groupOfUniqueNames extensibleObject'.split(), - 'ou': _get_group_rdn(ext) + 'ou': ensure_str(_get_group_rdn(ext)) }))) log.info("Create group %s" % group_dn) - return group_dn + return ensure_bytes(group_dn) def _delete_group(topology_st, ext): - group_dn = _get_group_dn(ext) + group_dn = ensure_str(_get_group_dn(ext)) topology_st.standalone.delete_s(group_dn) log.info("Delete group %s" % group_dn) def _check_memberattr(topology_st, entry, memberattr, value): log.info("Check %s.%s = %s" % (entry, memberattr, value)) - entry = topology_st.standalone.getEntry(entry, ldap.SCOPE_BASE, '(objectclass=*)', [memberattr]) - assert entry - if not entry.hasAttr(memberattr): + entry = topology_st.standalone.getEntry(ensure_str(entry), ldap.SCOPE_BASE, '(objectclass=*)', [memberattr]) + if not entry.hasAttr(ensure_str(memberattr)): return False found = False - for val in entry.getValues(memberattr): - log.info("%s: %s" % (memberattr, val)) - if value.lower() == val.lower(): + for val in entry.getValues(ensure_str(memberattr)): + log.info("%s: %s" % (memberattr, ensure_str(val))) + if ensure_str(value.lower()) == ensure_str(val.lower()): found = True break return found + def _check_memberof(topology_st, member, group): log.info("Lookup memberof from %s" % member) - entry = topology_st.standalone.getEntry(member, ldap.SCOPE_BASE, '(objectclass=*)', ['memberof']) - assert entry + entry = topology_st.standalone.getEntry(ensure_str(member), ldap.SCOPE_BASE, '(objectclass=*)', ['memberof']) if not entry.hasAttr('memberof'): return False found = False for val in entry.getValues('memberof'): - log.info("memberof: %s" % val) - if group.lower() == val.lower(): + log.info("memberof: %s" % ensure_str(val)) + if ensure_str(group.lower()) == ensure_str(val.lower()): found = True log.info("--> membership verified") break @@ -128,7 +126,21 @@ def text_memberof_683241_01(topology_st): topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_REPLACE, PLUGIN_TYPE, - 'betxnpostoperation')]) + b'betxnpostoperation')]) + topology_st.standalone.restart() + ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_TYPE]) + assert ent.hasAttr(PLUGIN_TYPE) + assert ent.getValue(PLUGIN_TYPE) == 'betxnpostoperation' + + +def text_memberof_683241_01(topology_st): + """ + Test Modify the memberof plugin to use the new type + """ + topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, + [(ldap.MOD_REPLACE, + PLUGIN_TYPE, + b'betxnpostoperation')]) topology_st.standalone.restart() ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_TYPE]) assert ent.hasAttr(PLUGIN_TYPE) @@ -143,8 +155,8 @@ def test_memberof_MultiGrpAttr_001(topology_st): ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_MEMBEROF_GRP_ATTR]) assert ent.hasAttr(PLUGIN_MEMBEROF_GRP_ATTR) - assert 'member'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)] - assert 'uniqueMember'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)] + assert b'member'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)] + assert b'uniqueMember'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)] def test_memberof_MultiGrpAttr_003(topology_st): @@ -156,7 +168,7 @@ def test_memberof_MultiGrpAttr_003(topology_st): topology_st.standalone.restart() ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_ENABLED]) assert ent.hasAttr(PLUGIN_ENABLED) - assert ent.getValue(PLUGIN_ENABLED).lower() == 'on' + assert ent.getValue(PLUGIN_ENABLED).lower() == b'on' def test_memberof_MultiGrpAttr_004(topology_st): @@ -172,11 +184,11 @@ def test_memberof_MultiGrpAttr_004(topology_st): mods = [(ldap.MOD_ADD, 'member', memofenh1), (ldap.MOD_ADD, 'uniqueMember', memofenh2)] log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp1)) log.info("Update %s is memberof %s (uniqueMember)" % (memofenh2, memofegrp1)) - topology_st.standalone.modify_s(memofegrp1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp1), mods) log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp2)) log.info("Update %s is memberof %s (uniqueMember)" % (memofenh2, memofegrp2)) - topology_st.standalone.modify_s(memofegrp2, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp2), mods) # assert enh1 is member of grp1 and grp2 assert _check_memberof(topology_st, member=memofenh1, group=memofegrp1) @@ -196,10 +208,9 @@ def test_memberof_MultiGrpAttr_005(topology_st): memofegrp1 = _get_group_dn('memofegrp1') memofegrp2 = _get_group_dn('memofegrp2') - log.info("Update %s is no longer memberof %s (member)" % (memofenh1, memofegrp1)) mods = [(ldap.MOD_DELETE, 'member', memofenh1)] - topology_st.standalone.modify_s(memofegrp1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp1), mods) # assert enh1 is NOT member of grp1 and is member of grp2 assert not _check_memberof(topology_st, member=memofenh1, group=memofegrp1) @@ -222,7 +233,7 @@ def test_memberof_MultiGrpAttr_006(topology_st): log.info("Update %s is no longer memberof %s (uniqueMember)" % (memofenh1, memofegrp1)) mods = [(ldap.MOD_DELETE, 'uniqueMember', memofenh2)] - topology_st.standalone.modify_s(memofegrp2, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp2), mods) # assert enh1 is NOT member of grp1 and is member of grp2 assert not _check_memberof(topology_st, member=memofenh1, group=memofegrp1) @@ -245,11 +256,11 @@ def test_memberof_MultiGrpAttr_007(topology_st): log.info("Update %s is no longer memberof %s (uniqueMember)" % (memofenh2, memofegrp1)) mods = [(ldap.MOD_DELETE, 'uniqueMember', memofenh2)] - topology_st.standalone.modify_s(memofegrp1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp1), mods) log.info("Update %s is no longer memberof %s (member)" % (memofenh1, memofegrp2)) mods = [(ldap.MOD_DELETE, 'member', memofenh1)] - topology_st.standalone.modify_s(memofegrp2, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp2), mods) # assert enh1 is NOT member of grp1 and is member of grp2 assert not _check_memberof(topology_st, member=memofenh1, group=memofegrp1) @@ -272,11 +283,11 @@ def test_memberof_MultiGrpAttr_008(topology_st): mods = [(ldap.MOD_ADD, 'member', memofenh1)] log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp1)) - topology_st.standalone.modify_s(memofegrp1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp1), mods) mods = [(ldap.MOD_ADD, 'uniqueMember', memofenh2)] log.info("Update %s is memberof %s (uniqueMember)" % (memofenh2, memofegrp2)) - topology_st.standalone.modify_s(memofegrp2, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp2), mods) # assert enh1 is member of grp1 and is NOT member of grp2 assert _check_memberof(topology_st, member=memofenh1, group=memofegrp1) @@ -290,7 +301,7 @@ def test_memberof_MultiGrpAttr_008(topology_st): topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_DELETE, PLUGIN_MEMBEROF_GRP_ATTR, - ['uniqueMember'])]) + [b'uniqueMember'])]) topology_st.standalone.restart() log.info("Assert that this change of configuration did change the already set values") @@ -336,7 +347,7 @@ def test_memberof_MultiGrpAttr_010(topology_st): mods = [(ldap.MOD_ADD, 'member', memofenh1)] log.info("Try %s is memberof %s (member)" % (memofenh1, memofegrp1)) try: - topology_st.standalone.modify_s(memofegrp1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp1), mods) log.error( "Should not be allowed to add %s member of %s (because it was already member)" % (memofenh1, memofegrp1)) assert False @@ -376,7 +387,7 @@ def test_memberof_MultiGrpAttr_011(topology_st): mods = [(ldap.MOD_ADD, 'uniqueMember', memofenh2)] log.info("Try %s is memberof %s (member)" % (memofenh2, memofegrp2)) try: - topology_st.standalone.modify_s(memofegrp2, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp2), mods) log.error( "Should not be allowed to add %s member of %s (because it was already member)" % (memofenh2, memofegrp2)) assert False @@ -473,7 +484,7 @@ def test_memberof_MultiGrpAttr_014(topology_st): mods = [(ldap.MOD_ADD, 'member', memofenh1), (ldap.MOD_ADD, 'uniqueMember', memofenh1)] log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp3)) log.info("Update %s is memberof %s (uniqueMember)" % (memofenh1, memofegrp3)) - topology_st.standalone.modify_s(memofegrp3, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp3), mods) # assert enh1 is member of # - grp1 (member) @@ -485,11 +496,11 @@ def test_memberof_MultiGrpAttr_014(topology_st): mods = [(ldap.MOD_DELETE, 'member', memofenh1)] log.info("Update %s is not memberof %s (member)" % (memofenh1, memofegrp3)) - topology_st.standalone.modify_s(memofegrp3, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp3), mods) mods = [(ldap.MOD_ADD, 'member', memofenh2)] log.info("Update %s is memberof %s (member)" % (memofenh2, memofegrp3)) - topology_st.standalone.modify_s(memofegrp3, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp3), mods) # assert enh1 is member of # - grp1 (member) @@ -507,13 +518,13 @@ def test_memberof_MultiGrpAttr_014(topology_st): assert _check_memberof(topology_st, member=memofenh2, group=memofegrp2) assert _check_memberof(topology_st, member=memofenh2, group=memofegrp3) - ent = topology_st.standalone.getEntry(memofegrp3, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) + ent = topology_st.standalone.getEntry(ensure_str(memofegrp3), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) assert ent.hasAttr('member') - assert memofenh1 not in ent.getValues('member') - assert memofenh2 in ent.getValues('member') + assert ensure_bytes(memofenh1) not in ent.getValues('member') + assert ensure_bytes(memofenh2) in ent.getValues('member') assert ent.hasAttr('uniqueMember') - assert memofenh1 in ent.getValues('uniqueMember') - assert memofenh2 not in ent.getValues('uniqueMember') + assert ensure_bytes(memofenh1) in ent.getValues('uniqueMember') + assert ensure_bytes(memofenh2) not in ent.getValues('uniqueMember') log.info("Checking final status") # assert enh1 is member of @@ -593,15 +604,15 @@ def test_memberof_MultiGrpAttr_015(topology_st): mods = [(ldap.MOD_ADD, 'member', dummy1), (ldap.MOD_ADD, 'uniqueMember', dummy2)] log.info("Update %s is memberof %s (member)" % (dummy1, memofegrp015)) log.info("Update %s is memberof %s (uniqueMember)" % (dummy2, memofegrp015)) - topology_st.standalone.modify_s(memofegrp015, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp015), mods) - ent = topology_st.standalone.getEntry(memofegrp015, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) + ent = topology_st.standalone.getEntry(ensure_str(memofegrp015), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) assert ent.hasAttr('member') - assert dummy1 in ent.getValues('member') - assert dummy2 not in ent.getValues('member') + assert ensure_bytes(dummy1) in ent.getValues('member') + assert ensure_bytes(dummy2) not in ent.getValues('member') assert ent.hasAttr('uniqueMember') - assert dummy1 not in ent.getValues('uniqueMember') - assert dummy2 in ent.getValues('uniqueMember') + assert ensure_bytes(dummy1) not in ent.getValues('uniqueMember') + assert ensure_bytes(dummy2) in ent.getValues('uniqueMember') # assert enh1 is member of # - grp1 (member) @@ -690,7 +701,7 @@ def test_memberof_MultiGrpAttr_016(topology_st): mods = [(ldap.MOD_ADD, 'member', memofenh1), (ldap.MOD_ADD, 'uniqueMember', memofenh1)] log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp016)) log.info("Update %s is memberof %s (uniqueMember)" % (memofenh1, memofegrp016)) - topology_st.standalone.modify_s(memofegrp016, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp016), mods) # assert enh1 is member of # - grp1 (member) @@ -718,23 +729,23 @@ def test_memberof_MultiGrpAttr_016(topology_st): mods = [(ldap.MOD_ADD, 'member', dummy1), ] log.info("Update %s is memberof %s (member)" % (dummy1, memofegrp016)) - topology_st.standalone.modify_s(memofegrp016, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp016), mods) - ent = topology_st.standalone.getEntry(memofegrp016, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) + ent = topology_st.standalone.getEntry(ensure_str(memofegrp016), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) assert ent.hasAttr('member') - assert dummy1 in ent.getValues('member') + assert ensure_bytes(dummy1) in ent.getValues('member') assert ent.hasAttr('uniqueMember') - assert dummy1 not in ent.getValues('uniqueMember') + assert ensure_bytes(dummy1) not in ent.getValues('uniqueMember') mods = [(ldap.MOD_ADD, 'uniqueMember', dummy1), ] log.info("Update %s is memberof %s (uniqueMember)" % (dummy1, memofegrp016)) - topology_st.standalone.modify_s(memofegrp016, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp016), mods) - ent = topology_st.standalone.getEntry(memofegrp016, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) + ent = topology_st.standalone.getEntry(ensure_str(memofegrp016), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember']) assert ent.hasAttr('member') - assert dummy1 in ent.getValues('member') + assert ensure_bytes(dummy1) in ent.getValues('member') assert ent.hasAttr('uniqueMember') - assert dummy1 in ent.getValues('uniqueMember') + assert ensure_bytes(dummy1) in ent.getValues('uniqueMember') # assert enh1 is member of # - grp1 (member) @@ -799,7 +810,7 @@ def test_memberof_MultiGrpAttr_017(topology_st): - not grp017 user1 is member of - - not grp1 + - not grp1 - not grp2 - not grp3 - not grp015 @@ -889,7 +900,7 @@ def test_memberof_MultiGrpAttr_017(topology_st): log.info("Update %s is memberof %s (member)" % (memofuser1, memofegrp017)) log.info("Update %s is memberof %s (uniqueMember)" % (memofuser2, memofegrp017)) log.info("Update %s is memberof %s (memberuid)" % (memofuser3, memofegrp017)) - topology_st.standalone.modify_s(memofegrp017, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp017), mods) # assert enh1 is member of # - grp1 (member) @@ -922,7 +933,7 @@ def test_memberof_MultiGrpAttr_017(topology_st): # assert user1 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - grp17 (member) @@ -936,7 +947,7 @@ def test_memberof_MultiGrpAttr_017(topology_st): # assert user2 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - grp17 (uniqueMember) @@ -950,7 +961,7 @@ def test_memberof_MultiGrpAttr_017(topology_st): # assert user3 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - NOT grp17 (memberuid) @@ -985,7 +996,7 @@ def test_memberof_MultiGrpAttr_018(topology_st): - not grp017 user1 is member of - - not grp1 + - not grp1 - not grp2 - not grp3 - not grp015 @@ -1070,7 +1081,7 @@ def test_memberof_MultiGrpAttr_018(topology_st): # assert user1 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - grp17 (member) @@ -1084,7 +1095,7 @@ def test_memberof_MultiGrpAttr_018(topology_st): # assert user2 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - grp17 (uniqueMember) @@ -1098,7 +1109,7 @@ def test_memberof_MultiGrpAttr_018(topology_st): # assert user3 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - NOT grp17 (memberuid) @@ -1118,12 +1129,12 @@ def test_memberof_MultiGrpAttr_018(topology_st): log.info("Update %s is memberof %s (member)" % (memofuser1, memofegrp017)) log.info("Update %s is memberof %s (uniqueMember)" % (memofuser1, memofegrp017)) log.info("Update %s is memberof %s (memberuid)" % (memofuser1, memofegrp017)) - topology_st.standalone.modify_s(memofegrp018, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp018), mods) # assert user1 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - grp17 (member) @@ -1139,12 +1150,12 @@ def test_memberof_MultiGrpAttr_018(topology_st): mods = [(ldap.MOD_DELETE, 'member', memofuser1), (ldap.MOD_DELETE, 'uniqueMember', memofuser1)] log.info("Update %s is no longer memberof %s (member)" % (memofuser1, memofegrp018)) log.info("Update %s is no longer memberof %s (uniqueMember)" % (memofuser1, memofegrp018)) - topology_st.standalone.modify_s(memofegrp018, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp018), mods) # assert user1 is member of # - not grp1 # - not grp2 - # - not grp3 + # - not grp3 # - not grp15 # - not grp16 # - grp17 (member) @@ -1158,10 +1169,10 @@ def test_memberof_MultiGrpAttr_018(topology_st): assert not _check_memberof(topology_st, member=memofuser1, group=memofegrp018) # DEL user1, user2, user3, grp17 - topology_st.standalone.delete_s(memofuser1) - topology_st.standalone.delete_s(memofuser2) - topology_st.standalone.delete_s(memofuser3) - topology_st.standalone.delete_s(memofegrp017) + topology_st.standalone.delete_s(ensure_str(memofuser1)) + topology_st.standalone.delete_s(ensure_str(memofuser2)) + topology_st.standalone.delete_s(ensure_str(memofuser3)) + topology_st.standalone.delete_s(ensure_str(memofegrp017)) # assert enh1 is member of # - grp1 (member) @@ -1198,7 +1209,7 @@ def test_memberof_MultiGrpAttr_019(topology_st): Add user3 to grp19_3 Add grp19_2 and grp_19_3 to grp19_1 - At the beginning: + At the beginning: enh1 is member of - grp1 (member) - not grp2 @@ -1278,26 +1289,26 @@ def test_memberof_MultiGrpAttr_019(topology_st): # Create a group grp019_2 with user2 member memofegrp019_2 = _create_group(topology_st, 'memofegrp019_2') mods = [(ldap.MOD_ADD, 'member', memofuser2)] - topology_st.standalone.modify_s(memofegrp019_2, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp019_2), mods) # Create a group grp019_3 with user3 member memofegrp019_3 = _create_group(topology_st, 'memofegrp019_3') mods = [(ldap.MOD_ADD, 'member', memofuser3)] - topology_st.standalone.modify_s(memofegrp019_3, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp019_3), mods) - mods = [(ldap.MOD_ADD, 'objectClass', 'inetUser')] - topology_st.standalone.modify_s(memofegrp019_2, mods) - topology_st.standalone.modify_s(memofegrp019_3, mods) + mods = [(ldap.MOD_ADD, 'objectClass', b'inetUser')] + topology_st.standalone.modify_s(ensure_str(memofegrp019_2), mods) + topology_st.standalone.modify_s(ensure_str(memofegrp019_3), mods) # Create a group grp019_1 with memofegrp019_2, memofegrp019_3 member memofegrp019_1 = _create_group(topology_st, 'memofegrp019_1') mods = [(ldap.MOD_ADD, 'member', memofegrp019_2), (ldap.MOD_ADD, 'member', memofegrp019_3)] - topology_st.standalone.modify_s(memofegrp019_1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp019_1), mods) # assert memofegrp019_1 is member of # - not grp1 - # - not grp2 - # - not grp3 + # - not grp2 + # - not grp3 # - not grp15 # - not grp16 # - not grp018 @@ -1395,11 +1406,11 @@ def test_memberof_MultiGrpAttr_019(topology_st): assert _check_memberof(topology_st, member=memofuser3, group=memofegrp019_3) # DEL user2, user3, grp19* - topology_st.standalone.delete_s(memofuser2) - topology_st.standalone.delete_s(memofuser3) - topology_st.standalone.delete_s(memofegrp019_1) - topology_st.standalone.delete_s(memofegrp019_2) - topology_st.standalone.delete_s(memofegrp019_3) + topology_st.standalone.delete_s(ensure_str(memofuser2)) + topology_st.standalone.delete_s(ensure_str(memofuser3)) + topology_st.standalone.delete_s(ensure_str(memofegrp019_1)) + topology_st.standalone.delete_s(ensure_str(memofegrp019_2)) + topology_st.standalone.delete_s(ensure_str(memofegrp019_3)) # assert enh1 is member of # - grp1 (member) @@ -1437,7 +1448,7 @@ def test_memberof_MultiGrpAttr_020(topology_st): Add grp[1-4] member of grp5 Check user1 is member of grp[1-5] - At the beginning: + At the beginning: enh1 is member of - grp1 (member) - not grp2 @@ -1505,20 +1516,20 @@ def test_memberof_MultiGrpAttr_020(topology_st): memofegrp020_3 = _create_group(topology_st, 'memofegrp020_3') memofegrp020_4 = _create_group(topology_st, 'memofegrp020_4') memofegrp020_5 = _create_group(topology_st, 'memofegrp020_5') - mods = [(ldap.MOD_ADD, 'objectClass', 'inetUser')] + mods = [(ldap.MOD_ADD, 'objectClass', b'inetUser')] for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5]: - topology_st.standalone.modify_s(grp, mods) + topology_st.standalone.modify_s(ensure_str(grp), mods) # add user1 to grp[1-4] (uniqueMember) mods = [(ldap.MOD_ADD, 'uniqueMember', memofuser1)] for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]: - topology_st.standalone.modify_s(grp, mods) + topology_st.standalone.modify_s(ensure_str(grp), mods) # create grp5 with grp[1-4] as member mods = [] for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]: mods.append((ldap.MOD_ADD, 'member', grp)) - topology_st.standalone.modify_s(memofegrp020_5, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp020_5), mods) assert _check_memberof(topology_st, member=memofuser1, group=memofegrp020_1) assert _check_memberof(topology_st, member=memofuser1, group=memofegrp020_2) @@ -1527,9 +1538,9 @@ def test_memberof_MultiGrpAttr_020(topology_st): assert _check_memberof(topology_st, member=memofuser1, group=memofegrp020_5) # DEL user1, grp20* - topology_st.standalone.delete_s(memofuser1) + topology_st.standalone.delete_s(ensure_str(memofuser1)) for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5]: - topology_st.standalone.delete_s(grp) + topology_st.standalone.delete_s(ensure_str(grp)) def test_memberof_MultiGrpAttr_021(topology_st): @@ -1542,7 +1553,7 @@ def test_memberof_MultiGrpAttr_021(topology_st): Check that user1 is member of Grp1 and Grp5 check that user* are members of Grp5 - At the beginning: + At the beginning: enh1 is member of - grp1 (member) - not grp2 @@ -1578,7 +1589,7 @@ def test_memberof_MultiGrpAttr_021(topology_st): - not grp018 - not grp20* - user1 is member of grp20_5 + user1 is member of grp20_5 userX is uniquemember of grp20_X grp[1-4] are member of grp20_5 @@ -1638,15 +1649,15 @@ def test_memberof_MultiGrpAttr_021(topology_st): (memofegrp020_2, memofuser2), (memofegrp020_3, memofuser3), (memofegrp020_4, memofuser4)]: - mods = [(ldap.MOD_ADD, 'objectClass', 'inetUser'), (ldap.MOD_ADD, 'uniqueMember', x[1])] - topology_st.standalone.modify_s(x[0], mods) + mods = [(ldap.MOD_ADD, 'objectClass', b'inetUser'), (ldap.MOD_ADD, 'uniqueMember', x[1])] + topology_st.standalone.modify_s(ensure_str(x[0]), mods) # create grp5 with grp[1-4] as member + user1 memofegrp020_5 = _create_group(topology_st, 'memofegrp020_5') mods = [(ldap.MOD_ADD, 'member', memofuser1)] for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]: mods.append((ldap.MOD_ADD, 'member', grp)) - topology_st.standalone.modify_s(memofegrp020_5, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp020_5), mods) # assert user[1-4] are member of grp20_5 for user in [memofuser1, memofuser2, memofuser3, memofuser4]: @@ -1722,7 +1733,7 @@ def test_memberof_MultiGrpAttr_022(topology_st): add Grp5 as uniquemember of GrpX (this create a loop) - At the beginning: + At the beginning: enh1 is member of - grp1 (member) - not grp2 @@ -1741,7 +1752,7 @@ def test_memberof_MultiGrpAttr_022(topology_st): - not grp20* - user1 is member of grp20_5 + user1 is member of grp20_5 userX is uniquemember of grp20_X grp[1-4] are member of grp20_5 @@ -1866,7 +1877,7 @@ def test_memberof_MultiGrpAttr_022(topology_st): (memofegrp020_3, memofuser3), (memofegrp020_4, memofuser4)]: mods = [(ldap.MOD_ADD, 'member', x[1])] - topology_st.standalone.modify_s(x[0], mods) + topology_st.standalone.modify_s(ensure_str(x[0]), mods) # check that user[1-4] are 'member' and 'uniqueMember' of the grp20_[1-4] for x in [(memofegrp020_1, memofuser1), @@ -1876,11 +1887,11 @@ def test_memberof_MultiGrpAttr_022(topology_st): assert _check_memberattr(topology_st, x[0], 'uniqueMember', x[1]) assert _check_memberattr(topology_st, x[0], 'member', x[1]) - # add Grp[1-4] (uniqueMember) to grp5 + # add Grp[1-4] (uniqueMember) to grp5 # it creates a membership loop !!! mods = [(ldap.MOD_ADD, 'uniqueMember', memofegrp020_5)] for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]: - topology_st.standalone.modify_s(grp, mods) + topology_st.standalone.modify_s(ensure_str(grp), mods) time.sleep(5) # assert user[1-4] are member of grp20_[1-4] @@ -1957,14 +1968,14 @@ def verify_post_023(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, /----member ---> G1 ---uniqueMember -------\ / V G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 ---member/uniqueMember -> U2 |<--uniquemember-/ | |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ + |<--uniquemember-/ |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + |<--uniquemember-/ """ for x in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]: assert _check_memberattr(topology_st, memofegrp020_5, 'member', x) @@ -2003,7 +2014,7 @@ def test_memberof_MultiGrpAttr_023(topology_st): - At the beginning: + At the beginning: enh1 is member of - grp1 (member) - not grp2 @@ -2029,14 +2040,14 @@ def test_memberof_MultiGrpAttr_023(topology_st): /----member ---> G1 ---member/uniqueMember -\ /<--uniquemember- V G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 ---member/uniqueMember -> U2 |<--uniquemember-/ | |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ + |<--uniquemember-/ |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + |<--uniquemember-/ @@ -2045,14 +2056,14 @@ def test_memberof_MultiGrpAttr_023(topology_st): /----member ---> G1 ---uniqueMember -------\ / V G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 ---member/uniqueMember -> U2 |<--uniquemember-/ | |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ + |<--uniquemember-/ |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + |<--uniquemember-/ """ memofenh1 = _get_user_dn('memofenh1') @@ -2161,10 +2172,10 @@ def test_memberof_MultiGrpAttr_023(topology_st): # DEL user1 as 'member' of grp20_1 mods = [(ldap.MOD_DELETE, 'member', memofuser1)] - topology_st.standalone.modify_s(memofegrp020_1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp020_1), mods) mods = [(ldap.MOD_DELETE, 'uniqueMember', memofegrp020_5)] - topology_st.standalone.modify_s(memofegrp020_1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp020_1), mods) """ /----member ---> G1 ---uniqueMember -------\ @@ -2189,14 +2200,14 @@ def verify_post_024(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, /----member ---> G1 ---member/uniqueMember -\ / V G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 ---member/uniqueMember -> U2 |<--uniquemember-/ | |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ + |<--uniquemember-/ |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + |<--uniquemember-/ """ for x in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]: assert _check_memberattr(topology_st, memofegrp020_5, 'member', x) @@ -2231,33 +2242,33 @@ def verify_post_024(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, def test_memberof_MultiGrpAttr_024(topology_st): """ - At the beginning: + At the beginning: /----member ---> G1 ---uniqueMember -------\ / V G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 ---member/uniqueMember -> U2 |<--uniquemember-/ | |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ + |<--uniquemember-/ |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + |<--uniquemember-/ At the end: /----member ---> G1 ---member/uniqueMember -\ / V G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 ---member/uniqueMember -> U2 |<--uniquemember-/ | |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ + |<--uniquemember-/ |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + |<--uniquemember-/ """ memofuser1 = _get_user_dn('memofuser1') @@ -2275,7 +2286,7 @@ def test_memberof_MultiGrpAttr_024(topology_st): # ADD user1 as 'member' of grp20_1 mods = [(ldap.MOD_ADD, 'member', memofuser1)] - topology_st.standalone.modify_s(memofegrp020_1, mods) + topology_st.standalone.modify_s(ensure_str(memofegrp020_1), mods) verify_post_024(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5, memofuser1, memofuser2, memofuser3, memofuser4) @@ -2283,12 +2294,12 @@ def test_memberof_MultiGrpAttr_024(topology_st): def verify_post_025(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5, memofuser1, memofuser2, memofuser3, memofuser4): """ - /----member ---> G1 - / + /----member ---> G1 + / G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 - |----member ---> G3 + |----member ---> G3 |----member ---> G4 """ @@ -2318,27 +2329,27 @@ def verify_post_025(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, def test_memberof_MultiGrpAttr_025(topology_st): """ - At the beginning: + At the beginning: /----member ---> G1 ---member/uniqueMember -\ / V G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 ---member/uniqueMember -> U2 |<--uniquemember-/ | |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ + |<--uniquemember-/ |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + |<--uniquemember-/ At the end: - /----member ---> G1 - / + /----member ---> G1 + / G5 ------------------------>member ---------- --->U1 - | + | |----member ---> G2 - |----member ---> G3 + |----member ---> G3 |----member ---> G4 """ @@ -2366,7 +2377,7 @@ def test_memberof_MultiGrpAttr_025(topology_st): (memofegrp020_4, memofuser4)]: mods = [(ldap.MOD_DELETE, 'member', x[1]), (ldap.MOD_DELETE, 'uniqueMember', x[1])] - topology_st.standalone.modify_s(x[0], mods) + topology_st.standalone.modify_s(ensure_str(x[0]), mods) """ /----member ---> G1 / @@ -2383,7 +2394,7 @@ def test_memberof_MultiGrpAttr_025(topology_st): for x in [memofegrp020_2, memofegrp020_3, memofegrp020_4]: mods = [(ldap.MOD_DELETE, 'uniqueMember', memofegrp020_5)] - topology_st.standalone.modify_s(x, mods) + topology_st.standalone.modify_s(ensure_str(x), mods) """ /----member ---> G1 / @@ -2409,7 +2420,7 @@ def test_memberof_auto_add_oc(topology_st): topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', - 'on')]) + b'on')]) except ldap.LDAPError as e: ldap.error('Failed to enable dynamic plugins! ' + e.message['desc']) assert False @@ -2459,7 +2470,7 @@ def test_memberof_auto_add_oc(topology_st): topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_REPLACE, 'memberofAutoAddOC', - 'invalid123')]) + b'invalid123')]) log.fatal('Incorrectly added invalid objectclass!') assert False except ldap.UNWILLING_TO_PERFORM: @@ -2475,7 +2486,7 @@ def test_memberof_auto_add_oc(topology_st): topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_REPLACE, 'memberofAutoAddOC', - 'inetuser')]) + b'inetuser')]) except ldap.LDAPError as e: log.fatal('Failed to configure memberOf plugin: error ' + e.message['desc']) assert False @@ -2528,7 +2539,7 @@ def test_memberof_auto_add_oc(topology_st): topology_st.standalone.modify_s(GROUP_DN, [(ldap.MOD_ADD, 'member', - USER2_DN)]) + ensure_bytes(USER2_DN))]) except ldap.LDAPError as e: log.fatal('Failed to add user2 to group: error ' + e.message['desc']) assert False diff --git a/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py b/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py index af5c4c4d4..4892255dc 100644 --- a/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py +++ b/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py @@ -8,13 +8,14 @@ # import logging import socket - +import ldap import pytest +from lib389.utils import * from lib389.tasks import * from lib389.tools import DirSrvTools from lib389.topologies import topology_st -from lib389._constants import PLUGIN_ROOTDN_ACCESS, DN_CONFIG, DEFAULT_SUFFIX, DN_DM, PASSWORD +from lib389._constants import PLUGIN_ROOTDN_ACCESS, DN_CONFIG, DEFAULT_SUFFIX, DN_DM, PASSWORD, LOCALHOST_IP logging.getLogger(__name__).setLevel(logging.DEBUG) log = logging.getLogger(__name__) @@ -47,10 +48,10 @@ def test_rootdn_init(topology_st): ACI = ('(target ="ldap:///cn=config")(targetattr = "*")(version 3.0' + ';acl "all access";allow (all)(userdn="ldap:///anyone");)') try: - topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_ADD, 'aci', ACI)]) + topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_ADD, 'aci', ensure_bytes(ACI))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_init: Failed to add aci to config: error ' + - e.message['desc']) + log.fatal('test_rootdn_init: Failed to add aci to config: error {}' + .format(e)) assert False # @@ -61,17 +62,17 @@ def test_rootdn_init(topology_st): 'uid': 'user1', 'userpassword': PASSWORD}))) except ldap.LDAPError as e: - log.fatal('test_rootdn_init: Failed to add test user ' + USER1_DN + ': error ' + - e.message['desc']) + log.fatal('test_rootdn_init: Failed to add test user ' + USER1_DN + ': error {}' + .format(e)) assert False # # Enable dynamic plugins # try: - topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')]) + topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_init: Failed to set dynamic plugins: error ' + e.message['desc']) + log.fatal('test_rootdn_init: Failed to set dynamic plugins: error {}'.format(e)) assert False # @@ -99,11 +100,11 @@ def test_rootdn_access_specific_time(topology_st): close_time = '1800' try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', open_time), - (ldap.MOD_ADD, 'rootdn-close-time', close_time)]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', ensure_bytes(open_time)), + (ldap.MOD_ADD, 'rootdn-close-time', ensure_bytes(close_time))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_specific_time: Failed to set (blocking) open/close times: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_specific_time: Failed to set (blocking) open/close times: error {}' + .format(e)) assert False # @@ -129,36 +130,36 @@ def test_rootdn_access_specific_time(topology_st): assert False try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'), - (ldap.MOD_REPLACE, 'rootdn-close-time', '2359')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'), + (ldap.MOD_REPLACE, 'rootdn-close-time', b'2359')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_specific_time: Failed to set (open) open/close times: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_specific_time: Failed to set (open) open/close times: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False # # Cleanup - undo the changes we made so the next test has a clean slate # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-open-time', None), - (ldap.MOD_DELETE, 'rootdn-close-time', None)]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-open-time', ensure_bytes(None)), + (ldap.MOD_DELETE, 'rootdn-close-time', ensure_bytes(None))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_specific_time: Failed to delete open and close time: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_specific_time: Failed to delete open and close time: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False log.info('test_rootdn_access_specific_time: PASSED') @@ -194,10 +195,10 @@ def test_rootdn_access_day_of_week(topology_st): # try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', - deny_days)]) + ensure_bytes(deny_days))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error {}' + .format(e)) assert False # @@ -224,34 +225,34 @@ def test_rootdn_access_day_of_week(topology_st): try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', - allow_days)]) + ensure_bytes(allow_days))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False # # Cleanup - undo the changes we made so the next test has a clean slate # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-days-allowed', None)]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-days-allowed', ensure_bytes(None))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_day_of_week: Failed to set rootDN plugin config: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_day_of_week: Failed to set rootDN plugin config: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False log.info('test_rootdn_access_day_of_week: PASSED') @@ -259,32 +260,32 @@ def test_rootdn_access_day_of_week(topology_st): def test_rootdn_access_denied_ip(topology_st): ''' - Test denied IP feature - we can just test denying 127.0.01 + Test denied IP feature - we can just test denying 127.0.0.1 ''' log.info('Running test_rootdn_access_denied_ip...') - try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', - '127.0.0.1'), + b'127.0.0.1'), (ldap.MOD_ADD, 'rootdn-deny-ip', - '::1')]) + b'::1')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error {}' + .format(e)) assert False # # Bind as Root DN - should fail # try: - topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) + conn = ldap.initialize('ldap://{}:{}'.format(LOCALHOST_IP, topology_st.standalone.port)) + topology_st.standalone.restart() + conn.simple_bind_s(DN_DM, PASSWORD) succeeded = True except ldap.LDAPError as e: succeeded = False - if succeeded: log.fatal('test_rootdn_access_denied_ip: Root DN was incorrectly able to bind') assert False @@ -299,17 +300,17 @@ def test_rootdn_access_denied_ip(topology_st): assert False try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', '255.255.255.255')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', b'255.255.255.255')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False # @@ -318,15 +319,15 @@ def test_rootdn_access_denied_ip(topology_st): try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-deny-ip', None)]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False log.info('test_rootdn_access_denied_ip: PASSED') @@ -343,14 +344,14 @@ def test_rootdn_access_denied_host(topology_st): try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-deny-host', - hostname)]) + ensure_bytes(hostname))]) if localhost != hostname: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-deny-host', - localhost)]) + ensure_bytes(localhost))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_host: Failed to set deny host: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_host: Failed to set deny host: error {}' + .format(e)) assert False # @@ -376,17 +377,17 @@ def test_rootdn_access_denied_host(topology_st): assert False try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', 'i.dont.exist.com')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', b'i.dont.exist.com')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False # @@ -395,15 +396,15 @@ def test_rootdn_access_denied_host(topology_st): try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-deny-host', None)]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False log.info('test_rootdn_access_denied_host: PASSED') @@ -420,10 +421,12 @@ def test_rootdn_access_allowed_ip(topology_st): # Set allowed host to an unknown host - blocks the Root DN # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', '255.255.255.255')]) + conn = ldap.initialize('ldap://{}:{}'.format(LOCALHOST_IP, topology_st.standalone.port)) + topology_st.standalone.restart() + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', b'255.255.255.255')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error {}' + .format(e)) assert False # @@ -449,18 +452,20 @@ def test_rootdn_access_allowed_ip(topology_st): assert False try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', '127.0.0.1'), - (ldap.MOD_ADD, 'rootdn-allow-ip', '::1')]) + #ipv4 = socket.gethostbyname(socket.gethostname()) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', b'127.0.0.1'), + (ldap.MOD_ADD, 'rootdn-allow-ip', b'::1')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error {}' + .format(e)) assert False try: - topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) + #topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) + conn.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False # @@ -469,15 +474,15 @@ def test_rootdn_access_allowed_ip(topology_st): try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-allow-ip', None)]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_ip: Failed to delete(rootdn-allow-ip): error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_ip: Failed to delete(rootdn-allow-ip): error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False log.info('test_rootdn_access_allowed_ip: PASSED') @@ -494,10 +499,10 @@ def test_rootdn_access_allowed_host(topology_st): # Set allowed host to an unknown host - blocks the Root DN # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', 'i.dont.exist.com')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', b'i.dont.exist.com')]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error {}' + .format(e)) assert False # @@ -530,21 +535,21 @@ def test_rootdn_access_allowed_host(topology_st): None)]) topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-allow-host', - localhost)]) + ensure_bytes(localhost))]) if hostname != localhost: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-allow-host', - hostname)]) + ensure_bytes(hostname))]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False # @@ -553,15 +558,15 @@ def test_rootdn_access_allowed_host(topology_st): try: topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-allow-host', None)]) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_host: Failed to delete(rootdn-allow-host): error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_host: Failed to delete(rootdn-allow-host): error {}' + .format(e)) assert False try: topology_st.standalone.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError as e: - log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error ' + - e.message['desc']) + log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error {}' + .format(e)) assert False log.info('test_rootdn_access_allowed_host: PASSED') @@ -583,39 +588,39 @@ def test_rootdn_config_validate(topology_st): # Test rootdn-open-time # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to just add "rootdn-open-time" ') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', '0000'), - (ldap.MOD_ADD, 'rootdn-open-time', '0001')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', b'0000'), + (ldap.MOD_ADD, 'rootdn-open-time', b'0001')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add multiple "rootdn-open-time"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '-1'), - (ldap.MOD_REPLACE, 'rootdn-close-time', '0000')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'-1'), + (ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-open-time: -1"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '2400'), - (ldap.MOD_REPLACE, 'rootdn-close-time', '0000')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'2400'), + (ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-open-time: 2400"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', 'aaaaa'), - (ldap.MOD_REPLACE, 'rootdn-close-time', '0000')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'aaaaa'), + (ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-open-time: aaaaa"') assert False except ldap.LDAPError: @@ -625,39 +630,39 @@ def test_rootdn_config_validate(topology_st): # Test rootdn-close-time # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-close-time', '0000')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add just "rootdn-close-time"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-close-time', '0000'), - (ldap.MOD_ADD, 'rootdn-close-time', '0001')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-close-time', b'0000'), + (ldap.MOD_ADD, 'rootdn-close-time', b'0001')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add multiple "rootdn-open-time"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'), - (ldap.MOD_REPLACE, 'rootdn-close-time', '-1')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'), + (ldap.MOD_REPLACE, 'rootdn-close-time', b'-1')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-close-time: -1"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'), - (ldap.MOD_REPLACE, 'rootdn-close-time', '2400')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'), + (ldap.MOD_REPLACE, 'rootdn-close-time', b'2400')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-close-time: 2400"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'), - (ldap.MOD_REPLACE, 'rootdn-close-time', 'aaaaa')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'), + (ldap.MOD_REPLACE, 'rootdn-close-time', b'aaaaa')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-close-time: aaaaa"') assert False except ldap.LDAPError: @@ -667,36 +672,36 @@ def test_rootdn_config_validate(topology_st): # Test days allowed # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-days-allowed', 'Mon'), - (ldap.MOD_ADD, 'rootdn-days-allowed', 'Tue')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-days-allowed', b'Mon'), + (ldap.MOD_ADD, 'rootdn-days-allowed', b'Tue')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add two "rootdn-days-allowed"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'Mon1')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'Mon1')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: Mon1"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'Tue, Mon1')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'Tue, Mon1')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: Tue, Mon1"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'm111m')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'm111m')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: 111"') assert False except ldap.LDAPError: pass try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'Gur')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'Gur')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: Gur"') assert False except ldap.LDAPError: @@ -706,7 +711,7 @@ def test_rootdn_config_validate(topology_st): # Test allow ips # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', '12.12.Z.12')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', b'12.12.Z.12')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-allow-ip: 12.12.Z.12"') assert False except ldap.LDAPError: @@ -716,7 +721,7 @@ def test_rootdn_config_validate(topology_st): # Test deny ips # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', '12.12.Z.12')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', b'12.12.Z.12')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-deny-ip: 12.12.Z.12"') assert False except ldap.LDAPError: @@ -726,7 +731,7 @@ def test_rootdn_config_validate(topology_st): # Test allow hosts # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', 'host._.com')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', b'host._.com')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-allow-host: host._.com"') assert False except ldap.LDAPError: @@ -736,7 +741,7 @@ def test_rootdn_config_validate(topology_st): # Test deny hosts # try: - topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', 'host.####.com')]) + topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', b'host.####.com')]) log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-deny-host: host.####.com"') assert False except ldap.LDAPError: diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py index 71cf359d3..f416c3e25 100644 --- a/src/lib389/lib389/_constants.py +++ b/src/lib389/lib389/_constants.py @@ -88,6 +88,7 @@ DIRSRV_STATE_ONLINE = 5 # So uh .... localhost.localdomain doesn't always exist. Stop. Using. It. # LOCALHOST = "localhost.localdomain" +LOCALHOST_IP = "127.0.0.1" LOCALHOST = "localhost" LOCALHOST_SHORT = "localhost" DEFAULT_PORT = 389
0
6377bc78ca09ab1a5478f62bc6ea9bd76cf6191f
389ds/389-ds-base
Ticket 50627 - Support platforms without pytest_html Bug Description: On systems without pytest_html the conftest hook would cause tests to fail Fix Description: If pytest_html is none, don't write the report to avoid the failure. Fixes: https://pagure.io/389-ds-base/issue/50627 Author: William Brown <[email protected]> Review by: vashirov
commit 6377bc78ca09ab1a5478f62bc6ea9bd76cf6191f Author: William Brown <[email protected]> Date: Thu Oct 10 11:47:45 2019 +1000 Ticket 50627 - Support platforms without pytest_html Bug Description: On systems without pytest_html the conftest hook would cause tests to fail Fix Description: If pytest_html is none, don't write the report to avoid the failure. Fixes: https://pagure.io/389-ds-base/issue/50627 Author: William Brown <[email protected]> Review by: vashirov diff --git a/dirsrvtests/conftest.py b/dirsrvtests/conftest.py index 8c0d65feb..f8710b308 100644 --- a/dirsrvtests/conftest.py +++ b/dirsrvtests/conftest.py @@ -94,7 +94,7 @@ def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() extra = getattr(report, 'extra', []) - if report.when == 'call': + if report.when == 'call' and pytest_html is not None: for f in glob.glob(f'{p.run_dir}/ns-slapd-*san*'): with open(f) as asan_report: text = asan_report.read()
0
b695fa9ed8382432f4863d68ad8501a862d65ff5
389ds/389-ds-base
Resolves: bug 232910 Description: ACI targetattr list parser is whitespace sensitive Fix Description: In addition to the previous fixes, test for quote at end of string before incrementing s - otherwise test will always fail.
commit b695fa9ed8382432f4863d68ad8501a862d65ff5 Author: Rich Megginson <[email protected]> Date: Fri Oct 19 22:14:56 2007 +0000 Resolves: bug 232910 Description: ACI targetattr list parser is whitespace sensitive Fix Description: In addition to the previous fixes, test for quote at end of string before incrementing s - otherwise test will always fail. diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c index 70def8d9e..86a609256 100644 --- a/ldap/servers/plugins/acl/aclparse.c +++ b/ldap/servers/plugins/acl/aclparse.c @@ -1239,16 +1239,16 @@ __aclp__init_targetattr (aci_t *aci, char *attr_val) if it begins with a quote, it must end with one as well */ if (*s == '"') { + if (s[len-1] == '"') { + s[len-1] = '\0'; /* trim trailing quote */ + } else { + /* error - if it begins with a quote, it must end with a quote */ + slapi_log_error(SLAPI_LOG_FATAL, plugin_name, + "__aclp__init_targetattr: Error: The statement does not begin and end with a \": [%s]\n", + attr_val); + return ACL_SYNTAX_ERR; + } s++; /* skip leading quote */ - if (s[len-1] == '"') { - s[len-1] = '\0'; /* trim trailing quote */ - } else { - /* error - if it begins with a quote, it must end with a quote */ - slapi_log_error(SLAPI_LOG_FATAL, plugin_name, - "__aclp__init_targetattr: Error: The statement does not begin and end with a \": [%s]\n", - attr_val); - return ACL_SYNTAX_ERR; - } } str = s;
0
6be23ba8b516f965a7ddadecbf9d25c513085d32
389ds/389-ds-base
Bug 630094 - (cov#15451) Get rid of unreachable free statements We need to remove the last "if (dnParts)" condition since it will never be true. The last frees of newDN, sval, and newvalue are also unnecessary since they are only set in the non subtree rename case, where they are already freed as well.
commit 6be23ba8b516f965a7ddadecbf9d25c513085d32 Author: Nathan Kinder <[email protected]> Date: Wed Sep 8 14:16:38 2010 -0700 Bug 630094 - (cov#15451) Get rid of unreachable free statements We need to remove the last "if (dnParts)" condition since it will never be true. The last frees of newDN, sval, and newvalue are also unnecessary since they are only set in the non subtree rename case, where they are already freed as well. diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c index 3ef9de6b8..32249e934 100644 --- a/ldap/servers/plugins/referint/referint.c +++ b/ldap/servers/plugins/referint/referint.c @@ -490,15 +490,6 @@ _update_one_per_mod(const char *entryDN, /* DN of the searched entry */ slapi_ch_free_string(&newDN); } - /* in case these memories have not freed */ - slapi_ch_free_string(&newvalue); - slapi_ch_free_string(&sval); - if (dnParts){ - slapi_ldap_value_free(dnParts); - dnParts = NULL; - } - slapi_ch_free_string(&newDN); - return rc; }
0