commit_id
string | repo
string | commit_message
string | diff
string | label
int64 |
---|---|---|---|---|
57f47a857e5719bd99844a087accea63ecdfbae4
|
389ds/389-ds-base
|
Bug(s) fixed: 186280
Bug Description: Close potential security vulnerabilities in CGI code - dsgw get/post arguments
Reviewed by: Noriko and Nathan (Thanks!)
Fix Description: Fortunately, the code was pretty clean already. There
were just a few places I needed to add some file or path name checking.
I also got rid of some code.
Platforms tested: Fedora Core 5
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
|
commit 57f47a857e5719bd99844a087accea63ecdfbae4
Author: Rich Megginson <[email protected]>
Date: Mon May 22 17:28:36 2006 +0000
Bug(s) fixed: 186280
Bug Description: Close potential security vulnerabilities in CGI code - dsgw get/post arguments
Reviewed by: Noriko and Nathan (Thanks!)
Fix Description: Fortunately, the code was pretty clean already. There
were just a few places I needed to add some file or path name checking.
I also got rid of some code.
Platforms tested: Fedora Core 5
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/clients/dsgw/Makefile b/ldap/clients/dsgw/Makefile
index 8eaf69f91..037b1f8d8 100644
--- a/ldap/clients/dsgw/Makefile
+++ b/ldap/clients/dsgw/Makefile
@@ -186,9 +186,6 @@ else
NEED_SECGLUE_BINS = $(addprefix $(BINDIR)/, $(addsuffix .exe, $(NEED_SECGLUE)))
endif
-NOTSHIPPINGPROGS= browse browsesrch templateindex
-NOTSHIPPINGBINS= $(addprefix $(BINDIR)/, $(NOTSHIPPINGPROGS))
-
CKUTILPROGS= ckput ckget ckdump ckpurge ckdel
CKUTILBINS= $(addprefix $(BINDIR)/, $(CKUTILPROGS))
@@ -212,10 +209,10 @@ NOSSLCOMMONOBJSREL=$(addprefix ../obj/, $(NOSSLCMNOBJS))
SCGLOBJS= secglue.o
SECGLUEOBJS=$(addprefix $(OBJDEST)/, $(SCGLOBJS))
-ALLOBJS = dosearch.o search.o csearch.o browse.o browsesrch.o templateindex.o \
+ALLOBJS = dosearch.o search.o csearch.o \
auth.o doauth.o unauth.o ckput.o ckget.o ckdump.o ckpurge.o ckdel.o \
- edit.o domodify.o newentry.o genscreen.o tutor.o dnedit.o \
- dsconfig.o dsimpldif.o dsexpldif.o lang.o utf8compare.o \
+ edit.o domodify.o newentry.o tutor.o dnedit.o \
+ lang.o utf8compare.o \
$(COMMONOBJS) $(SECGLUEOBJS)
INCLUDES= -I$(SDKHDIR) -I$(NSCP_DISTDIR)/include $(ICU_INCLUDE) -I$(ADMINUTIL_INCPATH)
@@ -231,15 +228,13 @@ CFLAGS += $(INCLUDES) $(DEFINES) $(ACFLAGS)
ifeq ($(ARCH), WINNT)
PROGBINS = $(addsuffix .exe, $(BINS))
-NOTSHIPPINGPROGBINS = $(addsuffix .exe, $(NOTSHIPPINGBINS))
CKUTILPROGBINS = $(addsuffix .exe, $(CKUTILBINS))
else
PROGBINS = $(BINS)
-NOTSHIPPINGPROGBINS = $(NOTSHIPPINGBINS)
CKUTILPROGBINS = $(CKUTILBINS)
endif
-ALLBINS= $(PROGBINS) $(NOTSHIPPINGPROGBINS) $(CKUTILPROGBINS)
+ALLBINS= $(PROGBINS) $(CKUTILPROGBINS)
## make sure there's prog.exe and prog for NT. Weak, but ES
## only works with prog, and AS needs both.
@@ -282,8 +277,6 @@ all-config:
ckutils: $(CKUTILPROGBINS)
-notshipping: $(NOTSHIPPINGPROGBINS)
-
$(LDAP_LIBLDBM_DEP):
cd $(LDAP_SRC)/libraries; $(MAKE) $(MFLAGS) clientSDK
diff --git a/ldap/clients/dsgw/config.c b/ldap/clients/dsgw/config.c
index 346f91f90..9113572d9 100644
--- a/ldap/clients/dsgw/config.c
+++ b/ldap/clients/dsgw/config.c
@@ -78,7 +78,6 @@ static void add_l10nset( dsgwsubst **l10np, char **argv );
static void read_dsgwconfig( char *filename, char *locsuffix,
int templatesonly, int binddnfile );
static void get_dbconf_properties( char *filename );
-static int write_dbswitch_info( FILE *fp, dsgwconfig *cfgp, char *dbhandle );
static int ldapdb_url_parse( char *url, LDAPDBURLDesc **ldbudpp );
static int dsgw_valid_context();
static int browser_is_msie40();
@@ -863,144 +862,6 @@ read_dsgwconfig( char *filename, char *locsuffix, int templatesonly, int binddnf
}
}
-int
-erase_db() {
-
- FILE *fp;
- int rc, lineno;
- char *line;
- char *cargv[ MAXARGS ];
- int cargc;
- char cmd[ BIG_LINE ];
-
- if ( (fp = fopen( gc->gc_localdbconf, "r" )) == NULL ) {
- dsgw_emitf (XP_GetClientStr(DBT_EraseDbCouldNotOpenLcacheConfFil_),
- gc->gc_localdbconf);
- return( -1 );
- }
- fp_getline_init( &lineno );
-
- while ( (line = fp_getline( fp, &lineno )) != NULL ) {
- fp_parse_line( line, &cargc, cargv );
- if ( strcasecmp( cargv[0], "directory" ) == 0) {
-#ifdef XP_WIN32
- dsgw_unix2dospath( cargv[1] );
-#endif
- PR_snprintf (cmd, BIG_LINE, "%s %s%c* > %s 2>&1", DSGW_DELETE_CMD, cargv[1],
- DSGW_PATHSEP_CHAR, DSGW_NULL_DEVICE);
- fflush (0);
- if (system (cmd) == 0) {
- /*
- * success: display status message
- */
- dsgw_emits( XP_GetClientStr(DBT_FontSize1NPTheDatabaseHasBeenDel_) );
- rc = 0;
- }
- else {
- dsgw_emits( XP_GetClientStr(DBT_FontSize1NPTheDatabaseCouldNotBe_) );
- rc = -1;
- }
-
- dsgw_emits( "<HR>\n" );
- fclose( fp );
- return( rc );
- }
- }
- return -1;
-}
-
-void
-app_suffix (char *ldif, char *suffix)
-{
- FILE *oldfp, *newfp;
- char *orig_line;
- char *p;
- char buf[BUFSIZ];
- int i, cargc;
- char *cargv[ 100 ];
- char tmpldif[ 128 ];
- char *dns[] = { "aliasedobjectname:",
- "aliasedobjectname:",
- "associatedname:",
- "dependentupon:",
- "ditredirect:",
- "dn:",
- "documentauthor:",
- "documentauthor:",
- "documentavailable:",
- "errorsto:",
- "errorsto:",
- "imagefiles:",
- "lastmodifiedby:",
- "manager:",
- "member:",
- "memberofgroup:",
- "naminglink:",
- "naminglink:",
- "obsoletedbydocument:",
- "obsoletesdocument:",
- "owner:",
- "proxy:",
- "reciprocalnaminglink:",
- "reciprocalnaminglink:",
- "replicaroot:",
- "replicabinddn:",
- "requeststo:",
- "roleoccupant:",
- "secretary:",
- "seealso:",
- "uniqueMember:",
- "updatedbydocument:",
- "updatesdocument:",
- NULL
- };
-
-
- if ( (oldfp = fopen( ldif, "r" )) == NULL ) {
- dsgw_emitf (XP_GetClientStr(DBT_AppSuffixCouldNotOpenLdifFileSN_),
- ldif);
- return;
- }
-
- PR_snprintf( tmpldif, sizeof(tmpldif), "%s.tmp", ldif);
- if ( (newfp = fopen( tmpldif, "w" )) == NULL ) {
- dsgw_emitf (XP_GetClientStr(DBT_AppSuffixCouldNotOpenTmpFileSN_),
- ldif);
- return;
- }
- while ( fgets( buf, sizeof(buf), oldfp ) != NULL ) {
- /* skip comments and blank lines */
- if ( buf[0] == '#' || buf[0] == '\0' || buf[0] == '\n') {
- fputs( buf, newfp );
- continue;
- }
- orig_line = dsgw_ch_strdup( buf );
-
- fp_parse_line( buf, &cargc, cargv );
- for (i=0; dns[i]!=NULL; i++) {
- if ( strcasecmp( cargv[0], dns[i] ) == 0 ) {
- if ( (p = strchr( orig_line, '\n' )) != NULL ) {
- *p = '\0';
- }
- fprintf ( newfp, "%s, %s\n", orig_line, suffix );
- break;
- }
- }
-
- if ( dns[i] == NULL ) {
- fputs( orig_line, newfp );
- }
- free (orig_line);
- }
- fclose(newfp);
- fclose(oldfp);
- unlink( ldif );
- if ( rename( tmpldif, ldif ) != 0 ) {
- dsgw_emitf (XP_GetClientStr(DBT_unableToRenameSToS_), tmpldif, ldif );
- return;
- }
-}
-
/*
* Running under admserv - traverse the list of property/value pairs
* returned by dbconf_read_default_dbinfo().
@@ -1130,190 +991,6 @@ get_dbconf_properties( char *filename )
return;
}
-
-/*
- * Update the dbswitch.conf file (used under admin. server) to reflect
- * the local/remote directory information contained in "cfgp". Our basic
- * strategy is to read the existing dbswitch.conf file, replacing and adding
- * lines that look like this:
- * directory <dbhandle> ...
- * <dbhandle>:binddn ...
- * <dbhandle>:encoded bindpw ...
- * as necessary. We write a new, temporary config file (copying all other
- * lines over unchanged) and then replace the old file with our new one.
- *
- * If cfgp is configured for localdb mode, we only write a directory line.
- *
- * We return zero if all goes well and non-zero if not.
- *
- * Note that all reading and writing of the dbswitch.conf file is now done
- * using the dbconf...() functions that are part of the ldaputil library, so
- * any comments, blank lines, or unrecognized config file lines will be lost.
- * Also, all "bindpw" property values will be encoded when re-written.
- *
- * Only these members of the cfgp structure are used in this function:
- * gc_localdbconf (NULL if using remote LDAP server)
- * gc_ldapsearchbase
- * gc_ldapserver
- * gc_ldapport
- * gc_ldapssl
- * gc_binddn
- * gc_bindpw
- * Actually, if gc_localdbconf is not NULL, only it and gc_ldapsearchbase are
- * used.
- */
-int
-dsgw_update_dbswitch( dsgwconfig *cfgp, char *dbhandle, int erropts )
-{
- char oldfname[ MAXPATHLEN ], newfname[ MAXPATHLEN ];
- char *userdb_path, buf[ MAXPATHLEN + 100 ];
- int rc, wrote_dbinfo;
- FILE *newfp;
- DBConfInfo_t *cip;
- DBConfDBInfo_t *dbip;
- DBPropVal_t *pvp;
-
- if ( dbhandle == NULL ) {
- dbhandle = "default";
- }
-
- if (( userdb_path = get_userdb_dir()) == NULL ) {
- dsgw_error( DSGW_ERR_USERDB_PATH, NULL, erropts, 0, NULL );
- return( -1 );
- }
-
- /* read old dbswitch.conf contents */
- PR_snprintf( oldfname, sizeof(oldfname), "%s/%s", userdb_path,
- DSGW_DBSWITCH_FILE );
- if (( rc = dbconf_read_config_file( oldfname, &cip )) != LDAPU_SUCCESS ) {
- report_ldapu_error( rc, DSGW_ERR_BADCONFIG, erropts );
- return( -1 );
- }
-
- /* write db info to new file, replacing information for "dbhandle" */
- PR_snprintf( newfname, sizeof(newfname), "%s/%s", userdb_path,
- DSGW_DBSWITCH_TMPFILE );
- if (( newfp = fopen( newfname, "w" )) == NULL ) {
- PR_snprintf( buf, sizeof(buf),
- XP_GetClientStr(DBT_cannotOpenConfigFileSForWritingN_), newfname );
- dsgw_error( DSGW_ERR_UPDATE_DBSWITCH, buf, erropts, 0, NULL );
- return( -1 );
- }
-
- wrote_dbinfo = 0;
- for ( dbip = cip->firstdb; dbip != NULL; dbip = dbip->next ) {
- if ( strcasecmp( dbip->dbname, dbhandle ) == 0 ) {
- /*
- * found db name to be replaced: replace with updated information
- */
- if (( rc = write_dbswitch_info( newfp, cfgp, dbhandle )) !=
- LDAPU_SUCCESS ) {
- report_ldapu_error( rc, DSGW_ERR_UPDATE_DBSWITCH, erropts );
- return( -1 );
- }
-
- wrote_dbinfo = 1;
-
- } else {
- /*
- * re-write existing db conf information without changes
- */
- if (( rc = dbconf_output_db_directive( newfp, dbip->dbname,
- dbip->url )) != LDAPU_SUCCESS ) {
- report_ldapu_error( rc, DSGW_ERR_UPDATE_DBSWITCH, erropts );
- return( -1 );
- }
-
- for ( pvp = dbip->firstprop; pvp != NULL; pvp = pvp->next ) {
- if (( rc = dbconf_output_propval( newfp, dbip->dbname,
- pvp->prop, pvp->val,
- strcasecmp( pvp->prop, "bindpw" ) == 0 ))
- != LDAPU_SUCCESS ) {
- report_ldapu_error( rc, DSGW_ERR_UPDATE_DBSWITCH, erropts );
- return( -1 );
- }
- }
- }
- }
-
- if ( !wrote_dbinfo ) {
- if (( rc = write_dbswitch_info( newfp, cfgp, dbhandle )) !=
- LDAPU_SUCCESS ) {
- report_ldapu_error( rc, DSGW_ERR_UPDATE_DBSWITCH, erropts );
- return( -1 );
- }
- }
-
- dbconf_free_confinfo( cip );
- fclose( newfp );
-
- /* replace old file with new one */
-#ifdef _WIN32
- if ( !MoveFileEx( newfname, oldfname, MOVEFILE_REPLACE_EXISTING )) {
-#else
- if ( rename( newfname, oldfname ) != 0 ) {
-#endif
- PR_snprintf( buf, MAXPATHLEN + 100,
- XP_GetClientStr(DBT_unableToRenameSToS_1), newfname, oldfname );
- dsgw_error( DSGW_ERR_UPDATE_DBSWITCH, buf, erropts, 0, NULL );
- return( -1 );
- }
-
- return( 0 );
-}
-
-
-static int
-write_dbswitch_info( FILE *fp, dsgwconfig *cfgp, char *dbhandle )
-{
- char *escapeddn, *url;
- int rc;
-
- escapeddn = dsgw_strdup_escaped( cfgp->gc_ldapsearchbase );
-
- if ( cfgp->gc_localdbconf == NULL ) { /* remote server: write ldap:// URL */
- url = dsgw_ch_malloc( 21 + strlen( cfgp->gc_ldapserver )
- + strlen( escapeddn )); /* room for "ldaps://HOST:PORT/DN" */
- sprintf( url, "ldap%s://%s:%d/%s",
-#ifdef DSGW_NO_SSL
- "",
-#else
- cfgp->gc_ldapssl ? "s" : "",
-#endif
- cfgp->gc_ldapserver, cfgp->gc_ldapport, escapeddn );
- } else { /* local db: write ldapdb:// URL */
- url = dsgw_ch_malloc( 11 + strlen( cfgp->gc_localdbconf )
- + strlen( escapeddn )); /* room for "ldapdb://PATH/DN" */
- sprintf( url, "ldapdb://%s/%s\n", cfgp->gc_localdbconf, escapeddn );
- }
-
- rc = dbconf_output_db_directive( fp, dbhandle, url );
-
- free( url );
- free( escapeddn );
-
- if ( rc != LDAPU_SUCCESS ) {
- return( rc );
- }
-
- if ( cfgp->gc_localdbconf == NULL ) { /* using directory server */
- if ( cfgp->gc_binddn != NULL &&
- ( rc = dbconf_output_propval( fp, dbhandle, "binddn",
- cfgp->gc_binddn, 0 ) != LDAPU_SUCCESS )) {
- return( rc );
- }
-
- if ( cfgp->gc_bindpw != NULL &&
- ( rc = dbconf_output_propval( fp, dbhandle, "bindpw",
- cfgp->gc_bindpw, 1 ) != LDAPU_SUCCESS )) {
- return( rc );
- }
- }
-
- return( LDAPU_SUCCESS );
-}
-
-
/* pass 0 for lineno if it is unknown or not applicable */
static void
adderr( dsgwconfig *gc, char *str, char *filename, int lineno )
@@ -1858,11 +1535,17 @@ dsgw_valid_docname(char *filename)
if (!ldap_utf8isalnum(local_filename)) {
/*If it's a dot, and there haven't been any other dots...*/
- if (*local_filename == '.' && dots == 0) {
- /*Then increment the dot count and continue...*/
- dots ++;
- continue;
- }
+ /* ... but disallow a dot as the first char */
+ if (*local_filename == '.') {
+ if (local_filename == filename) {
+ return (0); /* illegal - filename begins with . */
+ }
+ if (dots == 0) {
+ /*Then increment the dot count and continue...*/
+ dots ++; /* contains a . somewhere e.g. foo.html */
+ continue;
+ }
+ }
/*Allow dashes and underscores*/
if (*local_filename == '-' || *local_filename == '_') {
diff --git a/ldap/clients/dsgw/domodify.c b/ldap/clients/dsgw/domodify.c
index 6ff484039..75d2c5e30 100644
--- a/ldap/clients/dsgw/domodify.c
+++ b/ldap/clients/dsgw/domodify.c
@@ -130,19 +130,6 @@ post_request()
quiet = dsgw_get_boolean_var( "quiet", DSGW_CGIVAR_OPTIONAL, 0 );
-#if 0
- /*
- * If the "genscreen" form variable is set, it is the name of a
- * genscreen-compatible HTML template to display the domodify results
- * within. We replace the "DS_LAST_OP_INFO" directive with our own
- * "domodify" output. Presence of "genscreen" also turns on quiet mode.
- */
- if (( s = dsgw_get_cgi_var( "genscreen", DSGW_CGIVAR_OPTIONAL )) != NULL &&
- dsgw_genscreen_begin( s, &genfp, DRCT_DS_LAST_OP_INFO, 0 ) == 0 ) {
- quiet = display_results_inline = 1;
- }
-#endif
-
verbose = dsgw_get_boolean_var( "verbose", DSGW_CGIVAR_OPTIONAL, 0 );
if ( verbose ) {
quiet = 0; /* verbose overrides quiet */
@@ -392,18 +379,9 @@ post_request()
dsgw_emits( "\n</TABLE></CENTER></FORM>\n" );
}
-#if 0
- if ( display_results_inline && genfp != NULL ) {
- dsgw_emits( "<HR>\n" );
- dsgw_genscreen_continue( &genfp, NULL, 0 );
- } else if ( !quiet ) {
- dsgw_html_end();
- }
-#else
if ( !quiet ) {
dsgw_html_end();
}
-#endif
ldap_unbind( ld );
if (old_dn != dn) free ( old_dn );
free( dn );
diff --git a/ldap/clients/dsgw/dsconfig.c b/ldap/clients/dsgw/dsconfig.c
deleted file mode 100644
index 2aef34fb4..000000000
--- a/ldap/clients/dsgw/dsconfig.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/** --- 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) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- --- END COPYRIGHT BLOCK --- */
-/*
- * dsconfig.c -- CGI configuration update handler -- directory gateway
- */
-
-#include "dsgw.h"
-
-static void handle_request( int reqmethod );
-static void handle_post();
-
-
-main( argc, argv, env )
- int argc;
- char *argv[];
-#ifdef DSGW_DEBUG
- char *env[];
-#endif
-{
- int reqmethod;
-
- context= dsgw_ch_strdup("pb");
- /*CHANGE THIS*/
-
- reqmethod = dsgw_init( argc, argv, DSGW_METHOD_POST | DSGW_METHOD_GET );
- dsgw_send_header();
-
-#ifdef DSGW_DEBUG
- dsgw_logstringarray( "env", env );
-#endif
-
- handle_request( reqmethod );
-
- exit( 0 );
-}
-
-
-#define DSGWCONFIG_EMPTY_IF_NULL( s ) ( (s) == NULL ? "" : (s) )
-
-
-static void
-handle_request( int reqmethod )
-{
- FILE *fp;
- char **argv, *buf, line[ BIG_LINE ];
- char *checked = " CHECKED ", *qs = NULL;
- char *str_valuefmt = " VALUE=\"%s\" ";
- char *int_valuefmt = " VALUE=\"%d\" ";
- int did_post, argc, switch_mode = 0, is_localdb = 0;
-
- buf = dsgw_ch_malloc( strlen( progname ) + 6 ); /* room for ".html\0" */
- sprintf( buf, "%s.html", progname );
- fp = dsgw_open_html_file( buf, DSGW_ERROPT_EXIT );
- free( buf );
- did_post = 0;
- qs = getenv( "QUERY_STRING" );
- if (( reqmethod == DSGW_METHOD_GET ) && ( qs != NULL ) &&
- !strcasecmp( qs, "CHANGE" )) {
- switch_mode = 1;
- }
-
- is_localdb = gc->gc_localdbconf != NULL;
-
- while ( dsgw_next_html_line( fp, line )) {
- if ( dsgw_parse_line( line, &argc, &argv, 0, dsgw_simple_cond_is_true,
- NULL )) {
- if ( dsgw_directive_is( line, DRCT_DS_INLINE_POST_RESULTS )) {
- if ( !did_post && reqmethod == DSGW_METHOD_POST ) {
- handle_post();
- did_post = 1;
- /* We re-read the config file, so re-calculate is_localdb */
- is_localdb = ( gc->gc_localdbconf != NULL );
- }
-
- } else if ( dsgw_directive_is( line, DRCT_DS_CHECKED_IF_LOCAL )) {
- if (( is_localdb && !switch_mode ) ||
- ( !is_localdb && switch_mode )) {
- dsgw_emits( checked );
- }
-
- } else if ( dsgw_directive_is( line, DRCT_DS_CONFIG_INFO )) {
- dsgw_emits( "<FONT SIZE=\"+1\"><B>" );
- if (( is_localdb && !switch_mode ) ||
- ( !is_localdb && switch_mode )) {
- dsgw_emits( "Local Directory Configuration" );
- } else {
- dsgw_emits( "LDAP Directory Server Configuration" );
- }
- dsgw_emits( "</FONT>\n" );
-
- } else if ( dsgw_directive_is( line, DRCT_DS_CHECKED_IF_REMOTE )) {
- if (( !is_localdb && !switch_mode ) ||
- ( is_localdb && switch_mode )) {
- dsgw_emits( checked );
- }
-
- } else if ( dsgw_directive_is( line, DRCT_DS_HOSTNAME_VALUE ) &&
- (( !is_localdb && !switch_mode ) ||
- ( is_localdb && switch_mode ))) {
- dsgw_emits( "<TR>\n<TD ALIGN=\"right\" NOWRAP><B>Host Name:</B></TD>"
- "<TD><INPUT TYPE=\"text\" NAME=\"host\"" );
- dsgw_emitf( str_valuefmt,
- DSGWCONFIG_EMPTY_IF_NULL( gc->gc_ldapserver ));
- dsgw_emits( "SIZE=40></TD>\n</TR>\n\n" );
-
- } else if ( dsgw_directive_is( line, DRCT_DS_PORT_VALUE ) &&
- (( !is_localdb && !switch_mode ) ||
- ( is_localdb && switch_mode ))) {
- dsgw_emits( "<TR>\n<TD ALIGN=\"right\" NOWRAP><B>Port:</B></TD>\n"
- "<TD><INPUT TYPE=\"text\" NAME=\"port\" " );
- if ( !is_localdb ) {
- dsgw_emitf( int_valuefmt, gc->gc_ldapport );
- }
- dsgw_emits( "SIZE=5></TD>\n</TR>\n\n" );
-
-
-#ifndef DSGW_NO_SSL
- } else if ( dsgw_directive_is( line, DRCT_DS_SSL_CONFIG_VALUE ) &&
- (( !is_localdb && !switch_mode ) ||
- ( is_localdb && switch_mode ))) {
- dsgw_emits( "<TR>\n<TD ALIGN=\"right\" NOWRAP>\n"
- "<B>Use Secure<BR>Sockets Layer (SSL)<BR>for "
- "connections?:</B></TD>\n"
- "<TD><INPUT TYPE=\"radio\" NAME=\"ssl\" "
- "VALUE=\"true\" onClick=\"selectedSSL(true)\"" );
- if ( gc->gc_ldapssl ) {
- dsgw_emits( checked );
- }
- dsgw_HTML_emits( ">Yes" DSGW_UTF8_NBSP "\n<INPUT TYPE=\"radio\" NAME=\"ssl\" "
- "VALUE=\"false\" onClick=\"selectedSSL(false)\"" );
- if ( !gc->gc_ldapssl ) {
- dsgw_emits( checked );
- }
- dsgw_emits( ">No\n</TD>\n</TR>\n\n" );
-#endif
-
- } else if ( dsgw_directive_is( line, DRCT_DS_BASEDN_VALUE )) {
- dsgw_emits( "<TR>\n<TD ALIGN=\"right\" NOWRAP><B>Base DN" );
- if (( is_localdb && !switch_mode ) ||
- ( !is_localdb && switch_mode )) {
- dsgw_emits( " (optional)" );
- }
- dsgw_emits( ":</B></TD>\n<TD><INPUT TYPE=\"text\" "
- "NAME=\"basedn\" " );
- dsgw_emitf( str_valuefmt,
- DSGWCONFIG_EMPTY_IF_NULL( gc->gc_ldapsearchbase ));
- dsgw_emits( "SIZE=50></TD>\n</TR>\n\n" );
-
- } else if ( dsgw_directive_is( line, DRCT_DS_BINDDN_VALUE ) &&
- (( !is_localdb && !switch_mode ) ||
- ( is_localdb && switch_mode ))) {
- dsgw_emits( "<TR>\n<TD ALIGN=\"right\" NOWRAP><B>"
- "Bind DN (optional):</B></TD>\n"
- "<TD><INPUT TYPE=\"text\" NAME=\"binddn\" " );
- if ( gc->gc_binddn == NULL || strlen( gc->gc_binddn ) == 0 ) {
- dsgw_emits( "VALUE=\"\"" );
- } else {
- dsgw_emitf( "VALUE=\"%s\" ", gc->gc_binddn );
- }
- dsgw_emits( " SIZE=50></TD>\n</TR>\n\n" );
-
- } else if ( dsgw_directive_is( line, DRCT_DS_BINDPASSWD_VALUE ) &&
- (( !is_localdb && !switch_mode ) ||
- ( is_localdb && switch_mode ))) {
- dsgw_emits( "<TR>\n<TD ALIGN=\"right\" NOWRAP><B>"
- "Bind Password (optional):</B></TD>\n"
- "<TD><INPUT TYPE=\"password\" NAME=\"bindpw\" " );
- if ( gc->gc_bindpw != NULL && ( strlen( gc->gc_bindpw ) > 0 )) {
- dsgw_emitf( str_valuefmt, gc->gc_bindpw );
- }
- dsgw_emits( "SIZE=20></TD>\n</TR>\n\n" );
- } else if ( dsgw_directive_is( line, DRCT_DS_NOCERTFILE_WARNING )
- && ( gc->gc_securitypath == NULL )
- && !is_localdb && gc->gc_ldapssl && argc > 0 ) {
- /*
- * using LDAP over SSL but no CertFile in ns-admin.conf:
- * show a warning message
- */
- dsgw_emits( argv[ 0 ] );
- }
- }
- }
-
- fclose( fp );
-}
-
-
-static void
-handle_post()
-{
- char *dirsvctype, *dbhandle;
- dsgwconfig cfg;
-
- memset( &cfg, 0, sizeof( cfg ));
-
- dirsvctype = dsgw_get_cgi_var( "dirsvctype", DSGW_CGIVAR_REQUIRED );
- dbhandle = dsgw_get_cgi_var( "dbhandle", DSGW_CGIVAR_OPTIONAL );
- cfg.gc_ldapsearchbase = dsgw_get_cgi_var( "basedn", DSGW_CGIVAR_OPTIONAL );
-
- if ( strcasecmp( dirsvctype, "local" ) == 0 ) {
- char *userdb_path;
-
- if (( userdb_path = get_userdb_dir()) == NULL ) {
- dsgw_error( DSGW_ERR_USERDB_PATH, NULL, DSGW_ERROPT_INLINE, 0,
- NULL );
- return;
- }
- cfg.gc_localdbconf = dsgw_ch_malloc( strlen( userdb_path ) +
- strlen( DSGW_LCACHECONF_PPATH ) +
- strlen( DSGW_LCACHECONF_FILE ) + 2 );
- sprintf( cfg.gc_localdbconf, "%s/%s%s", userdb_path,
- DSGW_LCACHECONF_PPATH, DSGW_LCACHECONF_FILE );
- } else if ( strcasecmp( dirsvctype, "remote" ) == 0 ) {
- cfg.gc_ldapserver = dsgw_get_cgi_var( "host", DSGW_CGIVAR_REQUIRED );
- cfg.gc_ldapport = atoi( dsgw_get_cgi_var( "port",
- DSGW_CGIVAR_REQUIRED ));
-#ifndef DSGW_NO_SSL
- cfg.gc_ldapssl =
- dsgw_get_boolean_var( "ssl", DSGW_CGIVAR_OPTIONAL, 0 );
-#endif
- cfg.gc_binddn = dsgw_get_escaped_cgi_var( "escapedbinddn", "binddn",
- DSGW_CGIVAR_OPTIONAL );
- cfg.gc_bindpw = dsgw_get_cgi_var( "bindpw", DSGW_CGIVAR_OPTIONAL );
- } else {
- dsgw_error( DSGW_ERR_SERVICETYPE, dirsvctype, DSGW_ERROPT_INLINE, 0,
- NULL );
- return;
- }
-
- if ( cfg.gc_ldapsearchbase == NULL ) {
- cfg.gc_ldapsearchbase = "";
- }
-
- if ( dsgw_update_dbswitch( &cfg, dbhandle, DSGW_ERROPT_INLINE ) == 0 ) {
- /*
- * success: display status message and then re-read config. file
- */
- dsgw_emits( "<FONT SIZE=\"+1\">\n<P>The Directory Service configuration" );
- if ( dbhandle != NULL ) {
- dsgw_emitf( " for <B>%s</B>", dbhandle );
- }
- dsgw_emits( " has been updated.\n</FONT>\n" );
-
- (void)dsgw_read_config(NULL);
- }
-
- dsgw_emits( "<HR>\n" );
-}
diff --git a/ldap/clients/dsgw/dsexpldif.c b/ldap/clients/dsgw/dsexpldif.c
deleted file mode 100644
index 66d0b0405..000000000
--- a/ldap/clients/dsgw/dsexpldif.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/** --- 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) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- --- END COPYRIGHT BLOCK --- */
-/*
- * dsexpldif.c -- CGI configuration update handler -- directory gateway
- */
-
-#include "dsgw.h"
-#include "libadmin/libadmin.h"
-static void handle_request( int reqmethod );
-static void handle_post();
-
-static char *ldiffile, *suffix;
-
-main( argc, argv, env )
- int argc;
- char *argv[];
-#ifdef DSGW_DEBUG
- char *env[];
-#endif
-{
- int reqmethod;
-
- reqmethod = dsgw_init( argc, argv, DSGW_METHOD_POST | DSGW_METHOD_GET );
- dsgw_send_header();
-
-#ifdef DSGW_DEBUG
- dsgw_logstringarray( "env", env );
-#endif
-
- handle_request( reqmethod );
-
- exit( 0 );
-}
-
-
-#define DSGWCONFIG_EMPTY_IF_NULL( s ) ( (s) == NULL ? "" : (s) )
-
-
-static void
-handle_request( int reqmethod )
-{
- FILE *fp;
- char **argv, *buf, line[ BIG_LINE ];
- char *str_valuefmt = " VALUE=\"%s\" ";
- int did_post, argc;
-
- buf = dsgw_ch_malloc( strlen( progname ) + 6 ); /* room for ".html\0" */
- sprintf( buf, "%s.html", progname );
- fp = dsgw_open_html_file( buf, DSGW_ERROPT_EXIT );
- free( buf );
- did_post = 0;
-
- while ( dsgw_next_html_line( fp, line )) {
- if ( dsgw_parse_line( line, &argc, &argv, 0, dsgw_simple_cond_is_true,
- NULL )) {
- if ( dsgw_directive_is( line, DRCT_DS_INLINE_POST_RESULTS )) {
- if ( !did_post && reqmethod == DSGW_METHOD_POST ) {
- handle_post();
- did_post = 1;
- }
- } else if ( dsgw_directive_is( line, DS_LDIF_FILE )) {
- dsgw_emitf( str_valuefmt,
- DSGWCONFIG_EMPTY_IF_NULL( ldiffile ));
- } else if ( dsgw_directive_is( line, DS_SUFFIX )) {
- dsgw_emitf( str_valuefmt,
- DSGWCONFIG_EMPTY_IF_NULL( suffix ));
- }
- }
- }
-
- fclose( fp );
-}
-
-
-static void
-handle_post()
-{
- char cmd[BIG_LINE], path[BIG_LINE];
- char *userdb_path;
-
- ldiffile = dsgw_get_cgi_var( "ldif", DSGW_CGIVAR_REQUIRED );
- suffix = dsgw_get_cgi_var( "suffix", DSGW_CGIVAR_OPTIONAL );
-
- /* if the schema checking is off, put out a warning message */
-
- if (( userdb_path = get_userdb_dir()) == NULL ) {
- dsgw_error( DSGW_ERR_USERDB_PATH, NULL, DSGW_ERROPT_EXIT, 0, NULL );
- }
-
- if (gc->gc_localdbconf == NULL) {
- /* remote */
- PR_snprintf (cmd, sizeof(cmd),
- "./%s -b \"%s\" -h %s -p %d \"objectclass=*\" > %s 2> %s",
- DSGW_LDAPSEARCH, gc->gc_ldapsearchbase, gc->gc_ldapserver,
- gc->gc_ldapport, ldiffile, DSGW_NULL_DEVICE);
- }
- else {
- /* local database */
- PR_snprintf (cmd, sizeof(cmd),
- "./%s -b \"\" -C %s \"objectclass=*\" > %s 2> %s",
- DSGW_LDAPSEARCH, gc->gc_localdbconf, ldiffile, DSGW_NULL_DEVICE);
- }
- PR_snprintf (path, BIG_LINE, "%s%s", userdb_path, DSGW_TOOLSDIR);
- chdir (path);
-
- fflush (stdout);
- if (system (cmd) == 0){
-
- /* if local database and suffix is not null, append suffix to
- appropriate attributes. */
-
- if (( gc->gc_localdbconf != NULL) && (suffix != NULL )) {
- app_suffix (ldiffile, suffix);
- }
- /*
- * success: display status message
- */
- dsgw_emits( "<FONT SIZE=\"+1\">\n<P>The ldif file has been created.\n</FONT>\n" );
- }
- else {
- dsgw_emits( "<FONT SIZE=\"+1\">\n<P>The ldif file could not be created.\n</FONT>\n" );
- }
-
- dsgw_emits( "<HR>\n" );
-}
-
diff --git a/ldap/clients/dsgw/dsgwutil.c b/ldap/clients/dsgw/dsgwutil.c
index a353f0411..4ce2be567 100644
--- a/ldap/clients/dsgw/dsgwutil.c
+++ b/ldap/clients/dsgw/dsgwutil.c
@@ -152,15 +152,6 @@ dsgw_init( int argc, char **argv, int methods_handled )
context = dsgw_ch_strdup("default");
}
- /* If this is a LIte installation: dsgw is not enabled */
-/* this assumes the current dir is <server root>/dsgw/bin; under http servers
-other than admin server, we have to rely on relative paths to find the
-key file */
-
- if ( is_directory_lite (SERVER_ROOT_PATH)) {
- dsgw_error( DSGW_ERR_BADCONFIG, XP_GetClientStr(DBT_NotWillingToExecute_),
- DSGW_ERROPT_EXIT, 0, NULL );
- }
gc = dsgw_read_config();
gc->gc_charset = dsgw_emit_converts_to (gc->gc_charset);
diff --git a/ldap/clients/dsgw/dsimpldif.c b/ldap/clients/dsgw/dsimpldif.c
deleted file mode 100644
index 407fa6622..000000000
--- a/ldap/clients/dsgw/dsimpldif.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/** --- 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) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- --- END COPYRIGHT BLOCK --- */
-/*
- * dsimpldif.c -- CGI import ldif file handler -- directory gateway
- */
-
-#include "dsgw.h"
-static void handle_request( int reqmethod );
-static void handle_post();
-
-static char *ldiffile;
-static int erase = 0, stop = 1;
-
-main( argc, argv, env )
- int argc;
- char *argv[];
-#ifdef DSGW_DEBUG
- char *env[];
-#endif
-{
- int reqmethod;
-
- reqmethod = dsgw_init( argc, argv, DSGW_METHOD_POST | DSGW_METHOD_GET );
- dsgw_send_header();
-
-#ifdef DSGW_DEBUG
- dsgw_logstringarray( "env", env );
-#endif
-
- handle_request( reqmethod );
-
- exit( 0 );
-}
-
-
-#define DSGWCONFIG_EMPTY_IF_NULL( s ) ( (s) == NULL ? "" : (s) )
-
-
-static void
-handle_request( int reqmethod )
-{
- FILE *fp;
- char **argv, *buf, line[ BIG_LINE ];
- char *checked = " CHECKED ";
- char *str_valuefmt = " VALUE=\"%s\" ";
- int did_post, argc;
-
- buf = dsgw_ch_malloc( strlen( progname ) + 6 ); /* room for ".html\0" */
- sprintf( buf, "%s.html", progname );
- fp = dsgw_open_html_file( buf, DSGW_ERROPT_EXIT );
- free( buf );
- did_post = 0;
-
- while ( dsgw_next_html_line( fp, line )) {
- if ( dsgw_parse_line( line, &argc, &argv, 0, dsgw_simple_cond_is_true,
- NULL )) {
- if ( dsgw_directive_is( line, DRCT_DS_INLINE_POST_RESULTS )) {
- if ( !did_post && reqmethod == DSGW_METHOD_POST ) {
- handle_post();
- did_post = 1;
- }
- } else if ( dsgw_directive_is( line, DS_LDIF_FILE )) {
- dsgw_emitf( str_valuefmt,
- DSGWCONFIG_EMPTY_IF_NULL( ldiffile ));
- } else if ( dsgw_directive_is( line, DS_CHECKED_IF_ERASE )) {
- if ( erase ) {
- dsgw_emits( checked );
- }
- } else if ( dsgw_directive_is( line, DS_CHECKED_IF_NOTERASE )) {
- if ( !erase ) {
- dsgw_emits( checked );
- }
- } else if ( dsgw_directive_is( line, DS_CHECKED_IF_STOP )) {
- if ( stop ) {
- dsgw_emits( checked );
- }
- } else if ( dsgw_directive_is( line, DS_CHECKED_IF_NOTSTOP )) {
- if ( !stop ) {
- dsgw_emits( checked );
- }
- }
- }
- }
-
- fclose( fp );
-}
-
-
-static void
-handle_post()
-{
- char cmd[ BIG_LINE ], path[BIG_LINE ];
- char *userdb_path;
-
- ldiffile = dsgw_get_cgi_var( "ldif", DSGW_CGIVAR_REQUIRED );
- erase = dsgw_get_boolean_var( "erase", DSGW_CGIVAR_REQUIRED, 0 );
- stop = dsgw_get_boolean_var( "stop", DSGW_CGIVAR_REQUIRED, 0 );
-
- if (erase) {
- if ( gc->gc_localdbconf == NULL) {
- /* don't erase the real ldap database */
- dsgw_error( DSGW_ERR_DB_ERASE, NULL, DSGW_ERROPT_EXIT, 0, NULL );
- }
- /* erase the local database */
- if ( erase_db() != 0 ) {
- return;
- }
- }
-
- if (( userdb_path = get_userdb_dir()) == NULL ) {
- dsgw_error( DSGW_ERR_USERDB_PATH, NULL, DSGW_ERROPT_EXIT, 0, NULL );
- }
-
- if (gc->gc_localdbconf == NULL) {
- /* remote */
- PR_snprintf (cmd, sizeof(cmd), "./%s -a %s -h %s -p %d -f %s > %s 2>&1",
- DSGW_LDAPMODIFY, stop?"":"-c",gc->gc_ldapserver,
- gc->gc_ldapport, ldiffile, DSGW_NULL_DEVICE);
- }
- else {
- /* local database */
- PR_snprintf (cmd, sizeof(cmd), "./%s -a %s -C %s -f %s > %s 2>&1",
- DSGW_LDAPMODIFY, stop?"":"-c", gc->gc_localdbconf, ldiffile,
- DSGW_NULL_DEVICE);
- }
- PR_snprintf (path, sizeof(path), "%s%s", userdb_path, DSGW_TOOLSDIR);
- chdir ( path );
- fflush (stdout);
- if (system (cmd) == 0) {
- /*
- * success: display status message
- */
- dsgw_emits(
- "<FONT SIZE=\"+1\">\n<P>The ldif file has been added.\n</FONT>\n " );
- }
- else {
- dsgw_emits(
- "<FONT SIZE=\"+1\">\n<P>The ldif file could not be added.\n</FONT>\n " );
- }
-
- dsgw_emits( "<HR>\n" );
-}
-
diff --git a/ldap/clients/dsgw/edit.c b/ldap/clients/dsgw/edit.c
index 3f49aadef..a08f4ad60 100644
--- a/ldap/clients/dsgw/edit.c
+++ b/ldap/clients/dsgw/edit.c
@@ -43,7 +43,7 @@
#include "dbtdsgw.h"
static void get_request(char *dn, char *tmplname,
- char *parent, unsigned long options);
+ unsigned long options);
int main( argc, argv, env )
@@ -55,7 +55,7 @@ int main( argc, argv, env )
{
- char *dn, *tmplname, *p, *parent;
+ char *dn, *tmplname, *p;
unsigned long options;
/*
@@ -156,14 +156,14 @@ int main( argc, argv, env )
dsgw_logstringarray( "env", env );
#endif
- get_request(dn, tmplname, parent, options);
+ get_request(dn, tmplname, options);
exit( 0 );
}
static void
-get_request(char *dn, char *tmplname, char *parent, unsigned long options)
+get_request(char *dn, char *tmplname, unsigned long options)
{
LDAP *ld;
@@ -226,6 +226,7 @@ get_request(char *dn, char *tmplname, char *parent, unsigned long options)
dsgw_html_end();
} else if ( !dsgw_is_dnparent( matched, dn ) &&
!dsgw_dn_cmp( dn, gc->gc_ldapsearchbase )) {
+ char *parent = NULL;
/*
* The parent entry does not exist, and the dn being added is not
* the same as the suffix for which the gateway is configured.
diff --git a/ldap/clients/dsgw/entrydisplay.c b/ldap/clients/dsgw/entrydisplay.c
index 506044b5f..4b6d47ed8 100644
--- a/ldap/clients/dsgw/entrydisplay.c
+++ b/ldap/clients/dsgw/entrydisplay.c
@@ -340,6 +340,12 @@ dsgw_display_init( int tmpltype, char *template, unsigned long options )
char **argv, *attr, *filename, line[ BIG_LINE ];
unsigned long aopts;
+ /* template is passed in from the user - make sure it looks like a valid name */
+ if (!dsgw_valid_docname(template)) {
+ dsgw_error( DSGW_ERR_BADFILEPATH, template,
+ DSGW_ERROPT_EXIT, 0, NULL );
+ }
+
tip = (dsgwtmplinfo *)dsgw_ch_malloc( sizeof( dsgwtmplinfo ));
memset( tip, 0, sizeof( dsgwtmplinfo ));
tip->dsti_type = tmpltype;
diff --git a/ldap/clients/dsgw/genscreen.c b/ldap/clients/dsgw/genscreen.c
deleted file mode 100644
index 98f0bf3a2..000000000
--- a/ldap/clients/dsgw/genscreen.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/** --- 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) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- --- END COPYRIGHT BLOCK --- */
-/*
- * Generate a screen.
- */
-
-#include "dsgw.h"
-
-static int dsgw_genscreen_begin( char *fname, FILE **fpp,
- char *stop_at_directive, int erropts );
-static int dsgw_genscreen_continue( FILE **fpp, char *stop_at_directive,
- int erropts );
-
-static LDAP *ld = NULL;
-
-main( argc, argv, env )
- int argc;
- char *argv[];
-#ifdef DSGW_DEBUG
- char *env[];
-#endif
-{
- char *p, *tmplname, *buf;
-
- context=dsgw_ch_strdup("pb");
- /*CHANGE THIS*/
-
- (void)dsgw_init( argc, argv, DSGW_METHOD_GET );
- dsgw_send_header();
-
-#ifdef DSGW_DEBUG
- dsgw_logstringarray( "env", env );
-#endif
-
- /*
- * If the QUERY_STRING is non-NULL, it looks like this:
- *
- * template &CONTEXT=context [ &INFO=infostring ]
- *
- * where:
- * "template" is the name of the HTML template to render
- * "infostring" is a message used to replace DS_LAST_OP_INFO directives
- *
- * If the QUERY_STRING is NULL, the name of this program is used as the
- * template.
- */
-
- if (( tmplname = getenv( "QUERY_STRING" )) == NULL ) {
- tmplname = progname;
- } else {
- tmplname = dsgw_ch_strdup( tmplname );
- if (( p = strrchr( tmplname, '&' )) != NULL ) {
- *p++ = '\0';
- if ( strncasecmp( p, "info=", 5 ) == 0 ) {
- dsgw_last_op_info = dsgw_ch_strdup( p + 5 );
- dsgw_form_unescape( dsgw_last_op_info );
- }
- }
- }
-
-
- buf = dsgw_ch_malloc( strlen( tmplname ) + 6 ); /* room for ".html\0" */
- sprintf( buf, "%s.html", tmplname );
-
- dsgw_genscreen_begin( buf, NULL, NULL, DSGW_ERROPT_EXIT );
-
- exit( 0 );
-}
-
-
-static int
-dsgw_genscreen_begin( char *fname, FILE **fpp, char *stop_at_directive,
- int erropts )
-{
- FILE *html;
-
- if ( fpp == NULL ) {
- fpp = &html;
- }
-
- if (( *fpp = dsgw_open_html_file( fname, erropts )) == NULL ) {
- *fpp = NULL;
- return( -1 );
- }
-
- return( dsgw_genscreen_continue( fpp, stop_at_directive, erropts ));
-}
-
-
-static int
-dsgw_genscreen_continue( FILE **fpp, char *stop_at_directive, int erropts )
-{
- char **argv, line[ BIG_LINE ];
- int argc;
-
- while ( dsgw_next_html_line( *fpp, line )) {
- if ( dsgw_parse_line( line, &argc, &argv, 0, dsgw_simple_cond_is_true,
- NULL )) {
- if ( stop_at_directive != NULL &&
- dsgw_directive_is( line, stop_at_directive )) {
- return( 0 );
- }
- if ( dsgw_directive_is( line, DRCT_DS_LOCATIONPOPUP )) {
- dsgw_emit_location_popup( ld, argc, argv, erropts );
- }
- }
- }
-
- fclose( *fpp );
- *fpp = NULL;
-
- return( 0 );
-}
diff --git a/ldap/clients/dsgw/html/manual/contents.html b/ldap/clients/dsgw/html/manual/contents.html
index 35e2076c4..ff70a9f82 100644
--- a/ldap/clients/dsgw/html/manual/contents.html
+++ b/ldap/clients/dsgw/html/manual/contents.html
@@ -58,7 +58,7 @@ Contents</H1>
<DL>
<DD>
-<A HREF="lang?<!-- GCONTEXT -->&file=.MANUAL/lang?<!-- GCONTEXT -->&file=.MANUAL/search.htm#Performing a Standard Search">Performing a Standard
+<A HREF="lang?<!-- GCONTEXT -->&file=.MANUAL/search.htm#Performing a Standard Search">Performing a Standard
Search</A></DD>
<DL>
diff --git a/ldap/clients/dsgw/htmlparse.c b/ldap/clients/dsgw/htmlparse.c
index 9aa2567fb..7bc9b38db 100644
--- a/ldap/clients/dsgw/htmlparse.c
+++ b/ldap/clients/dsgw/htmlparse.c
@@ -51,7 +51,7 @@
extern char *Versionstr; /* from Versiongw.c */
/* global variables */
-char *dsgw_last_op_info; /* set in edit.c and genscreen.c */
+char *dsgw_last_op_info; /* set in edit.c */
char *dsgw_dnattr; /* set in edit.c */
char *dsgw_dndesc; /* set in edit.c */
diff --git a/ldap/clients/dsgw/lang.c b/ldap/clients/dsgw/lang.c
index a49908994..8c93c0d4d 100644
--- a/ldap/clients/dsgw/lang.c
+++ b/ldap/clients/dsgw/lang.c
@@ -232,13 +232,28 @@ main( int argc, char *argv[]
}
if (manual_file) {
+ /* check filename */
+ char *mandocname = dsgw_ch_strdup(docname + DSGW_MANUALSHORTCUT_LEN);
+ if (*mandocname == '/') {
+ if (!dsgw_valid_docname(mandocname+1)) {
+ dsgw_error( DSGW_ERR_BADFILEPATH, mandocname,
+ DSGW_ERROPT_EXIT, 0, NULL );
+ }
+ } else {
+ if (!dsgw_valid_docname(mandocname)) {
+ dsgw_error( DSGW_ERR_BADFILEPATH, mandocname,
+ DSGW_ERROPT_EXIT, 0, NULL );
+ }
+ }
+
helpdir = dsgw_file2path ( DSGW_MANROOT, "slapd/gw/manual/" );
tfname = (char *)dsgw_ch_malloc( strlen( helpdir ) +
- strlen( docname + DSGW_MANUALSHORTCUT_LEN ) +
+ strlen( mandocname ) +
1 );
sprintf( tfname, "%s%s",
- helpdir, docname + DSGW_MANUALSHORTCUT_LEN);
+ helpdir, mandocname);
free( helpdir );
+ free( mandocname );
} else {
tfname = dsgw_file2path (docdir, docname);
diff --git a/ldap/clients/dsgw/templateindex.c b/ldap/clients/dsgw/templateindex.c
deleted file mode 100644
index 80c40c4be..000000000
--- a/ldap/clients/dsgw/templateindex.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/** --- 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) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- --- END COPYRIGHT BLOCK --- */
-/*
- * templateindex.c -- CGI template indexer -- HTTP gateway
- */
-
-#include "dsgw.h"
-#if defined( XP_WIN32 )
-#include <io.h>
-struct dirent {
- char d_name[1];
-};
-#else
-#include <dirent.h>
-#endif
-
-static void build_index();
-
-#if defined( XP_WIN32 )
-char **ds_get_file_list( char *dir )
-{
- char szWildcardFileSpec[MAX_PATH];
- char **ret = NULL;
- long hFile;
- struct _finddata_t fileinfo;
- int nfiles = 0;
-
- if( ( dir == NULL ) || (strlen( dir ) == 0) )
- return NULL;
-
- if( ( ret = malloc( sizeof( char * ) * 2 ) ) == NULL )
- return NULL;
-
- PL_strncpyz(szWildcardFileSpec, dir, sizeof(szWildcardFileSpec));
- PL_strcatn(szWildcardFileSpec, sizeof(szWildcardFileSpec), "/*");
-
- hFile = _findfirst( szWildcardFileSpec, &fileinfo);
- if( hFile == -1 )
- return NULL;
-
- if( ( strcmp( fileinfo.name, "." ) != 0 ) &&
- ( strcmp( fileinfo.name, ".." ) != 0 ) )
- {
- ret[ nfiles++ ] = strdup( fileinfo.name );
- }
-
- while( _findnext( hFile, &fileinfo ) == 0 )
- {
- if( ( strcmp( fileinfo.name, "." ) != 0 ) &&
- ( strcmp( fileinfo.name, ".." ) != 0 ) )
- {
- if( ( ret = (char **) realloc( ret, sizeof( char * ) * ( nfiles + 1 ) ) ) != NULL )
- ret[ nfiles++ ] = strdup( fileinfo.name);
- }
- }
-
- _findclose( hFile );
-
- ret[ nfiles ] = NULL;
- return ret;
-}
-#endif ( XP_WIN32 )
-
-
-main( argc, argv, env )
- int argc;
- char *argv[];
-#ifdef DSGW_DEBUG
- char *env[];
-#endif
-{
- int reqmethod;
-
- reqmethod = dsgw_init( argc, argv, DSGW_METHOD_GET );
- dsgw_send_header();
-
-#ifdef DSGW_DEBUG
- dsgw_logstringarray( "env", env );
-#endif
-
- dsgw_html_begin( "Directory Server Gateway Template Indexer", 1 );
-
- build_index();
-
- dsgw_html_end();
-
- exit( 0 );
-}
-
-
-static void
-build_index()
-{
- FILE *htmlfp;
-#if !defined( XP_WIN32 )
- DIR *dirp;
-#endif
- struct dirent *dep;
- char *path, **argv, *classes, *p, line[ BIG_LINE ];
- char **filelist;
- int errcount, prefixlen, count, argc, filecount = 0;
-
-
- path = dsgw_file2path( gc->gc_tmpldir, "" );
-
-#if defined( XP_WIN32 )
- if (( filelist = ds_get_file_list( path )) == NULL ) {
-#else
- if (( dirp = opendir( path )) == NULL ) {
-#endif
- dsgw_error( DSGW_ERR_OPENDIR, path, DSGW_ERROPT_EXIT, 0, NULL );
- }
- free( path );
-
- prefixlen = strlen( DSGW_CONFIG_DISPLAYPREFIX );
- errcount = count = 0;
-
- dsgw_emitf( "Remove any lines that begin with \"template\" from \n" );
- dsgw_emitf( "your dsgw.conf file and add these lines:<BR><PRE>\n" );
-
-#if defined( XP_WIN32 )
- while( filelist != NULL && filelist[filecount] != NULL ) {
- dep = (struct dirent *)filelist[filecount];
-#else
- while (( dep = readdir( dirp )) != NULL ) {
-#endif
- if ( strlen( dep->d_name ) > prefixlen && strncasecmp( dep->d_name,
- DSGW_CONFIG_DISPLAYPREFIX, prefixlen ) == 0 && strcmp(
- ".html", dep->d_name + strlen( dep->d_name ) - 5 ) == 0 ) {
- ++count;
- htmlfp = dsgw_open_html_file( dep->d_name, DSGW_ERROPT_EXIT );
-
- while ( dsgw_next_html_line( htmlfp, line )) {
- if ( dsgw_parse_line( line, &argc, &argv, 1,
- dsgw_simple_cond_is_true, NULL )) {
- if ( dsgw_directive_is( line, DRCT_DS_OBJECTCLASS )) {
- if (( classes = get_arg_by_name( "value", argc, argv ))
- == NULL ) {
- dsgw_emitf(
- "Missing \"value=objectclass\" on line <%s<BR>\n", line+1 );
- ++errcount;
- continue;
- }
- dsgw_emitf( "template %.*s",
- strlen( dep->d_name ) - prefixlen - 5,
- dep->d_name + prefixlen );
- for ( ; classes != NULL && *classes != '\0';
- classes = p ) {
- if (( p = strchr( classes, ',' )) != NULL ) {
- *p++ = '\0';
- while ( ldap_utf8isspace( p )) {
- LDAP_UTF8INC(p);
- }
- }
- dsgw_emitf( " %s", classes );
- }
- dsgw_emits( "\n" );
- }
- }
- }
- fclose( htmlfp );
- filecount++;
- }
- }
-
-#if !defined( XP_WIN32 )
- closedir( dirp );
-#endif
-
- dsgw_emits( "</PRE><H3>Template indexing " );
-
- if ( errcount == 0 ) {
- dsgw_emitf( "complete (%d files).<H3>\n", count );
- } else {
- dsgw_emitf( "failed (%d errors).<H3>\n", errcount );
- }
-}
| 0 |
6c2bb66f15d7ab8ab079effc66e0705c2513b1fd
|
389ds/389-ds-base
|
Ticket 50308 - Fix memory leaks for repeat binds and replication
Description: Fixed two memory leaks:
- If a worker thread had multiple binds the "bind dn"
thread data was leaked.
- Memory leak when processing changes in the changelog
https://pagure.io/389-ds-base/issue/50308
Reviewed by: firstyear(Thanks!)
|
commit 6c2bb66f15d7ab8ab079effc66e0705c2513b1fd
Author: Mark Reynolds <[email protected]>
Date: Thu Mar 28 18:15:10 2019 -0400
Ticket 50308 - Fix memory leaks for repeat binds and replication
Description: Fixed two memory leaks:
- If a worker thread had multiple binds the "bind dn"
thread data was leaked.
- Memory leak when processing changes in the changelog
https://pagure.io/389-ds-base/issue/50308
Reviewed by: firstyear(Thanks!)
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index a8477a83a..6c1882952 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -589,6 +589,7 @@ clcache_refresh_local_maxcsn(const ruv_enum_data *rid_data, void *data)
/* this is the first time we have a local change for the RID
* we need to check what the consumer knows about it.
*/
+ csn_free(&buf->buf_cscbs[i]->consumer_maxcsn);
ruv_get_largest_csn_for_replica(
buf->buf_consumer_ruv,
buf->buf_cscbs[i]->rid,
@@ -832,6 +833,7 @@ clcache_skip_change(CLC_Buffer *buf)
/* Send CSNs that are covered by the local RUV snapshot */
if (csn_compare(buf->buf_current_csn, cscb->local_maxcsn) <= 0) {
skip = 0;
+ csn_free(&cscb->consumer_maxcsn);
csn_dup_or_init_by_csn(&cscb->consumer_maxcsn, buf->buf_current_csn);
break;
}
@@ -842,11 +844,12 @@ clcache_skip_change(CLC_Buffer *buf)
* are not sure if current_csn is the neighbor.
*/
if (csn_time_difference(buf->buf_current_csn, cscb->local_maxcsn) == 0 &&
- (csn_get_seqnum(buf->buf_current_csn) ==
- csn_get_seqnum(cscb->local_maxcsn) + 1)) {
+ (csn_get_seqnum(buf->buf_current_csn) == csn_get_seqnum(cscb->local_maxcsn) + 1))
+ {
csn_init_by_csn(cscb->local_maxcsn, buf->buf_current_csn);
if (cscb->consumer_maxcsn) {
- csn_init_by_csn(cscb->consumer_maxcsn, buf->buf_current_csn);
+ csn_free(&cscb->consumer_maxcsn);
+ csn_dup_or_init_by_csn(cscb->consumer_maxcsn, buf->buf_current_csn);
}
skip = 0;
break;
diff --git a/ldap/servers/slapd/thread_data.c b/ldap/servers/slapd/thread_data.c
index 7babe36c0..fb9951d13 100644
--- a/ldap/servers/slapd/thread_data.c
+++ b/ldap/servers/slapd/thread_data.c
@@ -98,6 +98,8 @@ slapi_td_get_plugin_locked()
int32_t
slapi_td_set_dn(char *value)
{
+ char *dn = pthread_getspecific(td_requestor_dn);
+ slapi_ch_free_string(&dn);
if (pthread_setspecific(td_requestor_dn, value) != 0) {
return PR_FAILURE;
}
| 0 |
d9b8787008e72e696b2b92f20e18b4c3f5f0a38c
|
389ds/389-ds-base
|
Resolves: bug 237356
Description: Move DS Admin Code into Admin Server
Fix Description: The Resource class needs to support more than 1 resource file e.g. for ds-base and ds-admin.
The property dir should be under $datadir. Property files are data files, not really config files.
Added a shared_lib_suffix token
Fixed some wording errors in the resource file.
Platforms tested: RHEL4
Flag Day: no
Doc impact: No new doc impact from previous commits for this bug.
|
commit d9b8787008e72e696b2b92f20e18b4c3f5f0a38c
Author: Rich Megginson <[email protected]>
Date: Fri Jun 8 20:36:53 2007 +0000
Resolves: bug 237356
Description: Move DS Admin Code into Admin Server
Fix Description: The Resource class needs to support more than 1 resource file e.g. for ds-base and ds-admin.
The property dir should be under $datadir. Property files are data files, not really config files.
Added a shared_lib_suffix token
Fixed some wording errors in the resource file.
Platforms tested: RHEL4
Flag Day: no
Doc impact: No new doc impact from previous commits for this bug.
diff --git a/Makefile.am b/Makefile.am
index d4fe8f9a8..8bebecd9c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -67,7 +67,7 @@ dberrstrs.h: Makefile
#------------------------
configdir = $(sysconfdir)@configdir@
sampledatadir = $(datadir)@sampledatadir@
-propertydir = $(sysconfdir)@propertydir@
+propertydir = $(datadir)@propertydir@
schemadir = $(sysconfdir)@schemadir@
serverdir = $(libdir)@serverdir@
serverplugindir = $(libdir)@serverplugindir@
@@ -76,6 +76,8 @@ initdir = $(sysconfdir)@initdir@
instconfigdir = @instconfigdir@
perldir = $(libdir)@perldir@
+shared_lib_suffix = @shared_lib_suffix@
+
#------------------------
# Build Products
#------------------------
@@ -1016,7 +1018,8 @@ fixupcmd = sed \
-e 's,@brand\@,$(brand),g' \
-e 's,@capbrand\@,$(capbrand),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
- -e 's,@perldir\@,$(perldir),g'
+ -e 's,@perldir\@,$(perldir),g' \
+ -e 's,@shared_lib_suffix\@,$(shared_lib_suffix),g'
else
fixupcmd = sed \
-e 's,@bindir\@,$(bindir),g' \
@@ -1046,7 +1049,8 @@ fixupcmd = sed \
-e 's,@brand\@,$(brand),g' \
-e 's,@capbrand\@,$(capbrand),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
- -e 's,@perldir\@,$(perldir),g'
+ -e 's,@perldir\@,$(perldir),g' \
+ -e 's,@shared_lib_suffix\@,$(shared_lib_suffix),g'
endif
%: %.in
diff --git a/Makefile.in b/Makefile.in
index 70a288efc..2c0d62805 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -962,7 +962,7 @@ oldincludedir = @oldincludedir@
perldir = $(libdir)@perldir@
prefix = @prefix@
program_transform_name = @program_transform_name@
-propertydir = $(sysconfdir)@propertydir@
+propertydir = $(datadir)@propertydir@
sampledatadir = $(datadir)@sampledatadir@
sasl_inc = @sasl_inc@
sasl_lib = @sasl_lib@
@@ -972,6 +972,7 @@ schemadir = $(sysconfdir)@schemadir@
scripttemplatedir = @scripttemplatedir@
serverdir = $(libdir)@serverdir@
serverplugindir = $(libdir)@serverplugindir@
+shared_lib_suffix = @shared_lib_suffix@
sharedstatedir = @sharedstatedir@
svrcore_inc = @svrcore_inc@
svrcore_lib = @svrcore_lib@
@@ -1909,7 +1910,8 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
@BUNDLE_FALSE@ -e 's,@brand\@,$(brand),g' \
@BUNDLE_FALSE@ -e 's,@capbrand\@,$(capbrand),g' \
@BUNDLE_FALSE@ -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-@BUNDLE_FALSE@ -e 's,@perldir\@,$(perldir),g'
+@BUNDLE_FALSE@ -e 's,@perldir\@,$(perldir),g' \
+@BUNDLE_FALSE@ -e 's,@shared_lib_suffix\@,$(shared_lib_suffix),g'
# these are for the config files and scripts that we need to generate and replace
@@ -1946,7 +1948,8 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
@BUNDLE_TRUE@ -e 's,@brand\@,$(brand),g' \
@BUNDLE_TRUE@ -e 's,@capbrand\@,$(capbrand),g' \
@BUNDLE_TRUE@ -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-@BUNDLE_TRUE@ -e 's,@perldir\@,$(perldir),g'
+@BUNDLE_TRUE@ -e 's,@perldir\@,$(perldir),g' \
+@BUNDLE_TRUE@ -e 's,@shared_lib_suffix\@,$(shared_lib_suffix),g'
all: $(BUILT_SOURCES) config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
diff --git a/configure b/configure
index ded1a90bc..55ffadf36 100755
--- a/configure
+++ b/configure
@@ -465,7 +465,7 @@ ac_includes_default="\
#endif"
ac_default_prefix=/opt/$PACKAGE_NAME
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_bitwise_TRUE enable_bitwise_FALSE configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link brand capbrand vendor LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_bitwise_TRUE enable_bitwise_FALSE configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir shared_lib_suffix HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link brand capbrand vendor LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -23177,8 +23177,8 @@ fi
# Shared paths for all layouts
# relative to sysconfdir
configdir=/$PACKAGE_NAME/config
-# relative to sysconfdir
-propertydir=/$PACKAGE_NAME/property
+# location of property/resource files, relative to datadir
+propertydir=/$PACKAGE_NAME/properties
# relative to sysconfdir
schemadir=/$PACKAGE_NAME/schema
# relative to libdir
@@ -23228,6 +23228,7 @@ else
fi
+shared_lib_suffix=.so
# Deal with platform dependent defines
# relative to sysconfdir
initdir=/rc.d
@@ -23361,6 +23362,7 @@ cat >>confdefs.h <<\_ACEOF
#define _HPUX_SOURCE 1
_ACEOF
+ shared_lib_suffix=.sl
platform="hpux"
;;
sparc-sun-solaris*)
@@ -23446,6 +23448,7 @@ esac
+
if test "$platform" = "hpux"; then
HPUX_TRUE=
HPUX_FALSE='#'
@@ -25999,6 +26002,7 @@ s,@LIBDL@,$LIBDL,;t t
s,@LIBCSTD@,$LIBCSTD,;t t
s,@LIBCRUN@,$LIBCRUN,;t t
s,@initdir@,$initdir,;t t
+s,@shared_lib_suffix@,$shared_lib_suffix,;t t
s,@HPUX_TRUE@,$HPUX_TRUE,;t t
s,@HPUX_FALSE@,$HPUX_FALSE,;t t
s,@SOLARIS_TRUE@,$SOLARIS_TRUE,;t t
diff --git a/configure.ac b/configure.ac
index 0719313c7..5d6ab021a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -186,8 +186,8 @@ fi
# Shared paths for all layouts
# relative to sysconfdir
configdir=/$PACKAGE_NAME/config
-# relative to sysconfdir
-propertydir=/$PACKAGE_NAME/property
+# location of property/resource files, relative to datadir
+propertydir=/$PACKAGE_NAME/properties
# relative to sysconfdir
schemadir=/$PACKAGE_NAME/schema
# relative to libdir
@@ -223,6 +223,7 @@ AC_SUBST(instconfigdir)
# cygnus, mingw, or the like and using cmd.exe as the shell
AM_CONDITIONAL([WINNT], false)
+shared_lib_suffix=.so
# Deal with platform dependent defines
# relative to sysconfdir
initdir=/rc.d
@@ -260,6 +261,7 @@ case $host in
AC_DEFINE([OS_hpux], [1], [OS HP-UX])
AC_DEFINE([_POSIX_C_SOURCE], [199506L], [POSIX revision])
AC_DEFINE([_HPUX_SOURCE], [1], [Source namespace])
+ shared_lib_suffix=.sl
platform="hpux"
;;
sparc-sun-solaris*)
@@ -295,6 +297,7 @@ dnl Cstd and Crun are required to link any C++ related code
;;
esac
AC_SUBST(initdir)
+AC_SUBST(shared_lib_suffix)
AM_CONDITIONAL(HPUX,test "$platform" = "hpux")
AM_CONDITIONAL(SOLARIS,test "$platform" = "solaris")
diff --git a/ldap/admin/src/scripts/Resource.pm b/ldap/admin/src/scripts/Resource.pm
index ba4ca83f5..a8cb62a52 100644
--- a/ldap/admin/src/scripts/Resource.pm
+++ b/ldap/admin/src/scripts/Resource.pm
@@ -51,41 +51,44 @@ sub new {
my $type = shift;
my $self = {};
- $self->{filename} = shift;
+ while (@_) {
+ push @{$self->{filenames}}, shift;
+ }
$self = bless $self, $type;
- if ($self->{filename}) {
+ if (@{$self->{filenames}}) {
$self->read();
}
return $self;
}
+# the resource files are read in order given. Definitions from
+# later files override the same definitions in earlier files.
sub read {
my $self = shift;
- my $filename = shift;
- if ($filename) {
- $self->{filename} = $filename;
- } else {
- $filename = $self->{filename};
+ while (@_) {
+ push @{$self->{filenames}}, shift;
}
- open RES, $filename or die "Error: could not open resource file $filename: $!";
- while (<RES>) {
- next if (/^\s*$/); # skip blank lines
- next if (/^\s*\#/); # skip comment lines
- # read name = value pairs like this
- # bol whitespace* name whitespace* '=' whitespace* value eol
- # the value will include any trailing whitespace
- if (/^\s*(.*?)\s*=\s*(.*?)$/) {
- $self->{res}->{$1} = $2;
- # replace \n with real newline
- $self->{res}->{$1} =~ s/\\n/\n/g;
+ for my $filename (@{$self->{filenames}}) {
+ open RES, $filename or die "Error: could not open resource file $filename: $!";
+ while (<RES>) {
+ next if (/^\s*$/); # skip blank lines
+ next if (/^\s*\#/); # skip comment lines
+ # read name = value pairs like this
+ # bol whitespace* name whitespace* '=' whitespace* value eol
+ # the value will include any trailing whitespace
+ if (/^\s*(.*?)\s*=\s*(.*?)$/) {
+ $self->{res}->{$1} = $2;
+ # replace \n with real newline
+ $self->{res}->{$1} =~ s/\\n/\n/g;
+ }
}
- }
- close RES;
+ close RES;
+ }
}
# given a resource key and optional args, return the value
diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in
index 246ecbdc2..600b3ac30 100644
--- a/ldap/admin/src/scripts/setup-ds.res.in
+++ b/ldap/admin/src/scripts/setup-ds.res.in
@@ -34,12 +34,12 @@ dialog_hostname_prompt = Computer name
dialog_hostname_warning = The hostname %s does not look like a\nfully qualified host and domain name.\nIf you feel you have made a mistake,\nplease go back to this dialog and enter another name.\n\n
# ----------- SSUser Dialog Resource ----------------
-dialog_ssuser_text = The server must run as a specific user in a specific group.\nIt is strongly recommended that this user should have no privileges\non the computer (i.e. a non-root user). The Administration Server\nwill give this user/group some permissions in specific paths/files\nto perform server-specific operations.\n\nIf you have not yet created a user and group for the server,\ncreate this user and group using your native operating\nsystem utilities.\n\n
+dialog_ssuser_text = The server must run as a specific user in a specific group.\nIt is strongly recommended that this user should have no privileges\non the computer (i.e. a non-root user). The setup procedure\nwill give this user/group some permissions in specific paths/files\nto perform server-specific operations.\n\nIf you have not yet created a user and group for the server,\ncreate this user and group using your native operating\nsystem utilities.\n\n
dialog_ssuser_prompt = System User
dialog_ssuser_error = The user '%s' is invalid.\n\n
dialog_ssuser_must_be_same = Since you are not running setup as root, the System User must be the same as your userid '%s'.\n\n
-dialog_ssuser_root_warning = You are strongly discouraged to use a non-root user for the server uid.\nIf you feel you have made a mistake,\nplease go back to this dialog and enter another system user.\n\n
+dialog_ssuser_root_warning = You are strongly encouraged to use a non-root user for the server uid.\nIf you feel you have made a mistake,\nplease go back to this dialog and enter another system user.\n\n
dialog_ssgroup_prompt = System Group
dialog_ssgroup_error = The group '%s' is invalid.\n\n
dialog_ssgroup_no_match = The system user '%s' does not belong to the group '%s'.\n\nThis is the list of users of the given group: %s\n\n
| 0 |
b5bee52888069417aa780ab79b897d0736f306c9
|
389ds/389-ds-base
|
Bug 670616 - Allow SSF to be set for local (ldapi) connections
This patch adds a new config parameter named nsslapd-localssf.
This parameter can be set to the SSF that one wants to apply for
ocal (LDAPI) connections. This SSF will be used with the minssf
global and ACI settings. The local SSF can also be used to satisfy
the confidentiality requirements for secure binds and password
modify extended operations.
|
commit b5bee52888069417aa780ab79b897d0736f306c9
Author: Nathan Kinder <[email protected]>
Date: Tue Feb 1 11:54:08 2011 -0800
Bug 670616 - Allow SSF to be set for local (ldapi) connections
This patch adds a new config parameter named nsslapd-localssf.
This parameter can be set to the SSF that one wants to apply for
ocal (LDAPI) connections. This SSF will be used with the minssf
global and ACI settings. The local SSF can also be used to satisfy
the confidentiality requirements for secure binds and password
modify extended operations.
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
index 5434075c0..7d1c48f0d 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -103,6 +103,7 @@ my %ignoreOld =
# these are new attrs that we should just pass through
'nsslapd-allow-unauthenticated-binds' => 'nsslapd-allow-unauthenticated-binds',
'nsslapd-allow-anonymous-access' => 'nsslapd-allow-anonymous-access',
+ 'nsslapd-localssf' => 'nsslapd-localssf',
'nsslapd-minssf' => 'nsslapd-minssf',
'nsslapd-saslpath' => 'nsslapd-saslpath',
'nsslapd-rundir' => 'nsslapd-rundir',
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index f607f44e6..cd98d16a0 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -32,6 +32,7 @@ nsslapd-ssl-check-hostname: on
nsslapd-allow-unauthenticated-binds: off
nsslapd-require-secure-binds: off
nsslapd-allow-anonymous-access: on
+nsslapd-localssf: 71
nsslapd-minssf: 0
nsslapd-port: %ds_port%
nsslapd-localuser: %ds_user%
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 8b666f1f7..679cbff9e 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -499,7 +499,8 @@ do_bind( Slapi_PBlock *pb )
/* Check if the minimum SSF requirement has been met. */
minssf = config_get_minssf();
- if ((pb->pb_conn->c_sasl_ssf < minssf) && (pb->pb_conn->c_ssl_ssf < minssf)) {
+ if ((pb->pb_conn->c_sasl_ssf < minssf) && (pb->pb_conn->c_ssl_ssf < minssf) &&
+ (pb->pb_conn->c_local_ssf < minssf)) {
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"Minimum SSF not met.", 0, NULL);
/* increment BindSecurityErrorcount */
@@ -569,6 +570,7 @@ do_bind( Slapi_PBlock *pb )
} else if (config_get_require_secure_binds() == 1) {
Connection *conn = NULL;
int sasl_ssf = 0;
+ int local_ssf = 0;
/* Allow simple binds only for SSL/TLS established connections
* or connections using SASL privacy layers */
@@ -579,8 +581,14 @@ do_bind( Slapi_PBlock *pb )
sasl_ssf = 0;
}
+ if ( slapi_pblock_get(pb, SLAPI_CONN_LOCAL_SSF, &local_ssf) != 0) {
+ slapi_log_error( SLAPI_LOG_PLUGIN, "do_bind",
+ "Could not get local SSF from connection\n" );
+ local_ssf = 0;
+ }
+
if (((conn->c_flags & CONN_FLAG_SSL) != CONN_FLAG_SSL) &&
- (sasl_ssf <= 1) ) {
+ (sasl_ssf <= 1) && (local_ssf <= 1)) {
send_ldap_result(pb, LDAP_CONFIDENTIALITY_REQUIRED, NULL,
"Operation requires a secure connection",
0, NULL);
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 7b00a21c1..7f93a0fe7 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -196,6 +196,7 @@ connection_cleanup(Connection *conn)
conn->c_prev= NULL;
conn->c_extension= NULL;
conn->c_ssl_ssf = 0;
+ conn->c_local_ssf = 0;
conn->c_unix_local = 0;
/* destroy any sasl context */
sasl_dispose((sasl_conn_t**)&conn->c_sasl_conn);
@@ -388,6 +389,7 @@ connection_reset(Connection* conn, int ns, PRNetAddr * from, int fromLen, int is
/* Just initialize the SSL SSF to 0 now since the handshake isn't complete
* yet, which prevents us from getting the effective key length. */
conn->c_ssl_ssf = 0;
+ conn->c_local_ssf = 0;
}
/* Create a pool of threads for handling the operations */
@@ -507,12 +509,14 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
* allowed, which gives the connection a chance to meet the
* SSF requirements. We also allow UNBIND and ABANDON.*/
if ((conn->c_sasl_ssf < minssf) && (conn->c_ssl_ssf < minssf) &&
- (op->o_tag != LDAP_REQ_BIND) && (op->o_tag != LDAP_REQ_EXTENDED) &&
- (op->o_tag != LDAP_REQ_UNBIND) && (op->o_tag != LDAP_REQ_ABANDON)) {
+ (conn->c_local_ssf < minssf) &&(op->o_tag != LDAP_REQ_BIND) &&
+ (op->o_tag != LDAP_REQ_EXTENDED) && (op->o_tag != LDAP_REQ_UNBIND) &&
+ (op->o_tag != LDAP_REQ_ABANDON)) {
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" NSPRIu64 " op=%d UNPROCESSED OPERATION"
- " - Insufficient SSF (sasl_ssf=%d ssl_ssf=%d)\n",
- conn->c_connid, op->o_opid, conn->c_sasl_ssf, conn->c_ssl_ssf );
+ " - Insufficient SSF (local_ssf=%d sasl_ssf=%d ssl_ssf=%d)\n",
+ conn->c_connid, op->o_opid, conn->c_local_ssf,
+ conn->c_sasl_ssf, conn->c_ssl_ssf );
send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"Minimum SSF not met.", 0, NULL );
return;
@@ -2631,15 +2635,17 @@ op_copy_identity(Connection *conn, Operation *op)
/* copy isroot flag as well so root DN privileges are preserved */
op->o_isroot = conn->c_isroot;
- /* copy the highest SSF (between SASL and SSL/TLS) into the
- * operation for use by access control. */
- if (conn->c_sasl_ssf >= conn->c_ssl_ssf) {
+ /* copy the highest SSF (between local, SASL, and SSL/TLS)
+ * into the operation for use by access control. */
+ if ((conn->c_sasl_ssf >= conn->c_ssl_ssf) && (conn->c_sasl_ssf >= conn->c_local_ssf)) {
op->o_ssf = conn->c_sasl_ssf;
- } else {
+ } else if ((conn->c_ssl_ssf >= conn->c_sasl_ssf) && (conn->c_ssl_ssf >= conn->c_local_ssf)){
op->o_ssf = conn->c_ssl_ssf;
+ } else {
+ op->o_ssf = conn->c_local_ssf;
}
- PR_Unlock( conn->c_mutex );
+ PR_Unlock( conn->c_mutex );
}
/* Sets the SSL SSF in the connection struct. */
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 667826949..cda4a0437 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -2207,6 +2207,7 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
if( local )
{
conn->c_unix_local = 1;
+ conn->c_local_ssf = config_get_localssf();
slapd_identify_local_user(conn);
}
#endif
diff --git a/ldap/servers/slapd/extendop.c b/ldap/servers/slapd/extendop.c
index f7e6ebe31..17b2f7bc9 100644
--- a/ldap/servers/slapd/extendop.c
+++ b/ldap/servers/slapd/extendop.c
@@ -335,7 +335,8 @@ do_extended( Slapi_PBlock *pb )
}
/* If the minssf is not met, only allow startTLS. */
- if ((pb->pb_conn->c_sasl_ssf < minssf) && (pb->pb_conn->c_ssl_ssf < minssf)) {
+ if ((pb->pb_conn->c_sasl_ssf < minssf) && (pb->pb_conn->c_ssl_ssf < minssf) &&
+ (pb->pb_conn->c_local_ssf < minssf)) {
send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"Minimum SSF not met.", 0, NULL );
goto free_and_return;
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 15f2aca99..c3047bfdd 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -619,6 +619,9 @@ static struct config_get_and_set {
NULL, 0,
(void**)&global_slapdFrontendConfig.allow_anon_access, CONFIG_SPECIAL_ANON_ACCESS_SWITCH,
(ConfigGetFunc)config_get_anon_access_switch},
+ {CONFIG_LOCALSSF_ATTRIBUTE, config_set_localssf,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.localssf, CONFIG_INT, NULL},
{CONFIG_MINSSF_ATTRIBUTE, config_set_minssf,
NULL, 0,
(void**)&global_slapdFrontendConfig.minssf, CONFIG_INT, NULL},
@@ -900,6 +903,7 @@ FrontendConfig_init () {
cfg->outbound_ldap_io_timeout = SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT;
cfg->max_filter_nest_level = SLAPD_DEFAULT_MAX_FILTER_NEST_LEVEL;
cfg->maxsasliosize = SLAPD_DEFAULT_MAX_SASLIO_SIZE;
+ cfg->localssf = SLAPD_DEFAULT_LOCAL_SSF;
cfg->minssf = SLAPD_DEFAULT_MIN_SSF;
#ifdef _WIN32
@@ -4709,6 +4713,48 @@ config_get_maxsasliosize()
return maxsasliosize;
}
+int
+config_set_localssf( const char *attrname, char *value, char *errorbuf, int apply )
+{
+ int retVal = LDAP_SUCCESS;
+ int localssf;
+ char *endptr;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ localssf = (int) strtol(value, &endptr, 10);
+
+ /* Check for non-numeric garbage in the value */
+ if (*endptr != '\0') {
+ retVal = LDAP_OPERATIONS_ERROR;
+ }
+
+ /* Check for a value overflow */
+ if (((localssf == INT_MAX) || (localssf == INT_MIN)) && (errno == ERANGE)){
+ retVal = LDAP_OPERATIONS_ERROR;
+ }
+
+ /* Don't allow negative values. */
+ if (localssf < 0) {
+ retVal = LDAP_OPERATIONS_ERROR;
+ }
+
+ if (retVal != LDAP_SUCCESS) {
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "%s: \"%s\" is invalid. Value must range from 0 to %d",
+ attrname, value, INT_MAX );
+ } else if (apply) {
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapdFrontendConfig->localssf = localssf;
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ }
+
+ return retVal;
+}
+
int
config_set_minssf( const char *attrname, char *value, char *errorbuf, int apply )
{
@@ -4751,6 +4797,17 @@ config_set_minssf( const char *attrname, char *value, char *errorbuf, int apply
return retVal;
}
+int
+config_get_localssf()
+{
+ int localssf;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ localssf = slapdFrontendConfig->localssf;
+
+ return localssf;
+}
+
int
config_get_minssf()
{
diff --git a/ldap/servers/slapd/passwd_extop.c b/ldap/servers/slapd/passwd_extop.c
index e22a52d41..c1f00d2e4 100644
--- a/ldap/servers/slapd/passwd_extop.c
+++ b/ldap/servers/slapd/passwd_extop.c
@@ -462,7 +462,7 @@ passwd_modify_extop( Slapi_PBlock *pb )
char *oldPasswd = NULL;
char *newPasswd = NULL;
char *errMesg = NULL;
- int ret=0, rc=0, sasl_ssf=0, need_pwpolicy_ctrl=0;
+ int ret=0, rc=0, sasl_ssf=0, local_ssf=0, need_pwpolicy_ctrl=0;
ber_tag_t tag=0;
ber_len_t len=(ber_len_t)-1;
struct berval *extop_value = NULL;
@@ -517,8 +517,16 @@ passwd_modify_extop( Slapi_PBlock *pb )
goto free_and_return;
}
+ if ( slapi_pblock_get(pb, SLAPI_CONN_LOCAL_SSF, &local_ssf) != 0) {
+ errMesg = "Could not get local SSF from connection\n";
+ rc = LDAP_OPERATIONS_ERROR;
+ slapi_log_error( SLAPI_LOG_PLUGIN, "passwd_modify_extop",
+ errMesg );
+ goto free_and_return;
+ }
+
if ( ((conn->c_flags & CONN_FLAG_SSL) != CONN_FLAG_SSL) &&
- (sasl_ssf <= 1) ) {
+ (sasl_ssf <= 1) && (local_ssf <= 1)) {
errMesg = "Operation requires a secure connection.\n";
rc = LDAP_CONFIDENTIALITY_REQUIRED;
goto free_and_return;
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index 3d945cdda..6bc23758d 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -362,6 +362,16 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
(*(int *)value) = pblock->pb_conn->c_ssl_ssf;
PR_Unlock( pblock->pb_conn->c_mutex );
break;
+ case SLAPI_CONN_LOCAL_SSF:
+ if (pblock->pb_conn == NULL) {
+ LDAPDebug( LDAP_DEBUG_ANY,
+ "Connection is NULL and hence cannot access SLAPI_CONN_LOCAL_SSF \n", 0, 0, 0 );
+ return (-1);
+ }
+ PR_Lock( pblock->pb_conn->c_mutex );
+ (*(int *)value) = pblock->pb_conn->c_local_ssf;
+ PR_Unlock( pblock->pb_conn->c_mutex );
+ break;
case SLAPI_CONN_CERT:
if (pblock->pb_conn == NULL) {
LDAPDebug( LDAP_DEBUG_ANY,
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index dd7ec8898..3d22da5ad 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -367,6 +367,7 @@ int config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
int config_set_unauth_binds_switch(const char *attrname, char *value, char *errorbuf, int apply );
int config_set_require_secure_binds(const char *attrname, char *value, char *errorbuf, int apply );
int config_set_anon_access_switch(const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_localssf(const char *attrname, char *value, char *errorbuf, int apply );
int config_set_minssf(const char *attrname, char *value, char *errorbuf, int apply );
int config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply);
@@ -504,6 +505,7 @@ int config_get_outbound_ldap_io_timeout(void);
int config_get_unauth_binds_switch(void);
int config_get_require_secure_binds(void);
int config_get_anon_access_switch(void);
+int config_get_localssf(void);
int config_get_minssf(void);
int config_get_csnlogging();
#ifdef MEMPOOL_EXPERIMENTAL
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 9c655ef9d..65ee8cec7 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -285,6 +285,7 @@ typedef void (*VFP0)(void);
#define SLAPD_DEFAULT_MAX_THREADS 30 /* connection pool threads */
#define SLAPD_DEFAULT_MAX_THREADS_PER_CONN 5 /* allowed per connection */
#define SLAPD_DEFAULT_SCHEMA_IGNORE_TRAILING_SPACES LDAP_OFF
+#define SLAPD_DEFAULT_LOCAL_SSF 71 /* assume local connections are secure */
#define SLAPD_DEFAULT_MIN_SSF 0 /* allow unsecured connections (no privacy or integrity) */
/* We'd like this number to be prime for
@@ -1358,6 +1359,7 @@ typedef struct conn {
Slapi_Backend *c_bi_backend; /* which backend is doing the import */
void *c_extension; /* plugins are able to extend the Connection object */
void *c_sasl_conn; /* sasl library connection sasl_conn_t */
+ int c_local_ssf; /* flag to tell us the local SSF */
int c_sasl_ssf; /* flag to tell us the SASL SSF */
int c_ssl_ssf; /* flag to tell us the SSL/TLS SSF */
int c_unix_local; /* flag true for LDAPI */
@@ -1820,6 +1822,7 @@ typedef struct _slapdEntryPoints {
#define CONFIG_UNAUTH_BINDS_ATTRIBUTE "nsslapd-allow-unauthenticated-binds"
#define CONFIG_REQUIRE_SECURE_BINDS_ATTRIBUTE "nsslapd-require-secure-binds"
#define CONFIG_ANON_ACCESS_ATTRIBUTE "nsslapd-allow-anonymous-access"
+#define CONFIG_LOCALSSF_ATTRIBUTE "nsslapd-localssf"
#define CONFIG_MINSSF_ATTRIBUTE "nsslapd-minssf"
#ifndef _WIN32
#define CONFIG_LOCALUSER_ATTRIBUTE "nsslapd-localuser"
@@ -2123,6 +2126,7 @@ typedef struct _slapdFrontendConfig {
int allow_unauth_binds; /* switch to enable/disable unauthenticated binds */
int require_secure_binds; /* switch to require simple binds to use a secure channel */
int allow_anon_access; /* switch to enable/disable anonymous access */
+ int localssf; /* the security strength factor to assign to local conns (ldapi) */
int minssf; /* minimum security strength factor (for SASL and SSL/TLS) */
size_t maxsasliosize; /* limit incoming SASL IO packet size */
char *anon_limits_dn; /* template entry for anonymous resource limits */
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 821b9110e..e2c7750e0 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -5630,6 +5630,7 @@ int slapi_reslimit_get_integer_limit( Slapi_Connection *conn, int handle,
#define SLAPI_CONN_AUTHMETHOD 746
#define SLAPI_CONN_SASL_SSF 748
#define SLAPI_CONN_SSL_SSF 749
+#define SLAPI_CONN_LOCAL_SSF 751
/*
* Types of authentication for SLAPI_CONN_AUTHMETHOD
| 0 |
5c0a926ccbc84c70798fa4dd57193c26793d145e
|
389ds/389-ds-base
|
Bug 697027 - 8 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 8]
Description: Adding slapi_ch_free_string to free temporary variable
value; adding slapi_ch_array_free to free types_to_generate.
|
commit 5c0a926ccbc84c70798fa4dd57193c26793d145e
Author: Noriko Hosoi <[email protected]>
Date: Fri Apr 15 13:21:49 2011 -0700
Bug 697027 - 8 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 8]
Description: Adding slapi_ch_free_string to free temporary variable
value; adding slapi_ch_array_free to free types_to_generate.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index c457c0f9c..fc520c933 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -869,6 +869,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
"dna_parse_config_entry: failed to normalize dn: "
"%s\n", value);
ret = DNA_FAILURE;
+ slapi_ch_free_string(&value);
goto bail;
}
entry->shared_cfg_base = normdn;
@@ -883,6 +884,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
"%s=%s+%s=%s,%s", DNA_HOSTNAME,
hostname, DNA_PORTNUM, portnum, value);
ret = DNA_FAILURE;
+ slapi_ch_free_string(&value);
goto bail;
}
entry->shared_cfg_dn = normdn;
@@ -890,6 +892,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
"----------> %s [%s]\n", DNA_SHARED_CFG_DN,
entry->shared_cfg_base);
+ slapi_ch_free_string(&value);
}
value = slapi_entry_attr_get_charptr(e, DNA_THRESHOLD);
@@ -3002,6 +3005,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
errstr = slapi_ch_smprintf("Allocation of a new value for range"
" %s failed! Unable to proceed.",
config_entry->dn);
+ slapi_ch_array_free(types_to_generate);
break;
}
@@ -3060,6 +3064,8 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
slapi_ch_free_string(&value);
slapi_ch_free_string(&new_value);
slapi_ch_array_free(types_to_generate);
+ } else if (types_to_generate) {
+ slapi_ch_free((void **)&types_to_generate);
}
next:
list = PR_NEXT_LINK(list);
| 0 |
152473dd92c100b5b65d535d2b433c98a66068be
|
389ds/389-ds-base
|
Issue 85 - Remove legacy replication attribute
Bug description: In 389-ds all references to legacy replication
has been removed (except in schema). But if in lib389 a replica
is created it always sets nsds5ReplicaLegacyConsumer: off.
This is no longer needed and confusing.
Fix description: Remove the properties related to legacy
replication attribute. Fix basedn of Replicas object.
Fix replicaLegacy tests.
Reviewed by: mreynolds (Thanks!)
https://pagure.io/lib389/issue/85
|
commit 152473dd92c100b5b65d535d2b433c98a66068be
Author: Simon Pichugin <[email protected]>
Date: Tue Aug 15 10:06:13 2017 +0200
Issue 85 - Remove legacy replication attribute
Bug description: In 389-ds all references to legacy replication
has been removed (except in schema). But if in lib389 a replica
is created it always sets nsds5ReplicaLegacyConsumer: off.
This is no longer needed and confusing.
Fix description: Remove the properties related to legacy
replication attribute. Fix basedn of Replicas object.
Fix replicaLegacy tests.
Reviewed by: mreynolds (Thanks!)
https://pagure.io/lib389/issue/85
diff --git a/src/lib389/lib389/properties.py b/src/lib389/lib389/properties.py
index 99d0e13ad..2a9e17452 100644
--- a/src/lib389/lib389/properties.py
+++ b/src/lib389/lib389/properties.py
@@ -161,7 +161,6 @@ REPL_BIND_GROUP = 'nsds5replicabinddngroup'
REPL_BIND_GROUP_INTERVAL = 'nsds5replicabinddngroupcheckinterval'
REPL_REF = 'nsds5ReplicaReferral'
REPL_TOMBSTONE_PURGE_INTERVAL = 'nsds5ReplicaTombstonePurgeInterval'
-REPL_LEGACY_CONS = 'nsds5ReplicaLegacyConsumer'
REPL_CLEAN_RUV = 'nsds5ReplicaCleanRUV'
REPL_ABORT_RUV = 'nsds5ReplicaAbortCleanRUV'
REPL_COUNT_COUNT = 'nsds5ReplicaChangeCount'
@@ -170,7 +169,6 @@ REPL_RELEASE_TIMEOUT = 'nsds5replicaReleaseTimeout'
# The values are from the REST API
REPLICA_SUFFIX = 'suffix'
-REPLICA_LEGACY_CONS = 'ReplicaLegacyConsumer'
REPLICA_PURGE_DELAY = 'ReplicaPurgeDelay'
REPLICA_ROOT = 'ReplicaRoot'
REPLICA_PROTOCOL_TIMEOUT = 'ReplicaProtocolTimeout'
@@ -198,7 +196,6 @@ REPLICA_PROPNAME_TO_ATTRNAME = {REPLICA_SUFFIX: REPL_ROOT,
REPLICA_ROOT: REPL_ROOT,
REPLICA_ID: REPL_ID,
REPLICA_TYPE: REPL_TYPE,
- REPLICA_LEGACY_CONS: REPL_LEGACY_CONS,
REPLICA_PURGE_INTERVAL:
REPL_TOMBSTONE_PURGE_INTERVAL,
REPLICA_PURGE_DELAY: REPL_PURGE_DELAY,
diff --git a/src/lib389/lib389/replica.py b/src/lib389/lib389/replica.py
index a0283962d..6d24a7ac8 100644
--- a/src/lib389/lib389/replica.py
+++ b/src/lib389/lib389/replica.py
@@ -174,7 +174,6 @@ class ReplicaLegacy(object):
REPLICA_SUFFIX
REPLICA_ID
REPLICA_TYPE
- REPLICA_LEGACY_CONS
REPLICA_BINDDN
REPLICA_PURGE_DELAY
REPLICA_PRECISE_PURGING
@@ -300,7 +299,6 @@ class ReplicaLegacy(object):
REPLICA_SUFFIX
REPLICA_ID
REPLICA_TYPE
- REPLICA_LEGACY_CONS ['off']
REPLICA_BINDDN [defaultProperties[REPLICATION_BIND_DN]]
REPLICA_PURGE_DELAY
REPLICA_PRECISE_PURGING
@@ -359,7 +357,6 @@ class ReplicaLegacy(object):
properties[prop] = args[prop]
# Now set default values of unset properties
- ReplicaLegacy._set_or_default(REPLICA_LEGACY_CONS, properties, 'off')
ReplicaLegacy._set_or_default(REPLICA_BINDDN, properties,
[defaultProperties[REPLICATION_BIND_DN]])
@@ -806,7 +803,7 @@ class Replica(DSLdapObject):
super(Replica, self).__init__(instance, dn, batch)
self._rdn_attribute = 'cn'
- self._must_attributes = ['cn', REPL_LEGACY_CONS, REPL_TYPE,
+ self._must_attributes = ['cn', REPL_TYPE,
REPL_ROOT, REPL_BINDDN, REPL_ID]
self._create_objectclasses = ['top', 'extensibleObject',
@@ -1259,7 +1256,7 @@ class Replicas(DSLdapObjects):
rtype = REPLICA_RDONLY_TYPE
# Set the properties provided as mandatory parameter
- properties = {'cn': RDN_REPLICA,
+ properties = {'cn': 'replica',
REPL_ROOT: suffix,
REPL_ID: str(replicaID),
REPL_TYPE: str(rtype)}
@@ -1271,10 +1268,6 @@ class Replicas(DSLdapObjects):
raise ValueError("unknown property: %s" % prop)
properties[prop] = args[prop]
- # Now set default values of unset properties
- if REPLICA_LEGACY_CONS not in properties:
- properties[REPL_LEGACY_CONS] = 'off'
-
# Set flags explicitly, so it will be more readable
if role == ReplicaRole.CONSUMER:
properties[REPL_FLAGS] = str(REPLICA_FLAGS_RDONLY)
@@ -1310,7 +1303,7 @@ class Replicas(DSLdapObjects):
# Now create the replica entry
mtents = self._instance.mappingtree.list(suffix=suffix)
- suffix_dn = mtents[0].dn
+ self._basedn = mtents[0].dn
replica = self.create(RDN_REPLICA, properties)
replica._suffix = suffix
diff --git a/src/lib389/lib389/tests/replicaLegacy_test.py b/src/lib389/lib389/tests/replicaLegacy_test.py
index 670b81da3..72bd338e2 100644
--- a/src/lib389/lib389/tests/replicaLegacy_test.py
+++ b/src/lib389/lib389/tests/replicaLegacy_test.py
@@ -399,8 +399,7 @@ def test_setProperties(topology):
log.info("\n\n##########\n### SETPROPERTIES\n############")
# set valid values to SUFFIX_1
- properties = {REPLICA_LEGACY_CONS: 'off',
- REPLICA_BINDDN: NEW_RM_1,
+ properties = {REPLICA_BINDDN: NEW_RM_1,
REPLICA_PURGE_INTERVAL: str(3600),
REPLICA_PURGE_DELAY: str(5 * 24 * 3600),
REPLICA_REFERRAL: "ldap://%s:1234/" % LOCALHOST}
@@ -425,20 +424,20 @@ def test_setProperties(topology):
# check call without suffix/dn/entry raise InvalidArgumentError
with pytest.raises(InvalidArgumentError) as excinfo:
- properties = {REPLICA_LEGACY_CONS: 'off'}
+ properties = {REPLICA_BINDDN: NEW_RM_1}
topology.master.replica.setProperties(properties=properties)
log.info("Exception (expected): %s" % str(excinfo.value))
# check that if we do not provide a valid entry it raises ValueError
with pytest.raises(ValueError) as excinfo:
- properties = {REPLICA_LEGACY_CONS: 'off'}
+ properties = {REPLICA_BINDDN: NEW_RM_1}
topology.master.replica.setProperties(replica_entry="dummy",
properties=properties)
log.info("Exception (expected): %s" % str(excinfo.value))
# check that with an invalid suffix or replica_dn it raise ValueError
with pytest.raises(ValueError) as excinfo:
- properties = {REPLICA_LEGACY_CONS: 'off'}
+ properties = {REPLICA_BINDDN: NEW_RM_1}
topology.master.replica.setProperties(suffix="dummy",
properties=properties)
log.info("Exception (expected): %s" % str(excinfo.value))
@@ -449,7 +448,6 @@ def test_getProperties(topology):
log.info("\n\n############\n### GETPROPERTIES\n###########")
with pytest.raises(NotImplementedError) as excinfo:
- properties = {REPLICA_LEGACY_CONS: 'off'}
topology.master.replica.getProperties(suffix=NEW_SUFFIX_1)
log.info("Exception (expected): %s" % str(excinfo.value))
| 0 |
940a0e93ac1bf175a42c34c5b6094aeac9a5af20
|
389ds/389-ds-base
|
Fix mapping of street and streetAddress attrs
|
commit 940a0e93ac1bf175a42c34c5b6094aeac9a5af20
Author: David Boreham <[email protected]>
Date: Mon Apr 25 20:33:54 2005 +0000
Fix mapping of street and streetAddress attrs
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index b01e3705b..3e5cca493 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -126,7 +126,6 @@ static char* windows_user_matching_attributes[] =
"registeredAddress",
"sn",
"st",
- "street",
"telephoneNumber",
"teletexTerminalIdentifier",
"telexNumber",
@@ -160,7 +159,6 @@ static char* windows_group_matching_attributes[] =
"registeredAddress",
"sn",
"st",
- "street",
"telephoneNumber",
"teletexTerminalIdentifier",
"telexNumber",
@@ -194,6 +192,7 @@ static windows_attribute_map user_attribute_map[] =
{ "logonHours", "ntUserLogonHours", bidirectional, always, normal},
{ "maxStorage", "ntUserMaxStorage", bidirectional, always, normal},
{ "profilePath", "ntUserProfile", bidirectional, always, normal},
+ { "streetAddress", "street", bidirectional, always, normal},
{ "userParameters", "ntUserParms", bidirectional, always, normal},
{ "userWorkstations", "ntUserWorkstations", bidirectional, always, normal},
{ "sAMAccountName", "ntUserDomainId", bidirectional, createonly, normal},
@@ -210,6 +209,7 @@ static windows_attribute_map group_attribute_map[] =
{
{ "groupType", "ntGroupType", bidirectional, createonly, normal},
{ "sAMAccountName", "ntUserDomainId", bidirectional, createonly, normal},
+ { "streetAddress", "street", bidirectional, always, normal},
{ "member", "uniquemember", bidirectional, always, dnmap},
{NULL, NULL, -1}
};
| 0 |
856d7f0d6904a03cd6c2e67831403793e9e73abe
|
389ds/389-ds-base
|
Issue 5517 - Replication conflict CI test sometime fails (#5518)
fix a Modrdn conflict resolution issue because wrong dn is used
to rename the subtree in entryrdn index.
|
commit 856d7f0d6904a03cd6c2e67831403793e9e73abe
Author: progier389 <[email protected]>
Date: Wed Feb 8 19:07:18 2023 +0100
Issue 5517 - Replication conflict CI test sometime fails (#5518)
fix a Modrdn conflict resolution issue because wrong dn is used
to rename the subtree in entryrdn index.
diff --git a/dirsrvtests/tests/suites/replication/conflict_resolve_test.py b/dirsrvtests/tests/suites/replication/conflict_resolve_test.py
index be30d418c..0d25bd5df 100644
--- a/dirsrvtests/tests/suites/replication/conflict_resolve_test.py
+++ b/dirsrvtests/tests/suites/replication/conflict_resolve_test.py
@@ -17,9 +17,10 @@ from lib389.idm.nscontainer import nsContainers
from lib389.idm.user import UserAccounts, UserAccount
from lib389.idm.group import Groups
from lib389.idm.organizationalunit import OrganizationalUnits
-from lib389.replica import ReplicationManager
+from lib389.replica import ReplicationManager, Replicas
from lib389.agreement import Agreements
from lib389.plugins import MemberOfPlugin
+from lib389.dirsrv_log import DirsrvErrorLog
pytestmark = pytest.mark.tier1
@@ -129,17 +130,37 @@ def _test_base(topology):
return base_m2
+def _dump_logs(topology):
+ """ Logs instances error logs"""
+ for inst in topology:
+ errlog = DirsrvErrorLog(inst)
+ log.info(f'{inst.serverid} errorlog:')
+ for l in errlog.readlines():
+ log.info(l.strip())
+
+
def _delete_test_base(inst, base_m2_dn):
"""Delete test container with entries and entry conflicts"""
- ents = inst.search_s(base_m2_dn, ldap.SCOPE_SUBTREE, filterstr="(|(objectclass=*)(objectclass=ldapsubentry))")
+ try:
+ ents = inst.search_s(base_m2_dn, ldap.SCOPE_SUBTREE, filterstr="(|(objectclass=*)(objectclass=ldapsubentry))")
+ for ent in sorted(ents, key=lambda e: len(e.dn), reverse=True):
+ log.debug("Delete entry children {}".format(ent.dn))
+ try:
+ inst.delete_ext_s(ent.dn)
+ except ldap.NO_SUCH_OBJECT: # For the case with objectclass: glue entries
+ pass
+ except ldap.NO_SUCH_OBJECT: # Subtree is already removed.
+ pass
- for ent in sorted(ents, key=lambda e: len(e.dn), reverse=True):
- log.debug("Delete entry children {}".format(ent.dn))
- try:
- inst.delete_ext_s(ent.dn)
- except ldap.NO_SUCH_OBJECT: # For the case with objectclass: glue entries
- pass
+
+def _resume_agmts(inst):
+ """Resume all agreements in the instance"""
+
+ replicas = Replicas(inst)
+ replica = replicas.get(DEFAULT_SUFFIX)
+ for agreement in replica.get_agreements().list():
+ agreement.resume()
@pytest.fixture
@@ -149,6 +170,16 @@ def base_m2(topology_m2, request):
def fin():
if not DEBUGGING:
_delete_test_base(topology_m2.ms["supplier1"], tb.dn)
+ _delete_test_base(topology_m2.ms["supplier2"], tb.dn)
+ # Replication may break while deleting the container because naming
+ # conflict entries still exists on the other side
+ # Note IMHO there a bug in the entryrdn handling of replicated delete operation
+ # ( children naming conflict or glue entries older than the parent delete operation should
+ # should be deleted when the parent is deleted )
+ # So let restarts the agmt once everything is deleted.
+ topology_m2.pause_all_replicas()
+ topology_m2.resume_all_replicas()
+
request.addfinalizer(fin)
return tb
@@ -363,7 +394,6 @@ class TestTwoSuppliers:
topology_m2.resume_all_replicas()
repl.test_replication_topology(topology_m2)
- time.sleep(30)
user_dns_m1 = [user.dn for user in test_users_m1.list()]
user_dns_m2 = [user.dn for user in test_users_m2.list()]
@@ -796,17 +826,22 @@ class TestTwoSuppliers:
M1 = topology_m2.ms["supplier1"]
M2 = topology_m2.ms["supplier2"]
+ repl = ReplicationManager(SUFFIX)
# add a test user
test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None)
user_1 = test_users_m1.create_test_user(uid=1000)
test_users_m2 = UserAccount(M2, user_1.dn)
# Waiting fo the user to be replicated
- for i in range(0,10):
+ for i in range(0,60):
time.sleep(1)
if test_users_m2.exists():
break
- assert(test_users_m2.exists())
+ try:
+ assert(test_users_m2.exists())
+ except AssertionError as e:
+ _dump_logs(topology_m2)
+ raise e from None
# Stop replication agreements
topology_m2.pause_all_replicas()
@@ -825,7 +860,7 @@ class TestTwoSuppliers:
# resume replication agreements
topology_m2.resume_all_replicas()
- time.sleep(5)
+ repl.test_replication_topology(topology_m2)
# check that on M1, the entry 'uid' has two values 'foo1' and 'foo2'
final_dn = re.sub('^.*1000,', 'uid=foo2,', original_dn)
@@ -880,6 +915,7 @@ class TestTwoSuppliers:
M1 = topology_m2.ms["supplier1"]
M2 = topology_m2.ms["supplier2"]
+ repl = ReplicationManager(SUFFIX)
# add a test user with a dummy 'uid' extra value because modrdn removes
# uid that conflict with 'account' objectclass
@@ -890,11 +926,15 @@ class TestTwoSuppliers:
test_users_m2 = UserAccount(M2, user_1.dn)
# Waiting fo the user to be replicated
- for i in range(0,10):
+ for i in range(0,60):
time.sleep(1)
if test_users_m2.exists():
break
- assert(test_users_m2.exists())
+ try:
+ assert(test_users_m2.exists())
+ except AssertionError as e:
+ _dump_logs(topology_m2)
+ raise e from None
# Stop replication agreements
topology_m2.pause_all_replicas()
@@ -913,7 +953,7 @@ class TestTwoSuppliers:
# resume replication agreements
topology_m2.resume_all_replicas()
- time.sleep(5)
+ repl.test_replication_topology(topology_m2)
# check that on M1, the entry 'employeenumber' has value 'foo1'
final_dn = re.sub('^.*1000,', 'employeenumber=foo2,', original_dn)
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
index b68a0cce8..6d6b6864b 100644
--- a/ldap/servers/slapd/back-ldbm/cache.c
+++ b/ldap/servers/slapd/back-ldbm/cache.c
@@ -44,7 +44,8 @@
if (!(_x)) { \
slapi_log_err(SLAPI_LOG_ERR, "cache", "BAD CACHE ASSERTION at %s/%d: %s\n", \
__FILE__, __LINE__, #_x); \
- *(char *)0L = 23; \
+ slapi_log_backtrace(SLAPI_LOG_ERR); \
+ *(char *)23L = 1; \
} \
} while (0)
@@ -514,6 +515,30 @@ flush_remove_entry(struct timespec *entry_time, struct timespec *start_time)
}
}
+static inline void
+dbgec_test_if_entry_pointer_is_valid(void *e, void *prev, int slot, int line)
+{
+ /* Check if the entry pointer is rightly aligned and crash loudly otherwise */
+ if ( ((uint64_t)e) & ((sizeof(long))-1) ) {
+ /* If this message occurs, it means that we have reproduced the elusive entry cache corruption
+ * seen first while fixing replication conflict_resolution CI test
+ * FYI some debug attempt have been stored in https://github.com/progier389/389-ds-base.git
+ * in branches:
+ * debug-stuff1 (older try with log of debugging trick in slapd/dbgec*)
+ * debug-stuff2: Log the dn associated with backentries in a mmap file and retrieve the
+ * dn of the corrupted entry.
+ * Note: if we are able to reproduce using this debug stuff and if it is always the same entry
+ * we may catch the issue by adding a watchpoint when adding that backentry
+ * Note: you should disable the setuid to be able to use watchpoint
+ */
+ slapi_log_err(SLAPI_LOG_FATAL, "dbgec_test_if_entry_pointer_is_valid", "cache.c[%d]: Wrong entry address: %p Previous entry address is: %p hash table slot is %d\n", line, e, prev, slot);
+ slapi_log_backtrace(SLAPI_LOG_FATAL);
+ *(char*)23 = 1; /* abort() somehow corrupt gdb stack backtrace so lets generate a SIGSEGV */
+ abort();
+ }
+}
+
+
/*
* Flush all the cache entries that were added after the "start time"
* This is called when a backend transaction plugin fails, and we need
@@ -536,6 +561,7 @@ flush_hash(struct cache *cache, struct timespec *start_time, int32_t type)
for (size_t i = 0; i < ht->size; i++) {
e = ht->slot[i];
+ dbgec_test_if_entry_pointer_is_valid(e, NULL, i, __LINE__);
while (e) {
struct backcommon *entry = (struct backcommon *)e;
uint64_t remove_it = 0;
@@ -547,6 +573,7 @@ flush_hash(struct cache *cache, struct timespec *start_time, int32_t type)
}
laste = e;
e = HASH_NEXT(ht, e);
+ dbgec_test_if_entry_pointer_is_valid(e, laste, i, __LINE__);
if (remove_it) {
/* since we have the cache lock we know we can trust refcnt */
@@ -577,6 +604,7 @@ flush_hash(struct cache *cache, struct timespec *start_time, int32_t type)
for (size_t i = 0; i < ht->size; i++) {
e = ht->slot[i];
+ dbgec_test_if_entry_pointer_is_valid(e, NULL, i, __LINE__);
while (e) {
struct backcommon *entry = (struct backcommon *)e;
uint64_t remove_it = 0;
@@ -588,6 +616,7 @@ flush_hash(struct cache *cache, struct timespec *start_time, int32_t type)
}
laste = e;
e = HASH_NEXT(ht, e);
+ dbgec_test_if_entry_pointer_is_valid(e, laste, i, __LINE__);
if (remove_it) {
/* since we have the cache lock we know we can trust refcnt */
@@ -2165,7 +2194,7 @@ check_entry_cache(struct cache *cache, struct backentry *e)
struct backentry *debug_e = cache_find_dn(cache,
slapi_sdn_get_dn(sdn),
slapi_sdn_get_ndn_len(sdn));
- in_cache = cache_is_in_cache(cache, (void *)e);
+ int in_cache = cache_is_in_cache(cache, (void *)e);
if (in_cache) {
if (debug_e) { /* e is in cache */
CACHE_RETURN(cache, &debug_e);
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c
index c6037352f..3bcd71584 100644
--- a/ldap/servers/slapd/back-ldbm/filterindex.c
+++ b/ldap/servers/slapd/back-ldbm/filterindex.c
@@ -1054,8 +1054,7 @@ keys2idl(
int allidslimit)
{
IDList *idl = NULL;
- Op_stat *op_stat;
- PRBool collect_stat = PR_FALSE;
+ Op_stat *op_stat = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "keys2idl", "=> type %s indextype %s\n", type, indextype);
@@ -1063,8 +1062,9 @@ keys2idl(
if (LDAP_STAT_READ_INDEX & config_get_statlog_level()) {
op_stat = op_stat_get_operation_extension(pb);
if (op_stat->search_stat) {
- collect_stat = PR_TRUE;
clock_gettime(CLOCK_MONOTONIC, &(op_stat->search_stat->keys_lookup_start));
+ } else {
+ op_stat = NULL;
}
}
@@ -1074,7 +1074,7 @@ keys2idl(
int key_len;
idl2 = index_read_ext_allids(pb, be, type, indextype, slapi_value_get_berval(ivals[i]), txn, err, unindexed, allidslimit);
- if (collect_stat) {
+ if (op_stat) {
/* gather the index lookup statistics */
key_stat = (struct component_keys_lookup *) slapi_ch_calloc(1, sizeof (struct component_keys_lookup));
@@ -1139,7 +1139,7 @@ keys2idl(
}
/* All the keys have been fetch, time to take the completion time */
- if (collect_stat) {
+ if (op_stat) {
clock_gettime(CLOCK_MONOTONIC, &(op_stat->search_stat->keys_lookup_end));
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 32a8cd657..c5e9be4aa 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -1126,9 +1126,10 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
*/
if (entryrdn_get_switch()) /* subtree-rename: on */
{
+ const Slapi_DN *oldsdn = slapi_entry_get_sdn_const(e->ep_entry);
Slapi_RDN newsrdn;
slapi_rdn_init_sdn(&newsrdn, (const Slapi_DN *)&dn_newdn);
- retval = entryrdn_rename_subtree(be, (const Slapi_DN *)sdn, &newsrdn,
+ retval = entryrdn_rename_subtree(be, oldsdn, &newsrdn,
(const Slapi_DN *)dn_newsuperiordn,
e->ep_id, &txn, is_tombstone);
slapi_rdn_done(&newsrdn);
| 0 |
f02cbddfa4a65e5ce2f6fbef1aadccacc922e0c5
|
389ds/389-ds-base
|
Ticket - lib389 - Python 3 support for memberof plugin test suit
Bug Description: ticket49064_test.py tests did not support python 3
Fix Description: Move the test file from tickets to suits/memberof_plugin/regression_test.py,
fix config_memberof and other methods to use DSLdapObject,
create test users and test groups using DSLdapObject in test case,
fix some docstrings and add more comments. Remove add_user,
add_group, update_member and memberof_fixup_task methods.
Remove ticket49064_test.py from dirsrvtests/tests/tickets/
https://pagure.io/lib389/issue/3
Reviewed by: William Brown (Huge Thanks!), spichugi
Signed-off-by: Simon Pichugin <[email protected]>
|
commit f02cbddfa4a65e5ce2f6fbef1aadccacc922e0c5
Author: Amita Sharma <[email protected]>
Date: Thu Nov 9 18:41:05 2017 +0530
Ticket - lib389 - Python 3 support for memberof plugin test suit
Bug Description: ticket49064_test.py tests did not support python 3
Fix Description: Move the test file from tickets to suits/memberof_plugin/regression_test.py,
fix config_memberof and other methods to use DSLdapObject,
create test users and test groups using DSLdapObject in test case,
fix some docstrings and add more comments. Remove add_user,
add_group, update_member and memberof_fixup_task methods.
Remove ticket49064_test.py from dirsrvtests/tests/tickets/
https://pagure.io/lib389/issue/3
Reviewed by: William Brown (Huge Thanks!), spichugi
Signed-off-by: Simon Pichugin <[email protected]>
diff --git a/dirsrvtests/tests/suites/memberof_plugin/regression_test.py b/dirsrvtests/tests/suites/memberof_plugin/regression_test.py
new file mode 100644
index 000000000..6ba421799
--- /dev/null
+++ b/dirsrvtests/tests/suites/memberof_plugin/regression_test.py
@@ -0,0 +1,241 @@
+import logging
+import pytest
+import os
+import time
+import ldap
+import subprocess
+from lib389.utils import ds_is_older
+from lib389.topologies import topology_m1h1c1 as topo
+from lib389._constants import *
+from lib389.plugins import MemberOfPlugin
+from lib389 import agreement
+from lib389.idm.user import UserAccount, UserAccounts, TEST_USER_PROPERTIES
+from lib389.idm.group import Groups, Group
+
+# Skip on older versions
+pytestmark = pytest.mark.skipif(ds_is_older('1.3.7'), reason="Not implemented")
+
+USER_CN='user_'
+GROUP_CN='group_'
+
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+
+def config_memberof(server):
+ # Configure fractional to prevent total init to send memberof
+ memberof = MemberOfPlugin(server)
+ memberof.enable()
+ memberof.set_autoaddoc('nsMemberOf')
+ server.restart()
+ ents = server.agreement.list(suffix=DEFAULT_SUFFIX)
+ for ent in ents:
+ log.info('update %s to add nsDS5ReplicatedAttributeListTotal' % ent.dn)
+ server.agreement.setProperties(agmnt_dn=ents[0].dn,
+ properties={RA_FRAC_EXCLUDE:'(objectclass=*) $ EXCLUDE memberOf',
+ RA_FRAC_EXCLUDE_TOTAL_UPDATE:'(objectclass=*) $ EXCLUDE '})
+
+
+def send_updates_now(server):
+ ents = server.agreement.list(suffix=DEFAULT_SUFFIX)
+ for ent in ents:
+ server.agreement.pause(ent.dn)
+ server.agreement.resume(ent.dn)
+
+
+def _find_memberof(server, member_dn, group_dn):
+ #To get the specific server's (M1, C1 and H1) user and group
+ user = UserAccount(server, member_dn)
+ assert user.exists()
+ group = Group(server, group_dn)
+ assert group.exists()
+
+ #test that the user entry should have memberof attribute with sepecified group dn value
+ assert group._dn in user.get_attr_vals_utf8('memberOf')
+
+
[email protected]
+def test_memberof_with_repl(topo):
+ """Test that we allowed to enable MemberOf plugin in dedicated consumer
+
+ :id: 60c11636-55a1-4704-9e09-2c6bcc828de4
+ :setup: 1 Master - 1 Hub - 1 Consumer
+ :steps:
+ 1. Configure replication to EXCLUDE memberof
+ 2. Enable memberof plugin
+ 3. Create users/groups
+ 4. Make user_0 member of group_0
+ 5. Checks that user_0 is memberof group_0 on M,H,C
+ 6. Make group_0 member of group_1 (nest group)
+ 7. Checks that user_0 is memberof group_0 and group_1 on M,H,C
+ 8. Check group_0 is memberof group_1 on M,H,C
+ 9. Remove group_0 from group_1
+ 10. Check group_0 and user_0 are NOT memberof group_1 on M,H,C
+ 11. Remove user_0 from group_0
+ 12. Check user_0 is not memberof group_0 and group_1 on M,H,C
+ 13. Disable memberof on C
+ 14. make user_0 member of group_1
+ 15. Checks that user_0 is memberof group_0 on M,H but not on C
+ 16. Enable memberof on C
+ 17. Checks that user_0 is memberof group_0 on M,H but not on C
+ 18. Run memberof fixup task
+ 19. Checks that user_0 is memberof group_0 on M,H,C
+ :expectedresults:
+ 1. Configuration should be successful
+ 2. Plugin should be enabled
+ 3. Users and groups should be created
+ 4. user_0 should be member of group_0
+ 5. user_0 should be memberof group_0 on M,H,C
+ 6. group_0 should be member of group_1
+ 7. user_0 should be memberof group_0 and group_1 on M,H,C
+ 8. group_0 should be memberof group_1 on M,H,C
+ 9. group_0 from group_1 removal should be successful
+ 10. group_0 and user_0 should not be memberof group_1 on M,H,C
+ 11. user_0 from group_0 remove should be successful
+ 12. user_0 should not be memberof group_0 and group_1 on M,H,C
+ 13. memberof should be disabled on C
+ 14. user_0 should be member of group_1
+ 15. user_0 should be memberof group_0 on M,H and should not on C
+ 16. Enable memberof on C should be successful
+ 17. user_0 should be memberof group_0 on M,H should not on C
+ 18. memberof fixup task should be successful
+ 19. user_0 should be memberof group_0 on M,H,C
+ """
+
+ M1 = topo.ms["master1"]
+ H1 = topo.hs["hub1"]
+ C1 = topo.cs["consumer1"]
+
+ # Step 1 & 2
+ M1.config.enable_log('audit')
+ config_memberof(M1)
+ M1.restart()
+
+ H1.config.enable_log('audit')
+ config_memberof(H1)
+ H1.restart()
+
+ C1.config.enable_log('audit')
+ config_memberof(C1)
+ C1.restart()
+
+ #Declare lists of users and groups
+ test_users = []
+ test_groups = []
+
+ # Step 3
+ #In for loop create users and add them in the user list
+ #it creates user_0 to user_9 (range is fun)
+ for i in range(10):
+ CN = '%s%d' % (USER_CN, i)
+ users = UserAccounts(M1, SUFFIX)
+ user_props = TEST_USER_PROPERTIES.copy()
+ user_props.update({'uid': CN, 'cn': CN, 'sn': '_%s' % CN})
+ testuser = users.create(properties=user_props)
+ time.sleep(2)
+ test_users.append(testuser)
+
+ #In for loop create groups and add them to the group list
+ #it creates group_0 to group_2 (range is fun)
+ for i in range(3):
+ CN = '%s%d' % (GROUP_CN, i)
+ groups = Groups(M1, SUFFIX)
+ testgroup = groups.create(properties={'cn' : CN})
+ time.sleep(2)
+ test_groups.append(testgroup)
+
+ # Step 4
+ #Now start testing by adding differnt user to differn group
+ if not ds_is_older('1.3.7'):
+ test_groups[0].remove('objectClass', 'nsMemberOf')
+
+ member_dn = test_users[0].dn
+ grp0_dn = test_groups[0].dn
+ grp1_dn = test_groups[1].dn
+
+ test_groups[0].add_member(member_dn)
+ time.sleep(5)
+
+ # Step 5
+ for i in [M1, H1, C1]:
+ _find_memberof(i, member_dn, grp0_dn)
+
+ # Step 6
+ test_groups[1].add_member(test_groups[0].dn)
+ time.sleep(5)
+
+ # Step 7
+ for i in [grp0_dn, grp1_dn]:
+ for inst in [M1, H1, C1]:
+ _find_memberof(inst, member_dn, i)
+
+ # Step 8
+ for i in [M1, H1, C1]:
+ _find_memberof(i, grp0_dn, grp1_dn)
+
+ # Step 9
+ test_groups[1].remove_member(test_groups[0].dn)
+ time.sleep(5)
+
+ # Step 10
+ # For negative testcase, we are using assertionerror
+ for inst in [M1, H1, C1]:
+ for i in [grp0_dn, member_dn]:
+ with pytest.raises(AssertionError):
+ _find_memberof(inst, i, grp1_dn)
+
+ # Step 11
+ test_groups[0].remove_member(member_dn)
+ time.sleep(5)
+
+ # Step 12
+ for inst in [M1, H1, C1]:
+ for grp in [grp0_dn, grp1_dn]:
+ with pytest.raises(AssertionError):
+ _find_memberof(inst, member_dn, grp)
+
+ # Step 13
+ C1.plugins.disable(name=PLUGIN_MEMBER_OF)
+ C1.restart()
+
+ # Step 14
+ test_groups[0].add_member(member_dn)
+ time.sleep(5)
+
+ # Step 15
+ for i in [M1, H1]:
+ _find_memberof(i, member_dn, grp0_dn)
+ with pytest.raises(AssertionError):
+ _find_memberof(C1, member_dn, grp0_dn)
+
+ # Step 16
+ memberof = MemberOfPlugin(C1)
+ memberof.enable()
+ C1.restart()
+
+ # Step 17
+ for i in [M1, H1]:
+ _find_memberof(i, member_dn, grp0_dn)
+ with pytest.raises(AssertionError):
+ _find_memberof(C1, member_dn, grp0_dn)
+
+ # Step 18
+ memberof.fixup(SUFFIX)
+ time.sleep(5)
+
+ # Step 19
+ for i in [M1, H1, C1]:
+ _find_memberof(i, member_dn, grp0_dn)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
+
+
diff --git a/dirsrvtests/tests/tickets/ticket49064_test.py b/dirsrvtests/tests/tickets/ticket49064_test.py
deleted file mode 100644
index 772adb069..000000000
--- a/dirsrvtests/tests/tickets/ticket49064_test.py
+++ /dev/null
@@ -1,261 +0,0 @@
-import logging
-import pytest
-import os
-import time
-import ldap
-import subprocess
-from lib389.utils import ds_is_older
-from lib389.topologies import topology_m1h1c1 as topo
-from lib389._constants import *
-from lib389 import Entry
-
-# Skip on older versions
-pytestmark = pytest.mark.skipif(ds_is_older('1.3.7'), reason="Not implemented")
-
-USER_CN='user_'
-GROUP_CN='group_'
-FIXUP_FILTER = '(objectClass=*)'
-FIXUP_CMD = 'fixup-memberof.pl'
-
-DEBUGGING = os.getenv("DEBUGGING", default=False)
-if DEBUGGING:
- logging.getLogger(__name__).setLevel(logging.DEBUG)
-else:
- logging.getLogger(__name__).setLevel(logging.INFO)
-log = logging.getLogger(__name__)
-
-def memberof_fixup_task(server):
- sbin_dir = server.get_sbin_dir()
- memof_task = os.path.join(sbin_dir, FIXUP_CMD)
- try:
- output = subprocess.check_output(
- [memof_task, '-D', DN_DM, '-w', PASSWORD, '-b', SUFFIX, '-Z', SERVERID_CONSUMER_1, '-f', FIXUP_FILTER])
- except subprocess.CalledProcessError as err:
- output = err.output
- log.info('output: {}'.format(output))
- expected = "Successfully added task entry"
- assert expected in output
-
-def config_memberof(server):
-
- server.plugins.enable(name=PLUGIN_MEMBER_OF)
- MEMBEROF_PLUGIN_DN = ('cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config')
- server.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_REPLACE,
- 'memberOfAllBackends',
- 'on'),
- (ldap.MOD_REPLACE, 'memberOfAutoAddOC', 'nsMemberOf')])
- # Configure fractional to prevent total init to send memberof
- ents = server.agreement.list(suffix=DEFAULT_SUFFIX)
- for ent in ents:
- log.info('update %s to add nsDS5ReplicatedAttributeListTotal' % ent.dn)
- server.modify_s(ent.dn,
- [(ldap.MOD_REPLACE,
- 'nsDS5ReplicatedAttributeListTotal',
- '(objectclass=*) $ EXCLUDE '),
- (ldap.MOD_REPLACE,
- 'nsDS5ReplicatedAttributeList',
- '(objectclass=*) $ EXCLUDE memberOf')])
-
-
-def send_updates_now(server):
-
- ents = server.agreement.list(suffix=DEFAULT_SUFFIX)
- for ent in ents:
- server.agreement.pause(ent.dn)
- server.agreement.resume(ent.dn)
-
-def add_user(server, no, desc='dummy', sleep=True):
- cn = '%s%d' % (USER_CN, no)
- dn = 'cn=%s,ou=people,%s' % (cn, SUFFIX)
- log.fatal('Adding user (%s): ' % dn)
- server.add_s(Entry((dn, {'objectclass': ['top', 'person', 'inetuser'],
- 'sn': ['_%s' % cn],
- 'description': [desc]})))
- if sleep:
- time.sleep(2)
-
-def add_group(server, nr, sleep=True):
- cn = '%s%d' % (GROUP_CN, nr)
- dn = 'cn=%s,ou=groups,%s' % (cn, SUFFIX)
- server.add_s(Entry((dn, {'objectclass': ['top', 'groupofnames'],
- 'description': 'group %d' % nr})))
- if sleep:
- time.sleep(2)
-
-def update_member(server, member_dn, group_dn, op, sleep=True):
- mod = [(op, 'member', member_dn)]
- server.modify_s(group_dn, mod)
- if sleep:
- time.sleep(2)
-
-def _find_memberof(server, member_dn, group_dn, find_result=True):
- ent = server.getEntry(member_dn, ldap.SCOPE_BASE, "(objectclass=*)", ['memberof'])
- found = False
- if ent.hasAttr('memberof'):
-
- for val in ent.getValues('memberof'):
- server.log.info("!!!!!!! %s: memberof->%s" % (member_dn, val))
- server.log.info("!!!!!!! %s" % (val))
- server.log.info("!!!!!!! %s" % (group_dn))
- if val.lower() == group_dn.lower():
- found = True
- break
-
- if find_result:
- assert (found)
- else:
- assert (not found)
-
-
-def test_ticket49064(topo):
- """Specify a test case purpose or name here
-
- :id: 60c11636-55a1-4704-9e09-2c6bcc828de4
- :setup: 1 Master - 1 Hub - 1 Consumer
- :steps:
- 1. Configure replication to EXCLUDE memberof
- 2. Enable memberof plugin
- 3. Create users/groups
- 4. make user_1 member of group_1
- 5. Checks that user_1 is memberof group_1 on M,H,C
- 6. make group_1 member of group_2 (nest group)
- 7. Checks that user_1 is memberof group_1 and group_2 on M,H,C
- 8. Check group_1 is memberof group_2 on M,H,C
- 9. remove group_1 from group_2
- 10. Check group_1 and user_1 are NOT memberof group_2 on M,H,C
- 11. remove user_1 from group_1
- 12. Check user_1 is NOT memberof group_1 and group_2 on M,H,C
- 13. Disable memberof on C1
- 14. make user_1 member of group_1
- 15. Checks that user is memberof group_1 on M,H but not on C
- 16. Enable memberof on C1
- 17. Checks that user is memberof group_1 on M,H but not on C
- 18. Run memberof fixup task
- 19. Checks that user is memberof group_1 on M,H,C
-
-
- :expectedresults:
- no assert for membership check
- """
-
-
- M1 = topo.ms["master1"]
- H1 = topo.hs["hub1"]
- C1 = topo.cs["consumer1"]
-
- # Step 1 & 2
- M1.config.enable_log('audit')
- config_memberof(M1)
- M1.restart()
-
- H1.config.enable_log('audit')
- config_memberof(H1)
- H1.restart()
-
- C1.config.enable_log('audit')
- config_memberof(C1)
- C1.restart()
-
- # Step 3
- for i in range(10):
- add_user(M1, i, desc='add on m1')
- for i in range(3):
- add_group(M1, i)
-
- # Step 4
- member_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
- group_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
- update_member(M1, member_dn, group_dn, ldap.MOD_ADD, sleep=True)
-
- # Step 5
- for i in [M1, H1, C1]:
- _find_memberof(i, member_dn, group_dn, find_result=True)
-
-
- # Step 6
- user_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
- grp1_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
- grp2_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 2, SUFFIX)
- update_member(M1, grp1_dn, grp2_dn, ldap.MOD_ADD, sleep=True)
-
- # Step 7
- for i in [grp1_dn, grp2_dn]:
- for inst in [M1, H1, C1]:
- _find_memberof(inst, user_dn, i, find_result=True)
-
- # Step 8
- for i in [M1, H1, C1]:
- _find_memberof(i, grp1_dn, grp2_dn, find_result=True)
-
- # Step 9
- user_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
- grp1_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
- grp2_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 2, SUFFIX)
- update_member(M1, grp1_dn, grp2_dn, ldap.MOD_DELETE, sleep=True)
-
- # Step 10
- for inst in [M1, H1, C1]:
- for i in [grp1_dn, user_dn]:
- _find_memberof(inst, i, grp2_dn, find_result=False)
-
- # Step 11
- member_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
- group_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
- update_member(M1, member_dn, group_dn, ldap.MOD_DELETE, sleep=True)
-
- # Step 12
- for inst in [M1, H1, C1]:
- for grp in [grp1_dn, grp2_dn]:
- _find_memberof(inst, member_dn, grp, find_result=False)
-
- # Step 13
- C1.plugins.disable(name=PLUGIN_MEMBER_OF)
- C1.restart()
-
- # Step 14
- member_dn = 'cn=%s%d,ou=people,%s' % (USER_CN, 1, SUFFIX)
- group_dn = 'cn=%s%d,ou=groups,%s' % (GROUP_CN, 1, SUFFIX)
- update_member(M1, member_dn, group_dn, ldap.MOD_ADD, sleep=True)
- # to give time to the update to go up to the C1
- time.sleep(10)
-
- # Step 15
- for i in [M1, H1]:
- _find_memberof(i, member_dn, group_dn, find_result=True)
- _find_memberof(C1, member_dn, group_dn, find_result=False)
-
- # Step 16
- C1.plugins.enable(name=PLUGIN_MEMBER_OF)
- C1.restart()
-
- # Step 17
- for i in [M1, H1]:
- _find_memberof(i, member_dn, group_dn, find_result=True)
- _find_memberof(C1, member_dn, group_dn, find_result=False)
-
- # Step 18
- memberof_fixup_task(C1)
- time.sleep(5)
-
- # Step 19
- for i in [M1, H1, C1]:
- _find_memberof(i, member_dn, group_dn, find_result=True)
-
- # If you need any test suite initialization,
- # please, write additional fixture for that (including finalizer).
- # Topology for suites are predefined in lib389/topologies.py.
-
- # If you need host, port or any other data about instance,
- # Please, use the instance object attributes for that (for example, topo.ms["master1"].serverid)
-
- if DEBUGGING:
- # Add debugging steps(if any)...
- pass
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
-
| 0 |
0cc661f3c9a1850a29cb89181f94edabc9f47cb5
|
389ds/389-ds-base
|
Ticket #347 - IPA dirsvr seg-fault during system longevity test
https://fedorahosted.org/389/ticket/347
Resolves: Ticket 347
Bug Description: IPA dirsvr seg-fault during system longevity test
Reviewed by: nhosoi, mreynolds (Thanks!)
Branch: master
Fix Description: Somehow the DB_MULTIPLE_NEXT pointer is being set to
an invalid value (-5). This causes the next iteration to return memory
that points to before the stack buffer, causing a seg fault. Valid
values for the pointer are > -1. The value -1 is used as the list terminator
value. The code that constructs the buffer is in the libdb function
__bam_bulk in bt_cursor.c. The fix is to check for a value < -1,
assume the page or value has been deleted out from under us, and do
a dbc->get to get the next buffer full, if any. The code also needs to
check for duplicate IDs being returned. In the failure case described
above, it is possible that the last ID returned in the multiple buffer is
the first ID in the next buffer. In that case, we want to skip the ID that
was already added to the IDL.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 5d45dd8de06aaee3e0a52c85fa5b3e18febd7a27)
|
commit 0cc661f3c9a1850a29cb89181f94edabc9f47cb5
Author: Rich Megginson <[email protected]>
Date: Fri Apr 20 20:15:21 2012 -0600
Ticket #347 - IPA dirsvr seg-fault during system longevity test
https://fedorahosted.org/389/ticket/347
Resolves: Ticket 347
Bug Description: IPA dirsvr seg-fault during system longevity test
Reviewed by: nhosoi, mreynolds (Thanks!)
Branch: master
Fix Description: Somehow the DB_MULTIPLE_NEXT pointer is being set to
an invalid value (-5). This causes the next iteration to return memory
that points to before the stack buffer, causing a seg fault. Valid
values for the pointer are > -1. The value -1 is used as the list terminator
value. The code that constructs the buffer is in the libdb function
__bam_bulk in bt_cursor.c. The fix is to check for a value < -1,
assume the page or value has been deleted out from under us, and do
a dbc->get to get the next buffer full, if any. The code also needs to
check for duplicate IDs being returned. In the failure case described
above, it is possible that the last ID returned in the multiple buffer is
the first ID in the next buffer. In that case, we want to skip the ID that
was already added to the IDL.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 5d45dd8de06aaee3e0a52c85fa5b3e18febd7a27)
diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c
index d62511c74..9cd3dafca 100644
--- a/ldap/servers/slapd/back-ldbm/idl_new.c
+++ b/ldap/servers/slapd/back-ldbm/idl_new.c
@@ -242,6 +242,7 @@ IDList * idl_new_fetch(
/* Iterate over the duplicates, amassing them into an IDL */
#ifdef DB_USE_BULK_FETCH
for (;;) {
+ ID lastid = 0;
DB_MULTIPLE_INIT(ptr, &data);
@@ -250,6 +251,13 @@ IDList * idl_new_fetch(
if (dataret.data == NULL) break;
if (ptr == NULL) break;
+ if (*(int32_t *)ptr < -1) {
+ LDAPDebug1Arg(LDAP_DEBUG_TRACE, "DB_MULTIPLE buffer is corrupt; "
+ "next offset [%d] is less than zero\n",
+ *(int32_t *)ptr);
+ /* retry the read */
+ break;
+ }
if (dataret.size != sizeof(ID)) {
LDAPDebug(LDAP_DEBUG_ANY, "database index is corrupt; "
"key %s has a data item with the wrong size (%d)\n",
@@ -257,7 +265,14 @@ IDList * idl_new_fetch(
goto error;
}
memcpy(&id, dataret.data, sizeof(ID));
-
+ if (id == lastid) { /* dup */
+ LDAPDebug1Arg(LDAP_DEBUG_TRACE, "Detedted duplicate id "
+ "%d due to DB_MULTIPLE error - skipping\n",
+ id);
+ continue; /* get next one */
+ }
+ /* note the last id read to check for dups */
+ lastid = id;
/* we got another ID, add it to our IDL */
idl_rc = idl_append_extend(&idl, id);
if (idl_rc) {
| 0 |
cd8614a75852f4d05dc76d104867542f18384416
|
389ds/389-ds-base
|
Ticket 48158 - Remove cleanAllRUV task limit of 4
Bug Description: There is a limit of 4 concurrent tasks, and this is too
low of a limit.
Fix Description: There still needs to be a limit because each task creates
a new thread. Setting limit to 64.
https://fedorahosted.org/389/ticket/48158
Reviewed by: rmeggins(Thanks!)
|
commit cd8614a75852f4d05dc76d104867542f18384416
Author: Mark Reynolds <[email protected]>
Date: Wed May 6 15:08:22 2015 -0400
Ticket 48158 - Remove cleanAllRUV task limit of 4
Bug Description: There is a limit of 4 concurrent tasks, and this is too
low of a limit.
Fix Description: There still needs to be a limit because each task creates
a new thread. Setting limit to 64.
https://fedorahosted.org/389/ticket/48158
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 7f5d6937d..8381c979b 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -700,7 +700,7 @@ void set_cleaned_rid(ReplicaId rid);
void cleanruv_log(Slapi_Task *task, int rid, char *task_type, char *fmt, ...);
char * replica_cleanallruv_get_local_maxcsn(ReplicaId rid, char *base_dn);
-#define CLEANRIDSIZ 4 /* maximum number for concurrent CLEANALLRUV tasks */
+#define CLEANRIDSIZ 64 /* maximum number for concurrent CLEANALLRUV tasks */
typedef struct _cleanruv_data
{
| 0 |
dbcd4481c8a2f38dc947dc728e30aac5e0a5761a
|
389ds/389-ds-base
|
ticket 181 - Allow PAM passthru plug-in to have multiple config entries
Previously, the PAM passthru plug-in only allowed a single configuration
to be in place. The only config entry was the top-level PAM plug-in
entry in cn=config.
This patch allows multiple PAM passthru configuration entries to be
specified. This gives the ability to have much more flexibility
when passing authentication to PAM. You can do things like use
different PAM server files for different portions of the DIT, or
even different mapping methods and security requirements.
To allow even more flexibility, I added support for a new pamFilter
configuration attribute. This allows an LDAP filter to be used to
determine which entries a PAM passthru configuration should apply
to. This allows a flat DIT to have different PAM passthru config
based off of the contents of the entries, such as using the objectclass
value.
Lastly, I added the ability to use an alternate plug-in configuration
area for PAM passthru config entries. This allows one to store the
config entries in a replicated tree instead of cn=config. When using
the alternate config area, only the child entries of the alternate
config container are considered to be PAM passthru config entries.
When the normal area in cn=config is used, both the top-level PAM
passthru plug-in config entry and it's children are considered to
be config entries. This ensures that the existing config style is
backwards compatible. Using an alternate config area meant getting
rid of the DSE style config callbacks and implementing normal pre-op
and post-op callback for dynamic config validation and loading.
|
commit dbcd4481c8a2f38dc947dc728e30aac5e0a5761a
Author: Nathan Kinder <[email protected]>
Date: Tue Feb 28 09:42:23 2012 -0800
ticket 181 - Allow PAM passthru plug-in to have multiple config entries
Previously, the PAM passthru plug-in only allowed a single configuration
to be in place. The only config entry was the top-level PAM plug-in
entry in cn=config.
This patch allows multiple PAM passthru configuration entries to be
specified. This gives the ability to have much more flexibility
when passing authentication to PAM. You can do things like use
different PAM server files for different portions of the DIT, or
even different mapping methods and security requirements.
To allow even more flexibility, I added support for a new pamFilter
configuration attribute. This allows an LDAP filter to be used to
determine which entries a PAM passthru configuration should apply
to. This allows a flat DIT to have different PAM passthru config
based off of the contents of the entries, such as using the objectclass
value.
Lastly, I added the ability to use an alternate plug-in configuration
area for PAM passthru config entries. This allows one to store the
config entries in a replicated tree instead of cn=config. When using
the alternate config area, only the child entries of the alternate
config container are considered to be PAM passthru config entries.
When the normal area in cn=config is used, both the top-level PAM
passthru plug-in config entry and it's children are considered to
be config entries. This ensures that the existing config style is
backwards compatible. Using an alternate config area meant getting
rid of the DSE style config callbacks and implementing normal pre-op
and post-op callback for dynamic config validation and loading.
diff --git a/ldap/schema/60pam-plugin.ldif b/ldap/schema/60pam-plugin.ldif
index 97157a2df..ddf91d98d 100644
--- a/ldap/schema/60pam-plugin.ldif
+++ b/ldap/schema/60pam-plugin.ldif
@@ -48,4 +48,5 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2071 NAME 'pamIDAttr' DESC 'Name of attr
attributeTypes: ( 2.16.840.1.113730.3.1.2072 NAME 'pamFallback' DESC 'Fallback to regular LDAP BIND if PAM auth fails' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE X-ORIGIN 'Red Hat Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2073 NAME 'pamSecure' DESC 'Require secure (TLS/SSL) connection for PAM auth' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE X-ORIGIN 'Red Hat Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2074 NAME 'pamService' DESC 'Service name to pass to pam_start' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'Red Hat Directory Server' )
-objectClasses: ( 2.16.840.1.113730.3.2.318 NAME 'pamConfig' DESC 'PAM plugin configuration' SUP top AUXILIARY MAY ( pamMissingSuffix $ pamExcludeSuffix $ pamIncludeSuffix $ pamIDAttr $ pamIDMapMethod $ pamFallback $ pamSecure $ pamService ) X-ORIGIN 'Red Hat Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2131 NAME 'pamFilter' DESC 'Filter to match entries that should use PAM authentication' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Red Hat Directory Server' )
+objectClasses: ( 2.16.840.1.113730.3.2.318 NAME 'pamConfig' DESC 'PAM plugin configuration' SUP top AUXILIARY MAY ( cn $ pamMissingSuffix $ pamExcludeSuffix $ pamIncludeSuffix $ pamIDAttr $ pamIDMapMethod $ pamFallback $ pamSecure $ pamService $ pamFilter ) X-ORIGIN 'Red Hat Directory Server' )
diff --git a/ldap/servers/plugins/pam_passthru/pam_passthru.h b/ldap/servers/plugins/pam_passthru/pam_passthru.h
index 748c2f110..c565fcb30 100644
--- a/ldap/servers/plugins/pam_passthru/pam_passthru.h
+++ b/ldap/servers/plugins/pam_passthru/pam_passthru.h
@@ -61,15 +61,25 @@
/*
* macros
*/
-#define PAM_PASSTHRU_PLUGIN_SUBSYSTEM "pam_passthru-plugin" /* for logging */
+#define PAM_PASSTHRU_PLUGIN_SUBSYSTEM "pam_passthru-plugin" /* for logging */
+#define PAM_PASSTHRU_INT_POSTOP_DESC "PAM Passthru internal postop plugin"
+#define PAM_PASSTHRU_POSTOP_DESC "PAM Passthru postop plugin"
#define PAM_PASSTHRU_ASSERT( expr ) PR_ASSERT( expr )
#define PAM_PASSTHRU_OP_NOT_HANDLED 0
#define PAM_PASSTHRU_OP_HANDLED 1
+#define PAM_PASSTHRU_SUCCESS 0
+#define PAM_PASSTHRU_FAILURE -1
/* #define PAM_PASSTHRU_VERBOSE_LOGGING */
+/*
+ * Plug-in globals
+ */
+extern int g_plugin_started;
+extern PRCList *pam_passthru_global_config;
+
/*
* structs
*/
@@ -87,21 +97,24 @@ typedef struct pam_passthrusuffix {
#define PAMPT_MISSING_SUFFIX_IGNORE_STRING "IGNORE"
typedef struct pam_passthruconfig {
- Slapi_Mutex *lock; /* for config access */
+ PRCList list;
+ char *dn;
Pam_PassthruSuffix *pamptconfig_includes; /* list of suffixes to include in this op */
Pam_PassthruSuffix *pamptconfig_excludes; /* list of suffixes to exclude in this op */
- PRBool pamptconfig_fallback; /* if false, failure here fails entire bind */
- /* if true, failure here falls through to regular bind */
+ char *filter_str; /* search filter used to identify bind entries to include in this op */
+ Slapi_Filter *slapi_filter; /* a Slapi_Filter version of the above filter */
+ PRBool pamptconfig_fallback; /* if false, failure here fails entire bind */
+ /* if true, failure here falls through to regular bind */
PRBool pamptconfig_secure; /* if true, plugin only operates on secure connections */
- char *pamptconfig_pam_ident_attr; /* name of attribute in user entry for ENTRY map method */
- int pamptconfig_map_method1; /* how to map the BIND DN to the PAM identity */
- int pamptconfig_map_method2; /* how to map the BIND DN to the PAM identity */
- int pamptconfig_map_method3; /* how to map the BIND DN to the PAM identity */
+ char *pamptconfig_pam_ident_attr; /* name of attribute in user entry for ENTRY map method */
+ int pamptconfig_map_method1; /* how to map the BIND DN to the PAM identity */
+ int pamptconfig_map_method2; /* how to map the BIND DN to the PAM identity */
+ int pamptconfig_map_method3; /* how to map the BIND DN to the PAM identity */
#define PAMPT_MAP_METHOD_NONE -1 /* do not map */
#define PAMPT_MAP_METHOD_DN 0 /* use the full DN as the PAM identity */
#define PAMPT_MAP_METHOD_RDN 1 /* use the leftmost RDN value as the PAM identity */
#define PAMPT_MAP_METHOD_ENTRY 2 /* use the PAM identity attribute in the entry */
- char *pamptconfig_service; /* the PAM service name for pam_start() */
+ char *pamptconfig_service; /* the PAM service name for pam_start() */
} Pam_PassthruConfig;
#define PAMPT_MAP_METHOD_DN_STRING "DN"
@@ -116,6 +129,7 @@ typedef struct pam_passthruconfig {
#define PAMPT_FALLBACK_ATTR "pamFallback" /* single */
#define PAMPT_SECURE_ATTR "pamSecure" /* single */
#define PAMPT_SERVICE_ATTR "pamService" /* single */
+#define PAMPT_FILTER_ATTR "pamFilter" /* single */
/*
* public functions
@@ -123,13 +137,23 @@ typedef struct pam_passthruconfig {
void pam_passthruauth_set_plugin_identity(void * identity);
void * pam_passthruauth_get_plugin_identity();
+void pam_passthruauth_set_plugin_sdn(const Slapi_DN *plugin_sdn);
+const Slapi_DN *pam_passthruauth_get_plugin_sdn();
+const char *pam_passthruauth_get_plugin_dn();
+void pam_passthru_read_lock();
+void pam_passthru_write_lock();
+void pam_passthru_unlock();
/*
* pam_ptconfig.c:
*/
-int pam_passthru_config( Slapi_Entry *config_e );
-Pam_PassthruConfig *pam_passthru_get_config( void );
-int pam_passthru_check_suffix(Pam_PassthruConfig *cfg, const char *binddn);
+int pam_passthru_load_config(int skip_validate);
+void pam_passthru_delete_config();
+Pam_PassthruConfig *pam_passthru_get_config( Slapi_DN *bind_sdn );
+int pam_passthru_validate_config (Slapi_Entry* e, char *returntext);
+int pam_passthru_dn_is_config(Slapi_DN *sdn);
+void pam_passthru_set_config_area(Slapi_DN *sdn);
+Slapi_DN* pam_passthru_get_config_area();
/*
* pam_ptimpl.c
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
index bde2ef6b1..fce8000bf 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
@@ -52,102 +52,170 @@
/*
* The configuration attributes are contained in the plugin entry e.g.
- * cn=PAM Pass Through,cn=plugins,cn=config
+ * cn=PAM Pass Through,cn=plugins,cn=config, or an alternate config area.
*
* Configuration is a two step process. The first pass is a validation step which
* occurs pre-op - check inputs and error out if bad. The second pass actually
* applies the changes to the run time config.
*/
+static Slapi_DN *_ConfigArea = NULL;
/*
* function prototypes
*/
-static int pam_passthru_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e,
- int *returncode, char *returntext, void *arg);
-static int pam_passthru_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e,
- int *returncode, char *returntext, void *arg);
-static int pam_passthru_search (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e,
- int *returncode, char *returntext, void *arg)
-{
- return SLAPI_DSE_CALLBACK_OK;
-}
+static int pam_passthru_apply_config (Slapi_Entry* e);
/*
- * static variables
+ * Read and load configuration. Validation will also
+ * be performed unless skip_validate is set to non-0.
+ * Returns PAM_PASSTHRU_SUCCESS if all is well.
*/
-/* for now, there is only one configuration and it is global to the plugin */
-static Pam_PassthruConfig theConfig;
-static int inited = 0;
+int
+pam_passthru_load_config(int skip_validate)
+{
+ int status = PAM_PASSTHRU_SUCCESS;
+ int result;
+ int i;
+ int alternate = 0;
+ Slapi_PBlock *search_pb;
+ Slapi_Entry **entries = NULL;
+
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "=> pam_passthru_load_config\n");
+
+ pam_passthru_write_lock();
+ pam_passthru_delete_config();
+
+ search_pb = slapi_pblock_new();
+
+ /* Find all entries in the active config area. */
+ slapi_search_internal_set_pb(search_pb, slapi_sdn_get_ndn(pam_passthru_get_config_area()),
+ LDAP_SCOPE_SUBTREE, "objectclass=*",
+ NULL, 0, NULL, NULL,
+ pam_passthruauth_get_plugin_identity(), 0);
+ slapi_search_internal_pb(search_pb);
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
+
+ if (LDAP_SUCCESS != result) {
+ status = PAM_PASSTHRU_FAILURE;
+ goto cleanup;
+ }
+
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
+ &entries);
+ if (NULL == entries || NULL == entries[0]) {
+ status = PAM_PASSTHRU_FAILURE;
+ goto cleanup;
+ }
+
+ /* Check if we are using an alternate config area. We do this here
+ * so we don't have to check each every time in the loop below. */
+ if (slapi_sdn_compare(pam_passthru_get_config_area(),
+ pam_passthruauth_get_plugin_sdn()) != 0) {
+ alternate = 1;
+ }
+ /* Validate and apply config if valid. If skip_validate is set, we skip
+ * validation and just apply the config. This should only be done if the
+ * configuration has already been validated. */
+ for (i = 0; (entries[i] != NULL); i++) {
+ /* If this is the alternate config container, skip it since
+ * we don't consider it to be an actual config entry. */
+ if (alternate && (slapi_sdn_compare(pam_passthru_get_config_area(),
+ slapi_entry_get_sdn(entries[i])) == 0)) {
+ continue;
+ }
+
+ if (skip_validate || (PAM_PASSTHRU_SUCCESS == pam_passthru_validate_config(entries[i], NULL))) {
+ if (PAM_PASSTHRU_FAILURE == pam_passthru_apply_config(entries[i])) {
+ slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_load_config: unable to apply config "
+ "for entry \"%s\"\n", slapi_entry_get_ndn(entries[i]));
+ }
+ } else {
+ slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_load_config: skipping invalid config "
+ "entry \"%s\"\n", slapi_entry_get_ndn(entries[i]));
+ }
+ }
+
+ cleanup:
+ slapi_free_search_results_internal(search_pb);
+ slapi_pblock_destroy(search_pb);
+ pam_passthru_unlock();
+ slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= pam_passthru_load_config\n");
+
+ return status;
+}
+
+static void
+Delete_Pam_PassthruSuffix(Pam_PassthruSuffix *one)
+{
+ if (one) {
+ slapi_sdn_free(&one->pamptsuffix_dn);
+ slapi_ch_free((void **)&one);
+ }
+}
-static int dont_allow_that(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e,
- int *returncode, char *returntext, void *arg)
+static void
+pam_ptconfig_free_suffixes(Pam_PassthruSuffix *list)
{
- *returncode = LDAP_UNWILLING_TO_PERFORM;
- return SLAPI_DSE_CALLBACK_ERROR;
+ while (list) {
+ Pam_PassthruSuffix *next = list->pamptsuffix_next;
+ Delete_Pam_PassthruSuffix(list);
+ list = next;
+ }
}
/*
- * Read configuration and create a configuration data structure.
- * This is called after the server has configured itself so we can check
- * for things like collisions between our suffixes and backend's suffixes.
- * Returns an LDAP error code (LDAP_SUCCESS if all goes well).
+ * Free a config struct.
*/
-int
-pam_passthru_config(Slapi_Entry *config_e)
+static void
+pam_passthru_free_config_entry(Pam_PassthruConfig **entry)
{
- int returncode = LDAP_SUCCESS;
- char returntext[SLAPI_DSE_RETURNTEXT_SIZE];
+ Pam_PassthruConfig *e = *entry;
- if ( inited ) {
- slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "only one PAM pass through plugin instance can be used\n" );
- return( LDAP_PARAM_ERROR );
+ if (e == NULL) {
+ return;
}
- /* initialize fields */
- if ((theConfig.lock = slapi_new_mutex()) == NULL) {
- return( LDAP_LOCAL_ERROR );
- }
- /* do not fallback to regular bind */
- theConfig.pamptconfig_fallback = PR_FALSE;
- /* require TLS/SSL security */
- theConfig.pamptconfig_secure = PR_TRUE;
- /* use the RDN method to derive the PAM identity */
- theConfig.pamptconfig_map_method1 = PAMPT_MAP_METHOD_RDN;
- theConfig.pamptconfig_map_method2 = PAMPT_MAP_METHOD_NONE;
- theConfig.pamptconfig_map_method3 = PAMPT_MAP_METHOD_NONE;
-
- if (SLAPI_DSE_CALLBACK_OK == pam_passthru_validate_config(NULL, NULL, config_e,
- &returncode, returntext, NULL)) {
- pam_passthru_apply_config(NULL, NULL, config_e,
- &returncode, returntext, NULL);
- }
+ slapi_ch_free_string(&e->dn);
+ pam_ptconfig_free_suffixes(e->pamptconfig_includes);
+ pam_ptconfig_free_suffixes(e->pamptconfig_excludes);
+ slapi_ch_free_string(&e->pamptconfig_pam_ident_attr);
+ slapi_ch_free_string(&e->pamptconfig_service);
+ slapi_ch_free_string(&e->filter_str);
+ slapi_filter_free(e->slapi_filter, 1);
- /* config DSE must be initialized before we get here */
- if (returncode == LDAP_SUCCESS) {
- const char *config_dn = slapi_entry_get_dn_const(config_e);
- slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE,
- PAM_PT_CONFIG_FILTER, pam_passthru_validate_config,NULL);
- slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_POSTOP, config_dn, LDAP_SCOPE_BASE,
- PAM_PT_CONFIG_FILTER, pam_passthru_apply_config,NULL);
- slapi_config_register_callback(SLAPI_OPERATION_MODRDN, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE,
- PAM_PT_CONFIG_FILTER, dont_allow_that, NULL);
- slapi_config_register_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE,
- PAM_PT_CONFIG_FILTER, dont_allow_that, NULL);
- slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE,
- PAM_PT_CONFIG_FILTER, pam_passthru_search,NULL);
- }
+ slapi_ch_free((void **) entry);
+}
- inited = 1;
+/*
+ * Free and remove a single config item from the list.
+ */
+static void
+pam_passthru_delete_configEntry(PRCList *entry)
+{
+ PR_REMOVE_LINK(entry);
+ pam_passthru_free_config_entry((Pam_PassthruConfig **) &entry);
+}
- if (returncode != LDAP_SUCCESS) {
- slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "Error %d: %s\n", returncode, returntext);
- }
+/*
+ * Delete the entire config list contents.
+ */
+void
+pam_passthru_delete_config()
+{
+ PRCList *list;
- return returncode;
+ while (!PR_CLIST_IS_EMPTY(pam_passthru_global_config)) {
+ list = PR_LIST_HEAD(pam_passthru_global_config);
+ pam_passthru_delete_configEntry(list);
+ }
+
+ return;
}
static int
@@ -230,39 +298,67 @@ meth_to_int(char **map_method, int *err)
static int
parse_map_method(char *map_method, int *one, int *two, int *three, char *returntext)
{
- int err = LDAP_SUCCESS;
+ int err = PAM_PASSTHRU_SUCCESS;
char **ptr = &map_method;
*one = *two = *three = PAMPT_MAP_METHOD_NONE;
*one = meth_to_int(ptr, &err);
if (err) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "The map method in the string [%s] is invalid: must be "
- "one of %s", map_method, get_map_method_values());
- return LDAP_UNWILLING_TO_PERFORM;
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "The map method in the string [%s] is invalid: must be "
+ "one of %s", map_method, get_map_method_values());
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "The map method in the string [%s] is invalid: must be "
+ "one of %s\n", map_method, get_map_method_values());
+ }
+ err = PAM_PASSTHRU_FAILURE;
+ goto bail;
}
*two = meth_to_int(ptr, &err);
if (err) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "The map method in the string [%s] is invalid: must be "
- "one of %s", map_method, get_map_method_values());
- return LDAP_UNWILLING_TO_PERFORM;
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "The map method in the string [%s] is invalid: must be "
+ "one of %s", map_method, get_map_method_values());
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "The map method in the string [%s] is invalid: must be "
+ "one of %s\n", map_method, get_map_method_values());
+ }
+ err = PAM_PASSTHRU_FAILURE;
+ goto bail;
}
*three = meth_to_int(ptr, &err);
if (err) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "The map method in the string [%s] is invalid: must be "
- "one of %s", map_method, get_map_method_values());
- return LDAP_UNWILLING_TO_PERFORM;
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "The map method in the string [%s] is invalid: must be "
+ "one of %s", map_method, get_map_method_values());
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "The map method in the string [%s] is invalid: must be "
+ "one of %s\n", map_method, get_map_method_values());
+ }
+ err = PAM_PASSTHRU_FAILURE;
+ goto bail;
}
- if ((meth_to_int(ptr, &err) != PAMPT_MAP_METHOD_NONE) ||
- err) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "Invalid extra text [%s] after last map method",
- ((ptr && *ptr) ? *ptr : "(null)"));
- return LDAP_UNWILLING_TO_PERFORM;
+ if ((meth_to_int(ptr, &err) != PAMPT_MAP_METHOD_NONE) || err) {
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Invalid extra text [%s] after last map method",
+ ((ptr && *ptr) ? *ptr : "(null)"));
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "Invalid extra text [%s] after last map method\n",
+ ((ptr && *ptr) ? *ptr : "(null)"));
+ }
+ err = PAM_PASSTHRU_FAILURE;
+ goto bail;
}
+ bail:
return err;
}
@@ -283,12 +379,14 @@ print_suffixes()
}
/*
- Validate the pending changes in the e entry.
-*/
-static int
-pam_passthru_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e,
- int *returncode, char *returntext, void *arg)
+ * Validate the pending changes in the e entry.
+ * If returntext is NULL, we log messages about invalid config
+ * to the errors log.
+ */
+int
+pam_passthru_validate_config (Slapi_Entry* e, char *returntext)
{
+ int rc = PAM_PASSTHRU_FAILURE;
char *missing_suffix_str = NULL;
int missing_suffix;
int ii;
@@ -296,15 +394,22 @@ pam_passthru_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_
char **includes = NULL;
char *pam_ident_attr = NULL;
char *map_method = NULL;
+ char *pam_filter_str = NULL;
+ Slapi_Filter *pam_filter = NULL;
- *returncode = LDAP_UNWILLING_TO_PERFORM; /* be pessimistic */
/* first, get the missing_suffix flag and validate it */
missing_suffix_str = slapi_entry_attr_get_charptr(e, PAMPT_MISSING_SUFFIX_ATTR);
if ((missing_suffix = missing_suffix_to_int(missing_suffix_str)) < 0 ||
!check_missing_suffix_flag(missing_suffix)) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
"Error: valid values for %s are %s",
PAMPT_MISSING_SUFFIX_ATTR, get_missing_suffix_values());
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "Error: valid values for %s are %s\n",
+ PAMPT_MISSING_SUFFIX_ATTR, get_missing_suffix_values());
+ }
goto done;
}
@@ -314,7 +419,8 @@ pam_passthru_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_
/* get the list of excluded suffixes */
excludes = slapi_entry_attr_get_charray(e, PAMPT_EXCLUDES_ATTR);
for (ii = 0; excludes && excludes[ii]; ++ii) {
- Slapi_DN *comp_dn = slapi_sdn_new_dn_byref(excludes[ii]);
+ /* The excludes DNs are already normalized. */
+ Slapi_DN *comp_dn = slapi_sdn_new_normdn_byref(excludes[ii]);
if (!slapi_be_exist(comp_dn)) {
charray_add(&missing_list, slapi_ch_strdup(excludes[ii]));
}
@@ -324,7 +430,8 @@ pam_passthru_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_
/* get the list of included suffixes */
includes = slapi_entry_attr_get_charray(e, PAMPT_INCLUDES_ATTR);
for (ii = 0; includes && includes[ii]; ++ii) {
- Slapi_DN *comp_dn = slapi_sdn_new_dn_byref(includes[ii]);
+ /* The includes DNs are already normalized. */
+ Slapi_DN *comp_dn = slapi_sdn_new_normdn_byref(includes[ii]);
if (!slapi_be_exist(comp_dn)) {
charray_add(&missing_list, slapi_ch_strdup(includes[ii]));
}
@@ -332,24 +439,33 @@ pam_passthru_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_
}
if (missing_list) {
- PRUint32 size =
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "The following suffixes listed in %s or %s are not present in this "
- "server: ", PAMPT_EXCLUDES_ATTR, PAMPT_INCLUDES_ATTR);
- for (ii = 0; missing_list[ii]; ++ii) {
- if (size < SLAPI_DSE_RETURNTEXT_SIZE) {
- size += PR_snprintf(returntext+size, SLAPI_DSE_RETURNTEXT_SIZE-size,
- "%s%s", (ii > 0) ? "; " : "",
- missing_list[ii]);
+ if (returntext) {
+ PRUint32 size =
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "The following suffixes listed in %s or %s are not present in this "
+ "server: ", PAMPT_EXCLUDES_ATTR, PAMPT_INCLUDES_ATTR);
+ for (ii = 0; missing_list[ii]; ++ii) {
+ if (size < SLAPI_DSE_RETURNTEXT_SIZE) {
+ size += PR_snprintf(returntext+size, SLAPI_DSE_RETURNTEXT_SIZE-size,
+ "%s%s", (ii > 0) ? "; " : "",
+ missing_list[ii]);
+ }
}
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "The suffixes listed in %s or %s are not present in "
+ "this server\n", PAMPT_EXCLUDES_ATTR, PAMPT_INCLUDES_ATTR);
}
+
slapi_ch_array_free(missing_list);
missing_list = NULL;
print_suffixes();
if (missing_suffix != PAMPT_MISSING_SUFFIX_ERROR) {
- slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "Warning: %s\n", returntext);
- *returntext = 0; /* log error, don't report back to user */
+ if (returntext) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "Warning: %s\n", returntext);
+ *returntext = 0; /* log error, don't report back to user */
+ }
} else {
goto done;
}
@@ -360,31 +476,64 @@ pam_passthru_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_
map_method = slapi_entry_attr_get_charptr(e, PAMPT_MAP_METHOD_ATTR);
if (map_method) {
int one, two, three;
- if (LDAP_SUCCESS !=
- (*returncode = parse_map_method(map_method, &one, &two, &three, returntext))) {
- goto done; /* returntext set already */
+ if (PAM_PASSTHRU_SUCCESS !=
+ (rc = parse_map_method(map_method, &one, &two, &three, returntext))) {
+ goto done; /* returntext set already (or error logged) */
}
if (!pam_ident_attr &&
((one == PAMPT_MAP_METHOD_ENTRY) || (two == PAMPT_MAP_METHOD_ENTRY) ||
(three == PAMPT_MAP_METHOD_ENTRY))) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "Error: the %s method"
- " was specified, but no %s was given",
- PAMPT_MAP_METHOD_ENTRY_STRING, PAMPT_PAM_IDENT_ATTR);
- *returncode = LDAP_UNWILLING_TO_PERFORM;
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "Error: the %s method"
+ " was specified, but no %s was given",
+ PAMPT_MAP_METHOD_ENTRY_STRING, PAMPT_PAM_IDENT_ATTR);
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "Error: the %s method was specified, but no %s was given\n",
+ PAMPT_MAP_METHOD_ENTRY_STRING, PAMPT_PAM_IDENT_ATTR);
+ }
+ rc = PAM_PASSTHRU_FAILURE;
goto done;
}
if ((one == PAMPT_MAP_METHOD_NONE) && (two == PAMPT_MAP_METHOD_NONE) &&
(three == PAMPT_MAP_METHOD_NONE)) {
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "Error: no method(s)"
- " specified for %s, should be one or more of %s",
- PAMPT_MAP_METHOD_ATTR, get_map_method_values());
- *returncode = LDAP_UNWILLING_TO_PERFORM;
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "Error: no method(s)"
+ " specified for %s, should be one or more of %s",
+ PAMPT_MAP_METHOD_ATTR, get_map_method_values());
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "Error: no method(s) specified for %s, should be "
+ "one or more of %s\n", PAMPT_MAP_METHOD_ATTR,
+ get_map_method_values());
+ }
+ rc = PAM_PASSTHRU_FAILURE;
+ goto done;
+ }
+ }
+
+ /* Validate filter by converting to Slapi_Filter */
+ pam_filter_str = slapi_entry_attr_get_charptr(e, PAMPT_FILTER_ATTR);
+ if (pam_filter_str) {
+ pam_filter = slapi_str2filter(pam_filter_str);
+ if (pam_filter == NULL) {
+ if (returntext) {
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "Error: invalid "
+ "filter specified for %s (filter: \"%s\")",
+ PAMPT_FILTER_ATTR, pam_filter_str);
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "Error: invalid filter specified for %s "
+ "(filter: \"%s\")\n", PAMPT_FILTER_ATTR,
+ pam_filter_str);
+ }
+ rc = PAM_PASSTHRU_FAILURE;
goto done;
}
}
/* success */
- *returncode = LDAP_SUCCESS;
+ rc = PAM_PASSTHRU_SUCCESS;
done:
slapi_ch_free_string(&map_method);
@@ -394,15 +543,10 @@ done:
slapi_ch_array_free(includes);
includes = NULL;
slapi_ch_free_string(&missing_suffix_str);
+ slapi_ch_free_string(&pam_filter_str);
+ slapi_filter_free(pam_filter, 1);
- if (*returncode != LDAP_SUCCESS)
- {
- return SLAPI_DSE_CALLBACK_ERROR;
- }
- else
- {
- return SLAPI_DSE_CALLBACK_OK;
- }
+ return rc;
}
static Pam_PassthruSuffix *
@@ -411,7 +555,8 @@ New_Pam_PassthruSuffix(char *suffix)
Pam_PassthruSuffix *newone = NULL;
if (suffix) {
newone = (Pam_PassthruSuffix *)slapi_ch_malloc(sizeof(Pam_PassthruSuffix));
- newone->pamptsuffix_dn = slapi_sdn_new_dn_byval(suffix);
+ /* The passed in suffix should already be normalized. */
+ newone->pamptsuffix_dn = slapi_sdn_new_normdn_byval(suffix);
newone->pamptsuffix_next = NULL;
}
return newone;
@@ -438,115 +583,139 @@ pam_ptconfig_add_suffixes(char **str_list)
return head;
}
-static void
-Delete_Pam_PassthruSuffix(Pam_PassthruSuffix *one)
-{
- if (one) {
- slapi_sdn_free(&one->pamptsuffix_dn);
- slapi_ch_free((void **)&one);
- }
-}
-
-static void
-pam_ptconfig_free_suffixes(Pam_PassthruSuffix *list)
-{
- while (list) {
- Pam_PassthruSuffix *next = list->pamptsuffix_next;
- Delete_Pam_PassthruSuffix(list);
- list = next;
- }
-}
-
/*
Apply the pending changes in the e entry to our config struct.
validate must have already been called
*/
static int
-pam_passthru_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e,
- int *returncode, char *returntext, void *arg)
+pam_passthru_apply_config (Slapi_Entry* e)
{
- char **excludes = NULL;
- char **includes = NULL;
- char *new_service = NULL;
- char *pam_ident_attr = NULL;
- char *map_method = NULL;
- PRBool fallback;
- PRBool secure;
+ int rc = PAM_PASSTHRU_SUCCESS;
+ char **excludes = NULL;
+ char **includes = NULL;
+ char *new_service = NULL;
+ char *pam_ident_attr = NULL;
+ char *map_method = NULL;
+ char *dn = NULL;
+ PRBool fallback;
+ PRBool secure;
+ Pam_PassthruConfig *entry = NULL;
+ PRCList *list;
+ Slapi_Attr *a = NULL;
+ char *filter_str = NULL;
+
+ pam_ident_attr = slapi_entry_attr_get_charptr(e, PAMPT_PAM_IDENT_ATTR);
+ map_method = slapi_entry_attr_get_charptr(e, PAMPT_MAP_METHOD_ATTR);
+ new_service = slapi_entry_attr_get_charptr(e, PAMPT_SERVICE_ATTR);
+ excludes = slapi_entry_attr_get_charray(e, PAMPT_EXCLUDES_ATTR);
+ includes = slapi_entry_attr_get_charray(e, PAMPT_INCLUDES_ATTR);
+ fallback = slapi_entry_attr_get_bool(e, PAMPT_FALLBACK_ATTR);
+ filter_str = slapi_entry_attr_get_charptr(e, PAMPT_FILTER_ATTR);
+ /* Require SSL/TLS if the secure attr is not specified. We
+ * need to check if the attribute is present to make this
+ * determiniation. */
+ if (slapi_entry_attr_find(e, PAMPT_SECURE_ATTR, &a) == 0) {
+ secure = slapi_entry_attr_get_bool(e, PAMPT_SECURE_ATTR);
+ } else {
+ secure = PR_TRUE;
+ }
- *returncode = LDAP_SUCCESS;
+ /* Allocate a config struct. */
+ entry = (Pam_PassthruConfig *)
+ slapi_ch_calloc(1, sizeof(Pam_PassthruConfig));
+ if (NULL == entry) {
+ rc = PAM_PASSTHRU_FAILURE;
+ goto bail;
+ }
- pam_ident_attr = slapi_entry_attr_get_charptr(e, PAMPT_PAM_IDENT_ATTR);
- map_method = slapi_entry_attr_get_charptr(e, PAMPT_MAP_METHOD_ATTR);
- new_service = slapi_entry_attr_get_charptr(e, PAMPT_SERVICE_ATTR);
- excludes = slapi_entry_attr_get_charray(e, PAMPT_EXCLUDES_ATTR);
- includes = slapi_entry_attr_get_charray(e, PAMPT_INCLUDES_ATTR);
- fallback = slapi_entry_attr_get_bool(e, PAMPT_FALLBACK_ATTR);
- secure = slapi_entry_attr_get_bool(e, PAMPT_SECURE_ATTR);
-
- /* lock config here */
- slapi_lock_mutex(theConfig.lock);
-
- theConfig.pamptconfig_fallback = fallback;
- theConfig.pamptconfig_secure = secure;
- if (!theConfig.pamptconfig_service ||
- (new_service && PL_strcmp(theConfig.pamptconfig_service, new_service))) {
- slapi_ch_free_string(&theConfig.pamptconfig_service);
- theConfig.pamptconfig_service = new_service;
- new_service = NULL; /* config now owns memory */
- }
+ /* use the RDN method to derive the PAM identity by default*/
+ entry->pamptconfig_map_method1 = PAMPT_MAP_METHOD_RDN;
+ entry->pamptconfig_map_method2 = PAMPT_MAP_METHOD_NONE;
+ entry->pamptconfig_map_method3 = PAMPT_MAP_METHOD_NONE;
- /* get the list of excluded suffixes */
- pam_ptconfig_free_suffixes(theConfig.pamptconfig_excludes);
- theConfig.pamptconfig_excludes = pam_ptconfig_add_suffixes(excludes);
+ /* Fill in the struct. */
+ dn = slapi_entry_get_ndn(e);
+ if (dn) {
+ entry->dn = slapi_ch_strdup(dn);
+ }
- /* get the list of included suffixes */
- pam_ptconfig_free_suffixes(theConfig.pamptconfig_includes);
- theConfig.pamptconfig_includes = pam_ptconfig_add_suffixes(includes);
+ entry->pamptconfig_fallback = fallback;
+ entry->pamptconfig_secure = secure;
- if (!theConfig.pamptconfig_pam_ident_attr ||
- (pam_ident_attr && PL_strcmp(theConfig.pamptconfig_pam_ident_attr, pam_ident_attr))) {
- slapi_ch_free_string(&theConfig.pamptconfig_pam_ident_attr);
- theConfig.pamptconfig_pam_ident_attr = pam_ident_attr;
- pam_ident_attr = NULL; /* config now owns memory */
- }
+ if (!entry->pamptconfig_service ||
+ (new_service && PL_strcmp(entry->pamptconfig_service, new_service))) {
+ slapi_ch_free_string(&entry->pamptconfig_service);
+ entry->pamptconfig_service = new_service;
+ new_service = NULL; /* config now owns memory */
+ }
- if (map_method) {
- parse_map_method(map_method,
- &theConfig.pamptconfig_map_method1,
- &theConfig.pamptconfig_map_method2,
- &theConfig.pamptconfig_map_method3,
- NULL);
- }
+ /* get the list of excluded suffixes */
+ pam_ptconfig_free_suffixes(entry->pamptconfig_excludes);
+ entry->pamptconfig_excludes = pam_ptconfig_add_suffixes(excludes);
- /* unlock config here */
- slapi_unlock_mutex(theConfig.lock);
+ /* get the list of included suffixes */
+ pam_ptconfig_free_suffixes(entry->pamptconfig_includes);
+ entry->pamptconfig_includes = pam_ptconfig_add_suffixes(includes);
- slapi_ch_free_string(&new_service);
- slapi_ch_free_string(&map_method);
- slapi_ch_free_string(&pam_ident_attr);
- slapi_ch_array_free(excludes);
- slapi_ch_array_free(includes);
+ if (!entry->pamptconfig_pam_ident_attr ||
+ (pam_ident_attr && PL_strcmp(entry->pamptconfig_pam_ident_attr, pam_ident_attr))) {
+ slapi_ch_free_string(&entry->pamptconfig_pam_ident_attr);
+ entry->pamptconfig_pam_ident_attr = pam_ident_attr;
+ pam_ident_attr = NULL; /* config now owns memory */
+ }
- if (*returncode != LDAP_SUCCESS)
- {
- return SLAPI_DSE_CALLBACK_ERROR;
- }
- else
- {
- return SLAPI_DSE_CALLBACK_OK;
+ if (map_method) {
+ parse_map_method(map_method,
+ &entry->pamptconfig_map_method1,
+ &entry->pamptconfig_map_method2,
+ &entry->pamptconfig_map_method3,
+ NULL);
}
+
+ if (filter_str) {
+ entry->filter_str = filter_str;
+ filter_str = NULL; /* config now owns memory */
+ entry->slapi_filter = slapi_str2filter(entry->filter_str);
+ }
+
+ /* Add config to list. We just store at the tail. */
+ if (!PR_CLIST_IS_EMPTY(pam_passthru_global_config)) {
+ list = PR_LIST_HEAD(pam_passthru_global_config);
+ while (list != pam_passthru_global_config) {
+ list = PR_NEXT_LINK(list);
+
+ if (pam_passthru_global_config == list) {
+ /* add to tail */
+ PR_INSERT_BEFORE(&(entry->list), list);
+ slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "store [%s] at tail\n", entry->dn);
+ break;
+ }
+ }
+ } else {
+ /* first entry */
+ PR_INSERT_LINK(&(entry->list), pam_passthru_global_config);
+ slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "store [%s] at head \n", entry->dn);
+ }
+
+ bail:
+ slapi_ch_free_string(&new_service);
+ slapi_ch_free_string(&map_method);
+ slapi_ch_free_string(&pam_ident_attr);
+ slapi_ch_free_string(&filter_str);
+ slapi_ch_array_free(excludes);
+ slapi_ch_array_free(includes);
+
+ return rc;
}
-int
-pam_passthru_check_suffix(Pam_PassthruConfig *cfg, const char *binddn)
+static int
+pam_passthru_check_suffix(Pam_PassthruConfig *cfg, const Slapi_DN *bindsdn)
{
- Slapi_DN *comp_dn;
Pam_PassthruSuffix *try;
int ret = LDAP_SUCCESS;
- comp_dn = slapi_sdn_new_dn_byref(binddn);
-
- slapi_lock_mutex(cfg->lock);
if (!cfg->pamptconfig_includes && !cfg->pamptconfig_excludes) {
goto done; /* NULL means allow */
}
@@ -554,7 +723,7 @@ pam_passthru_check_suffix(Pam_PassthruConfig *cfg, const char *binddn)
/* exclude trumps include - if suffix is on exclude list, then
deny */
for (try = cfg->pamptconfig_excludes; try; try = try->pamptsuffix_next) {
- if (slapi_sdn_issuffix(comp_dn, try->pamptsuffix_dn)) {
+ if (slapi_sdn_issuffix(bindsdn, try->pamptsuffix_dn)) {
ret = LDAP_UNWILLING_TO_PERFORM; /* suffix is excluded */
goto done;
}
@@ -564,7 +733,7 @@ pam_passthru_check_suffix(Pam_PassthruConfig *cfg, const char *binddn)
if (cfg->pamptconfig_includes) {
ret = LDAP_UNWILLING_TO_PERFORM; /* suffix is excluded */
for (try = cfg->pamptconfig_includes; try; try = try->pamptsuffix_next) {
- if (slapi_sdn_issuffix(comp_dn, try->pamptsuffix_dn)) {
+ if (slapi_sdn_issuffix(bindsdn, try->pamptsuffix_dn)) {
ret = LDAP_SUCCESS; /* suffix is included */
goto done;
}
@@ -572,18 +741,116 @@ pam_passthru_check_suffix(Pam_PassthruConfig *cfg, const char *binddn)
}
done:
- slapi_unlock_mutex(cfg->lock);
- slapi_sdn_free(&comp_dn);
return ret;
}
+
/*
- * Get the pass though configuration data. For now, there is only one
- * configuration and it is global to the plugin.
+ * Find the config entry that matches the passed in bind DN
*/
Pam_PassthruConfig *
-pam_passthru_get_config( void )
+pam_passthru_get_config( Slapi_DN *bind_sdn )
{
- return( &theConfig );
+ PRCList *list = NULL;
+ Pam_PassthruConfig *cfg = NULL;
+
+ /* Loop through config list to see if there is a match. */
+ if (!PR_CLIST_IS_EMPTY(pam_passthru_global_config)) {
+ list = PR_LIST_HEAD(pam_passthru_global_config);
+ while (list != pam_passthru_global_config) {
+ cfg = (Pam_PassthruConfig *)list;
+ if (pam_passthru_check_suffix( cfg, bind_sdn ) == LDAP_SUCCESS) {
+ if (cfg->slapi_filter) {
+ /* A filter is configured, so see if the bind entry is a match. */
+ Slapi_Entry *test_e = NULL;
+
+ /* Fetch the bind entry */
+ slapi_search_internal_get_entry(bind_sdn, NULL, &test_e,
+ pam_passthruauth_get_plugin_identity());
+
+ /* If the entry doesn't exist, just fall through to the main server code */
+ if (test_e) {
+ /* Evaluate the filter. */
+ if (LDAP_SUCCESS == slapi_filter_test_simple(test_e, cfg-> slapi_filter)) {
+ /* This is a match. */
+ slapi_entry_free(test_e);
+ goto done;
+ }
+
+ slapi_entry_free(test_e);
+ }
+ } else {
+ /* There is no filter to check, so this is a match. */
+ goto done;
+ }
+ }
+
+ cfg = NULL;
+ list = PR_NEXT_LINK(list);
+ }
+ }
+
+ done:
+ return(cfg);
}
+
+/*
+ * Check if the DN is considered to be a config entry.
+ *
+ * If the config is stored in cn=config, the top-level plug-in
+ * entry and it's children are considered to be config. If an
+ * alternate plug-in config area is being used, only the children
+ * of the alternate config container are considered to be config.
+ *
+ * Returns 1 if DN is a config entry.
+ */
+int
+pam_passthru_dn_is_config(Slapi_DN *sdn)
+{
+ int rc = 0;
+
+ if (sdn == NULL) {
+ goto bail;
+ }
+
+ /* Check if we're using the standard config area. */
+ if (slapi_sdn_compare(pam_passthru_get_config_area(),
+ pam_passthruauth_get_plugin_sdn()) == 0) {
+ /* We're using the standard config area, so both
+ * the container and the children are considered
+ * to be config entries. */
+ if (slapi_sdn_issuffix(sdn, pam_passthru_get_config_area())) {
+ rc = 1;
+ }
+ } else {
+ /* We're using an alternative config area, so only
+ * the children are considered to be config entries. */
+ if (slapi_sdn_issuffix(sdn, pam_passthru_get_config_area()) &&
+ slapi_sdn_compare(sdn, pam_passthru_get_config_area())) {
+ rc = 1;
+ }
+ }
+
+ bail:
+ return rc;
+}
+
+/*
+ * Set the active config area.
+ */
+void
+pam_passthru_set_config_area(Slapi_DN *sdn)
+{
+ _ConfigArea = sdn;
+}
+
+/*
+ * Return the active config area.
+ */
+Slapi_DN *
+pam_passthru_get_config_area()
+{
+ return _ConfigArea;
+}
+
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
index c0f03bef0..91dcc1008 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
@@ -91,13 +91,13 @@ struct my_pam_conv_str {
* Get the PAM identity from the value of the leftmost RDN in the BIND DN.
*/
static char *
-derive_from_bind_dn(Slapi_PBlock *pb, const char *binddn, MyStrBuf *pam_id)
+derive_from_bind_dn(Slapi_PBlock *pb, const Slapi_DN *bindsdn, MyStrBuf *pam_id)
{
Slapi_RDN *rdn;
char *type = NULL;
char *value = NULL;
- rdn = slapi_rdn_new_dn(binddn);
+ rdn = slapi_rdn_new_sdn(bindsdn);
slapi_rdn_get_first(rdn, &type, &value);
init_my_str_buf(pam_id, value);
slapi_rdn_free(&rdn);
@@ -106,33 +106,30 @@ derive_from_bind_dn(Slapi_PBlock *pb, const char *binddn, MyStrBuf *pam_id)
}
static char *
-derive_from_bind_entry(Slapi_PBlock *pb, const char *binddn,
+derive_from_bind_entry(Slapi_PBlock *pb, const Slapi_DN *bindsdn,
MyStrBuf *pam_id, char *map_ident_attr, int *locked)
{
char buf[BUFSIZ];
Slapi_Entry *entry = NULL;
- Slapi_DN *sdn = slapi_sdn_new_dn_byref(binddn);
char *attrs[] = { NULL, NULL };
attrs[0] = map_ident_attr;
- int rc = slapi_search_internal_get_entry(sdn, attrs, &entry,
+ int rc = slapi_search_internal_get_entry(bindsdn, attrs, &entry,
pam_passthruauth_get_plugin_identity());
- slapi_sdn_free(&sdn);
-
if (rc != LDAP_SUCCESS) {
slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"Could not find BIND dn %s (error %d - %s)\n",
- escape_string(binddn, buf), rc, ldap_err2string(rc));
+ escape_string(slapi_sdn_get_ndn(bindsdn), buf), rc, ldap_err2string(rc));
init_my_str_buf(pam_id, NULL);
} else if (NULL == entry) {
slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"Could not find entry for BIND dn %s\n",
- escape_string(binddn, buf));
+ escape_string(slapi_sdn_get_ndn(bindsdn), buf));
init_my_str_buf(pam_id, NULL);
} else if (slapi_check_account_lock( pb, entry, 0, 0, 0 ) == 1) {
slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"Account %s inactivated.\n",
- escape_string(binddn, buf));
+ escape_string(slapi_sdn_get_ndn(bindsdn), buf));
init_my_str_buf(pam_id, NULL);
*locked = 1;
} else {
@@ -286,9 +283,9 @@ do_one_pam_auth(
binddn = slapi_sdn_get_dn(bindsdn);
if (method == PAMPT_MAP_METHOD_RDN) {
- derive_from_bind_dn(pb, binddn, &pam_id);
+ derive_from_bind_dn(pb, bindsdn, &pam_id);
} else if (method == PAMPT_MAP_METHOD_ENTRY) {
- derive_from_bind_entry(pb, binddn, &pam_id, map_ident_attr, &locked);
+ derive_from_bind_entry(pb, bindsdn, &pam_id, map_ident_attr, &locked);
} else {
init_my_str_buf(&pam_id, binddn);
}
@@ -451,10 +448,7 @@ pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg)
int pw_response_requested;
LDAPControl **reqctrls = NULL;
- /* first lock and get the methods and other info */
- /* we do this so we can acquire and release the lock quickly to
- avoid potential deadlocks */
- slapi_lock_mutex(cfg->lock);
+ /* get the methods and other info */
method1 = cfg->pamptconfig_map_method1;
method2 = cfg->pamptconfig_map_method2;
method3 = cfg->pamptconfig_map_method3;
@@ -464,8 +458,6 @@ pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg)
fallback = cfg->pamptconfig_fallback;
- slapi_unlock_mutex(cfg->lock);
-
slapi_pblock_get (pb, SLAPI_REQCONTROLS, &reqctrls);
slapi_pblock_get (pb, SLAPI_PWPOLICY, &pw_response_requested);
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
index d726017a1..687d24cfa 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
@@ -49,7 +49,15 @@
static Slapi_PluginDesc pdesc = { "pam_passthruauth", VENDOR, DS_PACKAGE_VERSION,
"PAM pass through authentication plugin" };
-static void * pam_passthruauth_plugin_identity = NULL;
+static void *pam_passthruauth_plugin_identity = NULL;
+static const Slapi_DN *pam_passthruauth_plugin_sdn = NULL;
+static Slapi_RWLock *g_pam_config_lock = NULL;
+
+/*
+ * Plug-in globals
+ */
+int g_pam_plugin_started = 0;
+PRCList *pam_passthru_global_config = NULL;
/*
* function prototypes
@@ -57,7 +65,14 @@ static void * pam_passthruauth_plugin_identity = NULL;
static int pam_passthru_bindpreop( Slapi_PBlock *pb );
static int pam_passthru_bindpreop_start( Slapi_PBlock *pb );
static int pam_passthru_bindpreop_close( Slapi_PBlock *pb );
-
+static int pam_passthru_preop(Slapi_PBlock *pb, int modtype);
+static int pam_passthru_add_preop(Slapi_PBlock *pb);
+static int pam_passthru_mod_preop(Slapi_PBlock *pb);
+static int pam_passthru_del_preop(Slapi_PBlock *pb);
+static int pam_passthru_modrdn_preop(Slapi_PBlock *pb);
+static int pam_passthru_postop(Slapi_PBlock *pb);
+static int pam_passthru_internal_postop_init(Slapi_PBlock *pb);
+static int pam_passthru_postop_init(Slapi_PBlock *pb);
/*
** Plugin identity mgmt
@@ -65,12 +80,27 @@ static int pam_passthru_bindpreop_close( Slapi_PBlock *pb );
void pam_passthruauth_set_plugin_identity(void * identity)
{
- pam_passthruauth_plugin_identity=identity;
+ pam_passthruauth_plugin_identity=identity;
}
void * pam_passthruauth_get_plugin_identity()
{
- return pam_passthruauth_plugin_identity;
+ return pam_passthruauth_plugin_identity;
+}
+
+void pam_passthruauth_set_plugin_sdn(const Slapi_DN *plugin_sdn)
+{
+ pam_passthruauth_plugin_sdn = plugin_sdn;
+}
+
+const Slapi_DN *pam_passthruauth_get_plugin_sdn()
+{
+ return pam_passthruauth_plugin_sdn;
+}
+
+const char *pam_passthruauth_get_plugin_dn()
+{
+ return slapi_sdn_get_ndn(pam_passthruauth_plugin_sdn);
}
/*
@@ -80,33 +110,125 @@ void * pam_passthruauth_get_plugin_identity()
int
pam_passthruauth_init( Slapi_PBlock *pb )
{
+ int status = 0;
+
PAM_PASSTHRU_ASSERT( pb != NULL );
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "=> pam_passthruauth_init\n" );
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "=> pam_passthruauth_init\n" );
slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &pam_passthruauth_plugin_identity);
PR_ASSERT (pam_passthruauth_plugin_identity);
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
- (void *)SLAPI_PLUGIN_VERSION_01 ) != 0
- || slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
- (void *)&pdesc ) != 0
+ (void *)SLAPI_PLUGIN_VERSION_01 ) != 0
+ || slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
+ (void *)&pdesc ) != 0
|| slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN,
- (void *)pam_passthru_bindpreop_start ) != 0
+ (void *)pam_passthru_bindpreop_start ) != 0
|| slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_BIND_FN,
- (void *)pam_passthru_bindpreop ) != 0
+ (void *)pam_passthru_bindpreop ) != 0
+ || slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_ADD_FN,
+ (void *)pam_passthru_add_preop ) != 0
+ || slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
+ (void *)pam_passthru_mod_preop ) != 0
+ || slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_DELETE_FN,
+ (void *)pam_passthru_del_preop ) != 0
+ || slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_MODRDN_FN,
+ (void *)pam_passthru_modrdn_preop ) != 0
|| slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN,
- (void *)pam_passthru_bindpreop_close ) != 0 ) {
- slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "pam_passthruauth_init failed\n" );
- return( -1 );
+ (void *)pam_passthru_bindpreop_close ) != 0 ) {
+ slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthruauth_init failed\n" );
+ status = -1;
+ goto bail;
}
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "<= pam_passthruauth_init succeeded\n" );
+ /* Register internal postop functions. */
+ if (slapi_register_plugin("internalpostoperation", /* op type */
+ 1, /* Enabled */
+ "pam_passthruauth_init", /* this function desc */
+ pam_passthru_internal_postop_init, /* init func */
+ PAM_PASSTHRU_INT_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ pam_passthruauth_plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthruauth_init: failed to register plugin\n");
+ status = -1;
+ goto bail;
+ }
- return( 0 );
+ /* Register postop functions */
+ if (slapi_register_plugin("postoperation", /* op type */
+ 1, /* Enabled */
+ "pam_passthruauth_init", /* this function desc */
+ pam_passthru_postop_init, /* init func for post op */
+ PAM_PASSTHRU_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ pam_passthruauth_plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthruauth_init: failed to register plugin\n");
+ status = -1;
+ goto bail;
+ }
+
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= pam_passthruauth_init\n" );
+
+ bail:
+ return status;
+}
+
+static int
+pam_passthru_internal_postop_init(Slapi_PBlock *pb)
+{
+ int status = 0;
+
+ if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
+ SLAPI_PLUGIN_VERSION_01) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
+ (void *) &pdesc) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN,
+ (void *) pam_passthru_postop) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN,
+ (void *) pam_passthru_postop) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN,
+ (void *) pam_passthru_postop) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN,
+ (void *) pam_passthru_postop) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_internal_postop_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ return status;
+}
+
+static int
+pam_passthru_postop_init(Slapi_PBlock *pb)
+{
+ int status = 0;
+
+ if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
+ SLAPI_PLUGIN_VERSION_01) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
+ (void *) &pdesc) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
+ (void *) pam_passthru_postop) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
+ (void *) pam_passthru_postop) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
+ (void *) pam_passthru_postop) != 0 ||
+ slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
+ (void *) pam_passthru_postop) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_postop_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ return status;
}
/*
@@ -116,33 +238,85 @@ pam_passthruauth_init( Slapi_PBlock *pb )
static int
pam_passthru_bindpreop_start( Slapi_PBlock *pb )
{
- int rc;
- Slapi_Entry *config_e = NULL; /* entry containing plugin config */
+ int rc = PAM_PASSTHRU_SUCCESS;
+ Slapi_DN *pluginsdn = NULL;
+ char *config_area = NULL;
PAM_PASSTHRU_ASSERT( pb != NULL );
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "=> pam_passthru_bindpreop_start\n" );
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "=> pam_passthru_bindpreop_start\n" );
- if ( slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &config_e ) != 0 ) {
- slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "missing config entry\n" );
- return( -1 );
+ /* Check if we're already started */
+ if (g_pam_plugin_started) {
+ goto done;
}
- if (( rc = pam_passthru_config( config_e )) != LDAP_SUCCESS ) {
- slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "configuration failed (%s)\n", ldap_err2string( rc ));
- return( -1 );
+ /* Get the plug-in configuration DN and store it for later use. */
+ slapi_pblock_get(pb, SLAPI_TARGET_SDN, &pluginsdn);
+ if (NULL == pluginsdn || 0 == slapi_sdn_get_ndn_len(pluginsdn)) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_bindpreop_start: unable to determine plug-in config dn\n");
+ rc = PAM_PASSTHRU_FAILURE;
+ goto done;
}
+ /* Dup the plugin SDN to save it. */
+ pam_passthruauth_set_plugin_sdn(slapi_sdn_dup(pluginsdn));
+
+ /* Set the alternate config area if one is defined. */
+ slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_AREA, &config_area);
+ if (config_area) {
+ pam_passthru_set_config_area(slapi_sdn_new_normdn_byval(config_area));
+ } else {
+ pam_passthru_set_config_area(slapi_sdn_dup(pluginsdn));
+ }
+
+ slapi_log_error(SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_bindpreop_start: config at %s\n",
+ slapi_sdn_get_ndn(pam_passthru_get_config_area()));
+
+ /* Create the lock that protects the config . */
+ g_pam_config_lock = slapi_new_rwlock();
+
+ if (!g_pam_config_lock) {
+ slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_bindpreop_start: lock creation failed\n");
+ rc = PAM_PASSTHRU_FAILURE;
+ goto done;
+ }
+
+ /* Allocate the config list. */
+ pam_passthru_global_config = (PRCList *)
+ slapi_ch_calloc(1, sizeof(Pam_PassthruConfig));
+ PR_INIT_CLIST(pam_passthru_global_config);
+
+ /* Load config. */
+ pam_passthru_load_config(0 /* don't skip validation */);
+
if (( rc = pam_passthru_pam_init()) != LDAP_SUCCESS ) {
- slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "could not initialize PAM subsystem (%d)\n", rc);
- return( -1 );
+ slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "could not initialize PAM subsystem (%d)\n", rc);
+ rc = PAM_PASSTHRU_FAILURE;
+ goto done;
}
- return( 0 );
+done:
+ if ( rc != PAM_PASSTHRU_SUCCESS ) {
+ pam_passthru_delete_config();
+ slapi_destroy_rwlock(g_pam_config_lock);
+ g_pam_config_lock = NULL;
+ slapi_ch_free((void **)&pam_passthru_global_config);
+ } else {
+ g_pam_plugin_started = 1;
+ slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru: ready for service\n" );
+ }
+
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= pam_passthru_bindpreop_start\n" );
+
+ return( rc );
}
@@ -154,9 +328,32 @@ pam_passthru_bindpreop_close( Slapi_PBlock *pb )
{
PAM_PASSTHRU_ASSERT( pb != NULL );
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"=> pam_passthru_bindpreop_close\n" );
+ if (!g_pam_plugin_started) {
+ goto done;
+ }
+
+ pam_passthru_write_lock();
+ g_pam_plugin_started = 0;
+ pam_passthru_delete_config();
+ pam_passthru_unlock();
+
+ slapi_ch_free((void **)&pam_passthru_global_config);
+
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_pam_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
+
+done:
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= pam_passthru_bindpreop_close\n" );
+
return( 0 );
}
@@ -164,7 +361,8 @@ pam_passthru_bindpreop_close( Slapi_PBlock *pb )
static int
pam_passthru_bindpreop( Slapi_PBlock *pb )
{
- int rc, method;
+ int rc = LDAP_SUCCESS;
+ int method;
const char *normbinddn;
char *errmsg = NULL;
Slapi_DN *bindsdn = NULL;
@@ -174,18 +372,18 @@ pam_passthru_bindpreop( Slapi_PBlock *pb )
PAM_PASSTHRU_ASSERT( pb != NULL );
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "=> pam_passthru_bindpreop\n" );
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "=> pam_passthru_bindpreop\n" );
/*
* retrieve parameters for bind operation
*/
if ( slapi_pblock_get( pb, SLAPI_BIND_METHOD, &method ) != 0 ||
- slapi_pblock_get( pb, SLAPI_BIND_TARGET_SDN, &bindsdn ) != 0 ||
- slapi_pblock_get( pb, SLAPI_BIND_CREDENTIALS, &creds ) != 0 ) {
- slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "<= not handled (unable to retrieve bind parameters)\n" );
- return retcode;
+ slapi_pblock_get( pb, SLAPI_BIND_TARGET_SDN, &bindsdn ) != 0 ||
+ slapi_pblock_get( pb, SLAPI_BIND_CREDENTIALS, &creds ) != 0 ) {
+ slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= not handled (unable to retrieve bind parameters)\n" );
+ return retcode;
}
normbinddn = slapi_sdn_get_dn(bindsdn);
@@ -194,41 +392,45 @@ pam_passthru_bindpreop( Slapi_PBlock *pb )
* credentials. Let the Directory Server itself handle everything else.
*/
if ( method != LDAP_AUTH_SIMPLE || *normbinddn == '\0' ||
- creds->bv_len == 0 ) {
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "<= not handled (not simple bind or NULL dn/credentials)\n" );
- return retcode;
+ creds->bv_len == 0 ) {
+ slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= not handled (not simple bind or NULL dn/credentials)\n" );
+ return retcode;
}
- /* get the config */
- cfg = pam_passthru_get_config();
+ /* Get the config lock. From this point on, we must go to done
+ * to be sure we unlock. */
+ pam_passthru_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_pam_plugin_started) {
+ goto done;
+ }
- /* don't lock mutex here - simple integer access - assume atomic */
- if (cfg->pamptconfig_secure) { /* is a secure connection required? */
- int is_ssl = 0;
- slapi_pblock_get(pb, SLAPI_CONN_IS_SSL_SESSION, &is_ssl);
- if (!is_ssl) {
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "<= connection not secure (secure connection required; check config)");
- return retcode;
- }
- }
+ /* See if any of our config entries apply to this user */
+ cfg = pam_passthru_get_config(bindsdn);
- /*
- * Check to see if the target DN is one we should "pass through" to
- * PAM
- */
- if ( pam_passthru_check_suffix( cfg, normbinddn ) != LDAP_SUCCESS ) {
- slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "<= not handled (not one of our suffixes)\n" );
- return retcode;
+ if (!cfg) {
+ slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= \"%s\" not handled (doesn't meet configuration criteria)\n", normbinddn );
+ goto done;
+ }
+
+ if (cfg->pamptconfig_secure) { /* is a secure connection required? */
+ int is_ssl = 0;
+ slapi_pblock_get(pb, SLAPI_CONN_IS_SSL_SESSION, &is_ssl);
+ if (!is_ssl) {
+ slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= connection not secure (secure connection required; check config)");
+ goto done;
+ }
}
/*
* We are now committed to handling this bind request.
* Chain it off to PAM
*/
- rc = pam_passthru_do_pam_auth(pb, cfg);
+ rc = pam_passthru_do_pam_auth(pb, cfg);
/*
* If bind succeeded, change authentication information associated
@@ -237,34 +439,238 @@ pam_passthru_bindpreop( Slapi_PBlock *pb )
if (rc == LDAP_SUCCESS) {
char *ndn = slapi_ch_strdup(normbinddn);
if ((slapi_pblock_set(pb, SLAPI_CONN_DN, ndn) != 0) ||
- (slapi_pblock_set(pb, SLAPI_CONN_AUTHMETHOD,
- SLAPD_AUTH_SIMPLE) != 0)) {
+ (slapi_pblock_set(pb, SLAPI_CONN_AUTHMETHOD,
+ SLAPD_AUTH_SIMPLE) != 0)) {
slapi_ch_free_string(&ndn);
rc = LDAP_OPERATIONS_ERROR;
errmsg = "unable to set connection DN or AUTHTYPE";
slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "%s\n", errmsg);
+ "%s\n", errmsg);
} else {
- LDAPControl **reqctrls = NULL;
- slapi_pblock_get(pb, SLAPI_REQCONTROLS, &reqctrls);
- if (slapi_control_present(reqctrls, LDAP_CONTROL_AUTH_REQUEST, NULL, NULL)) {
- slapi_add_auth_response_control(pb, ndn);
- }
- }
+ LDAPControl **reqctrls = NULL;
+ slapi_pblock_get(pb, SLAPI_REQCONTROLS, &reqctrls);
+ if (slapi_control_present(reqctrls, LDAP_CONTROL_AUTH_REQUEST, NULL, NULL)) {
+ slapi_add_auth_response_control(pb, ndn);
+ }
+ }
+ }
+
+ if (rc == LDAP_SUCCESS) {
+ /* we are handling the result */
+ slapi_send_ldap_result(pb, rc, NULL, errmsg, 0, NULL);
+ /* tell bind code we handled the result */
+ retcode = PAM_PASSTHRU_OP_HANDLED;
+ } else if (!cfg->pamptconfig_fallback) {
+ /* tell bind code we already sent back the error result in pam_ptimpl.c */
+ retcode = PAM_PASSTHRU_OP_HANDLED;
}
- if (rc == LDAP_SUCCESS) {
- /* we are handling the result */
- slapi_send_ldap_result(pb, rc, NULL, errmsg, 0, NULL);
- /* tell bind code we handled the result */
- retcode = PAM_PASSTHRU_OP_HANDLED;
- } else if (!cfg->pamptconfig_fallback) {
- /* tell bind code we already sent back the error result in pam_ptimpl.c */
- retcode = PAM_PASSTHRU_OP_HANDLED;
- }
+done:
+ pam_passthru_unlock();
slapi_log_error(SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
- "<= handled (error %d - %s)\n", rc, ldap_err2string(rc));
+ "<= handled (error %d - %s)\n", rc, ldap_err2string(rc));
+
+ slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= pam_passthru_bindpreop\n" );
return retcode;
}
+
+
+/*
+ * Pre-op callbacks for config change validation
+ */
+static int
+pam_passthru_preop(Slapi_PBlock *pb, int modtype)
+{
+ Slapi_DN *sdn = NULL;
+ Slapi_Entry *e = NULL;
+ LDAPMod **mods;
+ char returntext[SLAPI_DSE_RETURNTEXT_SIZE];
+ int ret = 0;
+
+ slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "=> pam_passthru_preop\n");
+
+ /* Just bail if we aren't ready to service requests yet. */
+ if (!g_pam_plugin_started) {
+ goto bail;
+ }
+
+ /* Get the target SDN. */
+ slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn);
+ if (!sdn) {
+ goto bail;
+ }
+
+ /* If this is a config entry, we need to validate it. */
+ if (pam_passthru_dn_is_config(sdn)) {
+ switch (modtype) {
+ case LDAP_CHANGETYPE_ADD:
+ slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
+ /* Validate the entry being added. */
+ if (PAM_PASSTHRU_FAILURE == pam_passthru_validate_config(e, returntext)) {
+ ret = LDAP_UNWILLING_TO_PERFORM;
+ goto bail;
+ }
+ break;
+ case LDAP_CHANGETYPE_MODIFY:
+ /* Fetch the entry being modified so we can
+ * create the resulting entry for validation. */
+ slapi_search_internal_get_entry(sdn, 0, &e,
+ pam_passthruauth_get_plugin_identity());
+
+ /* If the entry doesn't exist, just bail and
+ * let the server handle it. */
+ if (e == NULL) {
+ goto bail;
+ }
+
+ /* Grab the mods. */
+ slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
+
+ /* Apply the mods to create the resulting entry. If the mods
+ * don't apply cleanly, we just let the main server code handle it. */
+ if (mods && (slapi_entry_apply_mods(e, mods) == LDAP_SUCCESS)) {
+ /* Validate the resulting entry. */
+ if (PAM_PASSTHRU_FAILURE == pam_passthru_validate_config(e, returntext)) {
+ ret = LDAP_UNWILLING_TO_PERFORM;
+ /* Don't bail here, as we need to free the entry. */
+ }
+ }
+
+ /* Free the entry. */
+ slapi_entry_free(e);
+ break;
+ case LDAP_CHANGETYPE_DELETE:
+ case LDAP_CHANGETYPE_MODDN:
+ /* Don't allow the plug-in container in DSE to be deleted or renamed. */
+ if (slapi_sdn_compare(sdn, pam_passthruauth_get_plugin_sdn()) == 0) {
+ ret = LDAP_UNWILLING_TO_PERFORM;
+ }
+ break;
+ }
+
+ }
+
+ bail:
+ /* If we are refusing the operation, return the result to the client. */
+ if (ret) {
+ slapi_send_ldap_result(pb, ret, NULL, returntext, 0, NULL);
+ ret = -1;
+ }
+
+ slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= pam_passthru_preop\n");
+
+ return ret;
+}
+
+static int
+pam_passthru_add_preop(Slapi_PBlock *pb)
+{
+ return pam_passthru_preop(pb, LDAP_CHANGETYPE_ADD);
+}
+
+static int
+pam_passthru_mod_preop(Slapi_PBlock *pb)
+{
+ return pam_passthru_preop(pb, LDAP_CHANGETYPE_MODIFY);
+}
+
+static int
+pam_passthru_del_preop(Slapi_PBlock *pb)
+{
+ return pam_passthru_preop(pb, LDAP_CHANGETYPE_DELETE);
+}
+
+static int
+pam_passthru_modrdn_preop(Slapi_PBlock *pb)
+{
+ return pam_passthru_preop(pb, LDAP_CHANGETYPE_MODDN);
+}
+
+/*
+ * Post-op callback for dynamic config loading.
+ */
+static int
+pam_passthru_postop(Slapi_PBlock *pb)
+{
+ int ret = 0;
+ Slapi_DN *sdn = NULL;
+ Slapi_DN *new_sdn = NULL;
+ Slapi_Entry *e = NULL;
+ int optype = SLAPI_OPERATION_NONE;
+ int oprc = -1;
+
+ slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "=> pam_passthru_postop\n");
+
+ /* Just bail if we aren't ready to service requests yet. */
+ if (!g_pam_plugin_started) {
+ goto bail;
+ }
+
+ /* Make sure the operation succeeded and bail if it didn't. */
+ slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc);
+ if (oprc != 0) {
+ goto bail;
+ }
+
+ /* Get the target SDN. */
+ slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn);
+ if (!sdn) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_postop: unale to fetch target SDN.\n");
+ goto bail;
+ }
+
+ /* Check if this is a rename operation.
+ * If so, we need to get the new DN. */
+ slapi_pblock_get(pb, SLAPI_OPERATION_TYPE, &optype);
+ if (optype == SLAPI_OPERATION_MODDN) {
+ slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &e);
+ if (e) {
+ new_sdn = slapi_entry_get_sdn(e);
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "pam_passthru_postop: unable to fetch post-op "
+ "entry for rename operation.\n");
+ goto bail;
+ }
+ }
+
+ /* Check if the target is a config entry. If so, reload all of the config.
+ * If this is a rename operation, we also need to see if the new DN is in
+ * the config scope. */
+ if (pam_passthru_dn_is_config(sdn) || (new_sdn && pam_passthru_dn_is_config(new_sdn))) {
+ pam_passthru_load_config(1); /* skip validation, as it was done at preop */
+ }
+
+ slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "<= pam_passthru_postop\n");
+
+ bail:
+ return ret;
+}
+
+/*
+ *
+ * Deal with config locking
+ *
+ */
+void pam_passthru_read_lock()
+{
+ slapi_rwlock_rdlock(g_pam_config_lock);
+}
+
+void pam_passthru_write_lock()
+{
+ slapi_rwlock_wrlock(g_pam_config_lock);
+}
+
+void pam_passthru_unlock()
+{
+ slapi_rwlock_unlock(g_pam_config_lock);
+}
| 0 |
a9263e3fa9d50d469e204fbc4581860c46e7d3b5
|
389ds/389-ds-base
|
fix build with nunc-stans
|
commit a9263e3fa9d50d469e204fbc4581860c46e7d3b5
Author: Rich Megginson <[email protected]>
Date: Mon Jun 15 10:47:22 2015 -0600
fix build with nunc-stans
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 968f0f59a..ddc6552ba 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1123,10 +1123,10 @@ static struct config_get_and_set {
(void**)&global_slapdFrontendConfig.maxsimplepaged_per_conn,
CONFIG_INT, (ConfigGetFunc)config_get_maxsimplepaged_per_conn, DEFAULT_MAXSIMPLEPAGED_PER_CONN_STR},
#ifdef ENABLE_NUNC_STANS
- ,{CONFIG_ENABLE_NUNC_STANS, config_set_enable_nunc_stans,
+ {CONFIG_ENABLE_NUNC_STANS, config_set_enable_nunc_stans,
NULL, 0,
(void**)&global_slapdFrontendConfig.enable_nunc_stans,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_nunc_stans, &init_enable_nunc_stans}
+ CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_nunc_stans, &init_enable_nunc_stans},
#endif
#ifdef MEMPOOL_EXPERIMENTAL
,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
| 0 |
90919bb41f89cfc376d170c4b0b6c790b7ba96d3
|
389ds/389-ds-base
|
Bug 691422 - acl_read_access_allowed_on_entry - fix coverity control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=691422
Resolves: bug 691422
Bug Description: acl_read_access_allowed_on_entry - fix coverity control flow issues
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: ifdef out all code related to DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit 90919bb41f89cfc376d170c4b0b6c790b7ba96d3
Author: Rich Megginson <[email protected]>
Date: Mon Mar 28 14:12:13 2011 -0600
Bug 691422 - acl_read_access_allowed_on_entry - fix coverity control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=691422
Resolves: bug 691422
Bug Description: acl_read_access_allowed_on_entry - fix coverity control flow issues
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: ifdef out all code related to DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
index e42a83adf..279469402 100644
--- a/ldap/servers/plugins/acl/acl.c
+++ b/ldap/servers/plugins/acl/acl.c
@@ -846,7 +846,9 @@ acl_read_access_allowed_on_entry (
Slapi_Attr *currAttr;
Slapi_Attr *nextAttr;
int len;
+#ifdef DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES
int attr_index = -1;
+#endif
char *attr_type = NULL;
int rv, isRoot;
char *clientDn;
@@ -1055,6 +1057,7 @@ acl_read_access_allowed_on_entry (
aclpb->aclpb_Evalattr = slapi_ch_malloc(len+1);
}
PL_strncpyz (aclpb->aclpb_Evalattr, attr_type, len);
+#ifdef DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES
if ( attr_index >= 0 ) {
/*
* access was granted to one of the user specified attributes
@@ -1064,13 +1067,16 @@ acl_read_access_allowed_on_entry (
aclpb->aclpb_state |=
ACLPB_ACCESS_ALLOWED_USERATTR;
} else {
+#endif /* DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES */
/*
* Access was granted to _an_ attribute in the entry and that
* attribute is now in aclpb_Evalattr
*/
aclpb->aclpb_state |=
ACLPB_ACCESS_ALLOWED_ON_A_ATTR;
+#ifdef DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES
}
+#endif /* DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES */
TNF_PROBE_1_DEBUG(acl_read_access_allowed_on_entry_end , "ACL","",
tnf_string,called_access_allowed,"");
@@ -1078,9 +1084,11 @@ acl_read_access_allowed_on_entry (
} else {
/* try the next one */
attr_type = NULL;
+#ifdef DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES
if (attr_index >= 0) {
attr_type = attrs[attr_index++];
} else {
+#endif /* DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES */
rv = slapi_entry_next_attr ( e, currAttr, &nextAttr );
if ( rv != 0 ) break;
currAttr = nextAttr;
@@ -1093,7 +1101,9 @@ acl_read_access_allowed_on_entry (
}
/* Get the attr type */
if ( currAttr ) slapi_attr_get_type ( currAttr , &attr_type );
+#ifdef DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES
}
+#endif /* DETERMINE_ACCESS_BASED_ON_REQUESTED_ATTRIBUTES */
}
}
| 0 |
3835f3ccd452c8d8af26f54ac04433f9f581a2ff
|
389ds/389-ds-base
|
Bug 630096 - (cov#15448) Check return value of cache_replace()
We need to check the return value of cache_replace() in
id2entry_add_ext(). The only possible error that can be returned
is when the entry we are trying to replace is not found in the
cache. This should not occur since we are told that the entry
already exists by CACHE_ADD() just prior to this call. If we run
into this situation, we will just log an error without adding the
entry to the cache. This shouldn't be a big deal since the entry
will get added to the cache next time it is accessed.
|
commit 3835f3ccd452c8d8af26f54ac04433f9f581a2ff
Author: Nathan Kinder <[email protected]>
Date: Wed Sep 8 10:33:23 2010 -0700
Bug 630096 - (cov#15448) Check return value of cache_replace()
We need to check the return value of cache_replace() in
id2entry_add_ext(). The only possible error that can be returned
is when the entry we are trying to replace is not found in the
cache. This should not occur since we are told that the entry
already exists by CACHE_ADD() just prior to this call. If we run
into this situation, we will just log an error without adding the
entry to the cache. This shouldn't be a big deal since the entry
will get added to the cache next time it is accessed.
diff --git a/ldap/servers/slapd/back-ldbm/id2entry.c b/ldap/servers/slapd/back-ldbm/id2entry.c
index 15d742c7a..198fdd511 100644
--- a/ldap/servers/slapd/back-ldbm/id2entry.c
+++ b/ldap/servers/slapd/back-ldbm/id2entry.c
@@ -104,7 +104,12 @@ id2entry_add_ext( backend *be, struct backentry *e, back_txn *txn, int encrypt
* replace it. */
if (CACHE_ADD( &inst->inst_dncache, bdn, &oldbdn ) == 1) {
if (slapi_sdn_compare(sdn, oldbdn->dn_sdn)) {
- cache_replace( &inst->inst_dncache, oldbdn, bdn );
+ if (cache_replace( &inst->inst_dncache, oldbdn, bdn ) != 0) {
+ /* The entry was not in the cache for some reason (this
+ * should not happen since CACHE_ADD said it existed above). */
+ LDAPDebug( LDAP_DEBUG_ANY, "id2entry_add_ext(): Entry disappeared "
+ "from cache (%s)\n", oldbdn->dn_sdn, 0, 0 );
+ }
}
CACHE_RETURN(&inst->inst_dncache, &oldbdn); /* to free oldbdn */
}
| 0 |
0c4eafbc945ae4252886ba8546665a79206f3f83
|
389ds/389-ds-base
|
Ticket #47569 - Added a testcase to ACL testsuite
Description: The attribute defined in the targetattr keyword of an ACI
is checked against the schema to make sure it is a defined attribute
when you are adding a new ACI. If you want to use an attribute subtype,
the ACI is rejected since the attribute with subtype is not defined in
the schema. We should strip off the subtype when we validate the
targetattr keyword against the schema.
Test description:
1. Define two attributes in the schema
- first will be a targetattr
- second will be a userattr
2. Add an ACI with an attribute subtype
- or language subtype
- or binary subtype
- or pronunciation subtype
Signed-off-by: Mark Reynolds <[email protected]>
|
commit 0c4eafbc945ae4252886ba8546665a79206f3f83
Author: Simon Pichugin <[email protected]>
Date: Tue Aug 11 16:11:48 2015 +0200
Ticket #47569 - Added a testcase to ACL testsuite
Description: The attribute defined in the targetattr keyword of an ACI
is checked against the schema to make sure it is a defined attribute
when you are adding a new ACI. If you want to use an attribute subtype,
the ACI is rejected since the attribute with subtype is not defined in
the schema. We should strip off the subtype when we validate the
targetattr keyword against the schema.
Test description:
1. Define two attributes in the schema
- first will be a targetattr
- second will be a userattr
2. Add an ACI with an attribute subtype
- or language subtype
- or binary subtype
- or pronunciation subtype
Signed-off-by: Mark Reynolds <[email protected]>
diff --git a/dirsrvtests/suites/acl/acl_test.py b/dirsrvtests/suites/acl/acl_test.py
index a500d5582..c069a82e3 100644
--- a/dirsrvtests/suites/acl/acl_test.py
+++ b/dirsrvtests/suites/acl/acl_test.py
@@ -51,43 +51,104 @@ def topology(request):
standalone.create()
standalone.open()
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
# Clear out the tmp dir
standalone.clearTmpDir(__file__)
return TopologyStandalone(standalone)
-def test_acl_init(topology):
- '''
- Write any test suite initialization here(if needed)
- '''
-
- return
-
-
-def test_acl_(topology):
- '''
- Write a single test here...
- '''
-
- return
-
-
-def test_acl_final(topology):
- topology.standalone.delete()
- log.info('acl test suite PASSED')
-
-
-def run_isolated():
- global installation1_prefix
- installation1_prefix = None
-
- topo = topology(True)
- test_acl_init(topo)
- test_acl_(topo)
- test_acl_final(topo)
+def add_attr(topology, attr_name):
+ """Adds attribute to the schema"""
+
+ ATTR_VALUE = """(NAME '%s' \
+ DESC 'Attribute filteri-Multi-Valued' \
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.27)""" % attr_name
+ mod = [(ldap.MOD_ADD, 'attributeTypes', ATTR_VALUE)]
+
+ try:
+ topology.standalone.modify_s(DN_SCHEMA, mod)
+ except ldap.LDAPError, e:
+ log.fatal('Failed to add attr (%s): error (%s)' % (attr_name,
+ e.message['desc']))
+ assert False
+
+
[email protected](params=["lang-ja", "binary", "phonetic"])
+def aci_with_attr_subtype(request, topology):
+ """Adds and deletes an ACI in the DEFAULT_SUFFIX"""
+
+ TARGET_ATTR = 'protectedOperation'
+ USER_ATTR = 'allowedToPerform'
+ SUBTYPE = request.param
+
+ log.info("========Executing test with '%s' subtype========" % SUBTYPE)
+ log.info(" Add a target attribute")
+ add_attr(topology, TARGET_ATTR)
+
+ log.info(" Add a user attribute")
+ add_attr(topology, USER_ATTR)
+
+ ACI_TARGET = '(targetattr=%s;%s)' % (TARGET_ATTR, SUBTYPE)
+ ACI_ALLOW = '(version 3.0; acl "test aci for subtypes"; allow (read) '
+ ACI_SUBJECT = 'userattr = "%s;%s#GROUPDN";)' % (USER_ATTR, SUBTYPE)
+ ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+
+ log.info(" Add an ACI with attribute subtype")
+ mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
+ try:
+ topology.standalone.modify_s(DEFAULT_SUFFIX, mod)
+ except ldap.LDAPError, e:
+ log.fatal('Failed to add ACI: error (%s)' % (e.message['desc']))
+ assert False
+
+ def fin():
+ log.info(" Finally, delete an ACI with the '%s' subtype" %
+ SUBTYPE)
+ mod = [(ldap.MOD_DELETE, 'aci', ACI_BODY)]
+ try:
+ topology.standalone.modify_s(DEFAULT_SUFFIX, mod)
+ except ldap.LDAPError, e:
+ log.fatal('Failed to delete ACI: error (%s)' % (e.message['desc']))
+ assert False
+ request.addfinalizer(fin)
+
+ return ACI_BODY
+
+
+def test_aci_attr_subtype_targetattr(topology, aci_with_attr_subtype):
+ """Checks, that ACIs allow attribute subtypes in the targetattr keyword
+
+ Test description:
+ 1. Define two attributes in the schema
+ - first will be a targetattr
+ - second will be a userattr
+ 2. Add an ACI with an attribute subtype
+ - or language subtype
+ - or binary subtype
+ - or pronunciation subtype
+ """
+
+ log.info(" Search for the added attribute")
+ try:
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_BASE,
+ '(objectclass=*)', ['aci'])
+ entry = str(entries[0])
+ assert aci_with_attr_subtype in entry
+ log.info(" The added attribute was found")
+
+ except ldap.LDAPError, e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
if __name__ == '__main__':
- run_isolated()
-
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
| 0 |
b7e9f9f3c35e7b3e964378a5606594942cf44b5f
|
389ds/389-ds-base
|
Ticket #47709 - package issue in 389-ds-base
Description: Automatically generated files: Makefile.in, configure
|
commit b7e9f9f3c35e7b3e964378a5606594942cf44b5f
Author: Noriko Hosoi <[email protected]>
Date: Thu Feb 20 13:18:53 2014 -0800
Ticket #47709 - package issue in 389-ds-base
Description: Automatically generated files: Makefile.in, configure
diff --git a/Makefile.in b/Makefile.in
index 780227f23..1d8fa4787 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -176,9 +176,9 @@ am__installdirs = "$(DESTDIR)$(serverdir)" \
"$(DESTDIR)$(initconfigdir)" "$(DESTDIR)$(mibdir)" \
"$(DESTDIR)$(propertydir)" "$(DESTDIR)$(perldir)" \
"$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(propertydir)" \
- "$(DESTDIR)$(sampledatadir)" "$(DESTDIR)$(schemadir)" \
- "$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(updatedir)" \
- "$(DESTDIR)$(serverincdir)"
+ "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(sampledatadir)" \
+ "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(systemdsystemunitdir)" \
+ "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(serverincdir)"
LTLIBRARIES = $(server_LTLIBRARIES) $(serverplugin_LTLIBRARIES)
am__DEPENDENCIES_1 =
libacctpolicy_plugin_la_DEPENDENCIES = libslapd.la \
@@ -1227,8 +1227,8 @@ NROFF = nroff
MANS = $(dist_man_MANS)
DATA = $(config_DATA) $(inf_DATA) $(initconfig_DATA) $(mib_DATA) \
$(nodist_property_DATA) $(perl_DATA) $(pkgconfig_DATA) \
- $(property_DATA) $(sampledata_DATA) $(schema_DATA) \
- $(systemdsystemunit_DATA) $(update_DATA)
+ $(property_DATA) $(python_DATA) $(sampledata_DATA) \
+ $(schema_DATA) $(systemdsystemunit_DATA) $(update_DATA)
HEADERS = $(serverinc_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)config.h.in
@@ -1456,6 +1456,7 @@ prefix = @prefix@
program_transform_name = @program_transform_name@
propertydir = $(datadir)@propertydir@
psdir = @psdir@
+pythondir = $(libdir)@pythondir@
sampledatadir = $(datadir)@sampledatadir@
sasl_inc = @sasl_inc@
sasl_lib = @sasl_lib@
@@ -1664,9 +1665,7 @@ config_DATA = $(srcdir)/lib/ldaputil/certmap.conf \
# with the default schema e.g. there is
# considerable overlap of 60changelog.ldif and 01common.ldif
# and 60inetmail.ldif and 50ns-mail.ldif among others
-sampledata_DATA = ldap/admin/src/scripts/failedbinds.py \
- ldap/admin/src/scripts/DSSharedLib \
- ldap/admin/src/scripts/logregex.py \
+sampledata_DATA = ldap/admin/src/scripts/DSSharedLib \
$(srcdir)/ldap/ldif/Ace.ldif \
$(srcdir)/ldap/ldif/European.ldif \
$(srcdir)/ldap/ldif/Eurosuffix.ldif \
@@ -1819,6 +1818,9 @@ perl_DATA = ldap/admin/src/scripts/SetupLog.pm \
ldap/admin/src/scripts/DSUpdate.pm \
ldap/admin/src/scripts/DSUpdateDialogs.pm
+python_DATA = ldap/admin/src/scripts/failedbinds.py \
+ ldap/admin/src/scripts/logregex.py
+
property_DATA = ldap/admin/src/scripts/setup-ds.res \
ldap/admin/src/scripts/migrate-ds.res
@@ -9851,6 +9853,27 @@ uninstall-propertyDATA:
@list='$(property_DATA)'; test -n "$(propertydir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(propertydir)'; $(am__uninstall_files_from_dir)
+install-pythonDATA: $(python_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(python_DATA)'; test -n "$(pythondir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pythondir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pythondir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pythondir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pythondir)" || exit $$?; \
+ done
+
+uninstall-pythonDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(python_DATA)'; test -n "$(pythondir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(pythondir)'; $(am__uninstall_files_from_dir)
install-sampledataDATA: $(sampledata_DATA)
@$(NORMAL_INSTALL)
@list='$(sampledata_DATA)'; test -n "$(sampledatadir)" || list=; \
@@ -10177,7 +10200,7 @@ check: $(BUILT_SOURCES)
all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) \
$(MANS) $(DATA) $(HEADERS) config.h
installdirs:
- for dir in "$(DESTDIR)$(serverdir)" "$(DESTDIR)$(serverplugindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(initdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(taskdir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(configdir)" "$(DESTDIR)$(infdir)" "$(DESTDIR)$(initconfigdir)" "$(DESTDIR)$(mibdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(perldir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(sampledatadir)" "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(serverincdir)"; do \
+ for dir in "$(DESTDIR)$(serverdir)" "$(DESTDIR)$(serverplugindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(initdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(taskdir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(configdir)" "$(DESTDIR)$(infdir)" "$(DESTDIR)$(initconfigdir)" "$(DESTDIR)$(mibdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(perldir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(sampledatadir)" "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(serverincdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: $(BUILT_SOURCES)
@@ -10336,7 +10359,7 @@ info-am:
install-data-am: install-configDATA install-infDATA \
install-initSCRIPTS install-initconfigDATA install-man \
install-mibDATA install-nodist_propertyDATA install-perlDATA \
- install-pkgconfigDATA install-propertyDATA \
+ install-pkgconfigDATA install-propertyDATA install-pythonDATA \
install-sampledataDATA install-schemaDATA \
install-serverLTLIBRARIES install-serverincHEADERS \
install-serverpluginLTLIBRARIES install-systemdsystemunitDATA \
@@ -10394,10 +10417,10 @@ uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
uninstall-initconfigDATA uninstall-man uninstall-mibDATA \
uninstall-nodist_propertyDATA uninstall-perlDATA \
uninstall-pkgconfigDATA uninstall-propertyDATA \
- uninstall-sampledataDATA uninstall-sbinPROGRAMS \
- uninstall-sbinSCRIPTS uninstall-schemaDATA \
- uninstall-serverLTLIBRARIES uninstall-serverincHEADERS \
- uninstall-serverpluginLTLIBRARIES \
+ uninstall-pythonDATA uninstall-sampledataDATA \
+ uninstall-sbinPROGRAMS uninstall-sbinSCRIPTS \
+ uninstall-schemaDATA uninstall-serverLTLIBRARIES \
+ uninstall-serverincHEADERS uninstall-serverpluginLTLIBRARIES \
uninstall-systemdsystemunitDATA uninstall-taskSCRIPTS \
uninstall-updateDATA uninstall-updateSCRIPTS
@@ -10423,8 +10446,9 @@ uninstall-man: uninstall-man1 uninstall-man8
install-man1 install-man8 install-mibDATA \
install-nodist_propertyDATA install-pdf install-pdf-am \
install-perlDATA install-pkgconfigDATA install-propertyDATA \
- install-ps install-ps-am install-sampledataDATA \
- install-sbinPROGRAMS install-sbinSCRIPTS install-schemaDATA \
+ install-ps install-ps-am install-pythonDATA \
+ install-sampledataDATA install-sbinPROGRAMS \
+ install-sbinSCRIPTS install-schemaDATA \
install-serverLTLIBRARIES install-serverincHEADERS \
install-serverpluginLTLIBRARIES install-strip \
install-systemdsystemunitDATA install-taskSCRIPTS \
@@ -10438,10 +10462,10 @@ uninstall-man: uninstall-man1 uninstall-man8
uninstall-man1 uninstall-man8 uninstall-mibDATA \
uninstall-nodist_propertyDATA uninstall-perlDATA \
uninstall-pkgconfigDATA uninstall-propertyDATA \
- uninstall-sampledataDATA uninstall-sbinPROGRAMS \
- uninstall-sbinSCRIPTS uninstall-schemaDATA \
- uninstall-serverLTLIBRARIES uninstall-serverincHEADERS \
- uninstall-serverpluginLTLIBRARIES \
+ uninstall-pythonDATA uninstall-sampledataDATA \
+ uninstall-sbinPROGRAMS uninstall-sbinSCRIPTS \
+ uninstall-schemaDATA uninstall-serverLTLIBRARIES \
+ uninstall-serverincHEADERS uninstall-serverpluginLTLIBRARIES \
uninstall-systemdsystemunitDATA uninstall-taskSCRIPTS \
uninstall-updateDATA uninstall-updateSCRIPTS
diff --git a/configure b/configure
index b37b5e270..da1517c72 100755
--- a/configure
+++ b/configure
@@ -720,6 +720,7 @@ defaultuser
updatedir
mibdir
infdir
+pythondir
perldir
scripttemplatedir
serverplugindir
@@ -914,6 +915,7 @@ with_fhs
with_fhs_opt
with_tmpfiles_d
with_perldir
+with_pythondir
with_systemdsystemunitdir
with_systemdsystemconfdir
with_systemdgroupname
@@ -1639,6 +1641,8 @@ Optional Packages:
--with-perldir=PATH Directory for perl)
+ --with-pythondir=PATH Directory for python)
+
--with-systemdsystemunitdir=PATH
Directory for systemd service files (default:
$with_systemdsystemunitdir)
@@ -7430,7 +7434,7 @@ ia64-*-hpux*)
rm -rf conftest*
;;
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
# Find out which ABI we are using.
echo 'int i;' > conftest.$ac_ext
@@ -7448,7 +7452,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_i386"
;;
- ppc64-*linux*|powerpc64-*linux*)
+ powerpc64le-*linux*)
+ LD="${LD-ld} -m elf32lppclinux"
+ ;;
+ powerpc64-*linux*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)
@@ -7467,7 +7474,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_x86_64"
;;
- ppc*-*linux*|powerpc*-*linux*)
+ powerpcle-*linux*)
+ LD="${LD-ld} -m elf64lppc"
+ ;;
+ powerpc-*linux*)
LD="${LD-ld} -m elf64ppc"
;;
s390*-*linux*|s390*-*tpf*)
@@ -17988,6 +17998,8 @@ if test "$with_fhs_opt" = "yes"; then
propertydir=/properties
# relative to libdir
perldir=/perl
+ # relative to libdir
+ pythondir=/python
else
if test "$with_fhs" = "yes"; then
ac_default_prefix=/usr
@@ -18017,6 +18029,8 @@ else
propertydir=/$PACKAGE_NAME/properties
# relative to libdir
perldir=/$PACKAGE_NAME/perl
+ # relative to libdir
+ pythondir=/$PACKAGE_NAME/python
fi
# if mandir is the default value, override it
@@ -18204,6 +18218,27 @@ else
with_perldir=
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-pythondir" >&5
+$as_echo_n "checking for --with-pythondir... " >&6; }
+
+# Check whether --with-pythondir was given.
+if test "${with_pythondir+set}" = set; then :
+ withval=$with_pythondir;
+fi
+
+if test -n "$with_pythondir"; then
+ if test "$with_pythondir" = yes ; then
+ as_fn_error $? "You must specify --with-pythondir=/full/path/to/python" "$LINENO" 5
+ elif test "$with_pythondir" = no ; then
+ with_pythondir=
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_pythondir" >&5
+$as_echo "$with_pythondir" >&6; }
+ fi
+else
+ with_pythondir=
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-systemdsystemunitdir" >&5
$as_echo_n "checking for --with-systemdsystemunitdir... " >&6; }
@@ -18292,6 +18327,7 @@ fi
+
# check for --with-instconfigdir
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-instconfigdir" >&5
$as_echo_n "checking for --with-instconfigdir... " >&6; }
| 0 |
be67f8128d4a19edec95a6b1b022fd9262710e74
|
389ds/389-ds-base
|
Ticket 47553: Enhance ACIs to have more control over MODRDN operations
Bug Description:
The ticket 47553 introduces a new aci right: moddn.
This rights allows/deny to do a MODDN from a part of the DIT to an other.
Before the right allow/deny to do a MODDN was granted if the subject had 'write' access to the rdn attribute.
To switch from the previous mode to the new one, there is a toggle 'nsslapd-moddn-aci'.
The getEffectiveRight control, should report the MODDN right ('n') according to
the acis and the value of this toggle
Fix Description:
test 'nsslapd-moddn-aci' in the geteffectiveright code
https://fedorahosted.org/389/ticket/47553
Reviewed by: Noriko (Thanks !)
Platforms tested: F17
Flag Day: no
Doc impact: no
|
commit be67f8128d4a19edec95a6b1b022fd9262710e74
Author: Thierry bordaz (tbordaz) <[email protected]>
Date: Thu Oct 16 17:24:15 2014 +0200
Ticket 47553: Enhance ACIs to have more control over MODRDN operations
Bug Description:
The ticket 47553 introduces a new aci right: moddn.
This rights allows/deny to do a MODDN from a part of the DIT to an other.
Before the right allow/deny to do a MODDN was granted if the subject had 'write' access to the rdn attribute.
To switch from the previous mode to the new one, there is a toggle 'nsslapd-moddn-aci'.
The getEffectiveRight control, should report the MODDN right ('n') according to
the acis and the value of this toggle
Fix Description:
test 'nsslapd-moddn-aci' in the geteffectiveright code
https://fedorahosted.org/389/ticket/47553
Reviewed by: Noriko (Thanks !)
Platforms tested: F17
Flag Day: no
Doc impact: no
diff --git a/dirsrvtests/tickets/ticket47553_ger.py b/dirsrvtests/tickets/ticket47553_ger.py
new file mode 100644
index 000000000..d688c70ab
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47553_ger.py
@@ -0,0 +1,553 @@
+'''
+Created on Nov 7, 2013
+
+@author: tbordaz
+'''
+import os
+import sys
+import time
+import ldap
+import logging
+import socket
+import time
+import logging
+import pytest
+import re
+from lib389 import DirSrv, Entry, tools
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from constants import *
+from lib389._constants import REPLICAROLE_MASTER
+from ldap.controls.simple import GetEffectiveRightsControl
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+#
+# important part. We can deploy Master1 and Master2 on different versions
+#
+installation1_prefix = None
+installation2_prefix = None
+
+TEST_REPL_DN = "cn=test_repl, %s" % SUFFIX
+
+STAGING_CN = "staged user"
+PRODUCTION_CN = "accounts"
+EXCEPT_CN = "excepts"
+
+STAGING_DN = "cn=%s,%s" % (STAGING_CN, SUFFIX)
+PRODUCTION_DN = "cn=%s,%s" % (PRODUCTION_CN, SUFFIX)
+PROD_EXCEPT_DN = "cn=%s,%s" % (EXCEPT_CN, PRODUCTION_DN)
+
+STAGING_PATTERN = "cn=%s*,%s" % (STAGING_CN[:2], SUFFIX)
+PRODUCTION_PATTERN = "cn=%s*,%s" % (PRODUCTION_CN[:2], SUFFIX)
+BAD_STAGING_PATTERN = "cn=bad*,%s" % (SUFFIX)
+BAD_PRODUCTION_PATTERN = "cn=bad*,%s" % (SUFFIX)
+
+BIND_CN = "bind_entry"
+BIND_DN = "cn=%s,%s" % (BIND_CN, SUFFIX)
+BIND_PW = "password"
+
+NEW_ACCOUNT = "new_account"
+MAX_ACCOUNTS = 20
+
+CONFIG_MODDN_ACI_ATTR = "nsslapd-moddn-aci"
+
+class TopologyMaster1Master2(object):
+ def __init__(self, master1, master2):
+ master1.open()
+ self.master1 = master1
+
+ master2.open()
+ self.master2 = master2
+
+
[email protected](scope="module")
+def topology(request):
+ '''
+ This fixture is used to create a replicated topology for the 'module'.
+ The replicated topology is MASTER1 <-> Master2.
+ At the beginning, It may exists a master2 instance and/or a master2 instance.
+ It may also exists a backup for the master1 and/or the master2.
+
+ Principle:
+ If master1 instance exists:
+ restart it
+ If master2 instance exists:
+ restart it
+ If backup of master1 AND backup of master2 exists:
+ create or rebind to master1
+ create or rebind to master2
+
+ restore master1 from backup
+ restore master2 from backup
+ else:
+ Cleanup everything
+ remove instances
+ remove backups
+ Create instances
+ Initialize replication
+ Create backups
+ '''
+ global installation1_prefix
+ global installation2_prefix
+
+ # allocate master1 on a given deployement
+ master1 = DirSrv(verbose=False)
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Args for the master1 instance
+ args_instance[SER_HOST] = HOST_MASTER_1
+ args_instance[SER_PORT] = PORT_MASTER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
+ args_master = args_instance.copy()
+ master1.allocate(args_master)
+
+ # allocate master1 on a given deployement
+ master2 = DirSrv(verbose=False)
+ if installation2_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation2_prefix
+
+ # Args for the consumer instance
+ args_instance[SER_HOST] = HOST_MASTER_2
+ args_instance[SER_PORT] = PORT_MASTER_2
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
+ args_master = args_instance.copy()
+ master2.allocate(args_master)
+
+
+ # Get the status of the backups
+ backup_master1 = master1.checkBackupFS()
+ backup_master2 = master2.checkBackupFS()
+
+ # Get the status of the instance and restart it if it exists
+ instance_master1 = master1.exists()
+ if instance_master1:
+ master1.stop(timeout=10)
+ master1.start(timeout=10)
+
+ instance_master2 = master2.exists()
+ if instance_master2:
+ master2.stop(timeout=10)
+ master2.start(timeout=10)
+
+ if backup_master1 and backup_master2:
+ # The backups exist, assuming they are correct
+ # we just re-init the instances with them
+ if not instance_master1:
+ master1.create()
+ # Used to retrieve configuration information (dbdir, confdir...)
+ master1.open()
+
+ if not instance_master2:
+ master2.create()
+ # Used to retrieve configuration information (dbdir, confdir...)
+ master2.open()
+
+ # restore master1 from backup
+ master1.stop(timeout=10)
+ master1.restoreFS(backup_master1)
+ master1.start(timeout=10)
+
+ # restore master2 from backup
+ master2.stop(timeout=10)
+ master2.restoreFS(backup_master2)
+ master2.start(timeout=10)
+ else:
+ # We should be here only in two conditions
+ # - This is the first time a test involve master-consumer
+ # so we need to create everything
+ # - Something weird happened (instance/backup destroyed)
+ # so we discard everything and recreate all
+
+ # Remove all the backups. So even if we have a specific backup file
+ # (e.g backup_master) we clear all backups that an instance my have created
+ if backup_master1:
+ master1.clearBackupFS()
+ if backup_master2:
+ master2.clearBackupFS()
+
+ # Remove all the instances
+ if instance_master1:
+ master1.delete()
+ if instance_master2:
+ master2.delete()
+
+ # Create the instances
+ master1.create()
+ master1.open()
+ master2.create()
+ master2.open()
+
+ #
+ # Now prepare the Master-Consumer topology
+ #
+ # First Enable replication
+ master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
+ master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
+
+ # Initialize the supplier->consumer
+
+ properties = {RA_NAME: r'meTo_$host:$port',
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ repl_agreement = master1.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
+
+ if not repl_agreement:
+ log.fatal("Fail to create a replica agreement")
+ sys.exit(1)
+
+ log.debug("%s created" % repl_agreement)
+
+ properties = {RA_NAME: r'meTo_$host:$port',
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ master2.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
+
+ master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
+ master1.waitForReplInit(repl_agreement)
+
+ # Check replication is working fine
+ master1.add_s(Entry((TEST_REPL_DN, {
+ 'objectclass': "top person".split(),
+ 'sn': 'test_repl',
+ 'cn': 'test_repl'})))
+ loop = 0
+ while loop <= 10:
+ try:
+ ent = master2.getEntry(TEST_REPL_DN, ldap.SCOPE_BASE, "(objectclass=*)")
+ break
+ except ldap.NO_SUCH_OBJECT:
+ time.sleep(1)
+ loop += 1
+
+ # Time to create the backups
+ master1.stop(timeout=10)
+ master1.backupfile = master1.backupFS()
+ master1.start(timeout=10)
+
+ master2.stop(timeout=10)
+ master2.backupfile = master2.backupFS()
+ master2.start(timeout=10)
+
+ # clear the tmp directory
+ master1.clearTmpDir(__file__)
+
+ #
+ # Here we have two instances master and consumer
+ # with replication working. Either coming from a backup recovery
+ # or from a fresh (re)init
+ # Time to return the topology
+ return TopologyMaster1Master2(master1, master2)
+
+
+
+def _bind_manager(topology):
+ topology.master1.log.info("Bind as %s " % DN_DM)
+ topology.master1.simple_bind_s(DN_DM, PASSWORD)
+
+def _bind_normal(topology):
+ # bind as bind_entry
+ topology.master1.log.info("Bind as %s" % BIND_DN)
+ topology.master1.simple_bind_s(BIND_DN, BIND_PW)
+
+def _moddn_aci_deny_tree(topology, mod_type=None, target_from=STAGING_DN, target_to=PROD_EXCEPT_DN):
+ '''
+ It denies the access moddn_to in cn=except,cn=accounts,SUFFIX
+ '''
+ assert mod_type != None
+
+ ACI_TARGET_FROM = ""
+ ACI_TARGET_TO = ""
+ if target_from:
+ ACI_TARGET_FROM = "(target_from = \"ldap:///%s\")" % (target_from)
+ if target_to:
+ ACI_TARGET_TO = "(target_to = \"ldap:///%s\")" % (target_to)
+
+ ACI_ALLOW = "(version 3.0; acl \"Deny MODDN to prod_except\"; deny (moddn)"
+ ACI_SUBJECT = " userdn = \"ldap:///%s\";)" % BIND_DN
+ ACI_BODY = ACI_TARGET_TO + ACI_TARGET_FROM + ACI_ALLOW + ACI_SUBJECT
+ mod = [(mod_type, 'aci', ACI_BODY)]
+ #topology.master1.modify_s(SUFFIX, mod)
+ topology.master1.log.info("Add a DENY aci under %s " % PROD_EXCEPT_DN)
+ topology.master1.modify_s(PROD_EXCEPT_DN, mod)
+
+def _moddn_aci_staging_to_production(topology, mod_type=None, target_from=STAGING_DN, target_to=PRODUCTION_DN):
+ assert mod_type != None
+
+
+ ACI_TARGET_FROM = ""
+ ACI_TARGET_TO = ""
+ if target_from:
+ ACI_TARGET_FROM = "(target_from = \"ldap:///%s\")" % (target_from)
+ if target_to:
+ ACI_TARGET_TO = "(target_to = \"ldap:///%s\")" % (target_to)
+
+ ACI_ALLOW = "(version 3.0; acl \"MODDN from staging to production\"; allow (moddn)"
+ ACI_SUBJECT = " userdn = \"ldap:///%s\";)" % BIND_DN
+ ACI_BODY = ACI_TARGET_FROM + ACI_TARGET_TO + ACI_ALLOW + ACI_SUBJECT
+ mod = [(mod_type, 'aci', ACI_BODY)]
+ topology.master1.modify_s(SUFFIX, mod)
+
+def _moddn_aci_from_production_to_staging(topology, mod_type=None):
+ assert mod_type != None
+
+ ACI_TARGET = "(target_from = \"ldap:///%s\") (target_to = \"ldap:///%s\")" % (PRODUCTION_DN, STAGING_DN)
+ ACI_ALLOW = "(version 3.0; acl \"MODDN from production to staging\"; allow (moddn)"
+ ACI_SUBJECT = " userdn = \"ldap:///%s\";)" % BIND_DN
+ ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+ mod = [(mod_type, 'aci', ACI_BODY)]
+ topology.master1.modify_s(SUFFIX, mod)
+
+
+def test_ticket47553_init(topology):
+ """
+ Creates
+ - a staging DIT
+ - a production DIT
+ - add accounts in staging DIT
+ - enable ACL logging (commented for performance reason)
+
+ """
+
+ topology.master1.log.info("\n\n######################### INITIALIZATION ######################\n")
+
+ # entry used to bind with
+ topology.master1.log.info("Add %s" % BIND_DN)
+ topology.master1.add_s(Entry((BIND_DN, {
+ 'objectclass': "top person".split(),
+ 'sn': BIND_CN,
+ 'cn': BIND_CN,
+ 'userpassword': BIND_PW})))
+
+ # DIT for staging
+ topology.master1.log.info("Add %s" % STAGING_DN)
+ topology.master1.add_s(Entry((STAGING_DN, {
+ 'objectclass': "top organizationalRole".split(),
+ 'cn': STAGING_CN,
+ 'description': "staging DIT"})))
+
+ # DIT for production
+ topology.master1.log.info("Add %s" % PRODUCTION_DN)
+ topology.master1.add_s(Entry((PRODUCTION_DN, {
+ 'objectclass': "top organizationalRole".split(),
+ 'cn': PRODUCTION_CN,
+ 'description': "production DIT"})))
+
+ # DIT for production/except
+ topology.master1.log.info("Add %s" % PROD_EXCEPT_DN)
+ topology.master1.add_s(Entry((PROD_EXCEPT_DN, {
+ 'objectclass': "top organizationalRole".split(),
+ 'cn': EXCEPT_CN,
+ 'description': "production except DIT"})))
+
+ # enable acl error logging
+ #mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '128')]
+ #topology.master1.modify_s(DN_CONFIG, mod)
+ #topology.master2.modify_s(DN_CONFIG, mod)
+
+
+
+
+
+ # add dummy entries in the staging DIT
+ for cpt in range(MAX_ACCOUNTS):
+ name = "%s%d" % (NEW_ACCOUNT, cpt)
+ topology.master1.add_s(Entry(("cn=%s,%s" % (name, STAGING_DN), {
+ 'objectclass': "top person".split(),
+ 'sn': name,
+ 'cn': name})))
+
+
+def test_ticket47553_mode_default_add_deny(topology):
+ '''
+ This test case checks that the ADD operation fails (no ADD aci on production)
+ '''
+
+ topology.master1.log.info("\n\n######################### mode moddn_aci : ADD (should fail) ######################\n")
+
+ _bind_normal(topology)
+
+ #
+ # First try to add an entry in production => INSUFFICIENT_ACCESS
+ #
+ try:
+ topology.master1.log.info("Try to add %s" % PRODUCTION_DN)
+ name = "%s%d" % (NEW_ACCOUNT, 0)
+ topology.master1.add_s(Entry(("cn=%s,%s" % (name, PRODUCTION_DN), {
+ 'objectclass': "top person".split(),
+ 'sn': name,
+ 'cn': name})))
+ assert 0 # this is an error, we should not be allowed to add an entry in production
+ except Exception as e:
+ topology.master1.log.info("Exception (expected): %s" % type(e).__name__)
+ assert isinstance(e, ldap.INSUFFICIENT_ACCESS)
+
+def test_ticket47553_mode_default_ger_no_moddn(topology):
+ topology.master1.log.info("\n\n######################### mode moddn_aci : GER no moddn ######################\n")
+ request_ctrl = GetEffectiveRightsControl(criticality=True,authzId="dn: " + BIND_DN)
+ msg_id = topology.master1.search_ext(PRODUCTION_DN, ldap.SCOPE_SUBTREE, "objectclass=*", serverctrls=[request_ctrl])
+ rtype,rdata,rmsgid,response_ctrl = topology.master1.result3(msg_id)
+ ger={}
+ value=''
+ for dn, attrs in rdata:
+ topology.master1.log.info ("dn: %s" % dn)
+ value = attrs['entryLevelRights'][0]
+
+ topology.master1.log.info ("############### entryLevelRights: %r" % value)
+ assert 'n' not in value
+
+def test_ticket47553_mode_default_ger_with_moddn(topology):
+ '''
+ This test case adds the moddn aci and check ger contains 'n'
+ '''
+
+ topology.master1.log.info("\n\n######################### mode moddn_aci: GER with moddn ######################\n")
+
+ # successfull MOD with the ACI
+ _bind_manager(topology)
+ _moddn_aci_staging_to_production(topology, mod_type=ldap.MOD_ADD, target_from=STAGING_DN, target_to=PRODUCTION_DN)
+ _bind_normal(topology)
+
+ request_ctrl = GetEffectiveRightsControl(criticality=True,authzId="dn: " + BIND_DN)
+ msg_id = topology.master1.search_ext(PRODUCTION_DN, ldap.SCOPE_SUBTREE, "objectclass=*", serverctrls=[request_ctrl])
+ rtype,rdata,rmsgid,response_ctrl = topology.master1.result3(msg_id)
+ ger={}
+ value = ''
+ for dn, attrs in rdata:
+ topology.master1.log.info ("dn: %s" % dn)
+ value = attrs['entryLevelRights'][0]
+
+ topology.master1.log.info ("############### entryLevelRights: %r" % value)
+ assert 'n' in value
+
+ # successfull MOD with the both ACI
+ _bind_manager(topology)
+ _moddn_aci_staging_to_production(topology, mod_type=ldap.MOD_DELETE, target_from=STAGING_DN, target_to=PRODUCTION_DN)
+ _bind_normal(topology)
+
+def test_ticket47553_mode_switch_default_to_legacy(topology):
+ '''
+ This test switch the server from default mode to legacy
+ '''
+ topology.master1.log.info("\n\n######################### Disable the moddn aci mod ######################\n" )
+ _bind_manager(topology)
+ mod = [(ldap.MOD_REPLACE, CONFIG_MODDN_ACI_ATTR, 'off')]
+ topology.master1.modify_s(DN_CONFIG, mod)
+
+def test_ticket47553_mode_legacy_ger_no_moddn1(topology):
+ topology.master1.log.info("\n\n######################### mode legacy 1: GER no moddn ######################\n")
+ request_ctrl = GetEffectiveRightsControl(criticality=True,authzId="dn: " + BIND_DN)
+ msg_id = topology.master1.search_ext(PRODUCTION_DN, ldap.SCOPE_SUBTREE, "objectclass=*", serverctrls=[request_ctrl])
+ rtype,rdata,rmsgid,response_ctrl = topology.master1.result3(msg_id)
+ ger={}
+ value=''
+ for dn, attrs in rdata:
+ topology.master1.log.info ("dn: %s" % dn)
+ value = attrs['entryLevelRights'][0]
+
+ topology.master1.log.info ("############### entryLevelRights: %r" % value)
+ assert 'n' not in value
+
+def test_ticket47553_mode_legacy_ger_no_moddn2(topology):
+ topology.master1.log.info("\n\n######################### mode legacy 2: GER no moddn ######################\n")
+ # successfull MOD with the ACI
+ _bind_manager(topology)
+ _moddn_aci_staging_to_production(topology, mod_type=ldap.MOD_ADD, target_from=STAGING_DN, target_to=PRODUCTION_DN)
+ _bind_normal(topology)
+
+ request_ctrl = GetEffectiveRightsControl(criticality=True,authzId="dn: " + BIND_DN)
+ msg_id = topology.master1.search_ext(PRODUCTION_DN, ldap.SCOPE_SUBTREE, "objectclass=*", serverctrls=[request_ctrl])
+ rtype,rdata,rmsgid,response_ctrl = topology.master1.result3(msg_id)
+ ger={}
+ value=''
+ for dn, attrs in rdata:
+ topology.master1.log.info ("dn: %s" % dn)
+ value = attrs['entryLevelRights'][0]
+
+ topology.master1.log.info ("############### entryLevelRights: %r" % value)
+ assert 'n' not in value
+
+ # successfull MOD with the both ACI
+ _bind_manager(topology)
+ _moddn_aci_staging_to_production(topology, mod_type=ldap.MOD_DELETE, target_from=STAGING_DN, target_to=PRODUCTION_DN)
+ _bind_normal(topology)
+
+def test_ticket47553_mode_legacy_ger_with_moddn(topology):
+ topology.master1.log.info("\n\n######################### mode legacy : GER with moddn ######################\n")
+
+ # being allowed to read/write the RDN attribute use to allow the RDN
+ ACI_TARGET = "(target = \"ldap:///%s\")(targetattr=\"cn\")" % (PRODUCTION_DN)
+ ACI_ALLOW = "(version 3.0; acl \"MODDN production changing the RDN attribute\"; allow (read,search,write)"
+ ACI_SUBJECT = " userdn = \"ldap:///%s\";)" % BIND_DN
+ ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+
+ # successfull MOD with the ACI
+ _bind_manager(topology)
+ mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
+ topology.master1.modify_s(SUFFIX, mod)
+ _bind_normal(topology)
+
+ request_ctrl = GetEffectiveRightsControl(criticality=True,authzId="dn: " + BIND_DN)
+ msg_id = topology.master1.search_ext(PRODUCTION_DN, ldap.SCOPE_SUBTREE, "objectclass=*", serverctrls=[request_ctrl])
+ rtype,rdata,rmsgid,response_ctrl = topology.master1.result3(msg_id)
+ ger={}
+ value=''
+ for dn, attrs in rdata:
+ topology.master1.log.info ("dn: %s" % dn)
+ value = attrs['entryLevelRights'][0]
+
+ topology.master1.log.info ("############### entryLevelRights: %r" % value)
+ assert 'n' in value
+
+ # successfull MOD with the both ACI
+ _bind_manager(topology)
+ mod = [(ldap.MOD_DELETE, 'aci', ACI_BODY)]
+ topology.master1.modify_s(SUFFIX, mod)
+ _bind_normal(topology)
+
+
+def test_ticket47553_final(topology):
+ topology.master1.stop(timeout=10)
+ topology.master2.stop(timeout=10)
+
+def run_isolated():
+ '''
+ run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
+ To run isolated without py.test, you need to
+ - edit this file and comment '@pytest.fixture' line before 'topology' function.
+ - set the installation prefix
+ - run this program
+ '''
+ global installation1_prefix
+ global installation2_prefix
+ installation1_prefix = None
+ installation2_prefix = None
+
+ topo = topology(True)
+ topo.master1.log.info("\n\n######################### Ticket 47553 ######################\n")
+ test_ticket47553_init(topo)
+
+ # Check that without appropriate aci we are not allowed to add/delete
+ test_ticket47553_mode_default_add_deny(topo)
+ test_ticket47553_mode_default_ger_no_moddn(topo)
+ test_ticket47553_mode_default_ger_with_moddn(topo)
+ test_ticket47553_mode_switch_default_to_legacy(topo)
+ test_ticket47553_mode_legacy_ger_no_moddn1(topo)
+ test_ticket47553_mode_legacy_ger_no_moddn2(topo)
+ test_ticket47553_mode_legacy_ger_with_moddn(topo)
+
+ test_ticket47553_final(topo)
+
+
+
+
+if __name__ == '__main__':
+ run_isolated()
+
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index b9e2055a5..3c7d63557 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -456,38 +456,45 @@ _ger_get_entry_rights (
entryrights |= SLAPI_ACL_DELETE;
_append_gerstr(gerstr, gerstrsize, gerstrcap, "d", NULL);
}
- /*
- * Some limitation/simplification applied here:
- * - The modrdn right requires the rights to delete the old rdn and
- * the new one. However we have no knowledge of what the new rdn
- * is going to be.
- * - In multi-valued RDN case, we check the right on
- * the first rdn type only for now.
- */
- rdn = slapi_rdn_new_dn ( slapi_entry_get_ndn (e) );
- slapi_rdn_get_first(rdn, &rdntype, &rdnvalue);
- if ( NULL != rdntype ) {
- slapi_log_error (SLAPI_LOG_ACL, plugin_name,
- "_ger_get_entry_rights: SLAPI_ACL_WRITE_DEL & _ADD %s\n", rdntype );
- if (acl_access_allowed(gerpb, e, rdntype, NULL,
- ACLPB_SLAPI_ACL_WRITE_DEL) == LDAP_SUCCESS &&
- acl_access_allowed(gerpb, e, rdntype, NULL,
- ACLPB_SLAPI_ACL_WRITE_ADD) == LDAP_SUCCESS)
- {
- /* n - rename e */
- entryrights |= SLAPI_ACL_WRITE;
- _append_gerstr(gerstr, gerstrsize, gerstrcap, "n", NULL);
- }
- }
- slapi_rdn_free ( &rdn );
-
- if (acl_access_allowed(gerpb, e, NULL, NULL, SLAPI_ACL_MODDN) == LDAP_SUCCESS) {
- slapi_log_error (SLAPI_LOG_ACL, plugin_name,
- "_ger_get_entry_rights: SLAPI_ACL_MODDN %s\n", slapi_entry_get_ndn (e) );
+
+ if (config_get_moddn_aci()) {
+ /* The server enforces the new MODDN aci right.
+ * So the status 'n' is set if this right is granted.
+ * Opposed to the legacy mode where this flag is set if
+ * WRITE was granted on rdn attrbibute
+ */
+ if (acl_access_allowed(gerpb, e, NULL, NULL, SLAPI_ACL_MODDN) == LDAP_SUCCESS) {
+ slapi_log_error(SLAPI_LOG_ACL, plugin_name,
+ "_ger_get_entry_rights: SLAPI_ACL_MODDN %s\n", slapi_entry_get_ndn(e));
+ /* n - rename e */
+ entryrights |= SLAPI_ACL_MODDN;
+ _append_gerstr(gerstr, gerstrsize, gerstrcap, "n", NULL);
+ }
+ } else {
+ /*
+ * Some limitation/simplification applied here:
+ * - The modrdn right requires the rights to delete the old rdn and
+ * the new one. However we have no knowledge of what the new rdn
+ * is going to be.
+ * - In multi-valued RDN case, we check the right on
+ * the first rdn type only for now.
+ */
+ rdn = slapi_rdn_new_dn(slapi_entry_get_ndn(e));
+ slapi_rdn_get_first(rdn, &rdntype, &rdnvalue);
+ if (NULL != rdntype) {
+ slapi_log_error(SLAPI_LOG_ACL, plugin_name,
+ "_ger_get_entry_rights: SLAPI_ACL_WRITE_DEL & _ADD %s\n", rdntype);
+ if (acl_access_allowed(gerpb, e, rdntype, NULL,
+ ACLPB_SLAPI_ACL_WRITE_DEL) == LDAP_SUCCESS &&
+ acl_access_allowed(gerpb, e, rdntype, NULL,
+ ACLPB_SLAPI_ACL_WRITE_ADD) == LDAP_SUCCESS) {
/* n - rename e */
- entryrights |= SLAPI_ACL_MODDN;
- _append_gerstr(gerstr, gerstrsize, gerstrcap, "n", NULL);
+ entryrights |= SLAPI_ACL_WRITE;
+ _append_gerstr(gerstr, gerstrsize, gerstrcap, "n", NULL);
+ }
}
+ slapi_rdn_free(&rdn);
+ }
if ( entryrights == 0 )
{
_append_gerstr(gerstr, gerstrsize, gerstrcap, "none", NULL);
| 0 |
7cf67d15b3c96b1fad71e20036552de08527e276
|
389ds/389-ds-base
|
Fix the fact that if an operation fails in a total update, we immediately halt
|
commit 7cf67d15b3c96b1fad71e20036552de08527e276
Author: David Boreham <[email protected]>
Date: Thu Apr 28 22:50:15 2005 +0000
Fix the fact that if an operation fails in a total update, we immediately halt
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
index cb9e9c0e9..b5325b923 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -142,7 +142,6 @@ static void protocol_sleep(Private_Repl_Protocol *prp, PRIntervalTime duration);
static int send_updates(Private_Repl_Protocol *prp, RUV *ruv, PRUint32 *num_changes_sent);
static void windows_inc_backoff_expired(time_t timer_fire_time, void *arg);
static int windows_examine_update_vector(Private_Repl_Protocol *prp, RUV *ruv);
-static PRBool ignore_error_and_keep_going(int error);
static const char* state2name (int state);
static const char* event2name (int event);
static const char* acquire2name (int code);
@@ -1271,7 +1270,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
if (CONN_OPERATION_FAILED == replay_crc)
{
/* Map ldap error code to return value */
- if (!ignore_error_and_keep_going(error))
+ if (!windows_ignore_error_and_keep_going(error))
{
return_value = UPDATE_TRANSIENT_ERROR;
finished = 1;
@@ -1643,101 +1642,6 @@ windows_examine_update_vector(Private_Repl_Protocol *prp, RUV *remote_ruv)
}
-/*
- * When we get an error from an LDAP operation, we call this
- * function to decide if we should just keep replaying
- * updates, or if we should stop, back off, and try again
- * later.
- * Returns PR_TRUE if we shoould keep going, PR_FALSE if
- * we should back off and try again later.
- *
- * In general, we keep going if the return code is consistent
- * with some sort of bug in URP that causes the consumer to
- * emit an error code that it shouldn't have, e.g. LDAP_ALREADY_EXISTS.
- *
- * We stop if there's some indication that the server just completely
- * failed to process the operation, e.g. LDAP_OPERATIONS_ERROR.
- */
-static PRBool
-ignore_error_and_keep_going(int error)
-{
- int return_value;
-
- LDAPDebug( LDAP_DEBUG_TRACE, "=> ignore_error_and_keep_going\n", 0, 0, 0 );
-
- switch (error)
- {
- /* Cases where we keep going */
- case LDAP_SUCCESS:
- case LDAP_NO_SUCH_ATTRIBUTE:
- case LDAP_UNDEFINED_TYPE:
- case LDAP_CONSTRAINT_VIOLATION:
- case LDAP_TYPE_OR_VALUE_EXISTS:
- case LDAP_INVALID_SYNTAX:
- case LDAP_NO_SUCH_OBJECT:
- case LDAP_INVALID_DN_SYNTAX:
- case LDAP_IS_LEAF:
- case LDAP_INSUFFICIENT_ACCESS:
- case LDAP_NAMING_VIOLATION:
- case LDAP_OBJECT_CLASS_VIOLATION:
- case LDAP_NOT_ALLOWED_ON_NONLEAF:
- case LDAP_NOT_ALLOWED_ON_RDN:
- case LDAP_ALREADY_EXISTS:
- case LDAP_NO_OBJECT_CLASS_MODS:
- return_value = PR_TRUE;
- break;
-
- /* Cases where we stop and retry */
- case LDAP_OPERATIONS_ERROR:
- case LDAP_PROTOCOL_ERROR:
- case LDAP_TIMELIMIT_EXCEEDED:
- case LDAP_SIZELIMIT_EXCEEDED:
- case LDAP_STRONG_AUTH_NOT_SUPPORTED:
- case LDAP_STRONG_AUTH_REQUIRED:
- case LDAP_PARTIAL_RESULTS:
- case LDAP_REFERRAL:
- case LDAP_ADMINLIMIT_EXCEEDED:
- case LDAP_UNAVAILABLE_CRITICAL_EXTENSION:
- case LDAP_CONFIDENTIALITY_REQUIRED:
- case LDAP_SASL_BIND_IN_PROGRESS:
- case LDAP_INAPPROPRIATE_MATCHING:
- case LDAP_ALIAS_PROBLEM:
- case LDAP_ALIAS_DEREF_PROBLEM:
- case LDAP_INAPPROPRIATE_AUTH:
- case LDAP_INVALID_CREDENTIALS:
- case LDAP_BUSY:
- case LDAP_UNAVAILABLE:
- case LDAP_UNWILLING_TO_PERFORM:
- case LDAP_LOOP_DETECT:
- case LDAP_SORT_CONTROL_MISSING:
- case LDAP_INDEX_RANGE_ERROR:
- case LDAP_RESULTS_TOO_LARGE:
- case LDAP_AFFECTS_MULTIPLE_DSAS:
- case LDAP_OTHER:
- case LDAP_SERVER_DOWN:
- case LDAP_LOCAL_ERROR:
- case LDAP_ENCODING_ERROR:
- case LDAP_DECODING_ERROR:
- case LDAP_TIMEOUT:
- case LDAP_AUTH_UNKNOWN:
- case LDAP_FILTER_ERROR:
- case LDAP_USER_CANCELLED:
- case LDAP_PARAM_ERROR:
- case LDAP_NO_MEMORY:
- case LDAP_CONNECT_ERROR:
- case LDAP_NOT_SUPPORTED:
- case LDAP_CONTROL_NOT_FOUND:
- case LDAP_NO_RESULTS_RETURNED:
- case LDAP_MORE_RESULTS_TO_RETURN:
- case LDAP_CLIENT_LOOP:
- case LDAP_REFERRAL_LIMIT_EXCEEDED:
- return_value = PR_FALSE;
- break;
- }
- LDAPDebug( LDAP_DEBUG_TRACE, "<= ignore_error_and_keep_going\n", 0, 0, 0 );
- return return_value;
-}
-
/* this function converts an aquisition code to a string - for debug output */
static const char*
acquire2name (int code)
diff --git a/ldap/servers/plugins/replication/windows_prot_private.h b/ldap/servers/plugins/replication/windows_prot_private.h
index 772aa7920..c01e8cb09 100644
--- a/ldap/servers/plugins/replication/windows_prot_private.h
+++ b/ldap/servers/plugins/replication/windows_prot_private.h
@@ -101,4 +101,6 @@ void windows_dirsync_inc_run(Private_Repl_Protocol *prp);
ConnResult windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op);
int windows_process_total_entry(Private_Repl_Protocol *prp,Slapi_Entry *e);
+PRBool windows_ignore_error_and_keep_going(int error);
+
#endif /* _REPL5_PROT_PRIVATE_H_ */
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 8c06d1aae..b942fcb47 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -197,7 +197,7 @@ static windows_attribute_map user_attribute_map[] =
{ "streetAddress", "street", towindowsonly, always, normal},
{ "userParameters", "ntUserParms", bidirectional, always, normal},
{ "userWorkstations", "ntUserWorkstations", bidirectional, always, normal},
- { "sAMAccountName", "ntUserDomainId", bidirectional, createonly, normal},
+ { "sAMAccountName", "ntUserDomainId", bidirectional, always, normal},
/* cn is a naming attribute in AD, so we don't want to change it after entry creation */
{ "cn", "cn", towindowsonly, createonly, normal},
/* However, it isn't a naming attribute in DS (we use uid) so it's safe to accept changes inbound */
@@ -231,6 +231,101 @@ static windows_attribute_map group_attribute_map[] =
* 6. NT4 has less and different schema from AD. For example users in NT4 have no firstname/lastname, only an optional 'description'.
*/
+/*
+ * When we get an error from an LDAP operation, we call this
+ * function to decide if we should just keep replaying
+ * updates, or if we should stop, back off, and try again
+ * later.
+ * Returns PR_TRUE if we shoould keep going, PR_FALSE if
+ * we should back off and try again later.
+ *
+ * In general, we keep going if the return code is consistent
+ * with some sort of bug in URP that causes the consumer to
+ * emit an error code that it shouldn't have, e.g. LDAP_ALREADY_EXISTS.
+ *
+ * We stop if there's some indication that the server just completely
+ * failed to process the operation, e.g. LDAP_OPERATIONS_ERROR.
+ */
+PRBool
+windows_ignore_error_and_keep_going(int error)
+{
+ int return_value;
+
+ LDAPDebug( LDAP_DEBUG_TRACE, "=> windows_ignore_error_and_keep_going\n", 0, 0, 0 );
+
+ switch (error)
+ {
+ /* Cases where we keep going */
+ case LDAP_SUCCESS:
+ case LDAP_NO_SUCH_ATTRIBUTE:
+ case LDAP_UNDEFINED_TYPE:
+ case LDAP_CONSTRAINT_VIOLATION:
+ case LDAP_TYPE_OR_VALUE_EXISTS:
+ case LDAP_INVALID_SYNTAX:
+ case LDAP_NO_SUCH_OBJECT:
+ case LDAP_INVALID_DN_SYNTAX:
+ case LDAP_IS_LEAF:
+ case LDAP_INSUFFICIENT_ACCESS:
+ case LDAP_NAMING_VIOLATION:
+ case LDAP_OBJECT_CLASS_VIOLATION:
+ case LDAP_NOT_ALLOWED_ON_NONLEAF:
+ case LDAP_NOT_ALLOWED_ON_RDN:
+ case LDAP_ALREADY_EXISTS:
+ case LDAP_NO_OBJECT_CLASS_MODS:
+ return_value = PR_TRUE;
+ break;
+
+ /* Cases where we stop and retry */
+ case LDAP_OPERATIONS_ERROR:
+ case LDAP_PROTOCOL_ERROR:
+ case LDAP_TIMELIMIT_EXCEEDED:
+ case LDAP_SIZELIMIT_EXCEEDED:
+ case LDAP_STRONG_AUTH_NOT_SUPPORTED:
+ case LDAP_STRONG_AUTH_REQUIRED:
+ case LDAP_PARTIAL_RESULTS:
+ case LDAP_REFERRAL:
+ case LDAP_ADMINLIMIT_EXCEEDED:
+ case LDAP_UNAVAILABLE_CRITICAL_EXTENSION:
+ case LDAP_CONFIDENTIALITY_REQUIRED:
+ case LDAP_SASL_BIND_IN_PROGRESS:
+ case LDAP_INAPPROPRIATE_MATCHING:
+ case LDAP_ALIAS_PROBLEM:
+ case LDAP_ALIAS_DEREF_PROBLEM:
+ case LDAP_INAPPROPRIATE_AUTH:
+ case LDAP_INVALID_CREDENTIALS:
+ case LDAP_BUSY:
+ case LDAP_UNAVAILABLE:
+ case LDAP_UNWILLING_TO_PERFORM:
+ case LDAP_LOOP_DETECT:
+ case LDAP_SORT_CONTROL_MISSING:
+ case LDAP_INDEX_RANGE_ERROR:
+ case LDAP_RESULTS_TOO_LARGE:
+ case LDAP_AFFECTS_MULTIPLE_DSAS:
+ case LDAP_OTHER:
+ case LDAP_SERVER_DOWN:
+ case LDAP_LOCAL_ERROR:
+ case LDAP_ENCODING_ERROR:
+ case LDAP_DECODING_ERROR:
+ case LDAP_TIMEOUT:
+ case LDAP_AUTH_UNKNOWN:
+ case LDAP_FILTER_ERROR:
+ case LDAP_USER_CANCELLED:
+ case LDAP_PARAM_ERROR:
+ case LDAP_NO_MEMORY:
+ case LDAP_CONNECT_ERROR:
+ case LDAP_NOT_SUPPORTED:
+ case LDAP_CONTROL_NOT_FOUND:
+ case LDAP_NO_RESULTS_RETURNED:
+ case LDAP_MORE_RESULTS_TO_RETURN:
+ case LDAP_CLIENT_LOOP:
+ case LDAP_REFERRAL_LIMIT_EXCEEDED:
+ return_value = PR_FALSE;
+ break;
+ }
+ LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_ignore_error_and_keep_going\n", 0, 0, 0 );
+ return return_value;
+}
+
static const char*
op2string(int op)
{
@@ -318,7 +413,13 @@ map_dn_values(Private_Repl_Protocol *prp,Slapi_ValueSet *original_values, Slapi_
}
}
slapi_sdn_free(&remote_dn);
+ } else
+ {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: no remote dn found for %s\n", original_dn_string);
}
+ } else
+ {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: this entry is not ours %s\n", original_dn_string);
}
} else {
slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: no local entry found for %s\n", original_dn_string);
@@ -354,6 +455,9 @@ map_dn_values(Private_Repl_Protocol *prp,Slapi_ValueSet *original_values, Slapi_
{
slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: no local dn found for %s\n", original_dn_string);
}
+ } else
+ {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: this entry is not ours %s\n", original_dn_string);
}
} else
{
@@ -2316,7 +2420,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
int rc = 0;
int is_nt4 = windows_private_get_isnt4(prp->agmt);
/* Iterate over the attributes on the remote entry, updating the local entry where appropriate */
- LDAPDebug( LDAP_DEBUG_TRACE, "=> windows_update_local_entry\n", 0, 0, 0 );
+ LDAPDebug( LDAP_DEBUG_TRACE, "=> windows_generate_update_mods\n", 0, 0, 0 );
*do_modify = 0;
if (to_windows)
@@ -2379,12 +2483,14 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
/* If it is then we need to replace the local values with the remote values if they are different */
if (!values_equal)
{
+ slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name,
+ "windows_generate_update_mods: %s, %s : values are different\n", slapi_sdn_get_dn(slapi_entry_get_sdn_const(local_entry)), local_type);
slapi_mods_add_mod_values(smods,LDAP_MOD_REPLACE,local_type,valueset_get_valuearray(vs));
*do_modify = 1;
} else
{
slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name,
- "windows_update_local_entry: %s, %s : values are equal\n", slapi_sdn_get_dn(slapi_entry_get_sdn_const(local_entry)), local_type);
+ "windows_generate_update_mods: %s, %s : values are equal\n", slapi_sdn_get_dn(slapi_entry_get_sdn_const(local_entry)), local_type);
}
} else {
/* A dn-valued attribute : need to take special steps */
@@ -2418,6 +2524,8 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
{
if (!is_present_local)
{
+ slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name,
+ "windows_generate_update_mods: %s, %s : values not present on peer entry\n", slapi_sdn_get_dn(slapi_entry_get_sdn_const(local_entry)), local_type);
/* If it is currently absent, then we add the value from the remote entry */
if (is_guid)
{
@@ -2464,7 +2572,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
{
slapi_mods_dump(smods,"windows sync");
}
- LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_update_local_entry: %d\n", retval, 0, 0 );
+ LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_generate_update_mods: %d\n", retval, 0, 0 );
return retval;
}
@@ -2583,6 +2691,18 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r
if (0 == retval && remote_entry)
{
retval = windows_update_remote_entry(prp,remote_entry,e);
+ /* Detect the case where the error is benign */
+ if (retval)
+ {
+ int operation = 0;
+ int error = 0;
+
+ conn_get_error(prp->conn, &operation, &error);
+ if (windows_ignore_error_and_keep_going(error))
+ {
+ retval = CONN_OPERATION_SUCCESS;
+ }
+ }
}
if (remote_entry)
{
| 0 |
4e9aab8a172c8636ea78a9d1230c78c76268efd7
|
389ds/389-ds-base
|
Ticket 527 - ns-slapd segfaults if it cannot rename the logs
Bug Description: If we can not rename a log file, triggered by log rotation,
we try and log a message stating this error, but trying to
log this new message triggers log rotation again. This leads
to an infinite loop and a stack overflow.
Fix Description: Created a new logging function that does not do a rotation check.
We use this new function for all emergency error logging.
https://fedorahosted.org/389/ticket/527
Reviewed by: richm(Thanks!)
|
commit 4e9aab8a172c8636ea78a9d1230c78c76268efd7
Author: Mark Reynolds <[email protected]>
Date: Thu Dec 6 14:52:40 2012 -0500
Ticket 527 - ns-slapd segfaults if it cannot rename the logs
Bug Description: If we can not rename a log file, triggered by log rotation,
we try and log a message stating this error, but trying to
log this new message triggers log rotation again. This leads
to an infinite loop and a stack overflow.
Fix Description: Created a new logging function that does not do a rotation check.
We use this new function for all emergency error logging.
https://fedorahosted.org/389/ticket/527
Reviewed by: richm(Thanks!)
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index ecfdb19d7..d1c63bc41 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -138,6 +138,7 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_
static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now);
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);
static int
slapd_log_error_proc_internal(
@@ -1834,6 +1835,57 @@ slapd_log_error_proc_internal(
return( rc );
}
+/*
+ * Directly write the already formatted message to the error log
+ */
+static void
+vslapd_log_emergency_error(LOGFD fp, const char *msg, int locked)
+{
+ time_t tnl;
+ long tz;
+ struct tm *tmsp, tms;
+ char tbuf[ TBUFSIZE ];
+ char buffer[SLAPI_LOG_BUFSIZ];
+ char sign;
+ int size;
+
+ tnl = current_time();
+#ifdef _WIN32
+ {
+ struct tm *pt = localtime( &tnl );
+ tmsp = &tms;
+ memcpy(&tms, pt, sizeof(struct tm) );
+ }
+#else
+ (void)localtime_r( &tnl, &tms );
+ tmsp = &tms;
+#endif
+#ifdef BSD_TIME
+ tz = tmsp->tm_gmtoff;
+#else /* BSD_TIME */
+ tz = - timezone;
+ if ( tmsp->tm_isdst ) {
+ tz += 3600;
+ }
+#endif /* BSD_TIME */
+ sign = ( tz >= 0 ? '+' : '-' );
+ if ( tz < 0 ) {
+ tz = -tz;
+ }
+ (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
+ sprintf( buffer, "[%s %c%02d%02d] - %s", tbuf, sign, (int)( tz / 3600 ), (int)( tz % 3600 ), msg);
+ size = strlen(buffer);
+
+ if(!locked)
+ LOG_ERROR_LOCK_WRITE();
+
+ slapi_write_buffer((fp), (buffer), (size));
+ PR_Sync(fp);
+
+ if(!locked)
+ LOG_ERROR_UNLOCK_WRITE();
+}
+
static int
vslapd_log_error(
LOGFD fp,
@@ -3102,9 +3154,6 @@ char rootpath[4];
PR_snprintf(buffer, sizeof(buffer),
"log__enough_freespace: Unable to get the free space (errno:%d)\n",
errno);
- /* This function could be called in the ERROR WRITE LOCK,
- * which causes the self deadlock if you call LDAPDebug for logging.
- * Thus, instead of LDAPDebug, call log__error_emergency with locked == 1. */
log__error_emergency(buffer, 0, 1);
return 1;
} else {
@@ -3351,9 +3400,6 @@ delete_logfile:
PR_snprintf (buffer, sizeof(buffer), "%s.%s", loginfo.log_error_file, tbuf);
if (PR_Delete(buffer) != PR_SUCCESS) {
PRErrorCode prerr = PR_GetError();
- /* This function could be called in the ERROR WRITE LOCK,
- * which causes the self deadlock if you call LDAPDebug for logging.
- * Thus, instead of LDAPDebug, call log__error_emergency with locked == 1. */
PR_snprintf(buffer, sizeof(buffer),
"LOGINFO:Unable to remove file:%s.%s error %d (%s)\n",
loginfo.log_error_file, tbuf, prerr, slapd_pr_strerror(prerr));
@@ -3713,10 +3759,7 @@ log__error_emergency(const char *errstr, int reopen, int locked)
PRErrorCode prerr = PR_GetError();
syslog(LOG_ERR, "Failed to reopen errors log file, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n", prerr, slapd_pr_strerror(prerr));
} else {
- /* LDAPDebug locks ERROR_LOCK_WRITE internally */
- if (locked) LOG_ERROR_UNLOCK_WRITE();
- LDAPDebug(LDAP_DEBUG_ANY, "%s\n", errstr, 0, 0);
- if (locked) LOG_ERROR_LOCK_WRITE( );
+ vslapd_log_emergency_error(loginfo.log_error_fdes, errstr, locked);
}
return;
}
| 0 |
810fa917626372674763a4a3f07a2235a1442bd5
|
389ds/389-ds-base
|
Issue 5225 - UI - impossible to manually set entry cache
Bug description: The UI thinks cache auto-tuning is always set which
prevents the user from manaully setting the entry cache.
Fix Description: The UI was comparing a value to an array, which always
returned false and kept the UI thinking autotunning was set.
relates: https://github.com/389ds/389-ds-base/issues/5225
Reviewed by: spichugi(Thanks!)
|
commit 810fa917626372674763a4a3f07a2235a1442bd5
Author: Mark Reynolds <[email protected]>
Date: Tue Mar 22 10:07:10 2022 -0400
Issue 5225 - UI - impossible to manually set entry cache
Bug description: The UI thinks cache auto-tuning is always set which
prevents the user from manaully setting the entry cache.
Fix Description: The UI was comparing a value to an array, which always
returned false and kept the UI thinking autotunning was set.
relates: https://github.com/389ds/389-ds-base/issues/5225
Reviewed by: spichugi(Thanks!)
diff --git a/src/cockpit/389-console/package-lock.json b/src/cockpit/389-console/package-lock.json
index 0ab2a3596..19c9d7a82 100644
--- a/src/cockpit/389-console/package-lock.json
+++ b/src/cockpit/389-console/package-lock.json
@@ -5591,9 +5591,9 @@
}
},
"node_modules/minimist": {
- "version": "1.2.5",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
- "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
+ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
"dev": true
},
"node_modules/ms": {
@@ -12594,9 +12594,9 @@
}
},
"minimist": {
- "version": "1.2.5",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
- "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
+ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
"dev": true
},
"ms": {
diff --git a/src/cockpit/389-console/src/database.jsx b/src/cockpit/389-console/src/database.jsx
index 6f0a59c60..07e679e0a 100644
--- a/src/cockpit/389-console/src/database.jsx
+++ b/src/cockpit/389-console/src/database.jsx
@@ -115,7 +115,6 @@ export class Database extends React.Component {
this.closeSuffixModal = this.closeSuffixModal.bind(this);
this.createSuffix = this.createSuffix.bind(this);
this.loadSuffix = this.loadSuffix.bind(this);
- this.loadSuffixConfig = this.loadSuffixConfig.bind(this);
this.loadIndexes = this.loadIndexes.bind(this);
this.loadVLV = this.loadVLV.bind(this);
this.loadAttrEncrypt = this.loadAttrEncrypt.bind(this);
@@ -765,7 +764,7 @@ export class Database extends React.Component {
.done(content => {
const config = JSON.parse(content);
if ('nsslapd-cache-autosize' in config.attrs &&
- config.attrs['nsslapd-cache-autosize'] !== "0") {
+ config.attrs['nsslapd-cache-autosize'][0] !== "0") {
this.setState({
[suffix]: {
...this.state[suffix],
@@ -776,47 +775,6 @@ export class Database extends React.Component {
});
}
- loadSuffixConfig(suffix) {
- const cmd = [
- "dsconf", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
- "backend", "suffix", "get", suffix
- ];
- log_cmd("loadSuffixConfig", "Load suffix config", cmd);
- cockpit
- .spawn(cmd, { superuser: true, err: "message" })
- .done(content => {
- const config = JSON.parse(content);
- let refs = [];
- let readonly = false;
- let requireindex = false;
- if ('nsslapd-referral' in config.attrs) {
- refs = config.attrs['nsslapd-referral'];
- }
- if ('nsslapd-readonly' in config.attrs) {
- if (config.attrs['nsslapd-readonly'] === "on") {
- readonly = true;
- }
- }
- if ('nsslapd-require-index' in config.attrs) {
- if (config.attrs['nsslapd-require-index'] === "on") {
- requireindex = true;
- }
- }
- this.setState({
- [suffix]: {
- ...this.state[suffix],
- refRows: refs,
- cachememsize: config.attrs['nsslapd-cachememsize'][0],
- cachesize: config.attrs['nsslapd-cachesize'][0],
- dncachememsize: config.attrs['nsslapd-dncachememsize'][0],
- dbstate: config.attrs['nsslapd-state'][0],
- readOnly: readonly,
- requireIndex: requireindex,
- }
- }, this.getAutoTuning(suffix));
- });
- }
-
loadVLV(suffix) {
const cmd = [
"dsconf", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
@@ -963,12 +921,12 @@ export class Database extends React.Component {
refs = config.attrs['nsslapd-referral'];
}
if ('nsslapd-readonly' in config.attrs) {
- if (config.attrs['nsslapd-readonly'] === "on") {
+ if (config.attrs['nsslapd-readonly'][0] === "on") {
readonly = true;
}
}
if ('nsslapd-require-index' in config.attrs) {
- if (config.attrs['nsslapd-require-index'] === "on") {
+ if (config.attrs['nsslapd-require-index'][0] === "on") {
requireindex = true;
}
}
| 0 |
a0f8e0f981a046882db299a7a6d6d1c01bc19571
|
389ds/389-ds-base
|
Ticket #48226 - In MMR, double free coould occur under some special condition
Bug description:
In a replicated topology, a authenticated user that have write access
on an entry can send a series of operations that crash the server.
The crash is due to an access to a already freed buffer.
Fix description:
To avoid the double free, duplicate a CSNSet and assign it to the
Slapi_Value.
https://fedorahosted.org/389/ticket/48226
Reviewed by [email protected] (Thank you, Rich!!)
|
commit a0f8e0f981a046882db299a7a6d6d1c01bc19571
Author: Noriko Hosoi <[email protected]>
Date: Thu Jul 16 10:34:47 2015 -0700
Ticket #48226 - In MMR, double free coould occur under some special condition
Bug description:
In a replicated topology, a authenticated user that have write access
on an entry can send a series of operations that crash the server.
The crash is due to an access to a already freed buffer.
Fix description:
To avoid the double free, duplicate a CSNSet and assign it to the
Slapi_Value.
https://fedorahosted.org/389/ticket/48226
Reviewed by [email protected] (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 0cf3ded86..7eabb828c 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -1415,8 +1415,9 @@ valueset_update_csn_for_valuearray_ext(Slapi_ValueSet *vs, const Slapi_Attr *a,
if(v)
{
value_update_csn(v,t,csn);
- if (csnref_updated)
- valuestoupdate[i]->v_csnset = (CSNSet *)value_get_csnset(v);
+ if (csnref_updated) {
+ valuestoupdate[i]->v_csnset = csnset_dup(value_get_csnset(v));
+ }
valuearrayfast_add_value_passin(&vaf_valuesupdated,valuestoupdate[i]);
valuestoupdate[i]= NULL;
del_count++;
| 0 |
b7255ce84d5dbe3f5109bd009ebf334bbad55265
|
389ds/389-ds-base
|
Issue:50860 - Port Password Policy test cases from TET to python3 bug624080
Bug Description: Port Password Policy test cases from TET to python3 bug624080
Relates: https://pagure.io/389-ds-base/issue/50690
Author: aborah
Reviewed by: Viktor Ashirov
|
commit b7255ce84d5dbe3f5109bd009ebf334bbad55265
Author: Anuj Borah <[email protected]>
Date: Mon Feb 3 15:35:33 2020 +0530
Issue:50860 - Port Password Policy test cases from TET to python3 bug624080
Bug Description: Port Password Policy test cases from TET to python3 bug624080
Relates: https://pagure.io/389-ds-base/issue/50690
Author: aborah
Reviewed by: Viktor Ashirov
diff --git a/dirsrvtests/tests/suites/password/pwdPolicy_warning_test.py b/dirsrvtests/tests/suites/password/pwdPolicy_warning_test.py
index b4a21b880..0dca5f593 100644
--- a/dirsrvtests/tests/suites/password/pwdPolicy_warning_test.py
+++ b/dirsrvtests/tests/suites/password/pwdPolicy_warning_test.py
@@ -17,6 +17,7 @@ from lib389.idm.organizationalunit import OrganizationalUnits
from lib389._constants import (DEFAULT_SUFFIX, DN_CONFIG, PASSWORD, DN_DM,
HOST_STANDALONE, PORT_STANDALONE, SERVERID_STANDALONE)
from dateutil.parser import parse as dt_parse
+from lib389.config import Config
import datetime
pytestmark = pytest.mark.tier1
@@ -547,6 +548,50 @@ def test_search_shadowWarning_when_passwordWarning_is_lower(topology_st, global_
assert testuser.present('shadowWarning')
[email protected]
+def test_password_expire_works(topology_st):
+ """Regression test for bug624080. If passwordMaxAge is set to a
+ value and a new user is added, if the passwordMaxAge is changed
+ to a shorter expiration time and the new users password
+ is then changed ..... the passwordExpirationTime for the
+ new user should be changed too. There was a bug in DS 6.2
+ where the expirationtime remained unchanged.
+
+ :id: 1ead6052-4636-11ea-b5af-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Set the Global password policy and a passwordMaxAge to 5 days
+ 2. Add the new user
+ 3. Check the users password expiration time now
+ 4. Decrease global passwordMaxAge to 2 days
+ 5. Modify the users password
+ 6. Modify the user one more time to make sur etime has been reset
+ 7. turn off the password policy
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ """
+ config = Config(topology_st.standalone)
+ config.replace_many(('passwordMaxAge', '432000'),
+ ('passwordExp', 'on'))
+ user = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX, rdn=None).create_test_user()
+ user.set('userPassword', 'anuj')
+ expire_time = user.get_attr_val_utf8('passwordExpirationTime')
+ config.replace('passwordMaxAge', '172800')
+ user.set('userPassword', 'borah')
+ expire_time2 = user.get_attr_val_utf8('passwordExpirationTime')
+ config.replace('passwordMaxAge', '604800')
+ user.set('userPassword', 'anujagaiin')
+ expire_time3 = user.get_attr_val_utf8('passwordExpirationTime')
+ assert expire_time != expire_time2 != expire_time3
+ config.replace('passwordExp', 'off')
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
| 0 |
0584156ba21823c138f91a68b9a0715fd81f82f7
|
389ds/389-ds-base
|
Ticket #48254 - Shell CLI fails with usage errors if an argument containing white spaces is given
Description: In addition to the patch:
Ticket #48254 - CLI db2index fails with usage errors
commit 3507c46c9f1156df11b6cf05eba695d81088b416
applying the similar changes to all the shell CLI which could be given
arguments that include white spaces.
https://fedorahosted.org/389/ticket/48254
Reviewed by [email protected] (Thank you, Mark!!)
(cherry picked from commit 5fe28921810a53dcd31525ba1f675582b6aba0f7)
|
commit 0584156ba21823c138f91a68b9a0715fd81f82f7
Author: Noriko Hosoi <[email protected]>
Date: Tue Aug 25 11:48:31 2015 -0700
Ticket #48254 - Shell CLI fails with usage errors if an argument containing white spaces is given
Description: In addition to the patch:
Ticket #48254 - CLI db2index fails with usage errors
commit 3507c46c9f1156df11b6cf05eba695d81088b416
applying the similar changes to all the shell CLI which could be given
arguments that include white spaces.
https://fedorahosted.org/389/ticket/48254
Reviewed by [email protected] (Thank you, Mark!!)
(cherry picked from commit 5fe28921810a53dcd31525ba1f675582b6aba0f7)
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index a2e54cc60..ab7c6b3ec 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -44,12 +44,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
q) args=$args" -q";;
- d) args=$args" -d $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
v) args=$args" -v";;
- D) args=$args" -D $OPTARG";;
- i) args=$args" -i $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
a) archivedir=$OPTARG;;
S) args=$args" -S";;
?) usage
@@ -76,4 +76,4 @@ else
archivedir=`pwd`/$archivedir
fi
-@sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
+eval @sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index 1896c197a..adbe30bf6 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -43,10 +43,10 @@ do
q) args=$args" -q";;
v) args=$args" -v";;
S) args=$args" -S";;
- D) args=$args" -D $OPTARG";;
- i) args=$args" -i $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
a) $bakdir=$OPTARG;;
- d) args=$args" -d $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
Z) servid=$OPTARG;;
?) usage
exit 1;;
@@ -72,4 +72,4 @@ then
fi
echo "Back up directory: $bak_dir"
-@sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
+eval @sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 6a0785ecf..c8e90759d 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -35,15 +35,15 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG"
+ n) args=$args" -n \"$OPTARG\""
benameopt="set";;
- s) args=$args" -s $OPTARG"
+ s) args=$args" -s \"$OPTARG\""
includeSuffix="set";;
t) args=$args" -t "\"$OPTARG\";;
T) args=$args" -T "\"$OPTARG\";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG";;
- x) args=$args" -x $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
v) args=$args" -v";;
S) args=$args" -S";;
D) args=$args" -D $OPTARG";;
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index fcf73a089..e9f7f7e8a 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -106,12 +106,12 @@ do
Z) servid=$OPTARG;;
n) benameopt="-n $OPTARG"
required_param="yes";;
- s) includeSuffix="-s $OPTARG"
+ s) includeSuffix="-s \"$OPTARG\""
required_param="yes";;
- x) excludeSuffix="-x $OPTARG";;
- a) outputFile="-a $OPTARG";;
- d) args=$args" -d $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ x) excludeSuffix="-x \"$OPTARG\"";;
+ a) outputFile="-a \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
N) args=$args" -N";;
E) args=$args" -E";;
S) args=$args" -S";;
@@ -154,7 +154,7 @@ rn=$?
echo "Exported ldif file: $ldif_file"
if [ $rn -eq 1 ]
then
- @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
+ eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
else
- @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
+ eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
fi
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index bbacc17f1..b98e9b2c3 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -33,14 +33,14 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
- d) args=$args" -d $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
V) args=$args" -V";;
v) args=$args" -v"
display_version="yes";;
f) args=$args" -f";;
- D) args=$args" -D $OPTARG";;
- a) args=$args" -a $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -57,7 +57,7 @@ fi
. $initfile
-@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
if [ $display_version = "yes" ]; then
exit 0
fi
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 616969acd..762e63a4c 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -27,12 +27,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- d) arg=$arg" -d $OPTARG";;
- a) arg=$arg" -a $OPTARG"
+ d) arg=$arg" -d \"$OPTARG\"";;
+ a) arg=$arg" -a \"$OPTARG\""
archive="provided";;
v) arg=$arg" -v";;
f) arg=$arg" -f";;
- D) arg=$arg" -D $OPTARG";;
+ D) arg=$arg" -D \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -55,4 +55,4 @@ if [ "$archive" != "provided" ]; then
args=$args"-a $bak_dir"
fi
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index a34241afd..3aed4697e 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -59,16 +59,16 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
- i) args=$args" -i $OPTARG";;
- s) args=$args" -s $OPTARG";;
- x) args=$args" -x $OPTARG";;
- c) args=$args" -c $OPTARG";;
- d) args=$args" -d $OPTARG";;
- g) args=$args" -g $OPTARG";;
- G) args=$args" -G $OPTARG";;
- t) args=$args" -t $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
+ s) args=$args" -s \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
+ c) args=$args" -c \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ g) args=$args" -g \"$OPTARG\"";;
+ G) args=$args" -G \"$OPTARG\"";;
+ t) args=$args" -t \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
E) args=$args" -E";;
v) args=$args" -v";;
N) args=$args" -N";;
@@ -104,6 +104,6 @@ if [ $quiet -eq 0 ]; then
echo importing data ...
fi
-@sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
+eval @sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
exit $?
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index 36a2fc9b0..e9265a126 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -73,8 +73,8 @@ fi
rm $file
if [ -n "$passwd" ]; then
- dn="-D $rootdn"
- passwd="-w$passwd"
+ dn="-D \"$rootdn\""
+ passwd="-w \"$passwd\""
fi
if [ -n "$ldapiURL" ]
then
@@ -109,9 +109,9 @@ if [ "$security" = "on" ]; then
echo "Using the next most secure protocol(STARTTLS)"
fi
if [ "$openldap" = "yes" ]; then
- ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ eval ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
- ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ eval ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index 7774148e2..d7c666104 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -24,7 +24,7 @@ while getopts "Z:s:h" flag
do
case $flag in
Z) servid=$OPTARG;;
- s) args=$args" -s $OPTARG";;
+ s) args=$args" -s \"$OPTARG\"";;
h) usage
exit 0;;
?) usage
@@ -55,4 +55,4 @@ then
exit 1
fi
-@sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
+eval @sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index bf600dd63..2b7c79daf 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -29,10 +29,10 @@ do
v) args=$args" -v";;
f) args=$args" -f";;
r) args=$args" -r";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG"
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\""
archive_provided="yes";;
- D) args=$args" -D $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
h) usage
exit 0;;
esac
@@ -56,4 +56,4 @@ then
fi
echo upgrade index files ...
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 51585aef8..9de60eaec 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -36,14 +36,14 @@ do
Z) servid=$OPTARG;;
v) args=$args" -v";;
N) args=$args" -N";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG"
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\""
dir="set";;
- n) args=$args" -n $OPTARG"
+ n) args=$args" -n \"$OPTARG\""
be="set";;
h) usage
exit 0;;
- D) args=$args" -D $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -65,7 +65,7 @@ fi
. $initfile
-@sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
rc=$?
exit $rc
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index 365e32fc8..a1696bc0f 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -29,14 +29,14 @@ do
case $flag in
Z) servid=$OPTARG;;
v) args=$args" -v";;
- s) args=$args" -s $OPTARG";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG";;
- T) args=$args" -T $OPTARG";;
+ s) args=$args" -s \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
+ T) args=$args" -T \"$OPTARG\"";;
S) args=$args" -S";;
- n) args=$args" -n $OPTARG";;
- x) args=$args" -x $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
h) usage
exit 0;;
?) usage
@@ -61,4 +61,4 @@ then
exit 1
fi
-@sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
| 0 |
30ae2d70e1ae5d5139afc6e74b0e44ee08cbe0b3
|
389ds/389-ds-base
|
Issue 50669 - Fix RPM build
Bug Description:
rpm build fails due to missing libnunc-stans.so:
```
RPM build errors:
File not found: /workspace/ds/rpmbuild/BUILDROOT/389-ds-base-1.4.2.2-20191025git44e92dc8b.fc30.x86_64/usr/lib64/dirsrv/libnunc-stans.so.*
make: *** [rpm.mk:115: rpms] Error 1
```
Fix Description:
Update 389-ds-base.spec file
Relates: https://pagure.io/389-ds-base/issue/50669
|
commit 30ae2d70e1ae5d5139afc6e74b0e44ee08cbe0b3
Author: Viktor Ashirov <[email protected]>
Date: Fri Oct 25 21:55:14 2019 +0200
Issue 50669 - Fix RPM build
Bug Description:
rpm build fails due to missing libnunc-stans.so:
```
RPM build errors:
File not found: /workspace/ds/rpmbuild/BUILDROOT/389-ds-base-1.4.2.2-20191025git44e92dc8b.fc30.x86_64/usr/lib64/dirsrv/libnunc-stans.so.*
make: *** [rpm.mk:115: rpms] Error 1
```
Fix Description:
Update 389-ds-base.spec file
Relates: https://pagure.io/389-ds-base/issue/50669
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index c73c554a1..48ef43d47 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -688,13 +688,11 @@ exit 0
%{_libdir}/libsvrcore.so
%{_libdir}/%{pkgname}/libslapd.so
%{_libdir}/%{pkgname}/libns-dshttpd.so
-%{_libdir}/%{pkgname}/libnunc-stans.so
%{_libdir}/%{pkgname}/libsds.so
%{_libdir}/%{pkgname}/libldaputil.so
%{_libdir}/pkgconfig/svrcore.pc
%{_libdir}/pkgconfig/dirsrv.pc
%{_libdir}/pkgconfig/libsds.pc
-%{_libdir}/pkgconfig/nunc-stans.pc
%files libs
%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.devel
@@ -702,7 +700,6 @@ exit 0
%{_libdir}/libsvrcore.so.*
%{_libdir}/%{pkgname}/libslapd.so.*
%{_libdir}/%{pkgname}/libns-dshttpd-*.so
-%{_libdir}/%{pkgname}/libnunc-stans.so.*
%{_libdir}/%{pkgname}/libsds.so.*
%{_libdir}/%{pkgname}/libldaputil.so.*
%if %{bundle_jemalloc}
| 0 |
6949bf2301e9f2fc5c64f6f9f60f7c24c0f7f68e
|
389ds/389-ds-base
|
Resolves: 240240
Summary: Fixed linker problems when linking with ldap c sdk.
|
commit 6949bf2301e9f2fc5c64f6f9f60f7c24c0f7f68e
Author: Nathan Kinder <[email protected]>
Date: Tue May 15 23:36:10 2007 +0000
Resolves: 240240
Summary: Fixed linker problems when linking with ldap c sdk.
diff --git a/Makefile.am b/Makefile.am
index a4d87e8a3..57fc66b38 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -264,7 +264,7 @@ libds_admin_la_SOURCES = ldap/admin/lib/dsalib_conf.c \
ldap/admin/lib/dsalib_util.c
libds_admin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@
-libds_admin_la_LIBADD = $(LDAPSDK_LINK) $(NSS_LINK) $(NSPR_LINK)
+libds_admin_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK)
#------------------------
# libns-dshttpd
@@ -417,7 +417,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \
$(libavl_a_SOURCES)
libslapd_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) @db_inc@ @svrcore_inc@
-libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK)
+libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK)
#////////////////////////////////////////////////////////////////
diff --git a/Makefile.in b/Makefile.in
index 9bc1ee330..c85fcc52c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -239,7 +239,8 @@ am_libdna_plugin_la_OBJECTS = \
libdna_plugin_la_OBJECTS = $(am_libdna_plugin_la_OBJECTS)
@enable_dna_TRUE@am_libdna_plugin_la_rpath = -rpath $(serverplugindir)
libds_admin_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
am_libds_admin_la_OBJECTS = \
ldap/admin/lib/libds_admin_la-dsalib_conf.lo \
ldap/admin/lib/libds_admin_la-dsalib_confs.lo \
@@ -431,7 +432,8 @@ am_libroles_plugin_la_OBJECTS = \
ldap/servers/plugins/roles/libroles_plugin_la-roles_plugin.lo
libroles_plugin_la_OBJECTS = $(am_libroles_plugin_la_OBJECTS)
libslapd_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
am__objects_2 = ldap/libraries/libavl/libslapd_la-avl.lo
am_libslapd_la_OBJECTS = ldap/servers/slapd/libslapd_la-add.lo \
ldap/servers/slapd/libslapd_la-agtmmap.lo \
@@ -1169,7 +1171,7 @@ libds_admin_la_SOURCES = ldap/admin/lib/dsalib_conf.c \
ldap/admin/lib/dsalib_util.c
libds_admin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@
-libds_admin_la_LIBADD = $(LDAPSDK_LINK) $(NSS_LINK) $(NSPR_LINK)
+libds_admin_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK)
#------------------------
# libns-dshttpd
@@ -1322,7 +1324,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \
$(libavl_a_SOURCES)
libslapd_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) @db_inc@ @svrcore_inc@
-libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK)
+libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK)
#////////////////////////////////////////////////////////////////
#
| 0 |
d95c07b1dd8e2ddb289ab627c425be1f9feda4eb
|
389ds/389-ds-base
|
Bump version to 1.3.7
|
commit d95c07b1dd8e2ddb289ab627c425be1f9feda4eb
Author: Mark Reynolds <[email protected]>
Date: Wed Apr 26 10:57:10 2017 -0400
Bump version to 1.3.7
diff --git a/VERSION.sh b/VERSION.sh
index fc5be48d2..68fee9268 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
# PACKAGE_VERSION is constructed from these
VERSION_MAJOR=1
VERSION_MINOR=3
-VERSION_MAINT=6.4
+VERSION_MAINT=7.0
# NOTE: VERSION_PREREL is automatically set for builds made out of a git tree
VERSION_PREREL=
VERSION_DATE=$(date -u +%Y%m%d)
| 0 |
83094c3b59b51a3720c7b2f005be101ea473d150
|
389ds/389-ds-base
|
Issue 4781 - There are some typos in man-pages
Description: Fixed the following man-page typo.
- dbscan(1)
- ldclt(1)
- rsearch(1)
- 99user.ldif(5)
- dirsrv.systemd(5)
relates: https://github.com/389ds/389-ds-base/issues/4781
|
commit 83094c3b59b51a3720c7b2f005be101ea473d150
Author: MIZUTA Takeshi <[email protected]>
Date: Tue May 25 23:58:12 2021 +0900
Issue 4781 - There are some typos in man-pages
Description: Fixed the following man-page typo.
- dbscan(1)
- ldclt(1)
- rsearch(1)
- 99user.ldif(5)
- dirsrv.systemd(5)
relates: https://github.com/389ds/389-ds-base/issues/4781
diff --git a/man/man1/dbscan.1 b/man/man1/dbscan.1
index a5418e790..810608371 100644
--- a/man/man1/dbscan.1
+++ b/man/man1/dbscan.1
@@ -61,7 +61,7 @@ only display index entries with more than <n> ids
display ID list lengths
.TP
.B \fB\-r\fR
-display the conents of ID list
+display the contents of ID list
.TP
.B \fB\-s\fR
Summary of index counts
diff --git a/man/man1/ldclt.1 b/man/man1/ldclt.1
index af6b8561a..f02fb50ba 100644
--- a/man/man1/ldclt.1
+++ b/man/man1/ldclt.1
@@ -17,7 +17,7 @@
.\" for manpage-specific macros, see man(7)
.SH NAME
ldclt \- load test program for LDAP
-.SH SYNOPSYS
+.SH SYNOPSIS
.B ldclt
[\fI\-qQvV\fR] [\fI\-E <max errors>\fR]
[\fI\-b <base DN>\fR] [\fI\-h <host>\fR] [\fI\-p <port>\fR] [\fI\-t <timeout>\fR]
diff --git a/man/man1/rsearch.1 b/man/man1/rsearch.1
index a6b46fffd..1cb073180 100644
--- a/man/man1/rsearch.1
+++ b/man/man1/rsearch.1
@@ -67,16 +67,16 @@ quiet
logging
.TP
.B \fB\-m\fR
-operaton: modify non\-indexed attr (description). \fB\-B\fR required
+operation: modify non\-indexed attr (description). \fB\-B\fR required
.TP
.B \fB\-M\fR
-operaton: modify indexed attr (telephonenumber). \fB\-B\fR required
+operation: modify indexed attr (telephonenumber). \fB\-B\fR required
.TP
.B \fB\-d\fR
-operaton: delete. \fB\-B\fR required
+operation: delete. \fB\-B\fR required
.TP
.B \fB\-c\fR
-operaton: compare. \fB\-B\fR required
+operation: compare. \fB\-B\fR required
.TP
.B \fB\-i\fR file
name file; used for the search filter
diff --git a/man/man5/99user.ldif.5 b/man/man5/99user.ldif.5
index da414a023..ec18e61a8 100644
--- a/man/man5/99user.ldif.5
+++ b/man/man5/99user.ldif.5
@@ -43,7 +43,7 @@ attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN
'user-defined' )
.br
objectClasses: ( 1.1.1.1.1.1.1.2 NAME 'myNewObjectcass' DESC 'Custom defined
-objectclass' SUP top MUST ( myNewAttrbiute ) MAY ( uid $ cn ) X-ORIGIN 'user-defined' )
+objectclass' SUP top MUST ( myNewAttribute ) MAY ( uid $ cn ) X-ORIGIN 'user-defined' )
.SH AUTHOR
99user.ldif was written by the 389 Project.
diff --git a/man/man5/dirsrv.systemd.5 b/man/man5/dirsrv.systemd.5
index cad251a43..791931a48 100644
--- a/man/man5/dirsrv.systemd.5
+++ b/man/man5/dirsrv.systemd.5
@@ -25,10 +25,10 @@
dirsrv.systemd
This controls the resources to the direct child of systemd, in
-this case ns-slapd. Because we are type notify we recieve these
+this case ns-slapd. Because we are type notify we receive these
limits correctly.
-For more inforation see man systemd.exec and man systemd.resource-control
+For more information see man systemd.exec and man systemd.resource-control
.SH AUTHOR
dirsrv.systemd was written by the 389 Project.
| 0 |
df52b510dd78ee931194d315fa9deb2c95effb4e
|
389ds/389-ds-base
|
Issue: 50860 - Port Password Policy test cases from TET to python3 pwp.sh
Bug Description: Port Password Policy test cases from TET to python3 pwp.sh
Relates: https://pagure.io/389-ds-base/issue/50690
Author: aborah
Reviewed by: Viktor Ashirov
|
commit df52b510dd78ee931194d315fa9deb2c95effb4e
Author: Anuj Borah <[email protected]>
Date: Tue Mar 3 09:40:56 2020 +0530
Issue: 50860 - Port Password Policy test cases from TET to python3 pwp.sh
Bug Description: Port Password Policy test cases from TET to python3 pwp.sh
Relates: https://pagure.io/389-ds-base/issue/50690
Author: aborah
Reviewed by: Viktor Ashirov
diff --git a/dirsrvtests/tests/suites/password/pwp_test.py b/dirsrvtests/tests/suites/password/pwp_test.py
new file mode 100644
index 000000000..cc29f6fe7
--- /dev/null
+++ b/dirsrvtests/tests/suites/password/pwp_test.py
@@ -0,0 +1,511 @@
+"""
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2020 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+"""
+
+import os
+import pytest
+from lib389.topologies import topology_st as topo
+from lib389.idm.user import UserAccounts, UserAccount
+from lib389._constants import DEFAULT_SUFFIX
+from lib389.config import Config
+from lib389.idm.group import Group
+import ldap
+import time
+
+pytestmark = pytest.mark.tier1
+
+
+def _create_user(topo, uid, cn, uidNumber, userpassword):
+ """
+ Will Create user
+ """
+ user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create(properties={
+ 'uid': uid,
+ 'sn': cn.split(' ')[-1],
+ 'cn': cn,
+ 'givenname': cn.split(' ')[0],
+ 'uidNumber': uidNumber,
+ 'gidNumber': uidNumber,
+ 'mail': f'{uid}@example.com',
+ 'userpassword': userpassword,
+ 'homeDirectory': f'/home/{uid}'
+ })
+ return user
+
+
+def _change_password_with_own(topo, user_dn, password, new_password):
+ """
+ Change user password with user self
+ """
+ conn = UserAccount(topo.standalone, user_dn).bind(password)
+ real_user = UserAccount(conn, user_dn)
+ real_user.replace('userpassword', new_password)
+
+
+def _change_password_with_root(topo, user_dn, new_password):
+ """
+ Root will change user password
+ """
+ UserAccount(topo.standalone, user_dn).replace('userpassword', new_password)
+
+
[email protected](scope="function")
+def _fix_password(topo, request):
+ user = _create_user(topo, 'dbyers', 'Danny Byers', '1001', 'dbyers1')
+ user.replace('userpassword', 'dbyers1')
+
+ def fin():
+ user.delete()
+ request.addfinalizer(fin)
+
+
+def test_passwordchange_to_no(topo, _fix_password):
+ """Change password fo a user even password even though pw policy is set to no
+
+ :id: 16c64ef0-5a20-11ea-a902-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Adding an user with uid=dbyers
+ 2. Set Password change to Must Not Change After Reset
+ 3. Setting Password policy to May Not Change Password
+ 4. Try to change password fo a user even password even though pw policy is set to no
+ 5. Set Password change to May Change Password
+ 6. Try to change password fo a user even password
+ 7. Try to change password with invalid credentials. Should see error message.
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ """
+ # Adding an user with uid=dbyers
+ user = f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}'
+ config = Config(topo.standalone)
+ # Set Password change to Must Not Change After Reset
+ config.replace_many(
+ ('passwordmustchange', 'off'),
+ ('passwordchange', 'off'))
+ # Try to change password fo a user even password even though pw policy is set to no
+ with pytest.raises(ldap.UNWILLING_TO_PERFORM):
+ _change_password_with_own(topo, user, 'dbyers1', 'AB')
+ # Set Password change to May Change Password
+ config.replace('passwordchange', 'on')
+ _change_password_with_own(topo, user, 'dbyers1', 'dbyers1')
+ # Try to change password with invalid credentials. Should see error message.
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'AB', 'dbyers1')
+
+
+def test_password_check_syntax(topo, _fix_password):
+ """Password check syntax
+
+ :id: 1e6fcc9e-5a20-11ea-9659-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Sets Password check syntax to on
+ 2. Try to change to a password that violates length. Should get error
+ 3. Attempt to Modify password to db which is in error to policy
+ 4. change min pw length to 5
+ 5. Attempt to Modify password to dby3rs which is in error to policy
+ 6. Attempt to Modify password to danny which is in error to policy
+ 7. Attempt to Modify password to byers which is in error to policy
+ 8. Change min pw length to 6
+ 9. Try to change the password
+ 10. Trying to set to a password containing value of sn
+ 11. Sets policy to not check pw syntax
+ 12. Test that when checking syntax is off, you can use small passwords
+ 13. Test that when checking syntax is off, trivial passwords can be used
+ 14. Changing password minimum length from 6 to 10
+ 15. Setting policy to Check Password Syntax again
+ 16. Try to change to a password that violates length
+ 17. Reset Password
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ 8. Success
+ 9. Success
+ 10. Success
+ 11. Success
+ 12. Success
+ 13. Success
+ 14. Success
+ 15. Success
+ 16. Fail
+ 17. Success
+ """
+ config = Config(topo.standalone)
+ # Sets Password check syntax to on
+ config.replace('passwordchecksyntax', 'on')
+ # Try to change to a password that violates length. Should get error
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers2')
+ # Attempt to Modify password to db which is in error to policy
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'db')
+ # change min pw length to 5
+ config.replace('passwordminlength', '5')
+ # Attempt to Modify password to dby3rs which is in error to policy
+ # Attempt to Modify password to danny which is in error to policy
+ # Attempt to Modify password to byers which is in error to policy
+ for password in ['dbyers', 'Danny', 'byers']:
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', password)
+ # Change min pw length to 6
+ config.replace('passwordminlength', '6')
+ # Try to change the password
+ # Trying to set to a password containing value of sn
+ for password in ['dby3rs1', 'dbyers2', '67Danny89', 'YAByers8']:
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', password)
+ # Sets policy to not check pw syntax
+ # Test that when checking syntax is off, you can use small passwords
+ # Test that when checking syntax is off, trivial passwords can be used
+ config.replace('passwordchecksyntax', 'off')
+ for password, new_pass in [('dbyers1', 'db'), ('db', 'dbyers'), ('dbyers', 'dbyers1')]:
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', password, new_pass)
+ # Changing password minimum length from 6 to 10
+ # Setting policy to Check Password Syntax again
+ config.replace_many(
+ ('passwordminlength', '10'),
+ ('passwordchecksyntax', 'on'))
+ # Try to change to a password that violates length
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'db')
+ UserAccount(topo.standalone, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}').replace('userpassword', 'dbyers1')
+
+
+def test_too_big_password(topo, _fix_password):
+ """Test for long long password
+
+ :id: 299a3fb4-5a20-11ea-bba8-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Setting policy to keep password histories
+ 2. Changing number of password in history to 3
+ 3. Modify password from dby3rs1 to dby3rs2
+ 4. Checking that the passwordhistory attribute has been added
+ 5. Add a password test for long long password
+ 6. Changing number of password in history to 6 and passwordhistory off
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ """
+ config = Config(topo.standalone)
+ # Setting policy to keep password histories
+ config.replace_many(
+ ('passwordchecksyntax', 'off'),
+ ('passwordhistory', 'on'))
+ assert config.get_attr_val_utf8('passwordinhistory') == '6'
+ # Changing number of password in history to 3
+ config.replace('passwordinhistory', '3')
+ # Modify password from dby3rs1 to dby3rs2
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers2')
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', 'dbyers1')
+ # Checking that the passwordhistory attribute has been added
+ assert UserAccount(topo.standalone, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}').get_attr_val_utf8('passwordhistory')
+ # Add a password test for long long password
+ long_pass = 50*'0123456789'+'LENGTH=510'
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', long_pass)
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', long_pass, long_pass)
+ _change_password_with_root(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1')
+ # Changing number of password in history to 6 and passwordhistory off
+ config.replace_many(('passwordhistory', 'off'),
+ ('passwordinhistory', '6'))
+
+
+def test_pwminage(topo, _fix_password):
+ """Test pwminage
+
+ :id: 2df7bf32-5a20-11ea-ad23-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Get pwminage; should be 0 currently
+ 2. Sets policy to pwminage 3
+ 3. Change current password
+ 4. Try to change password again
+ 5. Try now after 3 secs is up, should work.
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Fail
+ 5. Success
+ """
+ config = Config(topo.standalone)
+ # Get pwminage; should be 0 currently
+ assert config.get_attr_val_utf8('passwordminage') == '0'
+ # Sets policy to pwminage 3
+ config.replace('passwordminage', '3')
+ # Change current password
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers2')
+ # Try to change password again
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', 'dbyers1')
+ for _ in range(3):
+ time.sleep(1)
+ # Try now after 3 secs is up, should work.
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', 'dbyers1')
+ config.replace('passwordminage', '0')
+
+
+def test_invalid_credentials(topo, _fix_password):
+ """Test bind again with valid password: We should be locked
+
+ :id: 3233ca78-5a20-11ea-8d35-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Search if passwordlockout is off
+ 2. Turns on passwordlockout
+ 3. sets lockout duration to 3 seconds
+ 4. Changing pw failure count reset duration to 3 sec and passwordminlength to 10
+ 5. Try to bind with invalid credentials
+ 6. Change password to password lockout forever
+ 7. Try to bind with invalid credentials
+ 8. Now bind again with valid password: We should be locked
+ 9. Delete dby3rs before exiting
+ 10. Reset server
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Fail
+ 6. Success
+ 7. Success
+ 8. Success
+ 9. Success
+ 10. Success
+ """
+ config = Config(topo.standalone)
+ # Search if passwordlockout is off
+ assert config.get_attr_val_utf8('passwordlockout') == 'off'
+ # Turns on passwordlockout
+ # sets lockout duration to 3 seconds
+ # Changing pw failure count reset duration to 3 sec and passwordminlength to 10
+ config.replace_many(
+ ('passwordlockout', 'on'),
+ ('passwordlockoutduration', '3'),
+ ('passwordresetfailurecount', '3'),
+ ('passwordminlength', '10'))
+ # Try to bind with invalid credentials
+ for _ in range(3):
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
+ for _ in range(3):
+ time.sleep(1)
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers1')
+ # Change password to password lockout forever
+ config.replace('passwordunlock', 'off')
+ # Try to bind with invalid credentials
+ for _ in range(3):
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
+ for _ in range(3):
+ time.sleep(1)
+ # Now bind again with valid password: We should be locked
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers1')
+ # Delete dby3rs before exiting
+ _change_password_with_root(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1')
+ time.sleep(1)
+ _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers1')
+ # Reset server
+ config.replace_many(
+ ('passwordinhistory', '6'),
+ ('passwordlockout', 'off'),
+ ('passwordlockoutduration', '3600'),
+ ('passwordminlength', '6'),
+ ('passwordresetfailurecount', '600'),
+ ('passwordunlock', 'on'))
+
+
+def test_expiration_date(topo, _fix_password):
+ """Test check the expiration date is still in the future
+
+ :id: 3691739a-5a20-11ea-8712-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Password expiration
+ 2. Add a user with a password expiration date
+ 3. Modify their password
+ 4. Check the expiration date is still in the future
+ 5. Modify the password expiration date
+ 6. Check the expiration date is still in the future
+ 7. Change policy so that user can change passwords
+ 8. Deleting user
+ 9. Adding user
+ 10. Set password history ON
+ 11. Modify password Once
+ 12. Try to change the password with same one
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ 8. Success
+ 9. Success
+ 10. Success
+ 11. Success
+ 12. Fail
+ """
+ # Add a user with a password expiration date
+ user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()
+ user.replace_many(
+ ('userpassword', 'bind4now'),
+ ('passwordExpirationTime', '20380119031404Z'))
+ # Modify their password
+ user.replace('userPassword', 'secreter')
+ # Check the expiration date is still in the future
+ assert user.get_attr_val_utf8('passwordExpirationTime') == '20380119031404Z'
+ # Modify the password expiration date
+ user.replace('passwordExpirationTime', '20380119031405Z')
+ # Check the expiration date is still in the future
+ assert user.get_attr_val_utf8('passwordExpirationTime') == '20380119031405Z'
+ config = Config(topo.standalone)
+ # Change policy so that user can change passwords
+ config.replace('passwordchange', 'on')
+ # Deleting user
+ UserAccount(topo.standalone, f'uid=test_user_1000,ou=People,{DEFAULT_SUFFIX}').delete()
+ # Adding user
+ user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()
+ # Set password history ON
+ config.replace('passwordhistory', 'on')
+ # Modify password Once
+ user.replace('userPassword', 'secreter')
+ time.sleep(1)
+ assert 'PBKDF2_SHA256' in user.get_attr_val_utf8('userPassword')
+ # Try to change the password with same one
+ for _ in range(3):
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, user.dn, 'secreter', 'secreter')
+ user.delete()
+
+
+def test_passwordlockout(topo, _fix_password):
+ """Test adding admin user diradmin to Directory Administrator group
+
+ :id: 3ffcffda-5a20-11ea-a3af-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Account Lockout must be cleared on successful password change
+ 2. Adding admin user diradmin
+ 3. Adding admin user diradmin to Directory Administrator group
+ 4. Turn on passwordlockout
+ 5. Sets lockout duration to 30 seconds
+ 6. Sets failure count reset duration to 30 sec
+ 7. Sets max password bind failure count to 3
+ 8. Reset password retry count (to 0)
+ 9. Try to bind with invalid credentials(3 times)
+ 10. Try to bind with valid pw, should give lockout error
+ 11. Reset password using admin login
+ 12. Try to login as the user to check the unlocking of account. Will also change
+ the password back to original
+ 13. Change to account lockout forever until reset
+ 14. Reset password retry count (to 0)
+ 15. Try to bind with invalid credentials(3 times)
+ 16. Try to bind with valid pw, should give lockout error
+ 17. Reset password using admin login
+ 18. Try to login as the user to check the unlocking of account. Will also change the
+ password back to original
+ :expected results:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ 8. Success
+ 9. Fail
+ 10. Success
+ 11. Success
+ 12. Success
+ 13. Success
+ 14. Success
+ 15. Fail
+ 16. Success
+ 17. Success
+ 18. Success
+ """
+ config = Config(topo.standalone)
+ # Adding admin user diradmin
+ user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()
+ user.replace('userpassword', 'dby3rs2')
+ admin = _create_user(topo, 'diradmin', 'Anuj Borah', '1002', 'diradmin')
+ # Adding admin user diradmin to Directory Administrator group
+ Group(topo.standalone, f'cn=Directory Administrators,{DEFAULT_SUFFIX}').add('uniquemember', admin.dn)
+ # Turn on passwordlockout
+ # Sets lockout duration to 30 seconds
+ # Sets failure count reset duration to 30 sec
+ # Sets max password bind failure count to 3
+ # Reset password retry count (to 0)
+ config.replace_many(
+ ('passwordlockout', 'on'),
+ ('passwordlockoutduration', '30'),
+ ('passwordresetfailurecount', '30'),
+ ('passwordmaxfailure', '3'),
+ ('passwordhistory', 'off'))
+ user.replace('passwordretrycount', '0')
+ # Try to bind with invalid credentials(3 times)
+ for _ in range(3):
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
+ # Try to bind with valid pw, should give lockout error
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
+ # Reset password using admin login
+ conn = admin.bind('diradmin')
+ UserAccount(conn, user.dn).replace('userpassword', 'dby3rs2')
+ time.sleep(1)
+ # Try to login as the user to check the unlocking of account. Will also change
+ # the password back to original
+ _change_password_with_own(topo, user.dn, 'dby3rs2', 'secreter')
+ # Change to account lockout forever until reset
+ # Reset password retry count (to 0)
+ config.replace('passwordunlock', 'off')
+ user.replace('passwordretrycount', '0')
+ # Try to bind with invalid credentials(3 times)
+ for _ in range(3):
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
+ # Try to bind with valid pw, should give lockout error
+ with pytest.raises(ldap.CONSTRAINT_VIOLATION):
+ _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
+ # Reset password using admin login
+ UserAccount(conn, user.dn).replace('userpassword', 'dby3rs2')
+ time.sleep(1)
+ # Try to login as the user to check the unlocking of account. Will also change the
+ # password back to original
+ _change_password_with_own(topo, user.dn, 'dby3rs2', 'secreter')
+
+
+if __name__ == "__main__":
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
\ No newline at end of file
| 0 |
6e839e9cc2acb957dc3435ee46aa9d2942cf1bcc
|
389ds/389-ds-base
|
Bug 566320 - RFE: add exception to removal of attributes in cn=config for aci
https://bugzilla.redhat.com/show_bug.cgi?id=566320
Resolves: bug 566320
Bug description: RFE: add exception to removal of attributes in cn=config for aci
Fix description: The modify_config_dse() has been modified to
check the ignore_attr_type() for all types of modify operation.
Reviewed by: rmeggins (and pushed by)
|
commit 6e839e9cc2acb957dc3435ee46aa9d2942cf1bcc
Author: Endi S. Dewata <[email protected]>
Date: Mon Mar 22 17:53:33 2010 -0500
Bug 566320 - RFE: add exception to removal of attributes in cn=config for aci
https://bugzilla.redhat.com/show_bug.cgi?id=566320
Resolves: bug 566320
Bug description: RFE: add exception to removal of attributes in cn=config for aci
Fix description: The modify_config_dse() has been modified to
check the ignore_attr_type() for all types of modify operation.
Reviewed by: rmeggins (and pushed by)
diff --git a/ldap/servers/slapd/configdse.c b/ldap/servers/slapd/configdse.c
index 317c78dba..91b858004 100644
--- a/ldap/servers/slapd/configdse.c
+++ b/ldap/servers/slapd/configdse.c
@@ -391,17 +391,17 @@ modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, in
for ( apply_mods = 0; apply_mods <= 1; apply_mods++ ) {
int i = 0;
for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++) {
+ /* send all aci modifications to the backend */
+ config_attr = (char *)mods[i]->mod_type;
+ if (ignore_attr_type(config_attr))
+ continue;
+
if ((mods[i]->mod_op & LDAP_MOD_DELETE) ||
(mods[i]->mod_op & LDAP_MOD_ADD)) {
rc= LDAP_UNWILLING_TO_PERFORM;
PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "%s attributes is not allowed",
(mods[i]->mod_op & LDAP_MOD_DELETE) ? "Deleting" : "Adding");
} else if (mods[i]->mod_op & LDAP_MOD_REPLACE) {
- /* send all aci modifications to the backend */
- config_attr = (char *)mods[i]->mod_type;
- if (ignore_attr_type(config_attr))
- continue;
-
if ( (checked_all_maxdiskspace_and_mlogsize == 0 ) &&
((strcasecmp( mods[i]->mod_type, CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE) == 0) ||
(strcasecmp( mods[i]->mod_type, CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE) == 0) ||
| 0 |
22a2c2352e4f3659113973310c9e31d0896f5b63
|
389ds/389-ds-base
|
Issue 5752 - RFE - Provide a history for LastLoginTime (#5807)
Bug Description: For the lastloginhistory feature the user
can set the number of login histories that are saved by
modifing the lastloginhistorysize attribute. The CLI currently
allows setting this attribute value to 0 or a non positive int.
Fix Description: Add support for a lastloginhistorysize of 0 which
would disable the feature. Add CLI support for restricting non
positive int values.
relates: https://github.com/389ds/389-ds-base/issues/5752
Reviewed by: @droideck @mreynolds389 (Thank you)
|
commit 22a2c2352e4f3659113973310c9e31d0896f5b63
Author: James Chapman <[email protected]>
Date: Mon Jul 10 14:39:35 2023 +0000
Issue 5752 - RFE - Provide a history for LastLoginTime (#5807)
Bug Description: For the lastloginhistory feature the user
can set the number of login histories that are saved by
modifing the lastloginhistorysize attribute. The CLI currently
allows setting this attribute value to 0 or a non positive int.
Fix Description: Add support for a lastloginhistorysize of 0 which
would disable the feature. Add CLI support for restricting non
positive int values.
relates: https://github.com/389ds/389-ds-base/issues/5752
Reviewed by: @droideck @mreynolds389 (Thank you)
diff --git a/dirsrvtests/tests/suites/plugins/accpol_test.py b/dirsrvtests/tests/suites/plugins/accpol_test.py
index f4b578739..964d98ee0 100644
--- a/dirsrvtests/tests/suites/plugins/accpol_test.py
+++ b/dirsrvtests/tests/suites/plugins/accpol_test.py
@@ -497,7 +497,7 @@ def test_login_history_valid_values(topology_st, setup_test_user, setup_account_
inst = topology_st[0]
user = setup_test_user
- ap_configs = setup_account_policy_plugin
+ ap_config = setup_account_policy_plugin
# Bind as test user more times than lastLoginHistorySize
user_binds(user, USER_PW, LOGIN_HIST_NUM_BINDS_SEVEN)
@@ -505,12 +505,7 @@ def test_login_history_valid_values(topology_st, setup_test_user, setup_account_
# Verify lastLoginTimeHistory attribute returns the correct number of entries in chronological order
verify_last_login_entries(inst, USER_DN, LOGIN_HIST_SIZE_FIVE)
- # Reduce the lastLoginHistorySize to LOGIN_HIST_SIZE_TWO
- try:
- ap_config = ap_configs.create(properties={'cn': 'config', 'lastLoginHistorySize': str(LOGIN_HIST_SIZE_TWO)})
- except ldap.ALREADY_EXISTS:
- ap_config = ap_configs.get('config')
- ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_TWO))
+ ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_TWO))
# Bind as test user more times than lastLoginHistorySize
user_binds(user, USER_PW, LOGIN_HIST_NUM_BINDS_SEVEN)
@@ -519,11 +514,7 @@ def test_login_history_valid_values(topology_st, setup_test_user, setup_account_
verify_last_login_entries(inst, USER_DN, LOGIN_HIST_SIZE_TWO)
# Increase the lastLoginHistorySize to LOGIN_HIST_SIZE_FIVE
- try:
- ap_config = ap_configs.create(properties={'cn': 'config', 'lastLoginHistorySize': str(LOGIN_HIST_SIZE_FIVE)})
- except ldap.ALREADY_EXISTS:
- ap_config = ap_configs.get('config')
- ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_FIVE))
+ ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_FIVE))
# Bind as test user more times than lastLoginHistorySize
user_binds(user, USER_PW, LOGIN_HIST_NUM_BINDS_SEVEN)
@@ -555,14 +546,10 @@ def test_lastlogin_history_size_zero(topology_st, setup_test_user, setup_account
inst = topology_st[0]
user = setup_test_user
- ap_configs = setup_account_policy_plugin
+ ap_config = setup_account_policy_plugin
# Set lastLoginHistorySize to 0
- try:
- ap_configs.create(properties={'cn': 'config', 'lastLoginHistorySize': str(LOGIN_HIST_SIZE_ZERO)})
- except ldap.ALREADY_EXISTS:
- ap_config = ap_configs.get('config')
- ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_ZERO))
+ ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_ZERO))
# Bind as test user more times than lastLoginHistorySize
user_binds(user, USER_PW, LOGIN_HIST_NUM_BINDS_THREE)
@@ -580,19 +567,19 @@ def test_lastlogin_history_size_negative(topology_st, setup_account_policy_plugi
:steps:
1. Try to set the lastLoginHistorySize to a negative number.
:expectedresults:
- 1. An ldap.INVALID_SYNTAX error is raised.
+ 1. A warning messge has been written to the error logs.
"""
LOGIN_HIST_SIZE_NEGATIVE = -1
- ap_configs = setup_account_policy_plugin
+ AC_POL_CFG_DN = "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config"
- with pytest.raises(ldap.INVALID_SYNTAX):
- # Try to set lastLoginHistorySize to negative
- try:
- ap_configs.create(properties={'cn': 'config', 'lastLoginHistorySize': str(LOGIN_HIST_SIZE_NEGATIVE)})
- except ldap.ALREADY_EXISTS:
- ap_config = ap_configs.get('config')
- ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_NEGATIVE))
+ inst = topology_st[0]
+ ap_config = setup_account_policy_plugin
+
+ # Try to set lastLoginHistorySize to negative
+ ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_NEGATIVE))
+
+ assert inst.searchErrorsLog("Invalid value for login-history-size: -1")
def test_lastlogin_history_size_non_integer(topology_st, setup_account_policy_plugin):
@@ -608,15 +595,11 @@ def test_lastlogin_history_size_non_integer(topology_st, setup_account_policy_pl
"""
LOGIN_HIST_SIZE_NON_INTEGER = 'five'
- ap_configs = setup_account_policy_plugin
+ ap_config = setup_account_policy_plugin
+ # Try to set lastLoginHistorySize to a non-integer
with pytest.raises(ldap.INVALID_SYNTAX):
- # Try to set lastLoginHistorySize to a non-integer
- try:
- ap_configs.create(properties={'cn': 'config', 'lastLoginHistorySize': str(LOGIN_HIST_SIZE_NON_INTEGER)})
- except ldap.ALREADY_EXISTS:
- ap_config = ap_configs.get('config')
- ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_NON_INTEGER))
+ ap_config.replace('lastLoginHistorySize', str(LOGIN_HIST_SIZE_NON_INTEGER))
def test_glact_login(topology_st, accpol_global):
diff --git a/ldap/schema/60acctpolicy.ldif b/ldap/schema/60acctpolicy.ldif
index 8267d7588..a47c8aa97 100644
--- a/ldap/schema/60acctpolicy.ldif
+++ b/ldap/schema/60acctpolicy.ldif
@@ -19,6 +19,13 @@
# Schema for the account policy plugin
#
dn: cn=schema
+## lastLoginHistorySize determines the number of login histories to store
+##
+attributeTypes: ( 2.16.840.1.113730.3.1.2397 NAME 'lastLoginHistorySize'
+ DESC 'Number of entries to store in last login history'
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
+ SINGLE-VALUE
+ X-ORIGIN '389 Directory Server' )
##
## lastLoginHistory holds successful logins in an entry (GeneralizedTime syntax)
attributeTypes: ( 2.16.840.1.113730.3.1.2394 NAME 'lastLoginHistory'
diff --git a/ldap/servers/plugins/acctpolicy/acct_config.c b/ldap/servers/plugins/acctpolicy/acct_config.c
index 4325d11f6..cf5d4cf09 100644
--- a/ldap/servers/plugins/acctpolicy/acct_config.c
+++ b/ldap/servers/plugins/acctpolicy/acct_config.c
@@ -74,6 +74,7 @@ static int
acct_policy_entry2config(Slapi_Entry *e, acctPluginCfg *newcfg)
{
char *config_val;
+ int value = 0;
int rc = 0;
if (newcfg == NULL) {
@@ -150,10 +151,24 @@ acct_policy_entry2config(Slapi_Entry *e, acctPluginCfg *newcfg)
slapi_ch_free_string(&config_val);
if (newcfg->always_record_login) {
- char *hist_size = NULL;
- newcfg->login_history_attr = slapi_ch_strdup(LASTLOGIN_HISTORY_ATTR);
- if (has_attr(e, LASTLOGIN_HISTORY_SIZE_ATTR, &hist_size)) {
- newcfg->login_history_size = atoi(hist_size);
+ char *hist_size_str = NULL;
+ newcfg->login_history_attr = get_attr_string_val(e, LASTLOGIN_HISTORY_ATTR);
+ if (newcfg->login_history_attr == NULL) {
+ newcfg->login_history_attr = slapi_ch_strdup(LASTLOGIN_HISTORY_ATTR);
+ }
+ if (has_attr(e, LASTLOGIN_HISTORY_SIZE_ATTR, &hist_size_str)) {
+ if (hist_size_str) {
+ value = strtoul(hist_size_str, 0, 0);
+ if (value >= 0) {
+ newcfg->login_history_size = value;
+ } else {
+ slapi_log_err(SLAPI_LOG_WARNING, PLUGIN_NAME,
+ "acct_policy_entry2config - Invalid value for login-history-size: %d, "
+ "Using default value of %d\n", value, DEFAULT_LASTLOGIN_HISTORY_SIZE);
+ newcfg->login_history_size = DEFAULT_LASTLOGIN_HISTORY_SIZE;
+ }
+ slapi_ch_free_string(&hist_size_str);
+ }
} else {
newcfg->login_history_size = DEFAULT_LASTLOGIN_HISTORY_SIZE;
}
diff --git a/ldap/servers/plugins/acctpolicy/acct_plugin.c b/ldap/servers/plugins/acctpolicy/acct_plugin.c
index 8d60e6f60..83a42786c 100644
--- a/ldap/servers/plugins/acctpolicy/acct_plugin.c
+++ b/ldap/servers/plugins/acctpolicy/acct_plugin.c
@@ -220,34 +220,38 @@ acct_update_login_history(const char *dn, char *timestr)
config_rd_lock();
cfg = get_config();
- /* get login history */
- login_hist = slapi_entry_attr_get_charray_ext(e, cfg->login_history_attr, &num_entries);
- /* first time round */
- if (!login_hist || !num_entries) {
- login_hist = (char **)slapi_ch_calloc(2, sizeof(char *));
- }
+ /* history size of zero disables login history */
+ if (cfg->login_history_size) {
+ /* get login history */
+ login_hist = slapi_entry_attr_get_charray_ext(e, cfg->login_history_attr, &num_entries);
- /* Do we need to resize login_hist array */
- if (num_entries >= cfg->login_history_size) {
- int diff = (num_entries - cfg->login_history_size);
- /* free times we dont need */
- for (i = 0; i <= diff; i++) {
- slapi_ch_free_string(&login_hist[i]);
+ /* first time round */
+ if (!login_hist || !num_entries) {
+ login_hist = (char **)slapi_ch_calloc(2, sizeof(char *));
}
- /* remap array*/
- for (i = 0; i < (cfg->login_history_size - 1); i++) {
- login_hist[i] = login_hist[(diff + 1) + i];
+
+ /* Do we need to resize login_hist array */
+ if (num_entries >= cfg->login_history_size) {
+ int diff = (num_entries - cfg->login_history_size);
+ /* free times we dont need */
+ for (i = 0; i <= diff; i++) {
+ slapi_ch_free_string(&login_hist[i]);
+ }
+ /* remap array*/
+ for (i = 0; i < (cfg->login_history_size - 1); i++) {
+ login_hist[i] = login_hist[(diff + 1) + i];
+ }
+ /* expand array and add current time string at the end */
+ login_hist = (char **)slapi_ch_realloc((char *)login_hist, sizeof(char *) * (cfg->login_history_size + 1));
+ login_hist[i] = slapi_ch_smprintf("%s", timestr);
+ login_hist[i + 1] = NULL;
+ } else {
+ /* expand array and add current time string at the end */
+ login_hist = (char **)slapi_ch_realloc((char *)login_hist, sizeof(char *) * (num_entries + 2));
+ login_hist[num_entries] = slapi_ch_smprintf("%s", timestr);
+ login_hist[num_entries + 1] = NULL;
}
- /* expand array and add current time string at the end */
- login_hist = (char **)slapi_ch_realloc((char *)login_hist, sizeof(char *) * (cfg->login_history_size + 1));
- login_hist[i] = slapi_ch_smprintf("%s", timestr);
- login_hist[i + 1] = NULL;
- } else {
- /* expand array and add current time string at the end */
- login_hist = (char **)slapi_ch_realloc((char *)login_hist, sizeof(char *) * (num_entries + 2));
- login_hist[num_entries] = slapi_ch_smprintf("%s", timestr);
- login_hist[num_entries + 1] = NULL;
}
/* modify the attribute */
| 0 |
e49b10c286ecde1d31a094a82bb223a120ae656c
|
389ds/389-ds-base
|
Bug 619122 - fix coverify Defect Type: Resource leaks issues CID 11975 - 12053
https://bugzilla.redhat.com/show_bug.cgi?id=619122
Resolves: bug 619122
Bug description: fix coverify Defect Type: Resource leaks issues CID 12006.
description: The dna_parse_config_entry() has been modified to release value properly.
|
commit e49b10c286ecde1d31a094a82bb223a120ae656c
Author: Endi S. Dewata <[email protected]>
Date: Thu Jul 29 17:14:20 2010 -0500
Bug 619122 - fix coverify Defect Type: Resource leaks issues CID 11975 - 12053
https://bugzilla.redhat.com/show_bug.cgi?id=619122
Resolves: bug 619122
Bug description: fix coverify Defect Type: Resource leaks issues CID 12006.
description: The dna_parse_config_entry() has been modified to release value properly.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 2261318e0..6fc222a5f 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -740,6 +740,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
* attribute type. We require this since we internally
* perform a sorted range search on what we assume to
* be an INTEGER syntax. */
+ slapi_ch_free_string(&value);
}
slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
| 0 |
67233f5c6adb47fce4093f63bdf3dec30f336af6
|
389ds/389-ds-base
|
Ticket 631 - Replication: "Incremental update started" status message without consumer initialized
Bug Description: If you just setup repl agmts, without initializing, the status message makes it appear
that replication is running successfully when in fact it has not "really" started.
Then for the status attributes: nsds5replicaLastUpdateStart & nsds5replicaLastUpdateEnd,
these do not appear to report the expected results - as no updates have actually been sent.
Currently these just report when the protocol wakes up & stops, it has nothing to do with
sending updates.
Fix Description: If we determine that the remote replica is not initialized, or might need to be
initialized, then update the status accordingly. As for the start and end update
times, I changed it to record the actual start/end time from send_updates(). Previously
it just recorded when the protocol started up and stopped. This was not useful, and
often misunderstood.
https://fedorahosted.org/389/ticket/631
Reviewed by: richm & noriko(Thanks!!)
|
commit 67233f5c6adb47fce4093f63bdf3dec30f336af6
Author: Mark Reynolds <[email protected]>
Date: Tue Apr 2 11:12:52 2013 -0400
Ticket 631 - Replication: "Incremental update started" status message without consumer initialized
Bug Description: If you just setup repl agmts, without initializing, the status message makes it appear
that replication is running successfully when in fact it has not "really" started.
Then for the status attributes: nsds5replicaLastUpdateStart & nsds5replicaLastUpdateEnd,
these do not appear to report the expected results - as no updates have actually been sent.
Currently these just report when the protocol wakes up & stops, it has nothing to do with
sending updates.
Fix Description: If we determine that the remote replica is not initialized, or might need to be
initialized, then update the status accordingly. As for the start and end update
times, I changed it to record the actual start/end time from send_updates(). Previously
it just recorded when the protocol started up and stopped. This was not useful, and
often misunderstood.
https://fedorahosted.org/389/ticket/631
Reviewed by: richm & noriko(Thanks!!)
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
index 222bb9750..72d2d6ce7 100644
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
@@ -618,26 +618,24 @@ set_pause_and_busy_time(Private_Repl_Protocol *prp, long *pausetime, long *busyw
static void
repl5_inc_run(Private_Repl_Protocol *prp)
{
- int current_state = STATE_START;
- int next_state = STATE_START;
repl5_inc_private *prp_priv = (repl5_inc_private *)prp->private;
- int done;
- int e1;
- RUV *ruv = NULL;
- CSN *cons_schema_csn;
Replica *replica = NULL;
- int wait_change_timer_set = 0;
- time_t last_start_time;
+ CSN *cons_schema_csn;
+ RUV *ruv = NULL;
PRUint32 num_changes_sent;
/* use a different backoff timer strategy for ACQUIRE_REPLICA_BUSY errors */
PRBool use_busy_backoff_timer = PR_FALSE;
- long pausetime = 0;
+ time_t next_fire_time;
+ time_t now;
long busywaittime = 0;
+ long pausetime = 0;
long loops = 0;
+ int wait_change_timer_set = 0;
+ int current_state = STATE_START;
+ int next_state = STATE_START;
int optype, ldaprc;
- time_t next_fire_time;
- time_t now;
-
+ int done;
+ int e1;
prp->stopped = 0;
prp->terminate = 0;
@@ -807,7 +805,7 @@ repl5_inc_run(Private_Repl_Protocol *prp)
int optype, ldaprc;
conn_get_error(prp->conn, &optype, &ldaprc);
agmt_set_last_update_status(prp->agmt, ldaprc,
- prp->last_acquire_response_code, NULL);
+ prp->last_acquire_response_code, "Unable to acquire replica");
}
object_release(prp->replica_object);
@@ -896,7 +894,7 @@ repl5_inc_run(Private_Repl_Protocol *prp)
}
if (rc != ACQUIRE_SUCCESS){
conn_get_error(prp->conn, &optype, &ldaprc);
- agmt_set_last_update_status(prp->agmt, ldaprc, prp->last_acquire_response_code, NULL);
+ agmt_set_last_update_status(prp->agmt, ldaprc, prp->last_acquire_response_code, "Unable to acquire replica");
}
/*
* We either need to step the backoff timer, or
@@ -943,10 +941,7 @@ repl5_inc_run(Private_Repl_Protocol *prp)
case STATE_SENDING_UPDATES:
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES)");
- agmt_set_update_in_progress(prp->agmt, PR_TRUE);
num_changes_sent = 0;
- last_start_time = current_time();
- agmt_set_last_update_start(prp->agmt, last_start_time);
/*
* We've acquired the replica, and are ready to send any needed updates.
*/
@@ -1001,6 +996,7 @@ repl5_inc_run(Private_Repl_Protocol *prp)
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Replica has no update vector. It has never been initialized.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, rc, "Replica is not initialized");
next_state = STATE_BACKOFF_START;
break;
case EXAMINE_RUV_GENERATION_MISMATCH:
@@ -1008,6 +1004,8 @@ repl5_inc_run(Private_Repl_Protocol *prp)
"%s: The remote replica has a different database generation ID than "
"the local database. You may have to reinitialize the remote replica, "
"or the local replica.\n", agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, rc, "Replica has different database "
+ "generation ID, remote replica may need to be initialized");
next_state = STATE_BACKOFF_START;
break;
case EXAMINE_RUV_REPLICA_TOO_OLD:
@@ -1015,6 +1013,7 @@ repl5_inc_run(Private_Repl_Protocol *prp)
"%s: Replica update vector is too out of date to bring "
"into sync using the incremental protocol. The replica "
"must be reinitialized.\n", agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, rc, "Replica needs to be reinitialized");
next_state = STATE_BACKOFF_START;
break;
case EXAMINE_RUV_OK:
@@ -1036,6 +1035,15 @@ repl5_inc_run(Private_Repl_Protocol *prp)
agmt_get_long_name(prp->agmt));
next_state = STATE_STOP_FATAL_ERROR;
} else {
+ /*
+ * Reset our update times and status
+ */
+ agmt_set_last_update_start(prp->agmt, current_time());
+ agmt_set_last_update_end(prp->agmt, 0);
+ agmt_set_update_in_progress(prp->agmt, PR_TRUE);
+ /*
+ * Send the updates
+ */
rc = send_updates(prp, ruv, &num_changes_sent);
if (rc == UPDATE_NO_MORE_UPDATES){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_NO_MORE_UPDATES -> STATE_WAIT_CHANGES");
@@ -1047,6 +1055,7 @@ repl5_inc_run(Private_Repl_Protocol *prp)
next_state = STATE_BACKOFF_START;
} else if (rc == UPDATE_TRANSIENT_ERROR){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_TRANSIENT_ERROR -> STATE_BACKOFF_START");
+ agmt_set_last_update_status(prp->agmt, 0, rc, "Incremental update transient error. Backing off, will retry update later.");
next_state = STATE_BACKOFF_START;
} else if (rc == UPDATE_FATAL_ERROR){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_FATAL_ERROR -> STATE_STOP_FATAL_ERROR");
@@ -1063,21 +1072,29 @@ repl5_inc_run(Private_Repl_Protocol *prp)
conn_disconnect (prp->conn);
} else if (rc == UPDATE_CONNECTION_LOST){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_CONNECTION_LOST -> STATE_BACKOFF_START");
+ agmt_set_last_update_status(prp->agmt, 0, rc, "Incremental update connection error. Backing off, will retry update later.");
next_state = STATE_BACKOFF_START;
} else if (rc == UPDATE_TIMEOUT){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_TIMEOUT -> STATE_BACKOFF_START");
+ agmt_set_last_update_status(prp->agmt, 0, rc, "Incremental update timeout error. Backing off, will retry update later.");
next_state = STATE_BACKOFF_START;
}
+ /* Set the updates times based off the result of send_updates() */
+ if(rc == UPDATE_NO_MORE_UPDATES){
+ /* update successful, set the end time */
+ agmt_set_last_update_end(prp->agmt, current_time());
+ } else {
+ /* Failed to send updates, reset the start time to zero */
+ agmt_set_last_update_start(prp->agmt, 0);
+ }
+ agmt_set_update_in_progress(prp->agmt, PR_FALSE);
}
- last_start_time = 0UL;
break;
}
if (NULL != ruv){
ruv_destroy(&ruv); ruv = NULL;
}
- agmt_set_last_update_end(prp->agmt, current_time());
- agmt_set_update_in_progress(prp->agmt, PR_FALSE);
agmt_update_done(prp->agmt, 0);
/* If timed out, close the connection after released the replica */
release_replica(prp);
| 0 |
e2abffcc5cf6e63136fc0bcb5b0e12830cca22a5
|
389ds/389-ds-base
|
Ticket #48304 - ns-slapd - LOGINFO:Unable to remove file
Description: In the log rotation, if a log file to be deleted does
not exist, the "Unable to remove file" is logged in the error log,
which is not necessary.
This patch updates the logging code to suppress the unnecessary log
messages as well as replace with more detailed ones.
https://fedorahosted.org/389/ticket/48304
Reviewed by [email protected] (Thank you, Mark!!)
|
commit e2abffcc5cf6e63136fc0bcb5b0e12830cca22a5
Author: Noriko Hosoi <[email protected]>
Date: Thu Oct 8 10:30:07 2015 -0700
Ticket #48304 - ns-slapd - LOGINFO:Unable to remove file
Description: In the log rotation, if a log file to be deleted does
not exist, the "Unable to remove file" is logged in the error log,
which is not necessary.
This patch updates the logging code to suppress the unnecessary log
messages as well as replace with more detailed ones.
https://fedorahosted.org/389/ticket/48304
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 1458e5478..2ec90de6d 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -2330,15 +2330,25 @@ log__delete_access_logfile()
loginfo.log_access_fdes = NULL;
PR_snprintf (buffer, sizeof(buffer), "%s", loginfo.log_access_file);
if (PR_Delete(buffer) != PR_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s\n", loginfo.log_access_file,0,0);
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_access_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s error %d (%s)\n",
+ loginfo.log_access_file, prerr, slapd_pr_strerror(prerr));
+ }
}
/* Delete the rotation file also. */
PR_snprintf (buffer, sizeof(buffer), "%s.rotationinfo", loginfo.log_access_file);
if (PR_Delete(buffer) != PR_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s.rotationinfo\n", loginfo.log_access_file,0,0);
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_access_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s.rotationinfo error %d (%s)\n",
+ loginfo.log_access_file, prerr, slapd_pr_strerror(prerr));
+ }
}
return 0;
}
@@ -2440,15 +2450,15 @@ delete_logfile:
log_convert_time (delete_logp->l_ctime, tbuf, 1 /*short */);
PR_snprintf (buffer, sizeof(buffer), "%s.%s", loginfo.log_access_file, tbuf);
if (PR_Delete(buffer) != PR_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s.%s\n",
- loginfo.log_access_file,tbuf,0);
-
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_access_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s.%s error %d (%s)\n",
+ loginfo.log_access_file, tbuf, prerr, slapd_pr_strerror(prerr));
+ }
} else {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Removed file:%s.%s because of (%s)\n",
- loginfo.log_access_file, tbuf,
- logstr);
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Removed file:%s.%s because of (%s)\n", loginfo.log_access_file, tbuf, logstr);
}
slapi_ch_free((void**)&delete_logp);
loginfo.log_numof_access_logs--;
@@ -3067,7 +3077,6 @@ log__delete_error_logfile(int locked)
char buffer[BUFSIZ];
char tbuf[TBUFSIZE];
-
/* If we have only one log, then will delete this one */
if (loginfo.log_error_maxnumlogs == 1) {
LOG_CLOSE(loginfo.log_error_fdes);
@@ -3075,10 +3084,14 @@ log__delete_error_logfile(int locked)
PR_snprintf (buffer, sizeof(buffer), "%s", loginfo.log_error_file);
if (PR_Delete(buffer) != PR_SUCCESS) {
if (!locked) {
- /* if locked, we should not call LDAPDebug,
- which tries to get a lock internally. */
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s\n", loginfo.log_error_file,0,0);
+ /* If locked, we should not call LDAPDebug, which tries to get a lock internally. */
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_error_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s error %d (%s)\n",
+ loginfo.log_error_file, prerr, slapd_pr_strerror(prerr));
+ }
}
}
@@ -3086,11 +3099,14 @@ log__delete_error_logfile(int locked)
PR_snprintf (buffer, sizeof(buffer), "%s.rotationinfo", loginfo.log_error_file);
if (PR_Delete(buffer) != PR_SUCCESS) {
if (!locked) {
- /* if locked, we should not call LDAPDebug,
- which tries to get a lock internally. */
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s.rotationinfo\n",
- loginfo.log_error_file,0,0);
+ /* If locked, we should not call LDAPDebug, which tries to get a lock internally. */
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_error_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s.rotationinfo error %d (%s)\n",
+ loginfo.log_error_file, prerr, slapd_pr_strerror(prerr));
+ }
}
}
return 0;
@@ -3202,10 +3218,11 @@ delete_logfile:
PR_snprintf (buffer, sizeof(buffer), "%s.%s", loginfo.log_error_file, tbuf);
if (PR_Delete(buffer) != PR_SUCCESS) {
PRErrorCode prerr = PR_GetError();
- PR_snprintf(buffer, sizeof(buffer),
- "LOGINFO:Unable to remove file:%s.%s error %d (%s)\n",
- loginfo.log_error_file, tbuf, prerr, slapd_pr_strerror(prerr));
- log__error_emergency(buffer, 0, locked);
+ if (PR_FILE_NOT_FOUND_ERROR != prerr) {
+ PR_snprintf(buffer, sizeof(buffer), "LOGINFO:Unable to remove file:%s.%s error %d (%s)\n",
+ loginfo.log_error_file, tbuf, prerr, slapd_pr_strerror(prerr));
+ log__error_emergency(buffer, 0, locked);
+ }
}
slapi_ch_free((void**)&delete_logp);
loginfo.log_numof_error_logs--;
@@ -3245,15 +3262,25 @@ log__delete_audit_logfile()
loginfo.log_audit_fdes = NULL;
PR_snprintf(buffer, sizeof(buffer), "%s", loginfo.log_audit_file);
if (PR_Delete(buffer) != PR_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s\n", loginfo.log_audit_file,0,0);
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_audit_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s error %d (%s)\n",
+ loginfo.log_audit_file, prerr, slapd_pr_strerror(prerr));
+ }
}
/* Delete the rotation file also. */
PR_snprintf(buffer, sizeof(buffer), "%s.rotationinfo", loginfo.log_audit_file);
if (PR_Delete(buffer) != PR_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s.rotationinfo\n", loginfo.log_audit_file,0,0);
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_audit_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s.rotatoininfo error %d (%s)\n",
+ loginfo.log_audit_file, prerr, slapd_pr_strerror(prerr));
+ }
}
return 0;
}
@@ -3354,15 +3381,15 @@ delete_logfile:
log_convert_time (delete_logp->l_ctime, tbuf, 1 /*short */);
PR_snprintf(buffer, sizeof(buffer), "%s.%s", loginfo.log_audit_file, tbuf );
if (PR_Delete(buffer) != PR_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Unable to remove file:%s.%s\n",
- loginfo.log_audit_file, tbuf,0);
-
+ PRErrorCode prerr = PR_GetError();
+ if (PR_FILE_NOT_FOUND_ERROR == prerr) {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "File %s already removed\n", loginfo.log_audit_file);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Unable to remove file:%s.%s error %d (%s)\n",
+ loginfo.log_audit_file, tbuf, prerr, slapd_pr_strerror(prerr));
+ }
} else {
- LDAPDebug(LDAP_DEBUG_TRACE,
- "LOGINFO:Removed file:%s.%s because of (%s)\n",
- loginfo.log_audit_file, tbuf,
- logstr);
+ slapi_log_error(SLAPI_LOG_TRACE, "LOGINFO", "Removed file:%s.%s because of (%s)\n", loginfo.log_audit_file, tbuf, logstr);
}
slapi_ch_free((void**)&delete_logp);
loginfo.log_numof_audit_logs--;
@@ -3640,10 +3667,8 @@ log__open_errorlogfile(int logfile_state, int locked)
Even if PR_Rename fails with the error, we continue logging.
*/
if (PR_FILE_EXISTS_ERROR != prerr) {
- PR_snprintf(buffer, sizeof(buffer),
- "Failed to rename errors log file, "
- SLAPI_COMPONENT_NAME_NSPR " error %d (%s). Exiting...",
- prerr, slapd_pr_strerror(prerr));
+ PR_snprintf(buffer, sizeof(buffer), "Failed to rename errors log file, "
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s). Exiting...\n", prerr, slapd_pr_strerror(prerr));
log__error_emergency(buffer, 1, 1);
slapi_ch_free((void **)&log);
if (!locked) LOG_ERROR_UNLOCK_WRITE();
| 0 |
2a3c0d8e8bbc2e6bdf9207ef7754016de2653f6e
|
389ds/389-ds-base
|
Issue 6850 - AddressSanitizer: memory leak in mdb_init
Bug Description:
`dbmdb_componentid` can be allocated multiple times. To avoid a memory
leak, allocate it only once, and free at the cleanup.
Fixes: https://github.com/389ds/389-ds-base/issues/6850
Reviewed by: @mreynolds389, @tbordaz (Tnanks!)
|
commit 2a3c0d8e8bbc2e6bdf9207ef7754016de2653f6e
Author: Viktor Ashirov <[email protected]>
Date: Mon Jul 7 23:11:17 2025 +0200
Issue 6850 - AddressSanitizer: memory leak in mdb_init
Bug Description:
`dbmdb_componentid` can be allocated multiple times. To avoid a memory
leak, allocate it only once, and free at the cleanup.
Fixes: https://github.com/389ds/389-ds-base/issues/6850
Reviewed by: @mreynolds389, @tbordaz (Tnanks!)
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_config.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_config.c
index 447f3c70a..54ca03b0b 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_config.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_config.c
@@ -146,7 +146,9 @@ dbmdb_compute_limits(struct ldbminfo *li)
int mdb_init(struct ldbminfo *li, config_info *config_array)
{
dbmdb_ctx_t *conf = (dbmdb_ctx_t *)slapi_ch_calloc(1, sizeof(dbmdb_ctx_t));
- dbmdb_componentid = generate_componentid(NULL, "db-mdb");
+ if (dbmdb_componentid == NULL) {
+ dbmdb_componentid = generate_componentid(NULL, "db-mdb");
+ }
li->li_dblayer_config = conf;
strncpy(conf->home, li->li_directory, MAXPATHLEN-1);
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 c4e87987f..ed17f979f 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c
@@ -19,7 +19,7 @@
#include <prclist.h>
#include <glob.h>
-Slapi_ComponentId *dbmdb_componentid;
+Slapi_ComponentId *dbmdb_componentid = NULL;
#define BULKOP_MAX_RECORDS 100 /* Max records handled by a single bulk operations */
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_misc.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_misc.c
index 2d07db9b5..ae10ac7cf 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_misc.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_misc.c
@@ -49,6 +49,11 @@ dbmdb_cleanup(struct ldbminfo *li)
}
slapi_ch_free((void **)&(li->li_dblayer_config));
+ if (dbmdb_componentid != NULL) {
+ release_componentid(dbmdb_componentid);
+ dbmdb_componentid = NULL;
+ }
+
return 0;
}
| 0 |
7b16777076229eb5b3cada37504c0d19d4f56fd6
|
389ds/389-ds-base
|
Issue 6603 - Release tarballs ship a different Cargo.lock
Bug Description:
During release action `Cargo.lock` gets updated, has newer packages than
`Cargo.lock` committed in the repository.
Because of that upstream patches that update `Cargo.lock` do not apply
cleanly to the release tarball.
Fix Description:
Remove `cargo update` from the `download-cargo-dependencies` target. For
updating `Cargo.lock` there is a separate `update-cargo-dependencies`
target that should be used instead.
Additionally, fix `dist-bz2` target to generate tarball with a proper
name when `TAG` variable is not defined.
Fixes: https://github.com/389ds/389-ds-base/issues/6603
Reviewed by: @progier389 (Thanks!)
|
commit 7b16777076229eb5b3cada37504c0d19d4f56fd6
Author: Viktor Ashirov <[email protected]>
Date: Fri Apr 11 13:09:44 2025 +0200
Issue 6603 - Release tarballs ship a different Cargo.lock
Bug Description:
During release action `Cargo.lock` gets updated, has newer packages than
`Cargo.lock` committed in the repository.
Because of that upstream patches that update `Cargo.lock` do not apply
cleanly to the release tarball.
Fix Description:
Remove `cargo update` from the `download-cargo-dependencies` target. For
updating `Cargo.lock` there is a separate `update-cargo-dependencies`
target that should be used instead.
Additionally, fix `dist-bz2` target to generate tarball with a proper
name when `TAG` variable is not defined.
Fixes: https://github.com/389ds/389-ds-base/issues/6603
Reviewed by: @progier389 (Thanks!)
diff --git a/rpm.mk b/rpm.mk
index 8aa2dc353..aeb3c6376 100644
--- a/rpm.mk
+++ b/rpm.mk
@@ -11,7 +11,7 @@ TARBALL = $(NAME_VERSION).tar.bz2
NODE_MODULES_TEST = src/cockpit/389-console/package-lock.json
NODE_MODULES_PATH = src/cockpit/389-console/
CARGO_PATH = src/
-GIT_TAG = ${TAG}
+GIT_TAG = $(if $(TAG),$(TAG),$(PACKAGE)-$(RPM_VERSION)$(VERSION_PREREL))
BUNDLE_JEMALLOC = 1
RPMBUILD_OPTIONS += $(if $(filter 1, $(BUNDLE_JEMALLOC)),--with bundle_jemalloc,--without bundle_jemalloc)
@@ -55,7 +55,6 @@ update-cargo-dependencies:
cargo update --manifest-path=./src/Cargo.toml
download-cargo-dependencies:
- cargo update --manifest-path=./src/Cargo.toml
cargo vendor --manifest-path=./src/Cargo.toml
cargo fetch --manifest-path=./src/Cargo.toml
tar -czf vendor.tar.gz vendor
| 0 |
9db7a5adfaed49336ccee3bac43849c97c5c863b
|
389ds/389-ds-base
|
Issue 5413 - Allow only one MemberOf fixup task at a time
Description: only allow one fixup task to run at a time, and improve
the task logging
relates: https://github.com/389ds/389-ds-base/issues/5413
Reviewed by: progier & tbordaz(Thanks!)
|
commit 9db7a5adfaed49336ccee3bac43849c97c5c863b
Author: Mark Reynolds <[email protected]>
Date: Fri Sep 2 16:43:41 2022 -0400
Issue 5413 - Allow only one MemberOf fixup task at a time
Description: only allow one fixup task to run at a time, and improve
the task logging
relates: https://github.com/389ds/389-ds-base/issues/5413
Reviewed by: progier & tbordaz(Thanks!)
diff --git a/dirsrvtests/tests/suites/memberof_plugin/fixup_test.py b/dirsrvtests/tests/suites/memberof_plugin/fixup_test.py
new file mode 100644
index 000000000..9566e144c
--- /dev/null
+++ b/dirsrvtests/tests/suites/memberof_plugin/fixup_test.py
@@ -0,0 +1,74 @@
+import ldap
+import logging
+import pytest
+import os
+from lib389._constants import DEFAULT_SUFFIX
+from lib389.topologies import topology_st as topo
+from lib389.plugins import MemberOfPlugin
+from lib389.idm.user import UserAccounts
+from lib389.idm.group import Groups
+
+
+log = logging.getLogger(__name__)
+
+
+def test_fixup_task_limit(topo):
+ """Test only one fixup task is allowed at one time
+
+ :id: 2bb49a10-fca9-4d89-9a7a-34c2ba4baadc
+ :setup: Standalone Instance
+ :steps:
+ 1. Add some users and groups
+ 2. Enable memberOf Plugin
+ 3. Add fixup task
+ 4. Add second task
+ 5. Add a third task after first task completes
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Second task should fail
+ 5. Success
+ """
+
+ # Create group with members
+ groups = Groups(topo.standalone, DEFAULT_SUFFIX)
+ group = groups.create(properties={'cn': 'test'})
+
+ users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ for idx in range(400):
+ user = users.create(properties={
+ 'uid': 'testuser%s' % idx,
+ 'cn' : 'testuser%s' % idx,
+ 'sn' : 'user%s' % idx,
+ 'uidNumber' : '%s' % (1000 + idx),
+ 'gidNumber' : '%s' % (1000 + idx),
+ 'homeDirectory' : '/home/testuser%s' % idx
+ })
+ group.add('member', user.dn)
+
+ # Configure memberOf plugin
+ memberof = MemberOfPlugin(topo.standalone)
+ memberof.enable()
+ topo.standalone.restart()
+
+ # Add first task
+ task = memberof.fixup(DEFAULT_SUFFIX)
+
+ # Add second task which should fail
+ with pytest.raises(ldap.UNWILLING_TO_PERFORM):
+ memberof.fixup(DEFAULT_SUFFIX)
+
+ # Wait for first task to complete
+ task.wait()
+
+ # Add new task which should be allowed now
+ memberof.fixup(DEFAULT_SUFFIX)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main(["-s", CURRENT_FILE])
+
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index 91dc6d386..19da91ae7 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -52,7 +52,12 @@ static Slapi_DN* _pluginDN = NULL;
MemberOfConfig *qsortConfig = 0;
static int usetxn = 0;
static int premodfn = 0;
-
+static PRBool fixup_running = PR_FALSE;
+static PRLock *fixup_lock = NULL;
+static int32_t fixup_progress_count = 0;
+static int64_t fixup_progress_elapsed = 0;
+static int64_t fixup_start_time = 0;
+#define FIXUP_PROGRESS_LIMIT 1000
typedef struct _memberofstringll
{
@@ -329,6 +334,15 @@ memberof_postop_start(Slapi_PBlock *pb)
}
}
+ if (fixup_lock == NULL) {
+ if ((fixup_lock = PR_NewLock()) == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_postop_start - Failed to create fixup lock.\n");
+ rc = -1;
+ goto bail;
+ }
+ }
+
/* Set the alternate config area if one is defined. */
slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_AREA, &config_area);
if (config_area) {
@@ -421,6 +435,8 @@ memberof_postop_close(Slapi_PBlock *pb __attribute__((unused)))
slapi_sdn_free(&_pluginDN);
slapi_destroy_rwlock(config_rwlock);
config_rwlock = NULL;
+ PR_DestroyLock(fixup_lock);
+ fixup_lock = NULL;
slapi_log_err(SLAPI_LOG_TRACE, MEMBEROF_PLUGIN_SUBSYSTEM,
"<-- memberof_postop_close\n");
@@ -2820,9 +2836,16 @@ memberof_fixup_task_thread(void *arg)
if (!task) {
return; /* no task */
}
+
+ PR_Lock(fixup_lock);
+ fixup_running = PR_TRUE;
+ fixup_progress_count = 0;
+ fixup_progress_elapsed = slapi_current_rel_time_t();
+ fixup_start_time = slapi_current_rel_time_t();
+ PR_Unlock(fixup_lock);
+
slapi_task_inc_refcount(task);
- slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM,
- "memberof_fixup_task_thread - refcount incremented.\n");
+
/* Fetch our task data from the task */
td = (task_data *)slapi_task_get_data(task);
@@ -2846,6 +2869,7 @@ memberof_fixup_task_thread(void *arg)
/* Mark this as a task operation */
configCopy.fixup_task = 1;
+ configCopy.task = task;
if (usetxn) {
Slapi_DN *sdn = slapi_sdn_new_dn_byref(td->dn);
@@ -2885,15 +2909,23 @@ done:
}
memberof_free_config(&configCopy);
- slapi_task_log_notice(task, "Memberof task finished.\n");
- slapi_task_log_status(task, "Memberof task finished.\n");
+ slapi_task_log_notice(task, "Memberof task finished (processed %d entries in %ld seconds)",
+ fixup_progress_count, slapi_current_rel_time_t() - fixup_start_time);
+ slapi_task_log_status(task, "Memberof task finished (processed %d entries in %ld seconds)",
+ fixup_progress_count, slapi_current_rel_time_t() - fixup_start_time);
slapi_task_inc_progress(task);
/* this will queue the destruction of the task */
slapi_task_finish(task, rc);
slapi_task_dec_refcount(task);
- slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM,
- "memberof_fixup_task_thread - refcount decremented.\n");
+
+ PR_Lock(fixup_lock);
+ fixup_running = PR_FALSE;
+ PR_Unlock(fixup_lock);
+
+ slapi_log_err(SLAPI_LOG_INFO, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_fixup_task_thread - Memberof task finished (processed %d entries in %ld seconds)\n",
+ fixup_progress_count, slapi_current_rel_time_t() - fixup_start_time);
}
int
@@ -2914,6 +2946,17 @@ memberof_task_add(Slapi_PBlock *pb,
*returncode = LDAP_SUCCESS;
+ PR_Lock(fixup_lock);
+ if (fixup_running) {
+ PR_Unlock(fixup_lock);
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ slapi_log_err(SLAPI_LOG_ERR, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_task_add - there is already a fixup task running\n");
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto out;
+ }
+ PR_Unlock(fixup_lock);
+
/* get arg(s) */
if ((dn = slapi_entry_attr_get_ref(e, "basedn")) == NULL) {
*returncode = LDAP_OBJECT_CLASS_VIOLATION;
@@ -3145,7 +3188,8 @@ memberof_fix_memberof_callback(Slapi_Entry *e, void *callback_data)
/* Check if the entry has not already been fixed */
ndn = slapi_sdn_get_ndn(sdn);
if (ndn && config->fixup_cache && PL_HashTableLookupConst(config->fixup_cache, (void *)ndn)) {
- slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback: Entry %s already fixed up\n", ndn);
+ slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback - "
+ "Entry %s already fixed up\n", ndn);
goto bail;
}
@@ -3161,22 +3205,26 @@ memberof_fix_memberof_callback(Slapi_Entry *e, void *callback_data)
* so free this memory
*/
#if MEMBEROF_CACHE_DEBUG
- slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback: This is NOT a group %s\n", ndn);
+ slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_fix_memberof_callback: This is NOT a group %s\n", ndn);
#endif
ht_grp = ancestors_cache_lookup(config, (const void *)ndn);
if (ht_grp) {
if (ancestors_cache_remove(config, (const void *)ndn)) {
- slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback: free cached values for %s\n", ndn);
+ slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_fix_memberof_callback - free cached values for %s\n", ndn);
ancestor_hashtable_entry_free(ht_grp);
slapi_ch_free((void **)&ht_grp);
} else {
- slapi_log_err(SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback: Fail to remove that leaf node %s\n", ndn);
+ slapi_log_err(SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_fix_memberof_callback - Fail to remove that leaf node %s\n", ndn);
}
} else {
/* This is quite unexpected, after a call to memberof_get_groups
* ndn ancestors should be in the cache
*/
- slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback: Weird, %s is not in the cache\n", ndn);
+ slapi_log_err(SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_fix_memberof_callback - Weird, %s is not in the cache\n", ndn);
}
}
}
@@ -3220,7 +3268,7 @@ memberof_fix_memberof_callback(Slapi_Entry *e, void *callback_data)
if (config->fixup_cache) {
dn_copy = slapi_ch_strdup(ndn);
if (PL_HashTableAdd(config->fixup_cache, dn_copy, dn_copy) == NULL) {
- slapi_log_err(SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback: "
+ slapi_log_err(SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_fix_memberof_callback - "
"failed to add dn (%s) in the fixup hashtable; NSPR error - %d\n",
dn_copy, PR_GetError());
slapi_ch_free((void **)&dn_copy);
@@ -3228,6 +3276,24 @@ memberof_fix_memberof_callback(Slapi_Entry *e, void *callback_data)
}
}
+ if (config->task) {
+ fixup_progress_count++;
+ if (fixup_progress_count % FIXUP_PROGRESS_LIMIT == 0 ) {
+ slapi_task_log_notice(config->task,
+ "Processed %d entries in %ld seconds (+%ld seconds)",
+ fixup_progress_count,
+ slapi_current_rel_time_t() - fixup_start_time,
+ slapi_current_rel_time_t() - fixup_progress_elapsed);
+ slapi_task_log_status(config->task,
+ "Processed %d entries in %ld seconds (+%ld seconds)",
+ fixup_progress_count,
+ slapi_current_rel_time_t() - fixup_start_time,
+ slapi_current_rel_time_t() - fixup_progress_elapsed);
+ slapi_task_inc_progress(config->task);
+ fixup_progress_elapsed = slapi_current_rel_time_t();
+ }
+ }
+
bail:
return rc;
}
diff --git a/ldap/servers/plugins/memberof/memberof.h b/ldap/servers/plugins/memberof/memberof.h
index 6ac9a20b9..1925b9b58 100644
--- a/ldap/servers/plugins/memberof/memberof.h
+++ b/ldap/servers/plugins/memberof/memberof.h
@@ -66,6 +66,7 @@ typedef struct memberofconfig
char *auto_add_oc;
PLHashTable *ancestors_cache;
PLHashTable *fixup_cache;
+ Slapi_Task *task;
} MemberOfConfig;
/* The key to access the hash table is the normalized DN
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index 777dbc5b7..97582b16e 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -1675,15 +1675,7 @@ def get_task_status(inst, log, taskObj, dn=None, show_log=False, watch=False, us
all_finished = False
task_ended = ""
exitcode = "Not finished ..."
-
- # Calc elapsed time for running task
- curr_time = int(time.time()) # Use the current time
- time_tuple = (int(task_created[:4]), int(task_created[4:6]), int(task_created[6:8]),
- int(task_created[8:10]), int(task_created[10:12]), int(task_created[12:14]),
- 0, 0, 0)
- start_time = int(time.mktime(time_tuple))
- elapsed_secs = curr_time - start_time
- elapsed_time_str = str(timedelta(seconds=elapsed_secs))
+ elapsed_time_str = ""
else:
# Task is finished, use start and end times to calc elapsed time
elapsed_time_str = elapsed_time(task_created, task_ended)
| 0 |
5249788ee51c1b630994f2516c809151f79ea036
|
389ds/389-ds-base
|
Issue 6476 - Fix build failure with GCC 15
Description:
Most of the failures are our use of function pointer with a generic
typedef with unknown parameters (e.g. IFP)
There are other IFP we use, but they are not triggering build failures
yet.
Relates: https://github.com/389ds/389-ds-base/issues/6476
Reviewed by: tbordaz & spichugi (Thanks!!)
|
commit 5249788ee51c1b630994f2516c809151f79ea036
Author: Mark Reynolds <[email protected]>
Date: Tue Jan 28 15:49:46 2025 -0500
Issue 6476 - Fix build failure with GCC 15
Description:
Most of the failures are our use of function pointer with a generic
typedef with unknown parameters (e.g. IFP)
There are other IFP we use, but they are not triggering build failures
yet.
Relates: https://github.com/389ds/389-ds-base/issues/6476
Reviewed by: tbordaz & spichugi (Thanks!!)
diff --git a/dirsrvtests/tests/suites/replication/acceptance_test.py b/dirsrvtests/tests/suites/replication/acceptance_test.py
index c2f3f2572..83b312a42 100644
--- a/dirsrvtests/tests/suites/replication/acceptance_test.py
+++ b/dirsrvtests/tests/suites/replication/acceptance_test.py
@@ -588,7 +588,7 @@ def test_double_delete(topo_m4, create_entry):
time.sleep(5)
else:
time.sleep(1)
-
+
log.info('Make searches to check if server is alive')
entries = get_repl_entries(topo_m4, TEST_ENTRY_NAME, ["uid"])
assert not entries, "Entry deletion {} wasn't replicated successfully".format(TEST_ENTRY_DN)
@@ -679,7 +679,7 @@ def test_invalid_agmt(topo_m4):
assert False
-def test_warining_for_invalid_replica(topo_m4):
+def test_warning_for_invalid_replica(topo_m4):
"""Testing logs to indicate the inconsistency when configuration is performed.
:id: dd689d03-69b8-4bf9-a06e-2acd19d5e2c8
@@ -703,6 +703,7 @@ def test_warining_for_invalid_replica(topo_m4):
log.info('Check the error log for the error')
assert topo_m4.ms["supplier1"].ds_error_log.match('.*nsds5ReplicaBackoffMax.*10.*invalid.*')
+
def test_csnpurge_large_valueset(topo_m2):
"""Test csn generator test
diff --git a/dirsrvtests/tests/suites/replication/changelog_test.py b/dirsrvtests/tests/suites/replication/changelog_test.py
index cea37407d..2653025d9 100644
--- a/dirsrvtests/tests/suites/replication/changelog_test.py
+++ b/dirsrvtests/tests/suites/replication/changelog_test.py
@@ -14,6 +14,7 @@ import pytest
import time
import subprocess
import glob
+import re
from lib389.properties import TASK_WAIT
from lib389.replica import Replicas
from lib389.idm.user import UserAccounts
@@ -46,10 +47,11 @@ else:
logging.getLogger(__name__).setLevel(logging.INFO)
log = logging.getLogger(__name__)
+
def _check_repl_changelog_backup(instance, backup_dir):
# Note: there is no way to check dbi on lmdb backup
# That said dbscan may perhaps do it ...
- if instance.get_db_lib() is 'bdb':
+ if instance.get_db_lib() == 'bdb':
if ds_supports_new_changelog():
backup_checkdir = os.path.join(backup_dir, DEFAULT_BENAME, BDB_CL_FILENAME)
else:
@@ -60,6 +62,7 @@ def _check_repl_changelog_backup(instance, backup_dir):
log.fatal('test_changelog5: backup directory does not exist : {}*'.format(backup_checkdir))
assert False
+
def _perform_ldap_operations(topo):
"""Add a test user, modify description, modrdn user and delete it"""
@@ -751,7 +754,7 @@ def test_changelog_pagesize(topo):
3. Should not have any 4K page size in db_stat output
"""
- s1=topo.ms["supplier1"]
+ s1 = topo.ms["supplier1"]
fs_pagesize = os.statvfs(s1.ds_paths.db_home_dir).f_bsize
if fs_pagesize != 4096:
pytest.skip("This test requires that database filesystem prefered block size is 4K.")
@@ -761,8 +764,8 @@ def test_changelog_pagesize(topo):
log.debug(f"DEBUG: Running {cmd}")
output = subprocess.check_output(cmd, universal_newlines=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- self.log.error(f'Failed to gather db statistics {cmd}: "{e.output.decode()}')
- self.log.error(e)
+ log.error(f'Failed to gather db statistics {cmd}: "{e.output.decode()}')
+ log.error(e)
raise e
assert not re.match("^4096 *Page size", output, flags=re.MULTILINE)
diff --git a/ldap/include/avl.h b/ldap/include/avl.h
index cafe810ac..57086de23 100644
--- a/ldap/include/avl.h
+++ b/ldap/include/avl.h
@@ -64,14 +64,15 @@ typedef int (*IFP)(); /* takes undefined arguments */
/* avl routines */
#define avl_getone(x) (x == 0 ? 0 : (x)->avl_data)
#define avl_onenode(x) (x == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
-extern int avl_insert(Avlnode **root, void *data, IFP fcmp, IFP fdup);
-extern caddr_t avl_delete(Avlnode **root, void *data, IFP fcmp);
-extern caddr_t avl_find(Avlnode *root, void *data, IFP fcmp);
+
+extern int avl_insert(Avlnode **root, caddr_t data, int32_t(*fcmp)(caddr_t, caddr_t), int32_t(*fdup)(caddr_t, caddr_t));
+extern caddr_t avl_delete(Avlnode **root, caddr_t data, int32_t(*fcmp)(caddr_t, caddr_t));
+extern caddr_t avl_find(Avlnode *root, caddr_t data, int32_t(*fcmp)(caddr_t, caddr_t));
extern caddr_t avl_getfirst(Avlnode *root);
extern caddr_t avl_getnext(void);
-extern int avl_dup_error(void);
-extern int avl_apply(Avlnode *root, IFP fn, void *arg, int stopflag, int type);
-extern int avl_free(Avlnode *root, IFP dfree);
+extern int avl_dup_error(caddr_t a, caddr_t b);
+extern int avl_apply(Avlnode *root, int32_t(*fn)(caddr_t, caddr_t), void *arg, int stopflag, int type);
+extern int avl_free(Avlnode *root, int32_t(*dfree)(caddr_t));
/* apply traversal types */
#define AVL_PREORDER 1
@@ -80,6 +81,6 @@ extern int avl_free(Avlnode *root, IFP dfree);
/* what apply returns if it ran out of nodes */
#define AVL_NOMORE -6
-caddr_t avl_find_lin(Avlnode *root, caddr_t data, IFP fcmp);
+caddr_t avl_find_lin(Avlnode *root, caddr_t data, int32_t(*fcmp)(caddr_t, caddr_t));
#endif /* _AVL */
diff --git a/ldap/libraries/libavl/avl.c b/ldap/libraries/libavl/avl.c
index 759fbf68f..b004d25f0 100644
--- a/ldap/libraries/libavl/avl.c
+++ b/ldap/libraries/libavl/avl.c
@@ -69,8 +69,8 @@ ravl_insert(
Avlnode **iroot,
caddr_t data,
int *taller,
- IFP fcmp, /* comparison function */
- IFP fdup, /* function to call for duplicates */
+ int32_t (*fcmp)(caddr_t, caddr_t), /* comparison function */
+ int32_t (*fdup)(caddr_t, caddr_t), /* function to call for duplicates */
int depth)
{
int rc, cmp, tallersub;
@@ -226,13 +226,13 @@ ravl_insert(
int
avl_insert(
Avlnode **root,
- void *data,
- IFP fcmp,
- IFP fdup)
+ caddr_t data,
+ int32_t (*fcmp)(caddr_t, caddr_t),
+ int32_t (*fdup)(caddr_t, caddr_t))
{
int taller;
- return ravl_insert(root, (caddr_t)data, &taller, fcmp, fdup, 0);
+ return ravl_insert(root, data, &taller, fcmp, fdup, 0);
}
/*
@@ -374,7 +374,7 @@ static caddr_t
ravl_delete(
Avlnode **root,
caddr_t data,
- IFP fcmp,
+ int32_t (*fcmp)(caddr_t, caddr_t),
int *shorter)
{
int shortersubtree = 0;
@@ -464,15 +464,15 @@ ravl_delete(
*/
caddr_t
-avl_delete(Avlnode **root, void *data, IFP fcmp)
+avl_delete(Avlnode **root, caddr_t data, int32_t(*fcmp)(caddr_t, caddr_t))
{
int shorter;
- return ravl_delete(root, (caddr_t)data, fcmp, &shorter);
+ return ravl_delete(root, data, fcmp, &shorter);
}
static int
-avl_inapply(Avlnode *root, IFP fn, caddr_t arg, int stopflag)
+avl_inapply(Avlnode *root, int32_t(*fn)(caddr_t, caddr_t), caddr_t arg, int stopflag)
{
if (root == 0)
return (AVL_NOMORE);
@@ -491,7 +491,7 @@ avl_inapply(Avlnode *root, IFP fn, caddr_t arg, int stopflag)
}
static int
-avl_postapply(Avlnode *root, IFP fn, caddr_t arg, int stopflag)
+avl_postapply(Avlnode *root, int32_t(*fn)(caddr_t, caddr_t), caddr_t arg, int stopflag)
{
if (root == 0)
return (AVL_NOMORE);
@@ -508,7 +508,7 @@ avl_postapply(Avlnode *root, IFP fn, caddr_t arg, int stopflag)
}
static int
-avl_preapply(Avlnode *root, IFP fn, caddr_t arg, int stopflag)
+avl_preapply(Avlnode *root, int32_t(*fn)(caddr_t, caddr_t), caddr_t arg, int stopflag)
{
if (root == 0)
return (AVL_NOMORE);
@@ -537,7 +537,7 @@ avl_preapply(Avlnode *root, IFP fn, caddr_t arg, int stopflag)
int
avl_apply(
Avlnode *root,
- IFP fn,
+ int32_t (*fn)(caddr_t, caddr_t),
void *arg,
int stopflag,
int type)
@@ -572,9 +572,9 @@ int
avl_prefixapply(
Avlnode *root,
caddr_t data,
- IFP fmatch,
+ int32_t (*fmatch)(caddr_t, caddr_t),
caddr_t marg,
- IFP fcmp,
+ int32_t (*fcmp)(caddr_t, caddr_t, caddr_t),
caddr_t carg,
int stopflag)
{
@@ -619,7 +619,7 @@ avl_prefixapply(
*/
int
-avl_free(Avlnode *root, IFP dfree)
+avl_free(Avlnode *root, int32_t (*dfree)(caddr_t))
{
int nleft, nright;
@@ -649,11 +649,11 @@ avl_free(Avlnode *root, IFP dfree)
*/
caddr_t
-avl_find(Avlnode *root, void *data, IFP fcmp)
+avl_find(Avlnode *root, caddr_t data, int32_t (*fcmp)(caddr_t, caddr_t))
{
int cmp;
- while (root != 0 && (cmp = (*fcmp)((caddr_t)data, root->avl_data)) != 0) {
+ while (root != 0 && (cmp = (*fcmp)(data, root->avl_data)) != 0) {
if (cmp < 0)
root = root->avl_left;
else
@@ -671,7 +671,7 @@ avl_find(Avlnode *root, void *data, IFP fcmp)
*/
caddr_t
-avl_find_lin(Avlnode *root, caddr_t data, IFP fcmp)
+avl_find_lin(Avlnode *root, caddr_t data, int32_t (*fcmp)(caddr_t, caddr_t))
{
caddr_t res;
@@ -699,7 +699,7 @@ static int avl_nextlist = 0;
/* ARGSUSED */
static int
-avl_buildlist(caddr_t data, int arg __attribute__((unused)))
+avl_buildlist(caddr_t data, caddr_t arg __attribute__((unused)))
{
static int slots = 0;
@@ -774,8 +774,10 @@ avl_getnext(void)
return (avl_list[avl_nextlist++]);
}
+/* This is always called from avl_insert, where the dup function expects two
+ * caddr_t paramters */
int
-avl_dup_error(void)
+avl_dup_error(caddr_t a __attribute__((unused)), caddr_t b __attribute__((unused)))
{
return (-1);
}
diff --git a/ldap/servers/plugins/acl/acllist.c b/ldap/servers/plugins/acl/acllist.c
index e80c567c3..bf1168691 100644
--- a/ldap/servers/plugins/acl/acllist.c
+++ b/ldap/servers/plugins/acl/acllist.c
@@ -233,14 +233,14 @@ __acllist_add_aci(aci_t *aci)
slapi_sdn_set_ndn_byval(aciListHead->acic_sdn, slapi_sdn_get_ndn(aci->aci_sdn));
/* insert the aci */
- switch (avl_insert(&acllistRoot, aciListHead, __acllist_aciContainer_node_cmp,
+ switch (avl_insert(&acllistRoot, (caddr_t)aciListHead, __acllist_aciContainer_node_cmp,
__acllist_aciContainer_node_dup)) {
case 1: /* duplicate ACL on the same entry */
/* Find the node that contains the acl. */
- if (NULL == (head = (AciContainer *)avl_find(acllistRoot, aciListHead,
- (IFP)__acllist_aciContainer_node_cmp))) {
+ if (NULL == (head = (AciContainer *)avl_find(acllistRoot, (caddr_t)aciListHead,
+ __acllist_aciContainer_node_cmp))) {
slapi_log_err(SLAPI_PLUGIN_ACL, plugin_name,
"__acllist_add_aci - Can't insert the acl in the tree\n");
rv = 1;
@@ -356,8 +356,8 @@ acllist_remove_aci_needsLock(const Slapi_DN *sdn, const struct berval *attr)
slapi_sdn_set_ndn_byval(aciListHead->acic_sdn, slapi_sdn_get_ndn(sdn));
/* now find it */
- if (NULL == (root = (AciContainer *)avl_find(acllistRoot, aciListHead,
- (IFP)__acllist_aciContainer_node_cmp))) {
+ if (NULL == (root = (AciContainer *)avl_find(acllistRoot, (caddr_t)aciListHead,
+ __acllist_aciContainer_node_cmp))) {
/* In that case we don't have any acl for this entry. cool !!! */
acllist_free_aciContainer(&aciListHead);
@@ -389,7 +389,7 @@ acllist_remove_aci_needsLock(const Slapi_DN *sdn, const struct berval *attr)
slapi_log_err(SLAPI_LOG_ACL, plugin_name,
"acllist_remove_aci_needsLock - Removing container[%d]=%s\n", root->acic_index,
slapi_sdn_get_ndn(root->acic_sdn));
- dContainer = (AciContainer *)avl_delete(&acllistRoot, aciListHead,
+ dContainer = (AciContainer *)avl_delete(&acllistRoot, (caddr_t)aciListHead,
__acllist_aciContainer_node_cmp);
acllist_free_aciContainer(&dContainer);
@@ -472,8 +472,9 @@ acllist_done_aciContainer(AciContainer *head)
}
static int
-free_aci_avl_container(AciContainer *data)
+free_aci_avl_container(caddr_t d)
{
+ AciContainer *data = (AciContainer *)d;
aci_t *head, *next = NULL;
head = data->acic_list;
@@ -658,7 +659,7 @@ acllist_init_scan(Slapi_PBlock *pb, int scope __attribute__((unused)), const cha
root = (AciContainer *)avl_find(acllistRoot,
(caddr_t)aclpb->aclpb_aclContainer,
- (IFP)__acllist_aciContainer_node_cmp);
+ __acllist_aciContainer_node_cmp);
if (index >= aclpb_max_selected_acls - 2) {
aclpb->aclpb_handles_index[0] = -1;
slapi_ch_free_string(&basedn);
@@ -750,7 +751,7 @@ acllist_aciscan_update_scan(Acl_PBlock *aclpb, char *edn)
root = (AciContainer *)avl_find(acllistRoot,
(caddr_t)aclpb->aclpb_aclContainer,
- (IFP)__acllist_aciContainer_node_cmp);
+ __acllist_aciContainer_node_cmp);
slapi_log_err(SLAPI_LOG_ACL, plugin_name,
"acllist_aciscan_update_scan - Searching AVL tree for update:%s: container:%d\n",
@@ -910,8 +911,8 @@ acllist_moddn_aci_needsLock(Slapi_DN *oldsdn, char *newdn)
slapi_sdn_free(&aciListHead->acic_sdn);
aciListHead->acic_sdn = oldsdn;
- if (NULL == (head = (AciContainer *)avl_find(acllistRoot, aciListHead,
- (IFP)__acllist_aciContainer_node_cmp))) {
+ if (NULL == (head = (AciContainer *)avl_find(acllistRoot, (caddr_t)aciListHead,
+ __acllist_aciContainer_node_cmp))) {
slapi_log_err(SLAPI_PLUGIN_ACL, plugin_name,
"acllist_moddn_aci_needsLock - Can't find the acl in the tree for moddn operation:olddn%s\n",
diff --git a/ldap/servers/plugins/collation/orfilter.c b/ldap/servers/plugins/collation/orfilter.c
index 1ed17c097..22fa7607d 100644
--- a/ldap/servers/plugins/collation/orfilter.c
+++ b/ldap/servers/plugins/collation/orfilter.c
@@ -54,7 +54,7 @@ typedef struct or_filter_t
static or_filter_t *
or_filter_get(Slapi_PBlock *pb)
{
- auto void *obj = NULL;
+ void *obj = NULL;
if (!slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &obj)) {
return (or_filter_t *)obj;
}
@@ -64,7 +64,7 @@ or_filter_get(Slapi_PBlock *pb)
static int
or_filter_destroy(Slapi_PBlock *pb)
{
- auto or_filter_t * or = or_filter_get(pb);
+ or_filter_t * or = or_filter_get(pb);
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
"or_filter_destroy - (%p)\n", (void *) or);
if (or != NULL) {
@@ -105,10 +105,10 @@ ss_match(struct berval *value,
* -1 nothing in value will match; give up
*/
{
- auto struct berval *vals[2];
- auto struct berval val;
- auto struct berval key;
- auto size_t attempts = MAX_CHAR_COMBINING;
+ struct berval *vals[2];
+ struct berval val;
+ struct berval key;
+ size_t attempts = MAX_CHAR_COMBINING;
vals[0] = &val;
vals[1] = NULL;
@@ -117,9 +117,9 @@ ss_match(struct berval *value,
key.bv_val = key0->bv_val;
key.bv_len = key0->bv_len - 1;
while (1) {
- auto struct berval **vkeys = ix->ix_index(ix, vals, NULL);
+ struct berval **vkeys = ix->ix_index(ix, vals, NULL);
if (vkeys && vkeys[0]) {
- auto const struct berval *vkey = vkeys[0];
+ const struct berval *vkey = vkeys[0];
if (vkey->bv_len > key.bv_len) {
if (--attempts <= 0) {
break; /* No match at this starting point */
@@ -138,7 +138,7 @@ ss_match(struct berval *value,
val.bv_len += LDAP_UTF8LEN(val.bv_val + val.bv_len);
}
if (value->bv_len > 0) {
- auto size_t one = LDAP_UTF8LEN(value->bv_val);
+ size_t one = LDAP_UTF8LEN(value->bv_val);
value->bv_len -= one;
value->bv_val += one;
return 1;
@@ -153,12 +153,12 @@ ss_filter_match(or_filter_t * or, struct berval **vals)
* >0 an LDAP error code
*/
{
- auto int rc = -1; /* no match */
- auto indexer_t *ix = or->or_indexer;
+ int rc = -1; /* no match */
+ indexer_t *ix = or->or_indexer;
if (vals != NULL)
for (; *vals; ++vals) {
- auto struct berval v;
- auto struct berval **k = or->or_match_keys;
+ struct berval v;
+ struct berval **k = or->or_match_keys;
if (k == NULL || *k == NULL) {
rc = 0; /* present */
break;
@@ -180,12 +180,12 @@ ss_filter_match(or_filter_t * or, struct berval **vals)
break;
}
} else { /* final */
- auto size_t attempts = MAX_CHAR_COMBINING;
- auto char *limit = v.bv_val;
- auto char *end;
- auto struct berval **vkeys;
- auto struct berval *final_vals[2];
- auto struct berval key;
+ size_t attempts = MAX_CHAR_COMBINING;
+ char *limit = v.bv_val;
+ char *end;
+ struct berval **vkeys;
+ struct berval *final_vals[2];
+ struct berval key;
rc = -1;
final_vals[0] = &v;
@@ -211,7 +211,7 @@ ss_filter_match(or_filter_t * or, struct berval **vals)
v.bv_len = end - v.bv_val + 1;
vkeys = ix->ix_index(ix, final_vals, NULL);
if (vkeys && vkeys[0]) {
- auto const struct berval *vkey = vkeys[0];
+ const struct berval *vkey = vkeys[0];
if (vkey->bv_len > key.bv_len) {
if (--attempts <= 0) {
break;
@@ -239,11 +239,11 @@ ss_filter_match(or_filter_t * or, struct berval **vals)
static int
op_filter_match(or_filter_t * or, struct berval **vals)
{
- auto indexer_t *ix = or->or_indexer;
- auto struct berval **v = ix->ix_index(ix, vals, NULL);
+ indexer_t *ix = or->or_indexer;
+ struct berval **v = ix->ix_index(ix, vals, NULL);
if (v != NULL)
for (; *v; ++v) {
- auto struct berval **k = or->or_match_keys;
+ struct berval **k = or->or_match_keys;
if (k != NULL)
for (; *k; ++k) {
switch (or->or_op) {
@@ -282,11 +282,11 @@ or_filter_match(void *obj, Slapi_Entry *entry, Slapi_Attr *attr)
* >0 an LDAP error code
*/
{
- auto int rc = -1; /* no match */
- auto or_filter_t * or = (or_filter_t *)obj;
+ int rc = -1; /* no match */
+ or_filter_t * or = (or_filter_t *)obj;
for (; attr != NULL; slapi_entry_next_attr(entry, attr, &attr)) {
- auto char *type = NULL;
- auto struct berval **vals = NULL;
+ char *type = NULL;
+ struct berval **vals = NULL;
/*
* XXXmcs 1-March-2001: This code would perform better if it did not make
@@ -352,7 +352,7 @@ static struct berval *
slapi_ch_bvdup0(struct berval *val)
/* Return a copy of val, with a 0 byte following the end. */
{
- auto struct berval *result = (struct berval *)
+ struct berval *result = (struct berval *)
slapi_ch_malloc(sizeof(struct berval));
slapi_ber_bvcpy(result, val);
return result;
@@ -372,12 +372,12 @@ static struct berval **
ss_filter_values(struct berval *pattern, int *query_op)
/* Split the pattern into its substrings and return them. */
{
- auto struct berval **result;
- auto struct berval val;
- auto size_t n;
- auto char *s;
- auto char *p;
- auto char *plimit = pattern->bv_val + pattern->bv_len;
+ struct berval **result;
+ struct berval val;
+ size_t n;
+ char *s;
+ char *p;
+ char *plimit = pattern->bv_val + pattern->bv_len;
/* Compute the length of the result array, and
the maximum bv_len of any of its elements. */
@@ -389,7 +389,7 @@ ss_filter_values(struct berval *pattern, int *query_op)
case WILDCARD:
++n;
{
- auto const size_t len = (p - s);
+ const size_t len = (p - s);
if (val.bv_len < len)
val.bv_len = len;
}
@@ -402,8 +402,8 @@ ss_filter_values(struct berval *pattern, int *query_op)
}
}
if (n == 2) { /* no wildcards in pattern */
- auto struct berval **pvec = (struct berval **)slapi_ch_malloc(sizeof(struct berval *) * 2);
- auto struct berval *pv = slapi_ch_bvdup(pattern);
+ struct berval **pvec = (struct berval **)slapi_ch_malloc(sizeof(struct berval *) * 2);
+ struct berval *pv = slapi_ch_bvdup(pattern);
pvec[0] = pv;
pvec[1] = NULL;
ss_unescape(pv);
@@ -413,7 +413,7 @@ ss_filter_values(struct berval *pattern, int *query_op)
return NULL; /* presence */
}
{
- auto const size_t len = (p - s);
+ const size_t len = (p - s);
if (val.bv_len < len)
val.bv_len = len;
}
@@ -449,7 +449,7 @@ ss_filter_key(indexer_t *ix, struct berval *val)
struct berval *key = (struct berval *)slapi_ch_calloc(1, sizeof(struct berval));
if (val->bv_len > 0) {
struct berval **keys = NULL;
- auto struct berval *vals[2];
+ struct berval *vals[2];
vals[0] = val;
vals[1] = NULL;
keys = ix->ix_index(ix, vals, NULL);
@@ -477,10 +477,10 @@ ss_filter_keys(indexer_t *ix, struct berval **values)
an empty key definitely implies an absent value.
*/
{
- auto struct berval **keys = NULL;
+ struct berval **keys = NULL;
if (values != NULL) {
- auto size_t n; /* how many substring values */
- auto struct berval **val;
+ size_t n; /* how many substring values */
+ struct berval **val;
for (n = 0, val = values; *val != NULL; ++n, ++val)
;
keys = (struct berval **)slapi_ch_malloc((n + 1) * sizeof(struct berval *));
@@ -497,25 +497,25 @@ static int or_filter_index(Slapi_PBlock *pb);
static int
or_filter_create(Slapi_PBlock *pb)
{
- auto int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; /* failed to initialize */
- auto char *mrOID = NULL;
- auto char *mrTYPE = NULL;
- auto struct berval *mrVALUE = NULL;
- auto or_filter_t * or = NULL;
+ int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; /* failed to initialize */
+ char *mrOID = NULL;
+ char *mrTYPE = NULL;
+ struct berval *mrVALUE = NULL;
+ or_filter_t * or = NULL;
if (!slapi_pblock_get(pb, SLAPI_PLUGIN_MR_OID, &mrOID) && mrOID != NULL &&
!slapi_pblock_get(pb, SLAPI_PLUGIN_MR_TYPE, &mrTYPE) && mrTYPE != NULL &&
!slapi_pblock_get(pb, SLAPI_PLUGIN_MR_VALUE, &mrVALUE) && mrVALUE != NULL) {
- auto size_t len = mrVALUE->bv_len;
- auto indexer_t *ix = NULL;
- auto int op = SLAPI_OP_EQUAL;
- auto struct berval bv;
- auto int reusable = MRF_ANY_TYPE;
+ size_t len = mrVALUE->bv_len;
+ indexer_t *ix = NULL;
+ int op = SLAPI_OP_EQUAL;
+ struct berval bv;
+ int reusable = MRF_ANY_TYPE;
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
"or_filter_create - (oid %s; type %s)\n", mrOID, mrTYPE);
if (len > 1 && (ix = indexer_create(mrOID)) != NULL) {
- auto char *val = mrVALUE->bv_val;
+ char *val = mrVALUE->bv_val;
switch (val[0]) {
case '=':
break;
@@ -537,7 +537,7 @@ or_filter_create(Slapi_PBlock *pb)
bv.bv_val = (len > 0) ? val : NULL;
} else { /* mrOID does not identify an ordering rule. */
/* Is it an ordering rule OID with a relational operator suffix? */
- auto size_t oidlen = strlen(mrOID);
+ size_t oidlen = strlen(mrOID);
if (oidlen > 2 && mrOID[oidlen - 2] == '.') {
op = atoi(mrOID + oidlen - 1);
switch (op) {
@@ -547,7 +547,7 @@ or_filter_create(Slapi_PBlock *pb)
case SLAPI_OP_GREATER_OR_EQUAL:
case SLAPI_OP_GREATER:
case SLAPI_OP_SUBSTRING: {
- auto char *or_oid = slapi_ch_strdup(mrOID);
+ char *or_oid = slapi_ch_strdup(mrOID);
or_oid[oidlen - 2] = '\0';
ix = indexer_create(or_oid);
if (ix != NULL) {
@@ -575,7 +575,7 @@ or_filter_create(Slapi_PBlock *pb)
or->or_values[1] = NULL;
}
{
- auto struct berval **val = or->or_values;
+ struct berval **val = or->or_values;
if (val)
for (; *val; ++val) {
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
@@ -607,7 +607,7 @@ or_filter_create(Slapi_PBlock *pb)
static indexer_t *
op_indexer_get(Slapi_PBlock *pb)
{
- auto void *obj = NULL;
+ void *obj = NULL;
if (!slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &obj)) {
return (indexer_t *)obj;
}
@@ -617,7 +617,7 @@ op_indexer_get(Slapi_PBlock *pb)
static int
op_indexer_destroy(Slapi_PBlock *pb)
{
- auto indexer_t *ix = op_indexer_get(pb);
+ indexer_t *ix = op_indexer_get(pb);
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
"op_indexer_destroy - (%p)\n", (void *)ix);
if (ix != NULL) {
@@ -632,8 +632,8 @@ static int
op_index_entry(Slapi_PBlock *pb)
/* Compute collation keys (when writing an entry). */
{
- auto indexer_t *ix = op_indexer_get(pb);
- auto int rc;
+ indexer_t *ix = op_indexer_get(pb);
+ int rc;
struct berval **values;
if (ix != NULL && ix->ix_index != NULL &&
!slapi_pblock_get(pb, SLAPI_PLUGIN_MR_VALUES, &values) &&
@@ -651,10 +651,10 @@ static int
op_index_search(Slapi_PBlock *pb)
/* Compute collation keys (when searching for entries). */
{
- auto or_filter_t * or = or_filter_get(pb);
- auto int rc = LDAP_OPERATIONS_ERROR;
+ or_filter_t * or = or_filter_get(pb);
+ int rc = LDAP_OPERATIONS_ERROR;
if (or != NULL) {
- auto indexer_t *ix = or->or_indexer;
+ indexer_t *ix = or->or_indexer;
struct berval **values;
if (or->or_index_keys == NULL && ix != NULL && ix->ix_index != NULL && !slapi_pblock_get(pb, SLAPI_PLUGIN_MR_VALUES, &values)) {
or->or_index_keys = slapi_ch_bvecdup(ix->ix_index(ix, values, NULL));
@@ -688,7 +688,7 @@ ss_indexer_free(ss_indexer_t *ss)
static ss_indexer_t *
ss_indexer_get(Slapi_PBlock *pb)
{
- auto void *obj = NULL;
+ void *obj = NULL;
if (!slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &obj)) {
return (ss_indexer_t *)obj;
}
@@ -698,7 +698,7 @@ ss_indexer_get(Slapi_PBlock *pb)
static void
ss_indexer_destroy(Slapi_PBlock *pb)
{
- auto ss_indexer_t *ss = ss_indexer_get(pb);
+ ss_indexer_t *ss = ss_indexer_get(pb);
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
"ss_indexer_destroy - (%p)\n", (void *)ss);
if (ss) {
@@ -722,9 +722,9 @@ static int
long_enough(struct berval *bval, size_t enough)
{
if (bval) {
- auto size_t len = 0;
- auto char *next = bval->bv_val;
- auto char *last = next + bval->bv_len;
+ size_t len = 0;
+ char *next = bval->bv_val;
+ char *last = next + bval->bv_len;
while (next < last) {
LDAP_UTF8INC(next);
if (++len >= enough) {
@@ -742,23 +742,23 @@ static int
ss_index_entry(Slapi_PBlock *pb)
/* Compute substring index keys (when writing an entry). */
{
- auto int rc = LDAP_OPERATIONS_ERROR;
- auto size_t substringsLen = 0;
+ int rc = LDAP_OPERATIONS_ERROR;
+ size_t substringsLen = 0;
struct berval **values;
- auto ss_indexer_t *ss = ss_indexer_get(pb);
- auto indexer_t *ix = ss ? ss->ss_indexer : NULL;
+ ss_indexer_t *ss = ss_indexer_get(pb);
+ indexer_t *ix = ss ? ss->ss_indexer : NULL;
if (ix != NULL && ix->ix_index != NULL &&
!slapi_pblock_get(pb, SLAPI_PLUGIN_MR_VALUES, &values)) {
- auto struct berval *substrings = NULL;
- auto struct berval **prefixes = NULL;
- auto struct berval **value;
+ struct berval *substrings = NULL;
+ struct berval **prefixes = NULL;
+ struct berval **value;
for (value = values; *value != NULL; ++value) {
- auto struct berval substring;
+ struct berval substring;
substring.bv_val = (*value)->bv_val;
substring.bv_len = (*value)->bv_len;
if (long_enough(&substring, SS_INDEX_LENGTH - 1)) {
- auto struct berval *prefix = &ss_index_initial;
- auto size_t offset;
+ struct berval *prefix = &ss_index_initial;
+ size_t offset;
for (offset = 0; 1; ++offset) {
++substringsLen;
substrings = (struct berval *)
@@ -782,9 +782,9 @@ ss_index_entry(Slapi_PBlock *pb)
}
}
if (substrings != NULL) {
- auto struct berval **vector = (struct berval **)
+ struct berval **vector = (struct berval **)
slapi_ch_malloc((substringsLen + 1) * sizeof(struct berval *));
- auto size_t i;
+ size_t i;
for (i = 0; i < substringsLen; ++i)
vector[i] = &(substrings[i]);
vector[substringsLen] = NULL;
@@ -804,21 +804,21 @@ static int
ss_index_search(Slapi_PBlock *pb)
/* Compute substring search keys (when searching for entries). */
{
- auto int rc = LDAP_OPERATIONS_ERROR;
- auto or_filter_t * or = or_filter_get(pb);
+ int rc = LDAP_OPERATIONS_ERROR;
+ or_filter_t * or = or_filter_get(pb);
if (or) {
if (or->or_index_keys == NULL /* not yet computed */ &&
or->or_values && or->or_indexer && or->or_indexer->ix_index) {
- auto size_t substringsLen = 0;
- auto struct berval *substrings = NULL;
- auto struct berval **prefixes = NULL;
- auto struct berval **value;
+ size_t substringsLen = 0;
+ struct berval *substrings = NULL;
+ struct berval **prefixes = NULL;
+ struct berval **value;
for (value = or->or_values; *value != NULL; ++value) {
- auto size_t offset;
- auto struct berval substring;
+ size_t offset;
+ struct berval substring;
substring.bv_val = (*value)->bv_val;
for (offset = 0; 1; ++offset, LDAP_UTF8INC(substring.bv_val)) {
- auto struct berval *prefix = NULL;
+ struct berval *prefix = NULL;
substring.bv_len = (*value)->bv_len - (substring.bv_val - (*value)->bv_val);
if (offset == 0 && value == or->or_values) {
if (long_enough(&substring, SS_INDEX_LENGTH - 1)) {
@@ -845,10 +845,10 @@ ss_index_search(Slapi_PBlock *pb)
}
}
if (substrings != NULL) {
- auto indexer_t *ix = or->or_indexer;
- auto struct berval **vector = (struct berval **)
+ indexer_t *ix = or->or_indexer;
+ struct berval **vector = (struct berval **)
slapi_ch_malloc((substringsLen + 1) * sizeof(struct berval *));
- auto size_t i;
+ size_t i;
for (i = 0; i < substringsLen; ++i)
vector[i] = &(substrings[i]);
vector[substringsLen] = NULL;
@@ -872,10 +872,10 @@ static int
ss_indexable(struct berval **values)
/* at least one of the values is long enough to index */
{
- auto struct berval **val = values;
+ struct berval **val = values;
if (val)
for (; *val; ++val) {
- auto struct berval value;
+ struct berval value;
value.bv_val = (*val)->bv_val;
value.bv_len = (*val)->bv_len;
if (val == values) { /* initial */
@@ -899,12 +899,12 @@ static int
or_filter_index(Slapi_PBlock *pb)
/* Return an indexer and values that accelerate the given filter. */
{
- auto or_filter_t * or = or_filter_get(pb);
- auto int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
- auto IFP mrINDEX_FN = NULL;
- auto struct berval **mrVALUES = NULL;
- auto char *mrOID = NULL;
- auto int mrQUERY_OPERATOR;
+ or_filter_t * or = or_filter_get(pb);
+ int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
+ int32_t (*mrINDEX_FN)(Slapi_PBlock *) = NULL;
+ struct berval **mrVALUES = NULL;
+ char *mrOID = NULL;
+ int mrQUERY_OPERATOR;
if (or && or->or_indexer && or->or_indexer->ix_index) {
switch (or->or_op) {
case SLAPI_OP_LESS:
@@ -920,7 +920,7 @@ or_filter_index(Slapi_PBlock *pb)
case SLAPI_OP_SUBSTRING:
if (ss_indexable(or->or_values)) {
if (or->or_oid == NULL) {
- auto const size_t len = strlen(or->or_indexer->ix_oid);
+ const size_t len = strlen(or->or_indexer->ix_oid);
or->or_oid = slapi_ch_malloc(len + 3);
memcpy(or->or_oid, or->or_indexer->ix_oid, len);
sprintf(or->or_oid + len, ".%1i", SLAPI_OP_SUBSTRING);
@@ -952,15 +952,15 @@ or_filter_index(Slapi_PBlock *pb)
static int
or_indexer_create(Slapi_PBlock *pb)
{
- auto int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; /* failed to initialize */
- auto char *mrOID = NULL;
- auto void *mrOBJECT = NULL;
+ int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; /* failed to initialize */
+ char *mrOID = NULL;
+ void *mrOBJECT = NULL;
if (slapi_pblock_get(pb, SLAPI_PLUGIN_MR_OID, &mrOID) || mrOID == NULL) {
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
"or_indexer_create - No OID parameter\n");
} else {
- auto indexer_t *ix = indexer_create(mrOID);
- auto char *mrTYPE = NULL;
+ indexer_t *ix = indexer_create(mrOID);
+ char *mrTYPE = NULL;
slapi_pblock_get(pb, SLAPI_PLUGIN_MR_TYPE, &mrTYPE);
slapi_log_err(SLAPI_LOG_FILTER, "or_indexer_create", "(oid %s; type %s)\n",
mrOID, mrTYPE ? mrTYPE : "<NULL>");
@@ -977,14 +977,14 @@ or_indexer_create(Slapi_PBlock *pb)
}
} else { /* mrOID does not identify an ordering rule. */
/* Is it an ordering rule OID with the substring suffix? */
- auto size_t oidlen = strlen(mrOID);
+ size_t oidlen = strlen(mrOID);
if (oidlen > 2 && mrOID[oidlen - 2] == '.' &&
atoi(mrOID + oidlen - 1) == SLAPI_OP_SUBSTRING) {
- auto char *or_oid = slapi_ch_strdup(mrOID);
+ char *or_oid = slapi_ch_strdup(mrOID);
or_oid[oidlen - 2] = '\0';
ix = indexer_create(or_oid);
if (ix != NULL) {
- auto ss_indexer_t *ss = (ss_indexer_t *)slapi_ch_malloc(sizeof(ss_indexer_t));
+ ss_indexer_t *ss = (ss_indexer_t *)slapi_ch_malloc(sizeof(ss_indexer_t));
ss->ss_indexer = ix;
oidlen = strlen(ix->ix_oid);
ss->ss_oid = slapi_ch_malloc(oidlen + 3);
diff --git a/ldap/servers/plugins/pwdstorage/md5c.c b/ldap/servers/plugins/pwdstorage/md5c.c
index e7085a68d..8075dcb80 100644
--- a/ldap/servers/plugins/pwdstorage/md5c.c
+++ b/ldap/servers/plugins/pwdstorage/md5c.c
@@ -1,6 +1,6 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2005-2025 Red Hat, Inc.
* All rights reserved.
*
* License: GPL (version 3 or any later version).
@@ -69,20 +69,17 @@ static unsigned char PADDING[64] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-/* F, G, H and I are basic MD5 functions.
- */
+/* F, G, H and I are basic MD5 functions. */
#define F(x, y, z) (((x) & (y)) | ((~(x)) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~(z))))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~(z))))
-/* ROTATE_LEFT rotates x left n bits.
- */
+/* ROTATE_LEFT rotates x left n bits. */
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
-Rotation is separate from addition to prevent recomputation.
- */
+ * Rotation is separate from addition to prevent recomputation. */
#define FF(a, b, c, d, x, s, ac) \
{ \
(a) += F((b), (c), (d)) + (x) + (UINT4)(ac); \
@@ -108,14 +105,11 @@ Rotation is separate from addition to prevent recomputation.
(a) += (b); \
}
-/* MD5 initialization. Begins an MD5 operation, writing a new context.
- */
-void mta_MD5Init(context)
- mta_MD5_CTX *context; /* context */
+/* MD5 initialization. Begins an MD5 operation, writing a new context. */
+void mta_MD5Init(mta_MD5_CTX *context)
{
context->count[0] = context->count[1] = 0;
- /* Load magic initialization constants.
-*/
+ /* Load magic initialization constants */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
@@ -123,13 +117,9 @@ void mta_MD5Init(context)
}
/* MD5 block update operation. Continues an MD5 message-digest
- operation, processing another message block, and updating the
- context.
- */
-void mta_MD5Update(context, input, inputLen)
- mta_MD5_CTX *context; /* context */
-const unsigned char *input; /* input block */
-unsigned int inputLen; /* length of input block */
+ * operation, processing another message block, and updating the
+ * context. */
+void mta_MD5Update(mta_MD5_CTX *context, const unsigned char *input, unsigned int inputLen)
{
unsigned int i, index, partLen;
@@ -143,8 +133,7 @@ unsigned int inputLen; /* length of input block */
partLen = 64 - index;
- /* Transform as many times as possible.
-*/
+ /* Transform as many times as possible. */
if (inputLen >= partLen) {
MD5_memcpy((POINTER)&context->buffer[index], (POINTER)input, partLen);
MD5Transform(context->state, context->buffer);
@@ -162,10 +151,8 @@ unsigned int inputLen; /* length of input block */
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
- the message digest and zeroizing the context.
- */
-void mta_MD5Final(digest, context) unsigned char digest[16]; /* message digest */
-mta_MD5_CTX *context; /* context */
+ * the message digest and zeroizing the context. */
+void mta_MD5Final(unsigned char digest[16], mta_MD5_CTX *context)
{
unsigned char bits[8];
unsigned int index, padLen;
@@ -173,8 +160,7 @@ mta_MD5_CTX *context; /* context */
/* Save number of bits */
Encode(bits, context->count, 8);
- /* Pad out to 56 mod 64.
-*/
+ /* Pad out to 56 mod 64.*/
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
mta_MD5Update(context, PADDING, padLen);
@@ -185,16 +171,12 @@ mta_MD5_CTX *context; /* context */
/* Store state in digest */
Encode(digest, context->state, 16);
- /* Zeroize sensitive information.
-*/
+ /* Zeroize sensitive information.*/
MD5_memset((POINTER)context, 0, sizeof(*context));
}
-/* MD5 basic transformation. Transforms state based on block.
- */
-static void MD5Transform(state, block)
- UINT4 state[4];
-const unsigned char block[64];
+/* MD5 basic transformation. Transforms state based on block. */
+static void MD5Transform(UINT4 state[4], const unsigned char block[64])
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
@@ -277,17 +259,13 @@ const unsigned char block[64];
state[2] += c;
state[3] += d;
- /* Zeroize sensitive information.
-*/
+ /* Zeroize sensitive information. */
MD5_memset((POINTER)x, 0, sizeof(x));
}
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
- a multiple of 4.
- */
-static void Encode(output, input, len) unsigned char *output;
-const UINT4 *input;
-unsigned int len;
+ * a multiple of 4. */
+static void Encode(unsigned char *output, const UINT4 *input, unsigned int len)
{
unsigned int i, j;
@@ -300,12 +278,8 @@ unsigned int len;
}
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
- a multiple of 4.
- */
-static void Decode(output, input, len)
- UINT4 *output;
-const unsigned char *input;
-unsigned int len;
+ * a multiple of 4. */
+static void Decode(UINT4 *output, const unsigned char *input, unsigned int len)
{
unsigned int i, j;
@@ -314,13 +288,8 @@ unsigned int len;
(((UINT4)input[j + 2]) << 16) | (((UINT4)input[j + 3]) << 24);
}
-/* Note: Replace "for loop" with standard memcpy if possible.
- */
-
-static void MD5_memcpy(output, input, len)
- POINTER output;
-const POINTER input;
-unsigned int len;
+/* Note: Replace "for loop" with standard memcpy if possible. */
+static void MD5_memcpy(POINTER output, const POINTER input, unsigned int len)
{
unsigned int i;
@@ -328,12 +297,8 @@ unsigned int len;
output[i] = input[i];
}
-/* Note: Replace "for loop" with standard memset if possible.
- */
-static void MD5_memset(output, value, len)
- POINTER output;
-int value;
-unsigned int len;
+/* Note: Replace "for loop" with standard memset if possible. */
+static void MD5_memset(POINTER output, int value, unsigned int len)
{
unsigned int i;
diff --git a/ldap/servers/plugins/roles/roles_cache.c b/ldap/servers/plugins/roles/roles_cache.c
index c6946a853..16a0bef80 100644
--- a/ldap/servers/plugins/roles/roles_cache.c
+++ b/ldap/servers/plugins/roles/roles_cache.c
@@ -156,8 +156,8 @@ static int roles_is_inscope(Slapi_Entry *entry_to_check, role_object *this_role)
static void berval_set_string(struct berval *bv, const char *string);
static void roles_cache_role_def_delete(roles_cache_def *role_def);
static void roles_cache_role_def_free(roles_cache_def *role_def);
-static void roles_cache_role_object_free(role_object *this_role);
-static int roles_cache_role_object_nested_free(role_object_nested *this_role);
+static int roles_cache_role_object_free(caddr_t this_role);
+static int roles_cache_role_object_nested_free(caddr_t this_role);
static int roles_cache_dump(caddr_t data, caddr_t arg);
static int roles_cache_add_entry_cb(Slapi_Entry *e, void *callback_data);
static void roles_cache_result_cb(int rc, void *callback_data);
@@ -578,11 +578,11 @@ roles_cache_update(roles_cache_def *suffix_to_update)
if ((operation == SLAPI_OPERATION_MODIFY) ||
(operation == SLAPI_OPERATION_DELETE)) {
- to_delete = (role_object *)avl_delete(&(suffix_to_update->avl_tree), dn, roles_cache_find_node);
- roles_cache_role_object_free(to_delete);
+ to_delete = (role_object *)avl_delete(&(suffix_to_update->avl_tree), (caddr_t)dn, roles_cache_find_node);
+ roles_cache_role_object_free((caddr_t)to_delete);
to_delete = NULL;
if (slapi_is_loglevel_set(SLAPI_LOG_PLUGIN)) {
- avl_apply(suffix_to_update->avl_tree, (IFP)roles_cache_dump, &rc, -1, AVL_INORDER);
+ avl_apply(suffix_to_update->avl_tree, roles_cache_dump, &rc, -1, AVL_INORDER);
}
}
if ((operation == SLAPI_OPERATION_MODIFY) ||
@@ -1510,7 +1510,7 @@ roles_cache_listroles_ext(vattr_context *c, Slapi_Entry *entry, int return_value
/* XXX really need a mutex for this read operation ? */
slapi_rwlock_rdlock(roles_cache->cache_lock);
- avl_apply(roles_cache->avl_tree, (IFP)roles_cache_build_nsrole, &arg, -1, AVL_INORDER);
+ avl_apply(roles_cache->avl_tree, roles_cache_build_nsrole, &arg, -1, AVL_INORDER);
slapi_rwlock_unlock(roles_cache->cache_lock);
@@ -1627,7 +1627,7 @@ roles_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present)
}
slapi_rwlock_unlock(global_lock);
- this_role = (role_object *)avl_find(roles_cache->avl_tree, role_dn, (IFP)roles_cache_find_node);
+ this_role = (role_object *)avl_find(roles_cache->avl_tree, (caddr_t)role_dn, roles_cache_find_node);
/* MAB: For some reason the assumption made by this function (the role exists and is in scope)
* does not seem to be true... this_role might be NULL after the avl_find call (is the avl_tree
@@ -1765,7 +1765,7 @@ roles_is_entry_member_of_object_ext(vattr_context *c, caddr_t data, caddr_t argu
case ROLE_TYPE_NESTED: {
/* Go through the tree of the nested DNs */
get_nsrole->hint++;
- avl_apply(this_role->avl_tree, (IFP)roles_check_nested, get_nsrole, 0, AVL_INORDER);
+ avl_apply(this_role->avl_tree, roles_check_nested, get_nsrole, 0, AVL_INORDER);
get_nsrole->hint--;
/* kexcoff?? */
@@ -1901,12 +1901,12 @@ roles_check_nested(caddr_t data, caddr_t arg)
}
if (slapi_is_loglevel_set(SLAPI_LOG_PLUGIN)) {
- avl_apply(roles_cache->avl_tree, (IFP)roles_cache_dump, &rc, -1, AVL_INORDER);
+ avl_apply(roles_cache->avl_tree, roles_cache_dump, &rc, -1, AVL_INORDER);
}
this_role = (role_object *)avl_find(roles_cache->avl_tree,
- current_nested_role->dn,
- (IFP)roles_cache_find_node);
+ (caddr_t)current_nested_role->dn,
+ roles_cache_find_node);
if (this_role == NULL) {
/* the nested role doesn't exist */
@@ -2026,7 +2026,7 @@ roles_cache_role_def_free(roles_cache_def *role_def)
slapi_lock_mutex(role_def->stop_lock);
- avl_free(role_def->avl_tree, (IFP)roles_cache_role_object_free);
+ avl_free(role_def->avl_tree, roles_cache_role_object_free);
slapi_sdn_free(&(role_def->suffix_dn));
slapi_destroy_rwlock(role_def->cache_lock);
role_def->cache_lock = NULL;
@@ -2057,14 +2057,16 @@ roles_cache_role_def_free(roles_cache_def *role_def)
/* roles_cache_role_object_free
----------------------------
*/
-static void
-roles_cache_role_object_free(role_object *this_role)
+static int
+roles_cache_role_object_free(caddr_t tr)
{
+ role_object *this_role = (role_object *)tr;
+
slapi_log_err(SLAPI_LOG_PLUGIN,
ROLES_PLUGIN_SUBSYSTEM, "--> roles_cache_role_object_free\n");
if (this_role == NULL) {
- return;
+ return 0;
}
switch (this_role->type) {
@@ -2094,14 +2096,17 @@ roles_cache_role_object_free(role_object *this_role)
slapi_log_err(SLAPI_LOG_PLUGIN,
ROLES_PLUGIN_SUBSYSTEM, "<-- roles_cache_role_object_free\n");
+ return 0;
}
/* roles_cache_role_object_nested_free
------------------------------------
*/
static int
-roles_cache_role_object_nested_free(role_object_nested *this_role)
+roles_cache_role_object_nested_free(caddr_t tr)
{
+ role_object_nested *this_role = (role_object_nested *)tr;
+
slapi_log_err(SLAPI_LOG_PLUGIN,
ROLES_PLUGIN_SUBSYSTEM, "--> roles_cache_role_object_nested_free\n");
diff --git a/ldap/servers/plugins/syntaxes/bin.c b/ldap/servers/plugins/syntaxes/bin.c
index ab67cecf9..f793f3539 100644
--- a/ldap/servers/plugins/syntaxes/bin.c
+++ b/ldap/servers/plugins/syntaxes/bin.c
@@ -139,7 +139,8 @@ static struct mr_plugin_def mr_plugin_table[] = {
NULL,
bin_compare,
NULL /* mr_normalize */
- }};
+ }
+};
/*
certificateExactMatch
certificateListExactMatch
diff --git a/ldap/servers/plugins/syntaxes/syntax.h b/ldap/servers/plugins/syntaxes/syntax.h
index c743532c1..7e53c3586 100644
--- a/ldap/servers/plugins/syntaxes/syntax.h
+++ b/ldap/servers/plugins/syntaxes/syntax.h
@@ -104,21 +104,22 @@ struct mr_plugin_def
Slapi_PluginDesc mr_plg_desc; /* for SLAPI_PLUGIN_DESCRIPTION */
const char **mr_names; /* list of oid and names, NULL terminated SLAPI_PLUGIN_MR_NAMES */
/* these are optional for new style mr plugins */
- IFP mr_filter_create; /* old style factory function SLAPI_PLUGIN_MR_FILTER_CREATE_FN */
- IFP mr_indexer_create; /* old style factory function SLAPI_PLUGIN_MR_INDEXER_CREATE_FN */
+ int32_t (*mr_filter_create)(Slapi_PBlock *); /* old style factory function SLAPI_PLUGIN_MR_FILTER_CREATE_FN */
+ int32_t (*mr_indexer_create)(Slapi_PBlock *); /* old style factory function SLAPI_PLUGIN_MR_INDEXER_CREATE_FN */
/* new style syntax plugin functions */
/* not all functions will apply to all matching rule types */
/* e.g. a SUBSTR rule will not have a filter_ava func */
- IFP mr_filter_ava; /* SLAPI_PLUGIN_MR_FILTER_AVA */
- IFP mr_filter_sub; /* SLAPI_PLUGIN_MR_FILTER_SUB */
- IFP mr_values2keys; /* SLAPI_PLUGIN_MR_VALUES2KEYS */
- IFP mr_assertion2keys_ava; /* SLAPI_PLUGIN_MR_ASSERTION2KEYS_AVA */
- IFP mr_assertion2keys_sub; /* SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB */
- IFP mr_compare; /* SLAPI_PLUGIN_MR_COMPARE - only for ORDERING */
- VFPV mr_normalize;
+ int32_t (*mr_filter_ava)(Slapi_PBlock *, struct berval *, Slapi_Value **, int32_t, Slapi_Value **); /* SLAPI_PLUGIN_MR_FILTER_AVA */
+ int32_t (*mr_filter_sub)(Slapi_PBlock *, char *, char **, char *, Slapi_Value **); /* SLAPI_PLUGIN_MR_FILTER_SUB */
+ int32_t (*mr_values2keys)(Slapi_PBlock *, Slapi_Value **, Slapi_Value ***, int32_t); /* SLAPI_PLUGIN_MR_VALUES2KEYS */
+ int32_t (*mr_assertion2keys_ava)(Slapi_PBlock *, Slapi_Value *, Slapi_Value ***, int32_t);
+ int32_t (*mr_assertion2keys_sub)(Slapi_PBlock *, char *, char **, char *, Slapi_Value ***); /* SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB */
+ int32_t (*mr_compare)(struct berval *, struct berval *); /* SLAPI_PLUGIN_MR_COMPARE - only for ORDERING */
+ void (*mr_normalize)(Slapi_PBlock *, char *, int32_t, char **);
};
-int syntax_register_matching_rule_plugins(struct mr_plugin_def mr_plugin_table[], size_t mr_plugin_table_size, IFP matching_rule_plugin_init);
+int syntax_register_matching_rule_plugins(struct mr_plugin_def mr_plugin_table[], size_t mr_plugin_table_size,
+ int32_t (*matching_rule_plugin_init)(Slapi_PBlock *));
int syntax_matching_rule_plugin_init(Slapi_PBlock *pb, struct mr_plugin_def mr_plugin_table[], size_t mr_plugin_table_size);
#endif
diff --git a/ldap/servers/plugins/syntaxes/syntax_common.c b/ldap/servers/plugins/syntaxes/syntax_common.c
index 821d4d557..7407f0b9c 100644
--- a/ldap/servers/plugins/syntaxes/syntax_common.c
+++ b/ldap/servers/plugins/syntaxes/syntax_common.c
@@ -16,7 +16,7 @@ int
syntax_register_matching_rule_plugins(
struct mr_plugin_def mr_plugin_table[],
size_t mr_plugin_table_size,
- IFP matching_rule_plugin_init)
+ int32_t (*matching_rule_plugin_init)(Slapi_PBlock *))
{
int rc = -1;
size_t ii;
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index 6bbcb05ac..e03ea6478 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -608,10 +608,11 @@ attr_syntax_exists(const char *attr_name)
static void default_dirstring_normalize_int(char *s, int trim_spaces);
-static int
-default_dirstring_filter_ava(struct berval *bvfilter __attribute__((unused)),
- Slapi_Value **bvals __attribute__((unused)),
- int ftype __attribute__((unused)),
+static int32_t
+default_dirstring_filter_ava(Slapi_PBlock *pb __attribute__((unused)),
+ const struct berval *bv __attribute__((unused)),
+ Slapi_Value **vals __attribute__((unused)),
+ int32_t ftype __attribute__((unused)),
Slapi_Value **retVal __attribute__((unused)))
{
return (0);
@@ -621,7 +622,7 @@ static int
default_dirstring_values2keys(Slapi_PBlock *pb __attribute__((unused)),
Slapi_Value **bvals,
Slapi_Value ***ivals,
- int ftype)
+ int32_t ftype)
{
int numbvals = 0;
Slapi_Value **nbvals, **nbvlp;
@@ -664,11 +665,11 @@ default_dirstring_values2keys(Slapi_PBlock *pb __attribute__((unused)),
return (0);
}
-static int
+static int32_t
default_dirstring_assertion2keys_ava(Slapi_PBlock *pb __attribute__((unused)),
Slapi_Value *val __attribute__((unused)),
Slapi_Value ***ivals __attribute__((unused)),
- int ftype __attribute__((unused)))
+ int32_t ftype __attribute__((unused)))
{
return (0);
}
@@ -759,11 +760,11 @@ attr_syntax_default_plugin(const char *nameoroid)
pi->plg_syntax_oid = slapi_ch_strdup(nameoroid);
- pi->plg_syntax_filter_ava = (IFP)default_dirstring_filter_ava;
- pi->plg_syntax_values2keys = (IFP)default_dirstring_values2keys;
- pi->plg_syntax_assertion2keys_ava = (IFP)default_dirstring_assertion2keys_ava;
+ pi->plg_syntax_filter_ava = default_dirstring_filter_ava;
+ pi->plg_syntax_values2keys = default_dirstring_values2keys;
+ pi->plg_syntax_assertion2keys_ava = default_dirstring_assertion2keys_ava;
pi->plg_syntax_compare = (IFP)default_dirstring_cmp;
- pi->plg_syntax_normalize = (VFPV)default_dirstring_normalize;
+ pi->plg_syntax_normalize = default_dirstring_normalize;
return (pi);
}
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 fe8460ed8..68759fe52 100644
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
@@ -1321,8 +1321,10 @@ bdb_update_subordinatecounts(backend *be, ImportJob *job, DB_TXN *txn)
/* Function used to gather a list of indexed attrs */
static int
-bdb_import_attr_callback(void *node, void *param)
+bdb_import_attr_callback(caddr_t n, caddr_t p)
{
+ void *node = (void *)n;
+ void *param = (void *)p;
ImportJob *job = (ImportJob *)param;
struct attrinfo *a = (struct attrinfo *)node;
@@ -2242,9 +2244,9 @@ bdb_public_bdb_import_main(void *arg)
/* Here, we get an AVL tree which contains nodes for all attributes
* in the schema. Given this tree, we need to identify those nodes
* which are marked for indexing. */
- avl_apply(job->inst->inst_attrs, (IFP)bdb_import_attr_callback,
+ avl_apply(job->inst->inst_attrs, bdb_import_attr_callback,
(caddr_t)job, -1, AVL_INORDER);
- vlv_getindices((IFP)bdb_import_attr_callback, (void *)job, be);
+ vlv_getindices(bdb_import_attr_callback, (void *)job, be);
}
/* Determine how much index buffering space to allocate to each index */
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import.c
index 5f8e36cdc..14f059b05 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import.c
@@ -293,9 +293,11 @@ dbmdb_update_subordinatecounts(backend *be, ImportJob *job, dbi_txn_t *txn)
}
/* Function used to gather a list of indexed attrs */
-static int
-dbmdb_import_attr_callback(void *node, void *param)
+static int32_t
+dbmdb_import_attr_callback(caddr_t n, caddr_t p)
{
+ void *node = (void *)n;
+ void *param = (void *)p;
ImportJob *job = (ImportJob *)param;
struct attrinfo *a = (struct attrinfo *)node;
@@ -738,11 +740,11 @@ dbmdb_import_all_done(ImportJob *job, int ret)
/* Bring backend online again:
* In lmdb case, the import framework is also used for reindexing
* while in bdb case reindexing uses its own code.
- * So dbmdb_import_all_done is called either after
+ * So dbmdb_import_all_done is called either after
* dbmdb_ldif2db or after dbmdb_db2index while
* bdb_import_all_done is only called after bdb_ldif2db.
*
- * dbmdb_db2index uses instance_set_busy_and_readonly
+ * dbmdb_db2index uses instance_set_busy_and_readonly
* while dbmdb_ldif2db uses slapi_mtn_be_disable
* and these functions have to be reverted accordingly.
*/
@@ -771,9 +773,12 @@ dbmdb_import_all_done(ImportJob *job, int ret)
/* vlv_getindices callback that truncate vlv index (in reindex case) */
static int
-truncate_index_dbi(struct attrinfo *ai, ImportCtx_t *ctx)
+truncate_index_dbi(caddr_t a, caddr_t c)
{
+ struct attrinfo *ai = (struct attrinfo *)a;
+ ImportCtx_t *ctx = (ImportCtx_t *)c;
int rc = 0;
+
if (is_reindexed_attr(ai->ai_type, ctx, ctx->indexVlvs)) {
backend *be = ctx->job->inst->inst_be;
dbmdb_dbi_t *dbi = NULL;
@@ -828,9 +833,9 @@ dbmdb_public_dbmdb_import_main(void *arg)
/* Here, we get an AVL tree which contains nodes for all attributes
* in the schema. Given this tree, we need to identify those nodes
* which are marked for indexing. */
- avl_apply(job->inst->inst_attrs, (IFP)dbmdb_import_attr_callback,
+ avl_apply(job->inst->inst_attrs, dbmdb_import_attr_callback,
(caddr_t)job, -1, AVL_INORDER);
- vlv_getindices((IFP)dbmdb_import_attr_callback, (void *)job, be);
+ vlv_getindices(dbmdb_import_attr_callback, (void *)job, be);
}
/* insure all dbi get open */
@@ -851,7 +856,7 @@ dbmdb_public_dbmdb_import_main(void *arg)
pthread_mutex_unlock(&job->wire_lock);
break;
case IM_INDEX:
- vlv_getindices((IFP)truncate_index_dbi, ctx, job->inst->inst_be);
+ vlv_getindices(truncate_index_dbi, ctx, job->inst->inst_be);
default:
break;
}
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
index eabc137a7..abbecad4b 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c
@@ -2883,7 +2883,7 @@ look4indexinfo(ImportCtx_t *ctx, const char *attrname)
{
MdbIndexInfo_t searched_mii = {0};
searched_mii.name = (char*) attrname;
- return (MdbIndexInfo_t *)avl_find(ctx->indexes, &searched_mii, cmp_mii);
+ return (MdbIndexInfo_t *)avl_find(ctx->indexes, (caddr_t)&searched_mii, cmp_mii);
}
/* Prepare key and data for updating parentid or ancestorid indexes */
@@ -3447,7 +3447,7 @@ dbmdb_add_import_index(ImportCtx_t *ctx, const char *name, IndexInfo *ii)
DBG_LOG(DBGMDB_LEVEL_OTHER,"Calling dbmdb_open_dbi_from_filename for %s flags = 0x%x", mii->name, dbi_flags);
dbmdb_open_dbi_from_filename(&mii->dbi, job->inst->inst_be, mii->name, mii->ai, dbi_flags);
- avl_insert(&ctx->indexes, mii, cmp_mii, NULL);
+ avl_insert(&ctx->indexes, (caddr_t)mii, cmp_mii, NULL);
}
/*
@@ -3473,7 +3473,7 @@ dbmdb_open_redirect_db(ImportCtx_t *ctx)
mii->ai = ai;
mii->flags = MII_SKIP | MII_NOATTR;
dbmdb_open_dbi_from_filename(&mii->dbi, be, mii->name, mii->ai, dbi_flags);
- avl_insert(&ctx->indexes, mii, cmp_mii, NULL);
+ avl_insert(&ctx->indexes, (caddr_t)mii, cmp_mii, NULL);
ctx->redirect = mii;
}
@@ -3519,11 +3519,13 @@ dbmdb_build_import_index_list(ImportCtx_t *ctx)
}
-void
-free_ii(MdbIndexInfo_t *ii)
+static int32_t
+free_ii(caddr_t i)
{
+ MdbIndexInfo_t *ii = (MdbIndexInfo_t *)i;
slapi_ch_free_string(&ii->name);
slapi_ch_free((void**)&ii);
+ return 0;
}
/*
@@ -4325,7 +4327,7 @@ dbmdb_free_import_ctx(ImportJob *job)
dbmdb_import_q_destroy(&ctx->bulkq);
slapi_ch_free((void**)&ctx->id2entry->name);
slapi_ch_free((void**)&ctx->id2entry);
- avl_free(ctx->indexes, (IFP) free_ii);
+ avl_free(ctx->indexes, free_ii);
ctx->indexes = NULL;
charray_free(ctx->indexAttrs);
charray_free(ctx->indexVlvs);
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
index 83787931b..f1be4b7b8 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
@@ -333,8 +333,10 @@ int add_dbi(dbi_open_ctx_t *octx, backend *be, const char *fname, int flags)
/* avlapply callback to open/create the dbi needed to handle an index */
static int
-add_index_dbi(struct attrinfo *ai, dbi_open_ctx_t *octx)
+add_index_dbi(caddr_t attr, caddr_t otx)
{
+ struct attrinfo *ai = (struct attrinfo *)attr;
+ dbi_open_ctx_t *octx = (dbi_open_ctx_t *)otx;
int flags = octx->ctx->readonly ? MDB_RDONLY: MDB_CREATE;
char *rcdbname = NULL;
@@ -475,7 +477,7 @@ dbmdb_open_all_files(dbmdb_ctx_t *ctx, backend *be)
}
if (be->vlvSearchList_lock) {
/* vlv search list is initialized so we can use it */
- vlv_getindices((IFP)add_index_dbi, &octx, be);
+ vlv_getindices(add_index_dbi, &octx, be);
} else if (vlv_list) {
char *rcdbname = NULL;
for (size_t i=0; rc == 0 && vlv_list[i]; i++) {
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c
index 52f51713b..bcf3c9ad1 100644
--- a/ldap/servers/slapd/back-ldbm/filterindex.c
+++ b/ldap/servers/slapd/back-ldbm/filterindex.c
@@ -462,7 +462,7 @@ extensible_candidates(
case SLAPI_OP_EQUAL:
case SLAPI_OP_GREATER_OR_EQUAL:
case SLAPI_OP_GREATER: {
- IFP mrINDEX = NULL;
+ int32_t (*mrINDEX)(Slapi_PBlock *) = NULL;
void *mrOBJECT = NULL;
struct berval **mrVALUES = NULL;
char *mrOID = NULL;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attr.c b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
index 30bfd1349..7fe6f1405 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_attr.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
@@ -68,7 +68,7 @@ attrinfo_delete(struct attrinfo **pp)
}
static int
-attrinfo_internal_delete(caddr_t data, caddr_t arg __attribute__((unused)))
+attrinfo_internal_delete(caddr_t data)
{
struct attrinfo *n = (struct attrinfo *)data;
attrinfo_delete(&n);
@@ -85,16 +85,19 @@ attrinfo_deletetree(ldbm_instance *inst)
static int
ainfo_type_cmp(
char *type,
- struct attrinfo *a)
+ caddr_t val)
{
+ struct attrinfo *a = (struct attrinfo *)val;
return (strcasecmp(type, a->ai_type));
}
static int
ainfo_cmp(
- struct attrinfo *a,
- struct attrinfo *b)
+ caddr_t val1,
+ caddr_t val2)
{
+ struct attrinfo *a = (struct attrinfo *)val1;
+ struct attrinfo *b = (struct attrinfo *)val2;
return (strcasecmp(a->ai_type, b->ai_type));
}
@@ -102,7 +105,7 @@ void
attrinfo_delete_from_tree(backend *be, struct attrinfo *ai)
{
ldbm_instance *inst = (ldbm_instance *)be->be_instance_info;
- avl_delete(&inst->inst_attrs, ai, ainfo_cmp);
+ avl_delete(&inst->inst_attrs, (caddr_t)ai, ainfo_cmp);
}
/*
@@ -117,9 +120,12 @@ attrinfo_delete_from_tree(backend *be, struct attrinfo *ai)
static int
ainfo_dup(
- struct attrinfo *a,
- struct attrinfo *b)
+ caddr_t val1,
+ caddr_t val2)
{
+ struct attrinfo *a = (struct attrinfo *)val1;
+ struct attrinfo *b = (struct attrinfo *)val2;
+
/* merge duplicate indexing information */
if (b->ai_indexmask == 0 || b->ai_indexmask == INDEX_OFFLINE) {
a->ai_indexmask = INDEX_OFFLINE; /* turns off all indexes */
@@ -203,7 +209,7 @@ attr_index_parse_idlistsize_values(Slapi_Attr *attr, struct index_idlistsizeinfo
char *lasts = NULL;
char *val;
int syntaxcheck = config_get_syntaxcheck();
- IFP syntax_validate_fn = syntaxcheck ? attr->a_plugin->plg_syntax_validate : NULL;
+ int32_t (*syntax_validate_fn)(struct berval *) = syntaxcheck ? attr->a_plugin->plg_syntax_validate : NULL;
char staticfiltstrbuf[1024]; /* for small filter strings */
char *filtstrbuf = staticfiltstrbuf; /* default if not malloc'd */
size_t filtstrbuflen = sizeof(staticfiltstrbuf); /* default if not malloc'd */
@@ -880,7 +886,7 @@ attr_index_config(
* It would improve speed to save the indexer, for future use.
* But, for simplicity, we destroy it now:
*/
- IFP mrDESTROY = NULL;
+ int32_t (*mrDESTROY)(Slapi_PBlock *) = NULL;
if (!slapi_pblock_get(pb, SLAPI_PLUGIN_DESTROY_FN, &mrDESTROY) &&
mrDESTROY != NULL) {
mrDESTROY(pb);
@@ -941,7 +947,7 @@ attr_index_config(
}
}
- if (avl_insert(&inst->inst_attrs, a, ainfo_cmp, ainfo_dup) != 0) {
+ if (avl_insert(&inst->inst_attrs, (caddr_t)a, ainfo_cmp, ainfo_dup) != 0) {
/* duplicate - existing version updated */
attrinfo_delete(&a);
}
@@ -964,7 +970,7 @@ attr_create_empty(backend *be, char *type, struct attrinfo **ai)
struct attrinfo *a = attrinfo_new();
slapi_attr_init(&a->ai_sattr, type);
a->ai_type = slapi_ch_strdup(type);
- if (avl_insert(&inst->inst_attrs, a, ainfo_cmp, ainfo_dup) != 0) {
+ if (avl_insert(&inst->inst_attrs, (caddr_t)a, ainfo_cmp, ainfo_dup) != 0) {
/* duplicate - existing version updated */
attrinfo_delete(&a);
ainfo_get(be, type, &a);
diff --git a/ldap/servers/slapd/back-ldbm/matchrule.c b/ldap/servers/slapd/back-ldbm/matchrule.c
index 5365e8acf..85ff87b95 100644
--- a/ldap/servers/slapd/back-ldbm/matchrule.c
+++ b/ldap/servers/slapd/back-ldbm/matchrule.c
@@ -79,7 +79,7 @@ int
destroy_matchrule_indexer(Slapi_PBlock *pb)
{
Slapi_Value **keys = NULL;
- IFP mrDESTROY = NULL;
+ int32_t (*mrDESTROY)(Slapi_PBlock *) = NULL;
if (!slapi_pblock_get(pb, SLAPI_PLUGIN_DESTROY_FN, &mrDESTROY)) {
if (mrDESTROY != NULL) {
mrDESTROY(pb);
@@ -109,7 +109,7 @@ destroy_matchrule_indexer(Slapi_PBlock *pb)
int
matchrule_values_to_keys(Slapi_PBlock *pb, Slapi_Value **input_values, struct berval ***output_values)
{
- IFP mrINDEX = NULL;
+ int32_t (*mrINDEX)(Slapi_PBlock *) = NULL;
slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEX_FN, &mrINDEX);
slapi_pblock_set(pb, SLAPI_PLUGIN_MR_VALUES, input_values);
@@ -130,7 +130,7 @@ matchrule_values_to_keys(Slapi_PBlock *pb, Slapi_Value **input_values, struct be
int
matchrule_values_to_keys_sv(Slapi_PBlock *pb, Slapi_Value **input_values, Slapi_Value ***output_values)
{
- IFP mrINDEX = NULL;
+ int32_t (*mrINDEX)(Slapi_PBlock *) = NULL;
slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &mrINDEX);
if (NULL == mrINDEX) { /* old school - does not have SV function */
diff --git a/ldap/servers/slapd/back-ldbm/misc.c b/ldap/servers/slapd/back-ldbm/misc.c
index 309cc8a94..4ced0f1da 100644
--- a/ldap/servers/slapd/back-ldbm/misc.c
+++ b/ldap/servers/slapd/back-ldbm/misc.c
@@ -329,7 +329,7 @@ ldbm_txn_ruv_modify_context(Slapi_PBlock *pb, modify_context *mc)
Slapi_Mods *smods = NULL;
struct backentry *bentry;
entry_address bentry_addr;
- IFP fn = NULL;
+ int32_t (*fn)(Slapi_PBlock *, char **, Slapi_Mods **) = NULL;
int rc = 0;
back_txn txn = {NULL};
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 0317c184d..3df6f9c18 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -496,7 +496,7 @@ int vlv_trim_candidates_txn(backend *be, const IDList *candidates, const sort_sp
int vlv_trim_candidates(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **filteredCandidates, struct vlv_response *pResponse);
int vlv_parse_request_control(backend *be, struct berval *vlv_spec_ber, struct vlv_request *vlvp);
int vlv_make_response_control(Slapi_PBlock *pb, const struct vlv_response *vlvp);
-void vlv_getindices(IFP callback_fn, void *param, backend *be);
+void vlv_getindices(int32_t (*callback_fn)(caddr_t, caddr_t), void *param, backend *be);
void vlv_print_access_log(Slapi_PBlock *pb, struct vlv_request *vlvi, struct vlv_response *vlvo, sort_spec_thing *sort_control);
void vlv_grok_new_import_entry(const struct backentry *e, backend *be, int *seen_them_all);
IDList *vlv_find_index_by_filter(struct backend *be, const char *base, Slapi_Filter *f);
diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
index b086e22e9..b4ed7cf45 100644
--- a/ldap/servers/slapd/back-ldbm/vlv.c
+++ b/ldap/servers/slapd/back-ldbm/vlv.c
@@ -673,7 +673,7 @@ vlv_getindexnames(backend *be)
/* Return the list of VLV indices to the import code. Added read lock */
void
-vlv_getindices(IFP callback_fn, void *param, backend *be)
+vlv_getindices(int32_t (*callback_fn)(caddr_t, caddr_t), void *param, backend *be)
{
/* Traverse the list, calling the import code's callback function */
struct vlvSearch *ps = NULL;
@@ -683,7 +683,7 @@ vlv_getindices(IFP callback_fn, void *param, backend *be)
for (; ps != NULL; ps = ps->vlv_next) {
struct vlvIndex *pi = ps->vlv_index;
for (; pi != NULL; pi = pi->vlv_next) {
- callback_fn(pi->vlv_attrinfo, param);
+ callback_fn((caddr_t)(pi->vlv_attrinfo), (caddr_t)param);
}
}
slapi_rwlock_unlock(be->vlvSearchList_lock);
diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c
index 0a2555a9b..cf3c2ebbc 100644
--- a/ldap/servers/slapd/backend.c
+++ b/ldap/servers/slapd/backend.c
@@ -502,6 +502,7 @@ slapi_be_getentrypoint(Slapi_Backend *be, int entrypoint, void **ret_fnptr, Slap
return 0;
}
+
int
slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi_PBlock *pb)
{
@@ -517,61 +518,61 @@ slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi
switch (entrypoint) {
case SLAPI_PLUGIN_DB_BIND_FN:
- be->be_bind = (IFP)ret_fnptr;
+ be->be_bind = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_UNBIND_FN:
- be->be_unbind = (IFP)ret_fnptr;
+ be->be_unbind = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_SEARCH_FN:
- be->be_search = (IFP)ret_fnptr;
+ be->be_search = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_COMPARE_FN:
- be->be_compare = (IFP)ret_fnptr;
+ be->be_compare = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_MODIFY_FN:
- be->be_modify = (IFP)ret_fnptr;
+ be->be_modify = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_MODRDN_FN:
- be->be_modrdn = (IFP)ret_fnptr;
+ be->be_modrdn = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_ADD_FN:
- be->be_add = (IFP)ret_fnptr;
+ be->be_add = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_DELETE_FN:
- be->be_delete = (IFP)ret_fnptr;
+ be->be_delete = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_ABANDON_FN:
- be->be_abandon = (IFP)ret_fnptr;
+ be->be_abandon = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_CONFIG_FN:
- be->be_config = (IFP)ret_fnptr;
+ be->be_config = ret_fnptr;
break;
case SLAPI_PLUGIN_CLOSE_FN:
- be->be_close = (IFP)ret_fnptr;
+ be->be_close = ret_fnptr;
break;
case SLAPI_PLUGIN_START_FN:
- be->be_start = (IFP)ret_fnptr;
+ be->be_start = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_RESULT_FN:
- be->be_result = (IFP)ret_fnptr;
+ be->be_result = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_LDIF2DB_FN:
- be->be_ldif2db = (IFP)ret_fnptr;
+ be->be_ldif2db = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_DB2LDIF_FN:
- be->be_db2ldif = (IFP)ret_fnptr;
+ be->be_db2ldif = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
- be->be_archive2db = (IFP)ret_fnptr;
+ be->be_archive2db = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
- be->be_db2archive = (IFP)ret_fnptr;
+ be->be_db2archive = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
- be->be_next_search_entry = (IFP)ret_fnptr;
+ be->be_next_search_entry = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN:
- be->be_next_search_entry_ext = (IFP)ret_fnptr;
+ be->be_next_search_entry_ext = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN:
be->be_search_results_release = (VFPP)ret_fnptr;
@@ -580,19 +581,19 @@ slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi
be->be_prev_search_results = (VFP)ret_fnptr;
break;
case SLAPI_PLUGIN_DB_TEST_FN:
- be->be_dbtest = (IFP)ret_fnptr;
+ be->be_dbtest = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_RMDB_FN:
- be->be_rmdb = (IFP)ret_fnptr;
+ be->be_rmdb = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_SEQ_FN:
- be->be_seq = (IFP)ret_fnptr;
+ be->be_seq = ret_fnptr;
break;
case SLAPI_PLUGIN_DB_DB2INDEX_FN:
- be->be_db2index = (IFP)ret_fnptr;
+ be->be_db2index = ret_fnptr;
break;
case SLAPI_PLUGIN_CLEANUP_FN:
- be->be_cleanup = (IFP)ret_fnptr;
+ be->be_cleanup = ret_fnptr;
break;
default:
slapi_log_err(SLAPI_LOG_ERR, "slapi_be_setentrypoint",
@@ -682,7 +683,7 @@ slapi_back_ctrl_info(Slapi_Backend *be, int cmd, void *info)
int
slapi_back_transaction_begin(Slapi_PBlock *pb)
{
- IFP txn_begin;
+ int32_t (*txn_begin)(Slapi_PBlock *);
if (slapi_pblock_get(pb, SLAPI_PLUGIN_DB_BEGIN_FN, (void *)&txn_begin) ||
!txn_begin) {
return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED;
@@ -695,7 +696,7 @@ slapi_back_transaction_begin(Slapi_PBlock *pb)
int
slapi_back_transaction_commit(Slapi_PBlock *pb)
{
- IFP txn_commit;
+ int32_t (*txn_commit)(Slapi_PBlock *);
if (slapi_pblock_get(pb, SLAPI_PLUGIN_DB_COMMIT_FN, (void *)&txn_commit) ||
!txn_commit) {
return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED;
@@ -708,7 +709,7 @@ slapi_back_transaction_commit(Slapi_PBlock *pb)
int
slapi_back_transaction_abort(Slapi_PBlock *pb)
{
- IFP txn_abort;
+ int32_t (*txn_abort)(Slapi_PBlock *);
if (slapi_pblock_get(pb, SLAPI_PLUGIN_DB_ABORT_FN, (void *)&txn_abort) ||
!txn_abort) {
return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED;
diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c
index e3157c1ce..100c4d0d0 100644
--- a/ldap/servers/slapd/dse.c
+++ b/ldap/servers/slapd/dse.c
@@ -120,7 +120,7 @@ typedef struct dse_search_set
static int dse_permission_to_write(struct dse *pdse, int loglevel);
static int dse_write_file_nolock(struct dse *pdse);
-static int dse_apply_nolock(struct dse *pdse, IFP fp, caddr_t arg);
+static int dse_apply_nolock(struct dse *pdse, int32_t (*fp)(caddr_t, caddr_t), caddr_t arg);
static int dse_replace_entry(struct dse *pdse, Slapi_Entry *e, int write_file, int use_lock);
static dse_search_set *dse_search_set_new(void);
static void dse_search_set_delete(dse_search_set *ss);
@@ -257,7 +257,7 @@ dse_find_node(struct dse *pdse, const Slapi_DN *dn)
slapi_entry_set_sdn(fe, dn);
searchNode.entry = fe;
- n = (struct dse_node *)avl_find(pdse->dse_tree, &searchNode, entry_dn_cmp);
+ n = (struct dse_node *)avl_find(pdse->dse_tree, (caddr_t)&searchNode, entry_dn_cmp);
slapi_entry_free(fe);
}
@@ -491,7 +491,7 @@ dse_new_with_filelist(char *filename, char *tmpfilename, char *backfilename, cha
}
static int
-dse_internal_delete_entry(caddr_t data, caddr_t arg __attribute__((unused)))
+dse_internal_delete_entry(caddr_t data)
{
struct dse_node *n = (struct dse_node *)data;
dse_node_delete(&n);
@@ -1182,9 +1182,9 @@ dse_add_entry_pb(struct dse *pdse, Slapi_Entry *e, Slapi_PBlock *pb)
/* keep write lock during both tree update and file write operations */
dse_lock_write(pdse, DSE_USE_LOCK);
if (merge) {
- rc = avl_insert(&(pdse->dse_tree), n, entry_dn_cmp, dupentry_merge);
+ rc = avl_insert(&(pdse->dse_tree), (caddr_t)n, entry_dn_cmp, dupentry_merge);
} else {
- rc = avl_insert(&(pdse->dse_tree), n, entry_dn_cmp, dupentry_disallow);
+ rc = avl_insert(&(pdse->dse_tree), (caddr_t)n, entry_dn_cmp, dupentry_disallow);
}
if (-1 != rc) {
/* update num sub of parent with no lock; we already hold the write lock */
@@ -1371,7 +1371,7 @@ dse_replace_entry(struct dse *pdse, Slapi_Entry *e, int write_file, int use_lock
if (NULL != e) {
struct dse_node *n = dse_node_new(e);
dse_lock_write(pdse, use_lock);
- rc = avl_insert(&(pdse->dse_tree), n, entry_dn_cmp, dupentry_replace);
+ rc = avl_insert(&(pdse->dse_tree), (caddr_t)n, entry_dn_cmp, dupentry_replace);
if (write_file)
dse_write_file_nolock(pdse);
/* If the entry was replaced i.e. not added as a new entry, we need to
@@ -1446,7 +1446,7 @@ dse_read_next_entry(char *buf, char **lastp)
* searching, a read lock, for modifying in place, a write lock
*/
static int
-dse_apply_nolock(struct dse *pdse, IFP fp, caddr_t arg)
+dse_apply_nolock(struct dse *pdse, int32_t (*fp)(caddr_t, caddr_t), caddr_t arg)
{
avl_apply(pdse->dse_tree, fp, arg, STOP_TRAVERSAL, AVL_INORDER);
return 1;
@@ -1468,7 +1468,7 @@ dse_delete_entry(struct dse *pdse, Slapi_PBlock *pb, const Slapi_Entry *e)
/* keep write lock for both tree deleting and file writing */
dse_lock_write(pdse, DSE_USE_LOCK);
- if ((deleted_node = (struct dse_node *)avl_delete(&pdse->dse_tree, n, entry_dn_cmp))) {
+ if ((deleted_node = (struct dse_node *)avl_delete(&pdse->dse_tree, (caddr_t)n, entry_dn_cmp))) {
dse_node_delete(&deleted_node);
}
dse_node_delete(&n);
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 658b9b279..5e9819a38 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -709,7 +709,7 @@ entry_attrs_add(entry_attrs *ea, const char *atname, int atarrayindex)
ead->ead_attrarrayindex = atarrayindex;
ead->ead_attrtypename = atname; /* a reference, not a strdup! */
- avl_insert(&(ea->ea_attrlist), ead, attr_type_node_cmp, avl_dup_error);
+ avl_insert(&(ea->ea_attrlist), (caddr_t)ead, attr_type_node_cmp, avl_dup_error);
}
/*
@@ -723,7 +723,7 @@ entry_attrs_find(entry_attrs *ea, char *type)
entry_attr_data *foundead;
tmpead.ead_attrtypename = type;
- foundead = (entry_attr_data *)avl_find(ea->ea_attrlist, &tmpead,
+ foundead = (entry_attr_data *)avl_find(ea->ea_attrlist, (caddr_t)&tmpead,
attr_type_node_cmp);
return (NULL != foundead) ? foundead->ead_attrarrayindex : -1;
}
diff --git a/ldap/servers/slapd/filtercmp.c b/ldap/servers/slapd/filtercmp.c
index 3e17796e9..0d8764b5a 100644
--- a/ldap/servers/slapd/filtercmp.c
+++ b/ldap/servers/slapd/filtercmp.c
@@ -86,7 +86,7 @@ get_mr_normval(char *oid, char *type, struct berval **inval, struct berval ***ou
{
Slapi_PBlock *pb = slapi_pblock_new();
unsigned int sort_indicator = SLAPI_PLUGIN_MR_USAGE_SORT;
- IFP mrIndex = NULL;
+ int32_t (*mrIndex)(Slapi_PBlock *) = NULL;
if (!pb) {
return NULL;
@@ -118,7 +118,7 @@ get_mr_normval(char *oid, char *type, struct berval **inval, struct berval ***ou
static void
done_mr_normval(Slapi_PBlock *pb)
{
- IFP mrDestroy = NULL;
+ int32_t (*mrDestroy)(Slapi_PBlock *) = NULL;
if (slapi_pblock_get(pb, SLAPI_PLUGIN_DESTROY_FN, &mrDestroy) == 0) {
if (mrDestroy)
diff --git a/ldap/servers/slapd/getfilelist.c b/ldap/servers/slapd/getfilelist.c
index dd5deb282..2fd164baf 100644
--- a/ldap/servers/slapd/getfilelist.c
+++ b/ldap/servers/slapd/getfilelist.c
@@ -46,9 +46,11 @@ struct path_wrapper
int order;
};
-static int
-path_wrapper_cmp(struct path_wrapper *p1, struct path_wrapper *p2)
+static int32_t
+path_wrapper_cmp(caddr_t pwc1, caddr_t pwc2)
{
+ struct path_wrapper *p1 = (struct path_wrapper *)pwc1;
+ struct path_wrapper *p2 = (struct path_wrapper *)pwc2;
if (p1->order < p2->order) {
/* p1 is "earlier" so put it first */
return -1;
@@ -217,7 +219,7 @@ get_filelist(
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);
+ avl_insert(&filetree, (caddr_t)pw_ptr, path_wrapper_cmp, 0);
num++;
}
}
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index 0aedd70a6..f318058be 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -1,6 +1,6 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2005-2025 Red Hat, Inc.
* Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
* All rights reserved.
*
@@ -784,25 +784,25 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_bind;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_bind;
break;
case SLAPI_PLUGIN_DB_UNBIND_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_unbind;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_unbind;
break;
case SLAPI_PLUGIN_DB_SEARCH_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_search;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_search;
break;
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_next_search_entry;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_next_search_entry;
break;
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
@@ -826,37 +826,37 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_compare;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_compare;
break;
case SLAPI_PLUGIN_DB_MODIFY_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_modify;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_modify;
break;
case SLAPI_PLUGIN_DB_MODRDN_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_modrdn;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_modrdn;
break;
case SLAPI_PLUGIN_DB_ADD_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_add;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_add;
break;
case SLAPI_PLUGIN_DB_DELETE_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_delete;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_delete;
break;
case SLAPI_PLUGIN_DB_ABANDON_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_abandon;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_abandon;
break;
case SLAPI_PLUGIN_DB_CONFIG_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
@@ -868,7 +868,7 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
(*(IFP *)value) = pblock->pb_plugin->plg_close;
break;
case SLAPI_PLUGIN_CLEANUP_FN:
- (*(IFP *)value) = pblock->pb_plugin->plg_cleanup;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_cleanup;
break;
case SLAPI_PLUGIN_START_FN:
(*(IFP *)value) = pblock->pb_plugin->plg_start;
@@ -877,22 +877,22 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
(*(IFP *)value) = pblock->pb_plugin->plg_poststart;
break;
case SLAPI_PLUGIN_DB_WIRE_IMPORT_FN:
- (*(IFP *)value) = pblock->pb_plugin->plg_wire_import;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_wire_import;
break;
case SLAPI_PLUGIN_DB_GET_INFO_FN:
- (*(IFP *)value) = pblock->pb_plugin->plg_get_info;
+ (*(int32_t (**)(struct backend *, int32_t, void **))value) = pblock->pb_plugin->plg_get_info;
break;
case SLAPI_PLUGIN_DB_SET_INFO_FN:
- (*(IFP *)value) = pblock->pb_plugin->plg_set_info;
+ (*(int32_t (**)(struct backend *, int32_t, void **))value) = pblock->pb_plugin->plg_set_info;
break;
case SLAPI_PLUGIN_DB_CTRL_INFO_FN:
- (*(IFP *)value) = pblock->pb_plugin->plg_ctrl_info;
+ (*(int32_t (**)(struct backend *, int32_t, void **))value) = pblock->pb_plugin->plg_ctrl_info;
break;
case SLAPI_PLUGIN_DB_SEQ_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_seq;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_seq;
break;
case SLAPI_PLUGIN_DB_ENTRY_FN:
(*(IFP *)value) = SLAPI_PBLOCK_GET_PLUGIN_RELATED_POINTER(pblock,
@@ -916,55 +916,55 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_ldif2db;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_ldif2db;
break;
case SLAPI_PLUGIN_DB_DB2LDIF_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_db2ldif;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_db2ldif;
break;
case SLAPI_PLUGIN_DB_COMPACT_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_dbcompact;
+ (*(int32_t (**)(struct backend *, bool))value) = pblock->pb_plugin->plg_dbcompact;
break;
case SLAPI_PLUGIN_DB_DB2INDEX_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_db2index;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_db2index;
break;
case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_archive2db;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_archive2db;
break;
case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_db2archive;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_db2archive;
break;
case SLAPI_PLUGIN_DB_UPGRADEDB_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_upgradedb;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_upgradedb;
break;
case SLAPI_PLUGIN_DB_UPGRADEDNFORMAT_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_upgradednformat;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_upgradednformat;
break;
case SLAPI_PLUGIN_DB_DBVERIFY_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_dbverify;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_dbverify;
break;
case SLAPI_PLUGIN_DB_BEGIN_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
@@ -1008,7 +1008,7 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_exhandler;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_exhandler;
break;
case SLAPI_PLUGIN_EXT_OP_OIDLIST:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
@@ -1029,7 +1029,7 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_be_exhandler;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Backend **))value) = pblock->pb_plugin->plg_be_exhandler;
break;
/* preoperation plugin functions */
@@ -1475,31 +1475,32 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_syntax_filter_ava;
+ (*(int32_t (**)(Slapi_PBlock *, const struct berval *, Slapi_Value **,
+ int32_t, Slapi_Value **))value) = pblock->pb_plugin->plg_syntax_filter_ava;
break;
case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_syntax_filter_sub;
+ (*(int32_t (**)(Slapi_PBlock*, char *, char **, char *, Slapi_Value**))value) = pblock->pb_plugin->plg_syntax_filter_sub;
break;
case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_syntax_values2keys;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Value **, Slapi_Value ***, int32_t))value) = pblock->pb_plugin->plg_syntax_values2keys;
break;
case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_syntax_assertion2keys_ava;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Value *, Slapi_Value ***, int32_t))value) = pblock->pb_plugin->plg_syntax_assertion2keys_ava;
break;
case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_syntax_assertion2keys_sub;
+ (*(int32_t (**)(Slapi_PBlock *, char *, char **, char *, Slapi_Value ***))value) = pblock->pb_plugin->plg_syntax_assertion2keys_sub;
break;
case SLAPI_PLUGIN_SYNTAX_NAMES:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
@@ -1536,13 +1537,13 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_syntax_validate;
+ (*(int32_t (**)(struct berval *))value) = pblock->pb_plugin->plg_syntax_validate;
break;
case SLAPI_PLUGIN_SYNTAX_NORMALIZE:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- (*(VFPV *)value) = pblock->pb_plugin->plg_syntax_normalize;
+ (*(void (**)(Slapi_PBlock *, char *, int32_t, char **))value) = pblock->pb_plugin->plg_syntax_normalize;
break;
/* controls we know about */
@@ -1807,11 +1808,12 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
/* matching rule plugin functions */
case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
SLAPI_PLUGIN_TYPE_CHECK(pblock, SLAPI_PLUGIN_MATCHINGRULE);
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_filter_create;
+
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_mr_filter_create;
break;
case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
SLAPI_PLUGIN_TYPE_CHECK(pblock, SLAPI_PLUGIN_MATCHINGRULE);
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_indexer_create;
+ (*(int32_t (**)(Slapi_PBlock *))value) = pblock->pb_plugin->plg_mr_indexer_create;
break;
case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
if (pblock->pb_mr != NULL) {
@@ -1912,31 +1914,31 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_filter_ava;
+ (*(int32_t (**)(Slapi_PBlock *, const struct berval *, Slapi_Value **, int32_t, Slapi_Value **))value) = pblock->pb_plugin->plg_mr_filter_ava;
break;
case SLAPI_PLUGIN_MR_FILTER_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_filter_sub;
+ (*(int32_t (**)(Slapi_PBlock *, char *, char **, char*, Slapi_Value **))value) = pblock->pb_plugin->plg_mr_filter_sub;
break;
case SLAPI_PLUGIN_MR_VALUES2KEYS:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_values2keys;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Value **, Slapi_Value ***, int32_t))value) = pblock->pb_plugin->plg_mr_values2keys;
break;
case SLAPI_PLUGIN_MR_ASSERTION2KEYS_AVA:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_assertion2keys_ava;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Value *, Slapi_Value ***, int32_t))value) = pblock->pb_plugin->plg_mr_assertion2keys_ava;
break;
case SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_assertion2keys_sub;
+ (*(int32_t (**)(Slapi_PBlock *, char *, char **, char *, Slapi_Value ***))value) = pblock->pb_plugin->plg_mr_assertion2keys_sub;
break;
case SLAPI_PLUGIN_MR_FLAGS:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
@@ -1954,13 +1956,13 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- (*(IFP *)value) = pblock->pb_plugin->plg_mr_compare;
+ (*(int32_t (**)(struct berval *, struct berval *))value) = pblock->pb_plugin->plg_mr_compare;
break;
case SLAPI_PLUGIN_MR_NORMALIZE:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- (*(VFPV *)value) = pblock->pb_plugin->plg_mr_normalize;
+ (*(void (**)(Slapi_PBlock *, char *, int32_t, char **))value) = pblock->pb_plugin->plg_mr_normalize;
break;
/* seq arguments */
@@ -2153,9 +2155,9 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
break;
case SLAPI_TXN_RUV_MODS_FN:
if (pblock->pb_intop != NULL) {
- (*(IFP *)value) = pblock->pb_intop->pb_txn_ruv_mods_fn;
+ (*(int32_t(**)(Slapi_PBlock *, char **, Slapi_Mods **))value) = pblock->pb_intop->pb_txn_ruv_mods_fn;
} else {
- (*(IFP *)value) = NULL;
+ (*(int32_t(**)(Slapi_PBlock *, char **, Slapi_Mods **))value) = NULL;
}
break;
@@ -2229,24 +2231,25 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
(*(IFP *)value) = pblock->pb_plugin->plg_acl_init;
break;
case SLAPI_PLUGIN_ACL_SYNTAX_CHECK:
- (*(IFP *)value) = pblock->pb_plugin->plg_acl_syntax_check;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Entry *, char **))value) = pblock->pb_plugin->plg_acl_syntax_check;
break;
case SLAPI_PLUGIN_ACL_ALLOW_ACCESS:
- (*(IFP *)value) = pblock->pb_plugin->plg_acl_access_allowed;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Entry *, char **, struct berval *,
+ int32_t, int32_t, char **))value) = pblock->pb_plugin->plg_acl_access_allowed;
break;
case SLAPI_PLUGIN_ACL_MODS_ALLOWED:
- (*(IFP *)value) = pblock->pb_plugin->plg_acl_mods_allowed;
+ (*(int32_t (**)(Slapi_PBlock *, Slapi_Entry *, LDAPMod **, void *))value) = pblock->pb_plugin->plg_acl_mods_allowed;
break;
case SLAPI_PLUGIN_ACL_MODS_UPDATE:
- (*(IFP *)value) = pblock->pb_plugin->plg_acl_mods_update;
+ (*(int32_t (**)(Slapi_PBlock *, int32_t, Slapi_DN *, void *))value) = pblock->pb_plugin->plg_acl_mods_update;
break;
/* MMR Plugin */
case SLAPI_PLUGIN_MMR_BETXN_PREOP:
- (*(IFP *)value) = pblock->pb_plugin->plg_mmr_betxn_preop;
- break;
+ (*(int32_t (**)(Slapi_PBlock *, int32_t))value) = pblock->pb_plugin->plg_mmr_betxn_preop;
+ break;
case SLAPI_PLUGIN_MMR_BETXN_POSTOP:
- (*(IFP *)value) = pblock->pb_plugin->plg_mmr_betxn_postop;
- break;
+ (*(int32_t (**)(Slapi_PBlock *, int32_t))value) = pblock->pb_plugin->plg_mmr_betxn_postop;
+ break;
case SLAPI_REQUESTOR_DN:
/* NOTE: It's not a copy of the DN */
@@ -2370,11 +2373,11 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
/* entry fetch/store plugin */
case SLAPI_PLUGIN_ENTRY_FETCH_FUNC:
- (*(IFP *)value) = pblock->pb_plugin->plg_entryfetchfunc;
+ (*(int32_t (**)(char **, uint32_t *))value) = pblock->pb_plugin->plg_entryfetchfunc;
break;
case SLAPI_PLUGIN_ENTRY_STORE_FUNC:
- (*(IFP *)value) = pblock->pb_plugin->plg_entrystorefunc;
+ (*(int32_t (**)(char **, uint32_t *))value) = pblock->pb_plugin->plg_entrystorefunc;
break;
case SLAPI_PLUGIN_ENABLED:
@@ -2730,25 +2733,25 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_bind = (IFP)value;
+ pblock->pb_plugin->plg_bind = value;
break;
case SLAPI_PLUGIN_DB_UNBIND_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_unbind = (IFP)value;
+ pblock->pb_plugin->plg_unbind = value;
break;
case SLAPI_PLUGIN_DB_SEARCH_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_search = (IFP)value;
+ pblock->pb_plugin->plg_search = value;
break;
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_next_search_entry = (IFP)value;
+ pblock->pb_plugin->plg_next_search_entry = value;
break;
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
@@ -2772,37 +2775,37 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_compare = (IFP)value;
+ pblock->pb_plugin->plg_compare = value;
break;
case SLAPI_PLUGIN_DB_MODIFY_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_modify = (IFP)value;
+ pblock->pb_plugin->plg_modify = value;
break;
case SLAPI_PLUGIN_DB_MODRDN_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_modrdn = (IFP)value;
+ pblock->pb_plugin->plg_modrdn = value;
break;
case SLAPI_PLUGIN_DB_ADD_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_add = (IFP)value;
+ pblock->pb_plugin->plg_add = value;
break;
case SLAPI_PLUGIN_DB_DELETE_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_delete = (IFP)value;
+ pblock->pb_plugin->plg_delete = value;
break;
case SLAPI_PLUGIN_DB_ABANDON_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_abandon = (IFP)value;
+ pblock->pb_plugin->plg_abandon = value;
break;
case SLAPI_PLUGIN_DB_CONFIG_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
@@ -2814,7 +2817,7 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
pblock->pb_plugin->plg_close = (IFP)value;
break;
case SLAPI_PLUGIN_CLEANUP_FN:
- pblock->pb_plugin->plg_cleanup = (IFP)value;
+ pblock->pb_plugin->plg_cleanup = value;
break;
case SLAPI_PLUGIN_START_FN:
pblock->pb_plugin->plg_start = (IFP)value;
@@ -2823,22 +2826,22 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
pblock->pb_plugin->plg_poststart = (IFP)value;
break;
case SLAPI_PLUGIN_DB_WIRE_IMPORT_FN:
- pblock->pb_plugin->plg_wire_import = (IFP)value;
+ pblock->pb_plugin->plg_wire_import = value;
break;
case SLAPI_PLUGIN_DB_GET_INFO_FN:
- pblock->pb_plugin->plg_get_info = (IFP)value;
+ pblock->pb_plugin->plg_get_info = value;
break;
case SLAPI_PLUGIN_DB_SET_INFO_FN:
- pblock->pb_plugin->plg_set_info = (IFP)value;
+ pblock->pb_plugin->plg_set_info = value;
break;
case SLAPI_PLUGIN_DB_CTRL_INFO_FN:
- pblock->pb_plugin->plg_ctrl_info = (IFP)value;
+ pblock->pb_plugin->plg_ctrl_info = value;
break;
case SLAPI_PLUGIN_DB_SEQ_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_seq = (IFP)value;
+ pblock->pb_plugin->plg_seq = value;
break;
case SLAPI_PLUGIN_DB_ENTRY_FN:
pblock->pb_plugin->plg_entry = (IFP)value;
@@ -2859,49 +2862,49 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_ldif2db = (IFP)value;
+ pblock->pb_plugin->plg_ldif2db = value;
break;
case SLAPI_PLUGIN_DB_DB2LDIF_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_db2ldif = (IFP)value;
+ pblock->pb_plugin->plg_db2ldif = value;
break;
case SLAPI_PLUGIN_DB_DB2INDEX_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_db2index = (IFP)value;
+ pblock->pb_plugin->plg_db2index = value;
break;
case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_archive2db = (IFP)value;
+ pblock->pb_plugin->plg_archive2db = value;
break;
case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_db2archive = (IFP)value;
+ pblock->pb_plugin->plg_db2archive = value;
break;
case SLAPI_PLUGIN_DB_UPGRADEDB_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_upgradedb = (IFP)value;
+ pblock->pb_plugin->plg_upgradedb = value;
break;
case SLAPI_PLUGIN_DB_UPGRADEDNFORMAT_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_upgradednformat = (IFP)value;
+ pblock->pb_plugin->plg_upgradednformat = value;
break;
case SLAPI_PLUGIN_DB_DBVERIFY_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_dbverify = (IFP)value;
+ pblock->pb_plugin->plg_dbverify = value;
break;
case SLAPI_PLUGIN_DB_BEGIN_FN:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
@@ -2941,7 +2944,7 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
return (-1);
}
- pblock->pb_plugin->plg_dbcompact = (IFP)value;
+ pblock->pb_plugin->plg_dbcompact = value;
break;
/* extendedop plugin functions */
@@ -2950,7 +2953,7 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP) {
return (-1);
}
- pblock->pb_plugin->plg_exhandler = (IFP)value;
+ pblock->pb_plugin->plg_exhandler = value;
break;
case SLAPI_PLUGIN_EXT_OP_OIDLIST:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
@@ -2972,7 +2975,7 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP) {
return (-1);
}
- pblock->pb_plugin->plg_be_exhandler = (IFP)value;
+ pblock->pb_plugin->plg_be_exhandler = value;
break;
/* preoperation plugin functions */
@@ -3338,31 +3341,31 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- pblock->pb_plugin->plg_syntax_filter_ava = (IFP)value;
+ pblock->pb_plugin->plg_syntax_filter_ava = value;
break;
case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- pblock->pb_plugin->plg_syntax_filter_sub = (IFP)value;
+ pblock->pb_plugin->plg_syntax_filter_sub = value;
break;
case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- pblock->pb_plugin->plg_syntax_values2keys = (IFP)value;
+ pblock->pb_plugin->plg_syntax_values2keys = value;
break;
case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- pblock->pb_plugin->plg_syntax_assertion2keys_ava = (IFP)value;
+ pblock->pb_plugin->plg_syntax_assertion2keys_ava = value;
break;
case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- pblock->pb_plugin->plg_syntax_assertion2keys_sub = (IFP)value;
+ pblock->pb_plugin->plg_syntax_assertion2keys_sub = value;
break;
case SLAPI_PLUGIN_SYNTAX_NAMES:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
@@ -3398,13 +3401,13 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- pblock->pb_plugin->plg_syntax_validate = (IFP)value;
+ pblock->pb_plugin->plg_syntax_validate = value;
break;
case SLAPI_PLUGIN_SYNTAX_NORMALIZE:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX) {
return (-1);
}
- pblock->pb_plugin->plg_syntax_normalize = (VFPV)value;
+ pblock->pb_plugin->plg_syntax_normalize = value;
break;
case SLAPI_ENTRY_PRE_OP:
_pblock_assert_pb_intop(pblock);
@@ -3734,11 +3737,11 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
/* matching rule plugin functions */
case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
SLAPI_PLUGIN_TYPE_CHECK(pblock, SLAPI_PLUGIN_MATCHINGRULE);
- pblock->pb_plugin->plg_mr_filter_create = (IFP)value;
+ pblock->pb_plugin->plg_mr_filter_create = value;
break;
case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
SLAPI_PLUGIN_TYPE_CHECK(pblock, SLAPI_PLUGIN_MATCHINGRULE);
- pblock->pb_plugin->plg_mr_indexer_create = (IFP)value;
+ pblock->pb_plugin->plg_mr_indexer_create = value;
break;
case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
_pblock_assert_pb_mr(pblock);
@@ -3800,31 +3803,31 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- pblock->pb_plugin->plg_mr_filter_ava = (IFP)value;
+ pblock->pb_plugin->plg_mr_filter_ava = value;
break;
case SLAPI_PLUGIN_MR_FILTER_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- pblock->pb_plugin->plg_mr_filter_sub = (IFP)value;
+ pblock->pb_plugin->plg_mr_filter_sub = value;
break;
case SLAPI_PLUGIN_MR_VALUES2KEYS:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- pblock->pb_plugin->plg_mr_values2keys = (IFP)value;
+ pblock->pb_plugin->plg_mr_values2keys = value;
break;
case SLAPI_PLUGIN_MR_ASSERTION2KEYS_AVA:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- pblock->pb_plugin->plg_mr_assertion2keys_ava = (IFP)value;
+ pblock->pb_plugin->plg_mr_assertion2keys_ava = value;
break;
case SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- pblock->pb_plugin->plg_mr_assertion2keys_sub = (IFP)value;
+ pblock->pb_plugin->plg_mr_assertion2keys_sub = value;
break;
case SLAPI_PLUGIN_MR_FLAGS:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
@@ -3843,13 +3846,13 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- pblock->pb_plugin->plg_mr_compare = (IFP)value;
+ pblock->pb_plugin->plg_mr_compare = value;
break;
case SLAPI_PLUGIN_MR_NORMALIZE:
if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE) {
return (-1);
}
- pblock->pb_plugin->plg_mr_normalize = (VFPV)value;
+ pblock->pb_plugin->plg_mr_normalize = value;
break;
/* seq arguments */
@@ -3968,7 +3971,7 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
break;
case SLAPI_TXN_RUV_MODS_FN:
_pblock_assert_pb_intop(pblock);
- pblock->pb_intop->pb_txn_ruv_mods_fn = (IFP)value;
+ pblock->pb_intop->pb_txn_ruv_mods_fn = value;
break;
/* Search results set */
@@ -4037,23 +4040,23 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
break;
case SLAPI_PLUGIN_ACL_SYNTAX_CHECK:
- pblock->pb_plugin->plg_acl_syntax_check = (IFP)value;
+ pblock->pb_plugin->plg_acl_syntax_check = value;
break;
case SLAPI_PLUGIN_ACL_ALLOW_ACCESS:
- pblock->pb_plugin->plg_acl_access_allowed = (IFP)value;
+ pblock->pb_plugin->plg_acl_access_allowed = value;
break;
case SLAPI_PLUGIN_ACL_MODS_ALLOWED:
- pblock->pb_plugin->plg_acl_mods_allowed = (IFP)value;
+ pblock->pb_plugin->plg_acl_mods_allowed = value;
break;
case SLAPI_PLUGIN_ACL_MODS_UPDATE:
- pblock->pb_plugin->plg_acl_mods_update = (IFP)value;
+ pblock->pb_plugin->plg_acl_mods_update = value;
break;
/* MMR Plugin */
case SLAPI_PLUGIN_MMR_BETXN_PREOP:
- pblock->pb_plugin->plg_mmr_betxn_preop = (IFP) value;
+ pblock->pb_plugin->plg_mmr_betxn_preop = value;
break;
case SLAPI_PLUGIN_MMR_BETXN_POSTOP:
- pblock->pb_plugin->plg_mmr_betxn_postop = (IFP) value;
+ pblock->pb_plugin->plg_mmr_betxn_postop = value;
break;
case SLAPI_CLIENT_DNS:
@@ -4116,11 +4119,11 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
/* entry fetch store */
case SLAPI_PLUGIN_ENTRY_FETCH_FUNC:
- pblock->pb_plugin->plg_entryfetchfunc = (IFP)value;
+ pblock->pb_plugin->plg_entryfetchfunc = value;
break;
case SLAPI_PLUGIN_ENTRY_STORE_FUNC:
- pblock->pb_plugin->plg_entrystorefunc = (IFP)value;
+ pblock->pb_plugin->plg_entrystorefunc = value;
break;
case SLAPI_PLUGIN_ENABLED:
diff --git a/ldap/servers/slapd/pblock_v3.h b/ldap/servers/slapd/pblock_v3.h
index 1b4996c48..4bebb850f 100644
--- a/ldap/servers/slapd/pblock_v3.h
+++ b/ldap/servers/slapd/pblock_v3.h
@@ -117,7 +117,7 @@ typedef struct _slapi_pblock_intop
void *op_stack_elem;
void *pb_txn; /* transaction ID */
- IFP pb_txn_ruv_mods_fn; /* Function to fetch RUV mods for txn */
+ int32_t (*pb_txn_ruv_mods_fn)(Slapi_PBlock *, char **, Slapi_Mods **); /* Function to fetch RUV mods for txn */
passwdPolicy *pwdpolicy;
LDAPControl **pb_ctrls_arg; /* allows to pass controls as arguments before
operation object is created */
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index ba4a194c1..7d0cea745 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -663,7 +663,7 @@ slapi_send_ldap_intermediate(Slapi_PBlock *pb, LDAPControl **ectrls, char *respo
int
slapi_send_ldap_search_entry(Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly)
{
- IFP fn = NULL;
+ int32_t (*fn)(Slapi_PBlock *, Slapi_Entry *, LDAPControl **, char **, int32_t) = NULL;
slapi_pblock_get(pb, SLAPI_PLUGIN_DB_ENTRY_FN, (void *)&fn);
if (NULL == fn) {
return -1;
@@ -698,7 +698,7 @@ slapi_send_ldap_result_from_pb(Slapi_PBlock *pb)
int err;
char *matched;
char *text;
- IFP fn = NULL;
+ int32_t (*fn)(Slapi_PBlock*, int32_t, char*, char*, int32_t, struct berval **) = NULL;
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &err);
slapi_pblock_get(pb, SLAPI_RESULT_TEXT, &text);
@@ -718,7 +718,7 @@ slapi_send_ldap_result_from_pb(Slapi_PBlock *pb)
void
slapi_send_ldap_result(Slapi_PBlock *pb, int err, char *matched, char *text, int nentries, struct berval **urls)
{
- IFP fn = NULL;
+ int32_t (*fn)(Slapi_PBlock*, int32_t, char*, char*, int32_t, struct berval **) = NULL;
Slapi_Operation *operation;
long op_type;
@@ -756,7 +756,7 @@ slapi_send_ldap_result(Slapi_PBlock *pb, int err, char *matched, char *text, int
int
slapi_send_ldap_referral(Slapi_PBlock *pb, Slapi_Entry *e, struct berval **refs, struct berval ***urls)
{
- IFP fn = NULL;
+ int32_t (*fn)(Slapi_PBlock*, Slapi_Entry*, struct berval **, struct berval ***) = NULL;
slapi_pblock_get(pb, SLAPI_PLUGIN_DB_REFERRAL_FN, (void *)&fn);
if (NULL == fn) {
return -1;
@@ -1969,7 +1969,7 @@ plugin_call_func(struct slapdplugin *list, int operation, Slapi_PBlock *pb, int
int count = 0;
for (; list != NULL; list = list->plg_next) {
- IFP func = NULL;
+ int32_t (*func)(Slapi_PBlock *) = NULL;
slapi_pblock_set(pb, SLAPI_PLUGIN, list);
set_db_default_result_handlers(pb); /* JCM: What's this do? Is it needed here? */
diff --git a/ldap/servers/slapd/plugin_mmr.c b/ldap/servers/slapd/plugin_mmr.c
index f58120543..845e8f0ad 100644
--- a/ldap/servers/slapd/plugin_mmr.c
+++ b/ldap/servers/slapd/plugin_mmr.c
@@ -1,10 +1,10 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2005-2025 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 **/
#ifdef HAVE_CONFIG_H
@@ -19,11 +19,11 @@
#include "slap.h"
int
-plugin_call_mmr_plugin_preop ( Slapi_PBlock *pb, Slapi_Entry *e, int flags)
+plugin_call_mmr_plugin_preop(Slapi_PBlock *pb, Slapi_Entry *e, int flags)
{
- struct slapdplugin *p;
- int rc = LDAP_INSUFFICIENT_ACCESS;
- Operation *operation;
+ struct slapdplugin *p;
+ int rc = LDAP_INSUFFICIENT_ACCESS;
+ Operation *operation;
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
@@ -45,11 +45,11 @@ plugin_call_mmr_plugin_preop ( Slapi_PBlock *pb, Slapi_Entry *e, int flags)
}
int
-plugin_call_mmr_plugin_postop ( Slapi_PBlock *pb, Slapi_Entry *e, int flags)
+plugin_call_mmr_plugin_postop(Slapi_PBlock *pb, Slapi_Entry *e, int flags)
{
- struct slapdplugin *p;
- int rc = LDAP_INSUFFICIENT_ACCESS;
- Operation *operation;
+ struct slapdplugin *p;
+ int rc = LDAP_INSUFFICIENT_ACCESS;
+ Operation *operation;
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
diff --git a/ldap/servers/slapd/plugin_mr.c b/ldap/servers/slapd/plugin_mr.c
index b262820c5..9809a4374 100644
--- a/ldap/servers/slapd/plugin_mr.c
+++ b/ldap/servers/slapd/plugin_mr.c
@@ -1,6 +1,6 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2005-2025 Red Hat, Inc.
* All rights reserved.
*
* License: GPL (version 3 or any later version).
@@ -35,7 +35,7 @@ struct mr_private
const struct berval *value; /* orig value from filter */
int ftype; /* filter type */
int op; /* query op type */
- IFP match_fn; /* match func to use */
+ int32_t (*match_fn)(Slapi_PBlock *, const struct berval *, Slapi_Value **, int32_t, Slapi_Value **); /* match func to use */
/* note - substring matching rules not currently supported */
char *initial; /* these are for substring matches */
char *any[2]; /* at most one value for extensible filter */
@@ -225,7 +225,7 @@ int /* an LDAP error code, hopefully LDAP_SUCCESS */
int rc;
char *oid;
if (!(rc = slapi_pblock_get(opb, SLAPI_PLUGIN_MR_OID, &oid))) {
- IFP createFn = NULL;
+ int32_t (*createFn)(Slapi_PBlock *) = NULL;
struct slapdplugin *mrp = plugin_mr_find_registered(oid);
if (mrp != NULL) {
/* Great the matching OID -> MR plugin was already found, just reuse it */
@@ -251,7 +251,6 @@ int /* an LDAP error code, hopefully LDAP_SUCCESS */
rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
for (mrp = get_plugin_list(PLUGIN_LIST_MATCHINGRULE); mrp != NULL; mrp = mrp->plg_next) {
-
Slapi_PBlock *pb = slapi_pblock_new();
mr_indexer_init_pb(opb, pb);
slapi_pblock_set(pb, SLAPI_PLUGIN, mrp);
@@ -263,8 +262,8 @@ int /* an LDAP error code, hopefully LDAP_SUCCESS */
}
if (createFn && !createFn(pb)) {
- IFP indexFn = NULL;
- IFP indexSvFn = NULL;
+ int32_t (*indexFn)(void) = NULL;
+ int32_t (*indexSvFn)(void) = NULL;
/* These however, are in the pblock direct, so we need to copy them. */
slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEX_FN, &indexFn);
slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &indexSvFn);
@@ -624,7 +623,7 @@ static int
attempt_mr_filter_create(mr_filter_t *f, struct slapdplugin *mrp, Slapi_PBlock *pb)
{
int rc;
- IFP mrf_create = NULL;
+ int32_t (*mrf_create)(Slapi_PBlock *) = NULL;
f->mrf_match = NULL;
pblock_init(pb);
if (!(rc = slapi_pblock_set(pb, SLAPI_PLUGIN, mrp)) &&
diff --git a/ldap/servers/slapd/plugin_syntax.c b/ldap/servers/slapd/plugin_syntax.c
index f8a133f96..68f7bcb4b 100644
--- a/ldap/servers/slapd/plugin_syntax.c
+++ b/ldap/servers/slapd/plugin_syntax.c
@@ -1,6 +1,6 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2005-2025 Red Hat, Inc.
* All rights reserved.
*
* License: GPL (version 3 or any later version).
@@ -95,7 +95,7 @@ plugin_call_syntax_filter_ava_sv(
int useDeletedValues)
{
int rc;
- IFP ava_fn = NULL;
+ int32_t (*ava_fn)(Slapi_PBlock *, const struct berval *, Slapi_Value **, int32_t, Slapi_Value **) = NULL;
slapi_log_err(SLAPI_LOG_FILTER,
"plugin_call_syntax_filter_ava_sv", "=> %s=%s\n", ava->ava_type,
@@ -207,7 +207,7 @@ plugin_call_syntax_filter_sub_sv(
struct subfilt *fsub)
{
int rc;
- IFP sub_fn = NULL;
+ int32_t (*sub_fn)(Slapi_PBlock *, char *, char **, char*, Slapi_Value **) = NULL;
int filter_normalized = 0;
slapi_log_err(SLAPI_LOG_FILTER,
@@ -396,7 +396,7 @@ slapi_entry_syntax_check(
/* iterate through each value to check if it's valid */
while (val != NULL) {
bval = slapi_value_get_berval(val);
- if ((a->a_plugin->plg_syntax_validate(bval)) != 0) {
+ if ((a->a_plugin->plg_syntax_validate((struct berval *)bval)) != 0) {
if (syntaxlogging) {
slapi_log_err(SLAPI_LOG_ERR, "slapi_entry_syntax_check",
"\"%s\": (%s) value #%d invalid per syntax\n",
@@ -586,7 +586,7 @@ slapi_attr_values2keys_sv_pb(
{
int rc;
struct slapdplugin *pi = NULL;
- IFP v2k_fn = NULL;
+ int32_t (*v2k_fn)(Slapi_PBlock*, Slapi_Value**, Slapi_Value***, int32_t) = NULL;
if ((sattr->a_plugin == NULL)) {
/* could be lazy plugin initialization, get it now */
@@ -748,7 +748,7 @@ slapi_attr_assertion2keys_ava_sv(
{
int rc;
struct slapdplugin *pi = NULL;
- IFP a2k_fn = NULL;
+ int32_t (*a2k_fn)(Slapi_PBlock *, Slapi_Value *, Slapi_Value ***, int32_t) = NULL;
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_attr_assertion2keys_ava_sv", "=>\n");
@@ -880,7 +880,7 @@ slapi_attr_assertion2keys_sub_sv_pb(
Slapi_PBlock *work_pb = NULL;
struct slapdplugin *pi = NULL;
struct slapdplugin *origpi = NULL;
- IFP a2k_fn = NULL;
+ int32_t (*a2k_fn)(Slapi_PBlock *, char *, char **, char *, Slapi_Value ***) = NULL;
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_attr_assertion2keys_sub_sv_pb", "=>\n");
@@ -951,7 +951,7 @@ slapi_attr_value_normalize_ext(
unsigned long filter_type)
{
Slapi_Attr myattr = {0};
- VFPV norm_fn = NULL;
+ void (*norm_fn)(Slapi_PBlock *, char *, int32_t, char **) = NULL;
if (!sattr) {
sattr = slapi_attr_init(&myattr, type);
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index cec1796ae..94943325f 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -3246,7 +3246,7 @@ slapi_pw_set_entry_ext(Slapi_Entry *entry, Slapi_Value **vals, int flags)
}
int
-pw_copy_entry_ext(Slapi_Entry *src_e, Slapi_Entry *dest_e)
+pw_copy_entry_ext(const Slapi_Entry *src_e, Slapi_Entry *dest_e)
{
struct slapi_pw_entry_ext *src_extp = NULL;
struct slapi_pw_entry_ext *dest_extp = NULL;
@@ -3257,7 +3257,7 @@ pw_copy_entry_ext(Slapi_Entry *src_e, Slapi_Entry *dest_e)
src_extp = (struct slapi_pw_entry_ext *)slapi_get_object_extension(
pw_entry_objtype,
- src_e,
+ (void *)src_e,
pw_entry_handle);
if (NULL == src_extp) {
return LDAP_NO_SUCH_ATTRIBUTE;
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 53b93171c..4f4406096 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1,7 +1,7 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2009 Red Hat, Inc.
* Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
+ * Copyright (C) 2009-2025 Red Hat, Inc.
* All rights reserved.
*
* Contributors:
@@ -866,10 +866,10 @@ struct slapi_entry
struct attrs_in_extension
{
char *ext_type;
- IFP ext_get;
- IFP ext_set;
- IFP ext_copy;
- IFP ext_get_size;
+ int32_t (*ext_get)(Slapi_Entry *, Slapi_Value ***);
+ int32_t (*ext_set)(Slapi_Entry *, Slapi_Value **, int32_t);
+ int32_t (*ext_copy)(const Slapi_Entry *, Slapi_Entry *);
+ int32_t (*ext_get_size)(Slapi_Entry *, size_t *);
};
extern struct attrs_in_extension attrs_in_extension[];
@@ -1041,7 +1041,7 @@ struct slapdplugin
int plg_precedence; /* for plugin execution ordering */
struct slapdplugin *plg_group; /* pointer to the group to which this plugin belongs */
struct pluginconfig plg_conf; /* plugin configuration parameters */
- IFP plg_cleanup; /* cleanup function */
+ int32_t (*plg_cleanup)(Slapi_PBlock *); /* cleanup function */
IFP plg_start; /* start function */
IFP plg_poststart; /* poststart function */
int plg_closed; /* mark plugin as closed */
@@ -1051,47 +1051,47 @@ struct slapdplugin
Slapi_Counter *plg_op_counter; /* operation counter, used for shutdown */
/* NOTE: These LDIF2DB and DB2LDIF fn pointers are internal only for now.
- I don't believe you can get these functions from a plug-in and
- then call them without knowing what IFP or VFP0 are. (These aren't
- declared in slapi-plugin.h.) More importantly, it's a pretty ugly
- way to get to these functions. (Do we want people to get locked into
- this?)
-
- The correct way to do this would be to expose these functions as
- front-end API functions. We can fix this for the next release.
- (No one has the time right now.)
- */
+ * I don't believe you can get these functions from a plug-in and
+ * then call them without knowing what IFP or VFP0 are. (These aren't
+ * declared in slapi-plugin.h.) More importantly, it's a pretty ugly
+ * way to get to these functions. (Do we want people to get locked into
+ * this?)
+ *
+ * The correct way to do this would be to expose these functions as
+ * front-end API functions. We can fix this for the next release.
+ * (No one has the time right now.)
+ */
union
{ /* backend database plugin structure */
struct plg_un_database_backend
{
- IFP plg_un_db_bind; /* bind */
- IFP plg_un_db_unbind; /* unbind */
- IFP plg_un_db_search; /* search */
- IFP plg_un_db_next_search_entry; /* iterate */
+ int32_t (*plg_un_db_bind)(Slapi_PBlock *); /* bind */
+ int32_t (*plg_un_db_unbind)(Slapi_PBlock *); /* undbind */
+ int32_t (*plg_un_db_search)(Slapi_PBlock *); /* search */
+ int32_t (*plg_un_db_next_search_entry)(Slapi_PBlock *); /* iterate */
IFP plg_un_db_next_search_entry_ext;
- VFPP plg_un_db_search_results_release; /* PAGED RESULTS */
- VFP plg_un_db_prev_search_results; /* PAGED RESULTS */
- IFP plg_un_db_entry_release;
- IFP plg_un_db_compare; /* compare */
- IFP plg_un_db_modify; /* modify */
- IFP plg_un_db_modrdn; /* modrdn */
- IFP plg_un_db_add; /* add */
- IFP plg_un_db_delete; /* delete */
- IFP plg_un_db_abandon; /* abandon */
- IFP plg_un_db_config; /* config */
- IFP plg_un_db_seq; /* sequence */
- IFP plg_un_db_entry; /* entry send */
- IFP plg_un_db_referral; /* referral send */
- IFP plg_un_db_result; /* result send */
- IFP plg_un_db_ldif2db; /* ldif 2 database */
- IFP plg_un_db_db2ldif; /* database 2 ldif */
- IFP plg_un_db_db2index; /* database 2 index */
- IFP plg_un_db_dbcompact; /* compact database */
- IFP plg_un_db_archive2db; /* ldif 2 database */
- IFP plg_un_db_db2archive; /* database 2 ldif */
- IFP plg_un_db_upgradedb; /* convert old idl to new */
- IFP plg_un_db_upgradednformat; /* convert old dn format to new */
+ VFPP plg_un_db_search_results_release; /* Paged results */
+ VFP plg_un_db_prev_search_results; /* Paged results */
+ int32_t (*plg_un_db_entry_release)(Slapi_PBlock *, void *); /* Releas entry from cache */
+ int32_t (*plg_un_db_compare)(Slapi_PBlock *); /* compare */
+ int32_t (*plg_un_db_modify)(Slapi_PBlock *); /* modify */
+ int32_t (*plg_un_db_modrdn)(Slapi_PBlock *); /* modrdn */
+ int32_t (*plg_un_db_add)(Slapi_PBlock *); /* add */
+ int32_t (*plg_un_db_delete)(Slapi_PBlock *); /* delete */
+ int32_t (*plg_un_db_abandon)(Slapi_PBlock *); /* abandon */
+ IFP plg_un_db_config; /* config */
+ int32_t (*plg_un_db_seq)(Slapi_PBlock *); /* sequence */
+ IFP plg_un_db_entry; /* entry send */
+ IFP plg_un_db_referral; /* referral send */
+ IFP plg_un_db_result;
+ int32_t (*plg_un_db_ldif2db)(Slapi_PBlock *); /* ldif 2 database */
+ int32_t (*plg_un_db_db2ldif)(Slapi_PBlock *); /* database 2 ldif */
+ int32_t (*plg_un_db_db2index)(Slapi_PBlock *); /* database 2 index */
+ int32_t (*plg_un_db_dbcompact)(Slapi_Backend *, bool); /* compact database */
+ int32_t (*plg_un_db_archive2db)(Slapi_PBlock *); /* ldif 2 database */
+ int32_t (*plg_un_db_db2archive)(Slapi_PBlock *); /* database 2 ldif */
+ int32_t (*plg_un_db_upgradedb)(Slapi_PBlock *); /* convert old idl to new */
+ int32_t (*plg_un_db_upgradednformat)(Slapi_PBlock *); /* convert old dn format to new */
IFP plg_un_db_begin; /* dbase txn begin */
IFP plg_un_db_commit; /* dbase txn commit */
IFP plg_un_db_abort; /* dbase txn abort */
@@ -1101,12 +1101,12 @@ struct slapdplugin
IFP plg_un_db_register_dn_callback; /* Register a function to call when a operation is applied to a given DN */
IFP plg_un_db_register_oc_callback; /* Register a function to call when a operation is applied to a given ObjectClass */
IFP plg_un_db_init_instance; /* initializes new db instance */
- IFP plg_un_db_wire_import; /* fast replica update */
- IFP plg_un_db_verify; /* verify db files */
- IFP plg_un_db_add_schema; /* add schema */
- IFP plg_un_db_get_info; /* get info */
- IFP plg_un_db_set_info; /* set info */
- IFP plg_un_db_ctrl_info; /* ctrl info */
+ int32_t (*plg_un_db_wire_import)(Slapi_PBlock *); /* fast replica update */
+ int32_t (*plg_un_db_verify)(Slapi_PBlock *); /* verify db files */
+ IFP plg_un_db_add_schema; /* add schema */
+ int32_t (*plg_un_db_get_info)(Slapi_Backend *, int32_t, void **); /* get info */
+ int32_t (*plg_un_db_set_info)(Slapi_Backend *, int32_t, void **); /* set info */
+ int32_t (*plg_un_db_ctrl_info)(Slapi_Backend *, int32_t, void **); /* ctrl info */
} plg_un_db;
#define plg_bind plg_un.plg_un_db.plg_un_db_bind
#define plg_unbind plg_un.plg_un_db.plg_un_db_unbind
@@ -1151,10 +1151,10 @@ struct slapdplugin
{
char **plg_un_pe_exoids; /* exop oids */
char **plg_un_pe_exnames; /* exop names (may be NULL) */
- IFP plg_un_pe_exhandler; /* handler */
+ int32_t (*plg_un_pe_exhandler)(Slapi_PBlock *); /* handler */
IFP plg_un_pe_pre_exhandler; /* pre extop */
IFP plg_un_pe_post_exhandler; /* post extop */
- IFP plg_un_pe_be_exhandler; /* handler to retrieve the be name for the operation */
+ int32_t (*plg_un_pe_be_exhandler)(Slapi_PBlock *, Slapi_Backend **); /* handler to retrieve the be name for the operation */
} plg_un_pe;
#define plg_exoids plg_un.plg_un_pe.plg_un_pe_exoids
#define plg_exnames plg_un.plg_un_pe.plg_un_pe_exnames
@@ -1290,20 +1290,20 @@ struct slapdplugin
/* matching rule plugin structure */
struct plg_un_matching_rule
{
- IFP plg_un_mr_filter_create; /* factory function */
- IFP plg_un_mr_indexer_create; /* factory function */
+ int32_t (*plg_un_mr_filter_create)(Slapi_PBlock *); /* factory function */
+ int32_t (*plg_un_mr_indexer_create)(Slapi_PBlock *); /* factory function */
/* new style syntax plugin functions */
/* not all functions will apply to all matching rule types */
/* e.g. a SUBSTR rule will not have a filter_ava func */
- IFP plg_un_mr_filter_ava;
- IFP plg_un_mr_filter_sub;
- IFP plg_un_mr_values2keys;
- IFP plg_un_mr_assertion2keys_ava;
- IFP plg_un_mr_assertion2keys_sub;
+ int32_t (*plg_un_mr_filter_ava)(Slapi_PBlock *, const struct berval *, Slapi_Value **, int32_t, Slapi_Value **);
+ int32_t (*plg_un_mr_filter_sub)(Slapi_PBlock *, char *, char **, char*, Slapi_Value **);
+ int32_t (*plg_un_mr_values2keys)(Slapi_PBlock *, Slapi_Value **, Slapi_Value ***, int32_t);
+ int32_t (*plg_un_mr_assertion2keys_ava)(Slapi_PBlock *, Slapi_Value *, Slapi_Value ***, int32_t);
+ int32_t (*plg_un_mr_assertion2keys_sub)(Slapi_PBlock *, char *, char **, char *, Slapi_Value ***);
int plg_un_mr_flags;
char **plg_un_mr_names;
- IFP plg_un_mr_compare; /* only for ORDERING */
- VFPV plg_un_mr_normalize;
+ int32_t (*plg_un_mr_compare)(struct berval *, struct berval *); /* only for ORDERING */
+ void (*plg_un_mr_normalize)(Slapi_PBlock *, char *, int32_t, char **);
} plg_un_mr;
#define plg_mr_filter_create plg_un.plg_un_mr.plg_un_mr_filter_create
#define plg_mr_indexer_create plg_un.plg_un_mr.plg_un_mr_indexer_create
@@ -1320,25 +1320,25 @@ struct slapdplugin
/* syntax plugin structure */
struct plg_un_syntax_struct
{
- IFP plg_un_syntax_filter_ava;
+ int32_t (*plg_un_syntax_filter_ava)(Slapi_PBlock *, const struct berval *, Slapi_Value **, int32_t, Slapi_Value **);
IFP plg_un_syntax_filter_ava_sv;
- IFP plg_un_syntax_filter_sub;
+ int32_t (*plg_un_syntax_filter_sub)(Slapi_PBlock*, char *, char **, char *, Slapi_Value**);
IFP plg_un_syntax_filter_sub_sv;
- IFP plg_un_syntax_values2keys;
+ int32_t (*plg_un_syntax_values2keys)(Slapi_PBlock*, Slapi_Value**, Slapi_Value***, int32_t);
IFP plg_un_syntax_values2keys_sv;
- IFP plg_un_syntax_assertion2keys_ava;
- IFP plg_un_syntax_assertion2keys_sub;
+ int32_t (*plg_un_syntax_assertion2keys_ava)(Slapi_PBlock*, Slapi_Value*, Slapi_Value***, int32_t);
+ int32_t (*plg_un_syntax_assertion2keys_sub)(Slapi_PBlock*, char*, char**, char*, Slapi_Value***);
int plg_un_syntax_flags;
/*
- from slapi-plugin.h
-#define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
-#define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2
-*/
+ * from slapi-plugin.h
+#define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
+#define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2
+ */
char **plg_un_syntax_names;
char *plg_un_syntax_oid;
IFP plg_un_syntax_compare;
- IFP plg_un_syntax_validate;
- VFPV plg_un_syntax_normalize;
+ int32_t (*plg_un_syntax_validate)(struct berval *);
+ void (*plg_un_syntax_normalize)(Slapi_PBlock *, char *, int32_t, char **);
} plg_un_syntax;
#define plg_syntax_filter_ava plg_un.plg_un_syntax.plg_un_syntax_filter_ava
#define plg_syntax_filter_sub plg_un.plg_un_syntax.plg_un_syntax_filter_sub
@@ -1355,10 +1355,11 @@ struct slapdplugin
struct plg_un_acl_struct
{
IFP plg_un_acl_init;
- IFP plg_un_acl_syntax_check;
- IFP plg_un_acl_access_allowed;
- IFP plg_un_acl_mods_allowed;
- IFP plg_un_acl_mods_update;
+ int32_t (*plg_un_acl_syntax_check)(Slapi_PBlock *, Slapi_Entry *, char **);
+ int32_t (*plg_un_acl_access_allowed)(Slapi_PBlock *, Slapi_Entry*, char **, struct berval *, int32_t, int32_t, char **);
+ int32_t (*plg_un_acl_mods_allowed)(Slapi_PBlock *, Slapi_Entry *, LDAPMod **, void *);
+ int32_t (*plg_un_acl_mods_update)(Slapi_PBlock *, int32_t, Slapi_DN *, void *);
+
} plg_un_acl;
#define plg_acl_init plg_un.plg_un_acl.plg_un_acl_init
#define plg_acl_syntax_check plg_un.plg_un_acl.plg_un_acl_syntax_check
@@ -1368,8 +1369,8 @@ struct slapdplugin
struct plg_un_mmr_struct
{
- IFP plg_un_mmr_betxn_preop;
- IFP plg_un_mmr_betxn_postop;
+ int32_t (*plg_un_mmr_betxn_preop)(Slapi_PBlock *, int32_t);
+ int32_t (*plg_un_mmr_betxn_postop)(Slapi_PBlock *, int32_t);
} plg_un_mmr;
#define plg_mmr_betxn_preop plg_un.plg_un_mmr.plg_un_mmr_betxn_preop
#define plg_mmr_betxn_postop plg_un.plg_un_mmr.plg_un_mmr_betxn_postop
@@ -1390,8 +1391,8 @@ struct slapdplugin
/* entry fetch/store */
struct plg_un_entry_fetch_store_struct
{
- IFP plg_un_entry_fetch_func;
- IFP plg_un_entry_store_func;
+ int32_t (*plg_un_entry_fetch_func)(char **, uint32_t *);
+ int32_t (*plg_un_entry_store_func)(char **, uint32_t *);
} plg_un_entry_fetch_store;
#define plg_entryfetchfunc plg_un.plg_un_entry_fetch_store.plg_un_entry_fetch_func
#define plg_entrystorefunc plg_un.plg_un_entry_fetch_store.plg_un_entry_store_func
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index b119da0bf..bcf18f064 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1405,7 +1405,7 @@ int slapi_add_internal_attr_syntax(const char *name, const char *oid, const char
/* pw.c */
void pw_exp_init(void);
-int pw_copy_entry_ext(Slapi_Entry *src_e, Slapi_Entry *dest_e);
+int pw_copy_entry_ext(const Slapi_Entry *src_e, Slapi_Entry *dest_e);
int pw_get_ext_size(Slapi_Entry *e, size_t *size);
/* op_shared.c */
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index c14af83e0..d2a9a1b48 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -2036,7 +2036,7 @@ task_upgradedb_add(Slapi_PBlock *pb __attribute__((unused)),
int32_t task_flags = SLAPI_TASK_RUNNING_AS_TASK;
slapi_pblock_set(mypb, SLAPI_TASK_FLAGS, &task_flags);
- rv = (be->be_database->plg_upgradedb)(&mypb);
+ rv = (be->be_database->plg_upgradedb)(mypb);
if (rv == 0) {
slapi_entry_attr_set_charptr(e, TASK_LOG_NAME, "");
slapi_entry_attr_set_charptr(e, TASK_STATUS_NAME, "");
| 0 |
6319251696baccdbd8ab42390c0802996f3c701e
|
389ds/389-ds-base
|
Bug 515329 - Correct attribute value inconsistency on replica
When performing operations with multiple mods to the same multi-valued
attribute on a single modify operation, a replica was not resolving
the attribute values correctly. This would lead to an inconsistency
between the master the change was initially performed against and the
replicas. The problem would occur with a modify operation such as
this:
dn: uid=testuser,dc=example,dc=com
changetype: modify
add: cn
cn: 2
-
replace: cn
cn: 3
The problem is that we use the CSNs from the attribute state data
to determine which values should remain after the operation (this is
done to merge with later occuring changes from other masters). The
CSN for all mods within the same modify operation is exactly the same.
The old code was looking for attributes older than the deletion that
occurs as a part of the replace, then deleting those values. This
would cause the value of "2" in the above example to remain. Simply
changing this comparision to look for values with the same or older
CSN to delete would cause the new value of "3" to be removed as well
when we get around to resolving the attribute after the second half
of the replace operation.
The fix is to use a different CSN comparison when we are removing all
values of an attribute during attribute resolution (remove values with
the same or older CSN). This is safe becuse the only present values
at this time are older values or values added in a previous mod in the
same modify operation. When processing other mods that are not
removing all values of an attribute, we only want to remove values
with a CSN older that that of the current modify operation. This
prevents us from removing a newly added value, such as "3" in the
example above. This is safe since we resolve the attribute after
each mod in the modify operation.
|
commit 6319251696baccdbd8ab42390c0802996f3c701e
Author: Nathan Kinder <[email protected]>
Date: Mon Nov 16 12:03:26 2009 -0800
Bug 515329 - Correct attribute value inconsistency on replica
When performing operations with multiple mods to the same multi-valued
attribute on a single modify operation, a replica was not resolving
the attribute values correctly. This would lead to an inconsistency
between the master the change was initially performed against and the
replicas. The problem would occur with a modify operation such as
this:
dn: uid=testuser,dc=example,dc=com
changetype: modify
add: cn
cn: 2
-
replace: cn
cn: 3
The problem is that we use the CSNs from the attribute state data
to determine which values should remain after the operation (this is
done to merge with later occuring changes from other masters). The
CSN for all mods within the same modify operation is exactly the same.
The old code was looking for attributes older than the deletion that
occurs as a part of the replace, then deleting those values. This
would cause the value of "2" in the above example to remain. Simply
changing this comparision to look for values with the same or older
CSN to delete would cause the new value of "3" to be removed as well
when we get around to resolving the attribute after the second half
of the replace operation.
The fix is to use a different CSN comparison when we are removing all
values of an attribute during attribute resolution (remove values with
the same or older CSN). This is safe becuse the only present values
at this time are older values or values added in a previous mod in the
same modify operation. When processing other mods that are not
removing all values of an attribute, we only want to remove values
with a CSN older that that of the current modify operation. This
prevents us from removing a newly added value, such as "3" in the
example above. This is safe since we resolve the attribute after
each mod in the modify operation.
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
index 9923f57ff..579d044da 100644
--- a/ldap/servers/slapd/entrywsi.c
+++ b/ldap/servers/slapd/entrywsi.c
@@ -46,7 +46,7 @@
#include "slap.h"
#include "slapi-plugin.h"
-static void resolve_attribute_state(Slapi_Entry *e, Slapi_Attr *a, int attribute_state);
+static void resolve_attribute_state(Slapi_Entry *e, Slapi_Attr *a, int attribute_state, int delete_priority);
static int
entry_present_value_to_deleted_value(Slapi_Attr *a, Slapi_Value *v)
@@ -477,7 +477,7 @@ entry_add_present_values_wsi(Slapi_Entry *e, const char *type, struct berval **b
* Now delete non-RDN values from a->a_present_values; and
* restore possible RDN values from a->a_deleted_values
*/
- resolve_attribute_state(e, a, attr_state);
+ resolve_attribute_state(e, a, attr_state, 0);
retVal= LDAP_SUCCESS;
}
else
@@ -547,7 +547,7 @@ entry_delete_present_values_wsi(Slapi_Entry *e, const char *type, struct berval
attr_set_deletion_csn(a,csn);
if(urp)
{
- resolve_attribute_state(e, a, attr_state); /* ABSOLVED */
+ resolve_attribute_state(e, a, attr_state, 1 /* set delete priority */); /* ABSOLVED */
}
else
{
@@ -589,7 +589,7 @@ entry_delete_present_values_wsi(Slapi_Entry *e, const char *type, struct berval
* should free valuestodelete only (don't call valuearray_free)
* [622023] */
slapi_ch_free((void **)&valuestodelete);
- resolve_attribute_state(e, a, attr_state);
+ resolve_attribute_state(e, a, attr_state, 0);
retVal= LDAP_SUCCESS;
}
else
@@ -955,7 +955,7 @@ value_distinguished_at_csn(const Slapi_Entry *e, const Slapi_Attr *original_attr
}
static void
-resolve_attribute_state_multi_valued(Slapi_Entry *e, Slapi_Attr *a, int attribute_state)
+resolve_attribute_state_multi_valued(Slapi_Entry *e, Slapi_Attr *a, int attribute_state, int delete_priority)
{
int i;
const CSN *adcsn= attr_get_deletion_csn(a);
@@ -976,7 +976,17 @@ resolve_attribute_state_multi_valued(Slapi_Entry *e, Slapi_Attr *a, int attribut
vdcsn= value_get_csn(v, CSN_TYPE_VALUE_DELETED);
vucsn= value_get_csn(v, CSN_TYPE_VALUE_UPDATED);
deletedcsn= csn_max(vdcsn, adcsn);
- if(csn_compare(vucsn,deletedcsn)<0) /* check if the attribute or value was deleted after the value was last updated */
+
+ /* Check if the attribute or value was deleted after the value was
+ * last updated. If the value update CSN and the deleted CSN are
+ * the same (meaning they are separate mods from the same exact
+ * operation), we should only delete the value if delete priority
+ * is set. Delete priority should only be set when we are deleting
+ * all value of an attribute. This prevents us from leaving a value
+ * that was added as a previous mod in the same exact modify
+ * operation as the subsequent delete.*/
+ if((csn_compare(vucsn,deletedcsn)<0) ||
+ (delete_priority && (csn_compare(vucsn,deletedcsn) == 0)))
{
if(!value_distinguished_at_csn(e, a, v, deletedcsn))
{
@@ -1000,7 +1010,9 @@ resolve_attribute_state_multi_valued(Slapi_Entry *e, Slapi_Attr *a, int attribut
vdcsn= value_get_csn(v, CSN_TYPE_VALUE_DELETED);
vucsn= value_get_csn(v, CSN_TYPE_VALUE_UPDATED);
deletedcsn= csn_max(vdcsn, adcsn);
- if((csn_compare(vucsn,deletedcsn)>=0) || /* check if the attribute or value was deleted after the value was last updated */
+
+ /* check if the attribute or value was deleted after the value was last updated */
+ if((csn_compare(vucsn,deletedcsn)>0) ||
value_distinguished_at_csn(e, a, v, deletedcsn))
{
entry_deleted_value_to_present_value(a,v);
@@ -1178,7 +1190,7 @@ resolve_attribute_state_single_valued(Slapi_Entry *e, Slapi_Attr *a, int attribu
}
static void
-resolve_attribute_state(Slapi_Entry *e, Slapi_Attr *a, int attribute_state)
+resolve_attribute_state(Slapi_Entry *e, Slapi_Attr *a, int attribute_state, int delete_priority)
{
if(slapi_attr_flag_is_set(a,SLAPI_ATTR_FLAG_SINGLE))
{
@@ -1186,6 +1198,6 @@ resolve_attribute_state(Slapi_Entry *e, Slapi_Attr *a, int attribute_state)
}
else
{
- resolve_attribute_state_multi_valued(e,a,attribute_state);
+ resolve_attribute_state_multi_valued(e,a,attribute_state, delete_priority);
}
}
| 0 |
940ac98613957b69c3b32e47ed50cd25d5a80542
|
389ds/389-ds-base
|
Ticket 747 - Root DN Access Control - days allowed not working correctly
Bug Description: If you set more than one day in the rootdn-days-allowed config
attribute the plugin can reject all rootDN binds.
Fix Description: Correct the order of the char strings in strstr().
https://fedorahosted.org/389/ticket/474
Reviewed by: richm(Thanks!)
|
commit 940ac98613957b69c3b32e47ed50cd25d5a80542
Author: Mark Reynolds <[email protected]>
Date: Fri Sep 21 15:33:45 2012 -0400
Ticket 747 - Root DN Access Control - days allowed not working correctly
Bug Description: If you set more than one day in the rootdn-days-allowed config
attribute the plugin can reject all rootDN binds.
Fix Description: Correct the order of the char strings in strstr().
https://fedorahosted.org/389/ticket/474
Reviewed by: richm(Thanks!)
diff --git a/ldap/servers/plugins/rootdn_access/rootdn_access.c b/ldap/servers/plugins/rootdn_access/rootdn_access.c
index 19e578c03..bae2703eb 100644
--- a/ldap/servers/plugins/rootdn_access/rootdn_access.c
+++ b/ldap/servers/plugins/rootdn_access/rootdn_access.c
@@ -440,8 +440,9 @@ rootdn_check_access(Slapi_PBlock *pb){
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");
+ if(!strstr(daysAllowed, today)){
+ slapi_log_error(SLAPI_LOG_PLUGIN, ROOTDN_PLUGIN_SUBSYSTEM, "rootdn_check_access: bind not allowed for today(%s), "
+ "only allowed on days: %s\n", today, daysAllowed);
return -1;
}
}
| 0 |
4383fcacf5d3f1c77f04c6b347b80017a12a30eb
|
389ds/389-ds-base
|
bump version to 1.2.5.rc3
|
commit 4383fcacf5d3f1c77f04c6b347b80017a12a30eb
Author: Rich Megginson <[email protected]>
Date: Thu Dec 17 17:01:36 2009 -0700
bump version to 1.2.5.rc3
diff --git a/VERSION.sh b/VERSION.sh
index 42deb3907..bf0ee2d91 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -14,7 +14,7 @@ VERSION_MAINT=5
# if this is a PRERELEASE, set VERSION_PREREL
# otherwise, comment it out
# be sure to include the dot prefix in the prerel
-VERSION_PREREL=.rc2
+VERSION_PREREL=.rc3
# NOTES on VERSION_PREREL
# use aN for an alpha release e.g. a1, a2, etc.
# use rcN for a release candidate e.g. rc1, rc2, etc.
| 0 |
5c75740c62bd228b2bde244a55467f4724ce80a4
|
389ds/389-ds-base
|
610281 - fix coverity Defect Type: Control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=610281
11818 DEADCODE Triaged Unassigned Bug Minor Fix Required
agt_mopen_stats() ds/ldap/servers/slapd/agtmmap.c
Comment:
Removing the unreachable statement:
Execution cannot reach this statement "return 0;".
313 return 0;
|
commit 5c75740c62bd228b2bde244a55467f4724ce80a4
Author: Noriko Hosoi <[email protected]>
Date: Fri Jul 2 17:59:53 2010 -0700
610281 - fix coverity Defect Type: Control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=610281
11818 DEADCODE Triaged Unassigned Bug Minor Fix Required
agt_mopen_stats() ds/ldap/servers/slapd/agtmmap.c
Comment:
Removing the unreachable statement:
Execution cannot reach this statement "return 0;".
313 return 0;
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index 8211b7ba3..b152a7c31 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -219,7 +219,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
} /* end switch */
#else
-
+ /* _WIN32 */
switch (mode) {
case O_RDONLY:
{
@@ -310,8 +310,6 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
#endif /* !__WINNT__ */
-return 0;
-
} /* agt_mopen_stats () */
| 0 |
7e98ab34305c081859ca0ee5a30888991898a452
|
389ds/389-ds-base
|
Issue 6372 - Deadlock while doing online backup (#6475)
* Issue 6372 - Deadlock while doing online backup
Sometime server hangs during online backup because of a deadlock due to lock order inversion between the dse backup_lock mutex and the dse rwlock.
Solution:
Add functions to manage the lock/unlock to ensure consistency.
Ensure that threads always tries to lock dse_backup_lock mutex before the dse write lock
Code cleanup:
Move the backup_lock into the dse struct
Avoid the obsolete warning during tests (I think that we will have to do a second cleanup phase later to see if we could not replace self.conn.add_s by self.create .
Issue: #6372
Reviewed by: @mreynolds389 (Thanks!)
|
commit 7e98ab34305c081859ca0ee5a30888991898a452
Author: progier389 <[email protected]>
Date: Tue Jan 7 11:40:16 2025 +0100
Issue 6372 - Deadlock while doing online backup (#6475)
* Issue 6372 - Deadlock while doing online backup
Sometime server hangs during online backup because of a deadlock due to lock order inversion between the dse backup_lock mutex and the dse rwlock.
Solution:
Add functions to manage the lock/unlock to ensure consistency.
Ensure that threads always tries to lock dse_backup_lock mutex before the dse write lock
Code cleanup:
Move the backup_lock into the dse struct
Avoid the obsolete warning during tests (I think that we will have to do a second cleanup phase later to see if we could not replace self.conn.add_s by self.create .
Issue: #6372
Reviewed by: @mreynolds389 (Thanks!)
diff --git a/dirsrvtests/tests/suites/backups/backup_test.py b/dirsrvtests/tests/suites/backups/backup_test.py
index 22885b43f..1246469a3 100644
--- a/dirsrvtests/tests/suites/backups/backup_test.py
+++ b/dirsrvtests/tests/suites/backups/backup_test.py
@@ -17,16 +17,20 @@ import ldap
from datetime import datetime
from lib389._constants import DN_DM, PASSWORD, DEFAULT_SUFFIX, INSTALL_LATEST_CONFIG
from lib389.properties import BACKEND_SAMPLE_ENTRIES, TASK_WAIT
-from lib389.topologies import topology_st as topo, topology_m2 as topo_m2
+from lib389.topologies import topology_st as topo, topology_m2 as topo_m2, set_timeout
from lib389.backend import Backends, Backend
from lib389.dbgen import dbgen_users
from lib389.tasks import BackupTask, RestoreTask
from lib389.config import BDB_LDBMConfig
+from lib389.idm.nscontainer import nsContainers
from lib389 import DSEldif
from lib389.utils import ds_is_older, get_default_db_lib
from lib389.replica import ReplicationManager
+from threading import Thread, Event
import tempfile
+
+
pytestmark = pytest.mark.tier1
DEBUGGING = os.getenv("DEBUGGING", default=False)
@@ -36,6 +40,11 @@ else:
logging.getLogger(__name__).setLevel(logging.INFO)
log = logging.getLogger(__name__)
+# test_online_backup_and_dse_write may hang if 6372 is not fixed
+# so lets use a shorter timeout
+set_timeout(30*60)
+
+event = Event()
BESTRUCT = [
{ "bename" : "be1", "suffix": "dc=be1", "nbusers": 1000 },
@@ -348,6 +357,38 @@ def test_backup_task_after_failure(mytopo):
assert exitCode == 0, "Backup failed. Issue #6229 may not be fixed."
+def load_dse(inst):
+ conts = nsContainers(inst, 'cn=config')
+ while not event.is_set():
+ cont = conts.create(properties={'cn': 'test_online_backup_and_dse_write'})
+ cont.delete()
+
+
+def test_online_backup_and_dse_write(topo):
+ """Test online backup while attempting to add/delete entries in dse.ldif.
+
+ :id: 4a1edd2c-be15-11ef-8bc8-482ae39447e5
+ :setup: One standalone instance
+ :steps:
+ 1. Start a thread that loops adding then removing in the dse.ldif
+ 2. Perform 10 online backups
+ 3. Stop the thread
+ :expectedresults:
+ 1. Success
+ 2. Success (or timeout if issue #6372 is not fixed.)
+ 3. Success
+ """
+ inst = topo.standalone
+ t = Thread(target=load_dse, args=[inst])
+ t.start()
+ for x in range(10):
+ with tempfile.TemporaryDirectory() as backup_dir:
+ assert inst.tasks.db2bak(backup_dir=f'{backup_dir}', args={TASK_WAIT: True}) == 0
+ event.set()
+ t.join()
+ event.clear()
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c
index 2edc3f1f6..e3157c1ce 100644
--- a/ldap/servers/slapd/dse.c
+++ b/ldap/servers/slapd/dse.c
@@ -41,6 +41,7 @@
#include <pwd.h>
/* Needed to access read_config_dse */
#include "proto-slap.h"
+#include <stdbool.h>
#include <unistd.h> /* provides fsync/close */
@@ -73,9 +74,6 @@
#define DSE_USE_LOCK 1
#define DSE_NO_LOCK 0
-/* Global lock used during backups */
-static PRLock *backup_lock = NULL;
-
struct dse_callback
{
int operation;
@@ -104,6 +102,8 @@ struct dse
/* initialize the dse */
int dse_is_updateable; /* if non-zero, this DSE can be written to */
int dse_readonly_error_reported; /* used to ensure that read-only errors are logged only once */
+ pthread_mutex_t dse_backup_lock; /* used to block write when online backup is in progress */
+ bool dse_backup_in_progress; /* tell that online backup is in progress (protected by dse_rwlock) */
};
struct dse_node
@@ -155,6 +155,91 @@ static int dse_write_entry(caddr_t data, caddr_t arg);
static int ldif_record_end(char *p);
static int dse_call_callback(struct dse *pdse, Slapi_PBlock *pb, int operation, int flags, Slapi_Entry *entryBefore, Slapi_Entry *entryAfter, int *returncode, char *returntext);
+/* Lock the dse in read mode */
+INLINE_DIRECTIVE static void
+dse_lock_read(struct dse *pdse, int use_lock)
+{
+ if (use_lock == DSE_USE_LOCK && pdse->dse_rwlock) {
+ slapi_rwlock_rdlock(pdse->dse_rwlock);
+ }
+}
+
+/* Lock the dse in write mode and wait until the */
+INLINE_DIRECTIVE static void
+dse_lock_write(struct dse *pdse, int use_lock)
+{
+ if (use_lock != DSE_USE_LOCK || !pdse->dse_rwlock) {
+ return;
+ }
+ slapi_rwlock_wrlock(pdse->dse_rwlock);
+ while (pdse->dse_backup_in_progress) {
+ slapi_rwlock_unlock(pdse->dse_rwlock);
+ /* Wait util dse_backup_lock is unlocked */
+ pthread_mutex_lock(&pdse->dse_backup_lock);
+ pthread_mutex_unlock(&pdse->dse_backup_lock);
+ slapi_rwlock_wrlock(pdse->dse_rwlock);
+ }
+}
+
+/* release the dse lock */
+INLINE_DIRECTIVE static void
+dse_lock_unlock(struct dse *pdse, int use_lock)
+{
+ if (use_lock == DSE_USE_LOCK && pdse->dse_rwlock) {
+ slapi_rwlock_unlock(pdse->dse_rwlock);
+ }
+}
+
+/* Call cb(pdse) */
+INLINE_DIRECTIVE static void
+dse_call_cb(void (*cb)(struct dse*))
+{
+ Slapi_Backend *be = slapi_be_select_by_instance_name("DSE");
+ if (be) {
+ struct dse *pdse = NULL;
+ slapi_be_Rlock(be);
+ pdse = be->be_database->plg_private;
+ if (pdse) {
+ cb(pdse);
+ }
+ slapi_be_Unlock(be);
+ }
+}
+
+/* Helper for dse_backup_lock() */
+static void
+dse_backup_lock_cb(struct dse *pdse)
+{
+ pthread_mutex_lock(&pdse->dse_backup_lock);
+ slapi_rwlock_wrlock(pdse->dse_rwlock);
+ pdse->dse_backup_in_progress = true;
+ slapi_rwlock_unlock(pdse->dse_rwlock);
+}
+
+/* Helper for dse_backup_unlock() */
+static void
+dse_backup_unlock_cb(struct dse *pdse)
+{
+ slapi_rwlock_wrlock(pdse->dse_rwlock);
+ pdse->dse_backup_in_progress = false;
+ slapi_rwlock_unlock(pdse->dse_rwlock);
+ pthread_mutex_unlock(&pdse->dse_backup_lock);
+}
+
+/* Tells that a backup thread is starting */
+void
+dse_backup_lock()
+{
+ dse_call_cb(dse_backup_lock_cb);
+}
+
+/* Tells that a backup thread is ending */
+void
+dse_backup_unlock()
+{
+ dse_call_cb(dse_backup_unlock_cb);
+}
+
/*
* Map a DN onto a dse_node.
* Returns NULL if not found.
@@ -192,18 +277,12 @@ 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) {
- slapi_rwlock_rdlock(pdse->dse_rwlock);
- }
-
+ dse_lock_read(pdse, use_lock);
n = dse_find_node(pdse, dn);
if (n != NULL) {
e = slapi_entry_dup(n->entry);
}
-
- if (use_lock == DSE_USE_LOCK && pdse->dse_rwlock) {
- slapi_rwlock_unlock(pdse->dse_rwlock);
- }
+ dse_lock_unlock(pdse, use_lock);
return e;
}
@@ -393,6 +472,7 @@ dse_new(char *filename, char *tmpfilename, char *backfilename, char *startokfile
pdse->dse_callback = NULL;
pdse->dse_is_updateable = dse_permission_to_write(pdse,
SLAPI_LOG_TRACE);
+ pthread_mutex_init(&pdse->dse_backup_lock, NULL);
}
slapi_ch_free((void **)&realconfigdir);
}
@@ -429,8 +509,7 @@ dse_destroy(struct dse *pdse)
if (NULL == pdse) {
return 0; /* no one checks this return value */
}
- if (pdse->dse_rwlock)
- slapi_rwlock_wrlock(pdse->dse_rwlock);
+ dse_lock_write(pdse, DSE_USE_LOCK);
slapi_ch_free((void **)&(pdse->dse_filename));
slapi_ch_free((void **)&(pdse->dse_tmpfile));
slapi_ch_free((void **)&(pdse->dse_fileback));
@@ -439,8 +518,8 @@ dse_destroy(struct dse *pdse)
dse_callback_deletelist(&pdse->dse_callback);
charray_free(pdse->dse_filelist);
nentries = avl_free(pdse->dse_tree, dse_internal_delete_entry);
+ dse_lock_unlock(pdse, DSE_USE_LOCK);
if (pdse->dse_rwlock) {
- slapi_rwlock_unlock(pdse->dse_rwlock);
slapi_destroy_rwlock(pdse->dse_rwlock);
}
slapi_ch_free((void **)&pdse);
@@ -928,9 +1007,7 @@ dse_check_for_readonly_error(Slapi_PBlock *pb, struct dse *pdse)
{
int rc = 0; /* default: no error */
- if (pdse->dse_rwlock)
- slapi_rwlock_rdlock(pdse->dse_rwlock);
-
+ dse_lock_read(pdse, DSE_USE_LOCK);
if (!pdse->dse_is_updateable) {
if (!pdse->dse_readonly_error_reported) {
if (NULL != pdse->dse_filename) {
@@ -944,9 +1021,7 @@ dse_check_for_readonly_error(Slapi_PBlock *pb, struct dse *pdse)
}
rc = 1; /* return an error to the client */
}
-
- if (pdse->dse_rwlock)
- slapi_rwlock_unlock(pdse->dse_rwlock);
+ dse_lock_unlock(pdse, DSE_USE_LOCK);
if (rc != 0) {
slapi_send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
@@ -973,8 +1048,6 @@ dse_write_file_nolock(struct dse *pdse)
fpw.fpw_rc = 0;
fpw.fpw_prfd = NULL;
- dse_backup_lock();
-
if (NULL != pdse->dse_filename) {
if ((fpw.fpw_prfd = PR_Open(pdse->dse_tmpfile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, SLAPD_DEFAULT_DSE_FILE_MODE)) == NULL) {
rc = PR_GetOSError();
@@ -1107,8 +1180,7 @@ dse_add_entry_pb(struct dse *pdse, Slapi_Entry *e, Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_DSE_MERGE_WHEN_ADDING, &merge);
/* keep write lock during both tree update and file write operations */
- if (pdse->dse_rwlock)
- slapi_rwlock_wrlock(pdse->dse_rwlock);
+ dse_lock_write(pdse, DSE_USE_LOCK);
if (merge) {
rc = avl_insert(&(pdse->dse_tree), n, entry_dn_cmp, dupentry_merge);
} else {
@@ -1131,8 +1203,7 @@ dse_add_entry_pb(struct dse *pdse, Slapi_Entry *e, Slapi_PBlock *pb)
} else { /* duplicate entry ignored */
dse_node_delete(&n); /* This also deletes the contained entry */
}
- if (pdse->dse_rwlock)
- slapi_rwlock_unlock(pdse->dse_rwlock);
+ dse_lock_unlock(pdse, DSE_USE_LOCK);
if (rc == -1) {
/* duplicate entry ignored */
@@ -1299,8 +1370,7 @@ dse_replace_entry(struct dse *pdse, Slapi_Entry *e, int write_file, int use_lock
int rc = -1;
if (NULL != e) {
struct dse_node *n = dse_node_new(e);
- if (use_lock && pdse->dse_rwlock)
- slapi_rwlock_wrlock(pdse->dse_rwlock);
+ dse_lock_write(pdse, use_lock);
rc = avl_insert(&(pdse->dse_tree), n, entry_dn_cmp, dupentry_replace);
if (write_file)
dse_write_file_nolock(pdse);
@@ -1310,8 +1380,7 @@ dse_replace_entry(struct dse *pdse, Slapi_Entry *e, int write_file, int use_lock
dse_node_delete(&n);
rc = 0; /* for return to caller */
}
- if (use_lock && pdse->dse_rwlock)
- slapi_rwlock_unlock(pdse->dse_rwlock);
+ dse_lock_unlock(pdse, use_lock);
}
return rc;
}
@@ -1398,8 +1467,7 @@ dse_delete_entry(struct dse *pdse, Slapi_PBlock *pb, const Slapi_Entry *e)
slapi_pblock_get(pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, &dont_write_file);
/* keep write lock for both tree deleting and file writing */
- if (pdse->dse_rwlock)
- slapi_rwlock_wrlock(pdse->dse_rwlock);
+ dse_lock_write(pdse, DSE_USE_LOCK);
if ((deleted_node = (struct dse_node *)avl_delete(&pdse->dse_tree, n, entry_dn_cmp))) {
dse_node_delete(&deleted_node);
}
@@ -1411,8 +1479,7 @@ dse_delete_entry(struct dse *pdse, Slapi_PBlock *pb, const Slapi_Entry *e)
SLAPI_OPERATION_DELETE);
dse_write_file_nolock(pdse);
}
- if (pdse->dse_rwlock)
- slapi_rwlock_unlock(pdse->dse_rwlock);
+ dse_lock_unlock(pdse, DSE_USE_LOCK);
return 1;
}
@@ -1574,11 +1641,9 @@ do_dse_search(struct dse *pdse, Slapi_PBlock *pb, int scope, const Slapi_DN *bas
* entries that change, we skip looking through the DSE entries.
*/
if (pb_op == NULL || !operation_is_flag_set(pb_op, OP_FLAG_PS_CHANGESONLY)) {
- if (pdse->dse_rwlock)
- slapi_rwlock_rdlock(pdse->dse_rwlock);
+ dse_lock_read(pdse, DSE_USE_LOCK);
dse_apply_nolock(pdse, dse_search_filter_entry, (caddr_t)&stuff);
- if (pdse->dse_rwlock)
- slapi_rwlock_unlock(pdse->dse_rwlock);
+ dse_lock_unlock(pdse, DSE_USE_LOCK);
}
if (stuff.ss) /* something was found which matched our criteria */
@@ -2925,32 +2990,3 @@ dse_next_search_entry(Slapi_PBlock *pb)
return 0;
}
-/* When a backup is occurring we can not allow the writing the dse.ldif file */
-void
-dse_init_backup_lock()
-{
- backup_lock = PR_NewLock();
-}
-
-void
-dse_destroy_backup_lock()
-{
- PR_DestroyLock(backup_lock);
- backup_lock = NULL;
-}
-
-void
-dse_backup_lock()
-{
- if (backup_lock) {
- PR_Lock(backup_lock);
- }
-}
-
-void
-dse_backup_unlock()
-{
- if (backup_lock) {
- PR_Unlock(backup_lock);
- }
-}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 327937223..855ca9c3c 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -2033,9 +2033,6 @@ FrontendConfig_init(void)
/* Done, unlock! */
CFG_UNLOCK_WRITE(cfg);
- /* init the dse file backup lock */
- dse_init_backup_lock();
-
init_config_get_and_set();
}
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 1cdfeaa36..cc9f43799 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1164,7 +1164,6 @@ cleanup:
slapd_ssl_destroy();
ndn_cache_destroy();
NSS_Shutdown();
- dse_destroy_backup_lock();
/*
* Server has stopped, lets force everything to disk: logs
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index f0f6a4b70..b119da0bf 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1415,8 +1415,6 @@ void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);
void add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e);
/* dse.c */
-void dse_init_backup_lock(void);
-void dse_destroy_backup_lock(void);
void dse_backup_lock(void);
void dse_backup_unlock(void);
diff --git a/src/lib389/lib389/tasks.py b/src/lib389/lib389/tasks.py
index c1a2e7aaa..6bf302862 100644
--- a/src/lib389/lib389/tasks.py
+++ b/src/lib389/lib389/tasks.py
@@ -525,7 +525,7 @@ class Tasks(object):
entry.setValues('nsIncludeSuffix', suffix)
# start the task and possibly wait for task completion
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
exitCode = 0
warningCode = 0
@@ -598,7 +598,7 @@ class Tasks(object):
entry.setValues('nsExportReplica', 'true')
# start the task and possibly wait for task completion
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
exitCode = 0
warningCode = 0
if args and args.get(TASK_WAIT, False):
@@ -649,7 +649,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add the backup task (%s)", dn)
return -1
@@ -706,7 +706,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add the backup task (%s)", dn)
return -1
@@ -834,7 +834,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add the index task for %s", attrname)
return -1
@@ -914,7 +914,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add the memberOf fixup task")
return -1
@@ -975,7 +975,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add the fixup tombstone task")
return -1
@@ -1031,7 +1031,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Automember Rebuild Membership task")
return -1
@@ -1087,7 +1087,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Automember Export Updates task")
return -1
@@ -1138,7 +1138,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Automember Map Updates task")
return -1
@@ -1183,7 +1183,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Fixup Linked Attributes task")
return -1
@@ -1227,7 +1227,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Schema Reload task")
return -1
@@ -1272,7 +1272,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add fixupWinsyncMembers 'memberuid task'")
return -1
@@ -1319,7 +1319,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Syntax Validate task")
return -1
@@ -1370,7 +1370,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add USN tombstone cleanup task")
return -1
@@ -1421,7 +1421,7 @@ class Tasks(object):
entry.setValues('logchanges', logchanges)
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Sysconfig Reload task")
return -1
@@ -1473,7 +1473,7 @@ class Tasks(object):
entry.setValues('replica-force-cleaning', 'yes')
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add cleanAllRUV task")
return (dn, -1)
@@ -1528,7 +1528,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Abort cleanAllRUV task")
return (dn, -1)
@@ -1582,7 +1582,7 @@ class Tasks(object):
# start the task and possibly wait for task completion
try:
- self.conn.add_s(entry)
+ self.conn.add_s(entry, escapehatch='i am sure')
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add upgradedb task")
return -1
| 0 |
d72a226f6499f72c79123e2d929650d4e9c3716f
|
389ds/389-ds-base
|
Ticket 49327 - Add CI test for password expiration controls
Description: Add CI script for testing the various expired/expiring
controls.
https://pagure.io/389-ds-base/issue/49327
Reviewed by: spichugi(Thanks!)
|
commit d72a226f6499f72c79123e2d929650d4e9c3716f
Author: Mark Reynolds <[email protected]>
Date: Thu Sep 21 14:18:30 2017 -0400
Ticket 49327 - Add CI test for password expiration controls
Description: Add CI script for testing the various expired/expiring
controls.
https://pagure.io/389-ds-base/issue/49327
Reviewed by: spichugi(Thanks!)
diff --git a/dirsrvtests/tests/suites/password/pwdPolicy_controls_test.py b/dirsrvtests/tests/suites/password/pwdPolicy_controls_test.py
new file mode 100644
index 000000000..d0b5ae086
--- /dev/null
+++ b/dirsrvtests/tests/suites/password/pwdPolicy_controls_test.py
@@ -0,0 +1,324 @@
+import logging
+import pytest
+import os
+import ldap
+import time
+from ldap.controls.ppolicy import PasswordPolicyControl
+from lib389.topologies import topology_st as topo
+from lib389._constants import (DN_DM, PASSWORD, DN_CONFIG)
+from lib389.tasks import Entry
+
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+USER_DN = 'uid=test entry,dc=example,dc=com'
+USER_PW = 'password123'
+
+
[email protected]
+def init_user(topo, request):
+ """Initialize a user - Delete and re-add test user
+ """
+ try:
+ topo.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topo.standalone.delete_s(USER_DN)
+ except ldap.NO_SUCH_OBJECT:
+ pass
+ except ldap.LDAPError as e:
+ log.error("Failed to delete user, error: {}".format(e.message['desc']))
+ assert False
+
+ user_data = {'objectClass': 'top person inetOrgPerson'.split(),
+ 'uid': 'test entry',
+ 'cn': 'test entry',
+ 'sn': 'user',
+ 'userPassword': USER_PW}
+ try:
+ topo.standalone.add_s(Entry((USER_DN, user_data)))
+ except ldap.LDAPError as e:
+ log.error("Failed to add user, error: {}".format(e.message['desc']))
+ assert False
+
+
+def change_passwd(topo):
+ """Reset users password as the user, then re-bind as Directory Manager
+ """
+ try:
+ topo.standalone.simple_bind_s(USER_DN, USER_PW)
+ topo.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE,
+ 'userpassword',
+ USER_PW)])
+ topo.standalone.simple_bind_s(DN_DM, PASSWORD)
+ except ldap.LDAPError as e:
+ log.error("Failed to change user's password, error: {}".format(e.message['desc']))
+ assert False
+
+
+def bind_and_get_control(topo, err=0):
+ """Bind as the user, and return any controls
+ """
+ res_type = res_data = res_msgid = res_ctrls = None
+ result_id = ''
+
+ try:
+ result_id = topo.standalone.simple_bind(USER_DN, USER_PW,
+ serverctrls=[PasswordPolicyControl()])
+ res_type, res_data, res_msgid, res_ctrls = topo.standalone.result3(result_id)
+ if err:
+ log.fatal('Expected an error, but bind succeeded')
+ assert False
+ except ldap.LDAPError as e:
+ if err:
+ log.debug('Got expected error: {}'.format(e.message['desc']))
+ pass
+ else:
+ log.fatal('Did not expect an error: {}'.format(e.message['desc']))
+ assert False
+
+ if DEBUGGING and res_ctrls and len(res_ctrls) > 0:
+ for ctl in res_ctrls:
+ if ctl.timeBeforeExpiration:
+ log.debug('control time before expiration: {}'.format(ctl.timeBeforeExpiration))
+ if ctl.graceAuthNsRemaining:
+ log.debug('control grace login remaining: {}'.format(ctl.graceAuthNsRemaining))
+ if ctl.error is not None and ctl.error >= 0:
+ log.debug('control error: {}'.format(ctl.error))
+
+ topo.standalone.simple_bind_s(DN_DM, PASSWORD)
+ return res_ctrls
+
+
+def test_pwd_must_change(topo, init_user):
+ """Test for expiration control when password must be changed because an
+ admin reset the password
+
+ :id: a3d99be5-0b69-410d-b72f-04eda8821a56
+ :setup: Standalone instance, a user for testing
+ :steps:
+ 1. Configure password policy and reset password as admin
+ 2. Bind, and check for expired control withthe proper error code "2"
+ :expectedresults:
+ 1. Config update succeeds, adn the password is reset
+ 2. The EXPIRED control is returned, and we the expected error code "2"
+ """
+
+ log.info('Configure password policy with paswordMustChange set to "on"')
+ try:
+ topo.standalone.modify_s(DN_CONFIG, [
+ (ldap.MOD_REPLACE, 'passwordExp', 'on'),
+ (ldap.MOD_REPLACE, 'passwordMaxAge', '200'),
+ (ldap.MOD_REPLACE, 'passwordGraceLimit', '0'),
+ (ldap.MOD_REPLACE, 'passwordWarning', '199'),
+ (ldap.MOD_REPLACE, 'passwordMustChange', 'on')])
+ except ldap.LDAPError as e:
+ log.error("Failed to set password policy, error: {}".format(e.message['desc']))
+ assert False
+
+ log.info('Reset userpassword as Directory Manager')
+ try:
+ topo.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE,
+ 'userpassword',
+ USER_PW)])
+ except ldap.LDAPError as e:
+ log.error("Failed to change user's password, error: {}".format(e.message['desc']))
+ assert False
+
+ log.info('Bind should return ctrl with error code 2 (changeAfterReset)')
+ time.sleep(2)
+ ctrls = bind_and_get_control(topo)
+ if ctrls and len(ctrls) > 0:
+ if ctrls[0].error is None:
+ log.fatal("Response ctrl error code not set")
+ assert False
+ elif ctrls[0].error != 2:
+ log.fatal("Got unexpected error code: {}".format(ctrls[0].error))
+ assert False
+ else:
+ log.fatal("We did not get a response ctrl")
+ assert False
+
+
+def test_pwd_expired_grace_limit(topo, init_user):
+ """Test for expiration control when password is expired, but there are
+ remaining grace logins
+
+ :id: a3d99be5-0b69-410d-b72f-04eda8821a51
+ :setup: Standalone instance, a user for testing
+ :steps:
+ 1. Configure password policy and reset password,adn allow it to expire
+ 2. Bind, and check for expired control, and grace limit
+ 3. Bind again, consuming the last grace login, control should be returned
+ 4. Bind again, it should fail, and no control returned
+ :expectedresults:
+ 1. Config update and password reset are successful
+ 2. The EXPIRED control is returned, and we get the expected number
+ of grace logins in the control
+ 3. The response control has the expected value for grace logins
+ 4. The bind fails with error 49, and no contorl is returned
+ """
+
+ log.info('Configure password policy with grace limit set tot 2')
+ try:
+ topo.standalone.modify_s(DN_CONFIG, [
+ (ldap.MOD_REPLACE, 'passwordExp', 'on'),
+ (ldap.MOD_REPLACE, 'passwordMaxAge', '5'),
+ (ldap.MOD_REPLACE, 'passwordGraceLimit', '2')])
+ except ldap.LDAPError as e:
+ log.error("Failed to set password policy, error: {}".format(e.message['desc']))
+ assert False
+
+ log.info('Change password and wait for it to expire')
+ change_passwd(topo)
+ time.sleep(6)
+
+ log.info('Bind and use up one grace login (only one left)')
+ ctrls = bind_and_get_control(topo)
+ if ctrls is None or len(ctrls) == 0:
+ log.fatal('Did not get EXPIRED control in resposne')
+ assert False
+ else:
+ if int(ctrls[0].graceAuthNsRemaining) != 1:
+ log.fatal('Got unexpected value for grace logins: {}'.format(ctrls[0].graceAuthNsRemaining))
+ assert False
+
+ log.info('Use up last grace login, should get control')
+ ctrls = bind_and_get_control(topo)
+ if ctrls is None or len(ctrls) == 0:
+ log.fatal('Did not get control in response')
+ assert False
+
+ log.info('No grace login available, bind should fail, and no control should be returned')
+ ctrls = bind_and_get_control(topo, err=49)
+ if ctrls and len(ctrls) > 0:
+ log.fatal('Incorrectly got control in response')
+ assert False
+
+
+def test_pwd_expiring_with_warning(topo, init_user):
+ """Test expiring control response before and after warning is sent
+
+ :id: a3d99be5-0b69-410d-b72f-04eda8821a54
+ :setup: Standalone instance, a user for testing
+ :steps:
+ 1. Configure password policy, and reset password
+ 2. Check for EXPIRING control, and the "time to expire"
+ 3. Bind again, as a warning has now been sent, and check the "time to expire"
+ :expectedresults:
+ 1. Configuration update and password reset are successful
+ 2. Get the EXPIRING control, and the expected "time to expire" values
+ 3. Get the EXPIRING control, and the expected "time to expire" values
+ """
+
+ log.info('Configure password policy')
+ try:
+ topo.standalone.modify_s(DN_CONFIG, [
+ (ldap.MOD_REPLACE, 'passwordExp', 'on'),
+ (ldap.MOD_REPLACE, 'passwordMaxAge', '50'),
+ (ldap.MOD_REPLACE, 'passwordWarning', '50')])
+ except ldap.LDAPError as e:
+ log.error("Failed to set password policy, error: {}".format(e.message['desc']))
+ assert False
+
+ log.info('Change password and get controls')
+ change_passwd(topo)
+ ctrls = bind_and_get_control(topo)
+ if ctrls is None or len(ctrls) == 0:
+ log.fatal('Did not get EXPIRING control in response')
+ assert False
+
+ if int(ctrls[0].timeBeforeExpiration) < 50:
+ log.fatal('Got unexpected value for timeBeforeExpiration: {}'.format(ctrls[0].timeBeforeExpiration))
+ assert False
+
+ log.info('Warning has been sent, try the bind again, and recheck the expiring time')
+ time.sleep(5)
+ ctrls = bind_and_get_control(topo)
+ if ctrls is None or len(ctrls) == 0:
+ log.fatal('Did not get EXPIRING control in resposne')
+ assert False
+
+ if int(ctrls[0].timeBeforeExpiration) > 50:
+ log.fatal('Got unexpected value for timeBeforeExpiration: {}'.format(ctrls[0].timeBeforeExpiration))
+ assert False
+
+
+def test_pwd_expiring_with_no_warning(topo, init_user):
+ """Test expiring control response when no warning is sent
+
+ :id: a3d99be5-0b69-410d-b72f-04eda8821a54
+ :setup: Standalone instance, a user for testing
+ :steps:
+ 1. Configure password policy, and reset password
+ 2. Bind, and check that no controls are returned
+ 3. Set passwordSendExpiringTime to "on", bind, and check that the
+ EXPIRING control is returned
+ :expectedresults:
+ 1. Configuration update and passwordreset are successful
+ 2. No control is returned from bind
+ 3. A control is returned after setting "passwordSendExpiringTime"
+ """
+
+ log.info('Configure password policy')
+ try:
+ topo.standalone.modify_s(DN_CONFIG, [
+ (ldap.MOD_REPLACE, 'passwordExp', 'on'),
+ (ldap.MOD_REPLACE, 'passwordMaxAge', '50'),
+ (ldap.MOD_REPLACE, 'passwordWarning', '5')])
+ except ldap.LDAPError as e:
+ log.error("Failed to set password policy, error: {}".format(e.message['desc']))
+ assert False
+
+ log.info('When the warning is less than the max age, we never send expiring control response')
+ change_passwd(topo)
+ ctrls = bind_and_get_control(topo)
+ if len(ctrls) > 0:
+ log.fatal('Incorrectly got a response control: {}'.format(ctrls))
+ assert False
+
+ log.info('Turn on sending expiring control regardless of warning')
+ try:
+ topo.standalone.modify_s(DN_CONFIG, [
+ (ldap.MOD_REPLACE, 'passwordSendExpiringTime', 'on')])
+ except ldap.LDAPError as e:
+ log.error("Failed to set passwordSendExpiringTime, error: {}".format(e.message['desc']))
+ assert False
+
+ ctrls = bind_and_get_control(topo)
+ if ctrls is None or len(ctrls) == 0:
+ log.fatal('Did not get EXPIRED control in response')
+ assert False
+
+ if int(ctrls[0].timeBeforeExpiration) < 49:
+ log.fatal('Got unexpected value for time before expiration: {}'.format(ctrls[0].timeBeforeExpiration))
+ assert False
+
+ log.info('Check expiring time again')
+ time.sleep(6)
+ ctrls = bind_and_get_control(topo)
+ if ctrls is None or len(ctrls) == 0:
+ log.fatal('Did not get EXPIRED control in resposne')
+ assert False
+
+ if int(ctrls[0].timeBeforeExpiration) > 51:
+ log.fatal('Got unexpected value for time before expiration: {}'.format(ctrls[0].timeBeforeExpiration))
+ assert False
+
+ log.info('Turn off sending expiring control (restore the default setting)')
+ try:
+ topo.standalone.modify_s(DN_CONFIG, [
+ (ldap.MOD_REPLACE, 'passwordSendExpiringTime', 'off')])
+ except ldap.LDAPError as e:
+ log.error("Failed to set passwordSendExpiringTime, error: {}".format(e.message['desc']))
+ assert False
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
+
| 0 |
ac58ddf3e4c3a4f0388c56b262da8f7eeb11e230
|
389ds/389-ds-base
|
Issue 51100 - Correct numSubordinates value for cn=monitor
Bug Description: numSubordinates for cn=monitor shows 4
while there are 3 child entries are present.
Fix Description: Ignore easter egg entry while increasing
numSubordinates count.
https://pagure.io/389-ds-base/issue/51100
Reviewed by: mreynolds (Thanks!)
|
commit ac58ddf3e4c3a4f0388c56b262da8f7eeb11e230
Author: Simon Pichugin <[email protected]>
Date: Tue Jun 9 16:13:43 2020 +0200
Issue 51100 - Correct numSubordinates value for cn=monitor
Bug Description: numSubordinates for cn=monitor shows 4
while there are 3 child entries are present.
Fix Description: Ignore easter egg entry while increasing
numSubordinates count.
https://pagure.io/389-ds-base/issue/51100
Reviewed by: mreynolds (Thanks!)
diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c
index 0e22d3cec..b62c6d379 100644
--- a/ldap/servers/slapd/dse.c
+++ b/ldap/servers/slapd/dse.c
@@ -1109,8 +1109,11 @@ dse_add_entry_pb(struct dse *pdse, Slapi_Entry *e, Slapi_PBlock *pb)
if (-1 != rc) {
/* update num sub of parent with no lock; we already hold the write lock */
if (0 == rc) { /* entry was added, not merged; update numsub */
- dse_updateNumSubOfParent(pdse, slapi_entry_get_sdn_const(e),
- SLAPI_OPERATION_ADD);
+ /* easter egg entry - don't update num sub */
+ if (strcmp(slapi_entry_get_ndn(e), "ou=red hat directory server team,cn=monitor") != 0) {
+ dse_updateNumSubOfParent(pdse, slapi_entry_get_sdn_const(e),
+ SLAPI_OPERATION_ADD);
+ }
} else { /* entry was merged, free temp unused data */
dse_node_delete(&n);
}
| 0 |
33c815889ec3bc8eacc7df68d57370ce8cee32e0
|
389ds/389-ds-base
|
Issue 4736 - CLI - Errors from certutil are not propagated
Description: Errors from certutil are not returned to the client, and
only a generic failure code is returned. The actual error text should be
returned to the client since it has meaning. Just catch all the
exception and return the output as a ValueError.
relates: https://github.com/389ds/389-ds-base/issues/4736
Reviewed by: firstyear (Thanks!)
|
commit 33c815889ec3bc8eacc7df68d57370ce8cee32e0
Author: Mark Reynolds <[email protected]>
Date: Mon Aug 2 17:04:38 2021 -0400
Issue 4736 - CLI - Errors from certutil are not propagated
Description: Errors from certutil are not returned to the client, and
only a generic failure code is returned. The actual error text should be
returned to the client since it has meaning. Just catch all the
exception and return the output as a ValueError.
relates: https://github.com/389ds/389-ds-base/issues/4736
Reviewed by: firstyear (Thanks!)
diff --git a/dirsrvtests/tests/suites/clu/dsctl_tls_test.py b/dirsrvtests/tests/suites/clu/dsctl_tls_test.py
new file mode 100644
index 000000000..d5ceca6ef
--- /dev/null
+++ b/dirsrvtests/tests/suites/clu/dsctl_tls_test.py
@@ -0,0 +1,80 @@
+import logging
+import pytest
+import os
+from lib389.topologies import topology_st as topo
+from lib389.nss_ssl import NssSsl
+
+log = logging.getLogger(__name__)
+
+
+def test_tls_command_returns_error_text(topo):
+ """CLI commands that called certutil should return the error text from
+ certutil when something goes wrong, and not the system error code number.
+
+ :id: 7f0c28d0-6e13-4ca4-bec2-4586d56b73f6
+ :setup: Standalone Instance
+ :steps:
+ 1. Issue invalid "generate key and cert" command, and error text is returned
+ 2. Issue invalid "delete cert" command, and error text is returned
+ 3. Issue invalid "import ca cert" command, and error text is returned
+ 4. Issue invalid "import server cert" command, and error text is returned
+ 5. Issue invalid "import key and server cert" command, and error text is returned
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ """
+
+ # dsctl localhost tls generate-server-cert-csr -s "bad"
+ tls = NssSsl(dirsrv=topo.standalone)
+ try:
+ tls.create_rsa_key_and_csr([], "bad")
+ assert False
+ except ValueError as e:
+ assert '255' not in str(e)
+ assert 'improperly formatted name' in str(e)
+
+ # dsctl localhost tls remove-cert
+ try:
+ tls.del_cert("bad")
+ assert False
+ except ValueError as e:
+ assert '255' not in str(e)
+ assert 'could not find certificate named' in str(e)
+
+ # dsctl localhost tls import-ca
+ try:
+ invalid_file = topo.standalone.confdir + '/dse.ldif'
+ tls.add_cert(nickname="bad", input_file=invalid_file)
+ assert False
+ except ValueError as e:
+ assert '255' not in str(e)
+ assert 'error converting ascii to binary' in str(e)
+
+ # dsctl localhost tls import-server-cert
+ try:
+ invalid_file = topo.standalone.confdir + '/dse.ldif'
+ tls.import_rsa_crt(crt=invalid_file)
+ assert False
+ except ValueError as e:
+ assert '255' not in str(e)
+ assert 'error converting ascii to binary' in str(e)
+
+ # dsctl localhost tls import-server-key-cert
+ try:
+ invalid_file = topo.standalone.confdir + '/dse.ldif'
+ tls.add_server_key_and_cert(invalid_file, invalid_file)
+ assert False
+ except ValueError as e:
+ assert '255' not in str(e)
+ assert 'unable to load private key' in str(e)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main(["-s", CURRENT_FILE])
+
diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py
index b22fd728f..cf5069eb9 100644
--- a/src/lib389/lib389/nss_ssl.py
+++ b/src/lib389/lib389/nss_ssl.py
@@ -196,6 +196,10 @@ only.
self._generate_noise('%s/noise.txt' % self._certdb)
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ try:
+ result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
self.log.debug("nss output: %s", result)
return True
@@ -232,7 +236,10 @@ only.
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()
+ try:
+ openssl_version = check_output(['/usr/bin/openssl', 'version']).decode('utf-8').strip()
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
rehash_available = LegacyVersion(openssl_version.split(' ')[1]) >= LegacyVersion('1.1.0')
if rehash_available:
@@ -240,7 +247,10 @@ only.
else:
cmd = ['/usr/bin/c_rehash', certdir]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
def create_rsa_ca(self, months=VALID):
"""
@@ -292,7 +302,10 @@ only.
'-a',
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- certdetails = check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ certdetails = check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
with open('%s/ca.crt' % self._certdb, 'w') as f:
f.write(ensure_str(certdetails))
self.openssl_rehash(self._certdb)
@@ -312,7 +325,10 @@ only.
self._certdb,
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- certdetails = check_output(cmd, stderr=subprocess.STDOUT, encoding='utf-8')
+ try:
+ certdetails = check_output(cmd, stderr=subprocess.STDOUT, encoding='utf-8')
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
end_date_str = certdetails.split("Not After : ")[1].split("\n")[0]
date_format = '%a %b %d %H:%M:%S %Y'
end_date = datetime.strptime(end_date_str, date_format)
@@ -351,7 +367,10 @@ only.
'-o', csr_path,
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
# Sign the CSR with our old CA
cmd = [
@@ -373,7 +392,10 @@ only.
'%s' % months,
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
self.openssl_rehash(self._certdb)
@@ -389,7 +411,10 @@ only.
'-f', '%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
return crt_path
@@ -402,7 +427,10 @@ only.
'-f',
'%s/%s' % (self._certdb, PWD_TXT),
]
- result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ try:
+ result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
# We can skip the first few lines. They are junk
# IE ['',
@@ -434,8 +462,10 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
-
+ try:
+ result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
lines = result.split('\n')[1:-1]
for line in lines:
m = re.match('\<(?P<id>.*)\> (?P<type>\w+)\s+(?P<hash>\w+).*:(?P<name>.+)', line)
@@ -540,13 +570,16 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ try:
+ result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
self.log.debug("nss output: %s", result)
return True
def create_rsa_key_and_csr(self, alt_names=[], subject=None):
"""Create a new RSA key and the certificate signing request. This
- request can be submitted to a CA for signing. The returned certifcate
+ request can be submitted to a CA for signing. The returned certificate
can be added with import_rsa_crt.
"""
csr_path = os.path.join(self._certdb, '%s.csr' % CERT_NAME)
@@ -590,7 +623,10 @@ only.
'-o', csr_path,
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
return csr_path
@@ -616,7 +652,10 @@ only.
'-c', CA_NAME,
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
return (ca_path, crt_path)
@@ -644,7 +683,10 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
if crt is not None:
cmd = [
@@ -659,7 +701,10 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
cmd = [
'/usr/bin/certutil',
'-V',
@@ -668,7 +713,10 @@ only.
'-u', 'YCV'
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
def create_rsa_user(self, name, months=VALID):
"""
@@ -711,8 +759,11 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
+ try:
+ result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
- result = ensure_str(check_output(cmd, stderr=subprocess.STDOUT))
self.log.debug("nss output: %s", result)
# Now extract this into PEM files that we can use.
# pk12util -o user-william.p12 -d . -k pwdfile.txt -n user-william -W ''
@@ -725,7 +776,10 @@ only.
'-W', '""'
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
# openssl pkcs12 -in user-william.p12 -passin pass:'' -out file.pem -nocerts -nodes
# Extract the key
cmd = [
@@ -738,7 +792,10 @@ only.
'-nodes'
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
# Extract the cert
cmd = [
'openssl',
@@ -751,7 +808,10 @@ only.
'-nodes'
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
# Convert the cert for userCertificate attr
cmd = [
'openssl',
@@ -762,7 +822,10 @@ only.
'-out', '%s/%s%s.der' % (self._certdb, USER_PREFIX, name),
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
return subject
@@ -789,7 +852,10 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("del_cert cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
def edit_cert_trust(self, nickname, trust_flags):
"""Edit trust flags
@@ -819,7 +885,10 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("edit_cert_trust cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
def display_cert_details(self, nickname):
@@ -832,7 +901,12 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("display_cert_details cmd: %s", format_cmd_list(cmd))
- return check_output(cmd, stderr=subprocess.STDOUT, encoding='utf-8')
+ try:
+ result = check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
+
+ return result
def get_cert_details(self, nickname):
@@ -935,7 +1009,10 @@ only.
'%s/%s' % (self._certdb, PWD_TXT),
]
self.log.debug("add_cert cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
def add_server_key_and_cert(self, input_key, input_cert):
if not os.path.exists(input_key):
@@ -964,7 +1041,10 @@ only.
'-aes128'
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
# Remove the server-cert if it exists, because else the import name fails.
try:
self.del_cert(CERT_NAME)
@@ -981,7 +1061,10 @@ only.
'-W', "",
]
self.log.debug("nss cmd: %s", format_cmd_list(cmd))
- check_output(cmd, stderr=subprocess.STDOUT)
+ try:
+ check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.output.decode('utf-8').rstrip())
finally:
# Remove the p12
if os.path.exists(p12_bundle):
| 0 |
4dfc4be488232d5564f317ae46aecbccc65dc1c4
|
389ds/389-ds-base
|
Fix search scope for AD password sync - 159037
|
commit 4dfc4be488232d5564f317ae46aecbccc65dc1c4
Author: Nathan Kinder <[email protected]>
Date: Wed Jun 1 18:10:42 2005 +0000
Fix search scope for AD password sync - 159037
diff --git a/ldap/synctools/passwordsync/passsync/syncserv.cpp b/ldap/synctools/passwordsync/passsync/syncserv.cpp
index 5fd1ff4fd..800ea1576 100644
--- a/ldap/synctools/passwordsync/passsync/syncserv.cpp
+++ b/ldap/synctools/passwordsync/passsync/syncserv.cpp
@@ -411,7 +411,7 @@ int PassSyncService::QueryUsername(char* username)
_snprintf(searchFilter, SYNCSERV_BUF_SIZE, "(%s=%s)", ldapUsernameField, username);
- lastLdapError = ldap_search_ext_s(mainLdapConnection, ldapSearchBase, LDAP_SCOPE_ONELEVEL, searchFilter, NULL, 0, NULL, NULL, NULL, -1, &results);
+ lastLdapError = ldap_search_ext_s(mainLdapConnection, ldapSearchBase, LDAP_SCOPE_SUBTREE, searchFilter, NULL, 0, NULL, NULL, NULL, -1, &results);
if(lastLdapError != LDAP_SUCCESS)
{
| 0 |
8f64d38615fd6a2232a48b95863fda0daa80014e
|
389ds/389-ds-base
|
Resolves: #436837 (comment #9)
Summary: Dynamically reload schema via task interface
|
commit 8f64d38615fd6a2232a48b95863fda0daa80014e
Author: Noriko Hosoi <[email protected]>
Date: Fri Jun 6 17:53:35 2008 +0000
Resolves: #436837 (comment #9)
Summary: Dynamically reload schema via task interface
diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c
index 42cb2cf27..e6083a66b 100644
--- a/ldap/servers/slapd/backend.c
+++ b/ldap/servers/slapd/backend.c
@@ -169,7 +169,7 @@ slapi_be_issuffix( const Slapi_Backend *be, const Slapi_DN *suffix )
int
be_isdeleted( const Slapi_Backend *be )
{
- return BE_STATE_DELETED == be->be_state;
+ return ((be == NULL) || (BE_STATE_DELETED == be->be_state));
}
void
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 5d8de75b8..3241af712 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -776,8 +776,8 @@ struct slapdplugin {
IFP plg_un_db_register_oc_callback; /* Register a function to call when a operation is applied to a given ObjectClass */
IFP plg_un_db_init_instance; /* initializes new db instance */
IFP plg_un_db_wire_import; /* fast replica update */
- IFP plg_un_db_add_schema; /* add schema */
IFP plg_un_db_verify; /* verify db files */
+ IFP plg_un_db_add_schema; /* add schema */
} plg_un_db;
#define plg_bind plg_un.plg_un_db.plg_un_db_bind
#define plg_unbind plg_un.plg_un_db.plg_un_db_unbind
| 0 |
9a83b3a9b9f6c0b76ee447488f0439c65e01f1d7
|
389ds/389-ds-base
|
Ticket 49012 - Removed un-used counters
Bug Description: Remove unused counts from the ch_malloc code.
Fix Description: By removing these we make the code simpler, and we net a
performance improvement when DEBUG is set, and also when DEBUG is NOT set.
https://fedorahosted.org/389/ticket/49012
Author: wibrown
Review by: mreynolds (Thanks!)
|
commit 9a83b3a9b9f6c0b76ee447488f0439c65e01f1d7
Author: William Brown <[email protected]>
Date: Wed Oct 19 15:41:09 2016 +1000
Ticket 49012 - Removed un-used counters
Bug Description: Remove unused counts from the ch_malloc code.
Fix Description: By removing these we make the code simpler, and we net a
performance improvement when DEBUG is set, and also when DEBUG is NOT set.
https://fedorahosted.org/389/ticket/49012
Author: wibrown
Review by: mreynolds (Thanks!)
diff --git a/ldap/servers/slapd/ch_malloc.c b/ldap/servers/slapd/ch_malloc.c
index 443a785c8..8278de4e1 100644
--- a/ldap/servers/slapd/ch_malloc.c
+++ b/ldap/servers/slapd/ch_malloc.c
@@ -19,20 +19,8 @@
#include <string.h> /* strdup */
#include <sys/types.h>
#include <sys/socket.h>
-#undef DEBUG /* disable counters */
-#include <prcountr.h>
#include "slap.h"
-static int counters_created= 0;
-PR_DEFINE_COUNTER(slapi_ch_counter_malloc);
-PR_DEFINE_COUNTER(slapi_ch_counter_memalign);
-PR_DEFINE_COUNTER(slapi_ch_counter_calloc);
-PR_DEFINE_COUNTER(slapi_ch_counter_realloc);
-PR_DEFINE_COUNTER(slapi_ch_counter_strdup);
-PR_DEFINE_COUNTER(slapi_ch_counter_free);
-PR_DEFINE_COUNTER(slapi_ch_counter_created);
-PR_DEFINE_COUNTER(slapi_ch_counter_exist);
-
#define OOM_PREALLOC_SIZE 65536
static void *oom_emergency_area = NULL;
static PRLock *oom_emergency_lock = NULL;
@@ -50,24 +38,15 @@ static const char* const oom_advice =
"Can't recover; calling exit(1).\n";
static void
-create_counters(void)
+create_oom_buffer(void)
{
- PR_CREATE_COUNTER(slapi_ch_counter_malloc,"slapi_ch","malloc","");
- PR_CREATE_COUNTER(slapi_ch_counter_memalign,"slapi_ch","memalign","");
- PR_CREATE_COUNTER(slapi_ch_counter_calloc,"slapi_ch","calloc","");
- PR_CREATE_COUNTER(slapi_ch_counter_realloc,"slapi_ch","realloc","");
- PR_CREATE_COUNTER(slapi_ch_counter_strdup,"slapi_ch","strdup","");
- PR_CREATE_COUNTER(slapi_ch_counter_free,"slapi_ch","free","");
- PR_CREATE_COUNTER(slapi_ch_counter_created,"slapi_ch","created","");
- PR_CREATE_COUNTER(slapi_ch_counter_exist,"slapi_ch","exist","");
-
/* ensure that we have space to allow for shutdown calls to malloc()
* from should we run out of memory.
*/
if (oom_emergency_area == NULL) {
- oom_emergency_area = malloc(OOM_PREALLOC_SIZE);
+ oom_emergency_area = malloc(OOM_PREALLOC_SIZE);
+ oom_emergency_lock = PR_NewLock();
}
- oom_emergency_lock = PR_NewLock();
}
/* called when we have just detected an out of memory condition, before
@@ -123,14 +102,8 @@ slapi_ch_malloc(
size, oserr, slapd_system_strerror( oserr ), oom_advice );
exit( 1 );
}
- if(!counters_created)
- {
- create_counters();
- counters_created= 1;
- }
- PR_INCREMENT_COUNTER(slapi_ch_counter_malloc);
- PR_INCREMENT_COUNTER(slapi_ch_counter_created);
- PR_INCREMENT_COUNTER(slapi_ch_counter_exist);
+ /* So long as this happens once, we are happy, put it in ch_malloc. */
+ create_oom_buffer();
return( newmem );
}
@@ -155,14 +128,6 @@ slapi_ch_memalign(size_t size, size_t alignment)
size, oserr, slapd_system_strerror( oserr ), oom_advice );
exit( 1 );
}
- if(!counters_created)
- {
- create_counters();
- counters_created= 1;
- }
- PR_INCREMENT_COUNTER(slapi_ch_counter_memalign);
- PR_INCREMENT_COUNTER(slapi_ch_counter_created);
- PR_INCREMENT_COUNTER(slapi_ch_counter_exist);
return( newmem );
}
@@ -193,12 +158,6 @@ slapi_ch_realloc(
size, oserr, slapd_system_strerror( oserr ), oom_advice );
exit( 1 );
}
- if(!counters_created)
- {
- create_counters();
- counters_created= 1;
- }
- PR_INCREMENT_COUNTER(slapi_ch_counter_realloc);
return( newmem );
}
@@ -230,14 +189,6 @@ slapi_ch_calloc(
nelem, size, oserr, slapd_system_strerror( oserr ), oom_advice );
exit( 1 );
}
- if(!counters_created)
- {
- create_counters();
- counters_created= 1;
- }
- PR_INCREMENT_COUNTER(slapi_ch_counter_calloc);
- PR_INCREMENT_COUNTER(slapi_ch_counter_created);
- PR_INCREMENT_COUNTER(slapi_ch_counter_exist);
return( newmem );
}
@@ -260,9 +211,6 @@ slapi_ch_strdup ( const char* s1)
oom_advice );
exit (1);
}
- PR_INCREMENT_COUNTER(slapi_ch_counter_strdup);
- PR_INCREMENT_COUNTER(slapi_ch_counter_created);
- PR_INCREMENT_COUNTER(slapi_ch_counter_exist);
return newmem;
}
@@ -312,22 +260,19 @@ slapi_ch_bvecdup (struct berval** v)
* Note: pass in the address of the pointer you want to free.
* Note: you can pass in null pointers, it's cool.
*/
-void
+void
slapi_ch_free(void **ptr)
{
- if (ptr==NULL || *ptr == NULL){
+ /* Man 3 free
+ * If ptr is NULL, no operation is performed. We only need to check ptr
+ * has a value so that *ptr won't SIGSEGV
+ */
+ if ( ptr==NULL ){
return;
}
free (*ptr);
*ptr = NULL;
- if(!counters_created)
- {
- create_counters();
- counters_created= 1;
- }
- PR_INCREMENT_COUNTER(slapi_ch_counter_free);
- PR_DECREMENT_COUNTER(slapi_ch_counter_exist);
return;
}
#endif /* !MEMPOOL_EXPERIMENTAL */
| 0 |
2ddfb06ff73c9f22ddb3d0346602ffa4b2f6883a
|
389ds/389-ds-base
|
Merge #49457 `Fix spal_meminfo_get function prototype`
|
commit 2ddfb06ff73c9f22ddb3d0346602ffa4b2f6883a (from 691b14442dbe7b05daf00babefea9bac346a807f)
Merge: 691b14442 5c6241980
Author: Mark Reynolds <[email protected]>
Date: Mon Nov 20 15:40:08 2017 +0000
Merge #49457 `Fix spal_meminfo_get function prototype`
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
commit 2ddfb06ff73c9f22ddb3d0346602ffa4b2f6883a (from 5c62419806c7b9c836153358079898216f6f13da)
Merge: 691b14442 5c6241980
Author: Mark Reynolds <[email protected]>
Date: Mon Nov 20 15:40:08 2017 +0000
Merge #49457 `Fix spal_meminfo_get function prototype`
diff --git a/dirsrvtests/tests/suites/monitor/monitor_test.py b/dirsrvtests/tests/suites/monitor/monitor_test.py
new file mode 100644
index 000000000..5c5302198
--- /dev/null
+++ b/dirsrvtests/tests/suites/monitor/monitor_test.py
@@ -0,0 +1,69 @@
+import logging
+import pytest
+import os
+from lib389.monitor import *
+from lib389._constants import *
+from lib389.topologies import topology_st as topo
+
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+def test_monitor(topo):
+ """This test is to display monitor attributes to check the performace
+
+ :id: f7c8a815-07cf-4e67-9574-d26a0937d3db
+ :setup: Single instance
+ :steps:
+ 1. Get the cn=monitor connections attributes
+ 2. Print connections attributes
+ 3. Get the cn=monitor version
+ 4. Print cn=monitor version
+ 5. Get the cn=monitor threads attributes
+ 6. Print cn=monitor threads attributes
+ 7. Get cn=monitor backends attributes
+ 8. Print cn=monitor backends attributes
+ 9. Get cn=monitor operations attributes
+ 10. Print cn=monitor operations attributes
+ 11. Get cn=monitor statistics attributes
+ 12. Print cn=monitor statistics attributes
+ :expectedresults:
+ 1. cn=monitor attributes should be fetched and printed successfully.
+ """
+
+ #define the monitor object from Monitor class in lib389
+ monitor = Monitor(topo.standalone)
+
+ #get monitor connections
+ connections = monitor.get_connections()
+ log.info('connection: {0[0]}, currentconnections: {0[1]}, totalconnections: {0[2]}'.format(connections))
+
+ #get monitor version
+ version = monitor.get_version()
+ log.info('version :: %s' %version)
+
+ #get monitor threads
+ threads = monitor.get_threads()
+ log.info('threads: {0[0]},currentconnectionsatmaxthreads: {0[1]},maxthreadsperconnhits: {0[2]}'.format(threads))
+
+ #get monitor backends
+ backend = monitor.get_backends()
+ log.info('nbackends: {0[0]}, backendmonitordn: {0[1]}'.format(backend))
+
+ #get monitor operations
+ operations = monitor.get_operations()
+ log.info('opsinitiated: {0[0]}, opscompleted: {0[1]}'.format(operations))
+
+ #get monitor stats
+ stats = monitor.get_statistics()
+ log.info('dtablesize: {0[0]},readwaiters: {0[1]},entriessent: {0[2]},bytessent: {0[3]},currenttime: {0[4]},starttime: {0[5]}'.format(stats))
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/src/lib389/lib389/monitor.py b/src/lib389/lib389/monitor.py
index 5226a67ef..557e04be8 100644
--- a/src/lib389/lib389/monitor.py
+++ b/src/lib389/lib389/monitor.py
@@ -6,39 +6,83 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
-"""
-Monitor class to display current server performance details
-"""
-
import ldap
from ldap import filter as ldap_filter
from lib389._constants import *
-from lib389._mapped_object import DSLdapObject
-
+from lib389._mapped_object import DSLdapObjects, DSLdapObject
class Monitor(DSLdapObject):
+ """An object that helps reading of cn=monitor for server statistics.
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: not used
+ :param batch: not used
"""
- Allows reading of cn=monitor for server statistics.
- """
-
def __init__(self, instance, dn=None, batch=False):
super(Monitor, self).__init__(instance=instance, batch=batch)
self._dn = DN_MONITOR
- self._monitor_keys = [
- 'instanceection',
- 'currentinstanceections',
- 'currentconnections',
- 'opscompleted',
- 'opsinitiated',
- 'threads',
- 'totalinstanceections',
- 'version',
- 'currenttime',
- 'connection',
- ]
- def status(self):
- return self.get_attrs_vals(self._monitor_keys)
+ def get_connections(self):
+ """Get connection related attribute values for cn=monitor
+
+ :returns: Values of connection, currentconnections,
+ totalconnections attributes of cn=monitor
+ """
+ connection = self.get_attr_vals_utf8('connection')
+ currentconnections = self.get_attr_vals_utf8('currentconnections')
+ totalconnections = self.get_attr_vals_utf8('totalconnections')
+ return (connection, currentconnections, totalconnections)
+
+ def get_version(self):
+ """Get version attribute value for cn=monitor
+
+ :returns: Value of version attribute of cn=monitor
+ """
+ version = self.get_attr_vals_utf8('connection')
+ return version
+
+ def get_threads(self):
+ """Get thread related attributes value for cn=monitor
+
+ :returns: Values of threads, currentconnectionsatmaxthreads, and
+ maxthreadsperconnhits attributes of cn=monitor
+ """
+ threads = self.get_attr_vals_utf8('threads')
+ currentconnectionsatmaxthreads = self.get_attr_vals_utf8('currentconnectionsatmaxthreads')
+ maxthreadsperconnhits = self.get_attr_vals_utf8('maxthreadsperconnhits')
+ return (threads, currentconnectionsatmaxthreads, maxthreadsperconnhits)
+
+ def get_backends(self):
+ """Get backends related attributes value for cn=monitor
+
+ :returns: Values of nbackends and backendmonitordn attributes of cn=monitor
+ """
+ nbackends = self.get_attr_vals_utf8('nbackends')
+ backendmonitordn = self.get_attr_vals_utf8('backendmonitordn')
+ return (nbackends, backendmonitordn)
+
+ def get_operations(self):
+ """Get operations related attributes value for cn=monitor
+
+ :returns: Values of opsinitiated and opscompleted attributes of cn=monitor
+ """
+ opsinitiated = self.get_attr_vals_utf8('opsinitiated')
+ opscompleted = self.get_attr_vals_utf8('opsinitiated')
+ return (opsinitiated, opscompleted)
+
+ def get_statistics(self):
+ """Get statistics attributes value for cn=monitor
+
+ :returns: Values of dtablesize, readwaiters, entriessent,
+ bytessent, currenttime, starttime attributes of cn=monitor
+ """
+ dtablesize = self.get_attr_vals_utf8('dtablesize')
+ readwaiters = self.get_attr_vals_utf8('readwaiters')
+ entriessent = self.get_attr_vals_utf8('entriessent')
+ bytessent = self.get_attr_vals_utf8('bytessent')
+ currenttime = self.get_attr_vals_utf8('currenttime')
+ starttime = self.get_attr_vals_utf8('starttime')
+ return (dtablesize, readwaiters, entriessent, bytessent, currenttime, starttime)
class MonitorLDBM(DSLdapObject):
def __init__(self, instance, dn=None, batch=False):
@@ -53,7 +97,6 @@ class MonitorLDBM(DSLdapObject):
'dbcacheroevict',
'dbcacherwevict',
]
-
def status(self):
return self.get_attrs_vals(self._backend_keys)
| 0 |
0d276e07b9f806366b35f83a7ae4c22a5a53fe55
|
389ds/389-ds-base
|
Resolves: bug 442170
Bug Description: "DB_BUFFER_SMALL: User memory too small for return value" error when importing LDIF with replication active
Reviewed by: nkinder (Thanks!)
Fix Description: BDB 4.3 does not use ENOMEM if the given buffer is too small - it uses DB_BUFFER_SMALL. This fix allows us to use DB_BUFFER_SMALL in BDB 4.2 and earlier too. I also cleaned up some of the cl5 api return codes to return an appropriate error code to the higher levels rather than pass the ENOMEM up.
Platforms tested: RHEL5
Flag Day: no
Doc impact: no
|
commit 0d276e07b9f806366b35f83a7ae4c22a5a53fe55
Author: Rich Megginson <[email protected]>
Date: Mon Jun 23 18:32:11 2008 +0000
Resolves: bug 442170
Bug Description: "DB_BUFFER_SMALL: User memory too small for return value" error when importing LDIF with replication active
Reviewed by: nkinder (Thanks!)
Fix Description: BDB 4.3 does not use ENOMEM if the given buffer is too small - it uses DB_BUFFER_SMALL. This fix allows us to use DB_BUFFER_SMALL in BDB 4.2 and earlier too. I also cleaned up some of the cl5 api return codes to return an appropriate error code to the higher levels rather than pass the ENOMEM up.
Platforms tested: RHEL5
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 746dfd09b..4f3ec39e0 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -45,6 +45,15 @@
#include "cl5.h" /* changelog5Config */
#include "cl5_clcache.h"
+/* newer bdb uses DB_BUFFER_SMALL instead of ENOMEM as the
+ error return if the given buffer in which to load a
+ key or value is too small - if it is not defined, define
+ it here to ENOMEM
+*/
+#ifndef DB_BUFFER_SMALL
+#define DB_BUFFER_SMALL ENOMEM
+#endif
+
/*
* Constants for the buffer pool:
*
@@ -248,7 +257,7 @@ clcache_get_buffer ( CLC_Buffer **buf, DB *db, ReplicaId consumer_rid, const RUV
else {
slapi_log_error ( SLAPI_LOG_FATAL, get_thread_private_agmtname(),
"clcache_get_buffer: can't allocate new buffer\n" );
- rc = ENOMEM;
+ rc = CL5_MEMORY_ERROR;
}
return rc;
@@ -379,7 +388,7 @@ clcache_load_buffer_bulk ( CLC_Buffer *buf, int flag )
* Continue if the error is no-mem since we don't need to
* load in the key record anyway with DB_SET.
*/
- if ( 0 == rc || ENOMEM == rc )
+ if ( 0 == rc || DB_BUFFER_SMALL == rc )
rc = clcache_cursor_get ( cursor, buf, flag );
}
@@ -852,7 +861,7 @@ clcache_enqueue_busy_list ( DB *db, CLC_Buffer *buf )
if ( NULL == bl ) {
if ( NULL == ( bl = clcache_new_busy_list ()) ) {
- rc = ENOMEM;
+ rc = CL5_MEMORY_ERROR;
}
else {
PR_RWLock_Wlock ( _pool->pl_lock );
@@ -898,7 +907,7 @@ clcache_cursor_get ( DBC *cursor, CLC_Buffer *buf, int flag )
& buf->buf_key,
& buf->buf_data,
buf->buf_load_flag | flag );
- if ( ENOMEM == rc ) {
+ if ( DB_BUFFER_SMALL == rc ) {
/*
* The record takes more space than the current size of the
* buffer. Fortunately, buf->buf_data.size has been set by
@@ -923,7 +932,7 @@ clcache_cursor_get ( DBC *cursor, CLC_Buffer *buf, int flag )
"clcache_cursor_get: invalid parameter\n" );
break;
- case ENOMEM:
+ case DB_BUFFER_SMALL:
slapi_log_error ( SLAPI_LOG_FATAL, buf->buf_agmt_name,
"clcache_cursor_get: can't allocate %u bytes\n", buf->buf_data.ulen );
break;
| 0 |
65f473cb6d1299d88a0d2decf7d49eee3164702a
|
389ds/389-ds-base
|
Ticket #315 - ns-slapd exits/crashes if /var fills up
Bug Description: Once /var fills up the DS will crash.
Fix Description: Created a new feature to monitor the disk space used by DS.
Once the available disk space gets critical we shutdown
the process.
For complete details see "Disk_Monitoring" text file
https://fedorahosted.org/389/ticket/315
Reviewed by:
|
commit 65f473cb6d1299d88a0d2decf7d49eee3164702a
Author: Mark Reynolds <[email protected]>
Date: Wed Apr 4 17:50:16 2012 -0400
Ticket #315 - ns-slapd exits/crashes if /var fills up
Bug Description: Once /var fills up the DS will crash.
Fix Description: Created a new feature to monitor the disk space used by DS.
Once the available disk space gets critical we shutdown
the process.
For complete details see "Disk_Monitoring" text file
https://fedorahosted.org/389/ticket/315
Reviewed by:
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index c1a123c0f..132b2b901 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -6613,6 +6613,24 @@ ldbm_back_get_info(Slapi_Backend *be, int cmd, void **info)
}
break;
}
+ case BACK_INFO_DIRECTORY:
+ {
+ struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private;
+ if (li) {
+ *(char **)info = li->li_directory;
+ rc = 0;
+ }
+ break;
+ }
+ case BACK_INFO_LOG_DIRECTORY:
+ {
+ struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private;
+ if (li) {
+ *(char **)info = ldbm_config_db_logdirectory_get_ext((void *)li);
+ rc = 0;
+ }
+ break;
+ }
default:
break;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index b179591f4..d0664ebaa 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -469,7 +469,7 @@ static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int
return retval;
}
-static void *ldbm_config_db_logdirectory_get(void *arg)
+void *ldbm_config_db_logdirectory_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
@@ -483,7 +483,17 @@ static void *ldbm_config_db_logdirectory_get(void *arg)
return (void *) slapi_ch_strdup(li->li_dblayer_private->dblayer_log_directory);
else
return (void *) slapi_ch_strdup(li->li_new_directory);
+}
+
+/* Does not return a copy of the string - used by disk space monitoring feature */
+void *ldbm_config_db_logdirectory_get_ext(void *arg)
+{
+ struct ldbminfo *li = (struct ldbminfo *) arg;
+ if (strlen(li->li_dblayer_private->dblayer_log_directory) > 0)
+ return (void *)li->li_dblayer_private->dblayer_log_directory;
+ else
+ return (void *)li->li_new_directory;
}
static int ldbm_config_db_logdirectory_set(void *arg, void *value, char *errorbuf, int phase, int apply)
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 0734162dc..f93358b78 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -615,6 +615,7 @@ int dbversion_exists(struct ldbminfo *li, const char *directory);
int ldbm_config_load_dse_info(struct ldbminfo *li);
void ldbm_config_setup_default(struct ldbminfo *li);
void ldbm_config_internal_set(struct ldbminfo *li, char *attrname, char *value);
+void *ldbm_config_db_logdirectory_get_ext(void *arg);
void ldbm_instance_config_internal_set(ldbm_instance *inst, char *attrname, char *value);
void ldbm_instance_config_setup_default(ldbm_instance *inst);
int ldbm_instance_postadd_instance_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 85daa2825..01d307d41 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -59,6 +59,7 @@
#include <sys/time.h>
#include <sys/wait.h>
#include <pthread.h>
+#include <mntent.h>
#endif
#include <time.h>
#include <signal.h>
@@ -81,15 +82,17 @@
/* for some reason, linux tty stuff defines CTIME */
#ifdef LINUX
#undef CTIME
+#include <sys/statfs.h>
+#else
+#include <sys/statvfs.h>
+#include <sys/mnttab.h>
#endif
#include "slap.h"
#include "slapi-plugin.h"
-
#include "snmp_collator.h"
#include <private/pprio.h>
-
#include <ssl.h>
-
+#include <stdio.h>
#include "fe.h"
#if defined(ENABLE_LDAPI)
@@ -126,9 +129,12 @@ PRFileDesc* signalpipe[2];
static int writesignalpipe = SLAPD_INVALID_SOCKET;
static int readsignalpipe = SLAPD_INVALID_SOCKET;
-#define FDS_SIGNAL_PIPE 0
-
+static PRThread *disk_thread_p = NULL;
+static PRCondVar *diskmon_cvar = NULL;
+static PRLock *diskmon_mutex = NULL;
+void disk_monitoring_stop();
+#define FDS_SIGNAL_PIPE 0
static int get_configured_connection_table_size();
#ifdef RESOLVER_NEEDS_LOW_FILE_DESCRIPTORS
@@ -155,7 +161,6 @@ HANDLE hServDoneEvent = NULL;
static int createsignalpipe( void );
-
#if defined( _WIN32 )
/* Set an event to hook the NT Service termination */
void *slapd_service_exit_wait()
@@ -470,6 +475,444 @@ time_thread(void *nothing)
return(NULL);
}
+/*
+ * Return a copy of the mount point for the specified directory
+ */
+#ifdef SOLARIS
+char *
+disk_mon_get_mount_point(char *dir)
+{
+ struct mnttab *mnt;
+ struct stat s;
+ dev_t dev_id;
+ FILE *fp;
+
+ fp = fopen("/etc/mnttab", "r");
+
+ if (fp == NULL || stat(dir, &s) != 0) {
+ return NULL;
+ }
+
+ dev_id = s.st_dev;
+
+ while((mnt = getmntent(fp))){
+ if (stat(mnt->mnt_mountp, &s) != 0) {
+ continue;
+ }
+ if (s.st_dev == dev_id) {
+ return (slapi_ch_strdup(mnt->mnt_mountp));
+ }
+ }
+
+ return NULL;
+}
+#elif HPUX
+char *
+disk_mon_get_mount_point(char *dir)
+{
+ struct mntent *mnt;
+ struct stat s;
+ dev_t dev_id;
+ FILE *fp;
+
+ if ((fp = setmntent("/etc/mnttab", "r")) == NULL) {
+ return NULL;
+ }
+
+ if (stat(dir, &s) != 0) {
+ return NULL;
+ }
+
+ dev_id = s.st_dev;
+
+ while((mnt = getmntent(fp))){
+ if (stat(mnt->mnt_dir, &s) != 0) {
+ continue;
+ }
+ if (s.st_dev == dev_id) {
+ endmntent(fp);
+ return (slapi_ch_strdup(mnt->mnt_dir));
+ }
+ }
+ endmntent(fp);
+
+ return NULL;
+}
+#else /* Linux */
+char *
+disk_mon_get_mount_point(char *dir)
+{
+ struct mntent *mnt;
+ struct stat s;
+ dev_t dev_id;
+ FILE *fp;
+
+ if (stat(dir, &s) != 0) {
+ return NULL;
+ }
+
+ dev_id = s.st_dev;
+ if ((fp = setmntent("/proc/mounts", "r")) == NULL) {
+ return NULL;
+ }
+ while((mnt = getmntent(fp))){
+ if (stat(mnt->mnt_dir, &s) != 0) {
+ continue;
+ }
+ if (s.st_dev == dev_id) {
+ endmntent(fp);
+ return (slapi_ch_strdup(mnt->mnt_dir));
+ }
+ }
+ endmntent(fp);
+
+ return NULL;
+}
+#endif
+
+/*
+ * Get the mount point of the directory, and add it to the
+ * list. Skip duplicate mount points.
+ */
+void
+disk_mon_add_dir(char ***list, char *directory)
+{
+ char *dir = disk_mon_get_mount_point(directory);
+
+ if(dir == NULL)
+ return;
+
+ if(!charray_inlist(*list,dir)){
+ slapi_ch_array_add(list, dir);
+ } else {
+ slapi_ch_free((void **)&dir);
+ }
+}
+
+/*
+ * We gather all the log, txn log, config, and db directories
+ */
+void
+disk_mon_get_dirs(char ***list, int logs_critical){
+ slapdFrontendConfig_t *config = getFrontendConfig();
+ Slapi_Backend *be = NULL;
+ char *cookie = NULL;
+ char *dir = NULL;
+
+ if(logs_critical){
+ slapi_rwlock_rdlock(config->cfg_rwlock);
+ disk_mon_add_dir(list, config->accesslog);
+ disk_mon_add_dir(list, config->errorlog);
+ disk_mon_add_dir(list, config->auditlog);
+ slapi_rwlock_unlock(config->cfg_rwlock);
+ }
+
+ /* Add /var just to be safe */
+#ifdef LOCALSTATEDIR
+ disk_mon_add_dir(list, LOCALSTATEDIR);
+#else
+ disk_mon_add_dir(list, "/var");
+#endif
+
+ /* config and backend directories */
+ slapi_rwlock_rdlock(config->cfg_rwlock);
+ disk_mon_add_dir(list, config->configdir);
+ slapi_rwlock_unlock(config->cfg_rwlock);
+
+ be = slapi_get_first_backend (&cookie);
+ while (be) {
+ if(slapi_back_get_info(be, BACK_INFO_DIRECTORY, (void **)&dir) == LDAP_SUCCESS){ /* db directory */
+ disk_mon_add_dir(list, dir);
+ }
+ if(slapi_back_get_info(be, BACK_INFO_LOG_DIRECTORY, (void **)&dir) == LDAP_SUCCESS){ /* txn log dir */
+ disk_mon_add_dir(list, dir);
+ }
+ be = (backend *)slapi_get_next_backend (cookie);
+ }
+}
+
+/*
+ * This function checks the list of directories to see if any are below the
+ * threshold. We return the the directory/free disk space of the most critical
+ * directory.
+ */
+char *
+disk_mon_check_diskspace(char **dirs, PRInt64 threshold, PRInt64 *disk_space)
+{
+#ifdef LINUX
+ struct statfs buf;
+#else
+ struct statvfs buf;
+#endif
+ PRInt64 worst_disk_space = threshold;
+ PRInt64 freeBytes = 0;
+ PRInt64 blockSize = 0;
+ char *worst_dir = NULL;
+ int hit_threshold = 0;
+ int i = 0;
+
+ for(i = 0; dirs && dirs[i]; i++){
+#ifndef LINUX
+ if (statvfs(dirs[i], &buf) != -1)
+#else
+ if (statfs(dirs[i], &buf) != -1)
+#endif
+ {
+ LL_UI2L(freeBytes, buf.f_bavail);
+ LL_UI2L(blockSize, buf.f_bsize);
+ LL_MUL(freeBytes, freeBytes, blockSize);
+
+ if(LL_UCMP(freeBytes, <, threshold)){
+ hit_threshold = 1;
+ if(LL_UCMP(freeBytes, <, worst_disk_space)){
+ worst_disk_space = freeBytes;
+ worst_dir = dirs[i];
+ }
+ }
+ }
+ }
+
+ if(hit_threshold){
+ *disk_space = worst_disk_space;
+ return worst_dir;
+ } else {
+ *disk_space = 0;
+ return NULL;
+ }
+}
+
+#define LOGGING_OFF 0
+#define LOGGING_ON 1
+/*
+ * Disk Space Monitoring Thread
+ *
+ * We need to monitor the free disk space of critical disks.
+ *
+ * If we get below the free disk space threshold, start taking measures
+ * to avoid additional disk space consumption by stopping verbose logging,
+ * access/audit logging, and deleting rotated logs.
+ *
+ * If this is not enough, then we need to shut slapd down to avoid
+ * possibly corrupting the db.
+ *
+ * Future - it would be nice to be able to email an alert.
+ */
+void
+disk_monitoring_thread(void *nothing)
+{
+ char errorbuf[BUFSIZ];
+ char **dirs = NULL;
+ char *dirstr = NULL;
+ PRInt64 previous_mark = 0;
+ PRInt64 disk_space = 0;
+ PRInt64 threshold = 0;
+ time_t start = 0;
+ time_t now = 0;
+ int deleted_rotated_logs = 0;
+ int logging_critical = 0;
+ int preserve_logging = 0;
+ int passed_threshold = 0;
+ int verbose_logging = 0;
+ int using_accesslog = 0;
+ int using_auditlog = 0;
+ int logs_disabled = 0;
+ int grace_period = 0;
+ int first_pass = 1;
+ int halfway = 0;
+ int ok_now = 0;
+
+ while(!g_get_shutdown()) {
+ if(!first_pass){
+ PR_Lock(diskmon_mutex);
+ PR_WaitCondVar(diskmon_cvar, PR_SecondsToInterval(10));
+ PR_Unlock(diskmon_mutex);
+ /*
+ * We need to subtract from disk_space to account for the
+ * logging we just did, it doesn't hurt if we subtract a
+ * little more than necessary.
+ */
+ previous_mark = disk_space - 512;
+ ok_now = 0;
+ } else {
+ first_pass = 0;
+ }
+ /*
+ * Get the config settings, as they could have changed
+ */
+ logging_critical = config_get_disk_logging_critical();
+ preserve_logging = config_get_disk_preserve_logging();
+ grace_period = 60 * config_get_disk_grace_period(); /* convert it to seconds */
+ verbose_logging = config_get_errorlog_level();
+ threshold = config_get_disk_threshold();
+ halfway = threshold / 2;
+
+ if(config_get_auditlog_logging_enabled()){
+ using_auditlog = 1;
+ }
+ if(config_get_accesslog_logging_enabled()){
+ using_accesslog = 1;
+ }
+ /*
+ * Check the disk space. Always refresh the list, as backends can be added
+ */
+ slapi_ch_array_free(dirs);
+ dirs = NULL;
+ disk_mon_get_dirs(&dirs, logging_critical);
+ dirstr = disk_mon_check_diskspace(dirs, threshold, &disk_space);
+ if(dirstr == NULL){
+ /*
+ * Good, none of our disks are within the threshold,
+ * reset the logging if we turned it off
+ */
+ if(passed_threshold){
+ if(logs_disabled){
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is now within acceptable levels. "
+ "Restoring the log settings.\n",0,0,0);
+ if(using_accesslog){
+ config_set_accesslog_enabled(LOGGING_ON);
+ }
+ if(using_auditlog){
+ config_set_auditlog_enabled(LOGGING_ON);
+ }
+ } else {
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is now within acceptable levels.\n",0,0,0);
+ }
+ deleted_rotated_logs = 0;
+ passed_threshold = 0;
+ previous_mark = 0;
+ logs_disabled = 0;
+ }
+ continue;
+ } else {
+ passed_threshold = 1;
+ }
+ /*
+ * Check if we are already critical
+ */
+ if(disk_space < 4096){ /* 4 k */
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is critically low on disk (%s), remaining space: %d Kb. "
+ "Signaling slapd for shutdown...\n", dirstr , (disk_space / 1024), 0);
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ return;
+ }
+ /*
+ * If we are low, see if we are using verbose error logging, and turn it off
+ */
+ if(verbose_logging){
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is low on disk (%s), remaining space: %d Kb, "
+ "setting error loglevel to zero.\n", dirstr, (disk_space / 1024), 0);
+ config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, 0, errorbuf, CONFIG_APPLY);
+ continue;
+ }
+ /*
+ * If we are low, there's no verbose logging, logs are not critical, then disable the
+ * access/audit logs, log another error, and continue.
+ */
+ if(!logs_disabled && (!preserve_logging || !logging_critical)){
+ if(disk_space < previous_mark){
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
+ "disabling access and audit logging.\n", dirstr, (disk_space / 1024), 0);
+ config_set_accesslog_enabled(LOGGING_OFF);
+ config_set_auditlog_enabled(LOGGING_OFF);
+ logs_disabled = 1;
+ }
+ continue;
+ }
+ /*
+ * If we are low, we turned off verbose logging, logs are not critical, and we disabled
+ * access/audit logging, then delete the rotated logs, log another error, and continue.
+ */
+ if(!deleted_rotated_logs && (!preserve_logging || !logging_critical)){
+ if(disk_space < previous_mark){
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
+ "deleting rotated logs.\n", dirstr, (disk_space / 1024), 0);
+ log__delete_rotated_logs();
+ deleted_rotated_logs = 1;
+ }
+ continue;
+ }
+ /*
+ * Ok, we've done what we can, log a message if we continue to lose available disk space
+ */
+ if(disk_space < previous_mark){
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb\n",
+ dirstr, (disk_space / 1024), 0);
+ }
+ /*
+ *
+ * If we are below the halfway mark, and we did everything else,
+ * go into shutdown mode. If the disk space doesn't get critical,
+ * wait for the grace period before shutting down. This gives an
+ * admin the chance to clean things up.
+ *
+ */
+ if(disk_space < halfway){
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space on (%s) is too far below the threshold(%d bytes). "
+ "Waiting %d minutes for disk space to be cleaned up before shutting slapd down...\n",
+ dirstr, threshold, (grace_period / 60));
+ time(&start);
+ now = start;
+ while( (now - start) < grace_period ){
+ if(g_get_shutdown()){
+ return;
+ }
+ /*
+ * Sleep for a little bit, but we don't want to run out of disk space
+ * while sleeping for the entire grace period
+ */
+ DS_Sleep(PR_SecondsToInterval(1));
+ /*
+ * Now check disk space again in hopes some space was freed up
+ */
+ dirstr = disk_mon_check_diskspace(dirs, threshold, &disk_space);
+ if(!dirstr){
+ /*
+ * Excellent, we are back to acceptable levels, reset everything...
+ */
+ LDAPDebug(LDAP_DEBUG_ANY, "Available disk space is now acceptable (%d bytes). Aborting"
+ " shutdown, and restoring the log settings.\n",disk_space,0,0);
+ if(!preserve_logging && using_accesslog){
+ config_set_accesslog_enabled(LOGGING_ON);
+ }
+ if(!preserve_logging && using_auditlog){
+ config_set_auditlog_enabled(LOGGING_ON);
+ }
+ deleted_rotated_logs = 0;
+ passed_threshold = 0;
+ logs_disabled = 0;
+ previous_mark = 0;
+ ok_now = 1;
+ start = 0;
+ now = 0;
+ break;
+ } else if(disk_space < 4096){ /* 4 k */
+ /*
+ * Disk space is critical, log an error, and shut it down now!
+ */
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is critically low on disk (%s), remaining space: %d Kb."
+ " Signaling slapd for shutdown...\n", dirstr, (disk_space / 1024), 0);
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ return;
+ }
+ time(&now);
+ }
+
+ if(ok_now){
+ /*
+ * Disk space is acceptable, resume normal processing
+ */
+ continue;
+ }
+ /*
+ * If disk space was freed up we would of detected in the above while loop. So shut it down.
+ */
+ LDAPDebug(LDAP_DEBUG_ANY, "Disk space is still too low (%d Kb). Signaling slapd for shutdown...\n",
+ (disk_space / 1024), 0, 0);
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ return;
+ }
+ }
+}
void slapd_daemon( daemon_ports_t *ports )
{
@@ -563,7 +1006,44 @@ void slapd_daemon( daemon_ports_t *ports )
g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
}
- /* We are now ready to accept imcoming connections */
+ /*
+ * If we are monitoring disk space, then create the mutex, the cvar,
+ * and the monitoring thread.
+ */
+ if( config_get_disk_monitoring() ){
+ if ( ( diskmon_mutex = PR_NewLock() ) == NULL ) {
+ slapi_log_error(SLAPI_LOG_FATAL, NULL,
+ "Cannot create new lock for disk space monitoring. "
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
+ PR_GetError(), slapd_pr_strerror( PR_GetError() ));
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ }
+ if ( diskmon_mutex ){
+ if(( diskmon_cvar = PR_NewCondVar( diskmon_mutex )) == NULL ) {
+ slapi_log_error(SLAPI_LOG_FATAL, NULL,
+ "Cannot create new condition variable for disk space monitoring. "
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
+ PR_GetError(), slapd_pr_strerror( PR_GetError() ));
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ }
+ }
+ if( diskmon_mutex && diskmon_cvar ){
+ disk_thread_p = PR_CreateThread(PR_SYSTEM_THREAD,
+ (VFP) (void *) disk_monitoring_thread, NULL,
+ PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
+ PR_JOINABLE_THREAD,
+ SLAPD_DEFAULT_THREAD_STACKSIZE);
+ if ( NULL == disk_thread_p ) {
+ PRErrorCode errorCode = PR_GetError();
+ LDAPDebug(LDAP_DEBUG_ANY, "Unable to create disk monitoring thread - Shutting Down ("
+ SLAPI_COMPONENT_NAME_NSPR " error %d - %s)\n",
+ errorCode, slapd_pr_strerror(errorCode), 0);
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ }
+ }
+ }
+
+ /* We are now ready to accept incoming connections */
#if defined( XP_WIN32 )
if ( n_tcps != SLAPD_INVALID_SOCKET
&& listen( n_tcps, DAEMON_LISTEN_SIZE ) == -1 ) {
@@ -807,6 +1287,7 @@ void slapd_daemon( daemon_ports_t *ports )
be_flushall();
op_thread_cleanup();
housekeeping_stop(); /* Run this after op_thread_cleanup() logged sth */
+ disk_monitoring_stop(disk_thread_p);
#ifndef _WIN32
threads = g_get_active_threadcnt();
@@ -3128,10 +3609,10 @@ void configure_ns_socket( int * ns )
on = 0;
setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
} /* else (!enable_nagle) */
-
-
+
+
return;
-
+
}
@@ -3158,3 +3639,13 @@ get_loopback_by_addr( void )
AF_INET, &hp, hbuf, sizeof(hbuf), &herrno );
}
#endif /* RESOLVER_NEEDS_LOW_FILE_DESCRIPTORS */
+
+void
+disk_monitoring_stop()
+{
+ if ( disk_thread_p ) {
+ PR_Lock( diskmon_mutex );
+ PR_NotifyCondVar( diskmon_cvar );
+ PR_Unlock( diskmon_mutex );
+ }
+}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index b6c0c1f33..26c696ed2 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -662,6 +662,26 @@ static struct config_get_and_set {
NULL, 0,
(void**)&global_slapdFrontendConfig.default_naming_context,
CONFIG_STRING, (ConfigGetFunc)config_get_default_naming_context},
+ {CONFIG_DISK_MONITORING, config_set_disk_monitoring,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.disk_monitoring, CONFIG_ON_OFF,
+ (ConfigGetFunc)config_get_disk_monitoring},
+ {CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.disk_threshold, CONFIG_INT,
+ (ConfigGetFunc)config_get_disk_threshold},
+ {CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.disk_grace_period,
+ CONFIG_INT, (ConfigGetFunc)config_get_disk_grace_period},
+ {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_logging_critical,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.disk_logging_critical,
+ CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical},
+ {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_preserve_logging,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.disk_preserve_logging,
+ CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging},
#ifdef MEMPOOL_EXPERIMENTAL
,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
NULL, 0,
@@ -1050,6 +1070,12 @@ FrontendConfig_init () {
cfg->allowed_to_delete_attrs = slapi_ch_strdup("nsslapd-listenhost nsslapd-securelistenhost nsslapd-defaultnamingcontext");
cfg->default_naming_context = NULL; /* store normalized dn */
+ cfg->disk_monitoring = LDAP_OFF;
+ cfg->disk_threshold = 2097152; /* 2 mb */
+ cfg->disk_grace_period = 60; /* 1 hour */
+ cfg->disk_preserve_logging = LDAP_OFF;
+ cfg->disk_logging_critical = LDAP_OFF;
+
#ifdef MEMPOOL_EXPERIMENTAL
cfg->mempool_switch = LDAP_ON;
cfg->mempool_maxfreelist = 1024;
@@ -1159,7 +1185,98 @@ config_value_is_null( const char *attrname, const char *value, char *errorbuf,
return 0;
}
+int
+config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal = LDAP_SUCCESS;
+ retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_monitoring),
+ errorbuf, apply);
+ return retVal;
+}
+
+int
+config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal = LDAP_SUCCESS;
+ long threshold = 0;
+ char *endp = NULL;
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ threshold = strtol(value, &endp, 10);
+
+ if ( *endp != '\0' || threshold < 2048 ) {
+ PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, threshold must be greater than 2048 and less then %ld",
+ attrname, value, LONG_MAX );
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
+ }
+
+ if (apply) {
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapdFrontendConfig->disk_threshold = threshold;
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ }
+
+ return retVal;
+}
+
+int
+config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal = LDAP_SUCCESS;
+
+ retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_preserve_logging),
+ errorbuf, apply);
+ return retVal;
+}
+
+int
+config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal = LDAP_SUCCESS;
+
+ retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_logging_critical),
+ errorbuf, apply);
+ return retVal;
+}
+
+int
+config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal = LDAP_SUCCESS;
+ int period = 0;
+ char *endp = NULL;
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ period = strtol(value, &endp, 10);
+
+ if ( *endp != '\0' || period < 1 ) {
+ PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, grace period must be at least 1 minute",
+ attrname, value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
+ }
+
+ if (apply) {
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapdFrontendConfig->disk_grace_period = period;
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ }
+
+ return retVal;
+}
int
config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
@@ -3552,6 +3669,66 @@ config_get_port(){
}
+int
+config_get_disk_monitoring(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->disk_monitoring;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int
+config_get_disk_preserve_logging(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->disk_preserve_logging;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int
+config_get_disk_logging_critical(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->disk_logging_critical;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int
+config_get_disk_grace_period(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->disk_grace_period;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+long
+config_get_disk_threshold(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ long retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->disk_threshold;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
char *
config_get_ldapi_filename(){
char *retVal;
@@ -4008,8 +4185,6 @@ config_get_pw_maxfailure() {
}
-
-
int
config_get_pw_inhistory() {
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4022,9 +4197,6 @@ config_get_pw_inhistory() {
return retVal;
}
-
-
-
long
config_get_pw_lockduration() {
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4038,7 +4210,6 @@ config_get_pw_lockduration() {
}
-
long
config_get_pw_resetfailurecount() {
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4088,7 +4259,6 @@ config_get_pw_unlock() {
return retVal;
}
-
int
config_get_pw_lockout(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4101,7 +4271,6 @@ config_get_pw_lockout(){
return retVal;
}
-
int
config_get_pw_gracelimit() {
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4115,7 +4284,6 @@ config_get_pw_gracelimit() {
}
-
int
config_get_lastmod(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4128,7 +4296,6 @@ config_get_lastmod(){
return retVal;
}
-
int
config_get_enquote_sup_oc(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4141,7 +4308,6 @@ config_get_enquote_sup_oc(){
return retVal;
}
-
int
config_get_nagle() {
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4150,8 +4316,8 @@ config_get_nagle() {
CFG_LOCK_READ(slapdFrontendConfig);
retVal = slapdFrontendConfig->nagle;
CFG_UNLOCK_READ(slapdFrontendConfig);
-return retVal; }
-
+ return retVal;
+}
int
config_get_accesscontrol() {
@@ -4197,7 +4363,7 @@ config_get_security() {
CFG_UNLOCK_READ(slapdFrontendConfig);
return retVal;
- }
+}
int
slapi_config_get_readonly() {
@@ -4209,8 +4375,7 @@ slapi_config_get_readonly() {
CFG_UNLOCK_READ(slapdFrontendConfig);
return retVal;
- }
-
+}
int
config_get_schemacheck() {
@@ -4222,7 +4387,7 @@ config_get_schemacheck() {
CFG_UNLOCK_READ(slapdFrontendConfig);
return retVal;
- }
+}
int
config_get_syntaxcheck() {
@@ -4270,7 +4435,7 @@ config_get_ds4_compatible_schema() {
CFG_UNLOCK_READ(slapdFrontendConfig);
return retVal;
- }
+}
int
config_get_schema_ignore_trailing_spaces() {
@@ -4282,7 +4447,7 @@ config_get_schema_ignore_trailing_spaces() {
CFG_UNLOCK_READ(slapdFrontendConfig);
return retVal;
- }
+}
char *
config_get_rootdn() {
@@ -4325,7 +4490,6 @@ config_get_rootpwstoragescheme() {
return retVal;
}
-
#ifndef _WIN32
char *
@@ -4406,8 +4570,6 @@ config_get_reservedescriptors(){
return retVal;
}
-
-
int
config_get_ioblocktimeout(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4418,8 +4580,7 @@ config_get_ioblocktimeout(){
CFG_UNLOCK_READ(slapdFrontendConfig);
return retVal;
- }
-
+}
int
config_get_idletimeout(){
@@ -4574,7 +4735,6 @@ config_get_pw_minage(){
return retVal;
}
-
long
config_get_pw_warning() {
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4587,7 +4747,6 @@ config_get_pw_warning() {
return retVal;
}
-
int
config_get_errorlog_level(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4600,7 +4759,6 @@ config_get_errorlog_level(){
return retVal;
}
-
/* return integer -- don't worry about locking similar to config_check_referral_mode
below */
@@ -4627,6 +4785,16 @@ config_get_auditlog_logging_enabled(){
return retVal;
}
+int
+config_get_accesslog_logging_enabled(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ retVal = slapdFrontendConfig->accesslog_logging_enabled;
+
+ return retVal;
+}
+
char *config_get_referral_mode(void)
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4649,8 +4817,7 @@ config_get_conntablesize(void){
CFG_UNLOCK_READ(slapdFrontendConfig);
return retVal;
- }
-
+}
/* return yes/no without actually copying the referral url
we don't worry about another thread changing this value
@@ -4661,7 +4828,6 @@ int config_check_referral_mode(void)
return(slapdFrontendConfig->refer_mode & REFER_MODE_ON);
}
-
int
config_get_outbound_ldap_io_timeout(void)
{
@@ -4674,7 +4840,6 @@ config_get_outbound_ldap_io_timeout(void)
return retVal;
}
-
int
config_get_unauth_binds_switch(void)
{
@@ -4687,7 +4852,6 @@ config_get_unauth_binds_switch(void)
return retVal;
}
-
int
config_get_require_secure_binds(void)
{
@@ -6281,3 +6445,32 @@ config_allowed_to_delete_attrs(const char *attr_type)
return rc;
}
+void
+config_set_accesslog_enabled(int value){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ char errorbuf[BUFSIZ];
+
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapdFrontendConfig->accesslog_logging_enabled = value;
+ if(value){
+ log_set_logging(CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_ACCESS_LOG, errorbuf, CONFIG_APPLY);
+ } else {
+ log_set_logging(CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, "off", SLAPD_ACCESS_LOG, errorbuf, CONFIG_APPLY);
+ }
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+}
+
+void
+config_set_auditlog_enabled(int value){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ char errorbuf[BUFSIZ];
+
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapdFrontendConfig->auditlog_logging_enabled = value;
+ if(value){
+ log_set_logging(CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_AUDIT_LOG, errorbuf, CONFIG_APPLY);
+ } else {
+ log_set_logging(CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, "off", SLAPD_AUDIT_LOG, errorbuf, CONFIG_APPLY);
+ }
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index ebec254f3..60a49ab1a 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -2532,6 +2532,69 @@ delete_logfile:
return 1;
}
+/*
+ * This function is used by the disk monitoring thread (daemon.c)
+ *
+ * When we get close to running out of disk space we delete the rotated logs
+ * as a last resort to help keep the server up and running.
+ */
+void
+log__delete_rotated_logs()
+{
+ struct logfileinfo *logp = NULL;
+ char buffer[BUFSIZ];
+ char tbuf[TBUFSIZE];
+
+ /*
+ * Access Log
+ */
+ logp = loginfo.log_access_logchain;
+ while (logp) {
+ tbuf[0] = buffer[0] = '\0';
+ log_convert_time (logp->l_ctime, tbuf, 1);
+ PR_snprintf (buffer, sizeof(buffer), "%s.%s", loginfo.log_access_file, tbuf);
+
+ LDAPDebug(LDAP_DEBUG_ANY,"Deleted Rotated Log: %s\n",buffer,0,0); /* MARK */
+
+ if (PR_Delete(buffer) != PR_SUCCESS) {
+ logp = logp->l_next;
+ continue;
+ }
+ loginfo.log_numof_access_logs--;
+ logp = logp->l_next;
+ }
+ /*
+ * Audit Log
+ */
+ logp = loginfo.log_audit_logchain;
+ while (logp) {
+ tbuf[0] = buffer[0] = '\0';
+ log_convert_time (logp->l_ctime, tbuf, 1);
+ PR_snprintf (buffer, sizeof(buffer), "%s.%s", loginfo.log_audit_file, tbuf);
+ if (PR_Delete(buffer) != PR_SUCCESS) {
+ logp = logp->l_next;
+ continue;
+ }
+ loginfo.log_numof_audit_logs--;
+ logp = logp->l_next;
+ }
+ /*
+ * Error log
+ */
+ logp = loginfo.log_error_logchain;
+ while (logp) {
+ tbuf[0] = buffer[0] = '\0';
+ log_convert_time (logp->l_ctime, tbuf, 1);
+ PR_snprintf (buffer, sizeof(buffer), "%s.%s", loginfo.log_error_file, tbuf);
+ if (PR_Delete(buffer) != PR_SUCCESS) {
+ logp = logp->l_next;
+ continue;
+ }
+ loginfo.log_numof_error_logs--;
+ logp = logp->l_next;
+ }
+}
+
#define ERRORSLOG 1
#define ACCESSLOG 2
#define AUDITLOG 3
@@ -3776,7 +3839,7 @@ log__open_errorlogfile(int logfile_state, int locked)
while (logp) {
log_convert_time (logp->l_ctime, tbuf, 1 /*short */);
PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%"
- NSPRI64 "d)\n", PREVLOGFILE, loginfo.log_error_file, tbuf,
+ NSPRI64 "d)\n", PREVLOGFILE, loginfo.log_error_file, tbuf,
logp->l_ctime, logp->l_size);
LOG_WRITE(fpinfo, buffer, strlen(buffer), 0);
logp = logp->l_next;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index a62418777..9bbcf53ff 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -380,6 +380,11 @@ int config_set_entryusn_global( const char *attrname, char *value, char *errorbu
int config_set_allowed_to_delete_attrs( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_entryusn_import_init( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_default_naming_context( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
#if !defined(_WIN32) && !defined(AIX)
int config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply );
@@ -526,8 +531,15 @@ int config_get_entryusn_global(void);
char *config_get_allowed_to_delete_attrs(void);
char *config_get_entryusn_import_init(void);
char *config_get_default_naming_context(void);
-
int config_allowed_to_delete_attrs(const char *attr_type);
+void config_set_accesslog_enabled(int value);
+void config_set_auditlog_enabled(int value);
+int config_get_accesslog_logging_enabled();
+int config_get_disk_monitoring();
+long config_get_disk_threshold();
+int config_get_disk_grace_period();
+int config_get_disk_preserve_logging();
+int config_get_disk_logging_critical();
int is_abspath(const char *);
char* rel2abspath( char * );
@@ -737,7 +749,7 @@ int check_log_max_size(
void g_set_accesslog_level(int val);
-
+void log__delete_rotated_logs();
/*
* util.c
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 025f74997..f7c0bf2f5 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1989,6 +1989,11 @@ typedef struct _slapdEntryPoints {
#define CONFIG_ENTRYUSN_IMPORT_INITVAL "nsslapd-entryusn-import-initval"
#define CONFIG_ALLOWED_TO_DELETE_ATTRIBUTE "nsslapd-allowed-to-delete-attrs"
#define CONFIG_DEFAULT_NAMING_CONTEXT "nsslapd-defaultnamingcontext"
+#define CONFIG_DISK_MONITORING "nsslapd-disk-monitoring"
+#define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold"
+#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
+#define CONFIG_DISK_PRESERVE_LOGGING "nsslapd-disk-monitoring-preserve-logging"
+#define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
#ifdef MEMPOOL_EXPERIMENTAL
#define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
@@ -2214,6 +2219,13 @@ typedef struct _slapdFrontendConfig {
char *entryusn_import_init; /* Entry USN: determine the initital value of import */
int pagedsizelimit;
char *default_naming_context; /* Default naming context (normalized) */
+
+ /* disk monitoring */
+ int disk_monitoring;
+ int disk_threshold;
+ int disk_grace_period;
+ int disk_preserve_logging;
+ int disk_logging_critical;
} slapdFrontendConfig_t;
/* possible values for slapdFrontendConfig_t.schemareplace */
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 63eeb37d1..fa4892d7b 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6903,7 +6903,9 @@ enum
BACK_INFO_DBENV_OPENFLAGS, /* Get the dbenv openflags */
BACK_INFO_CRYPT_INIT, /* Ctrl: clcrypt_init */
BACK_INFO_CRYPT_ENCRYPT_VALUE, /* Ctrl: clcrypt_encrypt_value */
- BACK_INFO_CRYPT_DECRYPT_VALUE /* Ctrl: clcrypt_decrypt_value */
+ BACK_INFO_CRYPT_DECRYPT_VALUE, /* Ctrl: clcrypt_decrypt_value */
+ BACK_INFO_DIRECTORY, /* Get the directory path */
+ BACK_INFO_LOG_DIRECTORY /* Get the txn log directory */
};
struct _back_info_crypt_init {
| 0 |
f6d937e8189a5ebc2d096731bf811f3b370db612
|
389ds/389-ds-base
|
Fix syntax error in selinux interface.
There was a simple syntax error in the dirsrv SELinux interface
file. This would cause issues building the admin server SELinux
policy.
|
commit f6d937e8189a5ebc2d096731bf811f3b370db612
Author: Nathan Kinder <[email protected]>
Date: Mon Jan 18 11:37:18 2010 -0800
Fix syntax error in selinux interface.
There was a simple syntax error in the dirsrv SELinux interface
file. This would cause issues building the admin server SELinux
policy.
diff --git a/selinux/dirsrv.if b/selinux/dirsrv.if
index b8e1a7f99..c6e281140 100644
--- a/selinux/dirsrv.if
+++ b/selinux/dirsrv.if
@@ -77,7 +77,7 @@ interface(`dirsrv_manage_log',`
allow $1 dirsrv_var_log_t:dir manage_dir_perms;
allow $1 dirsrv_var_log_t:file manage_file_perms;
- allow $1 dirsrv_var_log_t:fifo_file: manage_fifo_file_perms;
+ allow $1 dirsrv_var_log_t:fifo_file manage_fifo_file_perms;
')
#######################################
| 0 |
b1e4f5f2bdfbfb88ecbacbd356b9a281af6f332b
|
389ds/389-ds-base
|
Issue 51102 - RFE - ds-replcheck - make online timeout configurable
Description:
Created a sanity test to check if the newly introduced -t option
for ds-replcheck does not break anything when used with various connection mechanisms.
Relates: https://pagure.io/389-ds-base/issue/51102
Reviewed by: spichugi (Thanks!)
|
commit b1e4f5f2bdfbfb88ecbacbd356b9a281af6f332b
Author: Barbora Simonova <[email protected]>
Date: Mon Aug 3 10:23:40 2020 +0200
Issue 51102 - RFE - ds-replcheck - make online timeout configurable
Description:
Created a sanity test to check if the newly introduced -t option
for ds-replcheck does not break anything when used with various connection mechanisms.
Relates: https://pagure.io/389-ds-base/issue/51102
Reviewed by: spichugi (Thanks!)
diff --git a/dirsrvtests/tests/suites/ds_tools/replcheck_test.py b/dirsrvtests/tests/suites/ds_tools/replcheck_test.py
index 010340af0..2411124ca 100644
--- a/dirsrvtests/tests/suites/ds_tools/replcheck_test.py
+++ b/dirsrvtests/tests/suites/ds_tools/replcheck_test.py
@@ -496,6 +496,48 @@ def test_dsreplcheck_with_password_file(topo_tls_ldapi, tmpdir):
subprocess.Popen(tool_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8')
[email protected]
[email protected]
[email protected](ds_is_older('1.4.1'), reason='Not implemented')
+def test_dsreplcheck_timeout_connection_mechanisms(topo_tls_ldapi):
+ """Check that ds-replcheck timeout option works with various connection mechanisms
+
+ :id: aeeb99c9-09e2-45dc-bd75-9f95409babe7
+ :setup: Two master replication
+ :steps:
+ 1. Create two masters with various connection mechanisms configured
+ 2. Run ds-replcheck with -t option
+ :expectedresults:
+ 1. Success
+ 2. Success
+ """
+
+ OUTPUT = 'Master and Replica are in perfect synchronization'
+
+ m1 = topo_tls_ldapi.ms["master1"]
+ m2 = topo_tls_ldapi.ms["master2"]
+
+ ds_replcheck_path = os.path.join(m1.ds_paths.bin_dir, 'ds-replcheck')
+
+ replcheck_cmd = [[ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',
+ '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '--conflicts',
+ '-r', 'ldap://{}:{}'.format(m2.host, m2.port), '-t', '120'],
+ [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',
+ '-m', 'ldaps://{}:{}'.format(m1.host, m1.sslport), '--conflicts',
+ '-r', 'ldaps://{}:{}'.format(m2.host, m2.sslport), '-t', '120'],
+ [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',
+ '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '-Z', m1.get_ssca_dir(),
+ '-r', 'ldap://{}:{}'.format(m2.host, m2.port), '--conflicts', '-t', '120'],
+ [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',
+ '-m', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m1.serverid), '--conflict',
+ '-r', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m2.serverid), '-t', '120']]
+
+ log.info('Run ds-replcheck with -t option')
+ for connection in replcheck_cmd:
+ result = subprocess.check_output(connection)
+ assert OUTPUT in ensure_str(result)
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
| 0 |
f08951680ddfebc3f3df07e720ad0650fe473c0f
|
389ds/389-ds-base
|
Updated SNMP OIDs for Red Hat namespace
|
commit f08951680ddfebc3f3df07e720ad0650fe473c0f
Author: Nathan Kinder <[email protected]>
Date: Thu Mar 3 19:21:46 2005 +0000
Updated SNMP OIDs for Red Hat namespace
diff --git a/ldap/servers/snmp/ldap-agent.c b/ldap/servers/snmp/ldap-agent.c
index a8060e8c5..efce41060 100644
--- a/ldap/servers/snmp/ldap-agent.c
+++ b/ldap/servers/snmp/ldap-agent.c
@@ -289,9 +289,9 @@ load_stats_table(netsnmp_cache *cache, void *foo)
if (serv_p->server_state == SERVER_UP) {
snmp_log(LOG_INFO, "Detected start of server: %d\n",
serv_p->port);
- send_nsDirectoryServerStart_trap(serv_p);
+ send_DirectoryServerStart_trap(serv_p);
} else {
- send_nsDirectoryServerDown_trap(serv_p);
+ send_DirectoryServerDown_trap(serv_p);
/* Zero out the ops and entries tables */
memset(&ctx->ops_tbl, 0x00, sizeof(ctx->ops_tbl));
memset(&ctx->entries_tbl, 0x00, sizeof(ctx->entries_tbl));
@@ -299,8 +299,8 @@ load_stats_table(netsnmp_cache *cache, void *foo)
} else if (ctx->hdr_tbl.startTime != previous_start) {
/* Send traps if the server has restarted since the last load */
snmp_log(LOG_INFO, "Detected restart of server: %d\n", serv_p->port);
- send_nsDirectoryServerDown_trap(serv_p);
- send_nsDirectoryServerStart_trap(serv_p);
+ send_DirectoryServerDown_trap(serv_p);
+ send_DirectoryServerStart_trap(serv_p);
}
}
} else {
@@ -575,30 +575,37 @@ dsEntityTable_get_value(netsnmp_request_info *request,
}
/************************************************************
- * send_nsDirectoryServerDown_trap
+ * send_DirectoryServerDown_trap
*
* Sends off the server down trap.
*/
int
-send_nsDirectoryServerDown_trap(server_instance *serv_p)
+send_DirectoryServerDown_trap(server_instance *serv_p)
{
netsnmp_variable_list *var_list = NULL;
+ stats_table_context *ctx = NULL;
snmp_log(LOG_INFO, "Sending down trap for server: %d\n", serv_p->port);
/* Define the oids for the trap */
- oid nsDirectoryServerDown_oid[] = { nsDirectoryServerDown_OID };
+ oid DirectoryServerDown_oid[] = { DirectoryServerDown_OID };
oid dsEntityDescr_oid[] = { dsEntityTable_TABLE_OID, 1, COLUMN_DSENTITYDESCR, serv_p->port };
oid dsEntityVers_oid[] = { dsEntityTable_TABLE_OID, 1, COLUMN_DSENTITYVERS, serv_p->port };
oid dsEntityLocation_oid[] = { dsEntityTable_TABLE_OID, 1, COLUMN_DSENTITYLOCATION, serv_p->port };
oid dsEntityContact_oid[] = { dsEntityTable_TABLE_OID, 1, COLUMN_DSENTITYCONTACT, serv_p->port };
-
+
+ /* Lookup row to get version string */
+ if ((ctx = stats_table_find_row(serv_p->port)) == NULL) {
+ snmp_log(LOG_ERR, "Malloc error finding row for server: %d\n", serv_p->port);
+ return 1;
+ }
+
/* Setup the variable list to send with the trap */
snmp_varlist_add_variable(&var_list,
snmptrap_oid, OID_LENGTH(snmptrap_oid),
ASN_OBJECT_ID,
- (u_char *) &nsDirectoryServerDown_oid,
- sizeof(nsDirectoryServerDown_oid));
+ (u_char *) &DirectoryServerDown_oid,
+ sizeof(DirectoryServerDown_oid));
snmp_varlist_add_variable(&var_list,
dsEntityDescr_oid,
OID_LENGTH(dsEntityDescr_oid), ASN_OCTET_STR,
@@ -607,8 +614,8 @@ send_nsDirectoryServerDown_trap(server_instance *serv_p)
snmp_varlist_add_variable(&var_list,
dsEntityVers_oid,
OID_LENGTH(dsEntityVers_oid), ASN_OCTET_STR,
- (char *) serv_p->version,
- strlen(serv_p->version));
+ (char *) ctx->hdr_tbl.dsVersion,
+ strlen(ctx->hdr_tbl.dsVersion));
snmp_varlist_add_variable(&var_list,
dsEntityLocation_oid,
OID_LENGTH(dsEntityLocation_oid),
@@ -630,29 +637,36 @@ send_nsDirectoryServerDown_trap(server_instance *serv_p)
}
/************************************************************
- * send_nsDirectoryServerStart_trap
+ * send_DirectoryServerStart_trap
*
* Sends off the server start trap.
*/
int
-send_nsDirectoryServerStart_trap(server_instance *serv_p)
+send_DirectoryServerStart_trap(server_instance *serv_p)
{
netsnmp_variable_list *var_list = NULL;
-
+ stats_table_context *ctx = NULL;
+
snmp_log(LOG_INFO, "Sending start trap for server: %d\n", serv_p->port);
-
+
/* Define the oids for the trap */
- oid nsDirectoryServerStart_oid[] = { nsDirectoryServerStart_OID };
+ oid DirectoryServerStart_oid[] = { DirectoryServerStart_OID };
oid dsEntityDescr_oid[] = { dsEntityTable_TABLE_OID, 1, COLUMN_DSENTITYDESCR, serv_p->port };
oid dsEntityVers_oid[] = { dsEntityTable_TABLE_OID, 1, COLUMN_DSENTITYVERS, serv_p->port };
oid dsEntityLocation_oid[] = { dsEntityTable_TABLE_OID, 1, COLUMN_DSENTITYLOCATION, serv_p->port };
-
+
+ /* Lookup row to get version string */
+ if ((ctx = stats_table_find_row(serv_p->port)) == NULL) {
+ snmp_log(LOG_ERR, "Malloc error finding row for server: %d\n", serv_p->port);
+ return 1;
+ }
+
/* Setup the variable list to send with the trap */
snmp_varlist_add_variable(&var_list,
snmptrap_oid, OID_LENGTH(snmptrap_oid),
ASN_OBJECT_ID,
- (u_char *) &nsDirectoryServerStart_oid,
- sizeof(nsDirectoryServerStart_oid));
+ (u_char *) &DirectoryServerStart_oid,
+ sizeof(DirectoryServerStart_oid));
snmp_varlist_add_variable(&var_list,
dsEntityDescr_oid,
OID_LENGTH(dsEntityDescr_oid), ASN_OCTET_STR,
@@ -661,8 +675,8 @@ send_nsDirectoryServerStart_trap(server_instance *serv_p)
snmp_varlist_add_variable(&var_list,
dsEntityVers_oid,
OID_LENGTH(dsEntityVers_oid), ASN_OCTET_STR,
- (char *) serv_p->version,
- strlen(serv_p->version));
+ (char *) ctx->hdr_tbl.dsVersion,
+ strlen(ctx->hdr_tbl.dsVersion));
snmp_varlist_add_variable(&var_list,
dsEntityLocation_oid,
OID_LENGTH(dsEntityLocation_oid),
diff --git a/ldap/servers/snmp/ldap-agent.h b/ldap/servers/snmp/ldap-agent.h
index 6acf79c69..4ce3fcf38 100644
--- a/ldap/servers/snmp/ldap-agent.h
+++ b/ldap/servers/snmp/ldap-agent.h
@@ -20,8 +20,8 @@ extern "C" {
/*************************************************************
* Trap value defines
*/
-#define SERVER_UP 7002
-#define SERVER_DOWN 7001
+#define SERVER_UP 6002
+#define SERVER_DOWN 6001
#define STATE_UNKNOWN 0
/*************************************************************
@@ -33,7 +33,6 @@ typedef struct server_instance_s {
char *stats_file;
char *dse_ldif;
char *description;
- char *version;
char *org;
char *location;
char *contact;
@@ -68,8 +67,8 @@ typedef struct stats_table_context_s {
int dsEntityTable_get_value(netsnmp_request_info *,
netsnmp_index *,
netsnmp_table_request_info *);
- int send_nsDirectoryServerDown_trap(server_instance *);
- int send_nsDirectoryServerStart_trap(server_instance *);
+ int send_DirectoryServerDown_trap(server_instance *);
+ int send_DirectoryServerStart_trap(server_instance *);
/*************************************************************
* Oid Declarations
@@ -83,13 +82,13 @@ typedef struct stats_table_context_s {
extern oid snmptrap_oid[];
extern size_t snmptrap_oid_len;
-#define enterprise_OID 1,3,6,1,4,1,1450
-#define dsOpsTable_TABLE_OID enterprise_OID,7,1
-#define dsEntriesTable_TABLE_OID enterprise_OID,7,2
-#define dsEntityTable_TABLE_OID enterprise_OID,7,5
+#define enterprise_OID 1,3,6,1,4,1,2312
+#define dsOpsTable_TABLE_OID enterprise_OID,6,1
+#define dsEntriesTable_TABLE_OID enterprise_OID,6,2
+#define dsEntityTable_TABLE_OID enterprise_OID,6,5
#define snmptrap_OID 1,3,6,1,6,3,1,1,4,1,0
-#define nsDirectoryServerDown_OID enterprise_OID,0,7001
-#define nsDirectoryServerStart_OID enterprise_OID,0,7002
+#define DirectoryServerDown_OID enterprise_OID,0,6001
+#define DirectoryServerStart_OID enterprise_OID,0,6002
/*************************************************************
* dsOpsTable column defines
diff --git a/ldap/servers/snmp/redhat-directory.mib b/ldap/servers/snmp/redhat-directory.mib
new file mode 100644
index 000000000..f18717cef
--- /dev/null
+++ b/ldap/servers/snmp/redhat-directory.mib
@@ -0,0 +1,724 @@
+-- BEGIN COPYRIGHT BLOCK
+-- Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
+-- Copyright (C) 2005 Red Hat, Inc.
+-- All rights reserved.
+-- END COPYRIGHT BLOCK
+--
+--
+-- MIB for Red Hat and Fedora Directory Server
+--
+-- This is an implementation of the MADMAN mib for monitoring LDAP/CLDAP and X.500
+-- directories described in RFC 2788 and 2789
+-- with the addition of traps for server up and down events
+
+RHDS-MIB DEFINITIONS ::= BEGIN
+
+IMPORTS
+ MODULE-IDENTITY, Counter32, Gauge32, OBJECT-TYPE
+ FROM SNMPv2-SMI
+ DisplayString, TimeStamp, TEXTUAL-CONVENTION
+ FROM SNMPv2-TC
+ MODULE-COMPLIANCE, OBJECT-GROUP
+ FROM SNMPv2-CONF
+ applIndex, DistinguishedName, URLString
+ FROM NETWORK-SERVICES-MIB
+ enterprises
+ FROM RFC1155-SMI
+ TRAP-TYPE
+ FROM RFC-1215;
+
+ redhat OBJECT IDENTIFIER ::= {enterprises 2312}
+
+ URLString ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "I couldn't find it but madman said it should be here, guessing DisplayString"
+ SYNTAX DisplayString
+
+ rhds MODULE-IDENTITY
+ LAST-UPDATED "200503020000Z"
+ ORGANIZATION "Red Hat, Inc."
+ CONTACT-INFO
+ "Red Hat, Inc.
+ Website: http://www.redhat.com"
+ DESCRIPTION
+ " An implementation of the MADMAN mib for monitoring LDAP/CLDAP and X.500
+ directories described in RFC 2788 and 2789
+ used for Red Hat and Fedora Directory Server"
+ ::= {redhat 6}
+
+ dsOpsTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF DsOpsEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ " The table holding information related to the
+ DS operations."
+ ::= {rhds 1}
+
+ dsOpsEntry OBJECT-TYPE
+ SYNTAX DsOpsEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ " Entry containing operations related statistics
+ for a DS."
+ INDEX { applIndex }
+ ::= {dsOpsTable 1}
+
+ DsOpsEntry ::= SEQUENCE {
+
+ -- Bindings
+
+ dsAnonymousBinds
+ Counter32,
+ dsUnAuthBinds
+ Counter32,
+ dsSimpleAuthBinds
+ Counter32,
+ dsStrongAuthBinds
+ Counter32,
+ dsBindSecurityErrors
+ Counter32,
+
+ -- In-coming operations
+
+ dsInOps
+ Counter32,
+ dsReadOps
+ Counter32,
+ dsCompareOps
+ Counter32,
+ dsAddEntryOps
+ Counter32,
+ dsRemoveEntryOps
+ Counter32,
+ dsModifyEntryOps
+ Counter32,
+ dsModifyRDNOps
+ Counter32,
+ dsListOps
+ Counter32,
+ dsSearchOps
+ Counter32,
+ dsOneLevelSearchOps
+ Counter32,
+ dsWholeSubtreeSearchOps
+ Counter32,
+
+ -- Out going operations
+
+ dsReferrals
+ Counter32,
+ dsChainings
+ Counter32,
+
+ -- Errors
+
+ dsSecurityErrors
+ Counter32,
+ dsErrors
+ Counter32
+ }
+
+ -- CLDAP does not use binds; for A CLDAP DS the bind
+ -- related counters will be inaccessible.
+ --
+ -- CLDAP and LDAP implement "Read" and "List" operations
+ -- indirectly via the "search" operation; the following
+ -- counters will be inaccessible for CLDAP and LDAP DSs:
+ -- dsReadOps, dsListOps
+ --
+ -- CLDAP does not implement "Compare", "Add", "Remove",
+ -- "Modify", "ModifyRDN"; the following counters will be
+ -- inaccessible for CLDAP DSs:
+ -- dsCompareOps, dsAddEntryOps, dsRemoveEntryOps,
+ -- dsModifyEntryOps, dsModifyRDNOps.
+ --
+ -- CLDAP and LDAP DS's do not return Referrals
+ -- the following fields will remain inaccessible for
+ -- CLDAP and LDAP DSs: dsReferrals.
+
+ dsAnonymousBinds OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of anonymous binds to this DS from UAs
+ since application start."
+ ::= {dsOpsEntry 1}
+
+ dsUnAuthBinds OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of un-authenticated binds to this DS since
+ application start."
+ ::= {dsOpsEntry 2}
+
+ dsSimpleAuthBinds OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of binds to this DS that were authenticated
+ using simple authentication procedures since
+ application start."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 8.1.2.1.1. and, RFC1777 Section 4.1"
+ ::= {dsOpsEntry 3}
+
+ dsStrongAuthBinds OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of binds to this DS that were authenticated
+ using the strong authentication procedures since
+ application start. This includes the binds that were
+ authenticated using external authentication procedures."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Sections 8.1.2.1.2 & 8.1.2.1.3. and, RFC1777 Section 4.1."
+ ::= {dsOpsEntry 4}
+
+ dsBindSecurityErrors OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of bind operations that have been rejected
+ by this DS due to inappropriateAuthentication or
+ invalidCredentials."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 12.7.2 and, RFC1777 Section 4."
+ ::= {dsOpsEntry 5}
+
+ dsInOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of operations forwarded to this DS
+ from UAs or other DSs since application
+ start up."
+ ::= {dsOpsEntry 6}
+
+ dsReadOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of read operations serviced by
+ this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 9.1."
+ ::= {dsOpsEntry 7}
+
+ dsCompareOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of compare operations serviced by
+ this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 9.2. and, RFC1777 section 4.8"
+ ::= {dsOpsEntry 8}
+
+ dsAddEntryOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of addEntry operations serviced by
+ this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 11.1. and, RFC1777 Section 4.5."
+ ::= {dsOpsEntry 9}
+
+ dsRemoveEntryOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of removeEntry operations serviced by
+ this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 11.2. and, RFC1777 Section 4.6."
+ ::= {dsOpsEntry 10}
+
+ dsModifyEntryOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of modifyEntry operations serviced by
+ this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 11.3. and, RFC1777 Section 4.4."
+ ::= {dsOpsEntry 11}
+
+ dsModifyRDNOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of modifyRDN operations serviced by
+ this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 11.4.and, RFC1777 Section 4.7"
+ ::= {dsOpsEntry 12}
+
+ dsListOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of list operations serviced by
+ this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 10.1."
+ ::= {dsOpsEntry 13}
+
+ dsSearchOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of search operations- baseObject searches,
+ oneLevel searches and wholeSubtree searches,
+ serviced by this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 10.2. and, RFC1777 Section 4.3."
+ ::= {dsOpsEntry 14}
+
+ dsOneLevelSearchOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of oneLevel search operations serviced
+ by this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 10.2.2.2. and, RFC1777 Section 4.3."
+ ::= {dsOpsEntry 15}
+
+ dsWholeSubtreeSearchOps OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of wholeSubtree search operations serviced
+ by this DS since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 10.2.2.2. and, RFC1777 Section 4.3."
+ ::= {dsOpsEntry 16}
+
+ dsReferrals OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of referrals returned by this DS in response
+ to requests for operations since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 12.6."
+ ::= {dsOpsEntry 17}
+
+ dsChainings OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of operations forwarded by this DS
+ to other DSs since application startup."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.518, 1988:
+ Section 14."
+ ::= {dsOpsEntry 18}
+
+ dsSecurityErrors OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of operations forwarded to this DS
+ which did not meet the security requirements. "
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Section 12.7. and, RFC1777 Section 4."
+ ::= {dsOpsEntry 19}
+
+ dsErrors OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of operations that could not be serviced
+ due to errors other than security errors, and
+ referrals.
+ A partially serviced operation will not be counted
+ as an error.
+ The errors include NameErrors, UpdateErrors, Attribute
+ errors and ServiceErrors."
+ REFERENCE
+ " CCITT Blue Book Fascicle VIII.8 - Rec. X.511, 1988:
+ Sections 12.4, 12.5, 12.8 & 12.9. and, RFC1777 Section 4."
+ ::= {dsOpsEntry 20}
+
+ -- Entry statistics/Cache performance
+ dsEntriesTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF DsEntriesEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ " The table holding information related to the
+ entry statistics and cache performance of the DSs."
+ ::= {rhds 2}
+
+ dsEntriesEntry OBJECT-TYPE
+ SYNTAX DsEntriesEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ " Entry containing statistics pertaining to entries
+ held by a DS."
+ INDEX { applIndex }
+ ::= {dsEntriesTable 1}
+
+
+ DsEntriesEntry ::= SEQUENCE {
+
+ dsMasterEntries
+ Gauge32,
+ dsCopyEntries
+ Gauge32,
+ dsCacheEntries
+ Gauge32,
+ dsCacheHits
+ Counter32,
+ dsSlaveHits
+ Counter32
+ }
+
+ -- A (C)LDAP frontend to the X.500 Directory will not have
+ -- MasterEntries, CopyEntries; the following counters will
+ -- be inaccessible for LDAP/CLDAP frontends to the X.500
+ -- directory: dsMasterEntries, dsCopyEntries, dsSlaveHits.
+
+ dsMasterEntries OBJECT-TYPE
+ SYNTAX Gauge32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of entries mastered in the DS."
+ ::= {dsEntriesEntry 1}
+
+ dsCopyEntries OBJECT-TYPE
+ SYNTAX Gauge32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of entries for which systematic (slave)
+ copies are maintained in the DS."
+ ::= {dsEntriesEntry 2}
+
+ dsCacheEntries OBJECT-TYPE
+ SYNTAX Gauge32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of entries cached (non-systematic copies) in
+ the DS. This will include the entries that are
+ cached partially. The negative cache is not counted."
+ ::= {dsEntriesEntry 3}
+
+ dsCacheHits OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of operations that were serviced from
+ the locally held cache since application
+ startup."
+ ::= {dsEntriesEntry 4}
+
+ dsSlaveHits OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Number of operations that were serviced from
+ the locally held object replications ( shadow
+ entries) since application startup."
+ ::= {dsEntriesEntry 5}
+
+ -- The dsIntTable contains statistical data on the peer DSs
+ -- with which the monitored DSs (attempt to) interact. This
+ -- table will provide a useful insight into the effect of
+ -- neighbours on the DS performance.
+ -- The table keeps track of the last "N" DSs with which the
+ -- monitored DSs has interacted (attempted to interact),
+ -- where "N" is a locally-defined constant.
+
+ dsIntTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF DsIntEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ " Each row of this table contains some details
+ related to the history of the interaction
+ of the monitored DSs with their respective
+ peer DSs."
+ ::= { rhds 3 }
+
+ dsIntEntry OBJECT-TYPE
+ SYNTAX DsIntEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ " Entry containing interaction details of a DS
+ with a peer DS."
+ INDEX { applIndex, dsIntIndex }
+ ::= { dsIntTable 1 }
+
+ DsIntEntry ::= SEQUENCE {
+
+ dsIntIndex
+ INTEGER,
+ dsName
+ DistinguishedName,
+ dsTimeOfCreation
+ TimeStamp,
+ dsTimeOfLastAttempt
+ TimeStamp,
+ dsTimeOfLastSuccess
+ TimeStamp,
+ dsFailuresSinceLastSuccess
+ Counter32,
+ dsFailures
+ Counter32,
+ dsSuccesses
+ Counter32,
+ dsURL
+ URLString
+
+ }
+
+ dsIntIndex OBJECT-TYPE
+ SYNTAX INTEGER (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ " Together with applIndex it forms the unique key to
+ identify the conceptual row which contains useful info
+ on the (attempted) interaction between the DS (referred
+ to by applIndex) and a peer DS."
+ ::= {dsIntEntry 1}
+
+ dsName OBJECT-TYPE
+ SYNTAX DistinguishedName
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Distinguished Name of the peer DS to which this
+ entry pertains."
+ ::= {dsIntEntry 2}
+
+ dsTimeOfCreation OBJECT-TYPE
+ SYNTAX TimeStamp
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " The value of sysUpTime when this row was created.
+ If the entry was created before the network management
+ subsystem was initialized, this object will contain
+ a value of zero."
+ ::= {dsIntEntry 3}
+
+ dsTimeOfLastAttempt OBJECT-TYPE
+ SYNTAX TimeStamp
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " The value of sysUpTime when the last attempt was made
+ to contact this DS. If the last attempt was made before
+ the network management subsystem was initialized, this
+ object will contain a value of zero."
+ ::= {dsIntEntry 4}
+
+ dsTimeOfLastSuccess OBJECT-TYPE
+ SYNTAX TimeStamp
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " The value of sysUpTime when the last attempt made to
+ contact this DS was successful. If there have
+ been no successful attempts this entry will have a value
+ of zero. If the last successful attempt was made before
+ the network management subsystem was initialized, this
+ object will contain a value of zero."
+ ::= {dsIntEntry 5}
+
+ dsFailuresSinceLastSuccess OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " The number of failures since the last time an
+ attempt to contact this DS was successful. If
+ there has been no successful attempts, this counter
+ will contain the number of failures since this entry
+ was created."
+ ::= {dsIntEntry 6}
+
+ dsFailures OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Cumulative failures since the creation of
+ this entry."
+ ::= {dsIntEntry 7}
+
+ dsSuccesses OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " Cumulative successes since the creation of
+ this entry."
+ ::= {dsIntEntry 8}
+
+ dsURL OBJECT-TYPE
+ SYNTAX URLString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " URL of the DS application."
+ ::= {dsIntEntry 9}
+
+--
+-- Information about this installation of the directory server
+--
+
+ dsEntityTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF DsEntityEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "This table holds general information related to an installed
+ instance of a directory server"
+ ::= {rhds 5}
+
+ dsEntityEntry OBJECT-TYPE
+ SYNTAX DsEntityEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Entry of general information about an installed instance
+ of a directory server"
+ INDEX { applIndex}
+ ::= {dsEntityTable 1}
+
+ DsEntityEntry ::= SEQUENCE {
+ dsEntityDescr
+ DisplayString,
+ dsEntityVers
+ DisplayString,
+ dsEntityOrg
+ DisplayString,
+ dsEntityLocation
+ DisplayString,
+ dsEntityContact
+ DisplayString,
+ dsEntityName
+ DisplayString
+ }
+
+ dsEntityDescr OBJECT-TYPE
+ SYNTAX DisplayString(SIZE (0..255))
+ ACCESS read-only
+ STATUS mandatory
+ DESCRIPTION
+ "A general textual description of this directory server."
+ ::= {dsEntityEntry 1}
+
+ dsEntityVers OBJECT-TYPE
+ SYNTAX DisplayString(SIZE (0..255))
+ ACCESS read-only
+ STATUS mandatory
+ DESCRIPTION
+ "The version of this directory server"
+ ::={dsEntityEntry 2}
+
+ dsEntityOrg OBJECT-TYPE
+ SYNTAX DisplayString(SIZE (0..255))
+ ACCESS read-only
+ STATUS mandatory
+ DESCRIPTION
+ "Organization responsible for directory server at this installation"
+ ::={dsEntityEntry 3}
+
+ dsEntityLocation OBJECT-TYPE
+ SYNTAX DisplayString(SIZE (0..255))
+ ACCESS read-only
+ STATUS mandatory
+ DESCRIPTION
+ "Physical location of this entity (directory server).
+ For example: hostname, building number, lab number, etc."
+ ::={dsEntityEntry 4}
+
+ dsEntityContact OBJECT-TYPE
+ SYNTAX DisplayString(SIZE (0..255))
+ ACCESS read-only
+ STATUS mandatory
+ DESCRIPTION
+ "Contact person(s)responsible for the directory server at this
+ installation, together with information on how to conact."
+ ::={dsEntityEntry 5}
+
+ dsEntityName OBJECT-TYPE
+ SYNTAX DisplayString(SIZE (0..255))
+ ACCESS read-only
+ STATUS mandatory
+ DESCRIPTION
+ "Name assigned to this entity at the installation site"
+ ::={dsEntityEntry 6}
+
+--
+-- Traps
+--
+--
+ DirectoryServerDown TRAP-TYPE
+ ENTERPRISE redhat
+ VARIABLES { dsEntityDescr, dsEntityVers, dsEntityLocation,
+ dsEntityContact }
+ DESCRIPTION "This trap is generated whenever the agent detects the
+ directory server to be (potentially) Down."
+ ::= 6001
+
+ DirectoryServerStart TRAP-TYPE
+ ENTERPRISE redhat
+ VARIABLES { dsEntityDescr, dsEntityVers, dsEntityLocation }
+ DESCRIPTION "This trap is generated whenever the agent detects the
+ directory server to have (re)started."
+ ::= 6002
+
+ END
+
| 0 |
f80928f47dbd35f9dfe8884769fa51fcebf64771
|
389ds/389-ds-base
|
Ticket 49795 - UI - add "action" backend funtionality
Description: Added the backend functionality for all the items in the "Action"
dropdown list on the banner.
Added ability to use the instance name in dsconf, previously
only ldap URLs worked.
Added more helper functions:
popup_confirm() - this now accepts html tags so nicer output
get_ldapurl_from_serverid(server_id) - take an instance name
and generate a LDAP URL from its dse.ldif
And of course did some code cleanup.
https://pagure.io/389-ds-base/issue/49795
Reviewed by: ?
|
commit f80928f47dbd35f9dfe8884769fa51fcebf64771
Author: Mark Reynolds <[email protected]>
Date: Fri Jun 29 16:08:01 2018 -0400
Ticket 49795 - UI - add "action" backend funtionality
Description: Added the backend functionality for all the items in the "Action"
dropdown list on the banner.
Added ability to use the instance name in dsconf, previously
only ldap URLs worked.
Added more helper functions:
popup_confirm() - this now accepts html tags so nicer output
get_ldapurl_from_serverid(server_id) - take an instance name
and generate a LDAP URL from its dse.ldif
And of course did some code cleanup.
https://pagure.io/389-ds-base/issue/49795
Reviewed by: ?
diff --git a/src/cockpit/389-console/banner.html b/src/cockpit/389-console/banner.html
index 14d866fb5..f919ed8c5 100644
--- a/src/cockpit/389-console/banner.html
+++ b/src/cockpit/389-console/banner.html
@@ -1,15 +1,16 @@
-389 Directory Server Management <div class="dropdown ds-server-action"> <select class="btn btn-default dropdown ds-dropdown-server" id="select-server">
+389 Directory Server Management <div class="dropdown ds-server-action"> <select class="btn btn-default dropdown ds-dropdown-server"
+ title="Directory Server Instance List" id="select-server">
</select></div><div class="dropdown ds-float-right"><button class="btn btn-primary dropdown-toggle ds-action-btn"
type="button" id="server-list-menu" data-toggle="dropdown">Actions<span class="caret"></span>
</button><ul class="dropdown-menu pull-right" role="menu">
<li role=""><a role="menuitem" id="start-server-btn" href="#">Start Instance</a></li>
<li role=""><a role="menuitem" id="stop-server-btn" href="#">Stop Instance</a></li>
<li role=""><a role="menuitem" id="restart-server-btn" href="#">Restart Instance</a></li>
- <li role=""><a role="menuitem" id="backup-server-btn" data-toggle="modal" data-target="#backup-form" href="#">Backup</a></li>
- <li role=""><a role="menuitem" id="restore-server-btn" data-toggle="modal" data-target="#restore-form" href="#">Restore</a></li>
- <li role=""><a role="menuitem" id="reload-schema-btn" href="#">Reload Schema Files</a></li>
- <li role=""><a role="menuitem" id="remove-server-btn" href="#">Remove Instance</a></li>
+ <li role=""><a role="menuitem" id="backup-server-btn" data-toggle="modal" data-target="#backup-form" href="#">Perform Backup</a></li>
+ <li role=""><a role="menuitem" id="restore-server-btn" data-toggle="modal" data-target="#restore-form" href="#">Manage Backups</a></li>
+ <li role=""><a role="menuitem" id="reload-schema-btn" data-toggle="modal" data-target="#schema-reload-form" href="#">Reload Schema Files</a></li>
<li class="divider"></li>
+ <li role=""><a role="menuitem" id="remove-server-btn" href="#">Remove Instance</a></li>
<li role=""><a role="menuitem" id="create-server-btn" data-toggle="modal" data-target="#create-inst-form" href="#">Create Instance</a></li>
</ul>
</div>
diff --git a/src/cockpit/389-console/css/ds.css b/src/cockpit/389-console/css/ds.css
index e5d1adf1c..bf77a6ba5 100644
--- a/src/cockpit/389-console/css/ds.css
+++ b/src/cockpit/389-console/css/ds.css
@@ -683,14 +683,13 @@ Zbutton:focus {
padding-bottom: 10px;
}
-
.ds-modal {
- width: 650px;
+ width: 450px;
}
.ds-modal-wide {
width: 850px;
- z-index: 10;
+ vertical-align: middle;
}
.modal-content {
diff --git a/src/cockpit/389-console/index.html b/src/cockpit/389-console/index.html
index 5f6910380..2c131225f 100644
--- a/src/cockpit/389-console/index.html
+++ b/src/cockpit/389-console/index.html
@@ -42,7 +42,7 @@
<nav class="navbar navbar-default" id="ds-navigation" role="navigation">
<div class="collapse navbar-collapse navbar-collapse-5 ds-nav">
<ul class="nav navbar-nav navbar-primary">
-
+
<!-- Server Config navtab -->
<li class="dropdown ds-nav-tab">
<a href="#0" class="dropdown-toggle ds-tab-list" data-toggle="dropdown" id="server-tab">
@@ -72,7 +72,7 @@
</li>
</ul>
</li>
-
+
<!-- Security navtab -->
<li class="dropdown ds-nav-tab">
<a href="#0" class="dropdown-toggle ds-tab-list" data-toggle="dropdown" id="security-tab">
@@ -185,9 +185,113 @@
</div>
</div>
+ <div class="modal fade" id="restart-instance-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="restart-inst-label" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content ds-modal">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
+ <span class="pficon pficon-close"></span>
+ </button>
+ <h4 class="modal-title" id="restart-inst-label">Restart Instance</h4>
+ </div>
+ <div class="modal-body">
+ <div id="reload-spinner" class="ds-center">
+ <p></p>
+ <p id="ds-restart-inst"><span class="spinner spinner-xs spinner-inline"></span> Restarting instance...</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="stop-instance-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="stop-inst-label" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content ds-modal">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
+ <span class="pficon pficon-close"></span>
+ </button>
+ <h4 class="modal-title" id="stop-inst-label">Stop Instance</h4>
+ </div>
+ <div class="modal-body">
+ <div id="reload-spinner" class="ds-center">
+ <p></p>
+ <p id="ds-stop-inst"><span class="spinner spinner-xs spinner-inline"></span> Stopping instance...</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="start-instance-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="start-inst-label" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content ds-modal">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
+ <span class="pficon pficon-close"></span>
+ </button>
+ <h4 class="modal-title" id="start-inst-label">Start Instance</h4>
+ </div>
+ <div class="modal-body">
+ <div id="reload-spinner" class="ds-center">
+ <p></p>
+ <p id="ds-start-inst"><span class="spinner spinner-xs spinner-inline"></span> Starting instance...</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="remove-instance-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="remove-inst-label" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content ds-modal">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
+ <span class="pficon pficon-close"></span>
+ </button>
+ <h4 class="modal-title" id="remove-inst-label">Remove Instance</h4>
+ </div>
+ <div class="modal-body">
+ <div id="reload-spinner" class="ds-center">
+ <p></p>
+ <p id="ds-remove-inst"><span class="spinner spinner-xs spinner-inline"></span> Removing instance...</p>
+ </div>
+ </div>>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="schema-reload-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="reload-label" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content ds-modal">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
+ <span class="pficon pficon-close"></span>
+ </button>
+ <h4 class="modal-title" id="reload-label">Reload Schema Files</h4>
+ </div>
+ <div class="modal-body">
+ <form class="form-horizontal">
+ <label for="reload-dir" class="ds-config-label" title="The name of the database link.">Schema File Directory</label><input
+ class="ds-input" type="text" placeholder="Leave empty to use default schema location" id="reload-dir">
+ </form>
+ <div id="reload-spinner" class="ds-center" hidden>
+ <p></p>
+ <p><span class="spinner spinner-xs spinner-inline"></span> Reloading schema files...</p>
+ </div>
+ </div>
+ <div class="modal-footer ds-modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
+ <button type="button" class="btn btn-primary" id ="schema-reload-btn">Reload Schema</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Restore from backup -->
<div class="modal fade" id="restore-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="restore-label" aria-hidden="true">
- <div class="modal-dialog ds-modal-wide">
- <div class="modal-content">
+ <div class="modal-dialog">
+ <div class="modal-content ds-modal-wide">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
<span class="pficon pficon-close"></span>
@@ -201,21 +305,22 @@
<tr class="ds-table-header">
<th>Backup Name</th>
<th>Date</th>
- <th></th>
+ <th>Size</th>
+ <th>Restore</th>
+ <th>Delete</th>
</tr>
</thead>
<tbody id="restore-tbody">
- <tr>
- <td>my_backup</td>
- <td>11/22/2018</td>
- <td><button class="btn btn-default restore-btn" type="button">Restore</button></td>
- </tr>
</tbody>
</table>
</form>
+ <div id="restore-spinner" class="ds-center" hidden>
+ <p></p>
+ <p><span class="spinner spinner-xs spinner-inline"></span> Restoring the server...</p>
+ </div>
</div>
<div class="modal-footer ds-modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
+ <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
@@ -279,10 +384,13 @@
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="chaining-save">Create Link</button>
</div>
- </div>
+ </div>
</div>
</div>
+ <!--
+ Create New Instance
+ -->
<div class="modal fade" id="create-inst-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="create-inst-header" aria-hidden="true">
<div class="modal-dialog ds-modal">
<div class="modal-content animate">
@@ -330,7 +438,7 @@
</div>
<div>
<p></p>
- <input type="checkbox" class="ds-config-checkbox" id="create-inst-tls"><label
+ <input type="checkbox" class="ds-config-checkbox" id="create-inst-tls" checked><label
for="create-inst-tls" class="ds-label" title="Create a self-signed certificate database">Create Self Signed Certificate DB</label>
</div>
<div id="create-inst-spinner" class="ds-center" hidden>
@@ -349,10 +457,12 @@
</div>
-
+ <!--
+ Do Backup
+ -->
<div class="modal fade" id="backup-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="backup-label" aria-hidden="true">
- <div class="modal-dialog ds-modal-wide">
- <div class="modal-content">
+ <div class="modal-dialog">
+ <div class="modal-content ds-modal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
<span class="pficon pficon-close"></span>
@@ -366,19 +476,20 @@
Backup Name</label><input class="ds-input ds-left-margin" type="text" id="backup-name"/>
</div>
</form>
+ <div id="backup-spinner" class="ds-center" hidden>
+ <p></p>
+ <p><span class="spinner spinner-xs spinner-inline"></span> Backing up the server...</p>
+ </div>
</div>
<div class="modal-footer ds-modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
- <button type="button" class="btn btn-primary" id="ds-backup-btn" data-dismiss="modal">Do Backup</button>
+ <button type="button" class="btn btn-primary" id="ds-backup-btn">Do Backup</button>
</div>
</div>
</div>
</div>
-
-
-
<!-- The Nav Tabs -->
<div class="ds-content">
@@ -391,6 +502,9 @@
<button type="button" class="btn btn-primary" id="no-inst-create-btn" data-toggle="modal" data-target="#create-inst-form">Create New Instance</button>
</p>
</div>
+ <div id="not-running" class="all-pages ds-center" hidden>
+ <h3>This server instance is not running, either start it from the <b>Actions</b> dropdown menu, or choose a different instance</h3>
+ </div>
<div id="server-content" class="all-pages" hidden>
</div>
diff --git a/src/cockpit/389-console/js/backend.js b/src/cockpit/389-console/js/backend.js
index 54f6ddf22..03609e7f8 100644
--- a/src/cockpit/389-console/js/backend.js
+++ b/src/cockpit/389-console/js/backend.js
@@ -21,7 +21,7 @@ function customMenu (node) {
"label": "Delete DB Link",
"icon": "glyphicon glyphicon-trash",
"action": function (data) {
- bootpopup.confirm("Are you sure you want to delete this Database Link?", "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete this Database Link?", "Confirmation", function (yes) {
if (yes) {
// TODO Delete db link
@@ -52,7 +52,7 @@ function customMenu (node) {
"label": "Reindex Suffix",
"icon": "glyphicon glyphicon-wrench",
"action": function (data) {
- bootpopup.confirm("This will impact DB performance during the indexing. Are you sure you want to reindex all attributes?", "Confirmation", function (yes) {
+ popup_confirm("This will impact DB performance during the indexing. Are you sure you want to reindex all attributes?", "Confirmation", function (yes) {
if (yes) {
// TODO Reindex suffix
}
@@ -84,7 +84,7 @@ function customMenu (node) {
"label": "Delete Suffix",
"icon": "glyphicon glyphicon-remove",
"action": function (data) {
- bootpopup.confirm("Are you sure you want to delete suffix?", "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete suffix?", "Confirmation", function (yes) {
if (yes) {
// TODO
}
@@ -489,7 +489,7 @@ $(document).ready( function() {
var data = ref_table.row( $(this).parents('tr') ).data();
var del_ref_name = data[0];
var ref_row = $(this); // Store element for callback
- bootpopup.confirm("Are you sure you want to delete referral: " + del_ref_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete referral: <b>" + del_ref_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete mapping from DS
@@ -800,7 +800,7 @@ $(document).ready( function() {
var data = ref_table.row( $(this).parents('tr') ).data();
var del_ref_name = data[0];
var ref_row = $(this);
- bootpopup.confirm("Are you sure you want to delete referral: " + del_ref_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete referral: " + del_ref_name, "Confirmation", function (yes) {
if (yes) {
// TODO Delete ref
ref_table.row( ref_row.parents('tr') ).remove().draw( false );
@@ -821,7 +821,7 @@ $(document).ready( function() {
e.preventDefault();
var data = index_table.row( $(this).parents('tr') ).data();
var reindex_name = data[0];
- bootpopup.confirm("Are you sure you want to reindex attribute: " + reindex_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to reindex attribute: <b>" + reindex_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO reindex attr
@@ -835,7 +835,7 @@ $(document).ready( function() {
var del_index_name = data[0];
var index_row = $(this);
- bootpopup.confirm("Are you sure you want to delete index: " + del_index_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete index: <b>" + del_index_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete index
index_table.row( index_row.parents('tr') ).remove().draw( false );
@@ -849,7 +849,7 @@ $(document).ready( function() {
var data = attr_encrypt_table.row( $(this).parents('tr') ).data();
var attr_name = data[0];
var eattr_row = $(this);
- bootpopup.confirm("Are you sure you want to delete encrypted attribute: " + attr_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete encrypted attribute: <b>" + attr_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete ref
attr_encrypt_table.row( eattr_row.parents('tr') ).remove().draw( false );
@@ -860,39 +860,3 @@ $(document).ready( function() {
});
});
-
-
-/*
-
-
-Advanced:
-=====================
-nsslapd-mode: 600
-nsslapd-directory: /var/lib/dirsrv/slapd-localhost/db
-nsslapd-db-logdirectory: /var/lib/dirsrv/slapd-localhost/db
-nsslapd-db-home-directory
-nsslapd-db-compactdb-interval: 2592000
-nsslapd-db-locks: 10000
-nsslapd-db-checkpoint-interval: 60
-nsslapd-db-durable-transaction: on
-nsslapd-db-transaction-wait: off
-nsslapd-db-transaction-batch-val: 0
-nsslapd-db-transaction-batch-min-wait: 50
-nsslapd-db-transaction-batch-max-wait: 50
-nsslapd-db-logbuf-size: 0
-nsslapd-db-private-import-mem: on
-nsslapd-idl-switch: new
-nsslapd-search-bypass-filter-test: on
-nsslapd-search-use-vlv-index: on
-nsslapd-exclude-from-export:
-nsslapd-serial-lock: on
-nsslapd-subtree-rename-switch: on
-nsslapd-backend-opt-level: 1
-
-
-
-
-
-*/
-
-
diff --git a/src/cockpit/389-console/js/ds.js b/src/cockpit/389-console/js/ds.js
index 935d4da24..830f4ae49 100644
--- a/src/cockpit/389-console/js/ds.js
+++ b/src/cockpit/389-console/js/ds.js
@@ -1,15 +1,17 @@
var DS_HOME = "/etc/dirsrv/";
var server_id = "None";
+var server_inst = "";
var dn_regex = new RegExp( "^([A-Za-z]+=.*)" );
var config_values = {};
//TODO - need "config_values" for all the other pages: SASL, backend, suffix, etc.
-// Used for local development testing
var DSCONF = "dsconf";
var DSCTL = "dsctl";
var DSCREATE = "dscreate";
var ENV = "";
+
/*
+// Used for local development testing
var DSCONF = '/home/mareynol/source/ds389/389-ds-base/src/lib389/cli/dsconf';
var DSCTL = '/home/mareynol/source/ds389/389-ds-base/src/lib389/cli/dsctl';
var DSCREATE = '/home/mareynol/source/ds389/389-ds-base/src/lib389/cli/dscreate';
@@ -69,26 +71,6 @@ function set_ports() {
});
}
-/* Example - remove eventually
- *
- * To test a local version of dsconf/lib389 use something like:
- *
- * var cmd = ['/home/mareynol/source/ds389/389-ds-base/src/lib389/cli/dsconf',
- * '-j', 'ldapi://%2fvar%2frun%2fslapd-' + server_id + '.socket','config',
- * 'replace'];
- * cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": ["PYTHONPATH=/home/mareynol/source/ds389/389-ds-base/src/lib389"]}).done(function() {
- */
-function test_json_and_dsconf () {
- var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2fslapd-' + server_id + '.socket','backend', 'list']
- cockpit.spawn(cmd, { superuser: true, "err": "message"}).done(function(data) {
- console.log(data);
- var obj = JSON.parse(data);
- console.log("backend: " + obj['items']);
- }).fail(function(data) {
- console.log("failed: " + data.message);
- });
-}
-
function sort_list (sel) {
var opts_list = sel.find('option');
opts_list.sort(function(a, b) { return $(a).text() > $(b).text() ? 1 : -1; });
@@ -109,6 +91,7 @@ function set_no_insts () {
select.appendChild(el);
select.selectedIndex = "0";
server_id = "";
+ server_inst = "";
$("#server-list-menu").attr('disabled', true);
$("#ds-navigation").hide();
@@ -117,7 +100,7 @@ function set_no_insts () {
}
function check_for_389 () {
- var cmd = ["ls", "/etc/dirsrv"];
+ var cmd = ["rpm", "-q", "389-ds-base"];
cockpit.spawn(cmd, { superuser: true }).fail(function(data) {
$("#server-list-menu").attr('disabled', true);
@@ -127,6 +110,27 @@ function check_for_389 () {
});
}
+function check_inst_alive () {
+ // Check if this instance is started, if not hide configuration pages
+ cmd = ['status-dirsrv', server_inst];
+ console.log("MARK cmd: " + cmd);
+ cockpit.spawn(cmd, { superuser: true }).done(function () {
+ $(".all-pages").hide();
+ $("#ds-navigation").show();
+ $("#server-content").show();
+ $("#server-config").show();
+ //$("#no-instances").hide();
+ //$("#no-package").hide();
+ $("#not-running").hide();
+ console.log("Running");
+ }).fail(function(data) {
+ $("#ds-navigation").hide();
+ $(".all-pages").hide();
+ $("#not-running").show();
+ console.log("Not Running");
+ });
+}
+
function get_insts() {
var insts = [];
var cmd = ["/bin/sh", "-c", "/usr/bin/ls -d " + DS_HOME + "slapd-*"];
@@ -175,6 +179,7 @@ function get_insts() {
$("#server-content").show();
$("#server-config").show();
server_id = insts[0];
+ server_inst = insts[0].replace("slapd-", "");
get_and_set_config();
}
@@ -211,6 +216,23 @@ function popup_msg(title, msg) {
});
}
+function popup_confirm(msg, title, callback) {
+ if(typeof callback !== "function") {
+ callback = function() {};
+ }
+ var answer = false;
+ return bootpopup({
+ title: title,
+ content: [
+ msg
+ ],
+ showclose: false,
+ buttons: ["no", "yes"],
+ yes: function() { answer = true; },
+ dismiss: function() { callback(answer); }
+ });
+}
+
function popup_success(msg) {
$('#success-msg').html(msg);
$('#success-form').modal('show');
@@ -234,7 +256,6 @@ function save_all () {
function load_config (){
// TODO - set all the pages
get_and_set_config(); // cn=config stuff
-
}
$(window.document).ready(function() {
diff --git a/src/cockpit/389-console/js/replication.js b/src/cockpit/389-console/js/replication.js
index 74233d2a9..20596c930 100644
--- a/src/cockpit/389-console/js/replication.js
+++ b/src/cockpit/389-console/js/replication.js
@@ -220,7 +220,7 @@ $(document).ready( function() {
if (role == "no-repl") {
// This also means disable replication: delete agmts, everything
- bootpopup.confirm("Are you sure you want to disable replication and remove all agreements?", "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to disable replication and remove all agreements?", "Confirmation", function (yes) {
if (yes) {
// TODO Delete attr from DS
@@ -367,7 +367,7 @@ $(document).ready( function() {
e.preventDefault();
var row = $(this).parent().parent(); //tr
var repl_dn = row.children("td:nth-child(1)");
- bootpopup.confirm("Are you sure you want to delete replication manager: " + repl_dn.html(), "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete replication manager: <b>" + repl_dn.html() + "</b>", "Confirmation", function (yes) {
if (yes) {
row.remove();
}
@@ -383,7 +383,7 @@ $(document).ready( function() {
var data = repl_agmt_table.row( $(this).parents('tr') ).data();
var del_agmt_name = data[0];
var agmt_row = $(this);
- bootpopup.confirm("Are you sure you want to delete replication agreement: " + del_agmt_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete replication agreement: <b>" + del_agmt_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete agmt
repl_agmt_table.row( agmt_row.parents('tr') ).remove().draw( false );
@@ -711,7 +711,7 @@ $(document).ready( function() {
$("#delete-repl-manager").on("click", function () {
var repl_mgr_dn = $("#repl-managers-list").find('option:selected');
if (repl_mgr_dn.val() !== undefined) {
- bootpopup.confirm("Are you sure you want to delete replication manager: " + repl_mgr_dn.val(), "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete replication manager: <b>" + repl_mgr_dn.val() + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Update replica config entry, do not delete the real repl mgr entry
diff --git a/src/cockpit/389-console/js/schema.js b/src/cockpit/389-console/js/schema.js
index 75b7f04fc..87717ab1b 100644
--- a/src/cockpit/389-console/js/schema.js
+++ b/src/cockpit/389-console/js/schema.js
@@ -299,7 +299,7 @@ $(document).ready( function() {
var data = at_table.row( $(this).parents('tr') ).data();
var del_attr_name = data[0];
var at_row = $(this);
- bootpopup.confirm("Are you sure you want to delete attribute: " + del_attr_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete attribute: <b>" + del_attr_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete attr from DS
@@ -337,7 +337,7 @@ $(document).ready( function() {
var del_oc_name = data[0];
var oc_row = $(this);
- bootpopup.confirm("Are you sure you want to delete objectclass: " + del_oc_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete objectclass: <b>" + del_oc_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete attr from DS
@@ -345,7 +345,6 @@ $(document).ready( function() {
oc_table.row( oc_row.parents('tr') ).remove().draw( false );
}
});
-
});
});
});
diff --git a/src/cockpit/389-console/js/servers.js b/src/cockpit/389-console/js/servers.js
index a6242bd3a..e9e9c3eb5 100644
--- a/src/cockpit/389-console/js/servers.js
+++ b/src/cockpit/389-console/js/servers.js
@@ -22,7 +22,7 @@ var local_pwp_html =
'</ul>' +
'</div>';
-var create_full_template =
+var create_full_template =
"[general]\n" +
"config_version = 2\n" +
"defaults = 999999999\n" +
@@ -59,7 +59,7 @@ var create_full_template =
"sysconf_dir = /etc\n" +
"tmp_dir = /tmp\n";
-var create_inf_template =
+var create_inf_template =
"[general]\n" +
"config_version = 2\n" +
"full_machine_name = FQDN\n\n" +
@@ -154,7 +154,7 @@ function clear_inst_form() {
$("#create-inst-group").val("dirsrv");
$("#rootdn-pw").val("");
$("#rootdn-pw-confirm").val("");
- $("#create-inst-tls").prop('checked', false);
+ $("#create-inst-tls").prop('checked', true);
clear_inst_input();
}
@@ -179,8 +179,10 @@ function get_and_set_config () {
config_values[attr] = val;
}
}
+ check_inst_alive();
}).fail(function(data) {
console.log("failed: " + data.message);
+ check_inst_alive();
});
}
@@ -264,7 +266,7 @@ function save_config() {
$(document).ready( function() {
$("#main-banner").load("banner.html");
- // Fill in the server instance dropdown
+ // Fill in the server instance dropdown
get_insts();
check_for_389();
@@ -274,6 +276,7 @@ $(document).ready( function() {
// Handle changing instance here
$('#select-server').on("change", function() {
server_id = $(this).val();
+ server_inst = server_id.replace("slapd-", "");
load_config();
});
@@ -283,8 +286,8 @@ $(document).ready( function() {
$("#server-config").show();
// To remove text border on firefox on dropdowns)
- if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
- $("select").focus( function() {
+ if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+ $("select").focus( function() {
this.style.setProperty( 'outline', 'none', 'important' );
this.style.setProperty( 'color', 'rgba(0,0,0,0)', 'important' );
this.style.setProperty( 'text-shadow', '0 0 0 #000', 'important' );
@@ -425,7 +428,7 @@ $(document).ready( function() {
var data = sasl_table.row( $(this).parents('tr') ).data();
var del_sasl_name = data[0];
var sasl_row = $(this); // Store element for callback
- bootpopup.confirm("Are you sure you want to delete sasl mapping: " + del_sasl_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete sasl mapping: <b>" + del_sasl_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete mapping from DS
@@ -615,7 +618,7 @@ $(document).ready( function() {
});
$("#nsslapd-ldapiautobind").change(function() {
- if (this.checked){
+ if (this.checked){
$(".autobind-attrs").show();
if ( $("#nsslapd-ldapimaptoentries").is(":checked") ){
$(".autobind-entry-attrs").show();
@@ -648,9 +651,16 @@ $(document).ready( function() {
"search": "Search Backups"
},
"columnDefs": [ {
- "targets": 2,
+ "targets": [3, 4],
"orderable": false
- } ]
+ } ],
+ "columns": [
+ { "width": "120px" },
+ { "width": "80px" },
+ { "width": "30px" },
+ { "width": "40px" },
+ { "width": "30px" }
+ ],
});
// Set up local passwd policy table
@@ -674,26 +684,26 @@ $(document).ready( function() {
// Get the values
var pwp_track = "off";
if ( $("#passwordtrackupdatetime").is(":checked") ) {
- pwp_track = "on";
+ pwp_track = "on";
}
var pwp_admin = $("#passwordadmindn").val();
var pwp_passwordchange = "off";
if ($("#passwordchange").is(":checked") ){
- pwp_passwordchange = "on";
+ pwp_passwordchange = "on";
}
var pwp_passwordmustchange = "off";
if ($("#passwordmustchange").is(":checked") ){
- pwp_passwordmustchange = "on";
+ pwp_passwordmustchange = "on";
}
var pwp_history = "off";
if ($("#passwordhistory").is(":checked") ){
- pwp_history = "on";
+ pwp_history = "on";
}
var pwp_inhistory = $("#passwordinhistory").val();
var pwp_minage = $("#passwordminage").val();
var pwp_exp = "off";
if ($("#passwordexp").is(":checked") ){
- pwp_exp = "on";
+ pwp_exp = "on";
}
var pwp_maxage = $("#passwordmaxage").val();
var pwp_gracelimit = $("#passwordgracelimit").val();
@@ -701,22 +711,22 @@ $(document).ready( function() {
var pwp_sendexp = "off";
if ($("#passwordsendexpiringtime").is(":checked") ){
- pwp_sendexp = "on";
+ pwp_sendexp = "on";
}
var pwp_lockout = "off";
if ($("#passwordlockout").is(":checked") ){
- pwp_lockout = "on";
+ pwp_lockout = "on";
}
var pwp_maxfailure = $("#passwordmaxfailure").val();
var pwp_failcount = $("#passwordresetfailurecount").val();
var pwp_unlock = "off";
if ($("#passwordunlock").is(":checked") ){
- pwp_unlock = "on";
+ pwp_unlock = "on";
}
var pwp_lockoutdur = $("#passwordlockoutduration").val();
var pwp_checksyntax = "off";
if ($("#passwordchecksyntax").is(":checked") ){
- pwp_checksyntax = "on";
+ pwp_checksyntax = "on";
}
var pwp_minlen = $("#passwordminlength").val();
var pwp_mindigit = $("#passwordmindigits").val();
@@ -731,7 +741,7 @@ $(document).ready( function() {
// TODO - save to DS
- }
+ }
/*
* Modal Forms
*/
@@ -745,26 +755,26 @@ $(document).ready( function() {
var policy_name = $("#local-entry-dn").val();
var pwp_track = "off";
if ( $("#local-passwordtrackupdatetime").is(":checked") ) {
- pwp_track = "on";
+ pwp_track = "on";
}
var pwp_admin = $("#local-passwordadmindn").val();
var pwp_passwordchange = "off";
if ($("#local-passwordchange").is(":checked") ){
- pwp_passwordchange = "on";
+ pwp_passwordchange = "on";
}
var pwp_passwordmustchange = "off";
if ($("#local-passwordmustchange").is(":checked") ){
- pwp_passwordmustchange = "on";
+ pwp_passwordmustchange = "on";
}
var pwp_history = "off";
if ($("#local-passwordhistory").is(":checked") ){
- pwp_history = "on";
+ pwp_history = "on";
}
var pwp_inhistory = $("#local-passwordinhistory").val();
var pwp_minage = $("#local-passwordminage").val();
var pwp_exp = "off";
if ($("#local-passwordexp").is(":checked") ){
- pwp_exp = "on";
+ pwp_exp = "on";
}
var pwp_maxage = $("#local-passwordmaxage").val();
var pwp_gracelimit = $("#local-passwordgracelimit").val();
@@ -772,22 +782,22 @@ $(document).ready( function() {
var pwp_sendexp = "off";
if ($("#local-passwordsendexpiringtime").is(":checked") ){
- pwp_sendexp = "on";
+ pwp_sendexp = "on";
}
var pwp_lockout = "off";
if ($("#local-passwordlockout").is(":checked") ){
- pwp_lockout = "on";
+ pwp_lockout = "on";
}
var pwp_maxfailure = $("#local-passwordmaxfailure").val();
var pwp_failcount = $("#local-passwordresetfailurecount").val();
var pwp_unlock = "off";
if ($("#local-passwordunlock").is(":checked") ){
- pwp_unlock = "on";
+ pwp_unlock = "on";
}
var pwp_lockoutdur = $("#local-passwordlockoutduration").val();
var pwp_checksyntax = "off";
if ($("#local-passwordchecksyntax").is(":checked") ){
- pwp_checksyntax = "on";
+ pwp_checksyntax = "on";
}
var pwp_minlen = $("#local-passwordminlength").val();
var pwp_mindigit = $("#local-passwordmindigits").val();
@@ -803,7 +813,7 @@ $(document).ready( function() {
var pwp_type = "User Password Policy";
if ( $("#subtree-pwp-radio").is(":checked")) {
- pwp_type = "Subtree Password Policy";
+ pwp_type = "Subtree Password Policy";
}
// TODO - add to DS
@@ -819,7 +829,7 @@ $(document).ready( function() {
$("#local-pwp-form").modal('toggle');
clear_local_pwp_form();
});
-
+
// Delete local password policy
$(document).on('click', '.delete-local-pwp', function(e) {
e.preventDefault();
@@ -828,7 +838,7 @@ $(document).ready( function() {
var data = pwp_table.row( $(this).parents('tr') ).data();
var del_pwp_name = data[0];
var pwp_row = $(this);
- bootpopup.confirm("Are you sure you want to delete local password policy: " + del_pwp_name, "Confirmation", function (yes) {
+ popup_confirm("Are you sure you want to delete local password policy: <b>" + del_pwp_name + "</b>", "Confirmation", function (yes) {
if (yes) {
// TODO Delete pwp from DS
@@ -837,7 +847,7 @@ $(document).ready( function() {
}
});
});
-
+
// SASL Mappings Form
$("#sasl-map-save").on("click", function() {
var sasl_name = $("#sasl-map-name").val();
@@ -863,8 +873,188 @@ $(document).ready( function() {
$("#sasl-map-form").modal('toggle');
});
+ /*
+ * Stop, Start, and Restart server
+ */
+ $("#start-server-btn").on("click", function () {
+ $("#ds-start-inst").html("<span class=\"spinner spinner-xs spinner-inline\"></span> Starting instance <b>" + server_id + "</b>...");
+ $("#start-instance-form").modal('toggle');
+ var cmd = [DSCTL, server_inst, 'start'];
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ $("#start-instance-form").modal('toggle');
+ load_config();
+ popup_success("Started instance \"" + server_id + "\"");
+ }).fail(function(data) {
+ $("#start-instance-form").modal('toggle');
+ popup_err("Error", "Failed to start instance \"" + server_id + "\"\n" + data.message);
+ });
+ });
+
+ $("#stop-server-btn").on("click", function () {
+ $("#ds-stop-inst").html("<span class=\"spinner spinner-xs spinner-inline\"></span> Stopping instance <b>" + server_id + "</b>...");
+ $("#stop-instance-form").modal('toggle');
+ var cmd = [DSCTL, server_inst, 'stop'];
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ $("#stop-instance-form").modal('toggle');
+ popup_success("Stopped instance \"" + server_id + "\"");
+ check_inst_alive();
+ }).fail(function(data) {
+ $("#stop-instance-form").modal('toggle');
+ popup_err("Error", "Failed to stop instance \"" + server_id + "\"\n" + data.message);
+ check_inst_alive();
+ });
+ });
+
+ $("#restart-server-btn").on("click", function () {
+ $("#ds-restart-inst").html("<span class=\"spinner spinner-xs spinner-inline\"></span> Retarting instance <b>" + server_id + "</b>...");
+ $("#restart-instance-form").modal('toggle');
+ var cmd = [DSCTL, server_inst, 'restart'];
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ $("#restart-instance-form").modal('toggle');
+ load_config();
+ popup_success("Restarted instance \"" + server_id + "\"");
+ }).fail(function(data) {
+ $("#restart-instance-form").modal('toggle');
+ popup_err("Error", "Failed to restart instance \"" + server_id + "\"\n" + data.message);
+ });
+ });
+
+ /* Backup server */
+ $("#ds-backup-btn").on('click', function () {
+ var backup_name = $("#backup-name").val();
+ if (backup_name == ""){
+ popup_msg("Error", "Backup must have a name");
+ return;
+ }
+ if (backup_name.indexOf(' ') >= 0) {
+ popup_msg("Error", "Backup name can not contain any spaces");
+ return;
+ }
+ if (backup_name.startsWith('/')) {
+ popup_msg("Error", "Backup name can not start with a forward slash. Backups are written to the server's backup directory (nsslapd-bakdir)");
+ return;
+ }
+ var cmd = [DSCTL, server_inst, 'db2bak', backup_name];
+ $("#backup-spinner").show();
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ $("#backup-spinner").hide();
+ popup_success("Backup has been created");
+ $("#backup-form").modal('toggle');
+ }).fail(function(data) {
+ $("#backup-spinner").hide();
+ popup_err("Error", "Failed to backup the server\n" + data.message);
+ });
+ });
+
+ $("#backup-server-btn").on('click', function () {
+ $("#backup-name").val("");
+ });
+
+ /* Restore. load restore table with current backups */
+ $("#restore-server-btn").on('click', function () {
+ var cmd = [DSCTL, server_id, '-j', 'backups'];
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ var backup_btn = "<button class=\"btn btn-default restore-btn\" type=\"button\">Restore</button>";
+ var del_btn = "<button title=\"Delete backup directory\" class=\"btn btn-default ds-del-backup-btn\" type=\"button\"><span class='glyphicon glyphicon-trash'></span></button>";
+ var obj = JSON.parse(data);
+ backup_table.clear().draw( false );
+ for (var i = 0; i < obj.items.length; i++) {
+ var backup_name = obj.items[i][0];
+ var backup_date = obj.items[i][1];
+ var backup_size = obj.items[i][2];
+ backup_table.row.add([backup_name, backup_date, backup_size, backup_btn, del_btn]).draw( false );
+ }
+ }).fail(function(data) {
+ popup_err("Error", "Failed to get list of backups\n" + data.message);
+ });
+ });
+
+ /* Restore server */
+ $(document).on('click', '.restore-btn', function(e) {
+ e.preventDefault();
+ var data = backup_table.row( $(this).parents('tr') ).data();
+ var restore_name = data[0];
+ popup_confirm("Are you sure you want to restore this backup: <b>" + restore_name + "<b>", "Confirmation", function (yes) {
+ if (yes) {
+ var cmd = [DSCTL, server_inst, 'bak2db', restore_name];
+ $("#restore-spinner").show();
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ popup_success("The backup has been restored");
+ $("#restore-spinner").hide();
+ $("#restore-form").modal('toggle');
+ }).fail(function(data) {
+ $("#restore-spinner").hide();
+ popup_err("Error", "Failed to restore from the backup\n" + data.message);
+ });
+ }
+ });
+ });
+
+ /* Delete backup directory */
+ $(document).on('click', '.ds-del-backup-btn', function(e) {
+ e.preventDefault();
+ var data = backup_table.row( $(this).parents('tr') ).data();
+ var restore_name = data[0];
+ var backup_row = $(this);
+ popup_confirm("Are you sure you want to delete this backup: <b>" + restore_name + "</b>", "Confirmation", function (yes) {
+ if (yes) {
+ var cmd = [DSCTL, server_inst, 'backups', '--delete', restore_name];
+ $("#restore-spinner").show();
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ $("#restore-spinner").hide();
+ backup_table.row( backup_row.parents('tr') ).remove().draw( false );
+ popup_success("The backup has been deleted");
+ }).fail(function(data) {
+ $("#restore-spinner").hide();
+ popup_err("Error", "Failed to delete the backup\n" + data.message);
+ });
+ }
+ });
+ });
+
+ /* reload schema */
+ $("#schema-reload-btn").on("click", function () {
+ var schema_dir = $("#reload-dir").val();
+ if (schema_dir != ""){
+ var cmd = [DSCONF, server_id, 'schema', 'reload', '--schemadir', schema_dir, '--wait'];
+ } else {
+ var cmd = [DSCONF, server_id, 'schema', 'reload', '--wait'];
+ }
+ $("#reload-spinner").show();
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ popup_msg("Success", "Successfully reloaded schema"); // TODO use timed interval success msg (waiting for another PR top be merged before we can add it)
+ $("#schema-reload-form").modal('toggle');
+ $("#reload-spinner").hide();
+ }).fail(function(data) {
+ popup_err("Error", "Failed to reload schema files\n" + data.message);
+ $("#reload-spinner").hide();
+ });
+ });
+
+
+ // Remove instance
+ $("#remove-server-btn").on("click", function () {
+ popup_confirm("Are you sure you want to this remove instance: <b>" + server_id + "</b>", "Confirmation", function (yes) {
+ if (yes) {
+ var cmd = [DSCTL, server_id, "remove", "--doit"];
+ $("#ds-remove-inst").html("<span class=\"spinner spinner-xs spinner-inline\"></span> Removing instance <b>" + server_id + "</b>...");
+ $("#remove-instance-form").modal('toggle');
+ cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) {
+ $("#remove-instance-form").modal('toggle');
+ popup_msg("Success", "Instance has been deleted");
+ get_insts();
+ check_for_389();
+ load_config();
+ }).fail(function(data) {
+ $("#remove-instance-form").modal('toggle');
+ popup_err("Error", "Failed to remove instance\n" + data.message);
+ });
+ }
+ });
+ });
+
// Create instance form
- $("#create-server-btn").on("click", function() {;
+ $("#create-server-btn").on("click", function() {
clear_inst_form();
set_ports();
});
@@ -979,7 +1169,7 @@ $(document).ready( function() {
// Failed to get FQDN
popup_err("Failed to get hostname!", ex.message);
}).done(function (data){
- /*
+ /*
* We have FQDN, so set the hostname in inf file, and create the setup file
*/
setup_inf = setup_inf.replace('FQDN', data);
@@ -1001,7 +1191,7 @@ $(document).ready( function() {
popup_err("Failed to set permission on setup file " + setup_file + ": ", ex.message);
}).done(function (){
/*
- * Success we have our setup file and it has the correct permissions.
+ * Success we have our setup file and it has the correct permissions.
* Now populate the setup file...
*/
var cmd = ["/bin/sh", "-c", '/usr/bin/echo -e "' + setup_inf + '" >> ' + setup_file];
@@ -1009,7 +1199,7 @@ $(document).ready( function() {
// Failed to populate setup file
popup_err("Failed to populate installation file!", ex.message);
}).done(function (){
- /*
+ /*
* Next, create the instance...
*/
cmd = [DSCREATE, 'install', setup_file];
@@ -1022,41 +1212,19 @@ $(document).ready( function() {
// Success!!! Now cleanup everything up...
cockpit.spawn(rm_cmd, { superuser: true }); // Remove Inf file with clear text password
$("#create-inst-spinner").hide();
- $("#server-list-menu").attr('disabled', false);
+ $("#server-list-menu").attr('disabled', false);
$("#no-instances").hide();
get_insts(); // Refresh server list
popup_msg("Success!", "Successfully created instance: <b>slapd-" + new_server_id + "</b>", );
$("#create-inst-form").modal('toggle');
});
- });
+ });
$("#create-inst-spinner").show();
});
});
});
});
- $("#backup-save").on("click", function() {
- // TODO - Do backup
-
- $("#backup-form").modal('toggle');
- });
-
- $(document).on('click', '.restore-btn', function(e) {
- e.preventDefault();
- // Backend name is inside input of table cell
- //var backup_name = $(this).parents('tr').find('input').val();
- var data = backup_table.row( $(this).parents('tr') ).data();
- var backup_name = data[0];
-
- bootpopup.confirm("Are you sure you want to restore: " + backup_name, "Confirmation", function (yes) {
- // TODO Do the restore
- if (yes) {
- // TODO - the restore operation
- $("#restore-form").modal('toggle');
- }
- });
- });
-
// Accordion opening/closings
$(".ds-accordion-panel").css('display','none');
diff --git a/src/cockpit/389-console/replication.html b/src/cockpit/389-console/replication.html
index 9294d48fb..955405be7 100644
--- a/src/cockpit/389-console/replication.html
+++ b/src/cockpit/389-console/replication.html
@@ -284,7 +284,7 @@ CleanAllRUV Tasks
<div class="modal fade" id="agmt-form" data-backdrop="static" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="agmt-wizard-title" aria-hidden="true">
- <div class="modal-dialog ds-modal">
+ <div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
@@ -351,7 +351,7 @@ CleanAllRUV Tasks
<p></p>
<button class="accordion ds-accordion" id="frac-accordion" type="button">► Show Fractional Settings</button>
<div class="ds-accordion-panel">
- <h4>Excluded Attributes</h4>
+ <p><b>Excluded Attributes</b></p>
<div class="ds-container">
<div>
<form>
@@ -370,7 +370,8 @@ CleanAllRUV Tasks
</div>
</div>
- <h4>Excluded Attributes From Total Initializations</h4>
+ <hr>
+ <p><b>Excluded Attributes From Total Initializations</b></p>
<div class="ds-container">
<div>
<form>
@@ -389,7 +390,8 @@ CleanAllRUV Tasks
</div>
</div>
- <h4>Strip Attributes</h4>
+ <hr>
+ <p><b>Strip Attributes</b></p>
<div class="ds-container">
<div>
<form>
@@ -418,7 +420,8 @@ CleanAllRUV Tasks
<div id="agmt-schedule-panel">
<div class="ds-container" id="schedule-settings" hidden>
<div class="ds-fractional-panel">
- <h4>Days to keep replication in sync</h4>
+ <hr>
+ <b>Days to keep replication in sync</b>
<div class="ds-container">
<div class="ds-inline">
<div>
@@ -456,14 +459,16 @@ CleanAllRUV Tasks
</div>
</div>
<div class="ds-fractional-panel">
- <h4>Replication Time Range</h4>
- <div class="ds-inline ds-left-margin">
- <div>
- <label for="agmt-start-time" class="ds-config-label-med">Start Time</label><input class="timepicker ds-agmt-schedule-timeZ" name="start" id="agmt-start-time" size="4"/>
- </div>
- <div>
- <div>
- <label for="agmt-start-time" class="ds-config-label-med">End Time</label><input class="timepicker ds-agmt-schedule-timeZ" name="start" id="agmt-end-time" size="4"/>
+ <hr>
+ <b>Replication Time Range</b>
+ <div class="ds-container">
+ <div class="ds-inline ds-left-margin">
+ <div>
+ <label for="agmt-start-time" class="ds-config-label-med">Start Time</label><input class="timepicker" name="start" id="agmt-start-time" size="4"/>
+ </div>
+ <div>
+ <label for="agmt-start-time" class="ds-config-label-med">End Time</label><input class="timepicker" name="start" id="agmt-end-time" size="4"/>
+ </div>
</div>
</div>
</div>
@@ -471,7 +476,6 @@ CleanAllRUV Tasks
</div>
</div>
</div>
- </div>
<div class="modal-footer ds-modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="agmt-save">Create Agreement</button>
diff --git a/src/cockpit/389-console/rhds-banner.html b/src/cockpit/389-console/rhds-banner.html
index 5496081ed..fef882615 100644
--- a/src/cockpit/389-console/rhds-banner.html
+++ b/src/cockpit/389-console/rhds-banner.html
@@ -1,15 +1,16 @@
-Red Hat Directory Server Management <div class="dropdown ds-server-action"> <select class="btn btn-default dropdown ds-dropdown-server" id="select-server">
+Red Hat Directory Server Management <div class="dropdown ds-server-action"> <select class="btn btn-default dropdown ds-dropdown-server"
+ title="Directory Server Instance List" id="select-server">
</select></div><div class="dropdown ds-float-right"><button class="btn btn-primary dropdown-toggle ds-action-btn"
type="button" id="server-list-menu" data-toggle="dropdown">Actions<span class="caret"></span>
</button><ul class="dropdown-menu pull-right" role="menu">
<li role=""><a role="menuitem" id="start-server-btn" href="#">Start Instance</a></li>
<li role=""><a role="menuitem" id="stop-server-btn" href="#">Stop Instance</a></li>
<li role=""><a role="menuitem" id="restart-server-btn" href="#">Restart Instance</a></li>
- <li role=""><a role="menuitem" id="backup-server-btn" data-toggle="modal" data-target="#backup-form" href="#">Backup</a></li>
- <li role=""><a role="menuitem" id="restore-server-btn" data-toggle="modal" data-target="#restore-form" href="#">Restore</a></li>
- <li role=""><a role="menuitem" id="reload-schema-btn" href="#">Reload Schema Files</a></li>
- <li role=""><a role="menuitem" id="remove-server-btn" href="#">Remove Instance</a></li>
+ <li role=""><a role="menuitem" id="backup-server-btn" data-toggle="modal" data-target="#backup-form" href="#">Perform Backup</a></li>
+ <li role=""><a role="menuitem" id="restore-server-btn" data-toggle="modal" data-target="#restore-form" href="#">Manage Backups</a></li>
+ <li role=""><a role="menuitem" id="reload-schema-btn" data-toggle="modal" data-target="#schema-reload-form" href="#">Reload Schema Files</a></li>
<li class="divider"></li>
+ <li role=""><a role="menuitem" id="remove-server-btn" href="#">Remove Instance</a></li>
<li role=""><a role="menuitem" id="create-server-btn" data-toggle="modal" data-target="#create-inst-form" href="#">Create Instance</a></li>
</ul>
</div>
\ No newline at end of file
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 590d930ea..2153bc60d 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -53,6 +53,7 @@ import errno
import pwd
import grp
import uuid
+import json
from shutil import copy2
try:
# There are too many issues with this on EL7
@@ -764,6 +765,8 @@ class DirSrv(SimpleLDAPObject, object):
# Don't need a default value now since it's set in init.
if serverid is None and hasattr(self, 'serverid'):
serverid = self.serverid
+ else:
+ serverid = serverid.replace('slapd-', '')
# first identify the directories we will scan
sysconfig_head = self.ds_paths.initconfig_dir
@@ -1055,6 +1058,7 @@ class DirSrv(SimpleLDAPObject, object):
if not uri:
uri = self.toLDAPURL()
+
self.log.debug('open(): Connecting to uri %s' % uri)
if hasattr(ldap, 'PYLDAP_VERSION') and MAJOR >= 3:
super(DirSrv, self).__init__(uri, bytes_mode=False, trace_level=TRACE_LEVEL)
@@ -2996,6 +3000,35 @@ class DirSrv(SimpleLDAPObject, object):
return True
+ def backups(self, use_json):
+ # Return a list of backups from the bakdir
+ bakdir = self.get_bak_dir()
+ dirlist = [item for item in os.listdir(bakdir) if os.path.isdir(os.path.join(bakdir, item))]
+ if use_json:
+ json_result = {'type': 'list', 'items': []}
+ for backup in dirlist:
+ bak = bakdir + "/" + backup
+ bak_date = os.path.getctime(bak)
+ bak_date = datetime.fromtimestamp(bak_date).strftime('%Y-%m-%d %H:%M:%S')
+ bak_size = subprocess.check_output(['du', '-sh', bak]).split()[0].decode('utf-8')
+ if use_json:
+ json_item = [backup, bak_date, bak_size]
+ json_result['items'].append(json_item)
+ else:
+ self.log.info('Backup: {} - {} ({})'.format(bak, bak_date, bak_size))
+
+ if use_json:
+ print(json.dumps(json_result))
+
+ return True
+
+ def del_backup(self, bak_dir):
+ # Delete backup directory
+ bakdir = self.get_bak_dir()
+ del_dir = bakdir + "/" + bak_dir
+ self.log.debug("Deleting backup directory: " + del_dir)
+ shutil.rmtree(del_dir)
+
def dbscan(self, bename=None, index=None, key=None, width=None, isRaw=False):
"""Wrapper around dbscan tool that analyzes and extracts information
from an import Directory Server database file
diff --git a/src/lib389/lib389/cli_base/__init__.py b/src/lib389/lib389/cli_base/__init__.py
index 537b9f719..d2222d3ae 100644
--- a/src/lib389/lib389/cli_base/__init__.py
+++ b/src/lib389/lib389/cli_base/__init__.py
@@ -13,7 +13,7 @@ import ldap
from getpass import getpass
from lib389 import DirSrv
-from lib389.utils import assert_c
+from lib389.utils import assert_c, get_ldapurl_from_serverid
from lib389.properties import *
MAJOR, MINOR, _, _, _ = sys.version_info
@@ -86,13 +86,26 @@ def _warn(data, msg=None):
return data
-# We'll need another of these that does a "connect via instance name?"
def connect_instance(dsrc_inst, verbose):
dsargs = dsrc_inst['args']
+ if '//' not in dsargs['ldapurl']:
+ # We have an instance name - generate url from dse.ldif
+ ldapurl, certdir = get_ldapurl_from_serverid(dsargs['ldapurl'])
+ if ldapurl is not None:
+ dsargs['ldapurl'] = ldapurl
+ if 'ldapi://' in ldapurl:
+ dsargs['ldapi_enabled'] = 'on'
+ dsargs['ldapi_socket'] = ldapurl.replace('ldapi://', '')
+ dsargs['ldapi_autobind'] = 'on'
+ elif 'ldaps://' in ldapurl:
+ dsrc_inst['tls_cert'] = certdir
+ else:
+ # The instance name does not match any instances
+ raise ValueError("Could not find configuration for instance: " + dsargs['ldapurl'])
ds = DirSrv(verbose=verbose)
ds.allocate(dsargs)
if not ds.can_autobind() and dsrc_inst['binddn'] is not None:
- dsargs[SER_ROOT_PW] = getpass("Enter password for %s on %s : " % (dsrc_inst['binddn'], dsrc_inst['uri']))
+ dsargs[SER_ROOT_PW] = getpass("Enter password for {} on {}: ".format(dsrc_inst['binddn'], dsrc_inst['uri']))
elif not ds.can_autobind() and dsrc_inst['binddn'] is None:
raise Exception("Must provide a binddn to connect with")
ds.allocate(dsargs)
diff --git a/src/lib389/lib389/cli_conf/schema.py b/src/lib389/lib389/cli_conf/schema.py
index cfa097f21..93e071657 100644
--- a/src/lib389/lib389/cli_conf/schema.py
+++ b/src/lib389/lib389/cli_conf/schema.py
@@ -74,8 +74,16 @@ def reload_schema(inst, basedn, log, args):
schema = Schema(inst)
log.info('Attempting to add task entry... This will fail if Schema Reload plug-in is not enabled.')
task = schema.reload(args.schemadir)
- log.info('Successfully added task entry ' + task.dn)
- log.info("To verify that the schema reload operation was successful, please check the error logs.")
+ if args.wait:
+ task.wait()
+ rc = task.get_exit_code()
+ if rc == 0:
+ log.info("Schema reload task ({}) successfully finished.".format(task.dn))
+ else:
+ raise ValueError("Schema reload task failed, please check the errors log for more information")
+ else:
+ log.info('Successfully added task entry ' + task.dn)
+ log.info("To verify that the schema reload operation was successful, please check the error logs.")
def create_parser(subparsers):
@@ -100,6 +108,7 @@ def create_parser(subparsers):
reload_parser = subcommands.add_parser('reload', help='Dynamically reload schema while server is running')
reload_parser.set_defaults(func=reload_schema)
reload_parser.add_argument('-d', '--schemadir', help="directory where schema files are located")
+ reload_parser.add_argument('--wait', action='store_true', default=False, help="Wait for the reload task to complete")
list_matchingrules_parser = subcommands.add_parser('list_matchingrules', help='List avaliable matching rules on this system')
list_matchingrules_parser.set_defaults(func=list_matchingrules)
diff --git a/src/lib389/lib389/cli_ctl/dbtasks.py b/src/lib389/lib389/cli_ctl/dbtasks.py
index 1b6c37042..7854fbe2c 100644
--- a/src/lib389/lib389/cli_ctl/dbtasks.py
+++ b/src/lib389/lib389/cli_ctl/dbtasks.py
@@ -51,6 +51,21 @@ def dbtasks_ldif2db(inst, log, args):
log.info("ldif2db successful")
+def dbtasks_backups(inst, log, args):
+ if args.delete:
+ # Delete backup
+ inst.del_backup(args.delete)
+ else:
+ # list backups
+ if not inst.backups(args.json):
+ log.fatal("Failed to get list of backups")
+ return False
+ else:
+ if args.json is None:
+ log.info("backups successful")
+
+
+
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.")
@@ -80,3 +95,6 @@ def create_parser(subcommands):
ldif2db_parser.add_argument('--encrypted', help="Import encrypted attributes", default=False, action='store_true')
ldif2db_parser.set_defaults(func=dbtasks_ldif2db)
+ backups_parser = subcommands.add_parser('backups', help="List backup's found in the server's default backup directory")
+ backups_parser.add_argument('--delete', help="Delete backup directory")
+ backups_parser.set_defaults(func=dbtasks_backups)
diff --git a/src/lib389/lib389/config.py b/src/lib389/lib389/config.py
index cec87e8a2..b462585df 100644
--- a/src/lib389/lib389/config.py
+++ b/src/lib389/lib389/config.py
@@ -20,6 +20,7 @@ import ldap
from lib389._constants import *
from lib389 import Entry
from lib389._mapped_object import DSLdapObject
+from lib389.dseldif import DSEldif
from lib389.utils import ensure_bytes, ensure_str
from lib389.lint import DSCLE0001, DSCLE0002, DSELE0001
diff --git a/src/lib389/lib389/dseldif.py b/src/lib389/lib389/dseldif.py
index 69ead6a11..1e0de6c0e 100644
--- a/src/lib389/lib389/dseldif.py
+++ b/src/lib389/lib389/dseldif.py
@@ -17,12 +17,18 @@ class DSEldif(object):
:type instance: lib389.DirSrv
"""
- def __init__(self, instance):
+ def __init__(self, instance, serverid=None):
self._instance = instance
self._contents = []
- ds_paths = Paths(self._instance.serverid, self._instance)
- self.path = os.path.join(ds_paths.config_dir, 'dse.ldif')
+ if serverid:
+ # Get the dse.ldif from the instance name
+ prefix = os.environ.get('PREFIX', ""),
+ serverid = serverid.replace("slapd-", "")
+ self.path = "{}/etc/dirsrv/slapd-{}/dse.ldif".format(prefix[0], serverid)
+ else:
+ ds_paths = Paths(self._instance.serverid, self._instance)
+ self.path = os.path.join(ds_paths.config_dir, 'dse.ldif')
with open(self.path, 'r') as file_dse:
for line in file_dse.readlines():
@@ -67,13 +73,15 @@ class DSEldif(object):
return entry_dn_i, attr_data
- def get(self, entry_dn, attr):
+ def get(self, entry_dn, attr, single=False):
"""Return attribute values under a given entry
:param entry_dn: a DN of entry we want to get attribute from
:type entry_dn: str
:param attr: an attribute name
:type attr: str
+ :param single: Return a single value instead of a list
+ :type sigle: boolean
"""
try:
@@ -81,6 +89,12 @@ class DSEldif(object):
except ValueError:
return None
+ if single:
+ vals = list(attr_data.values())
+ if len(vals) > 0:
+ return vals[0]
+ else:
+ return None
return attr_data.values()
def add(self, entry_dn, attr, value):
diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
index 9a376a649..7fa68c0b0 100644
--- a/src/lib389/lib389/instance/remove.py
+++ b/src/lib389/lib389/instance/remove.py
@@ -26,6 +26,7 @@ def remove_ds_instance(dirsrv):
remove_paths['cert_dir'] = dirsrv.ds_paths.cert_dir
remove_paths['config_dir'] = dirsrv.ds_paths.config_dir
remove_paths['db_dir'] = dirsrv.ds_paths.db_dir
+ remove_paths['db_dir_parent'] = dirsrv.ds_paths.db_dir + "/../"
### WARNING: The changelogdb isn't removed. we assume it's in:
# db_dir ../changelogdb. So remove that too!
# abspath will resolve the ".." down.
@@ -63,6 +64,8 @@ def remove_ds_instance(dirsrv):
for path_k in remove_paths:
_log.debug("Removing %s" % remove_paths[path_k])
shutil.rmtree(remove_paths[path_k], ignore_errors=True)
+ # Remove parent (/var/lib/dirsrv/slapd-INST)
+ shutil.rmtree(remove_paths['db_dir'].replace('db', ''))
# Finally remove the sysconfig marker.
os.remove(marker_path)
diff --git a/src/lib389/lib389/schema.py b/src/lib389/lib389/schema.py
index 14817be66..bd51a39d1 100755
--- a/src/lib389/lib389/schema.py
+++ b/src/lib389/lib389/schema.py
@@ -127,7 +127,6 @@ class SchemaLegacy(object):
ent = ents[0]
return ent.getValue('nsSchemaCSN')
-
def get_objectclasses(self, json=False):
"""Returns a list of ldap.schema.models.ObjectClass objects for all
objectClasses supported by this instance.
@@ -171,7 +170,6 @@ class SchemaLegacy(object):
results.getValues('attributeTypes')]
return attributetypes
-
def get_matchingrules(self, json=False):
"""Return a list of the server defined matching rules"""
attrs = ['matchingrules']
@@ -194,7 +192,6 @@ class SchemaLegacy(object):
results.getValues('matchingRules')]
return matchingRules
-
def query_matchingrule(self, mr_name, json=False):
"""Returns a single matching rule instance that matches the mr_name.
Returns None if the matching rule doesn't exist.
@@ -307,5 +304,4 @@ class SchemaLegacy(object):
'must': must}
return dump_json(result)
else:
- return (attributetype, must, may)
-
+ return (attributetype, must, may)
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index 9bccee85b..94fa93d20 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -40,6 +40,7 @@ from contextlib import closing
import lib389
from lib389.paths import Paths
+from lib389.dseldif import DSEldif
from lib389._constants import (
DEFAULT_USER, VALGRIND_WRAPPER, DN_CONFIG, CFGSUFFIX, LOCALHOST,
ReplicaRole, CONSUMER_REPLICAID
@@ -1001,3 +1002,38 @@ def format_cmd_list(cmd):
"""Format the subprocess command list to the quoted shell string"""
return " ".join(map(shlex.quote, cmd))
+
+
+def get_ldapurl_from_serverid(instance):
+ """ Take an instance name, and get the host/port/protocol from dse.ldif
+ and return a LDAP URL to use in the CLI tools (dsconf)
+
+ :param instance: The server ID of a server instance
+ :return tuple of LDAPURL and certificate directory (for LDAPS)
+ """
+ try:
+ dse_ldif = DSEldif(None, instance)
+ except:
+ return (None, None)
+
+ port = dse_ldif.get("cn=config", "nsslapd-port", single=True)
+ secureport = dse_ldif.get("cn=config", "nsslapd-secureport", single=True)
+ host = dse_ldif.get("cn=config", "nsslapd-localhost", single=True)
+ sec = dse_ldif.get("cn=config", "nsslapd-security", single=True)
+ ldapi_listen = dse_ldif.get("cn=config", "nsslapd-ldapilisten", single=True)
+ ldapi_autobind = dse_ldif.get("cn=config", "nsslapd-ldapiautobind", single=True)
+ ldapi_socket = dse_ldif.get("cn=config", "nsslapd-ldapifilepath", single=True)
+ certdir = dse_ldif.get("cn=config", "nsslapd-certdir", single=True)
+
+ if ldapi_listen is not None and ldapi_listen.lower() == "on" and \
+ ldapi_autobind is not None and ldapi_autobind.lower() == "on" and \
+ ldapi_socket is not None:
+ # Use LDAPI
+ socket = ldapi_socket.replace("/", "%2f") # Escape the path
+ return ("ldapi://" + socket, None)
+ elif sec is not None and sec.lower() == "on" and secureport is not None:
+ # Use LDAPS
+ return ("ldaps://{}:{}".format(host, secureport), certdir)
+ else:
+ # Use LDAP
+ return ("ldap://{}:{}".format(host, port), None)
| 0 |
4272e8f59c0fc5fb9d6edb4f7af1d9fa348620c4
|
389ds/389-ds-base
|
Bug 750625 - Fix Coverity (11108) Sizeof not portable
https://bugzilla.redhat.com/show_bug.cgi?id=750625
lib/libaccess/oneeval.cpp (ACLEvalBuildContext)
Bug Description: Passing argument "8UL /* sizeof (PList_t *) */
* ace->expr_term_index" to function "INTsystem_calloc_perm" and
then casting the return value to "PList_t *" is suspicious. Did
you intend to use "sizeof(PList_t)" instead of "sizeof (PList_t *)"?
In this particular case sizeof(PList_t *) happens to be equal to
sizeof(PList_t), but this is not a portable assumption.
Fix Description: replace sizeof(PList_t *) with sizesof(PList_t).
Note: PList_t is typedef of (PListStruct_t *). I.e., sizeof(PList_t)
and sizeof(PList_t *) are identical. Therefore, this is not a major
problem at all.
|
commit 4272e8f59c0fc5fb9d6edb4f7af1d9fa348620c4
Author: Noriko Hosoi <[email protected]>
Date: Tue Nov 1 18:14:59 2011 -0700
Bug 750625 - Fix Coverity (11108) Sizeof not portable
https://bugzilla.redhat.com/show_bug.cgi?id=750625
lib/libaccess/oneeval.cpp (ACLEvalBuildContext)
Bug Description: Passing argument "8UL /* sizeof (PList_t *) */
* ace->expr_term_index" to function "INTsystem_calloc_perm" and
then casting the return value to "PList_t *" is suspicious. Did
you intend to use "sizeof(PList_t)" instead of "sizeof (PList_t *)"?
In this particular case sizeof(PList_t *) happens to be equal to
sizeof(PList_t), but this is not a portable assumption.
Fix Description: replace sizeof(PList_t *) with sizesof(PList_t).
Note: PList_t is typedef of (PListStruct_t *). I.e., sizeof(PList_t)
and sizeof(PList_t *) are identical. Therefore, this is not a major
problem at all.
diff --git a/lib/libaccess/oneeval.cpp b/lib/libaccess/oneeval.cpp
index f3283b699..eff4e10c0 100644
--- a/lib/libaccess/oneeval.cpp
+++ b/lib/libaccess/oneeval.cpp
@@ -463,7 +463,7 @@ ACLEvalBuildContext(
if (rv > 0) {
/* First one for this ACE? */
if (!new_ace->autharray) {
- new_ace->autharray = (PList_t *)PERM_CALLOC(sizeof(PList_t *) * ace->expr_term_index);
+ new_ace->autharray = (PList_t *)PERM_CALLOC(sizeof(PList_t) * ace->expr_term_index);
if (!new_ace->autharray) {
nserrGenerate(errp, ACLERRNOMEM, ACLERR4040, ACL_Program, 1, XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAuthPointerArray));
goto error;
| 0 |
197c1d7381e6eb455210e2a785525c2b45b0e32a
|
389ds/389-ds-base
|
Bug 630094 - (cov#15456) Remove NULL check for srdn in import code
In the call to slapi_log_error(), we are guaranteed that srdn is
NULL if we are checking it for NULL due to the way the conditions
are nested. The only time we check if srdn is NULL is if inst is
non-NULL, and the if condition guarantees that either inst or
srdn are NULL.
We can just use the string "srdn" in our log message if inst is
non-NULL.
|
commit 197c1d7381e6eb455210e2a785525c2b45b0e32a
Author: Nathan Kinder <[email protected]>
Date: Wed Sep 8 15:48:21 2010 -0700
Bug 630094 - (cov#15456) Remove NULL check for srdn in import code
In the call to slapi_log_error(), we are guaranteed that srdn is
NULL if we are checking it for NULL due to the way the conditions
are nested. The only time we check if srdn is NULL is if inst is
non-NULL, and the if condition guarantees that either inst or
srdn are NULL.
We can just use the string "srdn" in our log message if inst is
non-NULL.
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 12018dbf3..7bdf32f70 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -3279,7 +3279,7 @@ import_get_and_add_parent_rdns(ImportWorkerInfo *info,
if (NULL == inst || NULL == srdn) {
slapi_log_error(SLAPI_LOG_FATAL, "ldif2dbm",
"import_get_and_add_parent_rdns: Empty %s\n",
- NULL==inst?"inst":NULL==srdn?"srdn":"unknown");
+ NULL==inst?"inst":"srdn");
return rc;
}
li = inst->inst_li;
| 0 |
2ccd0bed4e60e44303d5f1cf96bd30572ffea85b
|
389ds/389-ds-base
|
Ticket 49859 - A distinguished value can be missing in an entry
Bug description:
According to RFC 4511 (see ticket), the values of the RDN attributes
should be present in an entry.
With a set of replicated operations, it is possible that those values
would be missing
Fix description:
MOD and MODRDN update checks that the RDN values are presents.
If they are missing they are added to the resulting entry. In addition
the set of modifications to add those values are also indexed.
The specific case of single-valued attributes, where the final and unique value
can not be the RDN value, the attribute nsds5ReplConflict is added.
https://pagure.io/389-ds-base/issue/49859
Reviewed by: Mark Reynolds, William Brown
Platforms tested: F31
|
commit 2ccd0bed4e60e44303d5f1cf96bd30572ffea85b
Author: Thierry Bordaz <[email protected]>
Date: Fri Jun 5 12:14:51 2020 +0200
Ticket 49859 - A distinguished value can be missing in an entry
Bug description:
According to RFC 4511 (see ticket), the values of the RDN attributes
should be present in an entry.
With a set of replicated operations, it is possible that those values
would be missing
Fix description:
MOD and MODRDN update checks that the RDN values are presents.
If they are missing they are added to the resulting entry. In addition
the set of modifications to add those values are also indexed.
The specific case of single-valued attributes, where the final and unique value
can not be the RDN value, the attribute nsds5ReplConflict is added.
https://pagure.io/389-ds-base/issue/49859
Reviewed by: Mark Reynolds, William Brown
Platforms tested: F31
diff --git a/dirsrvtests/tests/suites/replication/conflict_resolve_test.py b/dirsrvtests/tests/suites/replication/conflict_resolve_test.py
index 99a072935..48d0067db 100644
--- a/dirsrvtests/tests/suites/replication/conflict_resolve_test.py
+++ b/dirsrvtests/tests/suites/replication/conflict_resolve_test.py
@@ -10,10 +10,11 @@ import time
import logging
import ldap
import pytest
+import re
from itertools import permutations
from lib389._constants import *
from lib389.idm.nscontainer import nsContainers
-from lib389.idm.user import UserAccounts
+from lib389.idm.user import UserAccounts, UserAccount
from lib389.idm.group import Groups
from lib389.idm.organizationalunit import OrganizationalUnits
from lib389.replica import ReplicationManager
@@ -763,6 +764,177 @@ class TestTwoMasters:
user_dns_m2 = [user.dn for user in test_users_m2.list()]
assert set(user_dns_m1) == set(user_dns_m2)
+ def test_conflict_attribute_multi_valued(self, topology_m2, base_m2):
+ """A RDN attribute being multi-valued, checks that after several operations
+ MODRDN and MOD_REPL its RDN values are the same on both servers
+
+ :id: 225b3522-8ed7-4256-96f9-5fab9b7044a5
+ :setup: Two master replication,
+ audit log, error log for replica and access log for internal
+ :steps:
+ 1. Create a test entry uid=user_test_1000,...
+ 2. Pause all replication agreements
+ 3. On M1 rename it into uid=foo1,...
+ 4. On M2 rename it into uid=foo2,...
+ 5. On M1 MOD_REPL uid:foo1
+ 6. Resume all replication agreements
+ 7. Check that entry on M1 has uid=foo1, foo2
+ 8. Check that entry on M2 has uid=foo1, foo2
+ 9. Check that entry on M1 and M2 has the same uid values
+ :expectedresults:
+ 1. It should pass
+ 2. It should pass
+ 3. It should pass
+ 4. It should pass
+ 5. It should pass
+ 6. It should pass
+ 7. It should pass
+ 8. It should pass
+ 9. It should pass
+ """
+
+ M1 = topology_m2.ms["master1"]
+ M2 = topology_m2.ms["master2"]
+
+ # add a test user
+ test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None)
+ user_1 = test_users_m1.create_test_user(uid=1000)
+ test_users_m2 = UserAccount(M2, user_1.dn)
+ # Waiting fo the user to be replicated
+ for i in range(0,4):
+ time.sleep(1)
+ if test_users_m2.exists():
+ break
+ assert(test_users_m2.exists())
+
+ # Stop replication agreements
+ topology_m2.pause_all_replicas()
+
+ # On M1 rename test entry in uid=foo1
+ original_dn = user_1.dn
+ user_1.rename('uid=foo1')
+ time.sleep(1)
+
+ # On M2 rename test entry in uid=foo2
+ M2.rename_s(original_dn, 'uid=foo2')
+ time.sleep(2)
+
+ # on M1 MOD_REPL uid into foo1
+ user_1.replace('uid', 'foo1')
+
+ # resume replication agreements
+ topology_m2.resume_all_replicas()
+ time.sleep(5)
+
+ # check that on M1, the entry 'uid' has two values 'foo1' and 'foo2'
+ final_dn = re.sub('^.*1000,', 'uid=foo2,', original_dn)
+ final_user_m1 = UserAccount(M1, final_dn)
+ for val in final_user_m1.get_attr_vals_utf8('uid'):
+ log.info("Check %s is on M1" % val)
+ assert(val in ['foo1', 'foo2'])
+
+ # check that on M2, the entry 'uid' has two values 'foo1' and 'foo2'
+ final_user_m2 = UserAccount(M2, final_dn)
+ for val in final_user_m2.get_attr_vals_utf8('uid'):
+ log.info("Check %s is on M1" % val)
+ assert(val in ['foo1', 'foo2'])
+
+ # check that the entry have the same uid values
+ for val in final_user_m1.get_attr_vals_utf8('uid'):
+ log.info("Check M1.uid %s is also on M2" % val)
+ assert(val in final_user_m2.get_attr_vals_utf8('uid'))
+
+ for val in final_user_m2.get_attr_vals_utf8('uid'):
+ log.info("Check M2.uid %s is also on M1" % val)
+ assert(val in final_user_m1.get_attr_vals_utf8('uid'))
+
+ def test_conflict_attribute_single_valued(self, topology_m2, base_m2):
+ """A RDN attribute being signle-valued, checks that after several operations
+ MODRDN and MOD_REPL its RDN values are the same on both servers
+
+ :id: c38ae613-5d1e-47cf-b051-c7284e64b817
+ :setup: Two master replication, test container for entries, enable plugin logging,
+ audit log, error log for replica and access log for internal
+ :steps:
+ 1. Create a test entry uid=user_test_1000,...
+ 2. Pause all replication agreements
+ 3. On M1 rename it into employeenumber=foo1,...
+ 4. On M2 rename it into employeenumber=foo2,...
+ 5. On M1 MOD_REPL employeenumber:foo1
+ 6. Resume all replication agreements
+ 7. Check that entry on M1 has employeenumber=foo1
+ 8. Check that entry on M2 has employeenumber=foo1
+ 9. Check that entry on M1 and M2 has the same employeenumber values
+ :expectedresults:
+ 1. It should pass
+ 2. It should pass
+ 3. It should pass
+ 4. It should pass
+ 5. It should pass
+ 6. It should pass
+ 7. It should pass
+ 8. It should pass
+ 9. It should pass
+ """
+
+ M1 = topology_m2.ms["master1"]
+ M2 = topology_m2.ms["master2"]
+
+ # add a test user with a dummy 'uid' extra value because modrdn removes
+ # uid that conflict with 'account' objectclass
+ test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None)
+ user_1 = test_users_m1.create_test_user(uid=1000)
+ user_1.add('objectclass', 'extensibleobject')
+ user_1.add('uid', 'dummy')
+ test_users_m2 = UserAccount(M2, user_1.dn)
+
+ # Waiting fo the user to be replicated
+ for i in range(0,4):
+ time.sleep(1)
+ if test_users_m2.exists():
+ break
+ assert(test_users_m2.exists())
+
+ # Stop replication agreements
+ topology_m2.pause_all_replicas()
+
+ # On M1 rename test entry in employeenumber=foo1
+ original_dn = user_1.dn
+ user_1.rename('employeenumber=foo1')
+ time.sleep(1)
+
+ # On M2 rename test entry in employeenumber=foo2
+ M2.rename_s(original_dn, 'employeenumber=foo2')
+ time.sleep(2)
+
+ # on M1 MOD_REPL uid into foo1
+ user_1.replace('employeenumber', 'foo1')
+
+ # resume replication agreements
+ topology_m2.resume_all_replicas()
+ time.sleep(5)
+
+ # check that on M1, the entry 'employeenumber' has value 'foo1'
+ final_dn = re.sub('^.*1000,', 'employeenumber=foo2,', original_dn)
+ final_user_m1 = UserAccount(M1, final_dn)
+ for val in final_user_m1.get_attr_vals_utf8('employeenumber'):
+ log.info("Check %s is on M1" % val)
+ assert(val in ['foo1'])
+
+ # check that on M2, the entry 'employeenumber' has values 'foo1'
+ final_user_m2 = UserAccount(M2, final_dn)
+ for val in final_user_m2.get_attr_vals_utf8('employeenumber'):
+ log.info("Check %s is on M2" % val)
+ assert(val in ['foo1'])
+
+ # check that the entry have the same uid values
+ for val in final_user_m1.get_attr_vals_utf8('employeenumber'):
+ log.info("Check M1.uid %s is also on M2" % val)
+ assert(val in final_user_m2.get_attr_vals_utf8('employeenumber'))
+
+ for val in final_user_m2.get_attr_vals_utf8('employeenumber'):
+ log.info("Check M2.uid %s is also on M1" % val)
+ assert(val in final_user_m1.get_attr_vals_utf8('employeenumber'))
class TestThreeMasters:
def test_nested_entries(self, topology_m3, base_m3):
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index e9d7e87e3..a507f3c31 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -213,6 +213,112 @@ error:
return retval;
}
+int32_t
+entry_get_rdn_mods(Slapi_PBlock *pb, Slapi_Entry *entry, CSN *csn, int repl_op, Slapi_Mods **smods_ret)
+{
+ unsigned long op_type = SLAPI_OPERATION_NONE;
+ char *new_rdn = NULL;
+ char **dns = NULL;
+ char **rdns = NULL;
+ Slapi_Mods *smods = NULL;
+ char *type = NULL;
+ struct berval *bvp[2] = {0};
+ struct berval bv;
+ Slapi_Attr *attr = NULL;
+ const char *entry_dn = NULL;
+
+ *smods_ret = NULL;
+ entry_dn = slapi_entry_get_dn_const(entry);
+ /* Do not bother to check that RDN is present, no one rename RUV or change its nsuniqueid */
+ if (strcasestr(entry_dn, RUV_STORAGE_ENTRY_UNIQUEID)) {
+ return 0;
+ }
+
+ /* First get the RDNs of the operation */
+ slapi_pblock_get(pb, SLAPI_OPERATION_TYPE, &op_type);
+ switch (op_type) {
+ case SLAPI_OPERATION_MODIFY:
+ dns = slapi_ldap_explode_dn(entry_dn, 0);
+ if (dns == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "entry_get_rdn_mods",
+ "Fails to split DN \"%s\" into components\n", entry_dn);
+ return -1;
+ }
+ rdns = slapi_ldap_explode_rdn(dns[0], 0);
+ slapi_ldap_value_free(dns);
+
+ break;
+ case SLAPI_OPERATION_MODRDN:
+ slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &new_rdn);
+ rdns = slapi_ldap_explode_rdn(new_rdn, 0);
+ break;
+ default:
+ break;
+ }
+ if (rdns == NULL || rdns[0] == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "entry_get_rdn_mods",
+ "Fails to split RDN \"%s\" into components\n", slapi_entry_get_dn_const(entry));
+ return -1;
+ }
+
+ /* Update the entry to add RDNs values if they are missing */
+ smods = slapi_mods_new();
+
+ bvp[0] = &bv;
+ bvp[1] = NULL;
+ for (size_t rdns_count = 0; rdns[rdns_count]; rdns_count++) {
+ Slapi_Value *value;
+ attr = NULL;
+ slapi_rdn2typeval(rdns[rdns_count], &type, &bv);
+
+ /* Check if the RDN value exists */
+ if ((slapi_entry_attr_find(entry, type, &attr) != 0) ||
+ (slapi_attr_value_find(attr, &bv))) {
+ const CSN *csn_rdn_add;
+ const CSN *adcsn = attr_get_deletion_csn(attr);
+
+ /* It is missing => adds it */
+ if (slapi_attr_flag_is_set(attr, SLAPI_ATTR_FLAG_SINGLE)) {
+ if (csn_compare(adcsn, csn) >= 0) {
+ /* this is a single valued attribute and the current value
+ * (that is different from RDN value) is more recent than
+ * the RDN value we want to apply.
+ * Keep the current value and add a conflict flag
+ */
+
+ type = ATTR_NSDS5_REPLCONFLICT;
+ bv.bv_val = "RDN value may be missing because it is single-valued";
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_add_string(entry, type, bv.bv_val);
+ slapi_mods_add_modbvps(smods, LDAP_MOD_ADD, type, bvp);
+ continue;
+ }
+ }
+ /* if a RDN value needs to be forced, make sure it csn is ahead */
+ slapi_mods_add_modbvps(smods, LDAP_MOD_ADD, type, bvp);
+ csn_rdn_add = csn_max(adcsn, csn);
+
+ if (entry_apply_mods_wsi(entry, smods, csn_rdn_add, repl_op)) {
+ slapi_log_err(SLAPI_LOG_ERR, "entry_get_rdn_mods",
+ "Fails to set \"%s\" in \"%s\"\n", type, slapi_entry_get_dn_const(entry));
+ slapi_ldap_value_free(rdns);
+ slapi_mods_free(&smods);
+ return -1;
+ }
+ /* Make the RDN value a distinguished value */
+ attr_value_find_wsi(attr, &bv, &value);
+ value_update_csn(value, CSN_TYPE_VALUE_DISTINGUISHED, csn_rdn_add);
+ }
+ }
+ slapi_ldap_value_free(rdns);
+ if (smods->num_mods == 0) {
+ /* smods_ret already NULL, just free the useless smods */
+ slapi_mods_free(&smods);
+ } else {
+ *smods_ret = smods;
+ }
+ return 0;
+}
/**
Apply the mods to the ec entry. Check for syntax, schema problems.
Check for abandon.
@@ -269,6 +375,8 @@ modify_apply_check_expand(
goto done;
}
+
+
/*
* If the objectClass attribute type was modified in any way, expand
* the objectClass values to reflect the inheritance hierarchy.
@@ -414,6 +522,7 @@ ldbm_back_modify(Slapi_PBlock *pb)
int result_sent = 0;
int32_t parent_op = 0;
struct timespec parent_time;
+ Slapi_Mods *smods_add_rdn = NULL;
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li);
@@ -731,6 +840,15 @@ ldbm_back_modify(Slapi_PBlock *pb)
}
} /* else if new_mod_count == mod_count then betxnpremod plugin did nothing */
+ /* time to check if applying a replicated operation removed
+ * the RDN value from the entry. Assuming that only replicated update
+ * can lead to that bad result
+ */
+ if (entry_get_rdn_mods(pb, ec->ep_entry, opcsn, repl_op, &smods_add_rdn)) {
+ goto error_return;
+ }
+
+
/*
* Update the ID to Entry index.
* Note that id2entry_add replaces the entry, so the Entry ID
@@ -764,6 +882,23 @@ ldbm_back_modify(Slapi_PBlock *pb)
MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
goto error_return;
}
+
+ if (smods_add_rdn && slapi_mods_get_num_mods(smods_add_rdn) > 0) {
+ retval = index_add_mods(be, (LDAPMod **) slapi_mods_get_ldapmods_byref(smods_add_rdn), e, ec, &txn);
+ if (DB_LOCK_DEADLOCK == retval) {
+ /* Abort and re-try */
+ slapi_mods_free(&smods_add_rdn);
+ continue;
+ }
+ if (retval != 0) {
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_modify",
+ "index_add_mods (rdn) failed, err=%d %s\n",
+ retval, (msg = dblayer_strerror(retval)) ? msg : "");
+ MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
+ slapi_mods_free(&smods_add_rdn);
+ goto error_return;
+ }
+ }
/*
* Remove the old entry from the Virtual List View indexes.
* Add the new entry to the Virtual List View indexes.
@@ -978,6 +1113,7 @@ error_return:
common_return:
slapi_mods_done(&smods);
+ slapi_mods_free(&smods_add_rdn);
if (inst) {
if (ec_locked || cache_is_in_cache(&inst->inst_cache, ec)) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index fde83c99f..e97b7a5f6 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -21,7 +21,7 @@ static void moddn_unlock_and_return_entry(backend *be, struct backentry **target
static int moddn_newrdn_mods(Slapi_PBlock *pb, const char *olddn, struct backentry *ec, Slapi_Mods *smods_wsi, int is_repl_op);
static IDList *moddn_get_children(back_txn *ptxn, Slapi_PBlock *pb, backend *be, struct backentry *parententry, Slapi_DN *parentdn, struct backentry ***child_entries, struct backdn ***child_dns, int is_resurect_operation);
static int moddn_rename_children(back_txn *ptxn, Slapi_PBlock *pb, backend *be, IDList *children, Slapi_DN *dn_parentdn, Slapi_DN *dn_newsuperiordn, struct backentry *child_entries[]);
-static int modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li, struct backentry *e, struct backentry **ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3);
+static int modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li, struct backentry *e, struct backentry **ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3, Slapi_Mods *smods4);
static void mods_remove_nsuniqueid(Slapi_Mods *smods);
#define MOD_SET_ERROR(rc, error, count) \
@@ -100,6 +100,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
Connection *pb_conn = NULL;
int32_t parent_op = 0;
struct timespec parent_time;
+ Slapi_Mods *smods_add_rdn = NULL;
if (slapi_pblock_get(pb, SLAPI_CONN_ID, &conn_id) < 0) {
conn_id = 0; /* connection is NULL */
@@ -842,6 +843,15 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
goto error_return;
}
}
+
+ /* time to check if applying a replicated operation removed
+ * the RDN value from the entry. Assuming that only replicated update
+ * can lead to that bad result
+ */
+ if (entry_get_rdn_mods(pb, ec->ep_entry, opcsn, is_replicated_operation, &smods_add_rdn)) {
+ goto error_return;
+ }
+
/* check that the entry still obeys the schema */
if (slapi_entry_schema_check(pb, ec->ep_entry) != 0) {
ldap_result_code = LDAP_OBJECT_CLASS_VIOLATION;
@@ -1003,7 +1013,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb)
/*
* Update the indexes for the entry.
*/
- retval = modrdn_rename_entry_update_indexes(&txn, pb, li, e, &ec, &smods_generated, &smods_generated_wsi, &smods_operation_wsi);
+ retval = modrdn_rename_entry_update_indexes(&txn, pb, li, e, &ec, &smods_generated, &smods_generated_wsi, &smods_operation_wsi, smods_add_rdn);
if (DB_LOCK_DEADLOCK == retval) {
/* Retry txn */
continue;
@@ -1497,6 +1507,7 @@ common_return:
slapi_mods_done(&smods_operation_wsi);
slapi_mods_done(&smods_generated);
slapi_mods_done(&smods_generated_wsi);
+ slapi_mods_free(&smods_add_rdn);
slapi_ch_free((void **)&child_entries);
slapi_ch_free((void **)&child_dns);
if (ldap_result_matcheddn && 0 != strcmp(ldap_result_matcheddn, "NULL"))
@@ -1778,7 +1789,7 @@ mods_remove_nsuniqueid(Slapi_Mods *smods)
* mods contains the list of attribute change made.
*/
static int
-modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li __attribute__((unused)), struct backentry *e, struct backentry **ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3)
+modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li __attribute__((unused)), struct backentry *e, struct backentry **ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3, Slapi_Mods *smods4)
{
backend *be;
ldbm_instance *inst;
@@ -1874,6 +1885,24 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
goto error_return;
}
}
+ if (smods4 != NULL && slapi_mods_get_num_mods(smods4) > 0) {
+ /*
+ * update the indexes: lastmod, rdn, etc.
+ */
+ retval = index_add_mods(be, slapi_mods_get_ldapmods_byref(smods4), e, *ec, ptxn);
+ if (DB_LOCK_DEADLOCK == retval) {
+ /* Retry txn */
+ slapi_log_err(SLAPI_LOG_BACKLDBM, "modrdn_rename_entry_update_indexes",
+ "index_add_mods4 deadlock\n");
+ goto error_return;
+ }
+ if (retval != 0) {
+ slapi_log_err(SLAPI_LOG_TRACE, "modrdn_rename_entry_update_indexes",
+ "index_add_mods 4 failed, err=%d %s\n",
+ retval, (msg = dblayer_strerror(retval)) ? msg : "");
+ goto error_return;
+ }
+ }
/*
* Remove the old entry from the Virtual List View indexes.
* Add the new entry to the Virtual List View indexes.
@@ -1991,7 +2020,7 @@ moddn_rename_child_entry(
* Update all the indexes.
*/
retval = modrdn_rename_entry_update_indexes(ptxn, pb, li, e, ec,
- smodsp, NULL, NULL);
+ smodsp, NULL, NULL, NULL);
/* JCMREPL - Should the children get updated modifiersname and lastmodifiedtime? */
slapi_mods_done(&smods);
}
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 5b277b966..3ea58087a 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -323,6 +323,7 @@ int get_parent_rdn(DB *db, ID parentid, Slapi_RDN *srdn);
/*
* modify.c
*/
+int32_t entry_get_rdn_mods(Slapi_PBlock *pb, Slapi_Entry *entry, CSN *csn, int repl_op, Slapi_Mods **smods_ret);
int modify_update_all(backend *be, Slapi_PBlock *pb, modify_context *mc, back_txn *txn);
void modify_init(modify_context *mc, struct backentry *old_entry);
int modify_apply_mods(modify_context *mc, Slapi_Mods *smods);
| 0 |
f8e5e01099f0dedb12feead3584607d6e80ee4bf
|
389ds/389-ds-base
|
Issue 50403 - Instance creation fails on 1.3.9 using perl utils and latest lib389
Bug Description:
There is a typo in formatInfData() that generates invalid inf file.
Fix Description:
Fix the typo.
Fixes https://pagure.io/389-ds-base/issue/50403
Reviewed by: mreynolds (Thanks!)
|
commit f8e5e01099f0dedb12feead3584607d6e80ee4bf
Author: Viktor Ashirov <[email protected]>
Date: Thu May 23 15:47:28 2019 +0200
Issue 50403 - Instance creation fails on 1.3.9 using perl utils and latest lib389
Bug Description:
There is a typo in formatInfData() that generates invalid inf file.
Fix Description:
Fix the typo.
Fixes https://pagure.io/389-ds-base/issue/50403
Reviewed by: mreynolds (Thanks!)
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index 49bcad8b7..783c1cd39 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -958,7 +958,7 @@ def formatInfData(args):
content = ("[General]" "\n")
content += ("FullMachineName= %s\n" % args[SER_HOST])
content += ("SuiteSpotUserID= %s\n" % args[SER_USER_ID])
- content += ("nSuiteSpotGroup= %s\n" % args[SER_GROUP_ID])
+ content += ("SuiteSpotGroup= %s\n" % args[SER_GROUP_ID])
content += ("StrictHostCheck= %s\n" % args[SER_STRICT_HOSTNAME_CHECKING])
if args.get('have_admin'):
| 0 |
ffda491f1738bde7691703369268ec1fadaadb18
|
389ds/389-ds-base
|
Issue 49300 - entryUSN is duplicated after memberOf operation
Bug Description: When we assign a member to a group we have two
oprations - group modification and user modification.
As a result, they both have the same entryUSN because USN Plugin
assigns entryUSN value in bepreop but increments the counter
in the postop and a lot of things can happen in between.
Fix Description: Increment the counter in bepreop together with
entryUSN assignment. Also, decrement the counter in bepostop if
the failuer has happened.
Add test suite to cover the change.
https://pagure.io/389-ds-base/issue/49300
Reviewed by: tbordaz (Thanks!)
|
commit ffda491f1738bde7691703369268ec1fadaadb18
Author: Simon Pichugin <[email protected]>
Date: Tue Jun 30 15:39:30 2020 +0200
Issue 49300 - entryUSN is duplicated after memberOf operation
Bug Description: When we assign a member to a group we have two
oprations - group modification and user modification.
As a result, they both have the same entryUSN because USN Plugin
assigns entryUSN value in bepreop but increments the counter
in the postop and a lot of things can happen in between.
Fix Description: Increment the counter in bepreop together with
entryUSN assignment. Also, decrement the counter in bepostop if
the failuer has happened.
Add test suite to cover the change.
https://pagure.io/389-ds-base/issue/49300
Reviewed by: tbordaz (Thanks!)
diff --git a/dirsrvtests/tests/suites/plugins/entryusn_test.py b/dirsrvtests/tests/suites/plugins/entryusn_test.py
new file mode 100644
index 000000000..721315419
--- /dev/null
+++ b/dirsrvtests/tests/suites/plugins/entryusn_test.py
@@ -0,0 +1,240 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2020 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import ldap
+import logging
+import pytest
+from lib389._constants import DEFAULT_SUFFIX
+from lib389.config import Config
+from lib389.plugins import USNPlugin, MemberOfPlugin
+from lib389.idm.group import Groups
+from lib389.idm.user import UserAccounts
+from lib389.idm.organizationalunit import OrganizationalUnit
+from lib389.tombstone import Tombstones
+from lib389.rootdse import RootDSE
+from lib389.topologies import topology_st, topology_m2
+
+log = logging.getLogger(__name__)
+
+USER_NUM = 10
+GROUP_NUM = 3
+
+
+def check_entryusn_no_duplicates(entryusn_list):
+ """Check that all values in the list are unique"""
+
+ if len(entryusn_list) > len(set(entryusn_list)):
+ raise AssertionError(f"EntryUSN values have duplicates, please, check logs")
+
+
+def check_lastusn_after_restart(inst):
+ """Check that last usn is the same after restart"""
+
+ root_dse = RootDSE(inst)
+ last_usn_before = root_dse.get_attr_val_int("lastusn;userroot")
+ inst.restart()
+ last_usn_after = root_dse.get_attr_val_int("lastusn;userroot")
+ assert last_usn_after == last_usn_before
+
+
[email protected](scope="module")
+def setup(topology_st, request):
+ """
+ Enable USN plug-in
+ Enable MEMBEROF plugin
+ Add test entries
+ """
+
+ inst = topology_st.standalone
+
+ log.info("Enable the USN plugin...")
+ plugin = USNPlugin(inst)
+ plugin.enable()
+
+ log.info("Enable the MEMBEROF plugin...")
+ plugin = MemberOfPlugin(inst)
+ plugin.enable()
+
+ inst.restart()
+
+ users_list = []
+ log.info("Adding test entries...")
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+ for id in range(USER_NUM):
+ user = users.create_test_user(uid=id)
+ users_list.append(user)
+
+ groups_list = []
+ log.info("Adding test groups...")
+ groups = Groups(inst, DEFAULT_SUFFIX)
+ for id in range(GROUP_NUM):
+ group = groups.create(properties={'cn': f'test_group{id}'})
+ groups_list.append(group)
+
+ def fin():
+ for user in users_list:
+ try:
+ user.delete()
+ except ldap.NO_SUCH_OBJECT:
+ pass
+ for group in groups_list:
+ try:
+ group.delete()
+ except ldap.NO_SUCH_OBJECT:
+ pass
+ request.addfinalizer(fin)
+
+ return {"users": users_list,
+ "groups": groups_list}
+
+
+def test_entryusn_no_duplicates(topology_st, setup):
+ """Verify that entryUSN is not duplicated after memberOf operation
+
+ :id: 1a7d382d-1214-4d56-b9c2-9c4ed57d1683
+ :setup: Standalone instance, Groups and Users, USN and memberOf are enabled
+ :steps:
+ 1. Add a member to group 1
+ 2. Add a member to group 1 and 2
+ 3. Check that entryUSNs are different
+ 4. Check that lastusn before and after a restart are the same
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ inst = topology_st.standalone
+ config = Config(inst)
+ config.replace('nsslapd-accesslog-level', '260') # Internal op
+ config.replace('nsslapd-errorlog-level', '65536')
+ config.replace('nsslapd-plugin-logging', 'on')
+ entryusn_list = []
+
+ users = setup["users"]
+ groups = setup["groups"]
+
+ groups[0].replace('member', users[0].dn)
+ entryusn_list.append(users[0].get_attr_val_int('entryusn'))
+ log.info(f"{users[0].dn}_1: {entryusn_list[-1:]}")
+ entryusn_list.append(groups[0].get_attr_val_int('entryusn'))
+ log.info(f"{groups[0].dn}_1: {entryusn_list[-1:]}")
+ check_entryusn_no_duplicates(entryusn_list)
+
+ groups[1].replace('member', [users[0].dn, users[1].dn])
+ entryusn_list.append(users[0].get_attr_val_int('entryusn'))
+ log.info(f"{users[0].dn}_2: {entryusn_list[-1:]}")
+ entryusn_list.append(users[1].get_attr_val_int('entryusn'))
+ log.info(f"{users[1].dn}_2: {entryusn_list[-1:]}")
+ entryusn_list.append(groups[1].get_attr_val_int('entryusn'))
+ log.info(f"{groups[1].dn}_2: {entryusn_list[-1:]}")
+ check_entryusn_no_duplicates(entryusn_list)
+
+ check_lastusn_after_restart(inst)
+
+
+def test_entryusn_is_same_after_failure(topology_st, setup):
+ """Verify that entryUSN is the same after failed operation
+
+ :id: 1f227533-370a-48c1-b920-9b3b0bcfc32e
+ :setup: Standalone instance, Groups and Users, USN and memberOf are enabled
+ :steps:
+ 1. Get current group's entryUSN value
+ 2. Try to modify the group with an invalid syntax
+ 3. Get new group's entryUSN value and compare with old
+ 4. Check that lastusn before and after a restart are the same
+ :expectedresults:
+ 1. Success
+ 2. Invalid Syntax error
+ 3. Should be the same
+ 4. Success
+ """
+
+ inst = topology_st.standalone
+ users = setup["users"]
+
+ # We need this update so we get the latest USN pointed to our entry
+ users[0].replace('description', 'update')
+
+ entryusn_before = users[0].get_attr_val_int('entryusn')
+ users[0].replace('description', 'update')
+ try:
+ users[0].replace('uid', 'invalid update')
+ except ldap.NOT_ALLOWED_ON_RDN:
+ pass
+ users[0].replace('description', 'second update')
+ entryusn_after = users[0].get_attr_val_int('entryusn')
+
+ # entryUSN should be OLD + 2 (only two user updates)
+ assert entryusn_after == (entryusn_before + 2)
+
+ check_lastusn_after_restart(inst)
+
+
+def test_entryusn_after_repl_delete(topology_m2):
+ """Verify that entryUSN is incremented on 1 after delete operation which creates a tombstone
+
+ :id: 1704cf65-41bc-4347-bdaf-20fc2431b218
+ :setup: An instance with replication, Users, USN enabled
+ :steps:
+ 1. Try to delete a user
+ 2. Check the tombstone has the incremented USN
+ 3. Try to delete ou=People with users
+ 4. Check the entry has a not incremented entryUSN
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Should fail with Not Allowed On Non-leaf error
+ 4. Success
+ """
+
+ inst = topology_m2.ms["master1"]
+ plugin = USNPlugin(inst)
+ plugin.enable()
+ inst.restart()
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+
+ try:
+ user_1 = users.create_test_user()
+ user_rdn = user_1.rdn
+ tombstones = Tombstones(inst, DEFAULT_SUFFIX)
+
+ user_1.replace('description', 'update_ts')
+ user_usn = user_1.get_attr_val_int('entryusn')
+
+ user_1.delete()
+
+ ts = tombstones.get(user_rdn)
+ ts_usn = ts.get_attr_val_int('entryusn')
+
+ assert (user_usn + 1) == ts_usn
+
+ user_1 = users.create_test_user()
+ org = OrganizationalUnit(inst, f"ou=People,{DEFAULT_SUFFIX}")
+ org.replace('description', 'update_ts')
+ ou_usn_before = org.get_attr_val_int('entryusn')
+ try:
+ org.delete()
+ except ldap.NOT_ALLOWED_ON_NONLEAF:
+ pass
+ ou_usn_after = org.get_attr_val_int('entryusn')
+ assert ou_usn_before == ou_usn_after
+
+ finally:
+ try:
+ user_1.delete()
+ except ldap.NO_SUCH_OBJECT:
+ pass
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 12ba040c6..f2cc8a62c 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -333,6 +333,12 @@ _usn_add_next_usn(Slapi_Entry *e, Slapi_Backend *be)
}
slapi_ch_free_string(&usn_berval.bv_val);
+ /*
+ * increment the counter now and decrement in the bepostop
+ * if the operation will fail
+ */
+ slapi_counter_increment(be->be_usn_counter);
+
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- _usn_add_next_usn\n");
@@ -370,6 +376,12 @@ _usn_mod_next_usn(LDAPMod ***mods, Slapi_Backend *be)
*mods = slapi_mods_get_ldapmods_passout(&smods);
+ /*
+ * increment the counter now and decrement in the bepostop
+ * if the operation will fail
+ */
+ slapi_counter_increment(be->be_usn_counter);
+
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- _usn_mod_next_usn\n");
return LDAP_SUCCESS;
@@ -420,6 +432,7 @@ usn_betxnpreop_delete(Slapi_PBlock *pb)
{
Slapi_Entry *e = NULL;
Slapi_Backend *be = NULL;
+ int32_t tombstone_incremented = 0;
int rc = SLAPI_PLUGIN_SUCCESS;
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -441,7 +454,9 @@ usn_betxnpreop_delete(Slapi_PBlock *pb)
goto bail;
}
_usn_add_next_usn(e, be);
+ tombstone_incremented = 1;
bail:
+ slapi_pblock_set(pb, SLAPI_USN_INCREMENT_FOR_TOMBSTONE, &tombstone_incremented);
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- usn_betxnpreop_delete\n");
@@ -483,7 +498,7 @@ bail:
return rc;
}
-/* count up the counter */
+/* count down the counter */
static int
usn_bepostop(Slapi_PBlock *pb)
{
@@ -493,25 +508,24 @@ usn_bepostop(Slapi_PBlock *pb)
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"--> usn_bepostop\n");
- /* if op is not successful, don't increment the counter */
+ /* if op is not successful, decrement the counter, else - do nothing */
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (LDAP_SUCCESS != rc) {
- /* no plugin failure */
- rc = SLAPI_PLUGIN_SUCCESS;
- goto bail;
- }
+ slapi_pblock_get(pb, SLAPI_BACKEND, &be);
+ if (NULL == be) {
+ rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
+ goto bail;
+ }
- slapi_pblock_get(pb, SLAPI_BACKEND, &be);
- if (NULL == be) {
- rc = LDAP_PARAM_ERROR;
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
- rc = SLAPI_PLUGIN_FAILURE;
- goto bail;
+ if (be->be_usn_counter) {
+ slapi_counter_decrement(be->be_usn_counter);
+ }
}
- if (be->be_usn_counter) {
- slapi_counter_increment(be->be_usn_counter);
- }
+ /* no plugin failure */
+ rc = SLAPI_PLUGIN_SUCCESS;
bail:
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- usn_bepostop\n");
@@ -519,13 +533,14 @@ bail:
return rc;
}
-/* count up the counter */
+/* count down the counter on a failure and mod ignore */
static int
usn_bepostop_modify(Slapi_PBlock *pb)
{
int rc = SLAPI_PLUGIN_FAILURE;
Slapi_Backend *be = NULL;
LDAPMod **mods = NULL;
+ int32_t do_decrement = 0;
int i;
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -534,9 +549,7 @@ usn_bepostop_modify(Slapi_PBlock *pb)
/* if op is not successful, don't increment the counter */
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (LDAP_SUCCESS != rc) {
- /* no plugin failure */
- rc = SLAPI_PLUGIN_SUCCESS;
- goto bail;
+ do_decrement = 1;
}
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
@@ -545,25 +558,29 @@ usn_bepostop_modify(Slapi_PBlock *pb)
if (mods[i]->mod_op & LDAP_MOD_IGNORE) {
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"usn_bepostop_modify - MOD_IGNORE detected\n");
- goto bail; /* conflict occurred.
- skip incrementing the counter. */
+ do_decrement = 1; /* conflict occurred.
+ decrement he counter. */
} else {
break;
}
}
}
- slapi_pblock_get(pb, SLAPI_BACKEND, &be);
- if (NULL == be) {
- rc = LDAP_PARAM_ERROR;
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
- rc = SLAPI_PLUGIN_FAILURE;
- goto bail;
+ if (do_decrement) {
+ slapi_pblock_get(pb, SLAPI_BACKEND, &be);
+ if (NULL == be) {
+ rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
+ goto bail;
+ }
+ if (be->be_usn_counter) {
+ slapi_counter_decrement(be->be_usn_counter);
+ }
}
- if (be->be_usn_counter) {
- slapi_counter_increment(be->be_usn_counter);
- }
+ /* no plugin failure */
+ rc = SLAPI_PLUGIN_SUCCESS;
bail:
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- usn_bepostop_modify\n");
@@ -573,34 +590,38 @@ bail:
/* count up the counter */
/* if the op is delete and the op was not successful, remove preventryusn */
+/* the function is executed on TXN level */
static int
usn_bepostop_delete(Slapi_PBlock *pb)
{
int rc = SLAPI_PLUGIN_FAILURE;
Slapi_Backend *be = NULL;
+ int32_t tombstone_incremented = 0;
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"--> usn_bepostop_delete\n");
- /* if op is not successful, don't increment the counter */
+ /* if op is not successful and it is a tombstone entry, decrement the counter */
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (LDAP_SUCCESS != rc) {
- /* no plugin failure */
- rc = SLAPI_PLUGIN_SUCCESS;
- goto bail;
- }
+ slapi_pblock_get(pb, SLAPI_USN_INCREMENT_FOR_TOMBSTONE, &tombstone_incremented);
+ if (tombstone_incremented) {
+ slapi_pblock_get(pb, SLAPI_BACKEND, &be);
+ if (NULL == be) {
+ rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
+ goto bail;
+ }
- slapi_pblock_get(pb, SLAPI_BACKEND, &be);
- if (NULL == be) {
- rc = LDAP_PARAM_ERROR;
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
- rc = SLAPI_PLUGIN_FAILURE;
- goto bail;
+ if (be->be_usn_counter) {
+ slapi_counter_decrement(be->be_usn_counter);
+ }
+ }
}
- if (be->be_usn_counter) {
- slapi_counter_increment(be->be_usn_counter);
- }
+ /* no plugin failure */
+ rc = SLAPI_PLUGIN_SUCCESS;
bail:
slapi_log_err(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- usn_bepostop_delete\n");
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index 7a9578d1a..faf8a694c 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -2436,7 +2436,7 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
(*(char **)value) = NULL;
}
break;
-
+
case SLAPI_SEARCH_CTRLS:
if (pblock->pb_intop != NULL) {
(*(LDAPControl ***)value) = pblock->pb_intop->pb_search_ctrls;
@@ -2479,6 +2479,14 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
}
break;
+ case SLAPI_USN_INCREMENT_FOR_TOMBSTONE:
+ if (pblock->pb_intop != NULL) {
+ (*(int32_t *)value) = pblock->pb_intop->pb_usn_tombstone_incremented;
+ } else {
+ (*(int32_t *)value) = 0;
+ }
+ break;
+
/* ACI Target Check */
case SLAPI_ACI_TARGET_CHECK:
if (pblock->pb_misc != NULL) {
@@ -4159,6 +4167,10 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
pblock->pb_intop->pb_paged_results_cookie = *(int *)value;
break;
+ case SLAPI_USN_INCREMENT_FOR_TOMBSTONE:
+ pblock->pb_intop->pb_usn_tombstone_incremented = *((int32_t *)value);
+ break;
+
/* ACI Target Check */
case SLAPI_ACI_TARGET_CHECK:
_pblock_assert_pb_misc(pblock);
diff --git a/ldap/servers/slapd/pblock_v3.h b/ldap/servers/slapd/pblock_v3.h
index 7ec2f37d6..90498c0b0 100644
--- a/ldap/servers/slapd/pblock_v3.h
+++ b/ldap/servers/slapd/pblock_v3.h
@@ -161,6 +161,7 @@ typedef struct _slapi_pblock_intop
int pb_paged_results_index; /* stash SLAPI_PAGED_RESULTS_INDEX */
int pb_paged_results_cookie; /* stash SLAPI_PAGED_RESULTS_COOKIE */
+ int32_t pb_usn_tombstone_incremented; /* stash SLAPI_PAGED_RESULTS_COOKIE */
} slapi_pblock_intop;
/* Stuff that is rarely used, but still present */
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index be6c98b29..3aadf3803 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -7482,6 +7482,9 @@ typedef enum _slapi_op_note_t {
#define SLAPI_PAGED_RESULTS_INDEX 1945
#define SLAPI_PAGED_RESULTS_COOKIE 1949
+/* USN Plugin flag for tombstone entries */
+#define SLAPI_USN_INCREMENT_FOR_TOMBSTONE 1950
+
/* ACI Target Check */
#define SLAPI_ACI_TARGET_CHECK 1946
| 0 |
434a92fb0a149f1070cf83c2ed449db50523f768
|
389ds/389-ds-base
|
Issue 48989 - Overflow in counters and monitor
Bug Description: NSPR's printf functions are only designed to work with 32bit ints,
so this causes unexpected overflows in logs, perf counters, and
monitor output.
Fix Description: Just use the standard printf functions which do work correctly
with 32/64 bit ints.
We are now using the gcc __atomic built-in functions which covers
a lot of portabilty issues between architectures, and helps simplify
the code. Replaced PRUint64 with uint64_t where needed
https://pagure.io/389-ds-base/issue/48989
Reviewed by: firstyear(Thanks!)
|
commit 434a92fb0a149f1070cf83c2ed449db50523f768
Author: Mark Reynolds <[email protected]>
Date: Tue Mar 21 15:32:21 2017 -0400
Issue 48989 - Overflow in counters and monitor
Bug Description: NSPR's printf functions are only designed to work with 32bit ints,
so this causes unexpected overflows in logs, perf counters, and
monitor output.
Fix Description: Just use the standard printf functions which do work correctly
with 32/64 bit ints.
We are now using the gcc __atomic built-in functions which covers
a lot of portabilty issues between architectures, and helps simplify
the code. Replaced PRUint64 with uint64_t where needed
https://pagure.io/389-ds-base/issue/48989
Reviewed by: firstyear(Thanks!)
diff --git a/dirsrvtests/tests/tickets/issue48989_test.py b/dirsrvtests/tests/tickets/issue48989_test.py
new file mode 100644
index 000000000..b4e7a9592
--- /dev/null
+++ b/dirsrvtests/tests/tickets/issue48989_test.py
@@ -0,0 +1,57 @@
+import os
+import time
+import ldap
+import logging
+import pytest
+from lib389.topologies import topology_st
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+DEBUGGING = False
+
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+
+def test_bytessent_overflow(topology_st):
+ """
+ Issue 48989 - Add 10k entries and run search until the value of bytessent is
+ bigger than 2^32 or resets to 0
+ """
+
+ # Create users
+ topology_st.standalone.ldclt.create_users('ou=People,%s' %
+ DEFAULT_SUFFIX, min=0, max=10000)
+ bytessent = int(topology_st.standalone.search_s(
+ 'cn=monitor', ldap.SCOPE_BASE, attrlist=['bytessent'])[0].getValue('bytessent'))
+ bytessent_old = bytessent
+
+ while bytessent < 4300000000:
+ # Do searches
+ topology_st.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ filterstr='(objectClass=*)')
+
+ # Read bytessent value from cn=monitor
+ bytessent = int(topology_st.standalone.search_s(
+ 'cn=monitor', ldap.SCOPE_BASE, attrlist=['bytessent'])[0].getValue('bytessent'))
+
+ if bytessent > bytessent_old:
+ bytessent_old = bytessent
+ else:
+ # If it overflows - test failed
+ assert(bytessent > 4294967295)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
+
+
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 54bbe865d..34011b9bd 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -2497,7 +2497,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
if ((config_entry->maxval == -1) ||
(nextval <= (config_entry->maxval + config_entry->interval))) {
/* try to set the new next value in the config entry */
- PR_snprintf(next_value, sizeof(next_value),"%" NSPRIu64, nextval);
+ snprintf(next_value, sizeof(next_value),"%" NSPRIu64, nextval);
/* set up our replace modify operation */
replace_val[0] = next_value;
@@ -2565,13 +2565,13 @@ dna_get_shared_config_attr_val(struct configEntry *config_entry, char *attr, cha
if(slapi_sdn_compare(server->sdn, server_sdn) == 0){
if(strcmp(attr, DNA_REMOTE_BIND_METHOD) == 0){
if (server->remote_bind_method) {
- PR_snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_bind_method);
+ snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_bind_method);
found = 1;
}
break;
} else if(strcmp(attr, DNA_REMOTE_CONN_PROT) == 0){
if (server->remote_conn_prot) {
- PR_snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_conn_prot);
+ snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_conn_prot);
found = 1;
}
break;
@@ -2609,7 +2609,7 @@ dna_update_shared_config(struct configEntry *config_entry)
/* We store the number of remaining assigned values
* in the shared config entry. */
- PR_snprintf(remaining_vals, sizeof(remaining_vals),"%" NSPRIu64,
+ snprintf(remaining_vals, sizeof(remaining_vals),"%" NSPRIu64,
config_entry->remaining);
/* set up our replace modify operation */
@@ -2709,7 +2709,7 @@ dna_update_next_range(struct configEntry *config_entry,
int ret = 0;
/* Try to set the new next range in the config entry. */
- PR_snprintf(nextrange_value, sizeof(nextrange_value), "%" NSPRIu64 "-%" NSPRIu64,
+ snprintf(nextrange_value, sizeof(nextrange_value), "%" NSPRIu64 "-%" NSPRIu64,
lower, upper);
/* set up our replace modify operation */
@@ -2778,8 +2778,8 @@ dna_activate_next_range(struct configEntry *config_entry)
int ret = 0;
/* Setup the modify operation for the config entry */
- PR_snprintf(maxval_val, sizeof(maxval_val),"%" NSPRIu64, config_entry->next_range_upper);
- PR_snprintf(nextval_val, sizeof(nextval_val),"%" NSPRIu64, config_entry->next_range_lower);
+ snprintf(maxval_val, sizeof(maxval_val),"%" NSPRIu64, config_entry->next_range_upper);
+ snprintf(nextval_val, sizeof(nextval_val),"%" NSPRIu64, config_entry->next_range_lower);
maxval_vals[0] = maxval_val;
maxval_vals[1] = 0;
@@ -4411,8 +4411,8 @@ static int dna_extend_exop(Slapi_PBlock *pb)
char highstr[16];
/* Create the exop response */
- PR_snprintf(lowstr, sizeof(lowstr), "%" NSPRIu64, lower);
- PR_snprintf(highstr, sizeof(highstr), "%" NSPRIu64, upper);
+ snprintf(lowstr, sizeof(lowstr), "%" NSPRIu64, lower);
+ snprintf(highstr, sizeof(highstr), "%" NSPRIu64, upper);
range_low.bv_val = lowstr;
range_low.bv_len = strlen(range_low.bv_val);
range_high.bv_val = highstr;
@@ -4588,7 +4588,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
*lower = *upper - release + 1;
/* try to set the new maxval in the config entry */
- PR_snprintf(max_value, sizeof(max_value),"%" NSPRIu64, (*lower - 1));
+ snprintf(max_value, sizeof(max_value),"%" NSPRIu64, (*lower - 1));
/* set up our replace modify operation */
replace_val[0] = max_value;
diff --git a/ldap/servers/plugins/posix-winsync/posix-winsync.c b/ldap/servers/plugins/posix-winsync/posix-winsync.c
index a7e024d90..63444e58a 100644
--- a/ldap/servers/plugins/posix-winsync/posix-winsync.c
+++ b/ldap/servers/plugins/posix-winsync/posix-winsync.c
@@ -234,7 +234,7 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
{
int ds_is_enabled = 1; /* default to true */
int ad_is_enabled = 1; /* default to true */
- unsigned long adval = 0; /* raw account val from ad entry */
+ uint64_t adval = 0; /* raw account val from ad entry */
int isvirt = 0;
/* get the account lock state of the ds entry */
@@ -270,9 +270,8 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
if (update_entry) {
slapi_entry_attr_set_ulong(update_entry, "userAccountControl", adval);
slapi_log_err(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
- "<-- sync_acct_disable - %s AD account [%s] - "
- "new value is [%ld]\n", (ds_is_enabled) ? "enabled" : "disabled",
- slapi_entry_get_dn_const(update_entry), adval);
+ "<-- sync_acct_disable - %s AD account [%s] - new value is [%" NSPRIu64 "]\n",
+ (ds_is_enabled) ? "enabled" : "disabled", slapi_entry_get_dn_const(update_entry), adval);
} else {
/* iterate through the mods - if there is already a mod
for userAccountControl, change it - otherwise, add it */
@@ -327,9 +326,8 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
mod_bval->bv_len = strlen(acctvalstr);
}
slapi_log_err(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
- "<-- sync_acct_disable - %s AD account [%s] - "
- "new value is [%ld]\n", (ds_is_enabled) ? "enabled" : "disabled",
- slapi_entry_get_dn_const(ad_entry), adval);
+ "<-- sync_acct_disable - %s AD account [%s] - new value is [%" NSPRIu64 "]\n",
+ (ds_is_enabled) ? "enabled" : "disabled", slapi_entry_get_dn_const(ad_entry), adval);
}
}
diff --git a/ldap/servers/plugins/replication/repl5_init.c b/ldap/servers/plugins/replication/repl5_init.c
index 0945f7b07..9549dcfe7 100644
--- a/ldap/servers/plugins/replication/repl5_init.c
+++ b/ldap/servers/plugins/replication/repl5_init.c
@@ -208,7 +208,7 @@ get_repl_session_id (Slapi_PBlock *pb, char *idstr, CSN **csn)
/* Avoid "Connection is NULL and hence cannot access SLAPI_CONN_ID" */
if (opid) {
slapi_pblock_get (pb, SLAPI_CONN_ID, &connid);
- PR_snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%" NSPRIu64 " op=%d",
+ snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%" NSPRIu64 " op=%d",
connid, opid);
}
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index 948f38d50..80580f912 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -865,7 +865,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
* the session's conn id and op id to identify the the supplier.
*/
/* junkrc = ruv_get_first_id_and_purl(supplier_ruv, &junkrid, &locking_purl); */
- PR_snprintf(locking_session, sizeof(locking_session), "conn=%" NSPRIu64 " id=%d",
+ snprintf(locking_session, sizeof(locking_session), "conn=%" NSPRIu64 " id=%d",
connid, opid);
locking_purl = &locking_session[0];
if (replica_get_exclusive_access(replica, &isInc, connid, opid,
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 6fe8d2e41..5e67e0af4 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -360,7 +360,7 @@ _usn_mod_next_usn(LDAPMod ***mods, Slapi_Backend *be)
/* add next USN to the mods; "be" contains the usn counter */
usn_berval.bv_val = counter_buf;
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter));
usn_berval.bv_len = strlen(usn_berval.bv_val);
bvals[0] = &usn_berval;
@@ -670,7 +670,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
/* nsslapd-entryusn-global: on*/
/* root dse shows ...
* lastusn: <num> */
- PR_snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 1, "%s", USN_LAST_USN);
+ snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 1, "%s", USN_LAST_USN);
for (be = slapi_get_first_backend(&cookie); be;
be = slapi_get_next_backend(cookie)) {
if (be->be_usn_counter) {
@@ -681,10 +681,10 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
/* get a next USN counter from be_usn_counter;
* then minus 1 from it (except if be_usn_counter has value 0) */
if (slapi_counter_get_value(be->be_usn_counter)) {
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
} else {
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
}
usn_berval.bv_len = strlen(usn_berval.bv_val);
slapi_entry_attr_replace(e, attr, vals);
@@ -693,7 +693,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
/* nsslapd-entryusn-global: off (default) */
/* root dse shows ...
* lastusn;<backend>: <num> */
- PR_snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 2, "%s;", USN_LAST_USN);
+ snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 2, "%s;", USN_LAST_USN);
attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN + 1;
for (be = slapi_get_first_backend(&cookie); be;
be = slapi_get_next_backend(cookie)) {
@@ -704,10 +704,10 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
/* get a next USN counter from be_usn_counter;
* then minus 1 from it (except if be_usn_counter has value 0) */
if (slapi_counter_get_value(be->be_usn_counter)) {
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
} else {
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
}
usn_berval.bv_len = strlen(usn_berval.bv_val);
@@ -716,7 +716,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
attr = (char *)slapi_ch_realloc(attr, attr_len);
attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN;
}
- PR_snprintf(attr_subp, attr_len - USN_LAST_USN_ATTR_CORE_LEN,
+ snprintf(attr_subp, attr_len - USN_LAST_USN_ATTR_CORE_LEN,
"%s", be->be_name);
slapi_entry_attr_replace(e, attr, vals);
}
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index dfcc73512..757792b4a 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -26,7 +26,7 @@
#define MSETF(_attr, _x) do { \
char tmp_atype[37]; \
- PR_snprintf(tmp_atype, sizeof(tmp_atype), _attr, _x); \
+ snprintf(tmp_atype, sizeof(tmp_atype), _attr, _x); \
MSET(tmp_atype); \
} while (0)
@@ -86,7 +86,7 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
MSET("entryCacheHits");
sprintf(buf, "%lu", (long unsigned int)tries);
MSET("entryCacheTries");
- sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
+ sprintf(buf, "%lu", (long unsigned int)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
MSET("entryCacheHitRatio");
sprintf(buf, "%lu", (long unsigned int)size);
MSET("currentEntryCacheSize");
diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.c b/ldap/servers/slapd/back-ldbm/perfctrs.c
index 2bd18bd6c..5929dea7d 100644
--- a/ldap/servers/slapd/back-ldbm/perfctrs.c
+++ b/ldap/servers/slapd/back-ldbm/perfctrs.c
@@ -49,7 +49,7 @@
static void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env);
static void perfctr_add_to_entry( Slapi_Entry *e, char *type,
- PRUint32 countervalue );
+ uint64_t countervalue );
/* Init perf ctrs */
void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
@@ -304,17 +304,13 @@ perfctrs_as_entry( Slapi_Entry *e, perfctrs_private *priv, DB_ENV *db_env )
*/
for ( i = 0; i < SLAPI_LDBM_PERFCTR_AT_MAP_COUNT; ++i ) {
perfctr_add_to_entry( e, perfctr_at_map[i].pam_type,
- *((PRUint32 *)((char *)perf + perfctr_at_map[i].pam_offset)));
+ *((uint64_t *)((char *)perf + perfctr_at_map[i].pam_offset)));
}
}
static void
-perfctr_add_to_entry( Slapi_Entry *e, char *type, PRUint32 countervalue )
+perfctr_add_to_entry( Slapi_Entry *e, char *type, uint64_t countervalue )
{
- /*
- * XXXmcs: the following line assumes that long's are 32 bits or larger,
- * which we assume in other places too I am sure.
- */
- slapi_entry_attr_set_ulong( e, type, (unsigned long)countervalue );
+ slapi_entry_attr_set_ulong( e, type, countervalue );
}
diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.h b/ldap/servers/slapd/back-ldbm/perfctrs.h
index 65a7850b4..57be1d19d 100644
--- a/ldap/servers/slapd/back-ldbm/perfctrs.h
+++ b/ldap/servers/slapd/back-ldbm/perfctrs.h
@@ -11,46 +11,48 @@
# include <config.h>
#endif
+#include <inttypes.h>
+
/* Structure definition for performance data */
/* This stuff goes in shared memory, so make sure the packing is consistent */
struct _performance_counters {
- PRUint32 sequence_number;
- PRUint32 lock_region_wait_rate;
- PRUint32 deadlock_rate;
- PRUint32 configured_locks;
- PRUint32 current_locks;
- PRUint32 max_locks;
- PRUint32 lockers;
- PRUint32 current_lock_objects;
- PRUint32 max_lock_objects;
- PRUint32 lock_conflicts;
- PRUint32 lock_request_rate;
- PRUint32 log_region_wait_rate;
- PRUint32 log_write_rate;
- PRUint32 log_bytes_since_checkpoint;
- PRUint32 cache_size_bytes;
- PRUint32 page_access_rate;
- PRUint32 cache_hit;
- PRUint32 cache_try;
- PRUint32 page_create_rate;
- PRUint32 page_read_rate;
- PRUint32 page_write_rate;
- PRUint32 page_ro_evict_rate;
- PRUint32 page_rw_evict_rate;
- PRUint32 hash_buckets;
- PRUint32 hash_search_rate;
- PRUint32 longest_chain_length;
- PRUint32 hash_elements_examine_rate;
- PRUint32 pages_in_use;
- PRUint32 dirty_pages;
- PRUint32 clean_pages;
- PRUint32 page_trickle_rate;
- PRUint32 cache_region_wait_rate;
- PRUint32 active_txns;
- PRUint32 commit_rate;
- PRUint32 abort_rate;
- PRUint32 txn_region_wait_rate;
+ uint64_t sequence_number;
+ uint64_t lock_region_wait_rate;
+ uint64_t deadlock_rate;
+ uint64_t configured_locks;
+ uint64_t current_locks;
+ uint64_t max_locks;
+ uint64_t lockers;
+ uint64_t current_lock_objects;
+ uint64_t max_lock_objects;
+ uint64_t lock_conflicts;
+ uint64_t lock_request_rate;
+ uint64_t log_region_wait_rate;
+ uint64_t log_write_rate;
+ uint64_t log_bytes_since_checkpoint;
+ uint64_t cache_size_bytes;
+ uint64_t page_access_rate;
+ uint64_t cache_hit;
+ uint64_t cache_try;
+ uint64_t page_create_rate;
+ uint64_t page_read_rate;
+ uint64_t page_write_rate;
+ uint64_t page_ro_evict_rate;
+ uint64_t page_rw_evict_rate;
+ uint64_t hash_buckets;
+ uint64_t hash_search_rate;
+ uint64_t longest_chain_length;
+ uint64_t hash_elements_examine_rate;
+ uint64_t pages_in_use;
+ uint64_t dirty_pages;
+ uint64_t clean_pages;
+ uint64_t page_trickle_rate;
+ uint64_t cache_region_wait_rate;
+ uint64_t active_txns;
+ uint64_t commit_rate;
+ uint64_t abort_rate;
+ uint64_t txn_region_wait_rate;
};
typedef struct _performance_counters performance_counters;
diff --git a/ldap/servers/slapd/back-ldbm/vlv_srch.h b/ldap/servers/slapd/back-ldbm/vlv_srch.h
index d1eba082c..6322f805f 100644
--- a/ldap/servers/slapd/back-ldbm/vlv_srch.h
+++ b/ldap/servers/slapd/back-ldbm/vlv_srch.h
@@ -92,7 +92,7 @@ struct vlvIndex
time_t vlv_lastchecked;
/* The number of uses this search has received since start up */
- PRUint32 vlv_uses;
+ uint64_t vlv_uses;
struct backend* vlv_be; /* need backend to remove the index when done */
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index 004aeae52..bcafa4ea3 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -395,7 +395,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
* 3 = The number of operations attempted that were blocked
* by max threads.
*/
- PR_snprintf(maxthreadbuf, sizeof(maxthreadbuf), "%d:%"NSPRIu64":%"NSPRIu64"",
+ snprintf(maxthreadbuf, sizeof(maxthreadbuf), "%d:%"NSPRIu64":%"NSPRIu64"",
maxthreadstate, ct->c[i].c_maxthreadscount,
ct->c[i].c_maxthreadsblocked);
@@ -426,32 +426,32 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
PR_ExitMonitor(ct->c[i].c_mutex);
}
- PR_snprintf( buf, sizeof(buf), "%d", nconns );
+ snprintf( buf, sizeof(buf), "%d", nconns );
val.bv_val = buf;
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "currentconnections", vals );
- PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(num_conns));
+ snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(num_conns));
val.bv_val = buf;
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "totalconnections", vals );
- PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(conns_in_maxthreads));
+ snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(conns_in_maxthreads));
val.bv_val = buf;
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "currentconnectionsatmaxthreads", vals );
- PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(max_threads_count));
+ snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(max_threads_count));
val.bv_val = buf;
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "maxthreadsperconnhits", vals );
- PR_snprintf( buf, sizeof(buf), "%d", (ct!=NULL?ct->size:0) );
+ snprintf( buf, sizeof(buf), "%d", (ct!=NULL?ct->size:0) );
val.bv_val = buf;
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "dtablesize", vals );
- PR_snprintf( buf, sizeof(buf), "%d", nreadwaiters );
+ snprintf( buf, sizeof(buf), "%d", nreadwaiters );
val.bv_val = buf;
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "readwaiters", vals );
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 7bbd2f4e5..abacc57d8 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3088,14 +3088,14 @@ slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
}
void
-slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
+slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, uint64_t l)
{
char value[16];
struct berval bv;
struct berval *bvals[2];
bvals[0] = &bv;
bvals[1] = NULL;
- sprintf(value,"%lu",l);
+ sprintf(value,"%" NSPRIu64, l);
bv.bv_val = value;
bv.bv_len = strlen( value );
slapi_entry_attr_replace( e, type, bvals );
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 2f43a98c4..afedd5b4a 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -2327,11 +2327,11 @@ vslapd_log_error(
char buffer[SLAPI_LOG_BUFSIZ];
char sev_name[10];
int blen = TBUFSIZE;
- char *vbuf;
+ char *vbuf = NULL;
int header_len = 0;
int err = 0;
- if ((vbuf = PR_vsmprintf(fmt, ap)) == NULL) {
+ if (vasprintf(&vbuf, fmt, ap) == -1) {
log__error_emergency("CRITICAL: vslapd_log_error, Unable to format message", 1 , locked);
return -1;
}
@@ -2381,10 +2381,10 @@ vslapd_log_error(
/* blen = strlen(buffer); */
/* This truncates again .... But we have the nice smprintf above! */
if (subsystem == NULL) {
- PR_snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s",
+ snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s",
get_log_sev_name(sev_level, sev_name), vbuf);
} else {
- PR_snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s - %s",
+ snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s - %s",
get_log_sev_name(sev_level, sev_name), subsystem, vbuf);
}
@@ -2418,7 +2418,7 @@ vslapd_log_error(
g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
}
- PR_smprintf_free (vbuf);
+ slapi_ch_free_string(&vbuf);
return( 0 );
}
@@ -2520,8 +2520,7 @@ static int vslapd_log_access(char *fmt, va_list ap)
time_t tnl;
/* We do this sooner, because that we we can use the message in other calls */
- vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
- if (! vlen) {
+ if ((vlen = vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap)) == -1){
log__error_emergency("CRITICAL: vslapd_log_access, Unable to format message", 1 ,0);
return -1;
}
diff --git a/ldap/servers/slapd/monitor.c b/ldap/servers/slapd/monitor.c
index 0917bc83a..f1fb38f2c 100644
--- a/ldap/servers/slapd/monitor.c
+++ b/ldap/servers/slapd/monitor.c
@@ -54,25 +54,25 @@ monitor_info(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *ret
attrlist_replace( &e->e_attrs, "version", vals );
slapi_ch_free( (void **) &val.bv_val );
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%d", g_get_active_threadcnt() );
+ val.bv_len = snprintf( buf, sizeof(buf), "%d", g_get_active_threadcnt() );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "threads", vals );
connection_table_as_entry(the_connection_table, e);
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_initiated) );
+ val.bv_len = snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_initiated) );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "opsinitiated", vals );
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_completed) );
+ val.bv_len = snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_completed) );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "opscompleted", vals );
- val.bv_len = PR_snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_entries_sent() );
+ val.bv_len = snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_entries_sent() );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "entriessent", vals );
- val.bv_len = PR_snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_bytes_sent() );
+ val.bv_len = snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_bytes_sent() );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "bytessent", vals );
@@ -88,12 +88,12 @@ monitor_info(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *ret
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "starttime", vals );
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%d", be_nbackends_public() );
+ val.bv_len = snprintf( buf, sizeof(buf), "%d", be_nbackends_public() );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "nbackends", vals );
#ifdef THREAD_SUNOS5_LWP
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%d", thr_getconcurrency() );
+ val.bv_len = snprintf( buf, sizeof(buf), "%d", thr_getconcurrency() );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "concurrency", vals );
#endif
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 1bd8fc8e1..725fa1ca2 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1954,7 +1954,7 @@ void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long
* \param type Attribute type in which you want to set the value.
* \param l Unsigned long value that you want to assign to the attribute.
*/
-void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
+void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, uint64_t l);
/**
* Check if an attribute is set in the entry
@@ -6746,12 +6746,12 @@ void slapi_destroy_task(void *arg);
Slapi_Counter *slapi_counter_new(void);
void slapi_counter_init(Slapi_Counter *counter);
void slapi_counter_destroy(Slapi_Counter **counter);
-PRUint64 slapi_counter_increment(Slapi_Counter *counter);
-PRUint64 slapi_counter_decrement(Slapi_Counter *counter);
-PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue);
-PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue);
-PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue);
-PRUint64 slapi_counter_get_value(Slapi_Counter *counter);
+uint64_t slapi_counter_increment(Slapi_Counter *counter);
+uint64_t slapi_counter_decrement(Slapi_Counter *counter);
+uint64_t slapi_counter_add(Slapi_Counter *counter, uint64_t addvalue);
+uint64_t slapi_counter_subtract(Slapi_Counter *counter, uint64_t subvalue);
+uint64_t slapi_counter_set_value(Slapi_Counter *counter, uint64_t newvalue);
+uint64_t slapi_counter_get_value(Slapi_Counter *counter);
/* Binder-based (connection centric) resource limits */
/*
diff --git a/ldap/servers/slapd/slapi_counter.c b/ldap/servers/slapd/slapi_counter.c
index c3ac846b5..d0696ebba 100644
--- a/ldap/servers/slapd/slapi_counter.c
+++ b/ldap/servers/slapd/slapi_counter.c
@@ -12,38 +12,17 @@
#include "slap.h"
-#ifdef SOLARIS
-PRUint64 _sparcv9_AtomicSet(PRUint64 *address, PRUint64 newval);
-PRUint64 _sparcv9_AtomicAdd(PRUint64 *address, PRUint64 val);
-PRUint64 _sparcv9_AtomicSub(PRUint64 *address, PRUint64 val);
-#endif
-
#ifdef HPUX
#ifdef ATOMIC_64BIT_OPERATIONS
#include <machine/sys/inline.h>
#endif
#endif
-#ifdef ATOMIC_64BIT_OPERATIONS
-#if defined(LINUX) && !HAVE_64BIT_ATOMIC_OP_FUNCS
-/* On systems that don't have the 64-bit GCC atomic builtins, we need to
- * implement our own atomic functions using inline assembly code. */
-PRUint64 __sync_add_and_fetch_8(PRUint64 *ptr, PRUint64 addval);
-PRUint64 __sync_sub_and_fetch_8(PRUint64 *ptr, PRUint64 subval);
-#define __sync_add_and_fetch __sync_add_and_fetch_8
-#define __sync_sub_and_fetch __sync_sub_and_fetch_8
-#endif
-#endif /* ATOMIC_64BIT_OPERATIONS */
-
-
/*
* Counter Structure
*/
typedef struct slapi_counter {
- PRUint64 value;
-#ifndef ATOMIC_64BIT_OPERATIONS
- Slapi_Mutex *lock;
-#endif
+ uint64_t value;
} slapi_counter;
/*
@@ -72,13 +51,6 @@ Slapi_Counter *slapi_counter_new()
void slapi_counter_init(Slapi_Counter *counter)
{
if (counter != NULL) {
-#ifndef ATOMIC_64BIT_OPERATIONS
- /* Create the lock if necessary. */
- if (counter->lock == NULL) {
- counter->lock = slapi_new_mutex();
- }
-#endif
-
/* Set the value to 0. */
slapi_counter_set_value(counter, 0);
}
@@ -93,9 +65,6 @@ void slapi_counter_init(Slapi_Counter *counter)
void slapi_counter_destroy(Slapi_Counter **counter)
{
if ((counter != NULL) && (*counter != NULL)) {
-#ifndef ATOMIC_64BIT_OPERATIONS
- slapi_destroy_mutex((*counter)->lock);
-#endif
slapi_ch_free((void **)counter);
}
}
@@ -105,7 +74,7 @@ void slapi_counter_destroy(Slapi_Counter **counter)
*
* Atomically increments a Slapi_Counter.
*/
-PRUint64 slapi_counter_increment(Slapi_Counter *counter)
+uint64_t slapi_counter_increment(Slapi_Counter *counter)
{
return slapi_counter_add(counter, 1);
}
@@ -117,7 +86,7 @@ PRUint64 slapi_counter_increment(Slapi_Counter *counter)
* that this will not prevent you from wrapping
* around 0.
*/
-PRUint64 slapi_counter_decrement(Slapi_Counter *counter)
+uint64_t slapi_counter_decrement(Slapi_Counter *counter)
{
return slapi_counter_subtract(counter, 1);
}
@@ -127,28 +96,20 @@ PRUint64 slapi_counter_decrement(Slapi_Counter *counter)
*
* Atomically add a value to a Slapi_Counter.
*/
-PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue)
+uint64_t slapi_counter_add(Slapi_Counter *counter, uint64_t addvalue)
{
- PRUint64 newvalue = 0;
+ uint64_t newvalue = 0;
#ifdef HPUX
- PRUint64 prev = 0;
+ uint64_t prev = 0;
#endif
if (counter == NULL) {
return newvalue;
}
-#ifndef ATOMIC_64BIT_OPERATIONS
- slapi_lock_mutex(counter->lock);
- counter->value += addvalue;
- newvalue = counter->value;
- slapi_unlock_mutex(counter->lock);
+#ifndef HPUX
+ newvalue = __atomic_add_fetch_8(&(counter->value), addvalue, __ATOMIC_SEQ_CST);
#else
-#ifdef LINUX
- newvalue = __sync_add_and_fetch(&(counter->value), addvalue);
-#elif defined(SOLARIS)
- newvalue = _sparcv9_AtomicAdd(&(counter->value), addvalue);
-#elif defined(HPUX)
/* fetchadd only works with values of 1, 4, 8, and 16. In addition, it requires
* it's argument to be an integer constant. */
if (addvalue == 1) {
@@ -173,7 +134,6 @@ PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue)
} while (prev != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), newvalue, _LDHINT_NONE));
}
#endif
-#endif /* ATOMIC_64BIT_OPERATIONS */
return newvalue;
}
@@ -184,28 +144,20 @@ PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue)
* Atomically subtract a value from a Slapi_Counter. Note
* that this will not prevent you from wrapping around 0.
*/
-PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue)
+uint64_t slapi_counter_subtract(Slapi_Counter *counter, uint64_t subvalue)
{
- PRUint64 newvalue = 0;
+ uint64_t newvalue = 0;
#ifdef HPUX
- PRUint64 prev = 0;
+ uint64_t prev = 0;
#endif
if (counter == NULL) {
return newvalue;
}
-#ifndef ATOMIC_64BIT_OPERATIONS
- slapi_lock_mutex(counter->lock);
- counter->value -= subvalue;
- newvalue = counter->value;
- slapi_unlock_mutex(counter->lock);
+#ifndef HPUX
+ newvalue = __atomic_sub_fetch_8(&(counter->value), subvalue, __ATOMIC_SEQ_CST);
#else
-#ifdef LINUX
- newvalue = __sync_sub_and_fetch(&(counter->value), subvalue);
-#elif defined(SOLARIS)
- newvalue = _sparcv9_AtomicSub(&(counter->value), subvalue);
-#elif defined(HPUX)
/* fetchadd only works with values of -1, -4, -8, and -16. In addition, it requires
* it's argument to be an integer constant. */
if (subvalue == 1) {
@@ -230,7 +182,6 @@ PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue)
} while (prev != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), newvalue, _LDHINT_NONE));
}
#endif
-#endif /* ATOMIC_64BIT_OPERATIONS */
return newvalue;
}
@@ -240,21 +191,15 @@ PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue)
*
* Atomically sets the value of a Slapi_Counter.
*/
-PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue)
+uint64_t slapi_counter_set_value(Slapi_Counter *counter, uint64_t newvalue)
{
- PRUint64 value = 0;
+ uint64_t value = 0;
if (counter == NULL) {
return value;
}
-#ifndef ATOMIC_64BIT_OPERATIONS
- slapi_lock_mutex(counter->lock);
- counter->value = newvalue;
- slapi_unlock_mutex(counter->lock);
- return newvalue;
-#else
-#ifdef LINUX
+#ifndef HPUX
/* Use our own inline assembly for an atomic set if
* the builtins aren't available. */
#if !HAVE_64BIT_ATOMIC_CAS_FUNC
@@ -290,18 +235,15 @@ PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue)
#endif
return newvalue;
-#else
+#else /* HAVE_64BIT_ATOMIC_CAS_FUNC */
while (1) {
- value = counter->value;
- if (__sync_bool_compare_and_swap(&(counter->value), value, newvalue)) {
+ value = __atomic_load_8(&(counter->value), __ATOMIC_SEQ_CST);
+ if (__atomic_compare_exchange_8(&(counter->value), &value, newvalue, PR_FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)){
return newvalue;
}
}
-#endif /* CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH */
-#elif defined(SOLARIS)
- _sparcv9_AtomicSet(&(counter->value), newvalue);
- return newvalue;
-#elif defined(HPUX)
+#endif
+#else /* HPUX */
do {
value = counter->value;
/* Put value in a register for cmpxchg to compare against */
@@ -309,7 +251,6 @@ PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue)
} while (value != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), newvalue, _LDHINT_NONE));
return newvalue;
#endif
-#endif /* ATOMIC_64BIT_OPERATIONS */
}
/*
@@ -317,20 +258,15 @@ PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue)
*
* Returns the value of a Slapi_Counter.
*/
-PRUint64 slapi_counter_get_value(Slapi_Counter *counter)
+uint64_t slapi_counter_get_value(Slapi_Counter *counter)
{
- PRUint64 value = 0;
+ uint64_t value = 0;
if (counter == NULL) {
return value;
}
-#ifndef ATOMIC_64BIT_OPERATIONS
- slapi_lock_mutex(counter->lock);
- value = counter->value;
- slapi_unlock_mutex(counter->lock);
-#else
-#ifdef LINUX
+#ifndef HPUX
/* Use our own inline assembly for an atomic get if
* the builtins aren't available. */
#if !HAVE_64BIT_ATOMIC_CAS_FUNC
@@ -367,124 +303,22 @@ PRUint64 slapi_counter_get_value(Slapi_Counter *counter)
#else
: "memory", "eax", "ebx", "ecx", "edx", "cc");
#endif
-#else
+#else /* HAVE_64BIT_ATOMIC_CAS_FUNC */
while (1) {
- value = counter->value;
- if (__sync_bool_compare_and_swap(&(counter->value), value, value)) {
+ value = __atomic_load_8(&(counter->value), __ATOMIC_SEQ_CST);
+ if (__atomic_compare_exchange_8(&(counter->value), &value, value, PR_FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)){
break;
}
}
-#endif /* CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH */
-#elif defined(SOLARIS)
- while (1) {
- value = counter->value;
- if (value == _sparcv9_AtomicSet(&(counter->value), value)) {
- break;
- }
- }
-#elif defined(HPUX)
+#endif
+#else /* HPUX */
do {
value = counter->value;
/* Put value in a register for cmpxchg to compare against */
_Asm_mov_to_ar(_AREG_CCV, value);
} while (value != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), value, _LDHINT_NONE));
#endif
-#endif /* ATOMIC_64BIT_OPERATIONS */
return value;
}
-#ifdef ATOMIC_64BIT_OPERATIONS
-#if defined(LINUX) && !HAVE_64BIT_ATOMIC_OP_FUNCS
-/* On systems that don't have the 64-bit GCC atomic builtins, we need to
- * implement our own atomic add and subtract functions using inline
- * assembly code. */
-PRUint64 __sync_add_and_fetch_8(PRUint64 *ptr, PRUint64 addval)
-{
- PRUint64 retval = 0;
-
- /*
- * %0 = *ptr
- * %1 = retval
- * %2 = addval
- */
- __asm__ __volatile__(
-#ifdef CPU_x86
- /* Save the PIC register */
- " pushl %%ebx;"
-#endif /* CPU_x86 */
- /* Put value of *ptr in EDX:EAX */
- "retryadd: movl %0, %%eax;"
- " movl 4%0, %%edx;"
- /* Put addval in ECX:EBX */
- " movl %2, %%ebx;"
- " movl 4+%2, %%ecx;"
- /* Add value from EDX:EAX to value in ECX:EBX */
- " addl %%eax, %%ebx;"
- " adcl %%edx, %%ecx;"
- /* If EDX:EAX and *ptr are the same, replace ptr with ECX:EBX */
- " lock; cmpxchg8b %0;"
- " jnz retryadd;"
- /* Put new value into retval */
- " movl %%ebx, %1;"
- " movl %%ecx, 4%1;"
-#ifdef CPU_x86
- /* Restore the PIC register */
- " popl %%ebx"
-#endif /* CPU_x86 */
- : "+o" (*ptr), "=m" (retval)
- : "m" (addval)
-#ifdef CPU_x86
- : "memory", "eax", "ecx", "edx", "cc");
-#else
- : "memory", "eax", "ebx", "ecx", "edx", "cc");
-#endif
-
- return retval;
-}
-
-PRUint64 __sync_sub_and_fetch_8(PRUint64 *ptr, PRUint64 subval)
-{
- PRUint64 retval = 0;
-
- /*
- * %0 = *ptr
- * %1 = retval
- * %2 = subval
- */
- __asm__ __volatile__(
-#ifdef CPU_x86
- /* Save the PIC register */
- " pushl %%ebx;"
-#endif /* CPU_x86 */
- /* Put value of *ptr in EDX:EAX */
- "retrysub: movl %0, %%eax;"
- " movl 4%0, %%edx;"
- /* Copy EDX:EAX to ECX:EBX */
- " movl %%eax, %%ebx;"
- " movl %%edx, %%ecx;"
- /* Subtract subval from value in ECX:EBX */
- " subl %2, %%ebx;"
- " sbbl 4+%2, %%ecx;"
- /* If EDX:EAX and ptr are the same, replace *ptr with ECX:EBX */
- " lock; cmpxchg8b %0;"
- " jnz retrysub;"
- /* Put new value into retval */
- " movl %%ebx, %1;"
- " movl %%ecx, 4%1;"
-#ifdef CPU_x86
- /* Restore the PIC register */
- " popl %%ebx"
-#endif /* CPU_x86 */
- : "+o" (*ptr), "=m" (retval)
- : "m" (subval)
-#ifdef CPU_x86
- : "memory", "eax", "ecx", "edx", "cc");
-#else
- : "memory", "eax", "ebx", "ecx", "edx", "cc");
-#endif
-
- return retval;
-}
-#endif /* LINUX && !HAVE_64BIT_ATOMIC_OP_FUNCS */
-#endif /* ATOMIC_64BIT_OPERATIONS */
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index 841922ff2..b0c873dae 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -711,7 +711,7 @@ static void
add_counter_to_value(Slapi_Entry *e, const char *type, PRUint64 countervalue)
{
char value[40];
- PR_snprintf(value,sizeof(value),"%" NSPRIu64, countervalue);
+ snprintf(value,sizeof(value),"%" NSPRIu64, countervalue);
slapi_entry_attr_set_charptr( e, type, value);
}
| 0 |
6ddfaa021a9db243ffe89527bf6f70bbd08435cc
|
389ds/389-ds-base
|
Ticket 433 - multiple bugs in start-dirsrv, stop-dirsrv, restart-dirsrv scripts
Bug Description: These scripts check /etc/sysconfig/ to for DS instances. The
issue is that when you install 389-admin it creates a file
called dirsrv-admin. Then these scripts report errors when
trying to start/stop/restart.
Fix Description: First, ignore instances that use "admin" for the indentifier.
Second, don't allow setup-ds.pl to use "admin" as the ID. I
also needed to add extra checks for silent installations(which
do not use the DSDialogs.pm). Also ensured the correct/detailed
error is displayed and logged when there is a failure.
https://fedorahosted.org/389/ticket/433
Reviewed by: Noriko(Thanks!)
|
commit 6ddfaa021a9db243ffe89527bf6f70bbd08435cc
Author: Mark Reynolds <[email protected]>
Date: Tue Jan 29 13:41:05 2013 -0500
Ticket 433 - multiple bugs in start-dirsrv, stop-dirsrv, restart-dirsrv scripts
Bug Description: These scripts check /etc/sysconfig/ to for DS instances. The
issue is that when you install 389-admin it creates a file
called dirsrv-admin. Then these scripts report errors when
trying to start/stop/restart.
Fix Description: First, ignore instances that use "admin" for the indentifier.
Second, don't allow setup-ds.pl to use "admin" as the ID. I
also needed to add extra checks for silent installations(which
do not use the DSDialogs.pm). Also ensured the correct/detailed
error is displayed and logged when there is a failure.
https://fedorahosted.org/389/ticket/433
Reviewed by: Noriko(Thanks!)
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index 68bb584a4..a3b8fe76e 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -122,7 +122,9 @@ sub sanityCheckParams {
}
}
- if (!isValidServerID($inf->{slapd}->{ServerIdentifier})) {
+ if($inf->{slapd}->{ServerIdentifier} eq "admin"){
+ return ('error_invalid_serverid - "admin" is reserved for the Admininstration Server, please choose a different server identifier');
+ } elsif (!isValidServerID($inf->{slapd}->{ServerIdentifier})) {
return ('error_invalid_serverid', $inf->{slapd}->{ServerIdentifier});
} elsif (-d $inf->{slapd}->{config_dir}) {
return ('error_server_already_exists', $inf->{slapd}->{config_dir});
diff --git a/ldap/admin/src/scripts/DSDialogs.pm b/ldap/admin/src/scripts/DSDialogs.pm
index 08c8b2b10..00765e0ee 100644
--- a/ldap/admin/src/scripts/DSDialogs.pm
+++ b/ldap/admin/src/scripts/DSDialogs.pm
@@ -99,7 +99,11 @@ my $dsserverid = new Dialog (
my $res = $DialogManager::SAME;
my $path = $self->{manager}->{setup}->{configdir} . "/slapd-" . $ans;
if (!isValidServerID($ans)) {
- $self->{manager}->alert("error_invalid_serverid", $ans);
+ if($ans eq "admin"){
+ $self->{manager}->alert("error_reserved_serverid", $ans);
+ } else {
+ $self->{manager}->alert("error_invalid_serverid", $ans);
+ }
} elsif (-d $path) {
$self->{manager}->alert("error_server_already_exists", $path);
} else {
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index 0f72571f6..70df23a20 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -137,7 +137,12 @@ sub isValidDN {
sub isValidServerID {
my $servid = shift;
my $validchars = '#%:\w@_-';
- return $servid =~ /^[$validchars]+$/o;
+ if($servid eq "admin"){
+ # "admin" is reserved for the admin server
+ return 0;
+ } else {
+ return $servid =~ /^[$validchars]+$/o;
+ }
}
# we want the name of the effective user id of this process e.g. if someone did
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index 76fb176db..74dc1cf40 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -50,6 +50,10 @@ if [ "$#" -eq 0 ]; then
for i in $initconfig_dir/@package_name@-*; do
regex=s,$initconfig_dir/@package_name@-,,g
inst=`echo $i | sed -e $regex`
+ # check for admin server ID used by 389-admin pkg, and ignore it
+ if [ "$inst" = "admin" ]; then
+ continue
+ fi
echo Restarting instance \"$inst\"
restart_instance $inst
if [ "$?" -ne 0 ]; then
diff --git a/ldap/admin/src/scripts/setup-ds.pl.in b/ldap/admin/src/scripts/setup-ds.pl.in
index 7613ed8c1..044444b05 100644
--- a/ldap/admin/src/scripts/setup-ds.pl.in
+++ b/ldap/admin/src/scripts/setup-ds.pl.in
@@ -88,8 +88,14 @@ if (@errs) {
if ($setup->{update}) {
$setup->msg($FATAL, 'error_updating');
} else {
- $setup->msg($FATAL, 'error_creating_dsinstance',
+ if($setup->{inf}->{slapd}->{ServerIdentifier} eq "admin"){
+ # 'admin' is reserved for the admin server - log the correct error
+ $setup->msg($FATAL, 'error_creating_dsinstance_adminid',
$setup->{inf}->{slapd}->{ServerIdentifier});
+ } else {
+ $setup->msg($FATAL, 'error_creating_dsinstance',
+ $setup->{inf}->{slapd}->{ServerIdentifier});
+ }
}
$setup->doExit(1);
} else {
diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in
index a8a0c002c..401722ee9 100644
--- a/ldap/admin/src/scripts/setup-ds.res.in
+++ b/ldap/admin/src/scripts/setup-ds.res.in
@@ -88,6 +88,7 @@ error_creating_suffix = Could not create the suffix '%s'. Error: %s\n\n
setup_exiting = Exiting . . .\nLog file is '%s'\n\n
error_creating_dsinstance = Error: Could not create directory server instance '%s'.\n
+error_creating_dsinstance_adminid = Error: Could not create directory server instance '%s', instance name 'admin' reserved for the Administration Server.\n
created_dsinstance = Your new DS instance '%s' was successfully created.\n
no_mapvalue_for_key = The map value '%s' for key '%s' did not map to a value in any of the given information files.\n
error_opening_ldiftmpl = Could not open the LDIF template file '%s'. Error: %s\n
@@ -104,6 +105,7 @@ program, or low port restriction. Please choose another value for\
ServerPort. Error: $!\n
error_invalid_serverid = The ServerIdentifier '%s' contains invalid characters. It must\
contain only alphanumeric characters and the following: #%:@_-\n\n
+error_reserved_serverid = The ServerIdentifier '%s" is reserved for the Administration Server, please choose a different server identifier.\n
error_opening_scripttmpl = Could not open the script template file '%s'. Error: %s\n
error_creating_directory = Could not create directory '%s'. Error: %s\n
error_chowning_directory = Could not change ownership of directory '%s' to userid '%s': Error: %s\n
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index 291c82110..cfd6477b5 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -127,6 +127,10 @@ if [ "$#" -eq 0 ]; then
for i in $initconfig_dir/@package_name@-*; do
regex=s,$initconfig_dir/@package_name@-,,g
inst=`echo $i | sed -e $regex`
+ # check for admin server ID used by 389-admin pkg, and ignore it
+ if [ "$inst" = "admin" ]; then
+ continue
+ fi
echo Starting instance \"$inst\"
start_instance $inst
if [ "$?" -ne 0 ]; then
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index 4d88585ad..28adde599 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -75,6 +75,10 @@ if [ "$#" -eq 0 ]; then
for i in $initconfig_dir/@package_name@-*; do
regex=s,$initconfig_dir/@package_name@-,,g
inst=`echo $i | sed -e $regex`
+ # check for admin server ID used by 389-admin pkg, and ignore it
+ if [ "$inst" = "admin" ]; then
+ continue
+ fi
echo Stopping instance \"$inst\"
stop_instance $inst
if [ "$?" -ne 0 ]; then
| 0 |
104968b67bbfbc89cf5311c7ca7be973dd86baed
|
389ds/389-ds-base
|
Revert "Ticket 49432 - filter optimise crash"
This reverts commit 5c89dd8f9c8eb77c967574412d049d55565bb364.
|
commit 104968b67bbfbc89cf5311c7ca7be973dd86baed
Author: Mark Reynolds <[email protected]>
Date: Fri Aug 24 16:21:32 2018 -0400
Revert "Ticket 49432 - filter optimise crash"
This reverts commit 5c89dd8f9c8eb77c967574412d049d55565bb364.
diff --git a/Makefile.am b/Makefile.am
index 4cc0fe767..fffae1331 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2150,7 +2150,6 @@ TESTS = test_slapd \
test_slapd_SOURCES = test/main.c \
test/libslapd/test.c \
test/libslapd/counters/atomic.c \
- test/libslapd/filter/optimise.c \
test/libslapd/pblock/analytics.c \
test/libslapd/pblock/v3_compat.c \
test/libslapd/operation/v3_compat.c \
diff --git a/ldap/servers/slapd/filter.c b/ldap/servers/slapd/filter.c
index 46a2266d2..87ec0dee0 100644
--- a/ldap/servers/slapd/filter.c
+++ b/ldap/servers/slapd/filter.c
@@ -1561,28 +1561,22 @@ filter_prioritise_element(Slapi_Filter **list, Slapi_Filter **head, Slapi_Filter
static void
filter_merge_subfilter(Slapi_Filter **list, Slapi_Filter **f_prev, Slapi_Filter **f_cur, Slapi_Filter **f_next) {
-
- /* First, graft in the new item between f_cur and f_cur -> f_next */
- Slapi_Filter *remainder = (*f_cur)->f_next;
- (*f_cur)->f_next = (*f_cur)->f_list;
- /* Go to the end of the newly grafted list, and put in our remainder. */
- Slapi_Filter *f_cur_tail = *f_cur;
- while (f_cur_tail->f_next != NULL) {
- f_cur_tail = f_cur_tail->f_next;
- }
- f_cur_tail->f_next = remainder;
-
- /* Now indicate to the caller what the next element is. */
- *f_next = (*f_cur)->f_next;
-
- /* Now that we have grafted our list in, cut out f_cur */
+ /* Cut our current AND/OR out */
if (*f_prev != NULL) {
- (*f_prev)->f_next = *f_next;
+ (*f_prev)->f_next = (*f_cur)->f_next;
} else if (*list == *f_cur) {
- *list = *f_next;
+ *list = (*f_cur)->f_next;
}
+ (*f_next) = (*f_cur)->f_next;
- /* Finally free the f_cur (and/or) */
+ /* Look ahead to the end of our list, without the f_cur. */
+ Slapi_Filter *f_cur_tail = *list;
+ while (f_cur_tail->f_next != NULL) {
+ f_cur_tail = f_cur_tail->f_next;
+ }
+ /* Now append our descendant into the tail */
+ f_cur_tail->f_next = (*f_cur)->f_list;
+ /* Finally free the remainder */
slapi_filter_free(*f_cur, 0);
}
diff --git a/test/libslapd/filter/optimise.c b/test/libslapd/filter/optimise.c
deleted file mode 100644
index bcf4ccd79..000000000
--- a/test/libslapd/filter/optimise.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/** 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 **/
-
-#include "../../test_slapd.h"
-
-/* To access filter optimise */
-#include <slapi-private.h>
-
-void
-test_libslapd_filter_optimise(void **state __attribute__((unused)))
-{
- char *test_filters[] = {
- "(&(uid=uid1)(sn=last1)(givenname=first1))",
- "(&(uid=uid1)(&(sn=last1)(givenname=first1)))",
- "(&(uid=uid1)(&(&(sn=last1))(&(givenname=first1))))",
- "(&(uid=*)(sn=last3)(givenname=*))",
- "(&(uid=*)(&(sn=last3)(givenname=*)))",
- "(&(uid=uid5)(&(&(sn=*))(&(givenname=*))))",
- "(&(objectclass=*)(uid=*)(sn=last*))",
- "(&(objectclass=*)(uid=*)(sn=last1))",
-
- "(|(uid=uid1)(sn=last1)(givenname=first1))",
- "(|(uid=uid1)(|(sn=last1)(givenname=first1)))",
- "(|(uid=uid1)(|(|(sn=last1))(|(givenname=first1))))",
- "(|(objectclass=*)(sn=last1)(|(givenname=first1)))",
- "(|(&(objectclass=*)(sn=last1))(|(givenname=first1)))",
- "(|(&(objectclass=*)(sn=last))(|(givenname=first1)))",
-
- "(&(uid=uid1)(!(cn=NULL)))",
- "(&(!(cn=NULL))(uid=uid1))",
- "(&(uid=*)(&(!(uid=1))(!(givenname=first1))))",
-
- "(&(|(uid=uid1)(uid=NULL))(sn=last1))",
- "(&(|(uid=uid1)(uid=NULL))(!(sn=NULL)))",
- "(&(|(uid=uid1)(sn=last2))(givenname=first1))",
- "(|(&(uid=uid1)(!(uid=NULL)))(sn=last2))",
- "(|(&(uid=uid1)(uid=NULL))(sn=last2))",
- "(&(uid=uid5)(sn=*)(cn=*)(givenname=*)(uid=u*)(sn=la*)(cn=full*)(givenname=f*)(uid>=u)(!(givenname=NULL)))",
- "(|(&(objectclass=*)(sn=last))(&(givenname=first1)))",
-
- "(&(uid=uid1)(sn=last1)(givenname=NULL))",
- "(&(uid=uid1)(&(sn=last1)(givenname=NULL)))",
- "(&(uid=uid1)(&(&(sn=last1))(&(givenname=NULL))))",
- "(&(uid=uid1)(&(&(sn=last1))(&(givenname=NULL)(sn=*)))(|(sn=NULL)))",
- "(&(uid=uid1)(&(&(sn=last*))(&(givenname=first*)))(&(sn=NULL)))",
-
- "(|(uid=NULL)(sn=NULL)(givenname=NULL))",
- "(|(uid=NULL)(|(sn=NULL)(givenname=NULL)))",
- "(|(uid=NULL)(|(|(sn=NULL))(|(givenname=NULL))))",
-
- "(uid>=uid3)",
- "(&(uid=*)(uid>=uid3))",
- "(|(uid>=uid3)(uid<=uid5))",
- "(&(uid>=uid3)(uid<=uid5))",
- "(|(&(uid>=uid3)(uid<=uid5))(uid=*))",
-
- "(|(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)(uid=*)"
- "(uid=*))",
- NULL
- };
-
- for (size_t i = 0; test_filters[i] != NULL; i++) {
- char *filter_str = slapi_ch_strdup(test_filters[i]);
-
- struct slapi_filter *filter = slapi_str2filter(filter_str);
- slapi_filter_optimise(filter);
- slapi_filter_free(filter, 1);
- slapi_ch_free_string(&filter_str);
- }
-}
-
diff --git a/test/libslapd/test.c b/test/libslapd/test.c
index 02c6c03a4..ffa650d5e 100644
--- a/test/libslapd/test.c
+++ b/test/libslapd/test.c
@@ -28,7 +28,6 @@ run_libslapd_tests(void)
cmocka_unit_test(test_libslapd_operation_v3c_target_spec),
cmocka_unit_test(test_libslapd_counters_atomic_usage),
cmocka_unit_test(test_libslapd_counters_atomic_overflow),
- cmocka_unit_test(test_libslapd_filter_optimise),
cmocka_unit_test(test_libslapd_pal_meminfo),
cmocka_unit_test(test_libslapd_util_cachesane),
};
diff --git a/test/test_slapd.h b/test/test_slapd.h
index efccaea78..ad4f73f86 100644
--- a/test/test_slapd.h
+++ b/test/test_slapd.h
@@ -26,9 +26,6 @@ int run_plugin_tests(void);
/* libslapd */
void test_libslapd_hello(void **state);
-/* libslapd-filter-optimise */
-void test_libslapd_filter_optimise(void **state);
-
/* libslapd-pblock-analytics */
void test_libslapd_pblock_analytics(void **state);
| 0 |
a4632aa66f4e3dfdc7ffebbcecc5a347198434ce
|
389ds/389-ds-base
|
Ticket 50056 - dsctl db2ldif throws an exception
Description: dsctl db2ldif throws an exception because of a typo in
a parameter name.
https://pagure.io/389-ds-base/issue/50056
Reviewed by: mreynolds(one line commit rule)
|
commit a4632aa66f4e3dfdc7ffebbcecc5a347198434ce
Author: Mark Reynolds <[email protected]>
Date: Thu Jan 10 12:49:10 2019 -0500
Ticket 50056 - dsctl db2ldif throws an exception
Description: dsctl db2ldif throws an exception because of a typo in
a parameter name.
https://pagure.io/389-ds-base/issue/50056
Reviewed by: mreynolds(one line commit rule)
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 78221dfa0..d76b34b08 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -2847,7 +2847,7 @@ class DirSrv(SimpleLDAPObject, object):
cmd.append('-a')
tnow = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
if bename:
- ldifname = os.path.join(self.ds_paths.ldif_dir, "%s-%s-%s.ldif" % (self.serverid, be_name, tnow))
+ ldifname = os.path.join(self.ds_paths.ldif_dir, "%s-%s-%s.ldif" % (self.serverid, bename, tnow))
else:
ldifname = os.path.join(self.ds_paths.ldif_dir, "%s-%s.ldif" % (self.serverid, tnow))
cmd.append(ldifname)
| 0 |
3571d7a5855cb1c222f83f98e03c340185e43152
|
389ds/389-ds-base
|
Bug 630097 - (cov#12143) NULL dereference in cos cache code
The tmpDn pointer is deferenced before checking if it is NULL. We
need to check if it is NULL first.
|
commit 3571d7a5855cb1c222f83f98e03c340185e43152
Author: Nathan Kinder <[email protected]>
Date: Mon Sep 13 15:05:52 2010 -0700
Bug 630097 - (cov#12143) NULL dereference in cos cache code
The tmpDn pointer is deferenced before checking if it is NULL. We
need to check if it is NULL first.
diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c
index fe8f53462..e20fd0dea 100644
--- a/ldap/servers/plugins/cos/cos_cache.c
+++ b/ldap/servers/plugins/cos/cos_cache.c
@@ -1383,7 +1383,7 @@ static int cos_cache_add_defn(
int ret = 0;
int tmplCount = 0;
cosDefinitions *theDef = 0;
- cosAttrValue *pTmpTmplDn = *tmpDn;
+ cosAttrValue *pTmpTmplDn = 0;
cosAttrValue *pDummyAttrVal = 0;
cosAttrValue *pAttrsIter = 0;
cosAttributes *pDummyAttributes = 0;
@@ -1396,9 +1396,15 @@ static int cos_cache_add_defn(
ret = -1;
goto out;
}
-
pSpecsIter = *spec;
+ if (!tmpDn) {
+ LDAPDebug( LDAP_DEBUG_ANY, "missing tmpDn\n",0,0,0);
+ ret = -1;
+ goto out;
+ }
+ pTmpTmplDn = *tmpDn;
+
/* we don't want cosspecifiers that can be supplied by the same scheme */
while( pSpecsIter )
{
| 0 |
7fb7f9baa421311a401e4a21292a7888f8ad6468
|
389ds/389-ds-base
|
Updated copyright info
|
commit 7fb7f9baa421311a401e4a21292a7888f8ad6468
Author: Nathan Kinder <[email protected]>
Date: Wed Mar 23 21:26:12 2005 +0000
Updated copyright info
diff --git a/ldap/libraries/libldif/line64.c b/ldap/libraries/libldif/line64.c
index e09d82500..7f9525f19 100644
--- a/ldap/libraries/libldif/line64.c
+++ b/ldap/libraries/libldif/line64.c
@@ -1,3 +1,8 @@
+/* --- BEGIN COPYRIGHT BLOCK ---
+ * Copyright (C) 2005 Red Hat, Inc.
+ * All rights reserved.
+ * --- END COPYRIGHT BLOCK --- */
+
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
diff --git a/ldap/servers/plugins/distrib/distrib.dsp b/ldap/servers/plugins/distrib/distrib.dsp
index ebf11f1e2..dffd5ceff 100644
--- a/ldap/servers/plugins/distrib/distrib.dsp
+++ b/ldap/servers/plugins/distrib/distrib.dsp
@@ -1,3 +1,8 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
+# Copyright (C) 2005 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
# Microsoft Developer Studio Project File - Name="distrib" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
diff --git a/ldapserver.spec b/ldapserver.spec
index b148dea41..1fdd532ef 100644
--- a/ldapserver.spec
+++ b/ldapserver.spec
@@ -1,3 +1,7 @@
+# BEGIN COPYRIGHT BLOCK
+# Copyright (C) 2005 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
Summary: Directory Server
Name: ldapserver
Version: 7.1
| 0 |
54bbaed10cd72d5e9809c6ef8d15c00bca6a5cdb
|
389ds/389-ds-base
|
Ticket 346 - version 4 Slow ldapmodify operation time
for large quantities of multi-valued attribute values
Bug Description: The reason for the performance degradation is that for
operations like add and delete of values and for updating the index for
each values a check has tobe done if it exists in the current attribute.
if the number of values grows the seaqrch time increases
Fix Description: Keep a secondary array of the indexes of the valuearray which is sorted.
To locate a value, a binary search can be used.
A design doc is available at: http://port389.org/wiki/Static_group_performance
https://fedorahosted.org/389/ticket/346
Reviewed by: RichM
|
commit 54bbaed10cd72d5e9809c6ef8d15c00bca6a5cdb
Author: Ludwig Krispenz <[email protected]>
Date: Wed Jul 17 15:54:50 2013 +0200
Ticket 346 - version 4 Slow ldapmodify operation time
for large quantities of multi-valued attribute values
Bug Description: The reason for the performance degradation is that for
operations like add and delete of values and for updating the index for
each values a check has tobe done if it exists in the current attribute.
if the number of values grows the seaqrch time increases
Fix Description: Keep a secondary array of the indexes of the valuearray which is sorted.
To locate a value, a binary search can be used.
A design doc is available at: http://port389.org/wiki/Static_group_performance
https://fedorahosted.org/389/ticket/346
Reviewed by: RichM
diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c
index 03b366c7d..8ab71352e 100644
--- a/ldap/servers/slapd/attr.c
+++ b/ldap/servers/slapd/attr.c
@@ -365,11 +365,9 @@ Slapi_Attr *
slapi_attr_dup(const Slapi_Attr *attr)
{
Slapi_Attr *newattr= slapi_attr_new();
- Slapi_Value **present_va= valueset_get_valuearray(&attr->a_present_values); /* JCM Mucking about inside the value set */
- Slapi_Value **deleted_va= valueset_get_valuearray(&attr->a_deleted_values); /* JCM Mucking about inside the value set */
slapi_attr_init(newattr, attr->a_type);
- valueset_add_valuearray( &newattr->a_present_values, present_va );
- valueset_add_valuearray( &newattr->a_deleted_values, deleted_va );
+ slapi_valueset_set_valueset( &newattr->a_deleted_values, &attr->a_deleted_values );
+ slapi_valueset_set_valueset( &newattr->a_present_values, &attr->a_present_values );
newattr->a_deletioncsn= csn_dup(attr->a_deletioncsn);
return newattr;
}
@@ -835,43 +833,11 @@ attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn)
}
/*
- * determine whether we should use an AVL tree of values or not
+ * add values and check for duplicate values
*/
- for ( i = 0; vals[i] != NULL; i++ ) ;
- numofvals = i;
-
- /*
- * detect duplicate values
- */
- if ( numofvals > 1 ) {
- /*
- * Several values to add: use an AVL tree to detect duplicates.
- */
- LDAPDebug( LDAP_DEBUG_TRACE,
- "slapi_entry_add_values: using an AVL tree to "
- "detect duplicate values\n", 0, 0, 0 );
-
- if (valueset_isempty(&a->a_present_values)) {
- /* if the attribute contains no values yet, just check the
- * input vals array for duplicates
- */
- Avlnode *vtree = NULL;
- rc= valuetree_add_valuearray(a, vals, &vtree, &duplicate_index);
- valuetree_free(&vtree);
- was_present_null = 1;
- } else {
- /* the attr and vals both contain values, check intersection */
- rc= valueset_intersectswith_valuearray(&a->a_present_values, a, vals, &duplicate_index);
- }
-
- } else if ( !valueset_isempty(&a->a_present_values) ) {
- /*
- * One or no value to add: don't bother constructing
- * an AVL tree, etc. since it probably isn't worth the time.
- */
- for ( i = 0; vals[i] != NULL; ++i ) {
- if ( slapi_attr_value_find( a, slapi_value_get_berval(vals[i]) ) == 0 ) {
- duplicate_index = i;
+ numofvals = valuearray_count(vals);
+ rc = slapi_valueset_add_attr_valuearray_ext (a, &a->a_present_values, vals, numofvals, SLAPI_VALUE_FLAG_DUPCHECK, &duplicate_index);
+ if ( rc != LDAP_SUCCESS) {
#if defined(USE_OLD_UNHASHED)
if (is_type_forbidden(a->a_type)) {
/* If the attr is in the forbidden list
@@ -884,22 +850,12 @@ attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn)
#else
rc = LDAP_TYPE_OR_VALUE_EXISTS;
#endif
- break;
}
- }
- }
-
- /*
- * add values if no duplicates detected
- */
- if(rc==LDAP_SUCCESS) {
- valueset_add_valuearray( &a->a_present_values, vals );
- }
/* In the case of duplicate value, rc == LDAP_TYPE_OR_VALUE_EXISTS or
* LDAP_OPERATIONS_ERROR
*/
- else if ( duplicate_index >= 0 ) {
+ if ( duplicate_index >= 0 ) {
char bvvalcopy[BUFSIZ];
char *duplicate_string = "null or non-ASCII";
@@ -940,7 +896,7 @@ attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn)
*/
int attr_replace(Slapi_Attr *a, Slapi_Value **vals)
{
- return valueset_replace(a, &a->a_present_values, vals);
+ return valueset_replace_valuearray(a, &a->a_present_values, vals);
}
int
diff --git a/ldap/servers/slapd/attrlist.c b/ldap/servers/slapd/attrlist.c
index 1f52bb874..8825e2bef 100644
--- a/ldap/servers/slapd/attrlist.c
+++ b/ldap/servers/slapd/attrlist.c
@@ -129,7 +129,7 @@ attrlist_merge_valuearray(Slapi_Attr **alist, const char *type, Slapi_Value **va
Slapi_Attr **a= NULL;
if (!vals) return;
attrlist_find_or_create(alist, type, &a);
- valueset_add_valuearray( &(*a)->a_present_values, vals );
+ slapi_valueset_add_valuearray( *a, &(*a)->a_present_values, vals );
}
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index 7ce426440..7abd6b781 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -1047,6 +1047,10 @@ slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr)
const char *syntaxoid = NULL;
int dn_syntax = 0; /* not DN, by default */
+ if (attr && attr->a_flags & SLAPI_ATTR_FLAG_SYNTAX_IS_DN)
+ /* it was checked before */
+ return(1);
+
if (attr && attr->a_plugin == NULL) {
slapi_attr_init_syntax (attr);
}
@@ -1055,6 +1059,8 @@ slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr)
dn_syntax = ((0 == strcmp(syntaxoid, NAMEANDOPTIONALUID_SYNTAX_OID))
|| (0 == strcmp(syntaxoid, DN_SYNTAX_OID)));
}
+ if (dn_syntax)
+ attr->a_flags |= SLAPI_ATTR_FLAG_SYNTAX_IS_DN;
}
return dn_syntax;
}
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 5cb56631c..3a2904ee0 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -2639,7 +2639,7 @@ import_foreman(void *param)
/* Setting new entrydn attribute value */
slapi_attr_init(new_entrydn, "entrydn");
- valueset_add_string(&new_entrydn->a_present_values,
+ valueset_add_string(new_entrydn, &new_entrydn->a_present_values,
/* new_dn: duped in valueset_add_string */
(const char *)new_dn,
CSN_TYPE_UNKNOWN, NULL);
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index c50201759..4b2b13a81 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -545,7 +545,7 @@ index_add_mods(
for (curr_attr = newe->ep_entry->e_attrs; curr_attr != NULL; curr_attr = curr_attr->a_next) {
if (slapi_attr_type_cmp( basetype, curr_attr->a_type, SLAPI_TYPE_CMP_BASE ) == 0) {
- valueset_add_valuearray(all_vals, attr_get_present_values(curr_attr));
+ slapi_valueset_join_attr_valueset(curr_attr, all_vals, &curr_attr->a_present_values);
}
}
@@ -566,7 +566,7 @@ index_add_mods(
for (curr_attr = olde->ep_entry->e_attrs; curr_attr != NULL; curr_attr = curr_attr->a_next) {
if (slapi_attr_type_cmp( mods[i]->mod_type, curr_attr->a_type, SLAPI_TYPE_CMP_EXACT ) == 0) {
- valueset_add_valuearray(mod_vals, attr_get_present_values(curr_attr));
+ slapi_valueset_join_attr_valueset(curr_attr, mod_vals, &curr_attr->a_present_values);
}
}
@@ -584,7 +584,7 @@ index_add_mods(
slapi_entry_attr_find( olde->ep_entry, mods[i]->mod_type, &curr_attr );
if ( mods_valueArray != NULL ) {
for ( j = 0; mods_valueArray[j] != NULL; j++ ) {
- Slapi_Value *rval = valuearray_remove_value(curr_attr, evals, mods_valueArray[j]);
+ Slapi_Value *rval = valueset_remove_value(curr_attr, all_vals, mods_valueArray[j]);
slapi_value_free( &rval );
}
}
@@ -593,12 +593,12 @@ index_add_mods(
* they don't exist, delete the equality index.
*/
for ( j = 0; deleted_valueArray[j] != NULL; j++ ) {
- if (valuearray_find(curr_attr, evals, deleted_valueArray[j]) == -1) {
+ if ( !slapi_valueset_find(curr_attr, all_vals, deleted_valueArray[j])) {
if (!(flags & BE_INDEX_EQUALITY)) {
flags |= BE_INDEX_EQUALITY;
}
} else {
- Slapi_Value *rval = valuearray_remove_value(curr_attr, deleted_valueArray, deleted_valueArray[j]);
+ Slapi_Value *rval = valueset_remove_value(curr_attr, mod_vals, deleted_valueArray[j]);
slapi_value_free( &rval );
j--;
/* indicates there was some conflict */
@@ -637,8 +637,8 @@ index_add_mods(
if (curr_attr) { /* found the type */
for (j = 0; mods_valueArray[j] != NULL; j++) {
/* mods_valueArray[j] is in curr_attr ==> return 0 */
- if (slapi_attr_value_find(curr_attr,
- slapi_value_get_berval(mods_valueArray[j]))) {
+ if ( !slapi_valueset_find(curr_attr, &curr_attr->a_present_values,
+ mods_valueArray[j])) {
/* The value is NOT in newe, remove it. */
Slapi_Value *rval;
rval = valuearray_remove_value(curr_attr,
@@ -677,7 +677,7 @@ index_add_mods(
for (curr_attr = olde->ep_entry->e_attrs; curr_attr != NULL; curr_attr = curr_attr->a_next) {
if (slapi_attr_type_cmp( mods[i]->mod_type, curr_attr->a_type, SLAPI_TYPE_CMP_EXACT ) == 0) {
- valueset_add_valuearray(mod_vals, attr_get_present_values(curr_attr));
+ slapi_valueset_join_attr_valueset(curr_attr, mod_vals, &curr_attr->a_present_values);
}
}
@@ -694,14 +694,14 @@ index_add_mods(
* also exist in a subtype.
*/
for (j = 0; deleted_valueArray && deleted_valueArray[j]; j++) {
- if ( valuearray_find(curr_attr, evals, deleted_valueArray[j]) == -1 ) {
+ if ( !slapi_valueset_find(curr_attr, all_vals, deleted_valueArray[j])) {
/* If the equality flag isn't already set, set it */
if (!(flags & BE_INDEX_EQUALITY)) {
flags |= BE_INDEX_EQUALITY;
}
} else {
/* Remove duplicate value from the mod list */
- Slapi_Value *rval = valuearray_remove_value(curr_attr, deleted_valueArray, deleted_valueArray[j]);
+ Slapi_Value *rval = valueset_remove_value(curr_attr, mod_vals, deleted_valueArray[j]);
slapi_value_free( &rval );
j--;
}
@@ -750,7 +750,7 @@ index_add_mods(
if (curr_attr) {
int found = 0;
for (j = 0; mods_valueArray[j] != NULL; j++ ) {
- if ( valuearray_find(curr_attr, evals, mods_valueArray[j]) > -1 ) {
+ if ( slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j])) {
/* The same value found in evals.
* We don't touch the equality index. */
found = 1;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attr.c b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
index 09f1a48ad..c13fd6d87 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_attr.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
@@ -437,7 +437,7 @@ ldbm_compute_evaluator(computed_attr_context *c,char* type,Slapi_Entry *e,slapi_
Slapi_Attr our_attr;
slapi_attr_init(&our_attr, numsubordinates);
our_attr.a_flags = SLAPI_ATTR_FLAG_OPATTR;
- valueset_add_string(&our_attr.a_present_values,"0",CSN_TYPE_UNKNOWN,NULL);
+ valueset_add_string(&our_attr, &our_attr.a_present_values,"0",CSN_TYPE_UNKNOWN,NULL);
rc = (*outputfn) (c, &our_attr, e);
attr_done(&our_attr);
return (rc);
@@ -454,9 +454,9 @@ ldbm_compute_evaluator(computed_attr_context *c,char* type,Slapi_Entry *e,slapi_
rc = slapi_entry_attr_find( e, numsubordinates, &read_attr );
if ( (0 != rc) || slapi_entry_attr_hasvalue(e,numsubordinates,"0") ) {
/* If not, or present and zero, we return FALSE, otherwise TRUE */
- valueset_add_string(&our_attr.a_present_values,"FALSE",CSN_TYPE_UNKNOWN,NULL);
+ valueset_add_string(&our_attr, &our_attr.a_present_values,"FALSE",CSN_TYPE_UNKNOWN,NULL);
} else {
- valueset_add_string(&our_attr.a_present_values,"TRUE",CSN_TYPE_UNKNOWN,NULL);
+ valueset_add_string(&our_attr, &our_attr.a_present_values,"TRUE",CSN_TYPE_UNKNOWN,NULL);
}
rc = (*outputfn) (c, &our_attr, e);
attr_done(&our_attr);
diff --git a/ldap/servers/slapd/computed.c b/ldap/servers/slapd/computed.c
index 8259deaad..7c99b45eb 100644
--- a/ldap/servers/slapd/computed.c
+++ b/ldap/servers/slapd/computed.c
@@ -148,7 +148,7 @@ compute_stock_evaluator(computed_attr_context *c,char* type,Slapi_Entry *e,slapi
Slapi_Attr our_attr;
slapi_attr_init(&our_attr, subschemasubentry);
our_attr.a_flags = SLAPI_ATTR_FLAG_OPATTR;
- valueset_add_string(&our_attr.a_present_values,SLAPD_SCHEMA_DN,CSN_TYPE_UNKNOWN,NULL);
+ valueset_add_string(&our_attr, &our_attr.a_present_values,SLAPD_SCHEMA_DN,CSN_TYPE_UNKNOWN,NULL);
rc = (*outputfn) (c, &our_attr, e);
attr_done(&our_attr);
return (rc);
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index f730ae0a1..ee7c18f28 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -237,8 +237,6 @@ str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, in
int freeval = 0;
int value_state= VALUE_NOTFOUND;
int attr_state= ATTRIBUTE_NOTFOUND;
- int maxvals;
- int del_maxvals;
if ( *s == '\n' || *s == '\0' ) {
break;
@@ -280,9 +278,7 @@ str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, in
slapi_ch_free_string(&ptype);
ptype=PL_strndup(type.bv_val, type.bv_len);
nvals = 0;
- maxvals = 0;
del_nvals = 0;
- del_maxvals = 0;
a = NULL;
}
@@ -503,25 +499,21 @@ str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, in
if(value_state==VALUE_DELETED)
{
/* consumes the value */
- valuearray_add_value_fast(
- &(*a)->a_deleted_values.va, /* JCM .va is private */
- svalue,
- del_nvals,
- &del_maxvals,
- 0/*!Exact*/,
- 1/*Passin*/ );
+ slapi_valueset_add_attr_value_ext(
+ *a,
+ &(*a)->a_deleted_values,
+ svalue,
+ SLAPI_VALUE_FLAG_PASSIN );
del_nvals++;
}
else
{
/* consumes the value */
- valuearray_add_value_fast(
- &(*a)->a_present_values.va, /* JCM .va is private */
- svalue,
- nvals,
- &maxvals,
- 0 /*!Exact*/,
- 1 /*Passin*/ );
+ slapi_valueset_add_attr_value_ext(
+ *a,
+ &(*a)->a_present_values,
+ svalue,
+ SLAPI_VALUE_FLAG_PASSIN);
nvals++;
}
if(attributedeletioncsn!=NULL)
@@ -603,8 +595,8 @@ typedef struct _entry_attrs {
typedef struct _str2entry_attr {
char *sa_type;
int sa_state;
- struct valuearrayfast sa_present_values;
- struct valuearrayfast sa_deleted_values;
+ struct slapi_value_set sa_present_values;
+ struct slapi_value_set sa_deleted_values;
int sa_numdups;
value_compare_fn_type sa_comparefn;
Avlnode *sa_vtree;
@@ -617,8 +609,8 @@ entry_attr_init(str2entry_attr *sa, const char *type, int state)
{
sa->sa_type= slapi_ch_strdup(type);
sa->sa_state= state;
- valuearrayfast_init(&sa->sa_present_values,NULL);
- valuearrayfast_init(&sa->sa_deleted_values,NULL);
+ slapi_valueset_init(&sa->sa_present_values);
+ slapi_valueset_init(&sa->sa_deleted_values);
sa->sa_numdups= 0;
sa->sa_comparefn = NULL;
sa->sa_vtree= NULL;
@@ -1106,66 +1098,20 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
{
/*
* for deleted values, we do not want to perform a dupcheck against
- * existing values. Also, we do not want to add it to the
- * avl tree (if one is being maintained)
- *
+ * existing values.
*/
- rc = 0; /* Presume no duplicate */
+ rc = slapi_valueset_add_attr_value_ext(&sa->sa_attr, &sa->sa_deleted_values,value, SLAPI_VALUE_FLAG_PASSIN);
}
- else if ( !check_for_duplicate_values )
+ else
{
- rc = LDAP_SUCCESS; /* presume no duplicate */
- } else {
- /* For value dup checking, we either use brute-force, if there's a small number */
- /* Or a tree-based approach if there's a large number. */
- /* The tree code is expensive, which is why we don't use it unless there's many attributes */
- rc = 0; /* Presume no duplicate */
- if (fast_dup_check)
- {
- /* Fast dup-checking */
- /* Do we now have so many values that we should switch to tree-based checking ? */
- if (sa->sa_present_values.num > STR2ENTRY_VALUE_DUPCHECK_THRESHOLD)
- {
- /* Make the tree from the existing attr values */
- rc= valuetree_add_valuearray( &sa->sa_attr, sa->sa_present_values.va, &sa->sa_vtree, NULL);
- /* Check if the value already exists, in the tree. */
- rc= valuetree_add_value( &sa->sa_attr, value, &sa->sa_vtree);
- fast_dup_check = 0;
- }
- else
- {
- /* JCM - need an efficient valuearray function to do this */
- /* Brute-force check */
- for ( j = 0; j < sa->sa_present_values.num; j++ )/* JCM innards */
- {
- if (0 == sa->sa_comparefn(slapi_value_get_berval(value),slapi_value_get_berval(sa->sa_present_values.va[j])))/* JCM innards */
- {
- /* Oops---this value matches one already present */
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- break;
- }
- }
- }
- }
- else
- {
- /* Check if the value already exists, in the tree. */
- rc = valuetree_add_value( &sa->sa_attr, value, &sa->sa_vtree);
- }
+ int flags = SLAPI_VALUE_FLAG_PASSIN;
+ if (check_for_duplicate_values) flags |= SLAPI_VALUE_FLAG_DUPCHECK;
+ rc = slapi_valueset_add_attr_value_ext(&sa->sa_attr, &sa->sa_present_values,value, flags);
}
if ( rc==LDAP_SUCCESS )
{
- if(value_state==VALUE_DELETED)
- {
- valuearrayfast_add_value_passin(&sa->sa_deleted_values,value);
- value= NULL; /* value was consumed */
- }
- else
- {
- valuearrayfast_add_value_passin(&sa->sa_present_values,value);
- value= NULL; /* value was consumed */
- }
+ value= NULL; /* value was consumed */
if(attributedeletioncsn!=NULL)
{
sa->sa_attributedeletioncsn= attributedeletioncsn;
@@ -1180,7 +1126,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
else
{
/* Failure adding to value tree */
- LDAPDebug( LDAP_DEBUG_ANY, "str2entry_dupcheck: unexpected failure %d constructing value tree\n", rc, 0, 0 );
+ LDAPDebug( LDAP_DEBUG_ANY, "str2entry_dupcheck: unexpected failure %d adding value\n", rc, 0, 0 );
slapi_entry_free( e ); e = NULL;
goto free_and_return;
}
@@ -1245,27 +1191,21 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
}
if(alist!=NULL)
{
- int maxvals = 0;
Slapi_Attr **a= NULL;
attrlist_find_or_create_locking_optional(alist, sa->sa_type, &a, PR_FALSE);
- valuearray_add_valuearray_fast( /* JCM should be calling a valueset function */
- &(*a)->a_present_values.va, /* JCM .va is private */
- sa->sa_present_values.va,
- 0, /* Currently there are no present values on the attribute */
- sa->sa_present_values.num,
- &maxvals,
- 1/*Exact*/,
- 1/*Passin*/);
+ slapi_valueset_add_attr_valuearray_ext(
+ *a,
+ &(*a)->a_present_values,
+ sa->sa_present_values.va,
+ sa->sa_present_values.num,
+ SLAPI_VALUE_FLAG_PASSIN, NULL);
sa->sa_present_values.num= 0; /* The values have been consumed */
- maxvals = 0;
- valuearray_add_valuearray_fast( /* JCM should be calling a valueset function */
- &(*a)->a_deleted_values.va, /* JCM .va is private */
- sa->sa_deleted_values.va,
- 0, /* Currently there are no deleted values on the attribute */
- sa->sa_deleted_values.num,
- &maxvals,
- 1/*Exact*/,
- 1/*Passin*/);
+ slapi_valueset_add_attr_valuearray_ext(
+ *a,
+ &(*a)->a_deleted_values,
+ sa->sa_deleted_values.va,
+ sa->sa_deleted_values.num,
+ SLAPI_VALUE_FLAG_PASSIN, NULL);
sa->sa_deleted_values.num= 0; /* The values have been consumed */
if(sa->sa_attributedeletioncsn!=NULL)
{
@@ -1312,9 +1252,8 @@ free_and_return:
for ( i = 0; i < nattrs; i++ )
{
slapi_ch_free((void **) &(attrs[ i ].sa_type));
- valuearrayfast_done(&attrs[ i ].sa_present_values);
- valuearrayfast_done(&attrs[ i ].sa_deleted_values);
- valuetree_free( &attrs[ i ].sa_vtree );
+ slapi_ch_free((void **) &(attrs[ i ].sa_present_values.va));
+ slapi_ch_free((void **) &(attrs[ i ].sa_deleted_values.va));
attr_done( &attrs[ i ].sa_attr );
}
if (tree_attr_checking)
@@ -1740,7 +1679,7 @@ entry2str_internal_put_attrlist( const Slapi_Attr *attrlist, int attr_state, int
* never be seen by any client. It will never be moved to the
* present values and is only used to preserve the AD-csn
*/
- valueset_add_string ((Slapi_ValueSet *)&a->a_deleted_values, "", CSN_TYPE_VALUE_DELETED, a->a_deletioncsn);
+ valueset_add_string (a, (Slapi_ValueSet *)&a->a_deleted_values, "", CSN_TYPE_VALUE_DELETED, a->a_deletioncsn);
}
entry2str_internal_put_valueset(a->a_type, a->a_deletioncsn, CSN_TYPE_ATTRIBUTE_DELETED, attr_state, &a->a_deleted_values, VALUE_DELETED, ecur, typebuf, typebuf_len, entry2str_ctrl);
@@ -2727,7 +2666,7 @@ slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value)
{
Slapi_Attr **a= NULL;
attrlist_find_or_create(&e->e_attrs, type, &a);
- valueset_add_string ( &(*a)->a_present_values, value, CSN_TYPE_UNKNOWN, NULL);
+ valueset_add_string ( *a, &(*a)->a_present_values, value, CSN_TYPE_UNKNOWN, NULL);
return 0;
}
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
index 200743d86..033535854 100644
--- a/ldap/servers/slapd/entrywsi.c
+++ b/ldap/servers/slapd/entrywsi.c
@@ -477,7 +477,7 @@ entry_add_present_values_wsi_single_valued(Slapi_Entry *e, const char *type, str
SLAPI_VALUE_FLAG_IGNOREERROR |
SLAPI_VALUE_FLAG_PRESERVECSNSET, NULL);
valuearray_update_csn (valuestoadd,CSN_TYPE_VALUE_UPDATED,csn);
- valueset_add_valuearray_ext(&a->a_present_values, valuestoadd, SLAPI_VALUE_FLAG_PASSIN);
+ slapi_valueset_add_attr_valuearray_ext (a, &a->a_present_values, valuestoadd, valuearray_count(valuestoadd), SLAPI_VALUE_FLAG_PASSIN, NULL);
slapi_ch_free ( (void **)&valuestoadd );
/*
* Now delete non-RDN values from a->a_present_values; and
@@ -514,7 +514,7 @@ entry_add_present_values_wsi_single_valued(Slapi_Entry *e, const char *type, str
Slapi_ValueSet vs;
/* Add each deleted value to the present list */
valuearray_update_csn(deletedvalues,CSN_TYPE_VALUE_UPDATED,csn);
- valueset_add_valuearray_ext(&a->a_present_values, deletedvalues, SLAPI_VALUE_FLAG_PASSIN);
+ slapi_valueset_add_attr_valuearray_ext (a, &a->a_present_values, deletedvalues, valuearray_count(deletedvalues), SLAPI_VALUE_FLAG_PASSIN, NULL);
/* Remove the deleted values from the values to add */
valueset_set_valuearray_passin(&vs,valuestoadd);
valueset_remove_valuearray(&vs, a, deletedvalues, SLAPI_VALUE_FLAG_IGNOREERROR, &v);
@@ -609,7 +609,7 @@ entry_add_present_values_wsi_multi_valued(Slapi_Entry *e, const char *type, stru
Slapi_ValueSet vs;
/* Add each deleted value to the present list */
valuearray_update_csn(deletedvalues,CSN_TYPE_VALUE_UPDATED,csn);
- valueset_add_valuearray_ext(&a->a_present_values, deletedvalues, SLAPI_VALUE_FLAG_PASSIN);
+ slapi_valueset_add_attr_valuearray_ext (a, &a->a_present_values, deletedvalues, valuearray_count(deletedvalues), SLAPI_VALUE_FLAG_PASSIN, NULL);
/* Remove the deleted values from the values to add */
valueset_set_valuearray_passin(&vs,valuestoadd);
valueset_remove_valuearray(&vs, a, deletedvalues, SLAPI_VALUE_FLAG_IGNOREERROR, &v);
@@ -744,7 +744,7 @@ entry_delete_present_values_wsi_single_valued(Slapi_Entry *e, const char *type,
valueset_update_csn_for_valuearray(&a->a_deleted_values, a, valuestodelete, CSN_TYPE_VALUE_DELETED, csn, &valuesupdated);
valuearray_free(&valuesupdated);
valuearray_update_csn(valuestodelete,CSN_TYPE_VALUE_DELETED,csn);
- valueset_add_valuearray_ext(&a->a_deleted_values, valuestodelete, SLAPI_VALUE_FLAG_PASSIN);
+ slapi_valueset_add_attr_valuearray_ext (a, &a->a_deleted_values, valuestodelete, valuearray_count(valuestodelete), SLAPI_VALUE_FLAG_PASSIN, NULL);
slapi_ch_free((void **)&valuestodelete);
resolve_attribute_state_single_valued(e, a, attr_state);
retVal= LDAP_SUCCESS;
@@ -838,7 +838,7 @@ entry_delete_present_values_wsi_multi_valued(Slapi_Entry *e, const char *type, s
valuearray_free(&valuesupdated);
valuearray_update_csn(valuestodelete,CSN_TYPE_VALUE_DELETED,csn);
- valueset_add_valuearray_ext(&a->a_deleted_values, valuestodelete, SLAPI_VALUE_FLAG_PASSIN);
+ slapi_valueset_add_attr_valuearray_ext (a, &a->a_deleted_values, valuestodelete, valuearray_count(valuestodelete), SLAPI_VALUE_FLAG_PASSIN, NULL);
/* all the elements in valuestodelete are passed;
* should free valuestodelete only (don't call valuearray_free)
* [622023] */
@@ -856,7 +856,8 @@ entry_delete_present_values_wsi_multi_valued(Slapi_Entry *e, const char *type, s
{
/* Add each deleted value to the deleted set */
valuearray_update_csn(deletedvalues,CSN_TYPE_VALUE_DELETED,csn);
- valueset_add_valuearray_ext(&a->a_deleted_values, deletedvalues, SLAPI_VALUE_FLAG_PASSIN);
+ slapi_valueset_add_attr_valuearray_ext (a,
+ &a->a_deleted_values, deletedvalues, valuearray_count(deletedvalues), SLAPI_VALUE_FLAG_PASSIN, NULL);
slapi_ch_free((void **)&deletedvalues);
if(valueset_isempty(&a->a_present_values))
{
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 25663d255..a5317b47e 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -167,13 +167,6 @@ int valuearray_first_value( Slapi_Value **va, Slapi_Value **v );
void valuearrayfast_init(struct valuearrayfast *vaf,Slapi_Value **va);
void valuearrayfast_done(struct valuearrayfast *vaf);
-void valuearrayfast_add_value(struct valuearrayfast *vaf,const Slapi_Value *v);
-void valuearrayfast_add_value_passin(struct valuearrayfast *vaf,Slapi_Value *v);
-void valuearrayfast_add_valuearrayfast(struct valuearrayfast *vaf,const struct valuearrayfast *vaf_add);
-
-int valuetree_add_value( const Slapi_Attr *sattr, const Slapi_Value *va, Avlnode **valuetreep);
-int valuetree_add_valuearray( const Slapi_Attr *sattr, Slapi_Value **va, Avlnode **valuetreep, int *duplicate_index);
-void valuetree_free( Avlnode **valuetreep );
/* Valueset functions */
@@ -184,15 +177,17 @@ int valueset_remove_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Va
int valueset_purge(Slapi_ValueSet *vs, const CSN *csn);
Slapi_Value **valueset_get_valuearray(const Slapi_ValueSet *vs);
size_t valueset_size(const Slapi_ValueSet *vs);
+void slapi_valueset_add_valuearray(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_add_valuearray(Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_add_valuearray_ext(Slapi_ValueSet *vs, Slapi_Value **addvals, PRUint32 flags);
-void valueset_add_string(Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn);
+void valueset_add_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn);
void valueset_update_csn(Slapi_ValueSet *vs, CSNType t, const CSN *csn);
void valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
int valueset_intersectswith_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **values, int *duplicate_index);
Slapi_ValueSet *valueset_dup(const Slapi_ValueSet *dupee);
void valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s);
-int valueset_replace(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals);
+int valueset_replace_valuearray(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals);
+int valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals, int dupcheck);
void valueset_update_csn_for_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestoupdate, CSNType t, const CSN *csn, Slapi_Value ***valuesupdated);
void valueset_update_csn_for_valuearray_ext(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestoupdate, CSNType t, const CSN *csn, Slapi_Value ***valuesupdated, int csnref_updated);
void valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals);
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 49626132d..7a91aa16d 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -5568,11 +5568,12 @@ va_locate_oc_val( Slapi_Value **va, const char *oc_name, const char *oc_oid )
* oc_unlock();
*/
static void
-va_expand_one_oc( const char *dn, Slapi_Value ***vap, const char *ocs )
+va_expand_one_oc( const char *dn, const Slapi_Attr *a, Slapi_ValueSet *vs, const char *ocs )
{
struct objclass *this_oc, *sup_oc;
- int p,i;
- Slapi_Value **newva;
+ int p;
+ Slapi_Value **va = vs->va;
+
this_oc = oc_find_nolock( ocs );
@@ -5589,29 +5590,18 @@ va_expand_one_oc( const char *dn, Slapi_Value ***vap, const char *ocs )
return; /* superior is unknown -- ignore */
}
- p = va_locate_oc_val( *vap, sup_oc->oc_name, sup_oc->oc_oid );
+ p = va_locate_oc_val( va, sup_oc->oc_name, sup_oc->oc_oid );
if ( p != -1 ) {
return; /* value already present -- done! */
}
- /* parent was not found. add to the end */
- for ( i = 0; (*vap)[i] != NULL; i++ ) {
- ;
- }
-
- /* prevent loops: stop if more than 1000 OC values are present */
- if ( i > 1000 ) {
+ if ( slapi_valueset_count(vs) > 1000 ) {
return;
}
- newva = (Slapi_Value **)slapi_ch_realloc( (char *)*vap,
- ( i + 2 )*sizeof(Slapi_Value *));
-
- newva[i] = slapi_value_new_string(sup_oc->oc_name);
- newva[i+1] = NULL;
-
- *vap = newva;
+ slapi_valueset_add_attr_value_ext(a, vs, slapi_value_new_string(sup_oc->oc_name), SLAPI_VALUE_FLAG_PASSIN);
+
LDAPDebug( LDAP_DEBUG_TRACE,
"Entry \"%s\": added missing objectClass value %s\n",
dn, sup_oc->oc_name, 0 );
@@ -5623,11 +5613,12 @@ va_expand_one_oc( const char *dn, Slapi_Value ***vap, const char *ocs )
* All missing superior classes are added to the objectClass attribute, as
* is 'top' if it is missing.
*/
-void
-slapi_schema_expand_objectclasses( Slapi_Entry *e )
+static void
+schema_expand_objectclasses_ext( Slapi_Entry *e, int lock)
{
Slapi_Attr *sa;
- Slapi_Value **va;
+ Slapi_Value *v;
+ Slapi_ValueSet *vs;
const char *dn = slapi_entry_get_dn_const( e );
int i;
@@ -5635,76 +5626,41 @@ slapi_schema_expand_objectclasses( Slapi_Entry *e )
return; /* no OC values -- nothing to do */
}
- va = attr_get_present_values( sa );
-
- if ( va == NULL || va[0] == NULL ) {
+ vs = &sa->a_present_values;
+ if ( slapi_valueset_isempty(vs) ) {
return; /* no OC values -- nothing to do */
}
- oc_lock_read();
+ if (lock)
+ oc_lock_read();
/*
* This loop relies on the fact that bv_expand_one_oc()
* always adds to the end
*/
- for ( i = 0; va[i] != NULL; ++i ) {
- if ( NULL != slapi_value_get_string(va[i]) ) {
- va_expand_one_oc( dn, &va, slapi_value_get_string(va[i]) );
- }
+ i = slapi_valueset_first_value(vs,&v);
+ while ( v != NULL) {
+ if ( NULL != slapi_value_get_string(v) ) {
+ va_expand_one_oc( dn, sa, &sa->a_present_values, slapi_value_get_string(v) );
+ }
+ i = slapi_valueset_next_value(vs, i, &v);
}
/* top must always be present */
- va_expand_one_oc( dn, &va, "top" );
-
- /*
- * Reset the present values in the set because we may have realloc'd it.
- * Note that this is the counterpart to the attr_get_present_values()
- * call we made above... nothing new has been allocated, but sa holds
- * a pointer to the original (pre realloc) va.
- */
- sa->a_present_values.va = va;
-
- oc_unlock();
+ va_expand_one_oc( dn, sa, &sa->a_present_values, "top" );
+ if (lock)
+ oc_unlock();
+}
+void
+slapi_schema_expand_objectclasses( Slapi_Entry *e )
+{
+ schema_expand_objectclasses_ext( e, 1);
}
void
schema_expand_objectclasses_nolock( Slapi_Entry *e )
{
- Slapi_Attr *sa;
- Slapi_Value **va;
- const char *dn = slapi_entry_get_dn_const( e );
- int i;
-
- if ( 0 != slapi_entry_attr_find( e, SLAPI_ATTR_OBJECTCLASS, &sa )) {
- return; /* no OC values -- nothing to do */
- }
-
- va = attr_get_present_values( sa );
-
- if ( va == NULL || va[0] == NULL ) {
- return; /* no OC values -- nothing to do */
- }
-
- /*
- * This loop relies on the fact that bv_expand_one_oc()
- * always adds to the end
- */
- for ( i = 0; va[i] != NULL; ++i ) {
- if ( NULL != slapi_value_get_string(va[i]) ) {
- va_expand_one_oc( dn, &va, slapi_value_get_string(va[i]) );
- }
- }
-
- /* top must always be present */
- va_expand_one_oc( dn, &va, "top" );
-
- /*
- * Reset the present values in the set because we may have realloc'd it.
- * Note that this is the counterpart to the attr_get_present_values()
- * call we made above... nothing new has been allocated, but sa holds
- * a pointer to the original (pre realloc) va.
- */
- sa->a_present_values.va = va;
+ schema_expand_objectclasses_ext( e, 0);
}
/* lock to protect both objectclass and schema_dse */
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index fff464654..0aa7aad06 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -450,8 +450,14 @@ struct slapi_value
* struct slapi_value_tree *vt;
* };
*/
+
+/* It is a useless layer, always use the valuarray fast version */
+#define VALUE_SORT_THRESHOLD 10
struct slapi_value_set
{
+ int num; /* The number of values in the array */
+ int max; /* The number of slots in the array */
+ int *sorted; /* sorted array of indices, if NULL va is not sorted */
struct slapi_value **va;
};
@@ -530,6 +536,8 @@ typedef struct asyntaxinfo {
#define SLAPI_ATTR_FLAG_NOLOCKING 0x0020 /* the init code doesn't lock the
tables */
#define SLAPI_ATTR_FLAG_KEEP 0x8000 /* keep when replacing all */
+#define SLAPI_ATTR_FLAG_SYNTAX_LOOKUP_DONE 0x010000 /* syntax lookup done, flag set */
+#define SLAPI_ATTR_FLAG_SYNTAX_IS_DN 0x020000 /* syntax lookup done, flag set */
/* This is the type of the function passed into attr_syntax_enumerate_attrs */
typedef int (*AttrEnumFunc)(struct asyntaxinfo *asi, void *arg);
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index f08540fe3..d171f994c 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -4658,6 +4658,7 @@ void slapi_ber_bvcpy(struct berval *bvd, const struct berval *bvs);
#define SLAPI_VALUE_FLAG_IGNOREERROR 0x2
#define SLAPI_VALUE_FLAG_PRESERVECSNSET 0x4
#define SLAPI_VALUE_FLAG_USENEWVALUE 0x8 /* see valueset_remove_valuearray */
+#define SLAPI_VALUE_FLAG_DUPCHECK 0x10 /* used in valueset_add... */
/**
* Creates an empty \c Slapi_ValueSet structure.
@@ -4752,6 +4753,7 @@ void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
* \see slapi_valueset_next_value()
*/
void slapi_valueset_add_value_ext(Slapi_ValueSet *vs, Slapi_Value *addval, unsigned long flags);
+int slapi_valueset_add_attr_value_ext(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *addval, unsigned long flags);
/**
* Gets the first value in a \c Slapi_ValueSet structure.
@@ -4806,6 +4808,16 @@ int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
*/
int slapi_valueset_count( const Slapi_ValueSet *vs);
+/**
+ * Checks if a \c Slapi_ValueSet structure has values
+ *
+ * \param vs Pointer to the \c Slapi_ValueSet structure of which
+ * you wish to get the count.
+ * \return 1 if there are no values contained in the \c Slapi_ValueSet structure.
+ * \return 0 if there are values contained in the \c Slapi_ValueSet structure.
+ */
+int slapi_valueset_isempty( const Slapi_ValueSet *vs);
+
/**
* Initializes a \c Slapi_ValueSet with copies of the values of a \c Slapi_Mod structure.
*
@@ -4837,6 +4849,7 @@ void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
* \see slapi_valueset_done()
*/
void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
+void slapi_valueset_join_attr_valueset(const Slapi_Attr *a, Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
/**
* Finds a requested value in a valueset.
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 1e8a53a6c..027056b42 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -839,9 +839,12 @@ int charray_normdn_add(char ***chararray, char *dn, char *errstr);
* the very least before we make them public.
*/
void valuearray_add_value(Slapi_Value ***vals, const Slapi_Value *addval);
-void valuearray_add_value_fast(Slapi_Value ***vals, Slapi_Value *addval, int nvals, int *maxvals, int exact, int passin);
void valuearray_add_valuearray( Slapi_Value ***vals, Slapi_Value **addvals, PRUint32 flags );
void valuearray_add_valuearray_fast( Slapi_Value ***vals, Slapi_Value **addvals, int nvals, int naddvals, int *maxvals, int exact, int passin );
+Slapi_Value * valueset_find_sorted (const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v, int *index);
+int valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *vi, int dupcheck);
+void valueset_array_to_sorted (const Slapi_Attr *a, Slapi_ValueSet *vs);
+int slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **addval, int nvals, unsigned long flags, int *dup_index);
int valuearray_find(const Slapi_Attr *a, Slapi_Value **va, const Slapi_Value *v);
int valuearray_dn_normalize_value(Slapi_Value **vals);
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index c4e3d5df8..76d03e17d 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -501,7 +501,8 @@ valuearray_purge(Slapi_Value ***va, const CSN *csn)
*va= NULL;
}
- return(0);
+ /* return the number of remaining values */
+ return(i);
}
size_t
@@ -530,51 +531,6 @@ valuearray_update_csn(Slapi_Value **va, CSNType t, const CSN *csn)
}
}
-/*
- * Shunt up the values to cover the empty slots.
- *
- * "compressed" means "contains no NULL's"
- *
- * Invariant for the outer loop:
- * va[0..i] is compressed &&
- * va[n..numvalues] contains just NULL's
- *
- * Invariant for the inner loop:
- * i<j<=k<=n && va[j..k] has been shifted left by (j-i) places &&
- * va[k..n] remains to be shifted left by (j-i) places
- *
- */
-void
-valuearray_compress(Slapi_Value **va,int numvalues)
-{
- int i = 0;
- int n= numvalues;
- while(i<n)
- {
- if ( va[i] != NULL ) {
- i++;
- } else {
- int k,j;
- j = i + 1;
- /* Find the length of the next run of NULL's */
- while( j<n && va[j] == NULL) { j++; }
- /* va[i..j] is all NULL && j<= n */
- for ( k = j; k<n; k++ )
- {
- va[k - (j-i)] = va[k];
- va[k] = NULL;
- }
- /* va[i..n] has been shifted down by j-i places */
- n = n - (j-i);
- /*
- * If va[i] in now non null, then bump i,
- * if not then we are done anyway (j==n) so can bump it.
- */
- i++;
- }
- }
-}
-
/* <=========================== Value Array Fast ==========================> */
void
@@ -615,237 +571,11 @@ valuearrayfast_add_value_passin(struct valuearrayfast *vaf,Slapi_Value *v)
vaf->num++;
}
-void
-valuearrayfast_add_valuearrayfast(struct valuearrayfast *vaf,const struct valuearrayfast *vaf_add)
-{
- valuearray_add_valuearray_fast(&vaf->va,vaf_add->va,vaf->num,vaf_add->num,&vaf->max,0/*Exact*/,0/*!PassIn*/);
- vaf->num+= vaf_add->num;
-}
-
-/* <=========================== ValueArrayIndexTree =======================> */
-
-static int valuetree_dupvalue_disallow( caddr_t d1, caddr_t d2 );
-static int valuetree_node_cmp( caddr_t d1, caddr_t d2 );
-static int valuetree_node_free( caddr_t data );
-
-/*
- * structure used within AVL value trees.
- */
-typedef struct valuetree_node
-{
- int index; /* index into the value array */
- Slapi_Value *sval; /* the actual value */
-} valuetree_node;
-
-/*
- * Create or update an AVL tree of values that can be used to speed up value
- * lookups. We store the index keys for the values in the AVL tree so
- * we can use a trivial comparison function.
- *
- * Returns:
- * LDAP_SUCCESS on success,
- * LDAP_TYPE_OR_VALUE_EXISTS if the value already exists,
- * LDAP_OPERATIONS_ERROR for some unexpected failure.
- *
- * Sets *valuetreep to the root of the AVL tree that was created. If a
- * non-zero value is returned, the tree is freed if free_on_error is non-zero
- * and *valuetreep is set to NULL.
- */
-int
-valuetree_add_valuearray( const Slapi_Attr *sattr, Slapi_Value **va, Avlnode **valuetreep, int *duplicate_index )
-{
- int rc= LDAP_SUCCESS;
-
- PR_ASSERT(sattr!=NULL);
- PR_ASSERT(valuetreep!=NULL);
-
- if ( duplicate_index ) {
- *duplicate_index = -1;
- }
-
- if ( !valuearray_isempty(va) )
- {
- Slapi_Value **keyvals;
- /* Convert the value array into key values */
- if ( slapi_attr_values2keys_sv( sattr, (Slapi_Value**)va, &keyvals, LDAP_FILTER_EQUALITY ) != 0 ) /* jcm cast */
- {
- LDAPDebug( LDAP_DEBUG_ANY,"slapi_attr_values2keys_sv for attribute %s failed\n", sattr->a_type, 0, 0 );
- rc= LDAP_OPERATIONS_ERROR;
- }
- else
- {
- int i;
- valuetree_node *vaip;
- for ( i = 0; rc==LDAP_SUCCESS && va[i] != NULL; ++i )
- {
- if ( keyvals[i] == NULL )
- {
- LDAPDebug( LDAP_DEBUG_ANY,"slapi_attr_values2keys_sv for attribute %s did not return enough key values\n", sattr->a_type, 0, 0 );
- rc= LDAP_OPERATIONS_ERROR;
- }
- else
- {
- vaip = (valuetree_node *)slapi_ch_malloc( sizeof( valuetree_node ));
- vaip->index = i;
- vaip->sval = keyvals[i];
- if (( rc = avl_insert( valuetreep, vaip, valuetree_node_cmp, valuetree_dupvalue_disallow )) != 0 )
- {
- slapi_ch_free( (void **)&vaip );
- /* Value must already be in there */
- rc= LDAP_TYPE_OR_VALUE_EXISTS;
- if ( duplicate_index ) {
- *duplicate_index = i;
- }
- }
- else
- {
- keyvals[i]= NULL;
- }
- }
- }
- /* start freeing at index i - the rest of them have already
- been moved into valuetreep
- the loop iteration will always do the +1, so we have
- to remove it if so */
- i = (i > 0) ? i-1 : 0;
- valuearray_free_ext( &keyvals, i );
- }
- }
- if(rc!=0)
- {
- valuetree_free( valuetreep );
- }
-
- return rc;
-}
-
-int
-valuetree_add_value( const Slapi_Attr *sattr, const Slapi_Value *v, Avlnode **valuetreep)
-{
- Slapi_Value *va[2];
- va[0]= (Slapi_Value*)v;
- va[1]= NULL;
- return valuetree_add_valuearray( sattr, va, valuetreep, NULL);
-}
-
-
-/*
- *
- * Find value "v" using AVL tree "valuetree"
- *
- * returns LDAP_SUCCESS if "v" was found, LDAP_NO_SUCH_ATTRIBUTE
- * if "v" was not found and LDAP_OPERATIONS_ERROR if some unexpected error occurs.
- */
-static int
-valuetree_find( const struct slapi_attr *a, const Slapi_Value *v, Avlnode *valuetree, int *index)
-{
- const Slapi_Value *oneval[2];
- Slapi_Value **keyvals;
- valuetree_node *vaip, tmpvain;
-
- PR_ASSERT(a!=NULL);
- PR_ASSERT(a->a_plugin!=NULL);
- PR_ASSERT(v!=NULL);
- PR_ASSERT(valuetree!=NULL);
- PR_ASSERT(index!=NULL);
-
- if ( a == NULL || v == NULL || valuetree == NULL )
- {
- return( LDAP_OPERATIONS_ERROR );
- }
-
- keyvals = NULL;
- oneval[0] = v;
- oneval[1] = NULL;
- if ( slapi_attr_values2keys_sv( a, (Slapi_Value**)oneval, &keyvals, LDAP_FILTER_EQUALITY ) != 0 /* jcm cast */
- || keyvals == NULL
- || keyvals[0] == NULL )
- {
- LDAPDebug( LDAP_DEBUG_ANY, "valuetree_find_and_replace: "
- "slapi_attr_values2keys_sv failed for type %s\n",
- a->a_type, 0, 0 );
- return( LDAP_OPERATIONS_ERROR );
- }
-
- tmpvain.index = 0;
- tmpvain.sval = keyvals[0];
- vaip = (valuetree_node *)avl_find( valuetree, &tmpvain, valuetree_node_cmp );
-
- if ( keyvals != NULL )
- {
- valuearray_free( &keyvals );
- }
-
- if (vaip == NULL)
- {
- return( LDAP_NO_SUCH_ATTRIBUTE );
- }
- else
- {
- *index= vaip->index;
- }
-
- return( LDAP_SUCCESS );
-}
-
-static int
-valuetree_dupvalue_disallow( caddr_t d1, caddr_t d2 )
-{
- return( 1 );
-}
-
-
-void
-valuetree_free( Avlnode **valuetreep )
-{
- if ( valuetreep != NULL && *valuetreep != NULL )
- {
- avl_free( *valuetreep, valuetree_node_free );
- *valuetreep = NULL;
- }
-}
-
-
-static int
-valuetree_node_free( caddr_t data )
-{
- if ( data!=NULL )
- {
- valuetree_node *vaip = (valuetree_node *)data;
-
- slapi_value_free(&vaip->sval);
- slapi_ch_free( (void **)&data );
- }
- return( 0 );
-}
-
-
-static int
-valuetree_node_cmp( caddr_t d1, caddr_t d2 )
-{
- const struct berval *bv1, *bv2;
- int rc;
-
- bv1 = slapi_value_get_berval(((valuetree_node *)d1)->sval);
- bv2 = slapi_value_get_berval(((valuetree_node *)d2)->sval);
-
- if ( bv1->bv_len < bv2->bv_len ) {
- rc = -1;
- } else if ( bv1->bv_len > bv2->bv_len ) {
- rc = 1;
- } else {
- rc = memcmp( bv1->bv_val, bv2->bv_val, bv1->bv_len );
- }
-
- return( rc );
-}
-
/* <=========================== Value Set =======================> */
-/*
- * JCM: All of these valueset functions are just forwarded to the
- * JCM: valuearray functions... waste of time. Inline them!
- */
+#define VALUESET_ARRAY_SORT_THRESHOLD 10
+#define VALUESET_ARRAY_MINSIZE 2
+#define VALUESET_ARRAY_MAXINCREMENT 4096
Slapi_ValueSet *
slapi_valueset_new()
@@ -864,6 +594,9 @@ slapi_valueset_init(Slapi_ValueSet *vs)
if(vs!=NULL)
{
vs->va= NULL;
+ vs->sorted = NULL;
+ vs->num = 0;
+ vs->max = 0;
}
}
@@ -877,6 +610,13 @@ slapi_valueset_done(Slapi_ValueSet *vs)
valuearray_free(&vs->va);
vs->va= NULL;
}
+ if (vs->sorted != NULL)
+ {
+ slapi_ch_free ((void **)&vs->sorted);
+ vs->sorted = NULL;
+ }
+ vs->num = 0;
+ vs->max = 0;
}
}
@@ -901,8 +641,22 @@ slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod)
void
valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals)
{
- slapi_valueset_init(vs);
- valueset_add_valuearray(vs,addvals);
+ int i, j=0;
+ slapi_valueset_init(vs);
+ vs->num = valuearray_count(addvals);
+ vs->max = vs->num + 1;
+ vs->va = (Slapi_Value **) slapi_ch_malloc( vs->max * sizeof(Slapi_Value *));
+ for ( i = 0, j = 0; i < vs->num; i++)
+ {
+ if ( addvals[i]!=NULL )
+ {
+ /* We copy the values */
+ vs->va[j] = slapi_value_dup(addvals[i]);
+ j++;
+ }
+ }
+ vs->va[j] = NULL;
+
}
void
@@ -910,6 +664,8 @@ valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals)
{
slapi_valueset_init(vs);
vs->va= addvals;
+ vs->num = valuearray_count(addvals);
+ vs->max = vs->num + 1;
}
void
@@ -919,6 +675,15 @@ slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
valueset_add_valueset(vs1,vs2);
}
+void
+slapi_valueset_join_attr_valueset(const Slapi_Attr *a, Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
+{
+ if (slapi_valueset_isempty(vs1))
+ valueset_add_valueset(vs1,vs2);
+ else
+ slapi_valueset_add_attr_valuearray_ext (a, vs1, vs2->va, vs2->num, 0, NULL);
+}
+
int
slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v )
{
@@ -934,15 +699,21 @@ slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v)
int
slapi_valueset_count( const Slapi_ValueSet *vs)
{
- int r=0;
if (NULL != vs)
{
- if(!valuearray_isempty(vs->va))
- {
- r= valuearray_count(vs->va);
- }
+ return (vs->num);
}
- return r;
+ return 0;
+}
+
+int
+slapi_valueset_isempty( const Slapi_ValueSet *vs)
+{
+ if (NULL != vs)
+ {
+ return (vs->num == 0);
+ }
+ return 1;
}
int
@@ -956,12 +727,15 @@ Slapi_Value *
slapi_valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v)
{
Slapi_Value *r= NULL;
- if(!valuearray_isempty(vs->va))
- {
- int i= valuearray_find(a,vs->va,v);
- if(i!=-1)
- {
- r= vs->va[i];
+ if(vs->num > 0 )
+ {
+ if (vs->sorted) {
+ r = valueset_find_sorted(a,vs,v,NULL);
+ } else {
+ int i= valuearray_find(a,vs->va,v);
+ if(i!=-1) {
+ r= vs->va[i];
+ }
}
}
return r;
@@ -970,17 +744,46 @@ slapi_valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_V
/*
* The value is found in the set, removed and returned.
* The caller is responsible for freeing the value.
+ *
+ * The _sorted function also handles the cleanup of the sorted array
*/
Slapi_Value *
-valueset_remove_value(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slapi_Value *v)
+valueset_remove_value_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slapi_Value *v)
{
Slapi_Value *r= NULL;
- if(!valuearray_isempty(vs->va))
- {
- r= valuearray_remove_value(a, vs->va, v);
+ int i, position = 0;
+ r = valueset_find_sorted(a,vs,v,&position);
+ if (r) {
+ /* the value was found, remove from valuearray */
+ int index = vs->sorted[position];
+ memmove(&vs->sorted[position],&vs->sorted[position+1],(vs->num - position)*sizeof(int));
+ memmove(&vs->va[index],&vs->va[index+1],(vs->num - index)*sizeof(Slapi_Value *));
+ vs->num--;
+ /* unfortunately the references in the sorted array
+ * to values past the removed one are no longer correct
+ * need to adjust */
+ for (i=0; i < vs->num; i++) {
+ if (vs->sorted[i] > index) vs->sorted[i]--;
+ }
}
return r;
}
+Slapi_Value *
+valueset_remove_value(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slapi_Value *v)
+{
+ if (vs->sorted) {
+ return (valueset_remove_value_sorted(a, vs, v));
+ } else {
+ Slapi_Value *r= NULL;
+ if(!valuearray_isempty(vs->va))
+ {
+ r= valuearray_remove_value(a, vs->va, v);
+ if (r)
+ vs->num--;
+ }
+ return r;
+ }
+}
/*
* Remove any values older than the CSN.
@@ -989,11 +792,25 @@ int
valueset_purge(Slapi_ValueSet *vs, const CSN *csn)
{
int r= 0;
- if(!valuearray_isempty(vs->va))
- {
+ if(!valuearray_isempty(vs->va)) {
+ /* valuearray_purge is not valueset and sorting aware,
+ * maybe need to rewrite, at least keep the valueset
+ * consistent
+ */
r= valuearray_purge(&vs->va, csn);
+ vs->num = r;
+ if (vs->va == NULL) {
+ /* va was freed */
+ vs->max = 0;
+ }
+ /* we can no longer rely on the sorting */
+ if (vs->sorted != NULL)
+ {
+ slapi_ch_free ((void **)&vs->sorted);
+ vs->sorted = NULL;
+ }
}
- return r;
+ return 0;
}
Slapi_Value **
@@ -1016,12 +833,21 @@ valueset_size(const Slapi_ValueSet *vs)
/*
* The value array is passed in by value.
*/
+void
+slapi_valueset_add_valuearray(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **addvals)
+{
+ if(!valuearray_isempty(addvals))
+ {
+ slapi_valueset_add_attr_valuearray_ext (a, vs, addvals, valuearray_count(addvals), 0, NULL);
+ }
+}
+
void
valueset_add_valuearray(Slapi_ValueSet *vs, Slapi_Value **addvals)
{
if(!valuearray_isempty(addvals))
{
- valuearray_add_valuearray(&vs->va, addvals, 0);
+ slapi_valueset_add_attr_valuearray_ext (NULL, vs, addvals, valuearray_count(addvals), 0, NULL);
}
}
@@ -1030,7 +856,7 @@ valueset_add_valuearray_ext(Slapi_ValueSet *vs, Slapi_Value **addvals, PRUint32
{
if(!valuearray_isempty(addvals))
{
- valuearray_add_valuearray(&vs->va, addvals, flags);
+ slapi_valueset_add_attr_valuearray_ext (NULL, vs, addvals, valuearray_count(addvals), flags, NULL);
}
}
@@ -1040,7 +866,7 @@ valueset_add_valuearray_ext(Slapi_ValueSet *vs, Slapi_Value **addvals, PRUint32
void
slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval)
{
- valuearray_add_value(&vs->va,addval);
+ slapi_valueset_add_value_ext(vs, addval, 0);
}
void
@@ -1049,19 +875,272 @@ slapi_valueset_add_value_ext(Slapi_ValueSet *vs, Slapi_Value *addval, unsigned l
Slapi_Value *oneval[2];
oneval[0]= (Slapi_Value*)addval;
oneval[1]= NULL;
- valuearray_add_valuearray(&vs->va, oneval, flags);
+ slapi_valueset_add_attr_valuearray_ext(NULL, vs, oneval, 1, flags, NULL);
+}
+
+
+/* find value v in the sorted array of values, using syntax of attribut a for comparison
+ *
+ */
+static int
+valueset_value_syntax_cmp( const Slapi_Attr *a, const Slapi_Value *v1, const Slapi_Value *v2 )
+{
+ /* this looks like a huge overhead, but there are no simple functions to normalize and
+ * compare available
+ */
+ const Slapi_Value *oneval[3];
+ Slapi_Value **keyvals;
+ int rc = -1;
+
+ keyvals = NULL;
+ oneval[0] = v1;
+ oneval[1] = v2;
+ oneval[2] = NULL;
+ if ( slapi_attr_values2keys_sv( a, (Slapi_Value**)oneval, &keyvals, LDAP_FILTER_EQUALITY ) != 0
+ || keyvals == NULL
+ || keyvals[0] == NULL || keyvals[1] == NULL)
+ {
+ /* this should never happen since always a syntax plugin to
+ * generate the keys will be found (there exists a default plugin)
+ * log an error and continue.
+ */
+ LDAPDebug( LDAP_DEBUG_ANY, "valueset_value_syntax_cmp: "
+ "slapi_attr_values2keys_sv failed for type %s\n",
+ a->a_type, 0, 0 );
+ } else {
+ struct berval *bv1, *bv2;
+ bv1 = &keyvals[0]->bv;
+ bv2 = &keyvals[1]->bv;
+ if ( bv1->bv_len < bv2->bv_len ) {
+ rc = -1;
+ } else if ( bv1->bv_len > bv2->bv_len ) {
+ rc = 1;
+ } else {
+ rc = memcmp( bv1->bv_val, bv2->bv_val, bv1->bv_len );
+ }
+ }
+ if (keyvals != NULL)
+ valuearray_free( &keyvals );
+ return (rc);
+
+}
+static int
+valueset_value_cmp( const Slapi_Attr *a, const Slapi_Value *v1, const Slapi_Value *v2 )
+{
+
+ if ( a == NULL || slapi_attr_is_dn_syntax_attr(a)) {
+ /* if no attr is provided just do a utf8compare */
+ /* for all the values the first step of normalization is done,
+ * case folding still needs to be done
+ */
+ /* would this be enough ?: return (strcasecmp(v1->bv.bv_val, v2->bv.bv_val)); */
+ return (slapi_utf8casecmp(v1->bv.bv_val, v2->bv.bv_val));
+ } else {
+ /* slapi_value_compare doesn't work, it only returns 0 or -1
+ return (slapi_value_compare(a, v1, v2));
+ * use special compare, base on what valuetree_find did
+ */
+ return(valueset_value_syntax_cmp(a, v1, v2));
+ }
+}
+/* find a value in the sorted valuearray.
+ * If the value is found the pointer to the value is returned and if index is provided
+ * it will return the index of the value in the valuearray
+ * If the value is not found, index will contain the place where the value would be inserted
+ */
+Slapi_Value *
+valueset_find_sorted (const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v, int *index)
+{
+ int cmp = -1;
+ int bot = -1;
+ int top;
+
+ if (vs->num == 0) {
+ /* empty valueset */
+ if (index) *index = 0;
+ return (NULL);
+ } else {
+ top = vs->num;
+ }
+ while (top - bot > 1) {
+ int mid = (top + bot)/2;
+ if ( (cmp = valueset_value_cmp(a, v, vs->va[vs->sorted[mid]])) > 0)
+ bot = mid;
+ else
+ top = mid;
+ }
+ if (index) *index = top;
+ /* check if the value is found */
+ if ( top < vs->num && (0 == valueset_value_cmp(a, v, vs->va[vs->sorted[top]])))
+ return (vs->va[vs->sorted[top]]);
+ else
+ return (NULL);
+}
+
+void
+valueset_array_to_sorted (const Slapi_Attr *a, Slapi_ValueSet *vs)
+{
+ int i, j, swap;
+
+ /* initialize sort array */
+ for (i = 0; i < vs->num; i++)
+ vs->sorted[i] = i;
+
+ /* now sort it, use a simple insertion sort as the array will always
+ * be very small when initially sorted
+ */
+ for (i = 1; i < vs->num; i++) {
+ swap = vs->sorted[i];
+ j = i -1;
+
+ while ( j >= 0 && valueset_value_cmp (a, vs->va[vs->sorted[j]], vs->va[swap]) > 0 ) {
+ vs->sorted[j+1] = vs->sorted[j];
+ j--;
+ }
+ vs->sorted[j+1] = swap;
+ }
+}
+/* insert a value into a sorted array, if dupcheck is set no duplicate values will be accepted
+ * (is there a reason to allow duplicates ? LK
+ * if the value is inserted the the function returns the index where it was inserted
+ * if the value already exists -index is returned to indicate anerror an the index of the existing value
+ */
+int
+valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *vi, int dupcheck)
+{
+ int index = -1;
+ Slapi_Value *v;
+ /* test for pre sorted array and to avoid boundary condition */
+ if (vs->num == 0) {
+ vs->sorted[0] = 0;
+ vs->num++;
+ return(0);
+ } else if (valueset_value_cmp (a, vi, vs->va[vs->sorted[vs->num-1]]) > 0 ) {
+ vs->sorted[vs->num] = vs->num;
+ vs->num++;
+ return (vs->num);
+ }
+ v = valueset_find_sorted (a, vs, vi, &index);
+ if (v && dupcheck) {
+ /* value already exists, do not insert duplicates */
+ return (-1);
+ } else {
+ memmove(&vs->sorted[index+1],&vs->sorted[index],(vs->num - index)* sizeof(int));
+ vs->sorted[index] = vs->num;
+ vs->num++;
+ return(index);
+ }
+
+}
+
+int
+slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs,
+ Slapi_Value **addvals, int naddvals, unsigned long flags, int *dup_index)
+{
+ int rc = LDAP_SUCCESS;
+ int i, dup;
+ int allocate = 0;
+ int need;
+ int passin = flags & SLAPI_VALUE_FLAG_PASSIN;
+ int dupcheck = flags & SLAPI_VALUE_FLAG_DUPCHECK;
+
+ if (naddvals == 0)
+ return (rc);
+
+ need = vs->num + naddvals + 1;
+ if (need > vs->max) {
+ /* Expand the array */
+ allocate= vs->max;
+ if ( allocate == 0 ) /* initial allocation */
+ allocate = VALUESET_ARRAY_MINSIZE;
+ while ( allocate < need )
+ {
+ if (allocate > VALUESET_ARRAY_MAXINCREMENT )
+ /* do not grow exponentially */
+ allocate += VALUESET_ARRAY_MAXINCREMENT;
+ else
+ allocate *= 2;
+
+ }
+ }
+ if(allocate>0)
+ {
+ if(vs->va==NULL)
+ {
+ vs->va = (Slapi_Value **) slapi_ch_malloc( allocate * sizeof(Slapi_Value *));
+ }
+ else
+ {
+ vs->va = (Slapi_Value **) slapi_ch_realloc( (char *) vs->va, allocate * sizeof(Slapi_Value *));
+ if (vs->sorted) {
+ vs->sorted = (int *) slapi_ch_realloc( (char *) vs->sorted, allocate * sizeof(int));
+ }
+ }
+ vs->max= allocate;
+ }
+
+ if ( (vs->num + naddvals > VALUESET_ARRAY_SORT_THRESHOLD || dupcheck ) &&
+ !vs->sorted ) {
+ /* initialize sort array and do initial sort */
+ vs->sorted = (int *) slapi_ch_malloc( vs->max* sizeof(int));
+ valueset_array_to_sorted (a, vs);
+ }
+
+ for ( i = 0; i < naddvals; i++)
+ {
+ if ( addvals[i]!=NULL )
+ {
+ if(passin)
+ {
+ /* We consume the values */
+ (vs->va)[vs->num] = addvals[i];
+ }
+ else
+ {
+ /* We copy the values */
+ (vs->va)[vs->num] = slapi_value_dup(addvals[i]);
+ }
+ if (vs->sorted) {
+ dup = valueset_insert_value_to_sorted(a, vs, (vs->va)[vs->num], dupcheck);
+ if (dup < 0 ) {
+ rc = LDAP_TYPE_OR_VALUE_EXISTS;
+ if (dup_index) *dup_index = i;
+ if ( !passin)
+ slapi_value_free(&(vs->va)[vs->num]);
+ break;
+ }
+ } else {
+ vs->num++;
+ }
+ }
+ }
+ (vs->va)[vs->num] = NULL;
+
+ return (rc);
+}
+
+int
+slapi_valueset_add_attr_value_ext(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *addval, unsigned long flags)
+{
+
+ Slapi_Value *oneval[2];
+ int rc;
+ oneval[0]= (Slapi_Value*)addval;
+ oneval[1]= NULL;
+ rc = slapi_valueset_add_attr_valuearray_ext(a, vs, oneval, 1, flags, NULL );
+ return (rc);
}
/*
* The string is passed in by value.
*/
void
-valueset_add_string(Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn)
+valueset_add_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn)
{
Slapi_Value v;
value_init(&v,NULL,t,csn);
slapi_value_set_string(&v,s);
- valuearray_add_value(&vs->va,&v);
+ slapi_valueset_add_attr_value_ext(a, vs, &v, 0 );
value_done(&v);
}
@@ -1071,8 +1150,30 @@ valueset_add_string(Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn
void
valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
{
- if (vs1 && vs2)
- valueset_add_valuearray(vs1, vs2->va);
+ int i;
+
+ if (vs1 && vs2) {
+ if (vs2->va) {
+ /* need to copy valuearray */
+ if (vs2->max == 0) {
+ /* temporary hack, not all valuesets were created properly. fix it now */
+ vs1->num = valuearray_count(vs2->va);
+ vs1->max = vs1->num + 1;
+ } else {
+ vs1->num = vs2->num;
+ vs1->max = vs2->max;
+ }
+ vs1->va = (Slapi_Value **) slapi_ch_malloc( vs1->max * sizeof(Slapi_Value *));
+ for (i=0; i< vs1->num;i++) {
+ vs1->va[i] = slapi_value_dup(vs2->va[i]);
+ }
+ vs1->va[vs1->num] = NULL;
+ }
+ if (vs2->sorted) {
+ vs1->sorted = (int *) slapi_ch_malloc( vs1->max* sizeof(int));
+ memcpy(&vs1->sorted[0],&vs2->sorted[0],vs1->num* sizeof(int));
+ }
+ }
}
void
@@ -1082,7 +1183,7 @@ valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s)
Slapi_Value *removed;
value_init(&v,NULL,CSN_TYPE_NONE,NULL);
slapi_value_set_string(&v,s);
- removed = valuearray_remove_value(a, vs->va, &v);
+ removed = valueset_remove_value(a, vs, &v);
if(removed) {
slapi_value_free(&removed);
}
@@ -1121,158 +1222,59 @@ int
valueset_remove_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestodelete, int flags, Slapi_Value ***va_out)
{
int rc= LDAP_SUCCESS;
- if(!valuearray_isempty(vs->va))
+ if(vs->num > 0)
{
- int numberofvaluestodelete= valuearray_count(valuestodelete);
+ int i;
struct valuearrayfast vaf_out;
+
if ( va_out )
{
valuearrayfast_init(&vaf_out,*va_out);
}
/*
- * If there are more then one values, build an AVL tree to check
- * the duplicated values.
+ * For larger valuesets the valuarray is sorted, values can be deleted individually
+ *
*/
- if ( numberofvaluestodelete > 1 )
+ for ( i = 0; rc==LDAP_SUCCESS && valuestodelete[i] != NULL; ++i )
{
- /*
- * Several values to delete: first build an AVL tree that
- * holds all of the existing values and use that to find
- * the values we want to delete.
- */
- Avlnode *vtree = NULL;
- int numberofexistingvalues= slapi_valueset_count(vs);
- rc= valuetree_add_valuearray( a, vs->va, &vtree, NULL );
- if ( rc!=LDAP_SUCCESS )
- {
- /*
- * failed while constructing AVL tree of existing
- * values... something bad happened.
- */
- rc= LDAP_OPERATIONS_ERROR;
- }
- else
+ Slapi_Value *found = valueset_remove_value(a, vs, valuestodelete[i]);
+ if(found!=NULL)
{
- int i;
- /*
- * find and mark all the values that are to be deleted
- */
- for ( i = 0; rc == LDAP_SUCCESS && valuestodelete[i] != NULL; ++i )
+ if ( va_out )
{
- int index= 0;
- rc = valuetree_find( a, valuestodelete[i], vtree, &index );
- if(rc==LDAP_SUCCESS)
- {
- if(vs->va[index]!=NULL)
- {
- /* Move the value to be removed to the out array */
- if ( va_out )
- {
- if (vs->va[index]->v_csnset &&
- (flags & (SLAPI_VALUE_FLAG_PRESERVECSNSET|
- SLAPI_VALUE_FLAG_USENEWVALUE)))
- {
- valuestodelete[i]->v_csnset = csnset_dup (vs->va[index]->v_csnset);
- }
- if (flags & SLAPI_VALUE_FLAG_USENEWVALUE)
- {
- valuearrayfast_add_value_passin(&vaf_out,valuestodelete[i]);
- valuestodelete[i] = vs->va[index];
- vs->va[index] = NULL;
- }
- else
- {
- valuearrayfast_add_value_passin(&vaf_out,vs->va[index]);
- vs->va[index] = NULL;
- }
- }
- else
- {
- if (flags & SLAPI_VALUE_FLAG_PRESERVECSNSET)
- {
- valuestodelete[i]->v_csnset = vs->va[index]->v_csnset;
- vs->va[index]->v_csnset = NULL;
- }
- slapi_value_free ( & vs->va[index] );
- }
- }
- else
- {
- /* We already deleted this value... */
- if((flags & SLAPI_VALUE_FLAG_IGNOREERROR) == 0)
- {
- /* ...that's an error. */
- rc= LDAP_NO_SUCH_ATTRIBUTE;
- }
- }
- }
- else
+ if (found->v_csnset &&
+ (flags & (SLAPI_VALUE_FLAG_PRESERVECSNSET|
+ SLAPI_VALUE_FLAG_USENEWVALUE)))
{
- /* Couldn't find the value to be deleted */
- if(rc==LDAP_NO_SUCH_ATTRIBUTE && (flags & SLAPI_VALUE_FLAG_IGNOREERROR ))
- {
- rc= LDAP_SUCCESS;
- }
+ valuestodelete[i]->v_csnset = csnset_dup (found->v_csnset);
}
- }
- valuetree_free( &vtree );
-
- if ( rc != LDAP_SUCCESS )
- {
- LDAPDebug( LDAP_DEBUG_ANY,"could not find value %d for attr %s (%s)\n", i-1, a->a_type, ldap_err2string( rc ));
- }
- else
- {
- /* Shunt up all the remaining values to cover the deleted ones. */
- valuearray_compress(vs->va,numberofexistingvalues);
- }
- }
- }
- else
- {
- /* We delete one or no value, so we use brute force. */
- int i;
- for ( i = 0; rc==LDAP_SUCCESS && valuestodelete[i] != NULL; ++i )
- {
- Slapi_Value *found= valueset_remove_value(a, vs, valuestodelete[i]);
- if(found!=NULL)
- {
- if ( va_out )
+ if (flags & SLAPI_VALUE_FLAG_USENEWVALUE)
{
- if (found->v_csnset &&
- (flags & (SLAPI_VALUE_FLAG_PRESERVECSNSET|
- SLAPI_VALUE_FLAG_USENEWVALUE)))
- {
- valuestodelete[i]->v_csnset = csnset_dup (found->v_csnset);
- }
- if (flags & SLAPI_VALUE_FLAG_USENEWVALUE)
- {
- valuearrayfast_add_value_passin(&vaf_out,valuestodelete[i]);
- valuestodelete[i] = found;
- }
- else
- {
- valuearrayfast_add_value_passin(&vaf_out,found);
- }
+ valuearrayfast_add_value_passin(&vaf_out,valuestodelete[i]);
+ valuestodelete[i] = found;
}
else
{
- if (flags & SLAPI_VALUE_FLAG_PRESERVECSNSET)
- {
- valuestodelete[i]->v_csnset = found->v_csnset;
- found->v_csnset = NULL;
- }
- slapi_value_free ( & found );
+ valuearrayfast_add_value_passin(&vaf_out,found);
}
}
else
{
- if((flags & SLAPI_VALUE_FLAG_IGNOREERROR) == 0)
+ if (flags & SLAPI_VALUE_FLAG_PRESERVECSNSET)
{
- LDAPDebug( LDAP_DEBUG_ARGS,"could not find value %d for attr %s\n", i-1, a->a_type, 0 );
- rc= LDAP_NO_SUCH_ATTRIBUTE;
+ valuestodelete[i]->v_csnset = found->v_csnset;
+ found->v_csnset = NULL;
}
+ slapi_value_free ( & found );
+ }
+ }
+ else
+ {
+ if((flags & SLAPI_VALUE_FLAG_IGNOREERROR) == 0)
+ {
+ LDAPDebug( LDAP_DEBUG_ARGS,"could not find value %d for attr %s\n", i-1, a->a_type, 0 );
+ rc= LDAP_NO_SUCH_ATTRIBUTE;
}
}
}
@@ -1288,88 +1290,13 @@ valueset_remove_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value
return rc;
}
-/*
- * Check if the set of values in the valueset and the valuearray intersect.
- *
- * Returns
- * LDAP_SUCCESS - No intersection.
- * LDAP_NO_SUCH_ATTRIBUTE - There is an intersection.
- * LDAP_OPERATIONS_ERROR - There are duplicate values in the value set already.
- */
-int
-valueset_intersectswith_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **values, int *duplicate_index )
-{
- int rc= LDAP_SUCCESS;
-
- if ( duplicate_index ) {
- *duplicate_index = -1;
- }
-
- if(valuearray_isempty(vs->va))
- {
- /* No intersection */
- }
- else
- {
- int numberofvalues= valuearray_count(values);
- /*
- * determine whether we should use an AVL tree of values or not
- */
- if (numberofvalues==0)
- {
- /* No intersection */
- }
- else if ( numberofvalues > 1 )
- {
- /*
- * Several values to add: use an AVL tree to detect duplicates.
- */
- Avlnode *vtree = NULL;
- rc= valuetree_add_valuearray( a, vs->va, &vtree, duplicate_index );
- if(rc==LDAP_OPERATIONS_ERROR)
- {
- /* There were already duplicate values in the value set */
- }
- else
- {
- rc= valuetree_add_valuearray( a, values, &vtree, duplicate_index );
- /*
- * Returns LDAP_OPERATIONS_ERROR if something very bad happens.
- * Or LDAP_TYPE_OR_VALUE_EXISTS if a value already exists.
- */
- }
- valuetree_free( &vtree );
- }
- else
- {
- /*
- * One value to add: don't bother constructing
- * an AVL tree, etc. since it probably isn't worth the time.
- *
- * JCM - This is actually quite slow because the comparison function is looked up many times.
- */
- int i;
- for ( i = 0; rc == LDAP_SUCCESS && values[i] != NULL; ++i )
- {
- if(valuearray_find(a, vs->va, values[i])!=-1)
- {
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- *duplicate_index = i;
- break;
- }
- }
- }
- }
- return rc;
-}
-
Slapi_ValueSet *
valueset_dup(const Slapi_ValueSet *dupee)
{
- Slapi_ValueSet *duped= (Slapi_ValueSet *)slapi_ch_calloc(1,sizeof(Slapi_ValueSet));
+ Slapi_ValueSet *duped = slapi_valueset_new();
if (NULL!=duped)
{
- valueset_add_valuearray( duped, dupee->va );
+ valueset_set_valuearray_byval(duped,dupee->va);
}
return duped;
}
@@ -1381,43 +1308,53 @@ valueset_dup(const Slapi_ValueSet *dupee)
* : LDAP_OPERATIONS_ERROR - duplicated values given
*/
int
-valueset_replace(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **valstoreplace)
+valueset_replace_valuearray(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **valstoreplace)
+{
+ return (valueset_replace_valuearray_ext(a, vs,valstoreplace, 1));
+}
+int
+valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **valstoreplace, int dupcheck)
{
int rc = LDAP_SUCCESS;
- int numberofvalstoreplace= valuearray_count(valstoreplace);
- /* verify the given values are not duplicated.
- if replacing with one value, no need to check. just replace it.
- */
- if (numberofvalstoreplace > 1)
- {
- Avlnode *vtree = NULL;
- rc = valuetree_add_valuearray( a, valstoreplace, &vtree, NULL );
- valuetree_free(&vtree);
- if ( LDAP_SUCCESS != rc &&
- /* bz 247413: don't override LDAP_TYPE_OR_VALUE_EXISTS */
- LDAP_TYPE_OR_VALUE_EXISTS != rc )
- {
- /* There were already duplicate values in the value set */
- rc = LDAP_OPERATIONS_ERROR;
- }
- }
-
- if ( rc == LDAP_SUCCESS )
- {
- /* values look good - replace the values in the attribute */
- if(!valuearray_isempty(vs->va))
- {
- /* remove old values */
- slapi_valueset_done(vs);
- }
- /* we now own valstoreplace */
- vs->va = valstoreplace;
- }
- else
- {
- /* caller expects us to own valstoreplace - since we cannot
- use them, just delete them */
- valuearray_free(&valstoreplace);
+ int vals_count = valuearray_count(valstoreplace);
+
+ if (vals_count == 0) {
+ /* no new values, just clear the valueset */
+ slapi_valueset_done(vs);
+ } else if (vals_count == 1 || !dupcheck) {
+ /* just repelace the valuearray and adjus num, max */
+ slapi_valueset_done(vs);
+ vs->va = valstoreplace;
+ vs->num = vals_count;
+ vs->max = vals_count + 1;
+ } else {
+ /* verify the given values are not duplicated. */
+ Slapi_ValueSet *vs_new = slapi_valueset_new();
+ rc = slapi_valueset_add_attr_valuearray_ext (a, vs_new, valstoreplace, vals_count, 0, NULL);
+
+ if ( rc == LDAP_SUCCESS )
+ {
+ /* values look good - replace the values in the attribute */
+ if(!valuearray_isempty(vs->va))
+ {
+ /* remove old values */
+ slapi_valueset_done(vs);
+ }
+ vs->va = vs_new->va;
+ vs_new->va = NULL;
+ vs->sorted = vs_new->sorted;
+ vs_new->sorted = NULL;
+ vs->num = vs_new->num;
+ vs->max = vs_new->max;
+ slapi_valueset_free (vs_new);
+ }
+ else
+ {
+ /* caller expects us to own valstoreplace - since we cannot
+ use them, just delete them */
+ slapi_valueset_free(vs_new);
+ valuearray_free(&valstoreplace);
+ }
}
return rc;
}
@@ -1439,50 +1376,35 @@ valueset_update_csn_for_valuearray_ext(Slapi_ValueSet *vs, const Slapi_Attr *a,
if(!valuearray_isempty(valuestoupdate) &&
!valuearray_isempty(vs->va))
{
- /*
- * determine whether we should use an AVL tree of values or not
- */
struct valuearrayfast vaf_valuesupdated;
- int numberofvaluestoupdate= valuearray_count(valuestoupdate);
valuearrayfast_init(&vaf_valuesupdated,*valuesupdated);
- if (numberofvaluestoupdate > 1) /* multiple values to update */
+ int i;
+ int del_index = -1, del_count = 0;
+ for (i=0;valuestoupdate[i]!=NULL;++i)
{
- int i;
- Avlnode *vtree = NULL;
- int rc= valuetree_add_valuearray( a, vs->va, &vtree, NULL );
- PR_ASSERT(rc==LDAP_SUCCESS);
- for (i=0;valuestoupdate[i]!=NULL;++i)
+ int index= valuearray_find(a, vs->va, valuestoupdate[i]);
+ if(index!=-1)
{
- int index= 0;
- rc = valuetree_find( a, valuestoupdate[i], vtree, &index );
- if(rc==LDAP_SUCCESS)
- {
- value_update_csn(vs->va[index],t,csn);
- if (csnref_updated)
- valuestoupdate[i]->v_csnset = (CSNSet *)value_get_csnset(vs->va[index]);
- valuearrayfast_add_value_passin(&vaf_valuesupdated,valuestoupdate[i]);
- valuestoupdate[i] = NULL;
- }
+ value_update_csn(vs->va[index],t,csn);
+ if (csnref_updated)
+ valuestoupdate[i]->v_csnset = (CSNSet *)value_get_csnset(vs->va[index]);
+ valuearrayfast_add_value_passin(&vaf_valuesupdated,valuestoupdate[i]);
+ valuestoupdate[i]= NULL;
+ del_count++;
+ if (del_index < 0) del_index = i;
}
- valuetree_free(&vtree);
- }
- else
- {
- int i;
- for (i=0;valuestoupdate[i]!=NULL;++i)
- {
- int index= valuearray_find(a, vs->va, valuestoupdate[i]);
- if(index!=-1)
- {
- value_update_csn(vs->va[index],t,csn);
- if (csnref_updated)
- valuestoupdate[i]->v_csnset = (CSNSet *)value_get_csnset(vs->va[index]);
- valuearrayfast_add_value_passin(&vaf_valuesupdated,valuestoupdate[i]);
- valuestoupdate[i]= NULL;
+ else
+ { /* keep the value in valuestoupdate, to keep array compressed, move to first free slot*/
+ if (del_index >= 0) {
+ valuestoupdate[del_index] = valuestoupdate[i];
+ del_index++;
}
}
}
- valuearray_compress(valuestoupdate,numberofvaluestoupdate);
+ /* complete compression */
+ for (i=0; i<del_count;i++)
+ valuestoupdate[del_index+i]= NULL;
+
*valuesupdated= vaf_valuesupdated.va;
}
}
| 0 |
fe4d09a3f984fe821635a1147da12dc3510cd4d6
|
389ds/389-ds-base
|
Bug 586571 - DS Console shows escaped DNs
https://bugzilla.redhat.com/show_bug.cgi?id=586571
Resolves: bug 586571
Bug Description: DS Console shows escaped DNs
Reviewed by: nkinder (Thanks!)
Branch: HEAD
Fix Description: In order for the console fixed to be used to manage the
correct directory server, the directory server needs to be able to specify
the ds console jar file version down to 3 digits, as opposed to the current
two digits. To support this, instead of overriding PACKAGE_BASE_VERSION,
a new configure macro is introduced - CONSOLE_VERSION. This value is
set in VERSION.sh, so it can be easily updated, and it is used to set
the value for BaseVersion in slapd.inf, which is what the admin server
setup uses to set the ds console jar file version corresponding to the
directory server.
Platforms tested: RHEL5 x86_64, Fedora 12
Flag Day: no
Doc impact: no
|
commit fe4d09a3f984fe821635a1147da12dc3510cd4d6
Author: Rich Megginson <[email protected]>
Date: Tue May 4 16:12:35 2010 -0600
Bug 586571 - DS Console shows escaped DNs
https://bugzilla.redhat.com/show_bug.cgi?id=586571
Resolves: bug 586571
Bug Description: DS Console shows escaped DNs
Reviewed by: nkinder (Thanks!)
Branch: HEAD
Fix Description: In order for the console fixed to be used to manage the
correct directory server, the directory server needs to be able to specify
the ds console jar file version down to 3 digits, as opposed to the current
two digits. To support this, instead of overriding PACKAGE_BASE_VERSION,
a new configure macro is introduced - CONSOLE_VERSION. This value is
set in VERSION.sh, so it can be easily updated, and it is used to set
the value for BaseVersion in slapd.inf, which is what the admin server
setup uses to set the ds console jar file version corresponding to the
directory server.
Platforms tested: RHEL5 x86_64, Fedora 12
Flag Day: no
Doc impact: no
diff --git a/Makefile.am b/Makefile.am
index 9d1bee6b3..f013a100a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1332,6 +1332,7 @@ fixupcmd = sed \
-e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
+ -e 's,@CONSOLE_VERSION\@,$(CONSOLE_VERSION),g' \
-e 's,@BUILDNUM\@,$(BUILDNUM),g' \
-e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
-e 's,@perlpath\@,$(perldir) $(libdir)/perl/arch $(libdir)/perl,g' \
@@ -1386,6 +1387,7 @@ fixupcmd = sed \
-e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
+ -e 's,@CONSOLE_VERSION\@,$(CONSOLE_VERSION),g' \
-e 's,@BUILDNUM\@,$(BUILDNUM),g' \
-e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
-e 's,@perlpath\@,$(perldir),g' \
diff --git a/Makefile.in b/Makefile.in
old mode 100755
new mode 100644
index 4ecd1c5c3..ee070d69e
--- a/Makefile.in
+++ b/Makefile.in
@@ -956,6 +956,7 @@ CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
+CONSOLE_VERSION = @CONSOLE_VERSION@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
@@ -2318,6 +2319,7 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
@BUNDLE_FALSE@ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
@BUNDLE_FALSE@ -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
@BUNDLE_FALSE@ -e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
+@BUNDLE_FALSE@ -e 's,@CONSOLE_VERSION\@,$(CONSOLE_VERSION),g' \
@BUNDLE_FALSE@ -e 's,@BUILDNUM\@,$(BUILDNUM),g' \
@BUNDLE_FALSE@ -e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
@BUNDLE_FALSE@ -e 's,@perlpath\@,$(perldir),g' \
@@ -2382,6 +2384,7 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
@BUNDLE_TRUE@ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
@BUNDLE_TRUE@ -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
@BUNDLE_TRUE@ -e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
+@BUNDLE_TRUE@ -e 's,@CONSOLE_VERSION\@,$(CONSOLE_VERSION),g' \
@BUNDLE_TRUE@ -e 's,@BUILDNUM\@,$(BUILDNUM),g' \
@BUNDLE_TRUE@ -e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
@BUNDLE_TRUE@ -e 's,@perlpath\@,$(perldir) $(libdir)/perl/arch $(libdir)/perl,g' \
diff --git a/VERSION.sh b/VERSION.sh
index 4b8b43f62..90b03e9f7 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -48,3 +48,6 @@ PACKAGE_TARNAME=${brand}-ds-base
# url for bug reports
PACKAGE_BUGREPORT="${PACKAGE_BUGREPORT}enter_bug.cgi?product=$brand"
PACKAGE_STRING="$PACKAGE_TARNAME $PACKAGE_VERSION"
+# the version of the ds console package that this directory server
+# is compatible with
+CONSOLE_VERSION=$VERSION_MAJOR.$VERSION_MINOR.2
diff --git a/configure b/configure
index 957f2eac0..44858ca5a 100755
--- a/configure
+++ b/configure
@@ -465,7 +465,7 @@ ac_includes_default="\
#endif"
ac_default_prefix=/opt/$PACKAGE_NAME
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS CCASFLAGS SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_autobind_TRUE enable_autobind_FALSE enable_auto_dn_suffix_TRUE enable_auto_dn_suffix_FALSE enable_bitwise_TRUE enable_bitwise_FALSE enable_presence_TRUE enable_presence_FALSE with_fhs_opt configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir infdir mibdir updatedir defaultuser defaultgroup instconfigdir WINNT_TRUE WINNT_FALSE THREADLIB LIBCRYPT LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir perlexec initconfigdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG KRB5_CONFIG_BIN kerberos_inc kerberos_lib kerberos_libdir with_selinux PACKAGE_BASE_VERSION SELINUX_TRUE SELINUX_FALSE OPENLDAP_TRUE OPENLDAP_FALSE nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir openldap_inc openldap_lib openldap_libdir openldap_bindir ol_libver db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir sasl_path svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link pcre_inc pcre_lib pcre_libdir brand capbrand vendor LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CONSOLE_VERSION MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS CCASFLAGS SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_autobind_TRUE enable_autobind_FALSE enable_auto_dn_suffix_TRUE enable_auto_dn_suffix_FALSE enable_bitwise_TRUE enable_bitwise_FALSE enable_presence_TRUE enable_presence_FALSE with_fhs_opt configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir infdir mibdir updatedir defaultuser defaultgroup instconfigdir WINNT_TRUE WINNT_FALSE THREADLIB LIBCRYPT LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir perlexec initconfigdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG KRB5_CONFIG_BIN kerberos_inc kerberos_lib kerberos_libdir with_selinux PACKAGE_BASE_VERSION SELINUX_TRUE SELINUX_FALSE OPENLDAP_TRUE OPENLDAP_FALSE nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir openldap_inc openldap_lib openldap_libdir openldap_bindir ol_libver db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir sasl_path svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link pcre_inc pcre_lib pcre_libdir brand capbrand vendor LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -2076,6 +2076,7 @@ cat >>confdefs.h <<_ACEOF
#define PACKAGE "$PACKAGE"
_ACEOF
+
echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6
# Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
@@ -4404,7 +4405,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4407 "configure"' > conftest.$ac_ext
+ echo '#line 4408 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5539,7 +5540,7 @@ fi
# Provide some information about the compiler.
-echo "$as_me:5542:" \
+echo "$as_me:5543:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -6602,11 +6603,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6605: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6606: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6609: \$? = $ac_status" >&5
+ echo "$as_me:6610: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6870,11 +6871,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6873: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6874: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6877: \$? = $ac_status" >&5
+ echo "$as_me:6878: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6974,11 +6975,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6977: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6978: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:6981: \$? = $ac_status" >&5
+ echo "$as_me:6982: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -8443,7 +8444,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 8446 "configure"' > conftest.$ac_ext
+ echo '#line 8447 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -9340,7 +9341,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9343 "configure"
+#line 9344 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -9440,7 +9441,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9443 "configure"
+#line 9444 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11783,11 +11784,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11786: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11787: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:11790: \$? = $ac_status" >&5
+ echo "$as_me:11791: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -11887,11 +11888,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11890: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11891: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:11894: \$? = $ac_status" >&5
+ echo "$as_me:11895: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -12423,7 +12424,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 12426 "configure"' > conftest.$ac_ext
+ echo '#line 12427 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -13481,11 +13482,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13484: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13485: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:13488: \$? = $ac_status" >&5
+ echo "$as_me:13489: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -13585,11 +13586,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13588: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13589: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:13592: \$? = $ac_status" >&5
+ echo "$as_me:13593: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -15034,7 +15035,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 15037 "configure"' > conftest.$ac_ext
+ echo '#line 15038 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -15812,11 +15813,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15815: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15816: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15819: \$? = $ac_status" >&5
+ echo "$as_me:15820: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16080,11 +16081,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16083: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16084: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16087: \$? = $ac_status" >&5
+ echo "$as_me:16088: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16184,11 +16185,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16187: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16188: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16191: \$? = $ac_status" >&5
+ echo "$as_me:16192: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -17653,7 +17654,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 17656 "configure"' > conftest.$ac_ext
+ echo '#line 17657 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -28233,6 +28234,7 @@ s,@am__leading_dot@,$am__leading_dot,;t t
s,@AMTAR@,$AMTAR,;t t
s,@am__tar@,$am__tar,;t t
s,@am__untar@,$am__untar,;t t
+s,@CONSOLE_VERSION@,$CONSOLE_VERSION,;t t
s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t
s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t
s,@MAINT@,$MAINT,;t t
diff --git a/configure.ac b/configure.ac
index cd4ab80c3..e5f419d06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ VERSION=$PACKAGE_VERSION
PACKAGE=$PACKAGE_TARNAME
AC_DEFINE_UNQUOTED([VERSION], "$VERSION", [package version])
AC_DEFINE_UNQUOTED([PACKAGE], "$PACKAGE", [package tar name])
+AC_SUBST([CONSOLE_VERSION])
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
diff --git a/ldap/admin/src/slapd.inf.in b/ldap/admin/src/slapd.inf.in
index 140ff36db..fa0354318 100644
--- a/ldap/admin/src/slapd.inf.in
+++ b/ldap/admin/src/slapd.inf.in
@@ -46,7 +46,7 @@ Name= @capbrand@ Directory Server
InstanceNamePrefix= Directory Server
NickName= slapd
Version= @PACKAGE_VERSION@
-BaseVersion= @PACKAGE_BASE_VERSION@
+BaseVersion= @CONSOLE_VERSION@
Compatible= 1.0
BuildNumber= @NQBUILD_NUM@
Description= @capbrand@ Directory Server
diff --git a/ltmain.sh b/ltmain.sh
old mode 100755
new mode 100644
| 0 |
a703d1017716159f9c84b2c8f6fb0246f9a6a8a8
|
389ds/389-ds-base
|
Ticket 50273 - reduce default replicaton agmt timeout
Description: The default timeout of 10 minutes is just too long.
Change default to 2 minutes.
https://pagure.io/389-ds-base/issue/50273
Reviewed by: tbordaz(Thanks!)
|
commit a703d1017716159f9c84b2c8f6fb0246f9a6a8a8
Author: Mark Reynolds <[email protected]>
Date: Mon Mar 11 11:38:01 2019 -0400
Ticket 50273 - reduce default replicaton agmt timeout
Description: The default timeout of 10 minutes is just too long.
Change default to 2 minutes.
https://pagure.io/389-ds-base/issue/50273
Reviewed by: tbordaz(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c
index 95584cef4..53e6708c8 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -57,7 +57,7 @@
#include "cl5_api.h"
#include "slapi-plugin.h"
-#define DEFAULT_TIMEOUT 600 /* (seconds) default outbound LDAP connection */
+#define DEFAULT_TIMEOUT 120 /* (seconds) default outbound LDAP connection */
#define DEFAULT_FLOWCONTROL_WINDOW 1000 /* #entries sent without acknowledgment */
#define DEFAULT_FLOWCONTROL_PAUSE 2000 /* msec of pause when #entries sent witout acknowledgment */
#define STATUS_LEN 1024
| 0 |
42f935ab7406802d522f357048db1e68d729d5e5
|
389ds/389-ds-base
|
Ticket 47525 - Crash if setting invalid plugin config area for MemberOf Plugin
Bug Description: Setting the nsslapd-pluginconfigarea to an entry that
does not have the required config attributes causes a
crash.
Fix Description: The plugin entry was being accidentally freed instead
of the config area entry.
The shared config area validation was being performed
in postop - this has now been moved into the preop stage.
Also, set the returntext when an error occurs.
https://fedorahosted.org/389/ticket/47525
Reviewed by: rmeggins(Thanks!)
|
commit 42f935ab7406802d522f357048db1e68d729d5e5
Author: Mark Reynolds <[email protected]>
Date: Wed Dec 3 16:47:59 2014 -0500
Ticket 47525 - Crash if setting invalid plugin config area for MemberOf Plugin
Bug Description: Setting the nsslapd-pluginconfigarea to an entry that
does not have the required config attributes causes a
crash.
Fix Description: The plugin entry was being accidentally freed instead
of the config area entry.
The shared config area validation was being performed
in postop - this has now been moved into the preop stage.
Also, set the returntext when an error occurs.
https://fedorahosted.org/389/ticket/47525
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index a59494159..3e0ae7e90 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -408,7 +408,6 @@ int memberof_postop_start(Slapi_PBlock *pb)
}
}
- memberof_set_plugin_area(slapi_entry_get_sdn(config_e));
memberof_set_config_area(slapi_entry_get_sdn(config_e));
if (( rc = memberof_config( config_e, pb )) != LDAP_SUCCESS ) {
slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
index 8efbe2f1d..012e2d055 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -355,48 +355,30 @@ memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
*returncode = LDAP_SUCCESS;
/*
- * Apply the config settings from the shared config entry
+ * Check if this is a shared config entry
*/
sharedcfg = slapi_entry_attr_get_charptr(e, SLAPI_PLUGIN_SHARED_CONFIG_AREA);
if(sharedcfg){
- int rc = 0;
-
- rc = slapi_dn_syntax_check(pb, sharedcfg, 1);
- if (rc) { /* syntax check failed */
- slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,"memberof_apply_config: "
- "%s does not contain a valid DN (%s)\n",
- SLAPI_PLUGIN_SHARED_CONFIG_AREA, sharedcfg);
- *returncode = LDAP_INVALID_DN_SYNTAX;
- goto done;
- }
if((config_sdn = slapi_sdn_new_dn_byval(sharedcfg))){
slapi_search_internal_get_entry(config_sdn, NULL, &config_entry, memberof_get_plugin_id());
if(config_entry){
- char errtext[SLAPI_DSE_RETURNTEXT_SIZE];
- int err = 0;
- /*
- * If we got here, we are updating the shared config area, so we need to
- * validate and apply the settings from that config area.
- */
- if ( SLAPI_DSE_CALLBACK_ERROR == memberof_validate_config (pb, NULL, config_entry, &err, errtext,0))
- {
- slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
- "%s", errtext);
- *returncode = LDAP_UNWILLING_TO_PERFORM;
- goto done;
-
- }
+ /* Set the entry to be the shared config entry. Validation was done in preop */
e = config_entry;
} else {
- /* this should of been checked in preop validation */
- slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_apply_config: "
- "Failed to locate shared config entry (%s)\n",sharedcfg);
+ /* This should of been checked in preop validation */
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "memberof_apply_config: Failed to locate shared config entry (%s)",
+ sharedcfg);
+ slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,"%s\n",returntext);
*returncode = LDAP_UNWILLING_TO_PERFORM;
goto done;
}
}
}
+ /*
+ * Apply the config settings
+ */
groupattrs = slapi_entry_attr_get_charray(e, MEMBEROF_GROUP_ATTR);
memberof_attr = slapi_entry_attr_get_charptr(e, MEMBEROF_ATTR);
allBackends = slapi_entry_attr_get_charptr(e, MEMBEROF_BACKEND_ATTR);
@@ -404,8 +386,10 @@ memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
entryScopeExcludeSubtree = slapi_entry_attr_get_charptr(e, MEMBEROF_ENTRY_SCOPE_EXCLUDE_SUBTREE);
skip_nested = slapi_entry_attr_get_charptr(e, MEMBEROF_SKIP_NESTED_ATTR);
- /* 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 */
+ /*
+ * 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
+ */
memberof_wlock_config();
if (groupattrs)
@@ -416,8 +400,10 @@ memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
theConfig.groupattrs = groupattrs;
groupattrs = NULL; /* config now owns memory */
- /* We allocate a list of Slapi_Attr using the groupattrs for
- * convenience in our memberOf comparison functions */
+ /*
+ * We allocate a list of Slapi_Attr using the groupattrs for
+ * convenience in our memberOf comparison functions
+ */
for (i = 0; theConfig.group_slapiattrs && theConfig.group_slapiattrs[i]; i++)
{
slapi_attr_free(&theConfig.group_slapiattrs[i]);
@@ -426,8 +412,10 @@ memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
/* Count the number of groupattrs. */
for (num_groupattrs = 0; theConfig.groupattrs && theConfig.groupattrs[num_groupattrs]; num_groupattrs++)
{
- /* Add up the total length of all attribute names. We need
- * to know this for building the group check filter later. */
+ /*
+ * Add up the total length of all attribute names. We need
+ * to know this for building the group check filter later.
+ */
groupattr_name_len += strlen(theConfig.groupattrs[num_groupattrs]);
}
@@ -448,8 +436,7 @@ memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
/* Terminate the list. */
theConfig.group_slapiattrs[i] = NULL;
- /* The filter is based off of the groupattr, so we
- * update it here too. */
+ /* The filter is based off of the groupattr, so we update it here too. */
slapi_filter_free(theConfig.group_filter, 1);
if (num_groupattrs > 1)
@@ -477,11 +464,13 @@ memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
filter_str = slapi_ch_smprintf("(%s=*)", theConfig.groupattrs[0]);
}
- /* Log an error if we were unable to build the group filter for some
+ /*
+ * Log an error if we were unable to build the group filter for some
* reason. If this happens, the memberOf plugin will not be able to
* check if an entry is a group, causing it to not catch changes. This
* shouldn't happen, but there may be some garbage configuration that
- * could trigger this. */
+ * could trigger this.
+ */
if ((theConfig.group_filter = slapi_str2filter(filter_str)) == NULL)
{
slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
@@ -569,13 +558,10 @@ memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
memberof_unlock_config();
done:
- slapi_ch_free_string(&sharedcfg);
slapi_sdn_free(&config_sdn);
- if(config_entry){
- /* we switched the entry pointer to the shared config entry - which needs to be freed */
- slapi_entry_free(e);
- }
+ slapi_entry_free(config_entry);
slapi_ch_array_free(groupattrs);
+ slapi_ch_free_string(&sharedcfg);
slapi_ch_free_string(&memberof_attr);
slapi_ch_free_string(&allBackends);
slapi_ch_free_string(&skip_nested);
@@ -772,6 +758,7 @@ memberof_config_get_entry_scope_exclude_subtree()
return entry_exclude_subtree;
}
+
/*
* Check if we are modifying the config, or changing the shared config entry
*/
@@ -780,53 +767,133 @@ memberof_shared_config_validate(Slapi_PBlock *pb)
{
Slapi_Entry *e = 0;
Slapi_Entry *resulting_e = 0;
- Slapi_DN *sdn = 0;
+ Slapi_Entry *config_entry = NULL;
+ Slapi_DN *sdn = NULL;
+ Slapi_DN *config_sdn = NULL;
Slapi_Mods *smods = 0;
+ Slapi_Mod *smod = NULL, *nextmod = NULL;
LDAPMod **mods = NULL;
char returntext[SLAPI_DSE_RETURNTEXT_SIZE];
+ char *configarea_dn = NULL;
int ret = SLAPI_PLUGIN_SUCCESS;
slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn);
- if (slapi_sdn_issuffix(sdn, memberof_get_config_area()) &&
- slapi_sdn_compare(sdn, memberof_get_config_area()) == 0)
- {
- /*
- * This is the shared config entry. Apply the mods and set/validate
- * the config
- */
- int result = 0;
-
+ if (slapi_sdn_compare(sdn, memberof_get_plugin_area()) == 0 ||
+ slapi_sdn_compare(sdn, memberof_get_config_area()) == 0)
+ {
slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &e);
if(e){
+ /*
+ * Create a copy of the entry and apply the
+ * mods to create the resulting entry.
+ */
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
smods = slapi_mods_new();
slapi_mods_init_byref(smods, mods);
-
- /* Create a copy of the entry and apply the
- * mods to create the resulting entry. */
resulting_e = slapi_entry_dup(e);
if (mods && (slapi_entry_apply_mods(resulting_e, mods) != LDAP_SUCCESS)) {
/* we don't care about this, the update is invalid and will be caught later */
goto bail;
}
- if ( SLAPI_DSE_CALLBACK_ERROR == memberof_validate_config (pb, NULL, resulting_e, &ret, returntext,0)) {
- slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
- "%s", returntext);
- ret = LDAP_UNWILLING_TO_PERFORM;
+ if (slapi_sdn_compare(sdn, memberof_get_plugin_area())){
+ /*
+ * This entry is a plugin config area entry, validate it.
+ */
+ if( SLAPI_DSE_CALLBACK_ERROR == memberof_validate_config (pb, NULL, resulting_e, &ret, returntext,0)) {
+ ret = LDAP_UNWILLING_TO_PERFORM;
+ }
+ } else {
+ /*
+ * This is the memberOf plugin entry, check if we are adding/replacing the
+ * plugin config area.
+ */
+ nextmod = slapi_mod_new();
+ for (smod = slapi_mods_get_first_smod(smods, nextmod);
+ smod != NULL;
+ smod = slapi_mods_get_next_smod(smods, nextmod) )
+ {
+ if ( PL_strcasecmp(SLAPI_PLUGIN_SHARED_CONFIG_AREA, slapi_mod_get_type(smod)) == 0 )
+ {
+ /*
+ * Okay, we are modifying the plugin config area, we only care about
+ * adds and replaces.
+ */
+ if(SLAPI_IS_MOD_REPLACE(slapi_mod_get_operation(smod)) ||
+ SLAPI_IS_MOD_ADD(slapi_mod_get_operation(smod)))
+ {
+ struct berval *bv = NULL;
+ int rc = 0;
+
+ bv = slapi_mod_get_first_value(smod);
+ configarea_dn = slapi_ch_strdup(bv->bv_val);
+ if(configarea_dn){
+ /* Check the DN syntax */
+ rc = slapi_dn_syntax_check(pb, configarea_dn, 1);
+ if (rc) { /* syntax check failed */
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "%s does not contain a valid DN (%s)",
+ SLAPI_PLUGIN_SHARED_CONFIG_AREA, configarea_dn);
+ ret = LDAP_UNWILLING_TO_PERFORM;
+ goto bail;
+ }
+
+ /* Check if the plugin config area entry exists */
+ if((config_sdn = slapi_sdn_new_dn_byval(configarea_dn))){
+ rc = slapi_search_internal_get_entry(config_sdn, NULL, &config_entry,
+ memberof_get_plugin_id());
+ if(config_entry){
+ int err = 0;
+ /*
+ * Validate the settings from the new config area.
+ */
+ if ( memberof_validate_config(pb, NULL, config_entry, &err, returntext,0)
+ == SLAPI_DSE_CALLBACK_ERROR )
+ {
+ ret = LDAP_UNWILLING_TO_PERFORM;
+ goto bail;
+
+ }
+ } else {
+ /* The config area does not exist */
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Unable to locate shared config entry (%s) error %d",
+ slapi_sdn_get_dn(memberof_get_config_area()), rc);
+ ret = LDAP_UNWILLING_TO_PERFORM;
+ goto bail;
+ }
+ }
+ }
+ slapi_ch_free_string(&configarea_dn);
+ slapi_sdn_free(&config_sdn);
+ slapi_entry_free(config_entry);
+ }
+ }
+ }
}
} else {
- slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_shared_config_validate: "
- "Unable to locate shared config entry (%s) error %d\n",
- slapi_sdn_get_dn(memberof_get_config_area()), result);
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,"Unable to locate shared config entry (%s)",
+ slapi_sdn_get_dn(memberof_get_config_area()));
ret = LDAP_UNWILLING_TO_PERFORM;
}
}
bail:
+
+ if (ret){
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
+ slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, returntext);
+ slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, "memberof_shared_config_validate: %s/n",
+ returntext);
+ }
+ slapi_sdn_free(&config_sdn);
+ if(nextmod)
+ slapi_mod_free(&nextmod);
slapi_mods_free(&smods);
slapi_entry_free(resulting_e);
+ slapi_entry_free(config_entry);
+ slapi_ch_free_string(&configarea_dn);
return ret;
}
| 0 |
fac83eaefd2be90d92643b45244848cbddc6c2b9
|
389ds/389-ds-base
|
Change "return"s in modGroupMembership to "break"s to avoid leaking
Reviewed by: rmeggins
|
commit fac83eaefd2be90d92643b45244848cbddc6c2b9
Author: Ken Rossato <[email protected]>
Date: Mon Aug 27 17:05:43 2012 -0400
Change "return"s in modGroupMembership to "break"s to avoid leaking
Reviewed by: rmeggins
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
index 5ae5abb5b..dc8e7ce3f 100644
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
@@ -286,48 +286,50 @@ modGroupMembership(Slapi_Entry *entry, Slapi_Mods *smods, int *do_modify)
int j = 0;
if (SLAPI_IS_MOD_DELETE(del_mod) || smod_deluids != NULL) {
- Slapi_Attr * mu_attr = NULL; /* Entry attributes */
- rc = slapi_entry_attr_find(entry, "memberUid", &mu_attr);
- if (rc != 0 || mu_attr == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership end: attribute memberUid not found\n");
- return 0;
- }
- /* found attribute uniquemember */
- if (smod_deluids == NULL) { /* deletion of the last value, deletes the Attribut from entry complete, this operation has no value, so we must look by self */
- Slapi_Attr * um_attr = NULL; /* Entry attributes */
- Slapi_Value * uid_dn_value = NULL; /* Attribute values */
- int rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
- if (rc != 0 || um_attr == NULL) {
+ do { /* Create a context to "break" from */
+ Slapi_Attr * mu_attr = NULL; /* Entry attributes */
+ rc = slapi_entry_attr_find(entry, "memberUid", &mu_attr);
+ if (rc != 0 || mu_attr == NULL) {
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership end: attribute uniquemember not found\n");
- return 0;
+ "modGroupMembership end: attribute memberUid not found\n");
+ break;
}
/* found attribute uniquemember */
- /* ...loop for value... */
- for (j = slapi_attr_first_value(um_attr, &uid_dn_value); j != -1;
- j = slapi_attr_next_value(um_attr, j, &uid_dn_value)) {
- slapi_ch_array_add(&smod_deluids,
- slapi_ch_strdup(slapi_value_get_string(uid_dn_value)));
+ if (smod_deluids == NULL) { /* deletion of the last value, deletes the Attribut from entry complete, this operation has no value, so we must look by self */
+ Slapi_Attr * um_attr = NULL; /* Entry attributes */
+ Slapi_Value * uid_dn_value = NULL; /* Attribute values */
+ int rc = slapi_entry_attr_find(entry, "uniquemember", &um_attr);
+ if (rc != 0 || um_attr == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership end: attribute uniquemember not found\n");
+ break;
+ }
+ /* found attribute uniquemember */
+ /* ...loop for value... */
+ for (j = slapi_attr_first_value(um_attr, &uid_dn_value); j != -1;
+ j = slapi_attr_next_value(um_attr, j, &uid_dn_value)) {
+ slapi_ch_array_add(&smod_deluids,
+ slapi_ch_strdup(slapi_value_get_string(uid_dn_value)));
+ }
}
- }
- /* ...loop for value... */
- for (j = slapi_attr_first_value(mu_attr, &uid_value); j != -1;
- j = slapi_attr_next_value(mu_attr, j, &uid_value)) {
- /* remove from uniquemember: remove from memberUid also */
- const char *uid = NULL;
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: test dellist \n");
- uid = slapi_value_get_string(uid_value);
- slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: test dellist %s\n", uid);
- if (uid_in_set(uid, smod_deluids)) {
- slapi_ch_array_add(&deluids, slapi_ch_strdup(uid));
+ /* ...loop for value... */
+ for (j = slapi_attr_first_value(mu_attr, &uid_value); j != -1;
+ j = slapi_attr_next_value(mu_attr, j, &uid_value)) {
+ /* remove from uniquemember: remove from memberUid also */
+ const char *uid = NULL;
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: test dellist \n");
+ uid = slapi_value_get_string(uid_value);
slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
- "modGroupMembership: add to dellist %s\n", uid);
- doModify = true;
+ "modGroupMembership: test dellist %s\n", uid);
+ if (uid_in_set(uid, smod_deluids)) {
+ slapi_ch_array_add(&deluids, slapi_ch_strdup(uid));
+ slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
+ "modGroupMembership: add to dellist %s\n", uid);
+ doModify = true;
+ }
}
- }
+ } while (false);
}
if (smod_adduids != NULL) { /* not MOD_DELETE */
const char *uid_dn = NULL;
| 0 |
0bef150e9d25e22adeeb0f46e8179f2b14025095
|
389ds/389-ds-base
|
dbscan - Support additional options (-t truncate -R)
Thanks to [email protected] for his ack.
|
commit 0bef150e9d25e22adeeb0f46e8179f2b14025095
Author: Noriko Hosoi <[email protected]>
Date: Fri Jan 27 15:43:30 2017 -0800
dbscan - Support additional options (-t truncate -R)
Thanks to [email protected] for his ack.
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index c7cf0bb4b..bb3fe26f1 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -2773,12 +2773,14 @@ class DirSrv(SimpleLDAPObject, object):
return result
- def dbscan(self, bename=None, index=None, key=None):
+ def dbscan(self, bename=None, index=None, key=None, width=None, isRaw=False):
"""
@param bename - The backend name to scan
@param index - index name (e.g., cn or cn.db) to scan
@param key - index key to dump
@param id - entry id to dump
+ @param width - entry truncate size (bytes)
+ @param isRaw - dump as raw data
@return - dumped string
"""
DirSrvTools.lib389User(user=DEFAULT_USER)
@@ -2794,7 +2796,7 @@ class DirSrv(SimpleLDAPObject, object):
elif '.db' in index:
indexfile = os.path.join(self.dbdir, bename, index)
else:
- indexfile = os.path.join(self.dbdir, bename, index)
+ indexfile = os.path.join(self.dbdir, bename, index + '.db')
option = ''
if 'id2entry' in index:
@@ -2804,6 +2806,12 @@ class DirSrv(SimpleLDAPObject, object):
if key:
option = ' -k %s' % key
+ if width:
+ option = option + ' -t %d' % width
+
+ if isRaw:
+ option = option + ' -R'
+
cmd = '%s -f %s' % (prog, indexfile)
if len(option) > 0:
| 0 |
08e49c1de2ba34538b2b0122ea3ef3e1fb0e6c5e
|
389ds/389-ds-base
|
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
description: Catch possible NULL pointer in filter_optimize().
|
commit 08e49c1de2ba34538b2b0122ea3ef3e1fb0e6c5e
Author: Endi S. Dewata <[email protected]>
Date: Fri Jul 9 20:48:08 2010 -0500
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
description: Catch possible NULL pointer in filter_optimize().
diff --git a/ldap/servers/slapd/filter.c b/ldap/servers/slapd/filter.c
index b3e96b4a3..b4a3102a8 100644
--- a/ldap/servers/slapd/filter.c
+++ b/ldap/servers/slapd/filter.c
@@ -1522,7 +1522,7 @@ filter_optimize(Slapi_Filter *f)
if(f_child->f_choice != LDAP_FILTER_NOT)
{
/* we have a winner, do swap */
- f_prev->f_next = f_child->f_next;
+ if (f_prev) f_prev->f_next = f_child->f_next;
f_child->f_next = f->f_list;
f->f_list = f_child;
break;
| 0 |
4d154353b014576b9630d63d3ed7b5e5676f13bf
|
389ds/389-ds-base
|
Ticket #48366 - proxyauth does not work bound as directory manager
Description: when binding as directory manager always full access is granted, even if a proxyauthzid is presnt
Fix: when evaluating if access control can be skipped check for proxy auth
Ticket: https://fedorahosted.org/389/ticket/48366
Reviewed by: Noriko, Thanks
|
commit 4d154353b014576b9630d63d3ed7b5e5676f13bf
Author: Ludwig Krispenz <[email protected]>
Date: Tue Feb 16 10:52:57 2016 +0100
Ticket #48366 - proxyauth does not work bound as directory manager
Description: when binding as directory manager always full access is granted, even if a proxyauthzid is presnt
Fix: when evaluating if access control can be skipped check for proxy auth
Ticket: https://fedorahosted.org/389/ticket/48366
Reviewed by: Noriko, Thanks
diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
index be2b80577..ba6b774b4 100644
--- a/ldap/servers/plugins/acl/acl.c
+++ b/ldap/servers/plugins/acl/acl.c
@@ -287,7 +287,7 @@ acl_access_allowed(
/* Check for things we need to skip */
TNF_PROBE_0_DEBUG(acl_skipaccess_start,"ACL","");
- if ( acl_skip_access_check ( pb, e )) {
+ if ( acl_skip_access_check ( pb, e, access )) {
slapi_log_error (loglevel, plugin_name,
"conn=%" NSPRIu64 " op=%d (main): Allow %s on entry(%s)"
": root user\n",
@@ -921,7 +921,7 @@ acl_read_access_allowed_on_entry (
** If it's the root, or acl is off or the entry is a rootdse,
** Then you have the privilege to read it.
*/
- if ( acl_skip_access_check ( pb, e ) ) {
+ if ( acl_skip_access_check ( pb, e, access ) ) {
char *n_edn = slapi_entry_get_ndn ( e );
slapi_log_error (SLAPI_LOG_ACL, plugin_name,
"Root access (%s) allowed on entry(%s)\n",
@@ -1227,7 +1227,7 @@ acl_read_access_allowed_on_attr (
n_edn = slapi_entry_get_ndn ( e );
/* If it's the root or acl is off or rootdse, he has all the priv */
- if ( acl_skip_access_check ( pb, e ) ) {
+ if ( acl_skip_access_check ( pb, e, access ) ) {
slapi_log_error (SLAPI_LOG_ACL, plugin_name,
"Root access (%s) allowed on entry(%s)\n",
acl_access2str(access),
@@ -4053,14 +4053,17 @@ acl__get_attrEval ( struct acl_pblock *aclpb, char *attr )
*
*/
int
-acl_skip_access_check ( Slapi_PBlock *pb, Slapi_Entry *e )
+acl_skip_access_check ( Slapi_PBlock *pb, Slapi_Entry *e, int access )
{
int rv, isRoot, accessCheckDisabled;
void *conn = NULL;
Slapi_Backend *be;
+ struct acl_pblock *aclpb = NULL;
slapi_pblock_get ( pb, SLAPI_REQUESTOR_ISROOT, &isRoot );
- if ( isRoot ) return ACL_TRUE;
+ /* need to check if root is proying another user */
+ aclpb = acl_get_aclpb ( pb, ACLPB_PROXYDN_PBLOCK );
+ if ( isRoot && ((access &SLAPI_ACL_PROXY) || !aclpb)) return ACL_TRUE;
/* See if this is local request */
slapi_pblock_get ( pb, SLAPI_CONNECTION, &conn);
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index da39cbcf9..6e3198f29 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -822,7 +822,7 @@ void acl_init_aclpb ( Slapi_PBlock *pb , Acl_PBlock *aclpb,
const char *dn, int copy_from_aclcb);
int acl_create_aclpb_pool ();
void acl_destroy_aclpb_pool ();
-int acl_skip_access_check ( Slapi_PBlock *pb, Slapi_Entry *e );
+int acl_skip_access_check ( Slapi_PBlock *pb, Slapi_Entry *e, int access );
int aclext_alloc_lockarray ();
void aclext_free_lockarray();
diff --git a/ldap/servers/plugins/acl/acllist.c b/ldap/servers/plugins/acl/acllist.c
index d604e3732..cc0e9b3ed 100644
--- a/ldap/servers/plugins/acl/acllist.c
+++ b/ldap/servers/plugins/acl/acllist.c
@@ -611,7 +611,7 @@ acllist_init_scan (Slapi_PBlock *pb, int scope, const char *base)
char *basedn = NULL;
int index;
- if ( acl_skip_access_check ( pb, NULL ) ) {
+ if ( acl_skip_access_check ( pb, NULL, 0 ) ) {
return;
}
diff --git a/ldap/servers/plugins/acl/aclplugin.c b/ldap/servers/plugins/acl/aclplugin.c
index d90996e8c..50de2ccc2 100644
--- a/ldap/servers/plugins/acl/aclplugin.c
+++ b/ldap/servers/plugins/acl/aclplugin.c
@@ -110,14 +110,22 @@ aclplugin_preop_search ( Slapi_PBlock *pb )
Slapi_DN *sdn = NULL;
int optype;
int isRoot;
+ int isProxy = 0;
int rc = 0;
+ char *errtxt = NULL;
+ char *proxy_dn = NULL;
TNF_PROBE_0_DEBUG(aclplugin_preop_search_start ,"ACL","");
slapi_pblock_get ( pb, SLAPI_OPERATION_TYPE, &optype );
slapi_pblock_get ( pb, SLAPI_REQUESTOR_ISROOT, &isRoot );
- if ( isRoot ) {
+ if (LDAP_SUCCESS == proxyauth_get_dn(pb, &proxy_dn, &errtxt) && proxy_dn) {
+ isProxy = 1;
+ slapi_ch_free_string(&proxy_dn);
+ }
+
+ if ( isRoot && !isProxy) {
TNF_PROBE_1_DEBUG(aclplugin_preop_search_end ,"ACL","",
tnf_string,isroot,"");
return rc;
| 0 |
6b4e0432f3c98c509b7c1e6d97a29b3cd08cad48
|
389ds/389-ds-base
|
fix deprecated repl args in dirsrv class - use default timeout of 120
Reviewed by: nkinder (Thanks!)
|
commit 6b4e0432f3c98c509b7c1e6d97a29b3cd08cad48
Author: Rich Megginson <[email protected]>
Date: Wed Dec 18 10:28:51 2013 -0700
fix deprecated repl args in dirsrv class - use default timeout of 120
Reviewed by: nkinder (Thanks!)
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 59ee7fb61..206975011 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -2084,13 +2084,19 @@ class DirSrv(SimpleLDAPObject):
log.warn("User already exists: %r " % user)
# setup replica
- repArgs['rtype'], repArgs['rid'] = repArgs['type'], repArgs['id']
+ # map old style args to new style replica args
+ if repArgs['type'] == MASTER_TYPE:
+ repArgs['role'] = REPLICAROLE_MASTER
+ elif repArgs['type'] == LEAF_TYPE:
+ repArgs['role'] = REPLICAROLE_CONSUMER
+ else:
+ repArgs['role'] = REPLICAROLE_HUB
+ repArgs['rid'] = repArgs['id']
# remove invalid arguments from replica.add
- for invalid_arg in 'type id bename'.split():
- del repArgs[invalid_arg]
- if 'log' in repArgs:
- del repArgs['log']
+ for invalid_arg in 'type id bename log'.split():
+ if invalid_arg in repArgs:
+ del repArgs[invalid_arg]
ret = self.replica.add(**repArgs)
if 'legacy' in repArgs:
diff --git a/src/lib389/lib389/tools.py b/src/lib389/lib389/tools.py
index 4b83feaa9..f2838821a 100644
--- a/src/lib389/lib389/tools.py
+++ b/src/lib389/lib389/tools.py
@@ -243,7 +243,7 @@ class DirSrvTools(object):
return 0
@staticmethod
- def stop(self, verbose=False, timeout=0):
+ def stop(self, verbose=False, timeout=120):
"""Stop server or raise."""
if not self.isLocal and hasattr(self, 'asport'):
log.info("stopping remote server ", self)
@@ -260,7 +260,7 @@ class DirSrvTools(object):
return DirSrvTools.serverCmd(self, 'stop', verbose, timeout)
@staticmethod
- def start(self, verbose=False, timeout=0):
+ def start(self, verbose=False, timeout=120):
if not self.isLocal and hasattr(self, 'asport'):
log.debug("starting remote server %s " % self)
cgiargs = {}
| 0 |
88fac273d6ab2abee03bcddc5a49ed1b8c0e7b2b
|
389ds/389-ds-base
|
Issue 49381 - Refactor filter test suite docstrings
Description: We need to have properly formatted and detailed
docstrings in all existing test suites. Filter test suite is
modified in this commit.
https://pagure.io/389-ds-base/issue/49381
Reviewed by: Simon
Signed-off-by: Simon Pichugin <[email protected]>
|
commit 88fac273d6ab2abee03bcddc5a49ed1b8c0e7b2b
Author: Amita Sharma <[email protected]>
Date: Mon Oct 9 19:42:44 2017 +0530
Issue 49381 - Refactor filter test suite docstrings
Description: We need to have properly formatted and detailed
docstrings in all existing test suites. Filter test suite is
modified in this commit.
https://pagure.io/389-ds-base/issue/49381
Reviewed by: Simon
Signed-off-by: Simon Pichugin <[email protected]>
diff --git a/dirsrvtests/tests/suites/filter/filter_logic.py b/dirsrvtests/tests/suites/filter/filter_logic.py
deleted file mode 100644
index fda86a57a..000000000
--- a/dirsrvtests/tests/suites/filter/filter_logic.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2017 Red Hat, Inc.
-# All rights reserved.
-#
-# License: GPL (version 3 or any later version).
-# See LICENSE for details.
-# --- END COPYRIGHT BLOCK ---
-#
-
-import pytest
-import ldap
-
-from lib389.topologies import topology_st
-from lib389._constants import DEFAULT_SUFFIX
-
-from lib389.idm.user import UserAccounts
-
-"""
-This test case asserts that various logical filters apply correctly and as expected.
-This is to assert that we have correct and working search operations, especially related
-to indexed content from filterindex.c and idl_sets.
-
-important to note, some tests check greater than 10 elements to assert that k-way intersect
-works, where as most of these actually hit the filtertest threshold so they early return.
-"""
-
-USER0_DN = 'uid=user0,ou=People,%s' % DEFAULT_SUFFIX
-USER1_DN = 'uid=user1,ou=People,%s' % DEFAULT_SUFFIX
-USER2_DN = 'uid=user2,ou=People,%s' % DEFAULT_SUFFIX
-USER3_DN = 'uid=user3,ou=People,%s' % DEFAULT_SUFFIX
-USER4_DN = 'uid=user4,ou=People,%s' % DEFAULT_SUFFIX
-USER5_DN = 'uid=user5,ou=People,%s' % DEFAULT_SUFFIX
-USER6_DN = 'uid=user6,ou=People,%s' % DEFAULT_SUFFIX
-USER7_DN = 'uid=user7,ou=People,%s' % DEFAULT_SUFFIX
-USER8_DN = 'uid=user8,ou=People,%s' % DEFAULT_SUFFIX
-USER9_DN = 'uid=user9,ou=People,%s' % DEFAULT_SUFFIX
-USER10_DN = 'uid=user10,ou=People,%s' % DEFAULT_SUFFIX
-USER11_DN = 'uid=user11,ou=People,%s' % DEFAULT_SUFFIX
-USER12_DN = 'uid=user12,ou=People,%s' % DEFAULT_SUFFIX
-USER13_DN = 'uid=user13,ou=People,%s' % DEFAULT_SUFFIX
-USER14_DN = 'uid=user14,ou=People,%s' % DEFAULT_SUFFIX
-USER15_DN = 'uid=user15,ou=People,%s' % DEFAULT_SUFFIX
-USER16_DN = 'uid=user16,ou=People,%s' % DEFAULT_SUFFIX
-USER17_DN = 'uid=user17,ou=People,%s' % DEFAULT_SUFFIX
-USER18_DN = 'uid=user18,ou=People,%s' % DEFAULT_SUFFIX
-USER19_DN = 'uid=user19,ou=People,%s' % DEFAULT_SUFFIX
-
[email protected](scope="module")
-def topology_st_f(topology_st):
- # Add our users to the topology_st
- users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
- for i in range(0, 20):
- users.create(properties={
- 'uid': 'user%s' % i,
- 'cn': 'user%s' % i,
- 'sn': '%s' % i,
- 'uidNumber': '%s' % i,
- 'gidNumber': '%s' % i,
- 'homeDirectory': '/home/user%s' % i
- })
- # return it
- # print("ATTACH NOW")
- # import time
- # time.sleep(30)
- return topology_st.standalone
-
-def _check_filter(topology_st_f, filt, expect_len, expect_dns):
- # print("checking %s" % filt)
- results = topology_st_f.search_s("ou=People,%s" % DEFAULT_SUFFIX, ldap.SCOPE_ONELEVEL, filt, ['uid',])
- assert len(results) == expect_len
- result_dns = [result.dn for result in results]
- assert set(expect_dns) == set(result_dns)
-
-def test_filter_logic_eq(topology_st_f):
- _check_filter(topology_st_f, '(uid=user0)', 1, [USER0_DN])
-
-def test_filter_logic_sub(topology_st_f):
- _check_filter(topology_st_f, '(uid=user*)', 20, [
- USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN,
- USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
- USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
- ])
-
-def test_filter_logic_not_eq(topology_st_f):
- _check_filter(topology_st_f, '(!(uid=user0))', 19, [
- USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN,
- USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
- USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
- ])
-
-# More not cases?
-
-def test_filter_logic_range(topology_st_f):
- ### REMEMBER: user10 is less than user5 because it's strcmp!!!
- _check_filter(topology_st_f, '(uid>=user5)', 5, [
- USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- ])
- _check_filter(topology_st_f, '(uid<=user4)', 15, [
- USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN,
- USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
- USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
- ])
- _check_filter(topology_st_f, '(uid>=ZZZZ)', 0, [])
- _check_filter(topology_st_f, '(uid<=aaaa)', 0, [])
-
-def test_filter_logic_and_eq(topology_st_f):
- _check_filter(topology_st_f, '(&(uid=user0)(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(&(uid=user0)(cn=user1))', 0, [])
- _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(&(uid=user0)(cn=user1)(sn=0))', 0, [])
- _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=1))', 0, [])
-
-def test_filter_logic_and_range(topology_st_f):
- _check_filter(topology_st_f, '(&(uid>=user5)(cn<=user7))', 3, [
- USER5_DN, USER6_DN, USER7_DN
- ])
-
-def test_filter_logic_and_allid_shortcut(topology_st_f):
- _check_filter(topology_st_f, '(&(objectClass=*)(uid=user0)(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(objectClass=*))', 1, [USER0_DN])
-
-def test_filter_logic_or_eq(topology_st_f):
- _check_filter(topology_st_f, '(|(uid=user0)(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(|(uid=user0)(uid=user1))', 2, [USER0_DN, USER1_DN])
- _check_filter(topology_st_f, '(|(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(|(uid=user0)(uid=user1)(sn=0))', 2, [USER0_DN, USER1_DN])
- _check_filter(topology_st_f, '(|(uid=user0)(uid=user1)(uid=user2))', 3, [USER0_DN, USER1_DN, USER2_DN])
-
-def test_filter_logic_and_not_eq(topology_st_f):
- _check_filter(topology_st_f, '(&(uid=user0)(!(cn=user0)))', 0, [])
- _check_filter(topology_st_f, '(&(uid=*)(!(uid=user0)))', 19, [
- USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN,
- USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
- USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
- ])
-
-def test_filter_logic_or_not_eq(topology_st_f):
- _check_filter(topology_st_f, '(|(!(uid=user0))(!(uid=user1)))', 20, [
- USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN,
- USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
- USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
- ])
-
-def test_filter_logic_and_range(topology_st_f):
- # These all hit shortcut cases.
- _check_filter(topology_st_f, '(&(uid>=user5)(uid=user6))', 1, [USER6_DN])
- _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0))', 0, [])
- _check_filter(topology_st_f, '(&(uid>=user5)(uid=user6)(sn=6))', 1, [USER6_DN])
- _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0)(sn=0))', 0, [])
- _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0)(sn=1))', 0, [])
- # These all take 2-way or k-way cases.
- _check_filter(topology_st_f, '(&(uid>=user5)(uid>=user6))', 4, [
- USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- ])
- _check_filter(topology_st_f, '(&(uid>=user5)(uid>=user6)(uid>=user7))', 3, [
- USER7_DN, USER8_DN, USER9_DN,
- ])
-
-
-def test_filter_logic_or_range(topology_st_f):
- _check_filter(topology_st_f, '(|(uid>=user5)(uid=user6))', 5, [
- USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- ])
- _check_filter(topology_st_f, '(|(uid>=user5)(uid=user0))', 6, [
- USER0_DN,
- USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
- ])
-
-def test_filter_logic_and_and_eq(topology_st_f):
- _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(&(&(uid=user1)(sn=0))(cn=user0))', 0, [])
- _check_filter(topology_st_f, '(&(&(uid=user0)(sn=1))(cn=user0))', 0, [])
- _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user1))', 0, [])
-
-def test_filter_logic_or_or_eq(topology_st_f):
- _check_filter(topology_st_f, '(|(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(|(|(uid=user1)(sn=0))(cn=user0))', 2, [USER0_DN, USER1_DN])
- _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user0))', 2, [USER0_DN, USER1_DN])
- _check_filter(topology_st_f, '(|(|(uid=user0)(sn=0))(cn=user1))', 2, [USER0_DN, USER1_DN])
- _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user2))', 3, [USER0_DN, USER1_DN, USER2_DN])
-
-def test_filter_logic_and_or_eq(topology_st_f):
- _check_filter(topology_st_f, '(&(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(&(|(uid=user1)(sn=0))(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(&(|(uid=user0)(sn=0))(cn=user1))', 0, [])
- _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=*))', 2, [USER0_DN, USER1_DN])
-
-def test_filter_logic_or_and_eq(topology_st_f):
- _check_filter(topology_st_f, '(|(&(uid=user0)(sn=0))(uid=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(|(&(uid=user1)(sn=2))(uid=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(|(&(uid=user0)(sn=1))(uid=user0))', 1, [USER0_DN])
- _check_filter(topology_st_f, '(|(&(uid=user1)(sn=1))(uid=user0))', 2, [USER0_DN, USER1_DN])
-
-
diff --git a/dirsrvtests/tests/suites/filter/filter_logic_test.py b/dirsrvtests/tests/suites/filter/filter_logic_test.py
new file mode 100644
index 000000000..130ff2de1
--- /dev/null
+++ b/dirsrvtests/tests/suites/filter/filter_logic_test.py
@@ -0,0 +1,445 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+
+import pytest
+import ldap
+
+from lib389.topologies import topology_st
+from lib389._constants import DEFAULT_SUFFIX
+
+from lib389.idm.user import UserAccounts
+
+"""
+This test case asserts that various logical filters apply correctly and as expected.
+This is to assert that we have correct and working search operations, especially related
+to indexed content from filterindex.c and idl_sets.
+
+important to note, some tests check greater than 10 elements to assert that k-way intersect
+works, where as most of these actually hit the filtertest threshold so they early return.
+"""
+
+USER0_DN = 'uid=user0,ou=People,%s' % DEFAULT_SUFFIX
+USER1_DN = 'uid=user1,ou=People,%s' % DEFAULT_SUFFIX
+USER2_DN = 'uid=user2,ou=People,%s' % DEFAULT_SUFFIX
+USER3_DN = 'uid=user3,ou=People,%s' % DEFAULT_SUFFIX
+USER4_DN = 'uid=user4,ou=People,%s' % DEFAULT_SUFFIX
+USER5_DN = 'uid=user5,ou=People,%s' % DEFAULT_SUFFIX
+USER6_DN = 'uid=user6,ou=People,%s' % DEFAULT_SUFFIX
+USER7_DN = 'uid=user7,ou=People,%s' % DEFAULT_SUFFIX
+USER8_DN = 'uid=user8,ou=People,%s' % DEFAULT_SUFFIX
+USER9_DN = 'uid=user9,ou=People,%s' % DEFAULT_SUFFIX
+USER10_DN = 'uid=user10,ou=People,%s' % DEFAULT_SUFFIX
+USER11_DN = 'uid=user11,ou=People,%s' % DEFAULT_SUFFIX
+USER12_DN = 'uid=user12,ou=People,%s' % DEFAULT_SUFFIX
+USER13_DN = 'uid=user13,ou=People,%s' % DEFAULT_SUFFIX
+USER14_DN = 'uid=user14,ou=People,%s' % DEFAULT_SUFFIX
+USER15_DN = 'uid=user15,ou=People,%s' % DEFAULT_SUFFIX
+USER16_DN = 'uid=user16,ou=People,%s' % DEFAULT_SUFFIX
+USER17_DN = 'uid=user17,ou=People,%s' % DEFAULT_SUFFIX
+USER18_DN = 'uid=user18,ou=People,%s' % DEFAULT_SUFFIX
+USER19_DN = 'uid=user19,ou=People,%s' % DEFAULT_SUFFIX
+
[email protected](scope="module")
+def topology_st_f(topology_st):
+ # Add our users to the topology_st
+ users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
+ for i in range(0, 20):
+ users.create(properties={
+ 'uid': 'user%s' % i,
+ 'cn': 'user%s' % i,
+ 'sn': '%s' % i,
+ 'uidNumber': '%s' % i,
+ 'gidNumber': '%s' % i,
+ 'homeDirectory': '/home/user%s' % i
+ })
+ # return it
+ # print("ATTACH NOW")
+ # import time
+ # time.sleep(30)
+ return topology_st.standalone
+
+def _check_filter(topology_st_f, filt, expect_len, expect_dns):
+ # print("checking %s" % filt)
+ results = topology_st_f.search_s("ou=People,%s" % DEFAULT_SUFFIX, ldap.SCOPE_ONELEVEL, filt, ['uid',])
+ assert len(results) == expect_len
+ result_dns = [result.dn for result in results]
+ assert set(expect_dns) == set(result_dns)
+
+
+def test_eq(topology_st_f):
+ """Test filter logic with "equal to" operator
+
+ :id: 1b0b7e59-a5ac-4825-8d36-525f4f0149a9
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter '(uid=user0)'
+ :expectedresults:
+ 1. There should be 1 user listed user0
+ """
+ _check_filter(topology_st_f, '(uid=user0)', 1, [USER0_DN])
+
+
+def test_sub(topology_st_f):
+ """Test filter logic with "sub"
+
+ :id: 8cfa946d-7ddf-4f8e-9f9f-39da8f35304e
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (uid=user*)
+ :expectedresults:
+ 1. There should be 20 users listed from user0 to user19
+ """
+ _check_filter(topology_st_f, '(uid=user*)', 20, [
+ USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN,
+ USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
+ USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
+ ])
+
+
+def test_not_eq(topology_st_f):
+ """Test filter logic with "not equal to" operator
+
+ :id: 1422ec65-421d-473b-89ba-649f8decc1ab
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (!(uid=user0)
+ :expectedresults:
+ 1. There should be 19 users listed from user1 to user19
+ """
+ _check_filter(topology_st_f, '(!(uid=user0))', 19, [
+ USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN,
+ USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
+ USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
+ ])
+
+# More not cases?
+
+def test_ranges(topology_st_f):
+ """Test filter logic with range
+
+ :id: cc7c25f0-6a6e-465b-8d32-7fcc1aec84ee
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (uid>=user5)
+ 2. Search for test users with filter (uid<=user4)
+ 3. Search for test users with filter (uid>=ZZZZ)
+ 4. Search for test users with filter (uid<=aaaa)
+ :expectedresults:
+ 1. There should be 5 users listed from user5 to user9
+ 2. There should be 15 users listed from user0 to user4
+ and from user10 to user19
+ 3. There should not be any user listed
+ 4. There should not be any user listed
+ """
+
+ ### REMEMBER: user10 is less than user5 because it's strcmp!!!
+ _check_filter(topology_st_f, '(uid>=user5)', 5, [
+ USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ ])
+ _check_filter(topology_st_f, '(uid<=user4)', 15, [
+ USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN,
+ USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
+ USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
+ ])
+ _check_filter(topology_st_f, '(uid>=ZZZZ)', 0, [])
+ _check_filter(topology_st_f, '(uid<=aaaa)', 0, [])
+
+
+def test_and_eq(topology_st_f):
+ """Test filter logic with "AND" operator
+
+ :id: 4721fd7c-8d0b-43e6-b2e8-a5bac7674f99
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (&(uid=user0)(cn=user0))
+ 2. Search for test users with filter (&(uid=user0)(cn=user1))
+ 3. Search for test users with filter (&(uid=user0)(cn=user0)(sn=0))
+ 4. Search for test users with filter (&(uid=user0)(cn=user1)(sn=0))
+ 5. Search for test users with filter (&(uid=user0)(cn=user0)(sn=1))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user0
+ 2. There should not be any user listed
+ 3. There should be 1 user listed i.e. user0
+ 4. There should not be any user listed
+ 5. There should not be any user listed
+ """
+ _check_filter(topology_st_f, '(&(uid=user0)(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(&(uid=user0)(cn=user1))', 0, [])
+ _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(&(uid=user0)(cn=user1)(sn=0))', 0, [])
+ _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=1))', 0, [])
+
+
+def test_range(topology_st_f):
+ """Test filter logic with range
+
+ :id: 617e6290-866e-4b5d-a300-d8f1715ad052
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (&(uid>=user5)(cn<=user7))
+ :expectedresults:
+ 1. There should be 3 users listed i.e. user5 to user7
+ """
+ _check_filter(topology_st_f, '(&(uid>=user5)(cn<=user7))', 3, [
+ USER5_DN, USER6_DN, USER7_DN
+ ])
+
+
+def test_and_allid_shortcut(topology_st_f):
+ """Test filter logic with "AND" operator
+ and shortcuts
+
+ :id: f4784752-d269-4ceb-aada-fafe0a5fc14c
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (&(objectClass=*)(uid=user0)(cn=user0))
+ 2. Search for test users with filter (&(uid=user0)(cn=user0)(objectClass=*))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user0
+ 2. There should be 1 user listed i.e. user0
+ """
+ _check_filter(topology_st_f, '(&(objectClass=*)(uid=user0)(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(objectClass=*))', 1, [USER0_DN])
+
+
+def test_or_eq(topology_st_f):
+ """Test filter logic with "or" and "equal to" operators
+
+ :id: a23a4fc9-0f5c-49ce-b1f7-6ac10bcd7763
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (|(uid=user0)(cn=user0))
+ 2. Search for test users with filter (|(uid=user0)(uid=user1))
+ 3. Search for test users with filter (|(uid=user0)(cn=user0)(sn=0))
+ 4. Search for test users with filter (|(uid=user0)(uid=user1)(sn=0))
+ 5. Search for test users with filter (|(uid=user0)(uid=user1)(uid=user2))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user0
+ 2. There should be 2 users listed i.e. user0 and user1
+ 3. There should be 1 user listed i.e. user0
+ 4. There should be 2 users listed i.e. user0 and user1
+ 5. There should be 3 users listed i.e. user0 to user2
+ """
+ _check_filter(topology_st_f, '(|(uid=user0)(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(|(uid=user0)(uid=user1))', 2, [USER0_DN, USER1_DN])
+ _check_filter(topology_st_f, '(|(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(|(uid=user0)(uid=user1)(sn=0))', 2, [USER0_DN, USER1_DN])
+ _check_filter(topology_st_f, '(|(uid=user0)(uid=user1)(uid=user2))', 3, [USER0_DN, USER1_DN, USER2_DN])
+
+
+def test_and_not_eq(topology_st_f):
+ """Test filter logic with "not equal" to operator
+
+ :id: bd00cb2b-35bb-49c0-8387-f60a6ada7c87
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (&(uid=user0)(!(cn=user0)))
+ 2. Search for test users with filter (&(uid=*)(!(uid=user0)))
+ :expectedresults:
+ 1. There should be no users listed
+ 2. There should be 19 users listed i.e. user1 to user19
+ """
+ _check_filter(topology_st_f, '(&(uid=user0)(!(cn=user0)))', 0, [])
+ _check_filter(topology_st_f, '(&(uid=*)(!(uid=user0)))', 19, [
+ USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN,
+ USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
+ USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
+ ])
+
+
+def test_or_not_eq(topology_st_f):
+ """Test filter logic with "OR and NOT" operators
+
+ :id: 8f62f339-72c9-49e4-8126-b2a14e61b9c0
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (|(!(uid=user0))(!(uid=user1)))
+ :expectedresults:
+ 1. There should be 20 users listed i.e. user0 to user19
+ """
+ _check_filter(topology_st_f, '(|(!(uid=user0))(!(uid=user1)))', 20, [
+ USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN,
+ USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN,
+ USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN
+ ])
+
+
+def test_and_range(topology_st_f):
+ """Test filter logic with range
+
+ :id: 8e5a0e2a-4ee1-4cd7-b5ec-90ad4d3ace64
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (&(uid>=user5)(uid=user6))
+ 2. Search for test users with filter (&(uid>=user5)(uid=user0))
+ 3. Search for test users with filter (&(uid>=user5)(uid=user6)(sn=6))
+ 4. Search for test users with filter (&(uid>=user5)(uid=user0)(sn=0))
+ 5. Search for test users with filter (&(uid>=user5)(uid=user0)(sn=1))
+ 6. Search for test users with filter (&(uid>=user5)(uid>=user6))
+ 7. Search for test users with filter (&(uid>=user5)(uid>=user6)(uid>=user7))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user6
+ 2. There should be no users listed
+ 3. There should be 1 user listed i.e. user6
+ 4. There should be no users listed
+ 5. There should be no users listed
+ 6. There should be 4 users listed i.e. user6 to user9
+ 7. There should be 3 users listed i.e. user7 to user9
+ """
+ # These all hit shortcut cases.
+ _check_filter(topology_st_f, '(&(uid>=user5)(uid=user6))', 1, [USER6_DN])
+ _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0))', 0, [])
+ _check_filter(topology_st_f, '(&(uid>=user5)(uid=user6)(sn=6))', 1, [USER6_DN])
+ _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0)(sn=0))', 0, [])
+ _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0)(sn=1))', 0, [])
+ # These all take 2-way or k-way cases.
+ _check_filter(topology_st_f, '(&(uid>=user5)(uid>=user6))', 4, [
+ USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ ])
+ _check_filter(topology_st_f, '(&(uid>=user5)(uid>=user6)(uid>=user7))', 3, [
+ USER7_DN, USER8_DN, USER9_DN,
+ ])
+
+
+
+def test_or_range(topology_st_f):
+ """Test filter logic with range
+
+ :id: bc413e74-667a-48b0-8fbd-e9b7d18a01e4
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (|(uid>=user5)(uid=user6))
+ 2. Search for test users with filter (|(uid>=user5)(uid=user0))
+ :expectedresults:
+ 1. There should be 5 users listed i.e. user5 to user9
+ 2. There should be 6 users listed i.e. user5 to user9 and user0
+ """
+ _check_filter(topology_st_f, '(|(uid>=user5)(uid=user6))', 5, [
+ USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ ])
+ _check_filter(topology_st_f, '(|(uid>=user5)(uid=user0))', 6, [
+ USER0_DN,
+ USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN,
+ ])
+
+
+def test_and_and_eq(topology_st_f):
+ """Test filter logic with "AND" and "equal to" operators
+
+ :id: 5c66eb38-d01f-459e-81e4-d335f97211c7
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (&(&(uid=user0)(sn=0))(cn=user0))
+ 2. Search for test users with filter (&(&(uid=user1)(sn=0))(cn=user0))
+ 3. Search for test users with filter (&(&(uid=user0)(sn=1))(cn=user0))
+ 4. Search for test users with filter (&(&(uid=user0)(sn=0))(cn=user1))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user0
+ 2. There should be no users listed
+ 3. There should be no users listed
+ 4. There should be no users listed
+ """
+ _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(&(&(uid=user1)(sn=0))(cn=user0))', 0, [])
+ _check_filter(topology_st_f, '(&(&(uid=user0)(sn=1))(cn=user0))', 0, [])
+ _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user1))', 0, [])
+
+
+def test_or_or_eq(topology_st_f):
+ """Test filter logic with "AND" and "equal to" operators
+
+ :id: 0cab4bbd-637c-419d-8069-ad5463ecaa75
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (|(|(uid=user0)(sn=0))(cn=user0))
+ 2. Search for test users with filter (|(|(uid=user1)(sn=0))(cn=user0))
+ 3. Search for test users with filter (|(|(uid=user0)(sn=1))(cn=user0))
+ 4. Search for test users with filter (|(|(uid=user0)(sn=0))(cn=user1))
+ 5. Search for test users with filter (|(|(uid=user0)(sn=1))(cn=user2))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user0
+ 2. There should be 2 users listed i.e. user0, user1
+ 3. There should be 2 users listed i.e. user0, user1
+ 4. There should be 2 users listed i.e. user0, user1
+ 5. There should be 3 users listed i.e. user0, user1 and user2
+ """
+ _check_filter(topology_st_f, '(|(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(|(|(uid=user1)(sn=0))(cn=user0))', 2, [USER0_DN, USER1_DN])
+ _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user0))', 2, [USER0_DN, USER1_DN])
+ _check_filter(topology_st_f, '(|(|(uid=user0)(sn=0))(cn=user1))', 2, [USER0_DN, USER1_DN])
+ _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user2))', 3, [USER0_DN, USER1_DN, USER2_DN])
+
+
+def test_and_or_eq(topology_st_f):
+ """Test filter logic with "AND" and "equal to" operators
+
+ :id: 2ce7cc2e-6058-422d-ac3e-e678decf1cc4
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (&(|(uid=user0)(sn=0))(cn=user0))
+ 2. Search for test users with filter (&(|(uid=user1)(sn=0))(cn=user0))
+ 3. Search for test users with filter (&(|(uid=user0)(sn=1))(cn=user0))
+ 4. Search for test users with filter (&(|(uid=user0)(sn=0))(cn=user1))
+ 5. Search for test users with filter (&(|(uid=user0)(sn=1))(cn=*))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user0
+ 2. There should be 1 user listed i.e. user0
+ 3. There should be 1 user listed i.e. user0
+ 4. There should be no users listed
+ 5. There should be 2 users listed i.e. user0 and user1
+ """
+ _check_filter(topology_st_f, '(&(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(&(|(uid=user1)(sn=0))(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(&(|(uid=user0)(sn=0))(cn=user1))', 0, [])
+ _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=*))', 2, [USER0_DN, USER1_DN])
+
+
+def test_or_and_eq(topology_st_f):
+ """Test filter logic with "AND" and "equal to" operators
+
+ :id: ee9fb400-451a-479e-852c-f59b4c937a8d
+ :setup: Standalone instance with 20 test users added
+ from uid=user0 to uid=user20
+ :steps:
+ 1. Search for test users with filter (|(&(uid=user0)(sn=0))(uid=user0))
+ 2. Search for test users with filter (|(&(uid=user1)(sn=2))(uid=user0))
+ 3. Search for test users with filter (|(&(uid=user0)(sn=1))(uid=user0))
+ 4. Search for test users with filter (|(&(uid=user1)(sn=1))(uid=user0))
+ :expectedresults:
+ 1. There should be 1 user listed i.e. user0
+ 2. There should be 1 user listed i.e. user0
+ 3. There should be 1 user listed i.e. user0
+ 4. There should be 2 user listed i.e. user0 and user1
+ """
+ _check_filter(topology_st_f, '(|(&(uid=user0)(sn=0))(uid=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(|(&(uid=user1)(sn=2))(uid=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(|(&(uid=user0)(sn=1))(uid=user0))', 1, [USER0_DN])
+ _check_filter(topology_st_f, '(|(&(uid=user1)(sn=1))(uid=user0))', 2, [USER0_DN, USER1_DN])
+
+
diff --git a/dirsrvtests/tests/suites/filter/filter_test.py b/dirsrvtests/tests/suites/filter/filter_test.py
index 280db68a3..a6007e058 100644
--- a/dirsrvtests/tests/suites/filter/filter_test.py
+++ b/dirsrvtests/tests/suites/filter/filter_test.py
@@ -18,10 +18,20 @@ log = logging.getLogger(__name__)
def test_filter_escaped(topology_st):
- '''
- Test we can search for an '*' in a attribute value.
- '''
-
+ """Test we can search for an '*' in a attribute value.
+
+ :id: 5c9aa40c-c641-4603-bce3-b19f4c1f2031
+ :setup: Standalone instance
+ :steps:
+ 1. Add a test user with an '*' in its attribute value
+ i.e. 'cn=test * me'
+ 2. Add another similar test user without '*' in its attribute value
+ 3. Search test user using search filter "cn=*\**"
+ :expectedresults:
+ 1. This should pass
+ 2. This should pass
+ 3. Test user with 'cn=test * me' only, should be listed
+ """
log.info('Running test_filter_escaped...')
USER1_DN = 'uid=test_entry,' + DEFAULT_SUFFIX
@@ -62,10 +72,18 @@ def test_filter_escaped(topology_st):
def test_filter_search_original_attrs(topology_st):
- '''
- Search and request attributes with extra characters. The returned entry
- should not have these extra characters: "objectclass EXTRA"
- '''
+ """Search and request attributes with extra characters. The returned entry
+ should not have these extra characters: objectclass EXTRA"
+
+ :id: d30d8a1c-84ac-47ba-95f9-41e3453fbf3a
+ :setup: Standalone instance
+ :steps:
+ 1. Execute a search operation for attributes with extra characters
+ 2. Check the search result have these extra characters or not
+ :expectedresults:
+ 1. Search should pass
+ 2. Search result should not have these extra characters attribute
+ """
log.info('Running test_filter_search_original_attrs...')
diff --git a/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py b/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py
index 571e31d44..625c3330e 100644
--- a/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py
+++ b/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py
@@ -96,13 +96,14 @@ def user_aci(topology_st):
def test_supported_features(topology_st):
"""Verify that OID 1.3.6.1.4.1.4203.1.5.1 is published
- in the supportedFeatures [RFC3674] attribute in the rootDSE.
+ in the supportedFeatures [RFC3674] attribute in the rootDSE.
- :ID: 441b3f1f-a24b-4943-aa65-7edce460abbf
- :feature: Filter
+ :id: 441b3f1f-a24b-4943-aa65-7edce460abbf
:setup: Standalone instance
- :steps: 1. Search for 'supportedFeatures' at rootDSE
- :expectedresults: Value 1.3.6.1.4.1.4203.1.5.1 is presented
+ :steps:
+ 1. Search for 'supportedFeatures' at rootDSE
+ :expectedresults:
+ 1. Value 1.3.6.1.4.1.4203.1.5.1 is presented
"""
entries = topology_st.standalone.search_s('', ldap.SCOPE_BASE,
@@ -119,17 +120,24 @@ def test_supported_features(topology_st):
def test_search_basic(topology_st, test_user, user_aci, add_attr,
search_suffix, regular_user, oper_attr_list):
"""Verify that you can get all expected operational attributes
- by a Search Request [RFC2251] with '+' (ASCII 43) filter.
- Please see: https://tools.ietf.org/html/rfc3673
+ by a Search Request [RFC2251] with '+' (ASCII 43) filter.
+ Please see: https://tools.ietf.org/html/rfc3673
- :ID: 14c66bc2-28e1-4f5f-893e-508e0f720f8c
- :feature: Filter
+ :id: 14c66bc2-28e1-4f5f-893e-508e0f720f8c
:setup: Standalone instance, test user for binding,
deny one attribute aci for that user
- :steps: 1. Bind as regular user or Directory Manager
- 2. Search with '+' filter and with additionaly
- 'objectClass' and '*' attrs too
- :expectedresults: All expected values were returned, not more
+ :steps:
+ 1. Bind as regular user or Directory Manager
+ 2. Search with '+' filter and with additionally
+ 'objectClass' and '*' attributes too
+ 3. Check attributes listed contain both operational
+ and non-operational attributes for '*' attributes
+ search
+ :expectedresults:
+ 1. Bind should be successful
+ 2. All expected values of attributes should be returned
+ as per the parametrization done
+ 3. It should pass
"""
if regular_user:
| 0 |
37539f4e15056a7ee29d2a34eb41da2a97839d59
|
389ds/389-ds-base
|
Bug(s) fixed: 169663
Bug Description: Build Cleanup - open source AS, other components;
remove Fortezza; etc.
Reviewed by: Noriko, Nathan, Rob C. (Thanks!)
Fix Description: This allows us to build DS entirely outside of the
firewall with entirely open source components, including setuputil,
adminutil, adminserver, and java components. I still need to address
some issues around nsperl, perldap, dsmlgw, xmltools, and general ease
of build. This also gets rid of the crufty Fortezza build stuff and
addresses some other minor build issues.
Platforms tested: RHEL4
Flag Day: yes, but the internal builds should not be affected
Doc impact: wiki
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
|
commit 37539f4e15056a7ee29d2a34eb41da2a97839d59
Author: Rich Megginson <[email protected]>
Date: Mon Oct 3 19:54:06 2005 +0000
Bug(s) fixed: 169663
Bug Description: Build Cleanup - open source AS, other components;
remove Fortezza; etc.
Reviewed by: Noriko, Nathan, Rob C. (Thanks!)
Fix Description: This allows us to build DS entirely outside of the
firewall with entirely open source components, including setuputil,
adminutil, adminserver, and java components. I still need to address
some issues around nsperl, perldap, dsmlgw, xmltools, and general ease
of build. This also gets rid of the crufty Fortezza build stuff and
addresses some other minor build issues.
Platforms tested: RHEL4
Flag Day: yes, but the internal builds should not be affected
Doc impact: wiki
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
diff --git a/buildpaths.mk b/buildpaths.mk
index b4cb83822..d512d3552 100644
--- a/buildpaths.mk
+++ b/buildpaths.mk
@@ -115,3 +115,23 @@ DB_MAJOR_MINOR := db-4.2
NETSNMP_SOURCE_ROOT = $(BUILD_ROOT)/../net-snmp-5.2.1
#NETSNMP_BUILD_DIR = $(BUILD_ROOT)/../net-snmp
+
+ADMINUTIL_SOURCE_ROOT = $(BUILD_ROOT)/../adminutil
+#ADMINUTIL_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/adminutil
+
+SETUPUTIL_SOURCE_ROOT = $(BUILD_ROOT)/../setuputil
+#SETUPUTIL_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/setuputil
+
+LDAPJDK_SOURCE_DIR = $(MOZILLA_SOURCE_ROOT)
+
+ADMINSERVER_SOURCE_ROOT = $(BUILD_ROOT)/../adminserver
+
+LDAPCONSOLE_SOURCE_ROOT = $(BUILD_ROOT)/../directoryconsole
+
+# these are the files needed to build the java components - xmltools and dsmlgw -
+# and where to get them
+# Axis - axis.jar - http://ws.apache.org/axis/index.html - also jaxrpc.jar,saaj.jar
+# Xerces-J - xercesImpl.jar, xml-apis.jar http://xml.apache.org/xerces2-j/download.cgi
+# JAF - activation.jar - http://java.sun.com/products/javabeans/glasgow/jaf.html
+# JWSDP - jaxrpc-api.jar,jaxrpc.jar,saaj.jar - http://java.sun.com/webservices/downloads/webservicespack.html
+# Crimson - crimson.jar - http://xml.apache.org/crimson/
diff --git a/component_versions.mk b/component_versions.mk
index c90c1a677..4d3d7f1b4 100644
--- a/component_versions.mk
+++ b/component_versions.mk
@@ -103,14 +103,6 @@ ifndef ANT_COMP
ANT_COMP = ant
endif
-# Servlet SDK
-ifndef SERVLET_VERSION
- SERVLET_VERSION = 2.3
-endif
-ifndef SERVLET_COMP
- SERVLET_COMP = javax/servlet
-endif
-
# LDAP JDK
ifndef LDAPJDK_RELDATE
LDAPJDK_RELDATE = v4.17
@@ -208,14 +200,6 @@ ifndef AXIS_VERSION
AXIS_VERSION=1.2rc3
endif
-# JSP compiler jasper
-ifndef JSPC_VERSION
- JSPC_VERSION = 4.0.3
-endif
-ifndef JSPC_COMP
- JSPC_COMP = javax/jasper
-endif
-
# ICU
ifndef ICU_VERSDIR
ICU_VERSDIR=libicu_2_4
diff --git a/components.mk b/components.mk
index 8c367f6c1..78d9985b0 100644
--- a/components.mk
+++ b/components.mk
@@ -483,6 +483,92 @@ PACKAGE_SRC_DEST += $(wildcard $(DB_LIBPATH)/*.$(DLL_SUFFIX)) bin/slapd/server
### DB component (Berkeley DB) ############################
+
+###########################################
+# SETUPUTIL
+##########################################
+
+ifdef SETUPUTIL_SOURCE_ROOT
+ SETUPUTIL_LIBPATH = $(SETUPUTIL_SOURCE_ROOT)/built/package/$(COMPONENT_OBJDIR)/lib
+ SETUPUTIL_INCDIR = $(SETUPUTIL_SOURCE_ROOT)/built/package/$(COMPONENT_OBJDIR)/include
+ SETUPUTIL_BINPATH = $(SETUPUTIL_SOURCE_ROOT)/built/package/$(COMPONENT_OBJDIR)/bin
+else
+ SETUPUTIL_LIBPATH = $(SETUPUTIL_BUILD_DIR)/lib
+ SETUPUTIL_INCDIR = $(SETUPUTIL_BUILD_DIR)/include
+ SETUPUTIL_BINPATH = $(SETUPUTIL_BUILD_DIR)/bin
+endif
+SETUPUTIL_INCLUDE = -I$(SETUPUTIL_INCDIR)
+
+ifeq ($(ARCH), WINNT)
+SETUPUTILLINK = /LIBPATH:$(SETUPUTIL_LIBPATH) nssetup32.$(LIB_SUFFIX)
+SETUPUTIL_S_LINK = /LIBPATH:$(SETUPUTIL_LIBPATH) nssetup32_s.$(LIB_SUFFIX)
+else
+SETUPUTILLINK = -L$(SETUPUTIL_LIBPATH) -linstall
+SETUPUTIL_S_LINK = $(SETUPUTILLINK)
+endif
+
+# this is the base directory under which the component's files will be found
+# during the build process
+ifdef ADMINUTIL_SOURCE_ROOT
+ ADMINUTIL_LIBPATH = $(ADMINUTIL_SOURCE_ROOT)/built/adminutil/$(COMPONENT_OBJDIR)/lib
+ ADMINUTIL_INCPATH = $(ADMINUTIL_SOURCE_ROOT)/built/adminutil/$(COMPONENT_OBJDIR)/include
+else
+ ADMINUTIL_LIBPATH = $(ADMINUTIL_BUILD_DIR)/lib
+ ADMINUTIL_INCPATH = $(ADMINUTIL_BUILD_DIR)/include
+endif
+
+PACKAGE_SRC_DEST += $(ADMINUTIL_LIBPATH)/property bin/slapd/lib
+LIBS_TO_PKG += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
+LIBS_TO_PKG_CLIENTS += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
+
+ifeq ($(ARCH),WINNT)
+ADMINUTIL_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
+ADMINUTIL_S_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil_s$(ADMINUTIL_VER).$(LIB_SUFFIX)
+LIBADMINUTILDLL_NAMES = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(DLL_SUFFIX)
+else
+ADMINUTIL_LINK=-L$(ADMINUTIL_LIBPATH) -ladminutil$(ADMINUTIL_VER)
+endif
+ADMINUTIL_INCLUDE=-I$(ADMINUTIL_INCPATH) -I$(ADMINUTIL_INCPATH)/libadminutil \
+ -I$(ADMINUTIL_INCPATH)/libadmsslutil
+
+#########################################
+# LDAPJDK
+#########################################
+
+LDAPJDK = ldapjdk.jar
+ifdef LDAPJDK_SOURCE_DIR
+ LDAPJDK_DIR = $(LDAPJDK_SOURCE_DIR)/directory/java-sdk/dist/packages
+else
+ LDAPJDK_DIR = $(CLASS_DEST)
+endif
+LDAPJARFILE=$(LDAPJDK_DIR)/ldapjdk.jar
+
+AXIS = axis-$(AXIS_VERSION).zip
+AXIS_FILES = $(AXIS)
+AXIS_FILE = $(CLASS_DEST)/$(AXIS)
+
+DSMLJAR = activation.jar,jaxrpc-api.jar,jaxrpc.jar,saaj.jar,xercesImpl.jar,xml-apis.jar
+DSMLJAR_FILE = $(CLASS_DEST)
+
+CRIMSON_LICENSE = LICENSE.crimson
+CRIMSONJAR = crimson.jar
+CRIMSONJAR_FILE = $(CLASS_DEST)/$(CRIMSONJAR)
+
+ifdef ADMINSERVER_SOURCE_ROOT
+ ADMSERV_DIR = $(ADMINSERVER_SOURCE_ROOT)/built/package/$(COMPONENT_OBJDIR)
+# else set in internal_buildpaths.mk
+endif
+# these are the only two subcomponents we use from the adminserver package
+ADMINSERVER_SUBCOMPS=admin base
+
+ifdef LDAPCONSOLE_SOURCE_ROOT
+ LDAPCONSOLE_DIR = $(LDAPCONSOLE_SOURCE_ROOT)/built/package
+else
+ LDAPCONSOLE_DIR = $(CLASS_DEST)
+endif
+LDAPCONSOLEJAR = ds$(LDAPCONSOLE_REL).jar
+LDAPCONSOLEJAR_EN = ds$(LDAPCONSOLE_REL)_en.jar
+
# must define dependencies last because they depend on the definitions above
ifeq ($(INTERNAL_BUILD), 1)
include $(BUILD_ROOT)/internal_comp_deps.mk
diff --git a/config/config.mk b/config/config.mk
index 840f930fe..086454922 100644
--- a/config/config.mk
+++ b/config/config.mk
@@ -422,10 +422,6 @@ ifeq ($(LW_JAVA), 1)
DEFINES += -DJAVA
endif
-ifdef FORTEZZA
-DEFINES += -DFORTEZZA
-endif
-
######################################################################
GARBAGE = $(DEPENDENCIES) core
diff --git a/httpd/src/unixso.mk b/httpd/src/unixso.mk
index 5dccb2064..802ba500f 100644
--- a/httpd/src/unixso.mk
+++ b/httpd/src/unixso.mk
@@ -107,9 +107,6 @@ SOLINK=-L. -L../../lib -lns-dshttpd$(DLL_PRESUF)
#NSPRLINK = -L. -lnspr$(DLL_PRESUF)
#NSPRLINK = -L. -ldsnspr$(DLL_PRESUF)
ADM_EXTRA := -L. -L../../lib $(LDAPLINK) $(NSPRLINK) $(EXTRA_LIBS)
-ifdef FORTEZZA
-ADM_EXTRA += $(NSCP_DISTDIR)/lib/libci.$(LIB_SUFFIX)
-endif
DEF_LIBPATH := .:../../lib:$(DEF_LIBPATH)
endif
@@ -160,22 +157,10 @@ else
LIBSEC1=$(LIBSECOBJS)
endif
-ifdef PRODUCT_IS_DIRECTORY_SERVER
- DAEMONLIB=
-else
- DAEMONLIB=$(OBJDIR)/lib/libhttpdaemon.a
-endif
-
-DEPLIBS = ${DAEMONLIB} $(OBJDIR)/lib/libsi18n.a $(ADMLIB) $(LDAPSDK_DEP)
+DEPLIBS = $(OBJDIR)/lib/libsi18n.a $(ADMLIB) $(LDAPSDK_DEP)
-ifdef FORTEZZA
-LIBSEC1 += $(NSCP_DISTDIR)/lib/libci.$(LIB_SUFFIX)
-endif
-
-DEPLINK = ${DAEMONLIB} $(OBJDIR)/lib/libsi18n.a
-ifneq ($(BUILD_MODULE), HTTP_PERSONAL)
+DEPLINK = $(OBJDIR)/lib/libsi18n.a
DEPLINK += $(OBJDIR)/lib/libmsgdisp.a
-endif
DEPLINK += $(SOLINK) $(LDAPLINK) $(NSPRLINK) $(SOLINK2)
# Relative to the directory that contains the .so
diff --git a/internal_buildpaths.mk b/internal_buildpaths.mk
index 6cd651e9d..9416009c6 100644
--- a/internal_buildpaths.mk
+++ b/internal_buildpaths.mk
@@ -125,3 +125,17 @@ DB_MAJOR_MINOR := db42
db_component_name=$(DB_MAJOR_MINOR)
db_path_config :=$(NSCP_DISTDIR)/$(db_component_name)
endif # DB_SOURCE_ROOT
+
+#ADMINUTIL_SOURCE_ROOT = $(BUILD_ROOT)/../adminutil
+ifndef ADMINUTIL_SOURCE_ROOT
+ADMINUTIL_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/adminutil
+endif # ADMINUTIL_SOURCE_ROOT
+
+#SETUPUTIL_SOURCE_ROOT = $(BUILD_ROOT)/../setuputil
+ifndef SETUPUTIL_SOURCE_ROOT
+SETUPUTIL_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/setuputil
+endif # SETUPUTIL_SOURCE_ROOT
+
+ifndef ADMINSERVER_SOURCE_ROOT
+ADMSERV_DIR=$(ABS_ROOT_PARENT)/dist/$(NSOBJDIR_NAME)/adminserver
+endif
diff --git a/internal_comp_deps.mk b/internal_comp_deps.mk
index 6cb72d1de..f9e2db955 100644
--- a/internal_comp_deps.mk
+++ b/internal_comp_deps.mk
@@ -330,30 +330,12 @@ else
ADMINUTIL_IMPORT=$(COMPONENTS_DIR)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
# ADMINUTIL_IMPORT=$(FED_COMPONENTS_DIR)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
endif
-# this is the base directory under which the component's files will be found
-# during the build process
ADMINUTIL_BUILD_DIR=$(NSCP_DISTDIR_FULL_RTL)/adminutil
-ADMINUTIL_LIBPATH=$(ADMINUTIL_BUILD_DIR)/lib
-ADMINUTIL_INCPATH=$(ADMINUTIL_BUILD_DIR)/include
-
-PACKAGE_SRC_DEST += $(ADMINUTIL_LIBPATH)/property bin/slapd/lib
-LIBS_TO_PKG += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
-LIBS_TO_PKG_CLIENTS += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
#
# Libadminutil
#
ADMINUTIL_DEP = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(DLL_SUFFIX)
-ifeq ($(ARCH), WINNT)
-ADMINUTIL_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
-ADMINUTIL_S_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil_s$(ADMINUTIL_VER).$(LIB_SUFFIX)
-LIBADMINUTILDLL_NAMES = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(DLL_SUFFIX)
-else
-ADMINUTIL_LINK=-L$(ADMINUTIL_LIBPATH) -ladminutil$(ADMINUTIL_VER)
-endif
-ADMINUTIL_INCLUDE=-I$(ADMINUTIL_INCPATH) \
- -I$(ADMINUTIL_INCPATH)/libadminutil \
- -I$(ADMINUTIL_INCPATH)/libadmsslutil
ifndef ADMINUTIL_PULL_METHOD
ADMINUTIL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
@@ -406,21 +388,13 @@ ifeq ($(BUILD_MODE), int)
else
SETUPUTIL_RELEASE = $(FED_COMPONENTS_DIR)/$(SETUPUTIL_VERSDIR)/$(SETUPUTIL_VERSION)/$(NSOBJDIR_NAME)
endif
-SETUPUTIL_LIBPATH = $(SETUPUTIL_BUILD_DIR)/lib
-SETUPUTIL_INCDIR = $(SETUPUTIL_BUILD_DIR)/include
-SETUPUTIL_BINPATH = $(SETUPUTIL_BUILD_DIR)/bin
-SETUPUTIL_INCLUDE = -I$(SETUPUTIL_INCDIR)
ifeq ($(ARCH), WINNT)
SETUPUTIL_FILES = setuputil.tar.gz -unzip $(NSCP_DISTDIR)/setuputil
SETUPUTIL_DEP = $(SETUPUTIL_LIBPATH)/nssetup32.$(LIB_SUFFIX)
-SETUPUTILLINK = /LIBPATH:$(SETUPUTIL_LIBPATH) nssetup32.$(LIB_SUFFIX)
-SETUPUTIL_S_LINK = /LIBPATH:$(SETUPUTIL_LIBPATH) nssetup32_s.$(LIB_SUFFIX)
else
SETUPUTIL_FILES = bin,lib,include
SETUPUTIL_DEP = $(SETUPUTIL_LIBPATH)/libinstall.$(LIB_SUFFIX)
-SETUPUTILLINK = -L$(SETUPUTIL_LIBPATH) -linstall
-SETUPUTIL_S_LINK = $(SETUPUTILLINK)
endif
ifndef SETUPUTIL_PULL_METHOD
@@ -436,17 +410,14 @@ endif
-@if [ ! -f $@ ] ; \
then echo "Error: could not get component SETUPUTIL file $@" ; \
fi
+
# apache-axis java classes #######################################
-AXIS = axis-$(AXIS_VERSION).zip
-AXIS_FILES = $(AXIS)
AXIS_RELEASE = $(COMPONENTS_DIR)/axis
#AXISJAR_DIR = $(AXISJAR_RELEASE)/$(AXISJAR_COMP)/$(AXISJAR_VERSION)
AXIS_DIR = $(AXIS_RELEASE)/$(AXIS_VERSION)
-AXIS_FILE = $(CLASS_DEST)/$(AXIS)
AXIS_DEP = $(AXIS_FILE)
AXIS_REL_DIR=$(subst -bin,,$(subst .zip,,$(AXIS)))
-
# This is java, so there is only one real platform subdirectory
#PACKAGE_UNDER_JAVA += $(AXIS_FILE)
@@ -461,21 +432,18 @@ ifdef COMPONENT_DEPS
$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
-objdir $(CLASS_DEST) -componentdir $(AXIS_DIR) \
-files $(AXIS_FILES) -unzip $(CLASS_DEST)
-endif
+endifldap/
-@if [ ! -f $@ ] ; \
then echo "Error: could not get component AXIS files $@" ; \
fi
###########################################################
-
# other dsml java classes #######################################
-DSMLJAR = activation.jar,jaxrpc-api.jar,jaxrpc.jar,saaj.jar,xercesImpl.jar,xml-apis.jar
DSMLJAR_FILES = $(DSMLJAR)
DSMLJAR_RELEASE = $(COMPONENTS_DIR)
#DSMLJARJAR_DIR = $(DSMLJARJAR_RELEASE)/$(DSMLJARJAR_COMP)/$(DSMLJARJAR_VERSION)
DSMLJAR_DIR = $(DSMLJAR_RELEASE)/dsmljars
-DSMLJAR_FILE = $(CLASS_DEST)
DSMLJAR_DEP = $(CLASS_DEST)/activation.jar $(CLASS_DEST)/jaxrpc-api.jar $(CLASS_DEST)/jaxrpc.jar $(CLASS_DEST)/saaj.jar $(CLASS_DEST)/xercesImpl.jar $(CLASS_DEST)/xml-apis.jar
ifndef DSMLJAR_PULL_METHOD
@@ -497,15 +465,11 @@ endif
###########################################################
# XMLTOOLS java classes #######################################
-CRIMSONJAR = crimson.jar
-CRIMSON_LICENSE = LICENSE.crimson
CRIMSONJAR_FILES = $(CRIMSONJAR),$(CRIMSON_LICENSE)
CRIMSONJAR_RELEASE = $(COMPONENTS_DIR)
CRIMSONJAR_DIR = $(CRIMSONJAR_RELEASE)/$(CRIMSONJAR_COMP)/$(CRIMSONJAR_VERSION)
-CRIMSONJAR_FILE = $(CLASS_DEST)/$(CRIMSONJAR)
CRIMSONJAR_DEP = $(CRIMSONJAR_FILE) $(CLASS_DEST)/$(CRIMSON_LICENSE)
-
# This is java, so there is only one real platform subdirectory
PACKAGE_UNDER_JAVA += $(CRIMSONJAR_FILE)
@@ -516,7 +480,6 @@ endif
$(CRIMSONJAR_DEP): $(CLASS_DEST)
ifdef COMPONENT_DEPS
- echo "Inside ftppull"
$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
-objdir $(CLASS_DEST) -componentdir $(CRIMSONJAR_DIR) \
-files $(CRIMSONJAR_FILES)
@@ -529,6 +492,7 @@ endif
# ANT java classes #######################################
ifeq ($(BUILD_JAVA_CODE),1)
+ifndef GET_ANT_FROM_PATH
# (we use ant for building some Java code)
ANTJAR = ant.jar
JAXPJAR = jaxp.jar
@@ -555,42 +519,14 @@ endif
then echo "Error: could not get component ant files $@" ; \
fi
endif
-###########################################################
-
-# Servlet SDK classes #######################################
-SERVLETJAR = servlet.jar
-SERVLET_FILES = $(SERVLETJAR)
-SERVLET_RELEASE = $(COMPONENTS_DIR)
-SERVLET_DIR = $(SERVLET_RELEASE)/$(SERVLET_COMP)/$(SERVLET_VERSION)
-SERVLET_DEP = $(addprefix $(CLASS_DEST)/, $(SERVLET_FILES))
-SERVLET_CP = $(subst $(SPACE),$(PATH_SEP),$(SERVLET_DEP))
-SERVLET_PULL = $(subst $(SPACE),$(COMMA),$(SERVLET_FILES))
-
-ifndef SERVLET_PULL_METHOD
-SERVLET_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(SERVLET_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(SERVLET_DIR) \
- -files $(SERVLET_PULL)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component servlet SDK files $@" ; \
- fi
-
+endif # GET_ANT_FROM_PATH
###########################################################
# LDAP java classes #######################################
-LDAPJDK = ldapjdk.jar
LDAPJDK_VERSION = $(LDAPJDK_RELDATE)
LDAPJDK_RELEASE = $(COMPONENTS_DIR)
-LDAPJDK_DIR = $(LDAPJDK_RELEASE)
LDAPJDK_IMPORT = $(LDAPJDK_RELEASE)/$(LDAPJDK_COMP)/$(LDAPJDK_VERSION)/$(NSOBJDIR_NAME)
# This is java, so there is only one real platform subdirectory
-LDAPJARFILE=$(CLASS_DEST)/ldapjdk.jar
LDAPJDK_DEP=$(LDAPJARFILE)
#PACKAGE_UNDER_JAVA += $(LDAPJARFILE)
@@ -612,23 +548,21 @@ endif
###########################################################
# LDAP Console java classes
###########################################################
-LDAPCONSOLEJAR = ds$(LDAPCONSOLE_REL).jar
-LDAPCONSOLEJAR_EN = ds$(LDAPCONSOLE_REL)_en.jar
#LDAPCONSOLE_RELEASE=$(COMPONENTS_DIR_DEV)
LDAPCONSOLE_RELEASE=$(COMPONENTS_DIR)
LDAPCONSOLE_JARDIR = $(LDAPCONSOLE_RELEASE)/ldapconsole/$(LDAPCONSOLE_COMP)$(BUILD_MODE)/$(LDAPCONSOLE_RELDATE)/jars
-LDAPCONSOLE_DEP = $(CLASS_DEST)/$(LDAPCONSOLEJAR)
+LDAPCONSOLE_DEP = $(LDAPCONSOLE_DIR)/$(LDAPCONSOLEJAR)
LDAPCONSOLE_FILES=$(LDAPCONSOLEJAR),$(LDAPCONSOLEJAR_EN)
ifndef LDAPCONSOLE_PULL_METHOD
LDAPCONSOLE_PULL_METHOD = $(COMPONENT_PULL_METHOD)
endif
-$(LDAPCONSOLE_DEP): $(CLASS_DEST)
+$(LDAPCONSOLE_DEP): $(LDAPCONSOLE_DIR)
ifdef COMPONENT_DEPS
$(FTP_PULL) -method $(LDAPCONSOLE_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(LDAPCONSOLE_JARDIR) \
+ -objdir $(LDAPCONSOLE_DIR) -componentdir $(LDAPCONSOLE_JARDIR) \
-files $(LDAPCONSOLE_FILES)
endif
-@if [ ! -f $@ ] ; \
@@ -642,80 +576,16 @@ endif
PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32)
PERLDAP_ZIP_FILE = perldap14.zip
-###########################################################
-
-# JSS classes - for the Mission Control Console ######
-JSSJAR = jss$(JSS_JAR_VERSION).jar
-JSSJARFILE = $(CLASS_DEST)/$(JSSJAR)
-JSS_RELEASE = $(COMPONENTS_DIR)/$(JSS_COMP)/$(JSS_VERSION)
-JSS_DEP = $(JSSJARFILE)
-
-#PACKAGE_UNDER_JAVA += $(JSSJARFILE)
-
-ifndef JSS_PULL_METHOD
-JSS_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(JSS_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
-ifdef VSFTPD_HACK
-# work around vsftpd -L problem
- $(FTP_PULL) -method $(JSS_PULL_METHOD) \
- -objdir $(CLASS_DEST)/jss -componentdir $(JSS_RELEASE) \
- -files xpclass.jar
- mv $(CLASS_DEST)/jss/xpclass.jar $(CLASS_DEST)/$(JSSJAR)
- rm -rf $(CLASS_DEST)/jss
-else
- $(FTP_PULL) -method $(JSS_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(JSS_RELEASE) \
- -files $(JSSJAR)
-endif
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component JSS file $@" ; \
- fi
-
-###########################################################
-
-### JSP compiler package ##################################
-
-JSPC_REL = $(JSPC_VERSDIR)
-JSPC_REL_DATE = $(JSPC_VERSION)
-JSPC_FILES = jasper-compiler.jar jasper-runtime.jar
-JSPC_RELEASE = $(COMPONENTS_DIR)
-JSPC_DIR = $(JSPC_RELEASE)/$(JSPC_COMP)/$(JSPC_VERSION)
-JSPC_DEP = $(addprefix $(CLASS_DEST)/, $(JSPC_FILES))
-JSPC_CP = $(subst $(SPACE),$(PATH_SEP),$(JSPC_DEP))
-JSPC_PULL = $(subst $(SPACE),$(COMMA),$(JSPC_FILES))
-
-ifndef JSPC_PULL_METHOD
-JSPC_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(JSPC_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(JSPC_DIR) \
- -files $(JSPC_PULL)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component jspc files $@" ; \
- fi
-
-###########################################################
-
###########################################################
### Admin Server package ##################################
ADMIN_REL = $(ADM_VERSDIR)
ADMIN_REL_DATE = $(ADM_VERSION)
#ADMIN_FILE = adminserver.tar.gz
-ADMIN_FILE = admin,base
+ADMIN_FILE = $(subst $(SPACE),$(COMMA),$(ADMINSERVER_SUBCOMPS))
ADMIN_FILE_TAR = adminserver.tar
IMPORTADMINSRV_BASE=$(COMPONENTS_DIR_DEV)/$(ADMIN_REL)/$(ADMIN_REL_DATE)
IMPORTADMINSRV = $(IMPORTADMINSRV_BASE)/$(NSOBJDIR_NAME_32)
-ADMSERV_DIR=$(ABS_ROOT_PARENT)/dist/$(NSOBJDIR_NAME)/adminserver
ADMSERV_DEP = $(ADMSERV_DIR)/admin/admin.inf
ADM_VERSION = $(ADM_RELDATE)
@@ -728,8 +598,7 @@ endif
ifndef ADMSERV_DEPS
ADMSERV_DEPS = $(COMPONENT_DEPS)
endif
-#IMPORTADMINSRV = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
-#ADM_RELEASE = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
+
$(ADMSERV_DEP): $(ABS_ROOT_PARENT)/dist/$(NSOBJDIR_NAME)
ifdef ADMSERV_DEPS
$(FTP_PULL) -method $(ADMSERV_PULL_METHOD) \
@@ -768,7 +637,6 @@ $(DSDOC_DEP): $(NSCP_DISTDIR)
fi
### DOCS END #############################
-
# Windows sync component for Active Directory
ADSYNC = PassSync.msi
ADSYNC_DEST = $(NSCP_DISTDIR_FULL_RTL)/winsync
diff --git a/ldap/admin/lib/Makefile b/ldap/admin/lib/Makefile
index 3eebe24d8..b130a224a 100644
--- a/ldap/admin/lib/Makefile
+++ b/ldap/admin/lib/Makefile
@@ -64,9 +64,6 @@ SRCS = dsalib_location.c dsalib_debug.c dsalib_updown.c dsalib_tailf.c \
OBJS = $(addprefix $(OBJDEST)/, $(subst .c,.o,$(SRCS)))
INCLUDES += -I$(LDAP_SRC)/admin/include
-ifdef FORTEZZA
-INCLUDES += -I$(BUILD_ROOT)/lib
-endif
EXTRA_LIBS += $(LDAP_COMMON_LIBS) $(SECURITYLINK) $(NSPRLINK)
@@ -77,15 +74,6 @@ MAPFILE= /MAP:$(LDAP_ADMLIBDIR)/libds_admin.map
EXTRA_LIBS_DEP += $(LDAP_COMMON_LIBS_DEP) $(LDAP_LIBLDIF_DEP)
#EXTRA_LIBS += $(LDAP_COMMON_LIBS) $(LDAP_LIBLDIF) $(LDAP_SDK_LIBLDAP_DLL) \
# $(ADMINUTIL_LINK) $(SECURITYLINK) $(NSPRLINK)
-else # WINNT
-ifdef FORTEZZA
-# libci.a needs to be recompiled with the -Z option on HPUX, until then,
-# we'll link libci.a with the executables which need it -atom
-ifneq ($(ARCH), HPUX)
-EXTRA_LIBS_DEP += $(FORTEZZA_DRIVER)
-EXTRA_LIBS += $(FORTEZZA_DRIVER)
-endif # !HPUX
-endif # FORTEZZA
endif # WINNT
ifeq ($(ARCH), Linux)
diff --git a/ldap/admin/src/Makefile b/ldap/admin/src/Makefile
index af5cb8264..5210982ca 100644
--- a/ldap/admin/src/Makefile
+++ b/ldap/admin/src/Makefile
@@ -132,12 +132,6 @@ EXTRA_LIBS += -lsocket -lnsl -lgen -lm -lposix4 -lthread
OPENSOURCE_LIBS += -lsocket -lnsl -lgen -lm -lposix4 -lthread
else
ifeq ($(ARCH),HPUX)
-ifdef FORTEZZA
-# link with libci.a for FORTEZZA builds. On other platforms, libci.a is
-# linked into libds_admin.so, but not on HPUX
-EXTRA_LIBS_DEP += $(FORTEZZA_DRIVER)
-EXTRA_LIBS += $(FORTEZZA_DRIVER)
-endif
ifeq ($(USE_64), 1)
EXTRALDFLAGS += +DA2.0W +DS2.0 +Z
endif
@@ -349,11 +343,7 @@ $(LDAP_SERVER_RELDIR)/namegen.exe: $(OBJDEST)/namegen.o
$(LDAP_SERVER_RELDIR)/latest_file.exe: $(OBJDEST)/latest_file.o
$(LINK_EXE_NOLIBSOBJS) $^
-installPerlFiles: $(BINDIR) $(BINDIR)/Install.pl
-
-$(BINDIR)/Install.pl: CreateInstall.pl $(PERL_SCRIPTS_DEST)
- -@$(RM) $@
- $(CP) $< $@
+installPerlFiles: $(BINDIR) $(PERL_SCRIPTS_DEST)
$(BINDIR)/%: %
-@$(RM) $@
diff --git a/ldap/clients/dsgw/secglue.c b/ldap/clients/dsgw/secglue.c
index 7cf27610a..95834fd22 100644
--- a/ldap/clients/dsgw/secglue.c
+++ b/ldap/clients/dsgw/secglue.c
@@ -147,13 +147,6 @@ FUNC(CERT_GetStateName)
FUNC(CERT_IsExportVersion)
FUNC(CERT_PublicModulusLen)
-#ifdef FORTEZZA
-FUNC(SSL_EnableGroup)
-FUNC(SEC_OpenVolatileCertDB)
-FUNC(FortezzaConfigureServer)
-FUNC(SSL_IsEnabledGroup)
-#endif /* FORTEZZA */
-
/* DSGW pkennedy added, for HCL integration */
FUNC(BTOA_DataToAscii)
FUNC(ATOB_AsciiToData)
@@ -162,7 +155,6 @@ FUNC(PK11_FindKeyByAnyCert)
FUNC(PK11_GetTokenName)
FUNC(PK11_SetPasswordFunc)
FUNC(PK11_FindCertFromNickname)
-FUNC(PK11_FortezzaHasKEA)
FUNC(PK11_ConfigurePKCS11)
FUNC(SSL_SetPolicy)
FUNC(CERT_VerifyCertNow)
diff --git a/ldap/clients/dsmlgw/Makefile b/ldap/clients/dsmlgw/Makefile
index 22cff75ef..f7afbe5c6 100644
--- a/ldap/clients/dsmlgw/Makefile
+++ b/ldap/clients/dsmlgw/Makefile
@@ -46,7 +46,9 @@ include $(BUILD_ROOT)/nsconfig.mk
include $(BUILD_ROOT)/ldap/javarules.mk
all: $(ANT_DEP) $(LDAPJDK_DEP)
- cp $(CLASS_DEST)/$(AXIS_REL_DIR)/lib/axis.jar $(CLASS_DEST)
+ @if [ ! -f $(CLASS_DEST)/axis.jar ]; then \
+ cp $(CLASS_DEST)/$(AXIS_REL_DIR)/lib/axis.jar $(CLASS_DEST) ; \
+ fi
$(ANT)
clean:
diff --git a/ldap/cm/Makefile b/ldap/cm/Makefile
index 039a58057..02256a76a 100644
--- a/ldap/cm/Makefile
+++ b/ldap/cm/Makefile
@@ -134,9 +134,6 @@ endif
ifeq ($(BUILD_SECURITY), domestic)
SEC=-sec domestic
-ifdef FORTEZZA
-SEC=-sec fortezza
-endif
else
SEC=-sec export
endif
@@ -188,24 +185,13 @@ DOTEXE = .exe
PACKAGE_STAGE_DIR=$(OBJDIR)/package
endif
-SHARETOP = $(COMPONENTS_DIR)/ldapsdk
-BUILD_DATE = $(shell date +%Y%m%d)
-SHAREDIR = $(SHARETOP)/$(BUILD_DATE)/$(NC_BUILD_FLAVOR)
-#ADM_VERSDIR = admserv40
-#ADM_RELDATE = untested/19980119
-#IMPORTADMINSRV = $(IMPORTADMINSRV_BASE)/$(NSOBJDIR_NAME_32)
-IMPORTADMINSRVNOTARBASE = $(COMPONENTS_DIR_DEV)/$(ADM_VERSDIR)/$(ADM_VERSION)/$(NSOBJDIR_NAME)
# these are files and directories in the import adminsrv directory which we don't
# make a local copy of, we just import directly into the tar file or create a
# symlink to
-ADMIN_IMPORTS=base admin
+ADMIN_IMPORTS=$(ADMINSERVER_SUBCOMPS)
ADMIN_SERVER_TARGZ=adminserver.tar.gz
ADMIN_IMPORTS_TARGZ=$(ADMIN_SERVER_TARGZ)
-# Release directory for ldapsdk
-RELSDK = $(BUILD_DRIVE)$(RELTOP)/ldapsdk/$(OBJDIR_BASE)
-RELJDK = $(BUILD_DRIVE)$(RELTOP)/ldapjdk
-
# these are files we need to put in the command line/console only package
#LDAPSDK_IMPORTS=ldapsearch ldapdelete ldapmodify
@@ -290,8 +276,6 @@ else
endif
endif
-# Borland libraries are build on NT only
-
dummy:
-@echo SITEHACK = $(SITEHACK)
-@echo PACKAGE_SRC_DEST = $(PACKAGE_SRC_DEST)
@@ -350,17 +334,23 @@ endif
# install the DSMLGW into the client directory
ifeq ($(USE_DSMLGW), 1)
$(MKDIR) $(RELDIR)/clients/dsmlgw
- $(CP) -R $(NSDIST)/classes/$(AXIS_REL_DIR)/webapps/axis/* $(RELDIR)/clients/dsmlgw/
+ if [ -d $(NSDIST)/classes/$(AXIS_REL_DIR)/webapps/axis ] ; then \
+ $(CP) -R $(NSDIST)/classes/$(AXIS_REL_DIR)/webapps/axis/* $(RELDIR)/clients/dsmlgw/ ; \
+ fi
$(INSTALL) -m 644 $(NSDIST)/dsmlgw/dsmlgw.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/dsmlgw/misc/server-config.wsdd $(RELDIR)/clients/dsmlgw/WEB-INF
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/dsmlgw/misc/web-app_2_3.dtd $(RELDIR)/clients/dsmlgw/
-
# now time to move the necessary jars in place
$(INSTALL) -m 644 $(NSDIST)/classes/ldapjdk.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
$(INSTALL) -m 644 $(NSDIST)/classes/activation.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
- $(INSTALL) -m 644 $(NSDIST)/classes/jaxrpc-api.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
+# if you use the jaxrpc.jar from the axis distribution, you don't need the api file
+# or perhaps you need the jaxrpc.jar for building, and jaxrpc-api.jar at runtime, or vice versa
+# if so, I'm not sure where to get the implementation
+ if [ -f $(NSDIST)/classes/jaxrpc-api.jar ] ; then \
+ $(INSTALL) -m 644 $(NSDIST)/classes/jaxrpc-api.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib ; \
+ fi
$(INSTALL) -m 644 $(NSDIST)/classes/jaxrpc.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
$(INSTALL) -m 644 $(NSDIST)/classes/saaj.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
$(INSTALL) -m 644 $(NSDIST)/classes/xercesImpl.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
@@ -472,13 +462,15 @@ endif
# install the ds jar file in the <server root>/$(DS_JAR_DEST_PATH) directory
# also install the other jar files we use
ifeq ($(USE_CONSOLE), 1)
- $(INSTALL) -m 644 $(NSDIST)/classes/$(LDAPCONSOLEJAR) $(RELDIR)/$(DS_JAR_DEST_PATH)
- $(INSTALL) -m 644 $(NSDIST)/classes/$(LDAPCONSOLEJAR_EN) $(RELDIR)/$(DS_JAR_DEST_PATH)
+ $(INSTALL) -m 644 $(LDAPCONSOLE_DIR)/$(LDAPCONSOLEJAR) $(RELDIR)/$(DS_JAR_DEST_PATH)
+ $(INSTALL) -m 644 $(LDAPCONSOLE_DIR)/$(LDAPCONSOLEJAR_EN) $(RELDIR)/$(DS_JAR_DEST_PATH)
endif
ifeq ($(USE_JAVATOOLS), 1)
$(INSTALL) -m 644 $(DS_JAR_SRC_PATH)/$(XMLTOOLS_JAR_FILE) $(RELDIR)/$(DS_JAR_DEST_PATH)
$(INSTALL) -m 644 $(NSDIST)/classes/$(CRIMSONJAR) $(RELDIR)/$(DS_JAR_DEST_PATH)
- $(INSTALL) -m 644 $(NSDIST)/classes/$(CRIMSON_LICENSE) $(RELDIR)/$(DS_JAR_DEST_PATH)
+ if [ -f $(NSDIST)/classes/$(CRIMSON_LICENSE) ] ; then \
+ $(INSTALL) -m 644 $(NSDIST)/classes/$(CRIMSON_LICENSE) $(RELDIR)/$(DS_JAR_DEST_PATH) ; \
+ fi
endif
# Images for IM Presence plugin
@@ -513,8 +505,8 @@ ifdef USE_QUANTIFY
endif
# Copy db tools
- $(INSTALL) -m 755 $(DB_BINPATH)/db_printlog* $(RELDIR)/bin/slapd/server
- $(INSTALL) -m 755 $(DB_BINPATH)/db_verify* $(RELDIR)/bin/slapd/server
+ $(INSTALL) -m 755 $(DB_BINPATH)/db_printlog$(EXE_SUFFIX) $(RELDIR)/bin/slapd/server
+ $(INSTALL) -m 755 $(DB_BINPATH)/db_verify$(EXE_SUFFIX) $(RELDIR)/bin/slapd/server
$(INSTALL) -m 755 $(OBJDIR)/lib/libsi18n/ns-slapd.properties $(RELDIR)/bin/slapd/property;
@@ -554,28 +546,13 @@ endif # BUILD_RPM
# For security reason, it's readable only by the owner
chmod 700 $(RELDIR)/bin/slapd/server
-# this is the rule to pull the Infozip utilities
-ifndef INFOZIP_PULL_METHOD
-INFOZIP_PULL_METHOD = FTP
-endif
-
-$(INSTDIR)/tools/infozip.zip:
- $(RM) $@
- $(FTP_PULL) -method $(INFOZIP_PULL_METHOD) \
- -objdir $(dir $@) \
- -componentdir $(COMPONENTS_DIR)/infozip/$(INFOZIP_RELDATE)/$(NSOBJDIR_NAME_32) \
- -files infozip.zip
- @if [ ! -f $@ ] ; \
- then echo "Error: could not get component INFOZIP file $@" ; \
- exit 1 ; \
- fi
-
# this is the rule to pull PerLDAP
ifndef PERLDAP_PULL_METHOD
PERLDAP_PULL_METHOD = FTP
endif
$(INSTDIR)/perldap/$(PERLDAP_ZIP_FILE):
+ifdef INTERNAL_BUILD
$(RM) $@
$(FTP_PULL) -method $(PERLDAP_PULL_METHOD) \
-objdir $(dir $@) \
@@ -586,6 +563,7 @@ $(INSTDIR)/perldap/$(PERLDAP_ZIP_FILE):
exit 1 ; \
fi
$(PERL) -w fixPerlDAPInf.pl $(dir $@)/perldap.inf
+endif
# this is the rule to pull nsPerl
ifndef NSPERL_PULL_METHOD
@@ -593,6 +571,7 @@ NSPERL_PULL_METHOD = FTP
endif
$(INSTDIR)/nsperl/$(NSPERL_ZIP_FILE):
+ifdef INTERNAL_BUILD
$(RM) $@
$(FTP_PULL) -method $(NSPERL_PULL_METHOD) \
-objdir $(dir $@) \
@@ -607,6 +586,7 @@ $(INSTDIR)/nsperl/$(NSPERL_ZIP_FILE):
# conflicts with the one in perldap - bug 600138
# SITEHACK is defined in nsperl.mk
# $(ZIP) -d $(dir $@)/$(NSPERL_ZIP_FILE) lib/nsPerl5.6.1/$(SITEHACK)/Mozilla/LDAP/LDIF.pm
+endif
$(INSTDIR)/slapd:
$(MKDIR) -p $@
@@ -619,7 +599,6 @@ ifneq ($(ARCH), WINNT)
packageDirectory: $(INSTDIR)/slapd \
$(INSTDIR)/nsperl/$(NSPERL_ZIP_FILE) \
$(INSTDIR)/perldap/$(PERLDAP_ZIP_FILE) \
- $(INSTDIR)/tools/infozip.zip \
$(ADMSERV_DEP)
ifdef BUILD_PATCH
@@ -657,6 +636,7 @@ endif
endif
endif
endif
+ifeq ($(USE_CONSOLE),1)
# create the slapd-client.zip file, which only has the ds jar file for the console and
# the ldap client utility programs
rm -f $(INSTDIR)/slapd/slapd-client.zip
@@ -668,7 +648,7 @@ else
# Normal way to ZIP the bits
cd $(RELDIR); $(ZIP) $(ZIP_FLAGS) $(ABS_INSTDIR)/slapd/slapd-client.zip ./java
endif
-
+endif # USE_CONSOLE
#; for file in $(LDAPSDK_IMPORTS) ; \
# do $(ZIP) $(ZIP_FLAGS) -g $(INSTDIR)/slapd/slapd-client.zip bin/slapd/server/$$file$(DOTEXE) ; \
# done
@@ -698,16 +678,14 @@ endif
# if the untar directory is there, hooray; otherwise, we will have to unpack the
# binaries ourselves . . .
- curdir=`pwd`; cd $(INSTDIR) ; \
- if [ ! -d $(IMPORTADMINSRVNOTARBASE)/admin ] ; \
- then for file in $(ADMIN_IMPORTS_TARGZ) ; \
- do rm -rf $$file ; \
- $(GUNZIP) -c $(ADMSERV_DIR)/$$file | $(TAR) xvf - ; \
- done ; \
+ if [ ! -d $(ADMSERV_DIR)/admin ] ; \
+ then \
+ rm -rf $(addprefix $(INSTDIR)/,$(ADMINSERVER_SUBCOMPS)) ; \
+ $(GUNZIP) -c $(ADMSERV_DIR)/$(ADMIN_SERVER_TARGZ) | (cd $(INSTDIR) ; $(TAR) xvf - $(ADMINSERVER_SUBCOMPS)) ; \
else \
- for file in $(ADMIN_IMPORTS) ; \
- do rm -rf $$file ; \
- cp -r $(IMPORTADMINSRVNOTARBASE)/$$file $$file ; \
+ for file in $(ADMINSERVER_SUBCOMPS) ; \
+ do rm -rf $(INSTDIR)/$$file ; \
+ cp -r $(ADMSERV_DIR)/$$file $(INSTDIR)/$$file ; \
done ; \
fi
@@ -715,7 +693,7 @@ endif
rm -f $(INSTDIR)/base/nsbase.zip
# we also need to remove the Archive directive from the [base] section of the
# base.inf file
- $(PERL) -w $(FIX_BASE_INF) $(INSTDIR)/base/base.inf
+# $(PERL) -w $(FIX_BASE_INF) $(INSTDIR)/base/base.inf
# Install LDAP Readme and License files at root of Installation (dated pre-packaging) directory.
# And, replace the License.txt file that is packaged in nssvrcore.zip.
@@ -735,14 +713,14 @@ ifndef NO_INSTALLER_TAR_FILES
ifdef BUILD_SHIP
ifndef BUILD_PATCH
cd $(INSTDIR); $(TAR) cvfh - setup.inf setup slapd nsperl \
- perldap dsktune tools $(ADMIN_IMPORTS) | gzip -f > $(BUILD_SHIP)/$(FTPNAMEGZ)
+ perldap dsktune $(ADMIN_IMPORTS) | gzip -f > $(BUILD_SHIP)/$(FTPNAMEGZ)
endif
ifeq ($(DEBUG), optimize)
# $(REMSH) "/u/svbld/bin/preRtm $(BUILD_SHIP) $(FTPNAMEGZ) svbld"
endif
else
cd $(INSTDIR); $(TAR) cvfh - setup.inf setup slapd nsperl \
- perldap dsktune tools $(ADMIN_IMPORTS) | gzip -f > ../all$(NS_BUILD_FLAVOR).tar.gz
+ perldap dsktune $(ADMIN_IMPORTS) | gzip -f > ../all$(NS_BUILD_FLAVOR).tar.gz
endif # BUILD_SHIP
#cp $(INSTDIR).tar.gz $(BUILD_SHIP)
#cp $(INSTDIR)/all$(NS_BUILD_FLAVOR).tar.gz $(BUILD_SHIP)
@@ -941,8 +919,8 @@ _slapd_files: $(INSTDIR)/$(SLAPD_DIR) \
$(INSTDIR)/$(SLAPD_DIR)/slapd.z \
$(INSTDIR)/$(SLAPD_DIR)/dsjars.z
-$(INSTDIR)/$(SLAPD_DIR)/dsjars.z: $(CLASS_DEST)/$(LDAPCONSOLEJAR) \
- $(CLASS_DEST)/$(LDAPCONSOLEJAR_EN) $(DS_JAR_SRC_PATH)/$(XMLTOOLS_JAR_FILE)
+$(INSTDIR)/$(SLAPD_DIR)/dsjars.z: $(LDAPCONSOLE_DIR)/$(LDAPCONSOLEJAR) \
+ $(LDAPCONSOLE_DIR)/$(LDAPCONSOLEJAR_EN) $(DS_JAR_SRC_PATH)/$(XMLTOOLS_JAR_FILE)
rm -f $(DSJARS_ZIPFILE); cd $(RELDIR); zip -r $(DSJARS_ZIPFILE) java
$(INSTDIR)/$(SLAPD_DIR)/slapd.z:
@@ -974,7 +952,7 @@ $(INSTDIR)/$(SLAPD_DIR)/slapd.z:
_setup_files: $(INSTDIR)/$(SLAPD_DIR)/dsinst.dll \
$(INSTDIR)/$(SLAPD_DIR)/slapd.inf \
$(INSTDIR)/admin $(INSTDIR)/base \
- $(INSTDIR)/svrcore $(INSTDIR)/tools
+ $(INSTDIR)/svrcore
# see components.mk for a description of PACKAGE_SETUP_LIBS
-@for file in $(PACKAGE_SETUP_LIBS) ; \
do if [ -f $$file ] ; \
@@ -1004,20 +982,6 @@ $(INSTDIR)/base: $(ADMSERV_DIR)/base
$(INSTDIR)/svrcore: $(ADMSERV_DIR)/svrcore
cp -R $< $@
-$(INSTDIR)/tools: $(INSTDIR)/tools/infozip.zip
- $(UNZIP) -j $(INSTDIR)/nsperl/$(NSPERL_ZIP_FILE) \
- lib/nsPerl5.6.1/bin/perl$(DOTEXE) -d $@
- $(UNZIP) -j $(INSTDIR)/nsperl/$(NSPERL_ZIP_FILE) \
- lib/nsPerl5.6.1/bin/perl56.dll -d $@
-# We need to pull out the perl lib directory for perl to work
- mkdir $@/tmp
- $(UNZIP) $(INSTDIR)/nsperl/$(NSPERL_ZIP_FILE) \
- lib/nsPerl5.6.1/lib/\* -d $@/tmp
- cp -R $@/tmp/lib/nsPerl5.6.1/lib $@
- rm -rf $@/tmp
- $(UNZIP) -j $< -d $@
- rm -f $<
-
endif
$(OBJDIR)/lib/libsi18n/ns-slapd.properties:
diff --git a/ldap/cm/newinst/ns-update b/ldap/cm/newinst/ns-update
index 5e4ffe866..24676d6a1 100755
--- a/ldap/cm/newinst/ns-update
+++ b/ldap/cm/newinst/ns-update
@@ -63,11 +63,13 @@ start_server()
install_nsperl()
{
# the current version of nsPerl to use is defined in the slapd.inf
- nsperlinst=`grep '^NSPerlPostInstall' setup/slapd/slapd.inf | cut -f2 -d=`
- # run the nsperl installer
- $nsperlinst > setup/nsperl/install.log
- # use nsperl as our local copy of perl
- cp `dirname $nsperlinst`/nsperl $PERL
+ nsperlinst=`grep '^NSPerlPostInstall' setup/slapd/slapd.inf | cut -f2 -d= 2> /dev/null`
+ if [ "$nsperlinst" ]; then
+ # run the nsperl installer
+ $nsperlinst > setup/nsperl/install.log
+ # use nsperl as our local copy of perl
+ cp `dirname $nsperlinst`/nsperl $PERL
+ fi
}
wrap_security_tools()
@@ -176,13 +178,8 @@ wrap_security_tools $sroot
cd `dirname $0`
rc=0
-if [ "$iDSISolaris" = "" ]; then
- ./ds_create $* $extraflags
- rc=$?
-else
- $PERL -w Install.pl $* $extraflags
- rc=$?
-fi
+./ds_create $* $extraflags
+rc=$?
if [ -f fix_secmod_db_64 ]; then
./fix_secmod_db_64 $sroot/alias $sroot/shared32/bin
diff --git a/ldap/include/proto-ntutil.h b/ldap/include/proto-ntutil.h
index 499693826..d74171aa8 100644
--- a/ldap/include/proto-ntutil.h
+++ b/ldap/include/proto-ntutil.h
@@ -96,9 +96,6 @@ extern BOOL SlapdGetServerNameFromCmdline(char *szServerName, char *szCmdLine, i
*/
#ifdef NET_SSL
extern char *Slapd_GetPassword();
-#ifdef FORTEZZA
-extern char *Slapd_GetFortezzaPIN();
-#endif
extern void CenterDialog(HWND hwndParent, HWND hwndDialog);
#endif /* NET_SSL */
diff --git a/ldap/javarules.mk b/ldap/javarules.mk
index 2d52d3f2e..baa70c29d 100644
--- a/ldap/javarules.mk
+++ b/ldap/javarules.mk
@@ -116,10 +116,7 @@ else
endif
endif
-CLASSPATH := $(JAVA_SRC_DIR)$(PATH_SEP)$(NMCLFJARFILE)$(PATH_SEP)$(LDAPJARFILE)$(PATH_SEP)$(MCCJARFILE)$(PATH_SEP)$(JAVASSLJARFILE)$(PATH_SEP)$(BASEJARFILE)$(PATH_SEP)$(JSSJARFILE)
-#CLASSPATH := $(JAVA_SRC_DIR)$(PATH_SEP)$(SWINGJARFILE)$(PATH_SEP)$(NMCLFJARFILE)$(PATH_SEP)$(LDAPJARFILE)$(PATH_SEP)$(MCCJARFILE)$(PATH_SEP)$(JAVASSLJARFILE)$(PATH_SEP)$(BASEJARFILE)
-
-RUNCLASSPATH:=$(JAVA_BUILD_DIR) $(PACKAGE_UNDER_JAVA)
+CLASSPATH := $(JAVA_SRC_DIR)$(PATH_SEP)$(LDAPJARFILE)
ifndef JAVA
ifdef JAVABINDIR
@@ -145,6 +142,10 @@ ifndef JAVADOC
endif
# How to run ant (the Java "make" system)
+ifdef GET_ANT_FROM_PATH
+ANT = ant
+else
ANT = $(JAVA) -Dant.home=$(ANT_HOME) -classpath "$(ANT_CP)$(PATH_SEP)$(JDKLIB)" org.apache.tools.ant.Main
+endif
##########################################################
diff --git a/ldap/nsldap.mk b/ldap/nsldap.mk
index 6e681f702..42aa3efdc 100644
--- a/ldap/nsldap.mk
+++ b/ldap/nsldap.mk
@@ -68,9 +68,9 @@ RELTOP=$(BUILD_ROOT)/built/release
OBJDIR_BASE = $(notdir $(OBJDIR))
OBJDIR_BASE_32 = $(notdir $(OBJDIR_32))
# Release directory for Directory Server
-RELDIR = $(BUILD_DRIVE)$(RELTOP)/$(DIR)/$(OBJDIR_BASE)
-RELDIR_32 = $(BUILD_DRIVE)$(RELTOP)/$(DIR)/$(OBJDIR_BASE_32)
-RELDIR_UNSTRIP = $(BUILD_DRIVE)$(RELTOP)/$(DIR)/$(ARCHPROCESSOR)$(NS64TAG)-$(SECURITY)$(SSL_PREFIX)-$(DEBUG)$(RTSUFFIX)-unstripped-$(BUILD_FORTEZZA)$(BUILD_PTHREADS)-$(DIR)
+RELDIR = $(BUILD_DRIVE)$(RELTOP)/$(OBJDIR_BASE)
+RELDIR_32 = $(BUILD_DRIVE)$(RELTOP)/$(OBJDIR_BASE_32)
+RELDIR_UNSTRIP = $(RELDIR)-unstripped
# this is the place libraries and plugins go which are used by other
# components i.e. not specific to slapd and its programs
@@ -384,9 +384,6 @@ endif
#
LIBSEC_DEP = $(NSCP_DISTDIR)/lib/libsec-$(SECURITY_EXTN).$(LIB_SUFFIX)
LIBSEC = $(NSCP_DISTDIR)/lib/libsec-$(SECURITY_EXTN).$(LIB_SUFFIX)
-ifdef FORTEZZA
-LIBSEC += $(FORTEZZA_DRIVER)
-endif
#
# Libdb
diff --git a/lib/base/Makefile b/lib/base/Makefile
index 3a65021b8..fb99fdf48 100644
--- a/lib/base/Makefile
+++ b/lib/base/Makefile
@@ -45,10 +45,10 @@
BUILD_ROOT=../..
MODULE=LibBase
-include $(BUILD_ROOT)/nsdefs.mk
-
OBJDEST=$(OBJDIR)/lib/base
+include $(BUILD_ROOT)/nsconfig.mk
+
ifeq ($(ARCH), WINNT)
LIBS=$(OBJDIR)/lib/libbase.lib
ifeq ($(BSCINFO), yes)
@@ -58,8 +58,6 @@ else
LIBS=$(OBJDIR)/lib/libbase.a
endif
-include $(BUILD_ROOT)/nsconfig.mk
-
MCC_INCLUDE += $(ADMINUTIL_INCLUDE)
LOCAL_DEPS = $(NSPR_DEP) $(ADMINUTIL_DEP) $(SECURITY_DEP) $(DBM_DEP)
diff --git a/lib/libadmin/Makefile b/lib/libadmin/Makefile
index 83f2471b3..8de6d7440 100644
--- a/lib/libadmin/Makefile
+++ b/lib/libadmin/Makefile
@@ -44,10 +44,10 @@ BUILD_ROOT=../..
MODULE=LibAdmin
MODULE_CFLAGS=-DENCRYPT_PASSWORDS -DUSE_ADMSERV
-include $(BUILD_ROOT)/nsdefs.mk
-
OBJDEST=$(OBJDIR)/lib/libadmin
+include $(BUILD_ROOT)/nsconfig.mk
+
ifeq ($(ARCH), WINNT)
LIBS=$(OBJDIR)/lib/libadmin.lib
else
@@ -69,8 +69,6 @@ all: $(OBJDEST) $(LIBS)
#$(LIBS): $(addprefix $(BUILD_ROOT)/include/libadmin/, \
# hadm_msgs.i la_msgs.i)
-include $(BUILD_ROOT)/nsconfig.mk
-
MCC_INCLUDE += $(ADMINUTIL_INCLUDE)
#ifeq ($(ARCH), HPUX)
diff --git a/lib/libsi18n/Makefile b/lib/libsi18n/Makefile
index d9432314a..408ad20bd 100644
--- a/lib/libsi18n/Makefile
+++ b/lib/libsi18n/Makefile
@@ -42,11 +42,11 @@
BUILD_ROOT=../..
MODULE=LibsI18N
-include $(BUILD_ROOT)/nsdefs.mk
+OBJDEST=$(OBJDIR)/lib/libsi18n
-NSDEFS_PRODUCT = $(NS_PRODUCT)
+include $(BUILD_ROOT)/nsconfig.mk
-OBJDEST=$(OBJDIR)/lib/libsi18n
+NSDEFS_PRODUCT = $(NS_PRODUCT)
L10NDIR = $(BUILD_ROOT)/l10n
@@ -92,8 +92,6 @@ ifeq ($(BUILD_MODULE), DIRECTORY)
gsslapd.h
endif
-include $(BUILD_ROOT)/nsconfig.mk
-
MCC_INCLUDE += $(ADMINUTIL_INCLUDE)
all: $(OBJDEST) $(LIBS) $(BSCS) $(OBJDEST)/$(StringDatabase)
diff --git a/modules.awk b/modules.awk
index 40bf55aa0..3a437857d 100644
--- a/modules.awk
+++ b/modules.awk
@@ -254,15 +254,6 @@ endif
#DISTLIB libsec-$(WHICHA) $(MCOM_LIBDIR)/libsec libnspr libdbm libxp
#endif
-ifdef FORTEZZA
-ifeq ($(ARCH), WINNT)
-LIBSEC += $(MCOM_LIBDIR)/../dist/$(NSOBJDIR_NAME)/lib/tssp32.lib
-else
-FORTEZZA_DRIVER = $(MCOM_LIBDIR)/../dist/$(NSOBJDIR_NAME)/lib/libci.a
-endif
-LIBSEC += $(FORTEZZA_DRIVER)
-endif
-
ifneq ($(MODULE), LibNet)
LIBNET=$(MCOM_LIBDIR)/libnet/$(NSOBJDIR_NAME)/libnet.$(LIB_SUFFIX)
DISTLIB libnet.$(LIB_SUFFIX) $(MCOM_LIBDIR)/libnet
diff --git a/nsconfig.mk b/nsconfig.mk
index 0425c19ae..301cbab2f 100644
--- a/nsconfig.mk
+++ b/nsconfig.mk
@@ -67,22 +67,23 @@ ifdef INTERNAL_BUILD
USE_DSGW:=1
USE_JAVATOOLS:=1
USE_SETUPUTIL:=1
+else
+ USE_ADMINSERVER:=1
+ USE_CONSOLE:=1
+ USE_DSMLGW:=1
+ USE_ORGCHART:=1
+ USE_DSGW:=1
+ USE_JAVATOOLS:=1
+ USE_SETUPUTIL:=1
endif
include $(BUILD_ROOT)/nsdefs.mk
include $(BUILD_ROOT)/component_versions.mk
-# SEC_SUFFIX is the suffix to be applied to the reldate macro which specifies
-# the security of the specified release, either E for export, D for domestic,
-# or F for Fortezza
-ifdef FORTEZZA
- SEC_SUFFIX = F
+ifeq ($(SECURITY), domestic)
+ SEC_SUFFIX = D
else
- ifeq ($(SECURITY), domestic)
- SEC_SUFFIX = D
- else
- SEC_SUFFIX = E
- endif
+ SEC_SUFFIX = E
endif
PRETTY_ARCH := $(shell uname -s)
@@ -410,10 +411,6 @@ ifdef PRODUCT_IS_DIRECTORY_SERVER
endif
endif
-ifdef FORTEZZA
- MCC_SERVER += -DFORTEZZA -DCLIENT_AUTH
-endif
-
MCC_SERVER += -DSPAPI20 -DBUILD_NUM=$(GET_BUILD_NUM)
# ----------- Default Flags, may be overridden below ------------
@@ -1360,22 +1357,10 @@ endif # IRIX
# XXXrobm The Sun MD stuff #includes stuff in the nspr dir without a prefix
# Otherwise the second NSCP_DISTDIR/include/nspr would not be necessary
-ifdef NSPR20
MCC_INCLUDE=-I$(BUILD_ROOT)/include \
- -I$(BUILD_ROOT)/include \
+ -I$(BUILD_ROOT)/include \
$(NSPR_INCLUDE) $(DBM_INCLUDE) $(SECURITY_INCLUDE) \
- $(SVRCORE_INCLUDE) \
- -I$(BUILD_ROOT)/nspr20/lib
-
-# $(SVRCORE_INCLUDE) $(NLS_INCLUDE) \
-
-else
-MCC_INCLUDE=-I$(BUILD_ROOT)/include \
- -I$(NSCP_DISTDIR)/include -I$(NSCP_DISTDIR)/include/nspr
-endif
-
-MCC_INCLUDE += -I$(LDAP_INCLUDE)
-MCC_INCLUDE += -I$(SASL_INCLUDE)
+ $(SVRCORE_INCLUDE) -I$(LDAP_INCLUDE) -I$(SASL_INCLUDE)
ifeq ($(ARCH), WINNT)
XP_FLAG=-DXP_WIN32 -DXP_WIN -D_WINDOWS -DXP_PC -DXP_WINNT
diff --git a/nsdefs.mk b/nsdefs.mk
index abf7b9a80..7405c7f9e 100644
--- a/nsdefs.mk
+++ b/nsdefs.mk
@@ -44,7 +44,7 @@
#
# BUILD_BOMB=[-DPUMPKIN_HOUR=xxxxxxx or just leave it empty]
# BUILD_DEBUG=[full, optimize, purify, quantify]
-# BUILD_MODULE=[HTTP_ADMIN, HTTP_PERSONAL, HTTP_ENTERPRISE, ...]
+# BUILD_MODULE=[HTTP_ADMIN, ...]
# BUILD_SECURITY=[none, export, domestic]
TMP_ARCH := $(shell uname -s)
@@ -125,22 +125,7 @@ endif # !BUILD_JAVA_CODE
NSPR_SUF=20
LDAP_SUF=50
-# We can't have lite fortezza ( I don't think it makes sense ).
-ifdef FORTEZZA
-BUILD_FORTEZZA=fortezza
-else
-ifdef LITE
-BUILD_FORTEZZA=lite
-else
-BUILD_FORTEZZA=normal
-endif
-endif
-
-ifdef LITE
-IS_DIR_LITE=true
-else
IS_DIR_LITE=false
-endif
# Foreign language support
WEBSERVER_LANGS = ja fr de
@@ -185,7 +170,6 @@ echo BUILD_ARCH=$(BUILD_ARCH)
echo BUILD_MODULE=$(BUILD_MODULE)
echo BUILD_SECURITY=$(BUILD_SECURITY)
echo BUILD_DEBUG=$(BUILD_DEBUG)
-echo BUILD_FORTEZZA=$(BUILD_FORTEZZA)
echo BUILD_NSPR_THREADS=$(BUILD_NSPR_THREADS)
echo BUILD_BOMB=$(BUILD_BOMB)
echo BUILD_DLL_VERSION=$(BUILD_DLL_VERSION)
@@ -205,7 +189,6 @@ else
endif
SECURITY=$(BUILD_SECURITY)
DEBUG=$(BUILD_DEBUG)
-B_FORTEZZA=$(BUILD_FORTEZZA)
BOMB=$(BUILD_BOMB)
NSPR_THREADS=$(BUILD_NSPR_THREADS)
BUILD_DLL=$(BUILD_DLL_VERSION)
@@ -225,13 +208,8 @@ RTSUFFIX=-d
endif
endif
endif
-BASIC_OBJDIR=$(BUILD_ROOT)/built/$(ARCH)$(NSOS_TEST1_TAG)$(NS64TAG)-$(SECURITY)-$(DEBUG)$(RTSUFFIX)-$(B_FORTEZZA)
+BASIC_OBJDIR=$(BUILD_ROOT)/built/$(FULL_RTL_OBJDIR)
-#
-# -- Directory Server Section -----------------------------------------------
-#
-
-ifeq ($(BUILD_MODULE), DIRECTORY)
ifdef NSPR20
NSPR_DIR=nspr20
else
@@ -244,24 +222,13 @@ PRODUCT_IS_DIRECTORY_SERVER=1
INSTANCE_NAME_PREFIX="Directory Server"
DIR=slapd
NS_PRODUCT=DIRECTORY_SERVER
-ARCHPROCESSOR=$(ARCH)
ifdef INCLUDE_SSL
SSL_PREFIX=-ssl
endif
-ifeq ($(findstring RHEL, $(BUILD_ARCH)), RHEL)
- NS_BUILD_FLAVOR = $(BUILD_ARCH)$(NS64TAG)-$(SECURITY)$(SSL_PREFIX)-$(DEBUG)$(RTSUFFIX)-$(BUILD_FORTEZZA)$(BUILD_PTHREADS)-$(DIR)
- ARCHPROCESSOR = $(BUILD_ARCH)
-else
- NS_BUILD_FLAVOR = $(ARCH)$(NSOS_TEST1_TAG)$(NS64TAG)-$(SECURITY)$(SSL_PREFIX)-$(DEBUG)$(RTSUFFIX)-$(BUILD_FORTEZZA)$(BUILD_PTHREADS)-$(DIR)
-endif
-NC_BUILD_FLAVOR = $(NSCONFIG)$(NSOBJDIR_TAG).OBJ
-ifeq ($(ARCH), WINNT)
-ifeq ($(PROCESSOR), ALPHA)
-ARCHPROCESSOR=$(ARCH)$(PROCESSOR)
-endif
-endif
-COMMON_OBJDIR=$(BUILD_ROOT)/built/$(ARCHPROCESSOR)$(NSOS_TEST1_TAG)$(NS64TAG)-$(SECURITY)$(SSL_PREFIX)-$(DEBUG)$(RTSUFFIX)-$(BUILD_FORTEZZA)$(BUILD_PTHREADS)-$(DIR)
-COMMON_OBJDIR_32=$(BUILD_ROOT)/built/$(ARCHPROCESSOR)-$(SECURITY)$(SSL_PREFIX)-$(DEBUG)$(RTSUFFIX)-$(BUILD_FORTEZZA)$(BUILD_PTHREADS)-$(DIR)
+NS_BUILD_FLAVOR = $(FULL_RTL_OBJDIR)
+NC_BUILD_FLAVOR = $(FULL_RTL_OBJDIR)
+COMMON_OBJDIR=$(BUILD_ROOT)/built/$(FULL_RTL_OBJDIR)
+COMMON_OBJDIR_32= $(subst $(NS64TAG),,$(COMMON_OBJDIR))
OBJDIR=$(COMMON_OBJDIR)
OBJDIR_32=$(COMMON_OBJDIR_32)
DO_SEARCH=no
@@ -281,36 +248,6 @@ LDAP_NO_LIBLCACHE:=1
DIRVERDIR=$(COMMON_OBJDIR)/include
DIRVER_H=$(DIRVERDIR)/dirver.h
SDKVER_H=$(DIRVERDIR)/sdkver.h
-endif
-
-#
-# -- Default Section --------------------------------------------------------
-#
-# Some of the _OBJDIR is maintained for backward compatibility until they
-# are all cleaned up. Most of them heavily dependent on value of $(DIR)
-#
-
-ifndef AMDSERV_OBJDIR
-ADMSERV_OBJDIR=$(BASIC_OBJDIR)-admin
-endif
-
-ifndef COMMON_OBJDIR
-COMMON_OBJDIR=$(BASIC_OBJDIR)-$(DIR)
-endif
-
-ifndef HTTPD_OBJDIR
-HTTPD_OBJDIR=$(BASIC_OBJDIR)-$(DIR)
-endif
-
-ifndef MC_ICONS_OBJDIR
-MC_ICONS_OBJDIR=$(BASIC_OBJDIR)-$(DIR)
-endif
-
-ifndef OBJDIR
-OBJDIR=$(BASIC_OBJDIR)-$(DIR)
-endif
-
-ifndef PLUGINS_OBJDIR
-PLUGINS_OBJDIR=$(BASIC_OBJDIR)-$(DIR)/plugins
-endif
+# this is the one that adminutil, setuputil, and adminserver uses
+COMPONENT_OBJDIR=$(FULL_RTL_OBJDIR)
| 0 |
1b2458fe9fd819d9ae733875bc86d342ab47a862
|
389ds/389-ds-base
|
Issue 5765 - Improve installer selinux handling
Description: When labeling ports we retry on error, and we should do the same
when labeling files
relates: https://github.com/389ds/389-ds-base/issues/5765
Reviewed by: ?
|
commit 1b2458fe9fd819d9ae733875bc86d342ab47a862
Author: Mark Reynolds <[email protected]>
Date: Thu May 11 10:33:28 2023 -0400
Issue 5765 - Improve installer selinux handling
Description: When labeling ports we retry on error, and we should do the same
when labeling files
relates: https://github.com/389ds/389-ds-base/issues/5765
Reviewed by: ?
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index e73dc6e69..4c8402724 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -270,7 +270,7 @@ def _get_selinux_fcontext_info():
def resolve_selinux_path(path):
- '''Return the path as expected by semanage fcontext'''
+ """Return the path as expected by semanage fcontext"""
path = str(Path(path).resolve())
if selinux_present():
_get_selinux_fcontext_info()
@@ -309,20 +309,34 @@ def selinux_label_file(path, label):
return
raise ValueError(f'Cannot change file context for {path} because it is defined in SELinux policy. Please choose another path.')
if label:
- try:
- log.debug(f"Setting label {label} in SELinux file context {path}.")
- result = subprocess.run(["semanage", "fcontext", "-a", "-t", label, path],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- args = ' '.join(ensure_list_str(result.args))
- stdout = ensure_str(result.stdout)
- stderr = ensure_str(result.stderr)
- if result.returncode != 0:
- log.error(f"ERROR CMD: {args} ; STDOUT: {stdout} ; STDERR: {stderr}")
+ rc = 0
+ for i in range(5):
+ try:
+ log.debug(f"Setting label {label} in SELinux file context {path}. Attempt {i}")
+ result = subprocess.run(["semanage", "fcontext", "-a", "-t", label, path],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ args = ' '.join(ensure_list_str(result.args))
+ stdout = ensure_str(result.stdout)
+ stderr = ensure_str(result.stderr)
+ rc = result.returncode
+ if rc == 0:
+ local[path] = label
+ break
+ else:
+ log.debug(f"Failure setting label {label} for context {path}: Result code {rc}, retrying...")
+ time.sleep(2)
+ except (OSError, subprocess.CalledProcessError) as e:
+ log.debug(f"Failure setting label {label} for context {path}: Exception {str(e)}, retrying...")
+ time.sleep(2)
+
+ if rc != 0:
+ log.error(f"ERROR CMD: {args} ; STDOUT: {stdout} ; STDERR: {stderr}")
+ try:
result.check_returncode()
- local[path] = label
- except (OSError, subprocess.CalledProcessError) as e:
- raise ValueError(f"Failed to set SElinux label {label} on {path}: {str(e)}")
+ except (OSError, subprocess.CalledProcessError) as e:
+ raise ValueError(f"Failed to set SElinux label {label} on {path}: {str(e)}")
+
if os.path.exists(path):
# pytest fails if I use selinux_restorecon(path)
subprocess.run(["restorecon", "-R", path])
| 0 |
2bef7e7dad076549faa6af3f0d7e70294fe48a00
|
389ds/389-ds-base
|
Ticket 495 - internalModifiersname not updated by DNA plugin
Bug Description: If you are using the "nsslapd-plugin-binddn-tracking", and the DNA plugin
modifiers the entry, the internalmodifiersname is not updated.
Fix Description: This is because the DNA plugin directly modifies the entry, and does not
use the internal modify functions that would trigger the last mod attributes
to be updated. So we have to call the last mod update funtciont directly from
the dna plugin.
There is also a slight change to the behavior now. The internalModifiersname &
internalCreatorsname will never be the bind dn, but instead it will be the plugin
that actually did the update. So if a entry was not touched by a DS plugin, then
the "database" plugin would be the internal modifier/creator:
cn=ldbm database,cn=plugins,cn=config
This would also allow us to detect if someone replaced the default backend.
https://fedorahosted.org/389/ticket/495
Reviewed by: nhosoi(Thanks!)
|
commit 2bef7e7dad076549faa6af3f0d7e70294fe48a00
Author: Mark Reynolds <[email protected]>
Date: Fri Oct 19 10:22:21 2012 -0400
Ticket 495 - internalModifiersname not updated by DNA plugin
Bug Description: If you are using the "nsslapd-plugin-binddn-tracking", and the DNA plugin
modifiers the entry, the internalmodifiersname is not updated.
Fix Description: This is because the DNA plugin directly modifies the entry, and does not
use the internal modify functions that would trigger the last mod attributes
to be updated. So we have to call the last mod update funtciont directly from
the dna plugin.
There is also a slight change to the behavior now. The internalModifiersname &
internalCreatorsname will never be the bind dn, but instead it will be the plugin
that actually did the update. So if a entry was not touched by a DS plugin, then
the "database" plugin would be the internal modifier/creator:
cn=ldbm database,cn=plugins,cn=config
This would also allow us to detect if someone replaced the default backend.
https://fedorahosted.org/389/ticket/495
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 34d67abe9..2b5696795 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -2853,6 +2853,8 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
/* no need to dup */
DNA_NEEDS_UPDATE);
}
+ /* Update the internalModifiersname for this add op */
+ add_internal_modifiersname(pb, e);
/* Make sure we don't generate for this
* type again by keeping a list of types
@@ -3106,6 +3108,8 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
/* no need to dup */
DNA_NEEDS_UPDATE);
}
+ /* Update the internalModifersname for this mod op */
+ modify_update_last_modified_attr(pb, smods);
/* Make sure we don't generate for this
* type again by keeping a list of types
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index d1d23b3a8..c41c09f68 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -73,7 +73,7 @@
/* Forward declarations */
static int add_internal_pb (Slapi_PBlock *pb);
static void op_shared_add (Slapi_PBlock *pb);
-static int add_created_attrs(Operation *op, Slapi_Entry *e);
+static int add_created_attrs(Slapi_PBlock *pb, Slapi_Entry *e);
static int check_rdn_for_created_attrs(Slapi_Entry *e);
static void handle_fast_add(Slapi_PBlock *pb, Slapi_Entry *entry);
static int add_uniqueid (Slapi_Entry *e);
@@ -684,7 +684,7 @@ static void op_shared_add (Slapi_PBlock *pb)
/* can get lastmod only after backend is selected */
slapi_pblock_get(pb, SLAPI_BE_LASTMOD, &lastmod);
- if (lastmod && add_created_attrs(operation, e) != 0)
+ if (lastmod && add_created_attrs(pb, e) != 0)
{
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"cannot insert computed attributes", 0, NULL);
@@ -797,20 +797,25 @@ done:
}
static int
-add_created_attrs(Operation *op, Slapi_Entry *e)
+add_created_attrs(Slapi_PBlock *pb, Slapi_Entry *e)
{
char buf[20];
char *binddn = NULL;
+ char *plugin_dn = NULL;
struct berval bv;
struct berval *bvals[2];
time_t curtime;
struct tm ltm;
+ Operation *op;
+ struct slapdplugin *plugin = NULL;
+ struct slapi_componentid *cid = NULL;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
LDAPDebug(LDAP_DEBUG_TRACE, "add_created_attrs\n", 0, 0, 0);
bvals[0] = &bv;
bvals[1] = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
if(slapdFrontendConfig->plugin_track){
/* plugin bindDN tracking is enabled, grab the dn from thread local storage */
@@ -818,8 +823,21 @@ add_created_attrs(Operation *op, Slapi_Entry *e)
bv.bv_val = "";
bv.bv_len = strlen(bv.bv_val);
} else {
- bv.bv_val = (char*)slapi_sdn_get_dn(&op->o_sdn);
- bv.bv_len = strlen(bv.bv_val);
+ slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &cid);
+ if (cid){
+ plugin=(struct slapdplugin *) cid->sci_plugin;
+ } else {
+ slapi_pblock_get (pb, SLAPI_PLUGIN, &plugin);
+ }
+ if(plugin)
+ plugin_dn = plugin_get_dn (plugin);
+ if(plugin_dn){
+ bv.bv_val = plugin_dn;
+ bv.bv_len = strlen(bv.bv_val);
+ } else {
+ bv.bv_val = (char*)slapi_sdn_get_dn(&op->o_sdn);
+ bv.bv_len = strlen(bv.bv_val);
+ }
}
slapi_entry_attr_replace(e, "internalCreatorsName", bvals);
slapi_entry_attr_replace(e, "internalModifiersName", bvals);
@@ -1023,3 +1041,31 @@ check_oc_subentry(Slapi_Entry *e, struct berval **vals, char *normtype) {
}
return subentry;
}
+
+/*
+ * Used by plugins that modify entries on add operations, otherwise the internalModifiersname
+ * would be incorrect.
+ */
+void
+add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e)
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ struct slapi_componentid *cid = NULL;
+ struct slapdplugin *plugin = NULL;
+ char *plugin_dn = NULL;
+
+ if(slapdFrontendConfig->plugin_track){
+ /* plugin bindDN tracking is enabled, grab the bind dn from thread local storage */
+ slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &cid);
+ if (cid){
+ plugin=(struct slapdplugin *) cid->sci_plugin;
+ } else {
+ slapi_pblock_get (pb, SLAPI_PLUGIN, &plugin);
+ }
+ if(plugin)
+ plugin_dn = plugin_get_dn (plugin);
+ if(plugin_dn){
+ slapi_entry_attr_set_charptr(e, "internalModifiersname", plugin_dn);
+ }
+ }
+}
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 019fe20b0..4a6ca44f0 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -135,7 +135,8 @@ do_ps_service(Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype, ber_int_t c
(ps_service_fn)(e, eprev, chgtype, chgnum);
}
-void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
+void
+modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
{
char buf[20];
char *plugin_dn = NULL;
@@ -162,8 +163,11 @@ void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
bv.bv_len = strlen(bv.bv_val);
} else {
slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &cid);
- if (cid)
+ if (cid){
plugin=(struct slapdplugin *) cid->sci_plugin;
+ } else {
+ slapi_pblock_get (pb, SLAPI_PLUGIN, &plugin);
+ }
if(plugin)
plugin_dn = plugin_get_dn (plugin);
if(plugin_dn){
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 905b0f45c..19c06a272 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1290,7 +1290,6 @@ void set_config_params (Slapi_PBlock *pb);
/* set parameters common for all internal operations */
void set_common_params (Slapi_PBlock *pb);
void do_ps_service(Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype, ber_int_t chgnum);
-void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);
/*
* debugdump.cpp
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 6c2781c29..3ee175598 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1252,6 +1252,12 @@ int slapi_add_internal_attr_syntax( const char *name, const char *oid, const cha
void pw_exp_init ( void );
int pw_copy_entry_ext(Slapi_Entry *src_e, Slapi_Entry *dest_e);
+/* op_shared.c */
+void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);
+
+/* add.c */
+void add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e);
+
#ifdef __cplusplus
}
#endif
| 0 |
947ee67df65799d24748a25e6be8c59fe82231b5
|
389ds/389-ds-base
|
Issue 6614 - CLI - Error when trying to display global DB stats with LMDB (#6622)
Bug description:
Displaying global monitor stats fails with key error. Caused by BDB
backend keys being used when MDB is the configured DB implementation.
Fix description:
Ensure backend and monitor keys match the configured DB implementation.
Fixes: https://github.com/389ds/389-ds-base/issues/6614
Reviewed by: @droideck, @progier389 (Thank you)
|
commit 947ee67df65799d24748a25e6be8c59fe82231b5
Author: James Chapman <[email protected]>
Date: Thu Apr 24 20:16:38 2025 +0000
Issue 6614 - CLI - Error when trying to display global DB stats with LMDB (#6622)
Bug description:
Displaying global monitor stats fails with key error. Caused by BDB
backend keys being used when MDB is the configured DB implementation.
Fix description:
Ensure backend and monitor keys match the configured DB implementation.
Fixes: https://github.com/389ds/389-ds-base/issues/6614
Reviewed by: @droideck, @progier389 (Thank you)
diff --git a/dirsrvtests/tests/suites/monitor/monitor_test.py b/dirsrvtests/tests/suites/monitor/monitor_test.py
index 04b2f35fe..ada465890 100644
--- a/dirsrvtests/tests/suites/monitor/monitor_test.py
+++ b/dirsrvtests/tests/suites/monitor/monitor_test.py
@@ -101,13 +101,12 @@ def test_monitor_ldbm(topo):
# Check that known attributes exist (only NDN cache stats)
assert 'normalizeddncachehits' in monitor
-
# Check for library specific attributes
if db_lib == 'bdb':
assert 'dbcachehits' in monitor
assert 'nsslapd-db-configured-locks' in monitor
elif db_lib == 'mdb':
- pass
+ assert 'dbcachehits' not in monitor
else:
# Unknown - the server would probably fail to start but check it anyway
log.fatal(f'Unknown backend library: {db_lib}')
diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py
index a3b8a4bcb..80c0b2773 100644
--- a/src/lib389/lib389/_constants.py
+++ b/src/lib389/lib389/_constants.py
@@ -383,3 +383,7 @@ BDB_IMPL_STATUS = Enum('BDB_IMPL_STATUS', [
'BUNDLED', # lib389 bundled rpm is installed
'READ_ONLY', # Read-only version is available
'NONE' ]) # bdb is not usasable
+
+# DB implementation
+DB_IMPL_BDB = "bdb"
+DB_IMPL_MDB = "mdb"
diff --git a/src/lib389/lib389/cli_conf/monitor.py b/src/lib389/lib389/cli_conf/monitor.py
index 1f55fd8f8..b01796549 100644
--- a/src/lib389/lib389/cli_conf/monitor.py
+++ b/src/lib389/lib389/cli_conf/monitor.py
@@ -10,8 +10,8 @@
import datetime
import json
import os
-from lib389.monitor import (Monitor, MonitorLDBM, MonitorSNMP,
- MonitorDiskSpace)
+from lib389._constants import (DB_IMPL_BDB, DB_IMPL_MDB)
+from lib389.monitor import (Monitor, MonitorLDBM, MonitorSNMP, MonitorDiskSpace)
from lib389.chaining import (ChainingLinks)
from lib389.backend import Backends
from lib389.utils import convert_bytes
@@ -129,27 +129,30 @@ def db_monitor(inst, basedn, log, args):
# Gather the global DB stats
report_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
ldbm_mon = ldbm_monitor.get_status()
- dbcachesize = int(ldbm_mon['nsslapd-db-cache-size-bytes'][0])
- # Warning: there are two different page sizes associated with bdb:
- # - nsslapd-db-mp-pagesize the db mempool (i.e the db cache) page size which is usually 4K
- # - nsslapd-db-pagesize the db instances (i.e id2entry, indexes, changelog) page size which
- # is usually 8K
- # To compute the db cache statistics we must use the nsslapd-db-mp-pagesize
- if 'nsslapd-db-mp-pagesize' in ldbm_mon:
- pagesize = int(ldbm_mon['nsslapd-db-mp-pagesize'][0])
- else:
- # targeting a remote instance that does not have github issue 5550 fix.
- # So lets use the usual default file system preferred block size
- # db cache free statistics may be wrong but we gave no way to
- # compute it rightly.
- pagesize = 4096
- dbhitratio = ldbm_mon['dbcachehitratio'][0]
- dbcachepagein = ldbm_mon['dbcachepagein'][0]
- dbcachepageout = ldbm_mon['dbcachepageout'][0]
- dbroevict = ldbm_mon['nsslapd-db-page-ro-evict-rate'][0]
- dbpages = int(ldbm_mon['nsslapd-db-pages-in-use'][0])
- dbcachefree = max(int(dbcachesize - (pagesize * dbpages)), 0)
- dbcachefreeratio = dbcachefree/dbcachesize
+ if ldbm_monitor.inst_db_impl == DB_IMPL_BDB:
+ dbcachesize = int(ldbm_mon['nsslapd-db-cache-size-bytes'][0])
+ # Warning: there are two different page sizes associated with bdb:
+ # - nsslapd-db-mp-pagesize the db mempool (i.e the db cache) page size which is usually 4K
+ # - nsslapd-db-pagesize the db instances (i.e id2entry, indexes, changelog) page size which
+ # is usually 8K
+ # To compute the db cache statistics we must use the nsslapd-db-mp-pagesize
+ if 'nsslapd-db-mp-pagesize' in ldbm_mon:
+ pagesize = int(ldbm_mon['nsslapd-db-mp-pagesize'][0])
+ else:
+ # targeting a remote instance that does not have github issue 5550 fix.
+ # So lets use the usual default file system preferred block size
+ # db cache free statistics may be wrong but we gave no way to
+ # compute it rightly.
+ pagesize = 4096
+
+ dbhitratio = ldbm_mon['dbcachehitratio'][0]
+ dbcachepagein = ldbm_mon['dbcachepagein'][0]
+ dbcachepageout = ldbm_mon['dbcachepageout'][0]
+ dbroevict = ldbm_mon['nsslapd-db-page-ro-evict-rate'][0]
+ dbpages = int(ldbm_mon['nsslapd-db-pages-in-use'][0])
+ dbcachefree = max(int(dbcachesize - (pagesize * dbpages)), 0)
+ dbcachefreeratio = dbcachefree/dbcachesize
+
ndnratio = ldbm_mon['normalizeddncachehitratio'][0]
ndncursize = int(ldbm_mon['currentnormalizeddncachesize'][0])
ndnmaxsize = int(ldbm_mon['maxnormalizeddncachesize'][0])
@@ -165,14 +168,6 @@ def db_monitor(inst, basedn, log, args):
# Build global cache stats
result = {
'date': report_time,
- 'dbcache': {
- 'hit_ratio': dbhitratio,
- 'free': convert_bytes(str(dbcachefree)),
- 'free_percentage': "{:.1f}".format(dbcachefreeratio * 100),
- 'roevicts': dbroevict,
- 'pagein': dbcachepagein,
- 'pageout': dbcachepageout
- },
'ndncache': {
'hit_ratio': ndnratio,
'free': convert_bytes(str(ndnfree)),
@@ -183,6 +178,16 @@ def db_monitor(inst, basedn, log, args):
'backends': {},
}
+ if ldbm_monitor.inst_db_impl == DB_IMPL_BDB:
+ result['dbcache'] = {
+ 'hit_ratio': dbhitratio,
+ 'free': convert_bytes(str(dbcachefree)),
+ 'free_percentage': "{:.1f}".format(dbcachefreeratio * 100),
+ 'roevicts': dbroevict,
+ 'pagein': dbcachepagein,
+ 'pageout': dbcachepageout
+ }
+
# Build the backend results
for be in backend_objs:
be_name = be.rdn
@@ -202,17 +207,18 @@ def db_monitor(inst, basedn, log, args):
else:
entsize = int(entcur / entcnt)
- # Process DN cache stats
- dncur = int(all_attrs['currentdncachesize'][0])
- dnmax = int(all_attrs['maxdncachesize'][0])
- dncnt = int(all_attrs['currentdncachecount'][0])
- dnratio = all_attrs['dncachehitratio'][0]
- dnfree = dnmax - dncur
- dnfreep = "{:.1f}".format(dnfree / dnmax * 100)
- if dncnt == 0:
- dnsize = 0
- else:
- dnsize = int(dncur / dncnt)
+ if ldbm_monitor.inst_db_impl == DB_IMPL_BDB:
+ # Process DN cache stats
+ dncur = int(all_attrs['currentdncachesize'][0])
+ dnmax = int(all_attrs['maxdncachesize'][0])
+ dncnt = int(all_attrs['currentdncachecount'][0])
+ dnratio = all_attrs['dncachehitratio'][0]
+ dnfree = dnmax - dncur
+ dnfreep = "{:.1f}".format(dnfree / dnmax * 100)
+ if dncnt == 0:
+ dnsize = 0
+ else:
+ dnsize = int(dncur / dncnt)
# Build the backend result
result['backends'][be_name] = {
@@ -222,13 +228,15 @@ def db_monitor(inst, basedn, log, args):
'entry_cache_free_percentage': entfreep,
'entry_cache_size': convert_bytes(str(entsize)),
'entry_cache_hit_ratio': entratio,
- 'dn_cache_count': all_attrs['currentdncachecount'][0],
- 'dn_cache_free': convert_bytes(str(dnfree)),
- 'dn_cache_free_percentage': dnfreep,
- 'dn_cache_size': convert_bytes(str(dnsize)),
- 'dn_cache_hit_ratio': dnratio,
'indexes': []
}
+ if ldbm_monitor.inst_db_impl == DB_IMPL_BDB:
+ backend = result['backends'][be_name]
+ backend['dn_cache_count'] = all_attrs['currentdncachecount'][0]
+ backend['dn_cache_free'] = convert_bytes(str(dnfree))
+ backend['dn_cache_free_percentage'] = dnfreep
+ backend['dn_cache_size'] = convert_bytes(str(dnsize))
+ backend['dn_cache_hit_ratio'] = dnratio
# Process indexes if requested
if args.indexes:
@@ -260,14 +268,15 @@ def db_monitor(inst, basedn, log, args):
else:
log.info("DB Monitor Report: " + result['date'])
log.info("--------------------------------------------------------")
- log.info("Database Cache:")
- log.info(" - Cache Hit Ratio: {}%".format(result['dbcache']['hit_ratio']))
- log.info(" - Free Space: {}".format(result['dbcache']['free']))
- log.info(" - Free Percentage: {}%".format(result['dbcache']['free_percentage']))
- log.info(" - RO Page Drops: {}".format(result['dbcache']['roevicts']))
- log.info(" - Pages In: {}".format(result['dbcache']['pagein']))
- log.info(" - Pages Out: {}".format(result['dbcache']['pageout']))
- log.info("")
+ if ldbm_monitor.inst_db_impl == DB_IMPL_BDB:
+ log.info("Database Cache:")
+ log.info(" - Cache Hit Ratio: {}%".format(result['dbcache']['hit_ratio']))
+ log.info(" - Free Space: {}".format(result['dbcache']['free']))
+ log.info(" - Free Percentage: {}%".format(result['dbcache']['free_percentage']))
+ log.info(" - RO Page Drops: {}".format(result['dbcache']['roevicts']))
+ log.info(" - Pages In: {}".format(result['dbcache']['pagein']))
+ log.info(" - Pages Out: {}".format(result['dbcache']['pageout']))
+ log.info("")
log.info("Normalized DN Cache:")
log.info(" - Cache Hit Ratio: {}%".format(result['ndncache']['hit_ratio']))
log.info(" - Free Space: {}".format(result['ndncache']['free']))
@@ -283,11 +292,12 @@ def db_monitor(inst, basedn, log, args):
log.info(" - Entry Cache Free Space: {}".format(attr_dict['entry_cache_free']))
log.info(" - Entry Cache Free Percentage: {}%".format(attr_dict['entry_cache_free_percentage']))
log.info(" - Entry Cache Average Size: {}".format(attr_dict['entry_cache_size']))
- log.info(" - DN Cache Hit Ratio: {}%".format(attr_dict['dn_cache_hit_ratio']))
- log.info(" - DN Cache Count: {}".format(attr_dict['dn_cache_count']))
- log.info(" - DN Cache Free Space: {}".format(attr_dict['dn_cache_free']))
- log.info(" - DN Cache Free Percentage: {}%".format(attr_dict['dn_cache_free_percentage']))
- log.info(" - DN Cache Average Size: {}".format(attr_dict['dn_cache_size']))
+ if ldbm_monitor.inst_db_impl == DB_IMPL_BDB:
+ log.info(" - DN Cache Hit Ratio: {}%".format(attr_dict['dn_cache_hit_ratio']))
+ log.info(" - DN Cache Count: {}".format(attr_dict['dn_cache_count']))
+ log.info(" - DN Cache Free Space: {}".format(attr_dict['dn_cache_free']))
+ log.info(" - DN Cache Free Percentage: {}%".format(attr_dict['dn_cache_free_percentage']))
+ log.info(" - DN Cache Average Size: {}".format(attr_dict['dn_cache_size']))
if len(result['backends'][be_name]['indexes']) > 0:
log.info(" - Indexes:")
for index in result['backends'][be_name]['indexes']:
diff --git a/src/lib389/lib389/monitor.py b/src/lib389/lib389/monitor.py
index ec82b0346..27b99a7e3 100644
--- a/src/lib389/lib389/monitor.py
+++ b/src/lib389/lib389/monitor.py
@@ -176,68 +176,64 @@ class MonitorLDBM(DSLdapObject):
:type instance: lib389.DirSrv
:param dn: not used
"""
+ DB_KEYS = {
+ DB_IMPL_BDB: [
+ 'dbcachehits', 'dbcachetries', 'dbcachehitratio',
+ 'dbcachepagein', 'dbcachepageout', 'dbcacheroevict',
+ 'dbcacherwevict'
+ ],
+ DB_IMPL_MDB: [
+ 'normalizeddncachetries', 'normalizeddncachehits',
+ 'normalizeddncachemisses', 'normalizeddncachehitratio',
+ 'normalizeddncacheevictions', 'currentnormalizeddncachesize',
+ 'maxnormalizeddncachesize', 'currentnormalizeddncachecount',
+ 'normalizeddncachethreadsize', 'normalizeddncachethreadslots'
+ ]
+ }
+ DB_MONITOR_KEYS = {
+ DB_IMPL_BDB: [
+ 'nsslapd-db-abort-rate', 'nsslapd-db-active-txns', 'nsslapd-db-cache-hit',
+ 'nsslapd-db-cache-try', 'nsslapd-db-cache-region-wait-rate',
+ 'nsslapd-db-cache-size-bytes', 'nsslapd-db-clean-pages', 'nsslapd-db-commit-rate',
+ 'nsslapd-db-deadlock-rate', 'nsslapd-db-dirty-pages', 'nsslapd-db-hash-buckets',
+ 'nsslapd-db-hash-elements-examine-rate', 'nsslapd-db-hash-search-rate',
+ 'nsslapd-db-lock-conflicts', 'nsslapd-db-lock-region-wait-rate',
+ 'nsslapd-db-lock-request-rate', 'nsslapd-db-lockers', 'nsslapd-db-configured-locks',
+ 'nsslapd-db-current-locks', 'nsslapd-db-max-locks', 'nsslapd-db-current-lock-objects',
+ 'nsslapd-db-max-lock-objects', 'nsslapd-db-log-bytes-since-checkpoint',
+ 'nsslapd-db-log-region-wait-rate', 'nsslapd-db-log-write-rate',
+ 'nsslapd-db-longest-chain-length', 'nsslapd-db-page-create-rate',
+ 'nsslapd-db-page-read-rate', 'nsslapd-db-page-ro-evict-rate',
+ 'nsslapd-db-page-rw-evict-rate', 'nsslapd-db-page-trickle-rate',
+ 'nsslapd-db-page-write-rate', 'nsslapd-db-pages-in-use',
+ 'nsslapd-db-txn-region-wait-rate', 'nsslapd-db-mp-pagesize'
+ ],
+ DB_IMPL_MDB: [
+ 'dbenvmapmaxsize', 'dbenvmapsize', 'dbenvlastpageno',
+ 'dbenvlasttxnid', 'dbenvmaxreaders', 'dbenvnumreaders',
+ 'dbenvnumdbis', 'waitingrwtxn', 'activerwtxn',
+ 'abortrwtxn', 'commitrwtxn', 'granttimerwtxn',
+ 'lifetimerwtxn', 'waitingrotxn', 'activerotxn',
+ 'abortrotxn', 'commitrotxn', 'granttimerotxn',
+ 'lifetimerotxn'
+ ]
+ }
+
def __init__(self, instance, dn=None):
super(MonitorLDBM, self).__init__(instance=instance)
self._dn = DN_MONITOR_LDBM
self._db_mon = MonitorDatabase(instance)
- self._backend_keys = [
- 'dbcachehits',
- 'dbcachetries',
- 'dbcachehitratio',
- 'dbcachepagein',
- 'dbcachepageout',
- 'dbcacheroevict',
- 'dbcacherwevict',
- ]
- self._db_mon_keys = [
- 'nsslapd-db-abort-rate',
- 'nsslapd-db-active-txns',
- 'nsslapd-db-cache-hit',
- 'nsslapd-db-cache-try',
- 'nsslapd-db-cache-region-wait-rate',
- 'nsslapd-db-cache-size-bytes',
- 'nsslapd-db-clean-pages',
- 'nsslapd-db-commit-rate',
- 'nsslapd-db-deadlock-rate',
- 'nsslapd-db-dirty-pages',
- 'nsslapd-db-hash-buckets',
- 'nsslapd-db-hash-elements-examine-rate',
- 'nsslapd-db-hash-search-rate',
- 'nsslapd-db-lock-conflicts',
- 'nsslapd-db-lock-region-wait-rate',
- 'nsslapd-db-lock-request-rate',
- 'nsslapd-db-lockers',
- 'nsslapd-db-configured-locks',
- 'nsslapd-db-current-locks',
- 'nsslapd-db-max-locks',
- 'nsslapd-db-current-lock-objects',
- 'nsslapd-db-max-lock-objects',
- 'nsslapd-db-log-bytes-since-checkpoint',
- 'nsslapd-db-log-region-wait-rate',
- 'nsslapd-db-log-write-rate',
- 'nsslapd-db-longest-chain-length',
- 'nsslapd-db-page-create-rate',
- 'nsslapd-db-page-read-rate',
- 'nsslapd-db-page-ro-evict-rate',
- 'nsslapd-db-page-rw-evict-rate',
- 'nsslapd-db-page-trickle-rate',
- 'nsslapd-db-page-write-rate',
- 'nsslapd-db-pages-in-use',
- 'nsslapd-db-txn-region-wait-rate',
- 'nsslapd-db-mp-pagesize',
- ]
- if not ds_is_older("1.4.0", instance=instance):
+ self.inst_db_impl = self._instance.get_db_lib()
+ self._backend_keys = list(self.DB_KEYS.get(self.inst_db_impl, []))
+ self._db_mon_keys = list(self.DB_MONITOR_KEYS.get(self.inst_db_impl, []))
+
+ if self.inst_db_impl == DB_IMPL_BDB and not ds_is_older("1.4.0", instance=instance):
self._backend_keys.extend([
- 'normalizeddncachetries',
- 'normalizeddncachehits',
- 'normalizeddncachemisses',
- 'normalizeddncachehitratio',
- 'normalizeddncacheevictions',
- 'currentnormalizeddncachesize',
- 'maxnormalizeddncachesize',
- 'currentnormalizeddncachecount',
- 'normalizeddncachethreadsize',
- 'normalizeddncachethreadslots'
+ 'normalizeddncachetries', 'normalizeddncachehits',
+ 'normalizeddncachemisses', 'normalizeddncachehitratio',
+ 'normalizeddncacheevictions', 'currentnormalizeddncachesize',
+ 'maxnormalizeddncachesize', 'currentnormalizeddncachecount',
+ 'normalizeddncachethreadsize', 'normalizeddncachethreadslots'
])
def get_status(self, use_json=False):
| 0 |
262e6aafb86c4e10f47bab593fcce840be1ee04a
|
389ds/389-ds-base
|
Issue 49588 - Add py3 support for tickets : part-1
Description: Added py3 support by explicitly changing strings to bytes.
Ported tests from ticket to test suites, also added docstrings.
https://pagure.io/389-ds-base/issue/49588
Reviewed by: spichugi,vashirov (Thanks!)
|
commit 262e6aafb86c4e10f47bab593fcce840be1ee04a
Author: Akshay Adhikari <[email protected]>
Date: Wed May 16 16:17:56 2018 +0530
Issue 49588 - Add py3 support for tickets : part-1
Description: Added py3 support by explicitly changing strings to bytes.
Ported tests from ticket to test suites, also added docstrings.
https://pagure.io/389-ds-base/issue/49588
Reviewed by: spichugi,vashirov (Thanks!)
diff --git a/dirsrvtests/tests/suites/acl/enhanced_aci_modrnd_test.py b/dirsrvtests/tests/suites/acl/enhanced_aci_modrnd_test.py
new file mode 100644
index 000000000..69290e9d8
--- /dev/null
+++ b/dirsrvtests/tests/suites/acl/enhanced_aci_modrnd_test.py
@@ -0,0 +1,121 @@
+# --- 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 pytest
+from lib389.tasks import *
+from lib389.utils import *
+from lib389.topologies import topology_st
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+CONTAINER_1_OU = 'test_ou_1'
+CONTAINER_2_OU = 'test_ou_2'
+CONTAINER_1 = f'ou={CONTAINER_1_OU},dc=example,dc=com'
+CONTAINER_2 = f'ou={CONTAINER_2_OU},dc=example,dc=com'
+USER_CN = 'test_user'
+USER_PWD = 'Secret123'
+USER = f'cn={USER_CN},{CONTAINER_1}'
+
+
[email protected](scope="module")
+def env_setup(topology_st):
+ """Adds two containers, one user and two ACI rules"""
+
+ log.info("Add a container: %s" % CONTAINER_1)
+ topology_st.standalone.add_s(Entry((CONTAINER_1,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_1_OU,
+ })))
+
+ log.info("Add a container: %s" % CONTAINER_2)
+ topology_st.standalone.add_s(Entry((CONTAINER_2,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_2_OU,
+ })))
+
+ log.info("Add a user: %s" % USER)
+ topology_st.standalone.add_s(Entry((USER,
+ {'objectclass': 'top person'.split(),
+ 'cn': USER_CN,
+ 'sn': USER_CN,
+ 'userpassword': USER_PWD
+ })))
+
+ ACI_TARGET = '(targetattr="*")'
+ ACI_ALLOW = '(version 3.0; acl "All rights for %s"; allow (all) ' % USER
+ ACI_SUBJECT = 'userdn="ldap:///%s";)' % USER
+ ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+ mod = [(ldap.MOD_ADD, 'aci', ensure_bytes(ACI_BODY))]
+
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_1))
+ topology_st.standalone.modify_s(CONTAINER_1, mod)
+
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_2))
+ topology_st.standalone.modify_s(CONTAINER_2, mod)
+
+
[email protected]
+def test_enhanced_aci_modrnd(topology_st, env_setup):
+ """Tests, that MODRDN operation is allowed,
+ if user has ACI right '(all)' under superior entries,
+ but doesn't have '(modrdn)'
+
+ :id: 492cf2a9-2efe-4e3b-955e-85eca61d66b9
+ :setup: Standalone instance
+ :steps:
+ 1. Create two containers
+ 2. Create a user within "ou=test_ou_1,dc=example,dc=com"
+ 3. Add an aci with a rule "cn=test_user is allowed all" within these containers
+ 4. Run MODRDN operation on the "cn=test_user" and set "newsuperior" to
+ the "ou=test_ou_2,dc=example,dc=com"
+ 5. Check there is no user under container one (ou=test_ou_1,dc=example,dc=com)
+ 6. Check there is a user under container two (ou=test_ou_2,dc=example,dc=com)
+
+ :expectedresults:
+ 1. Two containers should be created
+ 2. User should be added successfully
+ 3. This should pass
+ 4. This should pass
+ 5. User should not be found under container ou=test_ou_1,dc=example,dc=com
+ 6. User should be found under container ou=test_ou_2,dc=example,dc=com
+ """
+
+ log.info("Bind as %s" % USER)
+
+ topology_st.standalone.simple_bind_s(USER, USER_PWD)
+
+ log.info("User MODRDN operation from %s to %s" % (CONTAINER_1,
+ CONTAINER_2))
+
+ topology_st.standalone.rename_s(USER, "cn=%s" % USER_CN,
+ newsuperior=CONTAINER_2, delold=1)
+
+ log.info("Check there is no user in %s" % CONTAINER_1)
+ entries = topology_st.standalone.search_s(CONTAINER_1,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert not entries
+
+ log.info("Check there is our user in %s" % CONTAINER_2)
+ entries = topology_st.standalone.search_s(CONTAINER_2,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert entries
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ # -v for additional verbose
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/suites/filter/filter_test.py b/dirsrvtests/tests/suites/filter/filter_test.py
index a2fb9330f..176b39af0 100644
--- a/dirsrvtests/tests/suites/filter/filter_test.py
+++ b/dirsrvtests/tests/suites/filter/filter_test.py
@@ -11,11 +11,14 @@ import logging
import pytest
from lib389.tasks import *
from lib389.topologies import topology_st
-from lib389._constants import PASSWORD, DEFAULT_SUFFIX
+from lib389._constants import PASSWORD, DEFAULT_SUFFIX, DN_DM, SUFFIX
+from lib389.utils import *
logging.getLogger(__name__).setLevel(logging.DEBUG)
log = logging.getLogger(__name__)
+ENTRY_NAME = 'test_entry'
+
def test_filter_escaped(topology_st):
"""Test we can search for an '*' in a attribute value.
@@ -125,6 +128,100 @@ def test_filter_scope_one(topology_st):
log.info('Search should only have one entry')
assert len(results) == 1
[email protected]
+def test_filter_with_attribute_subtype(topology_st):
+ """Adds 2 test entries and Search with
+ filters including subtype and !
+
+ :id: 0e69f5f2-6a0a-480e-8282-fbcc50231908
+ :setup: Standalone instance
+ :steps:
+ 1. Add 2 entries and create 3 filters
+ 2. Search for entry with filter: (&(cn=test_entry en only)(!(cn=test_entry fr)))
+ 3. Search for entry with filter: (&(cn=test_entry en only)(!(cn;fr=test_entry fr)))
+ 4. Search for entry with filter: (&(cn=test_entry en only)(!(cn;en=test_entry en)))
+ 5. Delete the added entries
+ :expectedresults:
+ 1. Operation should be successful
+ 2. Search should be successful
+ 3. Search should be successful
+ 4. Search should not be successful
+ 5. Delete the added entries
+ """
+
+ # bind as directory manager
+ topology_st.standalone.log.info("Bind as %s" % DN_DM)
+ topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
+
+ # enable filter error logging
+ # mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '32')]
+ # topology_st.standalone.modify_s(DN_CONFIG, mod)
+
+ topology_st.standalone.log.info("\n\n######################### ADD ######################\n")
+
+ # Prepare the entry with cn;fr & cn;en
+ entry_name_fr = '%s fr' % (ENTRY_NAME)
+ entry_name_en = '%s en' % (ENTRY_NAME)
+ entry_name_both = '%s both' % (ENTRY_NAME)
+ entry_dn_both = 'cn=%s, %s' % (entry_name_both, SUFFIX)
+ entry_both = Entry(entry_dn_both)
+ entry_both.setValues('objectclass', 'top', 'person')
+ entry_both.setValues('sn', entry_name_both)
+ entry_both.setValues('cn', entry_name_both)
+ entry_both.setValues('cn;fr', entry_name_fr)
+ entry_both.setValues('cn;en', entry_name_en)
+
+ # Prepare the entry with one member
+ entry_name_en_only = '%s en only' % (ENTRY_NAME)
+ entry_dn_en_only = 'cn=%s, %s' % (entry_name_en_only, SUFFIX)
+ entry_en_only = Entry(entry_dn_en_only)
+ entry_en_only.setValues('objectclass', 'top', 'person')
+ entry_en_only.setValues('sn', entry_name_en_only)
+ entry_en_only.setValues('cn', entry_name_en_only)
+ entry_en_only.setValues('cn;en', entry_name_en)
+
+ topology_st.standalone.log.info("Try to add Add %s: %r" % (entry_dn_both, entry_both))
+ topology_st.standalone.add_s(entry_both)
+
+ topology_st.standalone.log.info("Try to add Add %s: %r" % (entry_dn_en_only, entry_en_only))
+ topology_st.standalone.add_s(entry_en_only)
+
+ topology_st.standalone.log.info("\n\n######################### SEARCH ######################\n")
+
+ # filter: (&(cn=test_entry en only)(!(cn=test_entry fr)))
+ myfilter = '(&(sn=%s)(!(cn=%s)))' % (entry_name_en_only, entry_name_fr)
+ topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
+ ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
+ assert len(ents) == 1
+ assert ensure_str(ents[0].sn) == entry_name_en_only
+ topology_st.standalone.log.info("Found %s" % ents[0].dn)
+
+ # filter: (&(cn=test_entry en only)(!(cn;fr=test_entry fr)))
+ myfilter = '(&(sn=%s)(!(cn;fr=%s)))' % (entry_name_en_only, entry_name_fr)
+ topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
+ ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
+ assert len(ents) == 1
+ assert ensure_str(ents[0].sn) == entry_name_en_only
+ topology_st.standalone.log.info("Found %s" % ents[0].dn)
+
+ # filter: (&(cn=test_entry en only)(!(cn;en=test_entry en)))
+ myfilter = '(&(sn=%s)(!(cn;en=%s)))' % (entry_name_en_only, entry_name_en)
+ topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
+ ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
+ assert len(ents) == 0
+ topology_st.standalone.log.info("Found none")
+
+ topology_st.standalone.log.info("\n\n######################### DELETE ######################\n")
+
+ topology_st.standalone.log.info("Try to delete %s " % entry_dn_both)
+ topology_st.standalone.delete_s(entry_dn_both)
+
+ topology_st.standalone.log.info("Try to delete %s " % entry_dn_en_only)
+ topology_st.standalone.delete_s(entry_dn_en_only)
+
+ log.info('Testcase PASSED')
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/dirsrvtests/tests/suites/password/pwd_algo_test.py b/dirsrvtests/tests/suites/password/pwd_algo_test.py
index e521727a8..ebc617e28 100644
--- a/dirsrvtests/tests/suites/password/pwd_algo_test.py
+++ b/dirsrvtests/tests/suites/password/pwd_algo_test.py
@@ -13,6 +13,9 @@ from lib389.topologies import topology_st
from lib389._constants import DEFAULT_SUFFIX, HOST_STANDALONE, DN_DM, PORT_STANDALONE
from lib389.idm.user import UserAccounts
+DEBUGGING = os.getenv('DEBUGGING', False)
+USER_DN = 'uid=user,ou=People,%s' % DEFAULT_SUFFIX
+
logging.getLogger(__name__).setLevel(logging.INFO)
log = logging.getLogger(__name__)
@@ -65,6 +68,62 @@ def _test_algo(inst, algo_name):
user.delete()
# done!
+def _test_bind_for_pbkdf2_algo(inst, password):
+ result = True
+ userconn = ldap.initialize("ldap://%s:%s" % (HOST_STANDALONE, PORT_STANDALONE))
+ try:
+ userconn.simple_bind_s(USER_DN, password)
+ userconn.unbind_s()
+ except ldap.INVALID_CREDENTIALS:
+ result = False
+ return result
+
+
+def _test_algo_for_pbkdf2(inst, algo_name):
+ inst.config.set('passwordStorageScheme', algo_name)
+
+ if DEBUGGING:
+ print('Testing %s' % algo_name)
+
+ # Create the user with a password
+ inst.add_s(Entry((
+ USER_DN, {
+ 'objectClass': 'top account simplesecurityobject'.split(),
+ 'uid': 'user',
+ 'userpassword': ['Secret123', ]
+ })))
+
+ # Make sure when we read the userPassword field, it is the correct ALGO
+ pw_field = inst.search_s(USER_DN, ldap.SCOPE_BASE, '(objectClass=*)', ['userPassword'])[0]
+
+ if DEBUGGING:
+ print(pw_field.getValue('userPassword'))
+
+ if algo_name != 'CLEAR':
+ lalgo_name = algo_name.lower()
+ lpw_algo_name = pw_field.getValue('userPassword').lower()
+ assert (lpw_algo_name.startswith(ensure_bytes('{'+lalgo_name+'}')))
+ # Now make sure a bind works
+ assert (_test_bind_for_pbkdf2_algo(inst, 'Secret123'))
+ # Bind with a wrong shorter password, should fail
+ assert (not _test_bind_for_pbkdf2_algo(inst, 'Wrong'))
+ # Bind with a wrong longer password, should fail
+ assert (not _test_bind_for_pbkdf2_algo(inst, 'This is even more wrong'))
+ # Bind with a password that has the algo in the name
+ assert (not _test_bind_for_pbkdf2_algo(inst, '{%s}SomeValues....' % algo_name))
+ # Bind with a wrong exact length password.
+ assert (not _test_bind_for_pbkdf2_algo(inst, 'Alsowrong'))
+ # Bind with a subset password, should fail
+ assert (not _test_bind_for_pbkdf2_algo(inst, 'Secret'))
+ if algo_name != 'CRYPT':
+ # Bind with a subset password that is 1 char shorter, to detect off by 1 in clear
+ assert (not _test_bind_for_pbkdf2_algo(inst, 'Secret12'))
+ # Bind with a superset password, should fail
+ assert (not _test_bind_for_pbkdf2_algo(inst, 'Secret123456'))
+ # Delete the user
+ inst.delete_s(USER_DN)
+ # done!
+
@pytest.mark.parametrize("algo",
('CLEAR', 'CRYPT', 'CRYPT-MD5', 'CRYPT-SHA256', 'CRYPT-SHA512',
'MD5', 'SHA', 'SHA256', 'SHA384', 'SHA512', 'SMD5', 'SSHA',
@@ -79,6 +138,37 @@ def test_pwd_algo_test(topology_st, algo):
_test_algo(topology_st.standalone, algo)
log.info('Test %s PASSED' % algo)
[email protected]
+def test_pbkdf2_algo(topology_st):
+ """Changing password storage scheme to PBKDF2_SHA256
+ and trying to bind with different password combination
+
+ :id: 112e265b-f468-4758-b8fa-ed8742de0182
+ :setup: Standalone instance
+ :steps:
+ 1. Change password storage scheme to PBKDF2_SHA256
+ 2. Add a test user entry
+ 3. Bind with correct password
+ 4. Bind with incorrect password combination(brute-force)
+ :expectedresults:
+ 1. Operation should be successful
+ 2. Operation should be successful
+ 3. Bind should be successful
+ 4. Should not allow to bind with incorrect password
+ """
+ if DEBUGGING:
+ # Add debugging steps(if any)...
+ log.info("ATTACH NOW")
+ time.sleep(30)
+
+ # Merge this to the password suite in the future
+
+ for algo in ('PBKDF2_SHA256',):
+ for i in range(0, 10):
+ _test_algo_for_pbkdf2(topology_st.standalone, algo)
+
+ log.info('Test PASSED')
+
if __name__ == '__main__':
# Run isolated
diff --git a/dirsrvtests/tests/suites/password/pwd_log_test.py b/dirsrvtests/tests/suites/password/pwd_log_test.py
new file mode 100644
index 000000000..a1132280b
--- /dev/null
+++ b/dirsrvtests/tests/suites/password/pwd_log_test.py
@@ -0,0 +1,120 @@
+# --- 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 logging
+
+import pytest
+from lib389.tasks import *
+from lib389.topologies import topology_st
+
+from lib389._constants import DN_CONFIG, DEFAULT_SUFFIX
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
[email protected]
+def test_hide_unhashed_pwd(topology_st):
+ """Change userPassword, enable hiding of un-hashed
+ password and check the audit logs.
+
+ :id: c4a5d08d-f525-459b-82b9-3f68dae6fc71
+ :setup: Standalone instance
+ :steps:
+ 1. Add a test user entry
+ 2. Set a new password for user and nsslapd-auditlog-logging-enabled to 'on'
+ 3. Disable nsslapd-auditlog-logging-hide-unhashed-pw
+ 4. Check the audit logs
+ 5. Set a new password for user and nsslapd-auditlog-logging-hide-unhashed-pw to 'on'
+ 6. Check the audit logs
+ :expectedresults:
+ 1. User addition should be successful
+ 2. New password should be set and audit logs should be enabled
+ 3. Operation should be successful
+ 4. Audit logs should show password without hash
+ 5. Operation should be successful
+ 6. Audit logs should hide password which is un-hashed
+ """
+
+ USER_DN = 'uid=test_entry,' + DEFAULT_SUFFIX
+
+ #
+ # Add the test entry
+ #
+ topology_st.standalone.add_s(Entry((USER_DN, {
+ 'objectclass': 'top extensibleObject'.split(),
+ 'uid': 'test_entry',
+ 'userpassword': 'password'
+ })))
+
+ #
+ # Enable the audit log
+ #
+ topology_st.standalone.modify_s(DN_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-auditlog-logging-enabled',
+ b'on')])
+ '''
+ try:
+ ent = topology_st.standalone.getEntry(DN_CONFIG, attrlist=[
+ 'nsslapd-instancedir',
+ 'nsslapd-errorlog',
+ 'nsslapd-accesslog',
+ 'nsslapd-certdir',
+ 'nsslapd-schemadir'])
+ '''
+ #
+ # Allow the unhashed password to be written to audit log
+ #
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-auditlog-logging-hide-unhashed-pw', b'off')])
+
+ #
+ # Set new password, and check the audit log
+ #
+ topology_st.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE,
+ 'userpassword',
+ b'mypassword')])
+
+ # Check audit log
+ time.sleep(1)
+ if not topology_st.standalone.searchAuditLog('unhashed#user#password: mypassword'):
+ log.fatal('failed to find unhashed password in auditlog')
+ assert False
+
+ #
+ # Hide unhashed password in audit log
+ #
+ topology_st.standalone.modify_s(DN_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-auditlog-logging-hide-unhashed-pw',
+ b'on')])
+ log.info('Test complete')
+
+ #
+ # Modify password, and check the audit log
+ #
+ topology_st.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE,
+ 'userpassword',
+ b'hidepassword')])
+
+ # Check audit log
+ time.sleep(1)
+ if topology_st.standalone.searchAuditLog('unhashed#user#password: hidepassword'):
+ log.fatal('Found unhashed password in auditlog')
+ assert False
+
+ log.info('Test complete')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
+
diff --git a/dirsrvtests/tests/tickets/ticket47384_test.py b/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py
similarity index 55%
rename from dirsrvtests/tests/tickets/ticket47384_test.py
rename to dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py
index da01b3d4e..1315fc6bc 100644
--- a/dirsrvtests/tests/tickets/ticket47384_test.py
+++ b/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py
@@ -17,12 +17,29 @@ logging.getLogger(__name__).setLevel(logging.DEBUG)
log = logging.getLogger(__name__)
-def test_ticket47384(topology_st):
- '''
- Test pluginpath validation: relative and absolute paths
-
[email protected]
+def test_pluginpath_validation(topology_st):
+ '''Test pluginpath validation: relative and absolute paths
With the inclusion of ticket 47601 - we do allow plugin paths
outside the default location
+
+ :id: 99f1fb2f-051d-4fd9-93d0-592dcd9b4c22
+ :setup: Standalone instance
+ :steps:
+ 1. Copy the library to a temporary directory
+ 2. Add valid plugin paths
+ * using the absolute path to the current library
+ * using new remote location
+ 3. Set plugin path back to the default
+ 4. Check invalid path (no library present)
+ 5. Check invalid relative path (no library present)
+
+ :expectedresults:
+ 1. This should pass
+ 2. This should pass
+ 3. This should pass
+ 4. This should fail
+ 5. This should fail
'''
if os.geteuid() != 0:
@@ -53,63 +70,34 @@ def test_ticket47384(topology_st):
# Test adding valid plugin paths
#
# Try using the absolute path to the current library
- try:
- topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
- 'nsslapd-pluginPath', '%s/libwhoami-plugin' % plugin_dir)])
- except ldap.LDAPError as e:
- log.error('Failed to set valid plugin path (%s): error (%s)' %
- ('%s/libwhoami-plugin' % plugin_dir, e.message['desc']))
- assert False
+ topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
+ 'nsslapd-pluginPath', ensure_bytes('%s/libwhoami-plugin' % plugin_dir))])
# Try using new remote location
- try:
- topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
- 'nsslapd-pluginPath', '%s/libwhoami-plugin' % tmp_dir)])
- except ldap.LDAPError as e:
- log.error('Failed to set valid plugin path (%s): error (%s)' %
- ('%s/libwhoami-plugin' % tmp_dir, e.message['desc']))
- assert False
+ topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
+ 'nsslapd-pluginPath', ensure_bytes('%s/libwhoami-plugin' % tmp_dir))])
# Set plugin path back to the default
- try:
- topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
- 'nsslapd-pluginPath', 'libwhoami-plugin')])
- except ldap.LDAPError as e:
- log.error('Failed to set valid relative plugin path (%s): error (%s)' %
- ('libwhoami-plugin' % tmp_dir, e.message['desc']))
- assert False
+ topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
+ 'nsslapd-pluginPath', b'libwhoami-plugin')])
#
# Test invalid path (no library present)
#
- try:
+ with pytest.raises(ldap.UNWILLING_TO_PERFORM):
topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
- 'nsslapd-pluginPath', '/bin/libwhoami-plugin')])
+ 'nsslapd-pluginPath', b'/bin/libwhoami-plugin')])
# No exception?! This is an error
log.error('Invalid plugin path was incorrectly accepted by the server!')
- assert False
- except ldap.UNWILLING_TO_PERFORM:
- # Correct, operation should be rejected
- pass
- except ldap.LDAPError as e:
- log.error('Failed to set invalid plugin path (%s): error (%s)' %
- ('/bin/libwhoami-plugin', e.message['desc']))
#
# Test invalid relative path (no library present)
#
- try:
+ with pytest.raises(ldap.UNWILLING_TO_PERFORM):
topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
- 'nsslapd-pluginPath', '../libwhoami-plugin')])
+ 'nsslapd-pluginPath', b'../libwhoami-plugin')])
# No exception?! This is an error
log.error('Invalid plugin path was incorrectly accepted by the server!')
- assert False
- except ldap.UNWILLING_TO_PERFORM:
- # Correct, operation should be rejected
- pass
- except ldap.LDAPError as e:
- log.error('Failed to set invalid plugin path (%s): error (%s)' %
- ('../libwhoami-plugin', e.message['desc']))
log.info('Test complete')
@@ -119,3 +107,4 @@ if __name__ == '__main__':
# -s for DEBUG mode
CURRENT_FILE = os.path.realpath(__file__)
pytest.main("-s %s" % CURRENT_FILE)
+
diff --git a/dirsrvtests/tests/tickets/ticket365_test.py b/dirsrvtests/tests/tickets/ticket365_test.py
deleted file mode 100644
index 505a59758..000000000
--- a/dirsrvtests/tests/tickets/ticket365_test.py
+++ /dev/null
@@ -1,138 +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 ---
-#
-
-import logging
-
-import pytest
-from lib389.tasks import *
-from lib389.topologies import topology_st
-
-from lib389._constants import DN_CONFIG, DEFAULT_SUFFIX
-
-logging.getLogger(__name__).setLevel(logging.DEBUG)
-log = logging.getLogger(__name__)
-
-
-def test_ticket365(topology_st):
- '''
- Write your testcase here...
-
- nsslapd-auditlog-logging-hide-unhashed-pw
-
- and test
-
- nsslapd-unhashed-pw-switch ticket 561
-
- on, off, nolog?
- '''
-
- USER_DN = 'uid=test_entry,' + DEFAULT_SUFFIX
-
- #
- # Add the test entry
- #
- try:
- topology_st.standalone.add_s(Entry((USER_DN, {
- 'objectclass': 'top extensibleObject'.split(),
- 'uid': 'test_entry',
- 'userpassword': 'password'
- })))
- except ldap.LDAPError as e:
- log.error('Failed to add test user: error ' + e.message['desc'])
- assert False
-
- #
- # Enable the audit log
- #
- try:
- topology_st.standalone.modify_s(DN_CONFIG,
- [(ldap.MOD_REPLACE,
- 'nsslapd-auditlog-logging-enabled',
- 'on')])
- except ldap.LDAPError as e:
- log.fatal('Failed to enable audit log, error: ' + e.message['desc'])
- assert False
- '''
- try:
- ent = topology_st.standalone.getEntry(DN_CONFIG, attrlist=[
- 'nsslapd-instancedir',
- 'nsslapd-errorlog',
- 'nsslapd-accesslog',
- 'nsslapd-certdir',
- 'nsslapd-schemadir'])
- '''
- #
- # Allow the unhashed password to be written to audit log
- #
- try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
- 'nsslapd-auditlog-logging-hide-unhashed-pw', 'off')])
- except ldap.LDAPError as e:
- log.fatal('Failed to enable writing unhashed password to audit log, ' +
- 'error: ' + e.message['desc'])
- assert False
-
- #
- # Set new password, and check the audit log
- #
- try:
- topology_st.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE,
- 'userpassword',
- 'mypassword')])
- except ldap.LDAPError as e:
- log.fatal('Failed to enable writing unhashed password to audit log, ' +
- 'error: ' + e.message['desc'])
- assert False
-
- # Check audit log
- time.sleep(1)
- if not topology_st.standalone.searchAuditLog('unhashed#user#password: mypassword'):
- log.fatal('failed to find unhashed password in auditlog')
- assert False
-
- #
- # Hide unhashed password in audit log
- #
- try:
- topology_st.standalone.modify_s(DN_CONFIG,
- [(ldap.MOD_REPLACE,
- 'nsslapd-auditlog-logging-hide-unhashed-pw',
- 'on')])
- except ldap.LDAPError as e:
- log.fatal('Failed to deny writing unhashed password to audit log, ' +
- 'error: ' + e.message['desc'])
- assert False
- log.info('Test complete')
-
- #
- # Modify password, and check the audit log
- #
- try:
- topology_st.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE,
- 'userpassword',
- 'hidepassword')])
- except ldap.LDAPError as e:
- log.fatal('Failed to enable writing unhashed password to audit log, ' +
- 'error: ' + e.message['desc'])
- assert False
-
- # Check audit log
- time.sleep(1)
- if topology_st.standalone.searchAuditLog('unhashed#user#password: hidepassword'):
- log.fatal('Found unhashed password in auditlog')
- assert False
-
- log.info('Test complete')
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket397_test.py b/dirsrvtests/tests/tickets/ticket397_test.py
deleted file mode 100644
index bd6cb8c27..000000000
--- a/dirsrvtests/tests/tickets/ticket397_test.py
+++ /dev/null
@@ -1,103 +0,0 @@
-import pytest
-from lib389.tasks import *
-from lib389.utils import *
-from lib389.topologies import topology_st
-
-from lib389._constants import DEFAULT_SUFFIX, HOST_STANDALONE, PORT_STANDALONE
-
-DEBUGGING = os.getenv('DEBUGGING', False)
-USER_DN = 'uid=user,ou=People,%s' % DEFAULT_SUFFIX
-
-if DEBUGGING:
- logging.getLogger(__name__).setLevel(logging.DEBUG)
-else:
- logging.getLogger(__name__).setLevel(logging.INFO)
-
-# Skip on older versions
-pytestmark = pytest.mark.skipif(ds_is_older('1.3.6'), reason="Not implemented")
-
-log = logging.getLogger(__name__)
-
-
-def _test_bind(inst, password):
- result = True
- userconn = ldap.initialize("ldap://%s:%s" % (HOST_STANDALONE, PORT_STANDALONE))
- try:
- userconn.simple_bind_s(USER_DN, password)
- userconn.unbind_s()
- except ldap.INVALID_CREDENTIALS:
- result = False
- return result
-
-
-def _test_algo(inst, algo_name):
- inst.config.set('passwordStorageScheme', algo_name)
-
- if DEBUGGING:
- print('Testing %s' % algo_name)
-
- # Create the user with a password
- inst.add_s(Entry((
- USER_DN, {
- 'objectClass': 'top account simplesecurityobject'.split(),
- 'uid': 'user',
- 'userpassword': ['Secret123', ]
- })))
-
- # Make sure when we read the userPassword field, it is the correct ALGO
- pw_field = inst.search_s(USER_DN, ldap.SCOPE_BASE, '(objectClass=*)', ['userPassword'])[0]
-
- if DEBUGGING:
- print(pw_field.getValue('userPassword'))
-
- if algo_name != 'CLEAR':
- lalgo_name = algo_name.lower()
- lpw_algo_name = pw_field.getValue('userPassword').lower()
- assert (lpw_algo_name.startswith("{%s}" % lalgo_name))
- # Now make sure a bind works
- assert (_test_bind(inst, 'Secret123'))
- # Bind with a wrong shorter password, should fail
- assert (not _test_bind(inst, 'Wrong'))
- # Bind with a wrong longer password, should fail
- assert (not _test_bind(inst, 'This is even more wrong'))
- # Bind with a password that has the algo in the name
- assert (not _test_bind(inst, '{%s}SomeValues....' % algo_name))
- # Bind with a wrong exact length password.
- assert (not _test_bind(inst, 'Alsowrong'))
- # Bind with a subset password, should fail
- assert (not _test_bind(inst, 'Secret'))
- if algo_name != 'CRYPT':
- # Bind with a subset password that is 1 char shorter, to detect off by 1 in clear
- assert (not _test_bind(inst, 'Secret12'))
- # Bind with a superset password, should fail
- assert (not _test_bind(inst, 'Secret123456'))
- # Delete the user
- inst.delete_s(USER_DN)
- # done!
-
-
-def test_397(topology_st):
- """
- Assert that all of our password algorithms correctly PASS and FAIL varying
- password conditions.
-
- """
- if DEBUGGING:
- # Add debugging steps(if any)...
- log.info("ATTACH NOW")
- time.sleep(30)
-
- # Merge this to the password suite in the future
-
- for algo in ('PBKDF2_SHA256',):
- for i in range(0, 10):
- _test_algo(topology_st.standalone, algo)
-
- log.info('Test PASSED')
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket47313_test.py b/dirsrvtests/tests/tickets/ticket47313_test.py
deleted file mode 100644
index 8640f4010..000000000
--- a/dirsrvtests/tests/tickets/ticket47313_test.py
+++ /dev/null
@@ -1,106 +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 ---
-#
-import logging
-
-import ldap
-import pytest
-from lib389 import Entry
-from lib389._constants import *
-from lib389.topologies import topology_st
-
-log = logging.getLogger(__name__)
-
-ENTRY_NAME = 'test_entry'
-
-
-def test_ticket47313_run(topology_st):
- """
- It adds 2 test entries
- Search with filters including subtype and !
- It deletes the added entries
- """
-
- # bind as directory manager
- topology_st.standalone.log.info("Bind as %s" % DN_DM)
- topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-
- # enable filter error logging
- # mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '32')]
- # topology_st.standalone.modify_s(DN_CONFIG, mod)
-
- topology_st.standalone.log.info("\n\n######################### ADD ######################\n")
-
- # Prepare the entry with cn;fr & cn;en
- entry_name_fr = '%s fr' % (ENTRY_NAME)
- entry_name_en = '%s en' % (ENTRY_NAME)
- entry_name_both = '%s both' % (ENTRY_NAME)
- entry_dn_both = 'cn=%s, %s' % (entry_name_both, SUFFIX)
- entry_both = Entry(entry_dn_both)
- entry_both.setValues('objectclass', 'top', 'person')
- entry_both.setValues('sn', entry_name_both)
- entry_both.setValues('cn', entry_name_both)
- entry_both.setValues('cn;fr', entry_name_fr)
- entry_both.setValues('cn;en', entry_name_en)
-
- # Prepare the entry with one member
- entry_name_en_only = '%s en only' % (ENTRY_NAME)
- entry_dn_en_only = 'cn=%s, %s' % (entry_name_en_only, SUFFIX)
- entry_en_only = Entry(entry_dn_en_only)
- entry_en_only.setValues('objectclass', 'top', 'person')
- entry_en_only.setValues('sn', entry_name_en_only)
- entry_en_only.setValues('cn', entry_name_en_only)
- entry_en_only.setValues('cn;en', entry_name_en)
-
- topology_st.standalone.log.info("Try to add Add %s: %r" % (entry_dn_both, entry_both))
- topology_st.standalone.add_s(entry_both)
-
- topology_st.standalone.log.info("Try to add Add %s: %r" % (entry_dn_en_only, entry_en_only))
- topology_st.standalone.add_s(entry_en_only)
-
- topology_st.standalone.log.info("\n\n######################### SEARCH ######################\n")
-
- # filter: (&(cn=test_entry en only)(!(cn=test_entry fr)))
- myfilter = '(&(sn=%s)(!(cn=%s)))' % (entry_name_en_only, entry_name_fr)
- topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
- ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
- assert len(ents) == 1
- assert ents[0].sn == entry_name_en_only
- topology_st.standalone.log.info("Found %s" % ents[0].dn)
-
- # filter: (&(cn=test_entry en only)(!(cn;fr=test_entry fr)))
- myfilter = '(&(sn=%s)(!(cn;fr=%s)))' % (entry_name_en_only, entry_name_fr)
- topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
- ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
- assert len(ents) == 1
- assert ents[0].sn == entry_name_en_only
- topology_st.standalone.log.info("Found %s" % ents[0].dn)
-
- # filter: (&(cn=test_entry en only)(!(cn;en=test_entry en)))
- myfilter = '(&(sn=%s)(!(cn;en=%s)))' % (entry_name_en_only, entry_name_en)
- topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
- ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
- assert len(ents) == 0
- topology_st.standalone.log.info("Found none")
-
- topology_st.standalone.log.info("\n\n######################### DELETE ######################\n")
-
- topology_st.standalone.log.info("Try to delete %s " % entry_dn_both)
- topology_st.standalone.delete_s(entry_dn_both)
-
- topology_st.standalone.log.info("Try to delete %s " % entry_dn_en_only)
- topology_st.standalone.delete_s(entry_dn_en_only)
-
- log.info('Testcase PASSED')
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket47553_test.py b/dirsrvtests/tests/tickets/ticket47553_test.py
deleted file mode 100644
index 08454d401..000000000
--- a/dirsrvtests/tests/tickets/ticket47553_test.py
+++ /dev/null
@@ -1,119 +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 ---
-#
-import pytest
-from lib389.tasks import *
-from lib389.utils import *
-from lib389.topologies import topology_st
-
-logging.getLogger(__name__).setLevel(logging.DEBUG)
-log = logging.getLogger(__name__)
-
-CONTAINER_1_OU = 'test_ou_1'
-CONTAINER_2_OU = 'test_ou_2'
-CONTAINER_1 = 'ou=%s,dc=example,dc=com' % CONTAINER_1_OU
-CONTAINER_2 = 'ou=%s,dc=example,dc=com' % CONTAINER_2_OU
-USER_CN = 'test_user'
-USER_PWD = 'Secret123'
-USER = 'cn=%s,%s' % (USER_CN, CONTAINER_1)
-
-
[email protected](scope="module")
-def env_setup(topology_st):
- """Adds two containers, one user and two ACI rules"""
-
- try:
- log.info("Add a container: %s" % CONTAINER_1)
- topology_st.standalone.add_s(Entry((CONTAINER_1,
- {'objectclass': 'top',
- 'objectclass': 'organizationalunit',
- 'ou': CONTAINER_1_OU,
- })))
-
- log.info("Add a container: %s" % CONTAINER_2)
- topology_st.standalone.add_s(Entry((CONTAINER_2,
- {'objectclass': 'top',
- 'objectclass': 'organizationalunit',
- 'ou': CONTAINER_2_OU,
- })))
-
- log.info("Add a user: %s" % USER)
- topology_st.standalone.add_s(Entry((USER,
- {'objectclass': 'top person'.split(),
- 'cn': USER_CN,
- 'sn': USER_CN,
- 'userpassword': USER_PWD
- })))
- except ldap.LDAPError as e:
- log.error('Failed to add object to database: %s' % e.message['desc'])
- assert False
-
- ACI_TARGET = '(targetattr="*")'
- ACI_ALLOW = '(version 3.0; acl "All rights for %s"; allow (all) ' % USER
- ACI_SUBJECT = 'userdn="ldap:///%s";)' % USER
- ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
- mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
-
- try:
- log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
- CONTAINER_1))
- topology_st.standalone.modify_s(CONTAINER_1, mod)
-
- log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
- CONTAINER_2))
- topology_st.standalone.modify_s(CONTAINER_2, mod)
- except ldap.LDAPError as e:
- log.fatal('Failed to add ACI: error (%s)' % (e.message['desc']))
- assert False
-
-
-def test_ticket47553(topology_st, env_setup):
- """Tests, that MODRDN operation is allowed,
- if user has ACI right '(all)' under superior entries,
- but doesn't have '(modrdn)'
- """
-
- log.info("Bind as %s" % USER)
- try:
- topology_st.standalone.simple_bind_s(USER, USER_PWD)
- except ldap.LDAPError as e:
- log.error('Bind failed for %s, error %s' % (USER, e.message['desc']))
- assert False
-
- log.info("User MODRDN operation from %s to %s" % (CONTAINER_1,
- CONTAINER_2))
- try:
- topology_st.standalone.rename_s(USER, "cn=%s" % USER_CN,
- newsuperior=CONTAINER_2, delold=1)
- except ldap.LDAPError as e:
- log.error('MODRDN failed for %s, error %s' % (USER, e.message['desc']))
- assert False
-
- try:
- log.info("Check there is no user in %s" % CONTAINER_1)
- entries = topology_st.standalone.search_s(CONTAINER_1,
- ldap.SCOPE_ONELEVEL,
- 'cn=%s' % USER_CN)
- assert not entries
-
- log.info("Check there is our user in %s" % CONTAINER_2)
- entries = topology_st.standalone.search_s(CONTAINER_2,
- ldap.SCOPE_ONELEVEL,
- 'cn=%s' % USER_CN)
- assert entries
- except ldap.LDAPError as e:
- log.fatal('Search failed, error: ' + e.message['desc'])
- assert False
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- # -v for additional verbose
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s -v %s" % CURRENT_FILE)
| 0 |
e373f3928991af051a459336b1bba05f14083101
|
389ds/389-ds-base
|
Ticket 50208 - make instances mark off based on dse.ldif not sysconfig
Bug Description: As sysconfig isn't cross platform compatible, and
there are some potential plans to remove it from our systemd files,
we need to make sure that lib389 can handle this file not being present
in new installs.
Fix Description: Thankfully, we have a file we can always guarantee
exists: dse.ldif. This makes /etc/dirsrv/slapd-instance the only
fixed location in the server now, all other locations can be "moved".
This patch:
* Fixes a large number of removal regressions
* Add comments and warnings throughout remove and setup to help
prevent future regresions
* Create no longer creates /etc/sysconfig/dirsrv-instance
* Create makes dse.ldif *first* as it's the marker location
* Remove works when there is no marker file (but will remove if it
exists)
* Listing now ignores /etc/sysconfig, and reads dse.ldif instead
with a follow up https://pagure.io/389-ds-base/issue/50207 to
parse data from this file for offline
https://pagure.io/389-ds-base/issue/50208
Author: William Brown <[email protected]>
Review by: spichugi, abbra (Thanks)
|
commit e373f3928991af051a459336b1bba05f14083101
Author: William Brown <[email protected]>
Date: Mon Feb 11 12:02:25 2019 +1000
Ticket 50208 - make instances mark off based on dse.ldif not sysconfig
Bug Description: As sysconfig isn't cross platform compatible, and
there are some potential plans to remove it from our systemd files,
we need to make sure that lib389 can handle this file not being present
in new installs.
Fix Description: Thankfully, we have a file we can always guarantee
exists: dse.ldif. This makes /etc/dirsrv/slapd-instance the only
fixed location in the server now, all other locations can be "moved".
This patch:
* Fixes a large number of removal regressions
* Add comments and warnings throughout remove and setup to help
prevent future regresions
* Create no longer creates /etc/sysconfig/dirsrv-instance
* Create makes dse.ldif *first* as it's the marker location
* Remove works when there is no marker file (but will remove if it
exists)
* Listing now ignores /etc/sysconfig, and reads dse.ldif instead
with a follow up https://pagure.io/389-ds-base/issue/50207 to
parse data from this file for offline
https://pagure.io/389-ds-base/issue/50208
Author: William Brown <[email protected]>
Review by: spichugi, abbra (Thanks)
diff --git a/Makefile.am b/Makefile.am
index 617ab45a5..ec65c1d76 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -647,7 +647,6 @@ dist_noinst_DATA = \
$(srcdir)/LICENSE.* \
$(srcdir)/VERSION.sh \
$(srcdir)/wrappers/*.in \
- $(srcdir)/wrappers/systemd.template.sysconfig \
$(srcdir)/dirsrvtests \
$(srcdir)/src/lib389/setup.py \
$(srcdir)/src/lib389
@@ -900,14 +899,9 @@ init_SCRIPTS = wrappers/$(PACKAGE_NAME) \
endif
endif
-if SYSTEMD
-initconfig_DATA = ldap/admin/src/$(PACKAGE_NAME) \
- wrappers/$(PACKAGE_NAME).systemd
-else
if INITDDIR
initconfig_DATA = ldap/admin/src/$(PACKAGE_NAME)
endif
-endif
inf_DATA = ldap/admin/src/slapd.inf \
ldap/admin/src/scripts/dscreate.map \
@@ -2342,10 +2336,6 @@ endif
fi; \
$(fixupcmd) $$service_template > $@
-%/$(PACKAGE_NAME).systemd: %/systemd.template.sysconfig
- if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
- $(fixupcmd) $^ > $@
-
%/$(systemdgroupname): %/systemd.group.in
if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
$(fixupcmd) $^ > $@
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index 7e76be6cb..ff0160eb2 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -599,8 +599,6 @@ exit 0
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/slapd-collations.conf
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/certmap.conf
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/template-initconfig
-%config(noreplace)%{_sysconfdir}/sysconfig/%{pkgname}
-%config(noreplace)%{_sysconfdir}/sysconfig/%{pkgname}.systemd
%{_datadir}/%{pkgname}
%exclude %{_datadir}/%{pkgname}/script-templates
%exclude %{_datadir}/%{pkgname}/updates
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 46e8b9d39..5e91dbcc3 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -601,10 +601,7 @@ class DirSrv(SimpleLDAPObject, object):
def list(self, all=False, serverid=None):
"""
Returns a list dictionary. For a created instance that is on the
- local file system (e.g. <prefix>/etc/dirsrv/slapd-*), it exists
- a file describing its properties
- (environment): <prefix>/etc/sysconfig/dirsrv-<serverid> or
- $HOME/.dirsrv/dirsv-<serverid>
+ local file system (e.g. <prefix>/etc/dirsrv/slapd-*/dse.ldif).
A dictionary is created with the following properties:
CONF_SERVER_DIR
CONF_SERVERBIN_DIR
@@ -628,16 +625,8 @@ class DirSrv(SimpleLDAPObject, object):
@raise IOError - if the file containing the properties is not
foundable or readable
"""
- def test_and_set(prop, propname, variable, value):
- '''
- If variable is 'propname' it adds to
- 'prop' dictionary the propname:value
- '''
- if variable == propname:
- prop[propname] = value
- return 1
- return 0
+ ### This inner function WILL BE REMOVED soon.
def _parse_configfile(filename=None, serverid=None):
'''
This method read 'filename' and build a dictionary with
@@ -653,46 +642,24 @@ class DirSrv(SimpleLDAPObject, object):
prop = {}
prop[CONF_SERVER_ID] = serverid
prop[SER_SERVERID_PROP] = serverid
- myfile = open(filename, 'r')
- for line in myfile:
- # retrieve the value in line::
- # <PROPNAME>=<string> [';' export <PROPNAME>]
-
- # skip comment lines
- if line.startswith('#'):
- continue
-
- # skip lines without assignment
- if '=' not in line:
- continue
- value = line.split(';', 1)[0]
-
- # skip lines without assignment
- if '=' not in value:
- continue
- variable = value.split('=', 1)[0]
- value = value.split('=', 1)[1]
- value = value.strip(' \t\n')
- for property in (CONF_SERVER_DIR,
- CONF_SERVERBIN_DIR,
- CONF_CONFIG_DIR,
- CONF_INST_DIR,
- CONF_RUN_DIR,
- CONF_DS_ROOT,
- CONF_PRODUCT_NAME):
- if test_and_set(prop, property, variable, value):
- break
-
- # Now, we have passed the sysconfig environment file.
- # read in and parse the dse.ldif to determine our SER_* values.
- # probably should use path join?
- dsefile = '%s/dse.ldif' % prop[CONF_CONFIG_DIR]
- if os.path.exists(dsefile):
- ldifconn = LDIFConn(dsefile)
- configentry = ldifconn.get(DN_CONFIG)
- for key in args_dse_keys:
- prop[key] = configentry.getValue(args_dse_keys[key])
+ inst_paths = Paths(serverid)
+
+ # WARNING: This is not correct, but is a stop gap until: https://pagure.io/389-ds-base/issue/50207
+ # Once that's done, this will "just work". Saying this, the whole prop dictionary
+ # concept is fundamentally broken, and we should be using ds_paths anyway.
+ prop[CONF_SERVER_DIR] = inst_paths.lib_dir
+ prop[CONF_SERVERBIN_DIR] = inst_paths.sbin_dir
+ prop[CONF_CONFIG_DIR] = inst_paths.config_dir
+ prop[CONF_INST_DIR] = inst_paths.inst_dir
+ prop[CONF_RUN_DIR] = inst_paths.run_dir
+ prop[CONF_DS_ROOT] = ''
+ prop[CONF_PRODUCT_NAME] = 'slapd'
+
+ ldifconn = LDIFConn(filename)
+ configentry = ldifconn.get(DN_CONFIG)
+ for key in args_dse_keys:
+ prop[key] = configentry.getValue(args_dse_keys[key])
# SER_HOST (host) nsslapd-localhost
# SER_PORT (port) nsslapd-port
# SER_SECURE_PORT (sslport) nsslapd-secureport
@@ -702,73 +669,19 @@ class DirSrv(SimpleLDAPObject, object):
# nsslapd-defaultnamingcontext
# SER_USER_ID (userid) nsslapd-localuser
# SER_SERVERID_PROP (serverid) Already have this
- # SER_GROUP_ID (groupid) ???
+ # SER_GROUP_ID (groupid)
# SER_DEPLOYED_DIR (prefix) Already provided to for
# discovery
- # SER_BACKUP_INST_DIR (backupdir) nsslapd-bakdir <<-- maybe?
+ # SER_BACKUP_INST_DIR (backupdir) nsslapd-bakdir
# We need to convert these two to int
# because other routines get confused if we don't
for intkey in [SER_PORT, SER_SECURE_PORT]:
- if prop[intkey] is not None:
+ if intkey in prop and prop[intkey] is not None:
prop[intkey] = int(prop[intkey])
return prop
+ ### end _parse_configfile
- def search_dir(instances, pattern, stop_value=None):
- '''
- It search all the files matching pattern.
- It there is not stop_value, it adds the properties found in
- each file to the 'instances'
- Else it searches the specific stop_value (instance's serverid)
- to add only its properties in the 'instances'
-
- @param instances - list of dictionary containing the instances
- properties
- @param pattern - pattern to find the files containing the
- properties
- @param stop_value - serverid value if we are looking only for
- one specific instance
-
- @return True or False - If stop_value is None it returns False.
- If stop_value is specified, it returns
- True if it added the property
- dictionary in instances. Or False if it
- did not find it.
- '''
- added = False
- for instance in glob.glob(pattern):
- serverid = os.path.basename(instance)[len(DEFAULT_ENV_HEAD):]
-
- # skip removed instance and admin server entry
- if '.removed' in serverid or 'dirsrv-admin' in instance:
- continue
-
- # it is found, store its properties in the list
- if stop_value:
- if stop_value == serverid:
- instances.append(_parse_configfile(instance, serverid))
- added = True
- break
- else:
- # this is not the searched value, continue
- continue
- else:
- # we are not looking for a specific value, just add it
- instances.append(_parse_configfile(instance, serverid))
-
- return added
-
- # Retrieves all instances under '/etc/sysconfig' and '/etc/dirsrv'
-
- # Instances/Environment are
- #
- # file: /etc/sysconfig/dirsrv-<serverid> (env)
- # inst: /etc/dirsrv/slapd-<serverid> (conf)
- #
- # or
- #
- # file: $HOME/.dirsrv/dirsrv-<serverid> (env)
- # inst: <prefix>/etc/dirsrv/slapd-<serverid> (conf)
- #
+ # Retrieves all instances under '<prefix>/etc/dirsrv'
# Don't need a default value now since it's set in init.
if serverid is None and hasattr(self, 'serverid'):
@@ -776,68 +689,35 @@ class DirSrv(SimpleLDAPObject, object):
elif serverid is not None:
serverid = serverid.replace('slapd-', '')
- # first identify the directories we will scan
- sysconfig_head = self.ds_paths.initconfig_dir
- privconfig_head = os.path.expanduser(os.path.join('~', ENV_LOCAL_DIR))
- if not os.path.isdir(sysconfig_head):
- privconfig_head = None
- self.log.debug("dir (sys) : %s", sysconfig_head)
- if privconfig_head:
- self.log.debug("dir (priv): %s", privconfig_head)
-
# list of the found instances
instances = []
# now prepare the list of instances properties
if not all:
+ dse_ldif = os.path.join(self.ds_paths.config_dir, 'dse.ldif')
# easy case we just look for the current instance
-
- # we have two location to retrieve the self.serverid
- # privconfig_head and sysconfig_head
-
- # first check the private repository
- if privconfig_head:
- pattern = "%s*" % os.path.join(privconfig_head,
- DEFAULT_ENV_HEAD)
- found = search_dir(instances, pattern, serverid)
- if len(instances) > 0:
- self.log.debug("List from %s", privconfig_head)
- for instance in instances:
- self.log.debug("list instance %r\n", instance)
- if found:
- assert len(instances) == 1
- else:
- assert len(instances) == 0
+ if os.path.exists(dse_ldif):
+ # It's real
+ # Now just populate that instance dict (soon to be changed ...)
+ instances.append(_parse_configfile(dse_ldif, serverid))
else:
- found = False
-
- # second, if not already found, search the system repository
- if not found:
- pattern = "%s*" % os.path.join(sysconfig_head,
- DEFAULT_ENV_HEAD)
- search_dir(instances, pattern, serverid)
- if len(instances) > 0:
- self.log.debug("List from %s", privconfig_head)
- for instance in instances:
- self.log.debug("list instance %r\n", instance)
+ # it's not
+ self.log.debug("list instance not found: %s\n", serverid)
else:
- # all instances must be retrieved
- if privconfig_head:
- pattern = "%s*" % os.path.join(privconfig_head,
- DEFAULT_ENV_HEAD)
- search_dir(instances, pattern)
- if len(instances) > 0:
- self.log.debug("List from %s", privconfig_head)
- for instance in instances:
- self.log.debug("list instance %r\n", instance)
-
- pattern = "%s*" % os.path.join(sysconfig_head, DEFAULT_ENV_HEAD)
- search_dir(instances, pattern)
- if len(instances) > 0:
- self.log.debug("List from %s", privconfig_head)
- for instance in instances:
- self.log.debug("list instance %r\n", instance)
+ # For each dir that starts with slapd-*
+ potential_inst = [
+ f for f
+ in os.listdir(self.ds_paths.sysconf_dir)
+ if os.path.isdir(f) and f.startswith('slapd-')]
+ # check it has dse.ldif
+ for pi in potential_inst:
+ pi_dse_ldif = os.path.join(potential_inst, 'dse.ldif')
+ # Takes /etc/dirsrv/slapd-instance -> slapd-instance -> instance
+ pi_name = pi.split('/')[-1].split('-')[-1]
+ # parse + append
+ if os.path.exists(pi_dse_ldif):
+ instances.append(_parse_configfile(pi_dse_ldif, pi_name))
return instances
diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
index 2d8ce99a8..9e7f3eea0 100644
--- a/src/lib389/lib389/instance/remove.py
+++ b/src/lib389/lib389/instance/remove.py
@@ -9,12 +9,30 @@
import os
import shutil
import subprocess
-from lib389.utils import selinux_label_port
+from lib389.nss_ssl import NssSsl
+from lib389.utils import selinux_label_port, assert_c
+
+
+######################## WARNING #############################
+# DO NOT CHANGE THIS FILE OR ITS CONTENTS WITHOUT READING
+# ALL OF THE COMMENTS FIRST. THERE ARE VERY DELICATE
+# AND DETAILED INTERACTIONS OF COMPONENTS IN THIS FILE.
+#
+# IF IN DOUBT CONTACT WILLIAM BROWN <[email protected]>
def remove_ds_instance(dirsrv, force=False):
"""
- This will delete the instance as it is define. This must be a local instance.
+ This will delete the instance as it is define. This must be a local instance. This is
+ designed to raise exceptions quickly and often if *any* error is hit. However, this can
+ be run repeatedly, and only when the instance is truely removed, will this program fail
+ to run further.
+
+ :param dirsrv: A directory server instance
+ :type dirsrv: DirSrv
+ :param force: A psycological aid, for people who think force means do something, harder. Does
+ literally nothing in this program because state machines are a thing.
+ :type force: bool
"""
_log = dirsrv.log.getChild('remove_ds')
_log.debug("Removing instance %s" % dirsrv.serverid)
@@ -38,30 +56,22 @@ def remove_ds_instance(dirsrv, force=False):
# remove_paths['run_dir'] = dirsrv.ds_paths.run_dir
remove_paths['tmpfiles_d'] = dirsrv.ds_paths.tmpfiles_d + "/dirsrv-" + dirsrv.serverid + ".conf"
remove_paths['inst_dir'] = dirsrv.ds_paths.inst_dir
+ remove_paths['etc_sysconfig'] = "%s/sysconfig/dirsrv-%s" % (dirsrv.ds_paths.sysconf_dir, dirsrv.serverid)
- marker_path = "%s/sysconfig/dirsrv-%s" % (dirsrv.ds_paths.sysconf_dir, dirsrv.serverid)
+ # These are handled in a special way.
etc_dirsrv_path = os.path.join(dirsrv.ds_paths.sysconf_dir, 'dirsrv/')
- ssca_path = os.path.join(etc_dirsrv_path, 'ssca/')
+ dse_ldif_path = os.path.join(etc_dirsrv_path, 'dse.ldif')
# Check the marker exists. If it *does not* warn about this, and say that to
# force removal you should touch this file.
- _log.debug("Checking for instance marker at %s" % marker_path)
- assert os.path.exists(marker_path)
-
- # Move the config_dir to config_dir.removed
- config_dir = dirsrv.ds_paths.config_dir
- config_dir_rm = "{}.removed".format(config_dir)
-
- if os.path.exists(config_dir_rm):
- _log.debug("Removing previously existed %s" % config_dir_rm)
- shutil.rmtree(config_dir_rm)
+ _log.debug("Checking for instance marker at %s" % dse_ldif_path)
+ if not os.path.exists(dse_ldif_path):
+ _log.info("Instance configuration not found, no action will be taken")
+ _log.info("If you want us to cleanup anyway, recreate '%s'" % dse_ldif_path)
+ return
- _log.debug("Copying %s to %s" % (config_dir, config_dir_rm))
- try:
- shutil.copytree(config_dir, config_dir_rm)
- except FileNotFoundError:
- pass
+ ### ANY NEW REMOVAL ACTION MUST BE BELOW THIS LINE!!!
# Remove these paths:
# for path in ('backup_dir', 'cert_dir', 'config_dir', 'db_dir',
@@ -73,36 +83,53 @@ def remove_ds_instance(dirsrv, force=False):
# Remove parent (/var/lib/dirsrv/slapd-INST)
shutil.rmtree(remove_paths['db_dir'].replace('db', ''), ignore_errors=True)
- # Finally remove the sysconfig marker.
- os.remove(marker_path)
- _log.debug("Removing %s" % marker_path)
+ # We can not assume we have systemd ...
+ if dirsrv.ds_paths.with_systemd:
+ # Remove the systemd symlink
+ _log.debug("Removing the systemd symlink")
+ subprocess.check_call(["systemctl", "disable", "dirsrv@{}".format(dirsrv.serverid)])
- # Remove the systemd symlink
- _log.debug("Removing the systemd symlink")
- subprocess.check_call(["systemctl", "disable", "dirsrv@{}".format(dirsrv.serverid)])
-
- # Remove selinux port label
- _log.debug("Removing the port label")
- try:
+ # Nor can we assume we have selinux. Try docker sometime ;)
+ if dirsrv.ds_paths.with_selinux:
+ # Remove selinux port label
+ _log.debug("Removing the port labels")
selinux_label_port(dirsrv.port, remove_label=True)
- except ValueError as e:
- if force:
- pass
- else:
- _log.error(str(e))
- raise e
- if dirsrv.sslport is not None:
- selinux_label_port(dirsrv.sslport, remove_label=True)
+ # This is a compatability with ancient installs, all modern install have tls port
+ if dirsrv.sslport is not None:
+ selinux_label_port(dirsrv.sslport, remove_label=True)
- # If this was the last instance, remove the ssca directory
+ # If this was the last instance, remove the ssca instance
insts = dirsrv.list(all=True)
if len(insts) == 0:
- # Remove /etc/dirsrv/ssca
- try:
- shutil.rmtree(ssca_path)
- except FileNotFoundError:
- pass
+ ssca = NssSsl(dbpath=dirsrv.get_ssca_dir())
+ ssca.remove_db()
+
+ ### ANY NEW REMOVAL ACTIONS MUST BE ABOVE THIS LINE!!!
+
+ # Finally means FINALLY, the last thing, the LAST LAST thing. By doing this absolutely
+ # last, it means that we can have any failure above, and continue to re-run until resolved
+ # because this instance marker (dse.ldif) continues to exist!
+ # Move the config_dir to config_dir.removed
+ config_dir = dirsrv.ds_paths.config_dir
+ config_dir_rm = "{}.removed".format(config_dir)
+
+ if os.path.exists(config_dir_rm):
+ _log.debug("Removing previously existed %s" % config_dir_rm)
+ shutil.rmtree(config_dir_rm)
+
+ assert_c(not os.path.exists(config_dir_rm))
+
+ # That's it, everything before this MUST have suceeded, so now we can move the
+ # config dir (containing dse.ldif, the marker) out of the way.
+ _log.debug("Moving %s to %s" % (config_dir, config_dir_rm))
+ try:
+ shutil.move(config_dir, config_dir_rm)
+ except FileNotFoundError:
+ pass
+
+ # DO NOT PUT ANY CODE BELOW THIS COMMENT BECAUSE THAT WOULD VIOLATE THE ASSERTIONS OF THE
+ # ABOVE CODE.
# Done!
_log.debug("Complete")
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
index 423a1dbe1..b2e19e359 100644
--- a/src/lib389/lib389/instance/setup.py
+++ b/src/lib389/lib389/instance/setup.py
@@ -654,37 +654,72 @@ class SetupDs(object):
"""
Actually install the Ds from the dicts provided.
- You should never call this directly, as it bypasses assert_cions.
+ You should never call this directly, as it bypasses assertions.
"""
- # register the instance to /etc/sysconfig
- # We do this first so that we can trick remove-ds.pl if needed.
- # There may be a way to create this from template like the dse.ldif ...
- initconfig = ""
- with open("%s/dirsrv/config/template-initconfig" % slapd['sysconf_dir']) as template_init:
- for line in template_init.readlines():
- initconfig += line.replace('{{', '{', 1).replace('}}', '}', 1).replace('-', '_')
+ ######################## WARNING #############################
+ # DO NOT CHANGE THIS FUNCTION OR ITS CONTENTS WITHOUT READING
+ # ALL OF THE COMMENTS FIRST. THERE ARE VERY DELICATE
+ # AND DETAILED INTERACTIONS OF COMPONENTS IN THIS FUNCTION.
+ #
+ # IF IN DOUBT CONTACT WILLIAM BROWN <[email protected]>
+
+
+ ### This first section is about creating the *minimal* required paths and config to get
+ # directory server to start: After this, we then perform all configuration as online
+ # changes from after this point.
+
+ # Create dse.ldif with a temporary root password.
+ # This is done first, because instances are found for removal and listing by detecting
+ # the present of their dse.ldif!!!!
+ # The template is in slapd['data_dir']/dirsrv/data/template-dse.ldif
+ # Variables are done with %KEY%.
+ self.log.debug("ACTION: Creating dse.ldif")
try:
- # /etc/sysconfig
- os.makedirs("%s" % slapd['initconfig_dir'], mode=0o770)
- except FileExistsError:
+ os.umask(0o007) # For parent dirs that get created -> sets 770 for perms
+ os.makedirs(slapd['config_dir'], mode=0o770)
+ except OSError:
pass
- sysconfig_filename = "%s/dirsrv-%s" % (slapd['initconfig_dir'], slapd['instance_name'])
- with open(sysconfig_filename, 'w') as f:
- f.write(initconfig.format(
- SERVER_DIR=slapd['lib_dir'],
- SERVERBIN_DIR=slapd['sbin_dir'],
- CONFIG_DIR=slapd['config_dir'],
- INST_DIR=slapd['inst_dir'],
- RUN_DIR=slapd['run_dir'],
- DS_ROOT='',
- PRODUCT_NAME='slapd',
+
+ # Get suffix for some plugin defaults (if possible)
+ # annoyingly for legacy compat backend takes TWO key types
+ # and we have to now deal with that ....
+ #
+ # Create ds_suffix here else it won't be in scope ....
+ ds_suffix = ''
+ if len(backends) > 0:
+ ds_suffix = normalizeDN(backends[0]['nsslapd-suffix'])
+
+ dse = ""
+ with open(os.path.join(slapd['data_dir'], 'dirsrv', 'data', 'template-dse.ldif')) as template_dse:
+ for line in template_dse.readlines():
+ dse += line.replace('%', '{', 1).replace('%', '}', 1)
+
+ with open(os.path.join(slapd['config_dir'], 'dse.ldif'), 'w') as file_dse:
+ file_dse.write(dse.format(
+ schema_dir=slapd['schema_dir'],
+ lock_dir=slapd['lock_dir'],
+ tmp_dir=slapd['tmp_dir'],
+ cert_dir=slapd['cert_dir'],
+ ldif_dir=slapd['ldif_dir'],
+ bak_dir=slapd['backup_dir'],
+ run_dir=slapd['run_dir'],
+ inst_dir=slapd['inst_dir'],
+ log_dir=slapd['log_dir'],
+ fqdn=general['full_machine_name'],
+ ds_port=slapd['port'],
+ ds_user=slapd['user'],
+ rootdn=slapd['root_dn'],
+ ds_passwd=self._secure_password, # We set our own password here, so we can connect and mod.
+ # This is because we never know the users input root password as they can validily give
+ # us a *hashed* input.
+ ds_suffix=ds_suffix,
+ config_dir=slapd['config_dir'],
+ db_dir=slapd['db_dir'],
))
- os.chmod(sysconfig_filename, 0o440)
- os.chown(sysconfig_filename, slapd['user_uid'], slapd['group_gid'])
# Create all the needed paths
# we should only need to make bak_dir, cert_dir, config_dir, db_dir, ldif_dir, lock_dir, log_dir, run_dir?
- for path in ('backup_dir', 'cert_dir', 'config_dir', 'db_dir', 'ldif_dir', 'lock_dir', 'log_dir', 'run_dir'):
+ for path in ('backup_dir', 'cert_dir', 'db_dir', 'ldif_dir', 'lock_dir', 'log_dir', 'run_dir'):
self.log.debug("ACTION: creating %s", slapd[path])
try:
os.umask(0o007) # For parent dirs that get created -> sets 770 for perms
@@ -745,51 +780,12 @@ class SetupDs(object):
# Bind sockets to our type?
- # Get suffix for some plugin defaults (if possible)
- # annoyingly for legacy compat backend takes TWO key types
- # and we have to now deal with that ....
- #
- # Create ds_suffix here else it won't be in scope ....
- ds_suffix = ''
- if len(backends) > 0:
- ds_suffix = normalizeDN(backends[0]['nsslapd-suffix'])
# Create certdb in sysconfidir
self.log.debug("ACTION: Creating certificate database is %s", slapd['cert_dir'])
- # Create dse.ldif with a temporary root password.
- # The template is in slapd['data_dir']/dirsrv/data/template-dse.ldif
- # Variables are done with %KEY%.
- # You could cheat and read it in, do a replace of % to { and } then use format?
- self.log.debug("ACTION: Creating dse.ldif")
- dse = ""
- with open(os.path.join(slapd['data_dir'], 'dirsrv', 'data', 'template-dse.ldif')) as template_dse:
- for line in template_dse.readlines():
- dse += line.replace('%', '{', 1).replace('%', '}', 1)
-
- with open(os.path.join(slapd['config_dir'], 'dse.ldif'), 'w') as file_dse:
- file_dse.write(dse.format(
- schema_dir=slapd['schema_dir'],
- lock_dir=slapd['lock_dir'],
- tmp_dir=slapd['tmp_dir'],
- cert_dir=slapd['cert_dir'],
- ldif_dir=slapd['ldif_dir'],
- bak_dir=slapd['backup_dir'],
- run_dir=slapd['run_dir'],
- inst_dir=slapd['inst_dir'],
- log_dir=slapd['log_dir'],
- fqdn=general['full_machine_name'],
- ds_port=slapd['port'],
- ds_user=slapd['user'],
- rootdn=slapd['root_dn'],
- # ds_passwd=slapd['root_password'],
- ds_passwd=self._secure_password, # We set our own password here, so we can connect and mod.
- ds_suffix=ds_suffix,
- config_dir=slapd['config_dir'],
- db_dir=slapd['db_dir'],
- ))
-
- # open the connection to the instance.
+ # BELOWE THIS LINE - all actions are now ONLINE changes to the directory server.
+ # if it all possible, ALWAYS ADD NEW INSTALLER CHANGES AS ONLINE ACTIONS.
# Should I move this import? I think this prevents some recursion
from lib389 import DirSrv
diff --git a/wrappers/systemd.template.service.in b/wrappers/systemd.template.service.in
index 3c1d36877..4d1c2c738 100644
--- a/wrappers/systemd.template.service.in
+++ b/wrappers/systemd.template.service.in
@@ -23,22 +23,48 @@ Type=notify
NotifyAccess=all
TimeoutStartSec=0
TimeoutStopSec=600
-EnvironmentFile=@initconfigdir@/@package_name@
-EnvironmentFile=@initconfigdir@/@package_name@-%i
+EnvironmentFile=-@initconfigdir@/@package_name@
+EnvironmentFile=-@initconfigdir@/@package_name@-%i
PIDFile=@localstatedir@/run/@package_name@/slapd-%i.pid
ExecStartPre=@libexecdir@/ds_systemd_ask_password_acl @instconfigdir@/slapd-%i/dse.ldif
ExecStart=@sbindir@/ns-slapd -D @instconfigdir@/slapd-%i -i @localstatedir@/run/@package_name@/slapd-%i.pid
+#### To change any of these values or directives, you should use a drop in file
+# such as: /etc/systemd/system/dirsrv@<instance>.d/custom.conf
+
+# These are from man systemd.exec and man systemd.resource-control
+
+# This controls the resources to the direct child of systemd, in
+# this case ns-slapd. Because we are type notify we recieve these
+# limits correctly.
+
+# This controls the number of file handles avaliable. File handles
+# correlate to sockets for the process, and our access to logs and
+# databases.
+LimitNOFILE=16384
+
+# You can limit the memory in the cgroup with these, and ns-slapd
+# will account for them in it's autotuning.
+# Memory account may be controlled by DefaultMemoryAccounting= in systemd-system.conf
+# MemoryAccounting=true
+# MemoryLimit=bytes
+
+# Limits on the size of coredump that may be produced by the process. It's not
+# specified how this interacts with coredumpd.
+# 0 means not to produce cores.
+# This value is 64G
+LimitCORE=68719476736
+
+# Limit number of processes (threads) we may spawn. We don't advise you change
+# this as DS will autodetect your threads / cpus and adjust as needed.
+# LimitNPROC=
+
# Hardening options:
# PrivateDevices=true
# ProtectSystem=true
# ProtectHome=true
# PrivateTmp=true
-# if you need to set other directives e.g. LimitNOFILE=8192
-# set them in this file
-.include @initconfigdir@/@[email protected]
-
[Install]
WantedBy=multi-user.target
diff --git a/wrappers/systemd.template.sysconfig b/wrappers/systemd.template.sysconfig
deleted file mode 100644
index 903876b17..000000000
--- a/wrappers/systemd.template.sysconfig
+++ /dev/null
@@ -1,29 +0,0 @@
-[Service]
-# These are from man systemd.exec and man systemd.resource-control
-
-# This controls the resources to the direct child of systemd, in
-# this case ns-slapd. Because we are type notify we recieve these
-# limits correctly.
-
-# This controls the number of file handles avaliable. File handles
-# correlate to sockets for the process, and our access to logs and
-# databases.
-LimitNOFILE=16384
-
-# You can limit the memory in the cgroup with these, and ns-slapd
-# will account for them in it's autotuning.
-# Memory account may be controlled by DefaultMemoryAccounting= in systemd-system.conf
-# MemoryAccounting=true
-# MemoryLimit=bytes
-
-# Limits on the size of coredump that may be produced by the process. It's not
-# specified how this interacts with coredumpd.
-# 0 means not to produce cores.
-# This value is 64G
-LimitCORE=68719476736
-
-# Limit number of processes (threads) we may spawn. We don't advise you change
-# this as DS will autodetect your threads / cpus and adjust as needed.
-# LimitNPROC=
-
-
diff --git a/wrappers/systemd.template.xsan.service.in b/wrappers/systemd.template.xsan.service.in
index 1a4d7dcd6..541392ff8 100644
--- a/wrappers/systemd.template.xsan.service.in
+++ b/wrappers/systemd.template.xsan.service.in
@@ -35,15 +35,42 @@ LimitCORE=infinity
ExecStartPre=@libexecdir@/ds_systemd_ask_password_acl @instconfigdir@/slapd-%i/dse.ldif
ExecStart=@sbindir@/ns-slapd -D @instconfigdir@/slapd-%i -i @localstatedir@/run/@package_name@/slapd-%i.pid
+#### To change any of these values or directives, you should use a drop in file
+# such as: /etc/systemd/system/dirsrv@<instance>.d/custom.conf
+
+# These are from man systemd.exec and man systemd.resource-control
+
+# This controls the resources to the direct child of systemd, in
+# this case ns-slapd. Because we are type notify we recieve these
+# limits correctly.
+
+# This controls the number of file handles avaliable. File handles
+# correlate to sockets for the process, and our access to logs and
+# databases.
+LimitNOFILE=16384
+
+# You can limit the memory in the cgroup with these, and ns-slapd
+# will account for them in it's autotuning.
+# Memory account may be controlled by DefaultMemoryAccounting= in systemd-system.conf
+# MemoryAccounting=true
+# MemoryLimit=bytes
+
+# Limits on the size of coredump that may be produced by the process. It's not
+# specified how this interacts with coredumpd.
+# 0 means not to produce cores.
+# This value is 64G
+LimitCORE=68719476736
+
+# Limit number of processes (threads) we may spawn. We don't advise you change
+# this as DS will autodetect your threads / cpus and adjust as needed.
+# LimitNPROC=
+
# Hardening options:
# PrivateDevices=true
# ProtectSystem=true
# ProtectHome=true
# PrivateTmp=true
-# if you need to set other directives e.g. LimitNOFILE=8192
-# set them in this file
-.include @initconfigdir@/@[email protected]
[Install]
WantedBy=multi-user.target
| 0 |
4fc53e1a63222d0ff67c30a59f2cff4b535f90a8
|
389ds/389-ds-base
|
Ticket #47748 - Simultaneous adding a user and binding as the user could fail in the password policy check
Bug description: In do_bind, bind_target_entry is retrieved from the
DB or the entry cache. There was a small window that the entry failed
to retrieve from there but the bind procedure in the backend (be_bind)
succeeds. In the case, NULL bind_target_entry is passed to the Pass-
word Policy check and it fails.
Fix description: If be_bind returns SUCCESS and bind_target_entry is
NULL, retrieve bind_target_entry agian, which is guaranteed since the
entry was retrieved in the backend and placed in the entry cache.
https://fedorahosted.org/389/ticket/47748
Reviewed by [email protected] (Thank you, Rich!!)
|
commit 4fc53e1a63222d0ff67c30a59f2cff4b535f90a8
Author: Noriko Hosoi <[email protected]>
Date: Fri Mar 21 12:18:39 2014 -0700
Ticket #47748 - Simultaneous adding a user and binding as the user could fail in the password policy check
Bug description: In do_bind, bind_target_entry is retrieved from the
DB or the entry cache. There was a small window that the entry failed
to retrieve from there but the bind procedure in the backend (be_bind)
succeeds. In the case, NULL bind_target_entry is passed to the Pass-
word Policy check and it fails.
Fix description: If be_bind returns SUCCESS and bind_target_entry is
NULL, retrieve bind_target_entry agian, which is guaranteed since the
entry was retrieved in the backend and placed in the entry cache.
https://fedorahosted.org/389/ticket/47748
Reviewed by [email protected] (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index cb563f0c6..2a9d8b7d7 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -429,6 +429,7 @@ do_bind( Slapi_PBlock *pb )
if (!strcasecmp (saslmech, LDAP_SASL_EXTERNAL)) {
/* call preop plugins */
if (plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) != 0){
+ send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "", 0, NULL);
goto free_and_return;
}
@@ -474,10 +475,10 @@ do_bind( Slapi_PBlock *pb )
goto free_and_return;
}
- if (!isroot ) {
+ 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 && slapi_check_account_lock(pb, bind_target_entry,
+ if ( bind_target_entry && slapi_check_account_lock(pb, bind_target_entry,
pw_response_requested, 1 /*check password policy*/, 1 /*send ldap result*/) == 1) {
/* call postop plugins */
plugin_call_plugins( pb, SLAPI_PLUGIN_POST_BIND_FN );
@@ -553,6 +554,8 @@ do_bind( Slapi_PBlock *pb )
/* call postop plugins */
plugin_call_plugins( pb, SLAPI_PLUGIN_POST_BIND_FN );
+ } else {
+ send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "", 0, NULL);
}
goto free_and_return;
/* Check if unauthenticated binds are allowed. */
@@ -651,7 +654,7 @@ do_bind( Slapi_PBlock *pb )
bind_credentials_set( pb->pb_conn, SLAPD_AUTH_SIMPLE, slapi_ch_strdup(slapi_sdn_get_ndn(sdn)),
NULL, NULL, NULL , NULL);
} else {
- /*
+ /*
* right dn, wrong passwd - reject with invalid credentials
*/
send_ldap_result( pb, LDAP_INVALID_CREDENTIALS, NULL, NULL, 0, NULL );
@@ -675,6 +678,8 @@ do_bind( Slapi_PBlock *pb )
/* call postop plugins */
plugin_call_plugins( pb, SLAPI_PLUGIN_POST_BIND_FN );
+ } else {
+ send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "", 0, NULL);
}
goto free_and_return;
}
@@ -733,9 +738,10 @@ do_bind( Slapi_PBlock *pb )
(rc == SLAPI_BIND_ANONYMOUS))) ) {
long t;
char* authtype = NULL;
-
- if(auto_bind)
+ /* rc is SLAPI_BIND_SUCCESS or SLAPI_BIND_ANONYMOUS */
+ if(auto_bind) {
rc = SLAPI_BIND_SUCCESS;
+ }
switch ( method ) {
case LDAP_AUTH_SIMPLE:
@@ -755,53 +761,68 @@ do_bind( Slapi_PBlock *pb )
/* authtype = SLAPD_AUTH_SASL && saslmech: */
PR_snprintf(authtypebuf, sizeof(authtypebuf), "%s%s", SLAPD_AUTH_SASL, saslmech);
authtype = authtypebuf;
- break;
- default: /* ??? */
+ break;
+ default:
break;
}
if ( rc == SLAPI_BIND_SUCCESS ) {
- if(!auto_bind)
- bind_credentials_set( pb->pb_conn,
- authtype, slapi_ch_strdup(
- slapi_sdn_get_ndn(sdn)),
- NULL, NULL, NULL, bind_target_entry );
- if ( auth_response_requested ) {
- slapi_add_auth_response_control( pb,
- slapi_sdn_get_ndn(sdn));
+ if (!auto_bind) {
+ /*
+ * There could be a race that bind_target_entry was not added
+ * when bind_target_entry was retrieved before be_bind, but it
+ * was in be_bind. Since be_bind returned SLAPI_BIND_SUCCESS,
+ * the entry is in the DS. So, we need to retrieve it once more.
+ */
+ if (!bind_target_entry) {
+ bind_target_entry = get_entry(pb, slapi_sdn_get_ndn(sdn));
+ if (bind_target_entry) {
+ rc = slapi_check_account_lock(pb, bind_target_entry,
+ pw_response_requested, 1, 1);
+ if (1 == rc) { /* account is locked */
+ goto account_locked;
+ }
+ } else {
+ send_ldap_result(pb, LDAP_NO_SUCH_OBJECT, NULL, "", 0, NULL);
+ goto free_and_return;
+ }
+ }
+ bind_credentials_set(pb->pb_conn, authtype,
+ slapi_ch_strdup(slapi_sdn_get_ndn(sdn)),
+ NULL, NULL, NULL, bind_target_entry);
+ if (!slapi_be_is_flag_set(be, SLAPI_BE_FLAG_REMOTE_DATA)) {
+ /* check if need new password before sending
+ the bind success result */
+ rc = need_new_pw(pb, &t, bind_target_entry, pw_response_requested);
+ switch (rc) {
+ case 1:
+ (void)slapi_add_pwd_control(pb, LDAP_CONTROL_PWEXPIRED, 0);
+ break;
+ case 2:
+ (void)slapi_add_pwd_control(pb, LDAP_CONTROL_PWEXPIRING, t);
+ break;
+ default:
+ break;
+ }
+ }
}
+ if (auth_response_requested) {
+ slapi_add_auth_response_control(pb, slapi_sdn_get_ndn(sdn));
+ }
+ if (-1 == rc) {
+ /* neeed_new_pw failed; need_new_pw already send_ldap_result in it. */
+ goto free_and_return;
+ }
} else { /* anonymous */
/* set bind creds here so anonymous limits are set */
- bind_credentials_set( pb->pb_conn, authtype, NULL,
- NULL, NULL, NULL, NULL );
+ bind_credentials_set(pb->pb_conn, authtype, NULL, NULL, NULL, NULL, NULL);
if ( auth_response_requested ) {
- slapi_add_auth_response_control( pb,
- "" );
+ slapi_add_auth_response_control(pb, "");
}
}
-
- if ( 0 == auto_bind && (rc != SLAPI_BIND_ANONYMOUS) &&
- ! slapi_be_is_flag_set(be, SLAPI_BE_FLAG_REMOTE_DATA)) {
- /* check if need new password before sending
- the bind success result */
- switch ( need_new_pw (pb, &t, bind_target_entry, pw_response_requested )) {
- case 1:
- (void)slapi_add_pwd_control ( pb,
- LDAP_CONTROL_PWEXPIRED, 0);
- break;
- case 2:
- (void)slapi_add_pwd_control ( pb,
- LDAP_CONTROL_PWEXPIRING, t);
- break;
- case -1:
- goto free_and_return;
- default:
- break;
- }
- } /* end if */
- }else{
-
+ } else {
+account_locked:
if(cred.bv_len == 0) {
/* its an UnAuthenticated Bind, DN specified but no pw */
slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsUnAuthBinds);
@@ -837,7 +858,7 @@ do_bind( Slapi_PBlock *pb )
"Function not implemented", 0, NULL );
}
- free_and_return:;
+free_and_return:;
if (be)
slapi_be_Unlock(be);
slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn);
diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c
index 8e8d850c7..5a0ecb24f 100644
--- a/ldap/servers/slapd/pw_mgmt.c
+++ b/ldap/servers/slapd/pw_mgmt.c
@@ -68,6 +68,9 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int pwresponse_req )
int pwdGraceUserTime = 0;
char graceUserTime[8];
+ if (NULL == e) {
+ return (-1);
+ }
slapi_mods_init (&smods, 0);
sdn = slapi_entry_get_sdn_const( e );
dn = slapi_entry_get_ndn( e );
| 0 |
de2ea202fc54b1e6d3c55d1334f5c211856f235e
|
389ds/389-ds-base
|
Fixed pep8 errors in __init__.py, backend.py and mappingtee.py
|
commit de2ea202fc54b1e6d3c55d1334f5c211856f235e
Author: Mark Reynolds <[email protected]>
Date: Fri Oct 30 11:23:16 2015 -0400
Fixed pep8 errors in __init__.py, backend.py and mappingtee.py
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 2119a9460..604758502 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -67,7 +67,7 @@ from lib389.utils import (
get_bin_dir)
# mixin
-#from lib389.tools import DirSrvTools
+# from lib389.tools import DirSrvTools
MAJOR, MINOR, _, _, _ = sys.version_info
@@ -111,26 +111,30 @@ class NotImplementedError(Error):
pass
-class DsError(Error):
+class DsError(Error):
"""Generic DS Error."""
pass
def wrapper(f, name):
- """Wrapper of all superclass methods using lib389.Entry.
+ """
+ Wrapper of all superclass methods using lib389.Entry.
@param f - DirSrv method inherited from SimpleLDAPObject
@param name - method to call
- This seems to need to be an unbound method, that's why it's outside of DirSrv. Perhaps there
- is some way to do this with the new classmethod or staticmethod of 2.4.
+ This seems to need to be an unbound method, that's why it's outside of
+ DirSrv. Perhaps there is some way to do this with the new classmethod
+ or staticmethod of 2.4.
We replace every call to a method in SimpleLDAPObject (the superclass
- of DirSrv) with a call to inner. The f argument to wrapper is the bound method
- of DirSrv (which is inherited from the superclass). Bound means that it will implicitly
- be called with the self argument, it is not in the args list. name is the name of
- the method to call. If name is a method that returns entry objects (e.g. result),
- we wrap the data returned by an Entry class. If name is a method that takes an entry
- argument, we extract the raw data from the entry object to pass in."""
+ of DirSrv) with a call to inner. The f argument to wrapper is the bound
+ method of DirSrv (which is inherited from the superclass). Bound means
+ that it will implicitly be called with the self argument, it is not in
+ the args list. name is the name of the method to call. If name is a
+ method that returns entry objects (e.g. result), we wrap the data returned
+ by an Entry class. If name is a method that takes an entry argument, we
+ extract the raw data from the entry object to pass in.
+ """
def inner(*args, **kargs):
if name == 'result':
objtype, data = f(*args, **kargs)
@@ -218,16 +222,17 @@ class DirSrv(SimpleLDAPObject):
'nsslapd-schemadir',
'nsslapd-bakdir',
'nsslapd-ldifdir'])
- self.errlog = ent.getValue('nsslapd-errorlog')
+ self.errlog = ent.getValue('nsslapd-errorlog')
self.accesslog = ent.getValue('nsslapd-accesslog')
- self.auditlog = ent.getValue('nsslapd-auditlog')
- self.confdir = ent.getValue('nsslapd-certdir')
+ self.auditlog = ent.getValue('nsslapd-auditlog')
+ self.confdir = ent.getValue('nsslapd-certdir')
self.schemadir = ent.getValue('nsslapd-schemadir')
- self.bakdir = ent.getValue('nsslapd-bakdir')
- self.ldifdir = ent.getValue('nsslapd-ldifdir')
+ self.bakdir = ent.getValue('nsslapd-bakdir')
+ self.ldifdir = ent.getValue('nsslapd-ldifdir')
if self.isLocal:
- if not self.confdir or not os.access(self.confdir + '/dse.ldif', os.R_OK):
+ if not self.confdir or \
+ not os.access(self.confdir + '/dse.ldif', os.R_OK):
self.confdir = ent.getValue('nsslapd-schemadir')
if self.confdir:
self.confdir = os.path.dirname(self.confdir)
@@ -269,9 +274,10 @@ class DirSrv(SimpleLDAPObject):
self.serverid = self.inst
ent = self.getEntry('cn=config,' + DN_LDBM,
- attrlist=['nsslapd-directory'])
+ attrlist=['nsslapd-directory'])
self.dbdir = os.path.dirname(ent.getValue('nsslapd-directory'))
- except (ldap.INSUFFICIENT_ACCESS, ldap.CONNECT_ERROR, NoSuchEntryError):
+ except (ldap.INSUFFICIENT_ACCESS, ldap.CONNECT_ERROR,
+ NoSuchEntryError):
log.exception("Skipping exception during initialization")
except ldap.OPERATIONS_ERROR as e:
log.exception("Skipping exception: Probably Active Directory")
@@ -281,8 +287,9 @@ class DirSrv(SimpleLDAPObject):
def __localinit__(self):
'''
- Establish a connection to the started instance. It binds with the binddn property,
- then it initializes various fields from DirSrv (via __initPart2)
+ Establish a connection to the started instance. It binds with the
+ binddn property, then it initializes various fields from DirSrv
+ (via __initPart2)
@param - self
@@ -328,36 +335,36 @@ class DirSrv(SimpleLDAPObject):
@raise ldap.CONFIDENTIALITY_REQUIRED - missing TLS:
"""
SimpleLDAPObject.__init__(self, self.toLDAPURL())
- #self.start_tls_s()
+ # self.start_tls_s()
self.simple_bind_s(self.binddn, self.bindpw)
def __add_brookers__(self):
from lib389.brooker import (
Config)
from lib389.mappingTree import MappingTree
- from lib389.backend import Backend
- from lib389.suffix import Suffix
- from lib389.replica import Replica
- from lib389.changelog import Changelog
- from lib389.agreement import Agreement
- from lib389.schema import Schema
- from lib389.plugins import Plugins
- from lib389.tasks import Tasks
- from lib389.index import Index
- from lib389.aci import Aci
-
- self.agreement = Agreement(self)
- self.replica = Replica(self)
- self.changelog = Changelog(self)
- self.backend = Backend(self)
- self.config = Config(self)
- self.index = Index(self)
+ from lib389.backend import Backend
+ from lib389.suffix import Suffix
+ from lib389.replica import Replica
+ from lib389.changelog import Changelog
+ from lib389.agreement import Agreement
+ from lib389.schema import Schema
+ from lib389.plugins import Plugins
+ from lib389.tasks import Tasks
+ from lib389.index import Index
+ from lib389.aci import Aci
+
+ self.agreement = Agreement(self)
+ self.replica = Replica(self)
+ self.changelog = Changelog(self)
+ self.backend = Backend(self)
+ self.config = Config(self)
+ self.index = Index(self)
self.mappingtree = MappingTree(self)
- self.suffix = Suffix(self)
- self.schema = Schema(self)
- self.plugins = Plugins(self)
- self.tasks = Tasks(self)
- self.aci = Aci(self)
+ self.suffix = Suffix(self)
+ self.schema = Schema(self)
+ self.plugins = Plugins(self)
+ self.tasks = Tasks(self)
+ self.aci = Aci(self)
def __init__(self, verbose=False, timeout=10):
"""
@@ -379,14 +386,15 @@ class DirSrv(SimpleLDAPObject):
- open
"""
- self.state = DIRSRV_STATE_INIT
+ self.state = DIRSRV_STATE_INIT
self.verbose = verbose
- self.log = log
+ self.log = log
self.timeout = timeout
# Reset the args (py.test reuses the args_instance for each test case)
args_instance[SER_DEPLOYED_DIR] = os.environ.get('PREFIX', '/')
- args_instance[SER_BACKUP_INST_DIR] = os.environ.get('BACKUPDIR', DEFAULT_BACKUPDIR)
+ args_instance[SER_BACKUP_INST_DIR] = os.environ.get('BACKUPDIR',
+ DEFAULT_BACKUPDIR)
args_instance[SER_ROOT_DN] = DN_DM
args_instance[SER_ROOT_PW] = PW_DM
args_instance[SER_HOST] = LOCALHOST
@@ -397,7 +405,8 @@ class DirSrv(SimpleLDAPObject):
args_instance[SER_USER_ID] = None
args_instance[SER_GROUP_ID] = None
- # We allocate a "default" prefix here which allows an un-allocate or un-instantiated DirSrv
+ # We allocate a "default" prefix here which allows an un-allocate or
+ # un-instantiated DirSrv
# instance to be able to do an an instance discovery. For example:
# ds = lib389.DirSrv()
# ds.list(all=True)
@@ -416,7 +425,8 @@ class DirSrv(SimpleLDAPObject):
The final state -> DIRSRV_STATE_ALLOCATED
@param args - dictionary that contains the DirSrv properties
properties are
- SER_SERVERID_PROP: used for offline op (create/delete/backup/start/stop..) -> slapd-<serverid>
+ SER_SERVERID_PROP: used for offline op
+ (create/delete/backup/start/stop..) -> slapd-<serverid>
SER_HOST: hostname [LOCALHOST]
SER_PORT: normal ldap port [DEFAULT_PORT]
SER_SECURE_PORT: secure ldap port
@@ -425,27 +435,31 @@ class DirSrv(SimpleLDAPObject):
SER_USER_ID: user id of the create instance [DEFAULT_USER]
SER_GROUP_ID: group id of the create instance [SER_USER_ID]
SER_DEPLOYED_DIR: directory where 389-ds is deployed
- SER_BACKUP_INST_DIR: directory where instances will be backup
+ SER_BACKUP_INST_DIR: directory where instances will be
+ backed up
@return None
- @raise ValueError - if missing mandatory properties or invalid state of DirSrv
+ @raise ValueError - if missing mandatory properties or invalid
+ state of DirSrv
'''
DirSrvTools.testLocalhost()
- if self.state != DIRSRV_STATE_INIT and self.state != DIRSRV_STATE_ALLOCATED:
- raise ValueError("invalid state for calling allocate: %s" % self.state)
+ if self.state != DIRSRV_STATE_INIT and \
+ self.state != DIRSRV_STATE_ALLOCATED:
+ raise ValueError("invalid state for calling allocate: %s" %
+ self.state)
if SER_SERVERID_PROP not in args:
self.log.info('SER_SERVERID_PROP not provided')
# Settings from args of server attributes
- self.host = args.get(SER_HOST, LOCALHOST)
- self.port = args.get(SER_PORT, DEFAULT_PORT)
+ self.host = args.get(SER_HOST, LOCALHOST)
+ self.port = args.get(SER_PORT, DEFAULT_PORT)
self.sslport = args.get(SER_SECURE_PORT)
- self.binddn = args.get(SER_ROOT_DN, DN_DM)
- self.bindpw = args.get(SER_ROOT_PW, PW_DM)
+ self.binddn = args.get(SER_ROOT_DN, DN_DM)
+ self.bindpw = args.get(SER_ROOT_PW, PW_DM)
self.creation_suffix = args.get(SER_CREATION_SUFFIX, DEFAULT_SUFFIX)
- self.userid = args.get(SER_USER_ID)
+ self.userid = args.get(SER_USER_ID)
if not self.userid:
if os.getuid() == 0:
# as root run as default user
@@ -454,16 +468,17 @@ class DirSrv(SimpleLDAPObject):
self.userid = pwd.getpwuid(os.getuid())[0]
# Settings from args of server attributes
- self.serverid = args.get(SER_SERVERID_PROP, None)
- self.groupid = args.get(SER_GROUP_ID, self.userid)
+ self.serverid = args.get(SER_SERVERID_PROP, None)
+ self.groupid = args.get(SER_GROUP_ID, self.userid)
self.backupdir = args.get(SER_BACKUP_INST_DIR, DEFAULT_BACKUPDIR)
# Allocate from the args, or use our env, or use /
- if args.get(SER_DEPLOYED_DIR, self.prefix ) is not None:
- self.prefix = args.get(SER_DEPLOYED_DIR, self.prefix )
+ if args.get(SER_DEPLOYED_DIR, self.prefix) is not None:
+ self.prefix = args.get(SER_DEPLOYED_DIR, self.prefix)
# 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)
+ # self.sroot = os.path.join(self.prefix, "lib/dirsrv")
+ # 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
@@ -475,8 +490,9 @@ class DirSrv(SimpleLDAPObject):
self.state = DIRSRV_STATE_ALLOCATED
self.log.info("Allocate %s with %s:%s" % (self.__class__,
- self.host,
- self.sslport or self.port))
+ self.host,
+ (self.sslport or
+ self.port)))
def openConnection(self):
# Open a new connection to our LDAP server
@@ -492,9 +508,11 @@ class DirSrv(SimpleLDAPObject):
def list(self, all=False, serverid=None):
"""
- Returns a list dictionary. For a created instance that is on the local file system
- (e.g. <prefix>/etc/dirsrv/slapd-*), it exists a file describing its properties
- (environment): <prefix>/etc/sysconfig/dirsrv-<serverid> or $HOME/.dirsrv/dirsv-<serverid>
+ Returns a list dictionary. For a created instance that is on the
+ local file system (e.g. <prefix>/etc/dirsrv/slapd-*), it exists
+ a file describing its properties
+ (environment): <prefix>/etc/sysconfig/dirsrv-<serverid> or
+ $HOME/.dirsrv/dirsv-<serverid>
A dictionary is created with the following properties:
CONF_SERVER_DIR
CONF_SERVERBIN_DIR
@@ -503,16 +521,20 @@ class DirSrv(SimpleLDAPObject):
CONF_RUN_DIR
CONF_DS_ROOT
CONF_PRODUCT_NAME
- If all=True it builds a list of dictionary for all created instances.
- Else (default), the list will only contain the dictionary of the calling instance
+ If all=True it builds a list of dictionaries for all created
+ instances. Else (default), the list will only contain the
+ dictionary of the calling instance
@param all - True or False . default is [False]
- @param instance - The name of the instance to retrieve or None for the current instance
+ @param instance - The name of the instance to retrieve or None for
+ the current instance
- @return list of dictionaries, each of them containing instance properities
+ @return - list of dictionaries, each of them containing instance
+ properities
- @raise IOError - if the file containing the properties is not foundable or readable
+ @raise IOError - if the file containing the properties is not
+ foundable or readable
"""
def test_and_set(prop, propname, variable, value):
'''
@@ -532,7 +554,8 @@ class DirSrv(SimpleLDAPObject):
if not filename:
raise IOError('filename is mandatory')
- if not os.path.isfile(filename) or not os.access(filename, os.R_OK):
+ if not os.path.isfile(filename) or \
+ not os.access(filename, os.R_OK):
raise IOError('invalid file name or rights: %s' % filename)
prop = {}
@@ -541,24 +564,25 @@ class DirSrv(SimpleLDAPObject):
prop[SER_DEPLOYED_DIR] = self.prefix
myfile = open(filename, 'r')
for line in myfile:
- # retrieve the value in line:: <PROPNAME>=<string> [';' export <PROPNAME>]
+ # retrieve the value in line::
+ # <PROPNAME>=<string> [';' export <PROPNAME>]
- #skip comment lines
+ # skip comment lines
if line.startswith('#'):
continue
- #skip lines without assignment
- if not '=' in line:
+ # skip lines without assignment
+ if '=' not in line:
continue
value = line.split(';', 1)[0]
- #skip lines without assignment
- if not '=' in value:
+ # skip lines without assignment
+ if '=' not in value:
continue
variable = value.split('=', 1)[0]
- value = value.split('=', 1)[1]
- value = value.strip(' \t\n') # remove heading/ending space/tab/newline
+ value = value.split('=', 1)[1]
+ value = value.strip(' \t\n')
for property in (CONF_SERVER_DIR,
CONF_SERVERBIN_DIR,
CONF_CONFIG_DIR,
@@ -578,17 +602,19 @@ class DirSrv(SimpleLDAPObject):
configentry = ldifconn.get(DN_CONFIG)
for key in args_dse_keys:
prop[key] = configentry.getValue(args_dse_keys[key])
- #SER_HOST (host) nsslapd-localhost
- #SER_PORT (port) nsslapd-port
- #SER_SECURE_PORT (sslport) nsslapd-secureport
- #SER_ROOT_DN (binddn) nsslapd-rootdn
- #SER_ROOT_PW (bindpw) We can't do this
- #SER_CREATION_SUFFIX (creation_suffix) nsslapd-defaultnamingcontext
- #SER_USER_ID (userid) nsslapd-localuser
- #SER_SERVERID_PROP (serverid) Already have this
- #SER_GROUP_ID (groupid) ???
- #SER_DEPLOYED_DIR (prefix) Already provided to do the discovery
- #SER_BACKUP_INST_DIR (backupdir) nsslapd-bakdir <<-- maybe?
+ # SER_HOST (host) nsslapd-localhost
+ # SER_PORT (port) nsslapd-port
+ # SER_SECURE_PORT (sslport) nsslapd-secureport
+ # SER_ROOT_DN (binddn) nsslapd-rootdn
+ # SER_ROOT_PW (bindpw) We can't do this
+ # SER_CREATION_SUFFIX (creation_suffix)
+ # nsslapd-defaultnamingcontext
+ # SER_USER_ID (userid) nsslapd-localuser
+ # SER_SERVERID_PROP (serverid) Already have this
+ # SER_GROUP_ID (groupid) ???
+ # SER_DEPLOYED_DIR (prefix) Already provided to for
+ # discovery
+ # SER_BACKUP_INST_DIR (backupdir) nsslapd-bakdir <<-- maybe?
# We need to convert these two to int
# because other routines get confused if we don't
for intkey in [SER_PORT, SER_SECURE_PORT]:
@@ -599,19 +625,23 @@ class DirSrv(SimpleLDAPObject):
def search_dir(instances, pattern, stop_value=None):
'''
It search all the files matching pattern.
- It there is not stop_value, it adds the properties found in each file
- to the 'instances'
- Else it searches the specific stop_value (instance's serverid) to add only
- its properties in the 'instances'
-
- @param instances - list of dictionary containing the instances properties
- @param pattern - pattern to find the files containing the properties
- @param stop_value - serverid value if we are looking only for one specific instance
+ It there is not stop_value, it adds the properties found in
+ each file to the 'instances'
+ Else it searches the specific stop_value (instance's serverid)
+ to add only its properties in the 'instances'
+
+ @param instances - list of dictionary containing the instances
+ properties
+ @param pattern - pattern to find the files containing the
+ properties
+ @param stop_value - serverid value if we are looking only for
+ one specific instance
@return True or False - If stop_value is None it returns False.
- If stop_value is specified, it returns True if it added
- the property dictionary in instances. Or False if it did
- not find it.
+ If stop_value is specified, it returns
+ True if it added the property
+ dictionary in instances. Or False if it
+ did not find it.
'''
added = False
print(pattern)
@@ -629,7 +659,7 @@ class DirSrv(SimpleLDAPObject):
added = True
break
else:
- #this is not the searched value, continue
+ # this is not the searched value, continue
continue
else:
# we are not looking for a specific value, just add it
@@ -660,7 +690,8 @@ class DirSrv(SimpleLDAPObject):
if confdir:
self.log.info("$INITCONFIGDIR set to: %s" % confdir)
if not os.path.isdir(confdir):
- raise ValueError("$INITCONFIGDIR incorrect directory (%s)" % confdir)
+ raise ValueError("$INITCONFIGDIR incorrect directory (%s)" %
+ confdir)
sysconfig_head = confdir
privconfig_head = None
else:
@@ -684,7 +715,8 @@ class DirSrv(SimpleLDAPObject):
# first check the private repository
if privconfig_head:
- pattern = "%s*" % os.path.join(privconfig_head, DEFAULT_ENV_HEAD)
+ pattern = "%s*" % os.path.join(privconfig_head,
+ DEFAULT_ENV_HEAD)
found = search_dir(instances, pattern, serverid)
if len(instances) > 0:
self.log.info("List from %s" % privconfig_head)
@@ -699,7 +731,8 @@ class DirSrv(SimpleLDAPObject):
# second, if not already found, search the system repository
if not found:
- pattern = "%s*" % os.path.join(sysconfig_head, DEFAULT_ENV_HEAD)
+ pattern = "%s*" % os.path.join(sysconfig_head,
+ DEFAULT_ENV_HEAD)
search_dir(instances, pattern, serverid)
if len(instances) > 0:
self.log.info("List from %s" % privconfig_head)
@@ -709,7 +742,8 @@ class DirSrv(SimpleLDAPObject):
else:
# all instances must be retrieved
if privconfig_head:
- pattern = "%s*" % os.path.join(privconfig_head, DEFAULT_ENV_HEAD)
+ pattern = "%s*" % os.path.join(privconfig_head,
+ DEFAULT_ENV_HEAD)
search_dir(instances, pattern)
if len(instances) > 0:
self.log.info("List from %s" % privconfig_head)
@@ -756,26 +790,28 @@ class DirSrv(SimpleLDAPObject):
log.error("Can't find file: %r, removing extension" % prog)
prog = prog[:-3]
- args = {SER_HOST: self.host,
- SER_PORT: self.port,
- SER_SECURE_PORT: self.sslport,
- SER_ROOT_DN: self.binddn,
- SER_ROOT_PW: self.bindpw,
+ args = {SER_HOST: self.host,
+ SER_PORT: self.port,
+ SER_SECURE_PORT: self.sslport,
+ SER_ROOT_DN: self.binddn,
+ SER_ROOT_PW: self.bindpw,
SER_CREATION_SUFFIX: self.creation_suffix,
- SER_USER_ID: self.userid,
- SER_SERVERID_PROP: self.serverid,
- SER_GROUP_ID: self.groupid,
- SER_DEPLOYED_DIR: self.prefix,
+ SER_USER_ID: self.userid,
+ SER_SERVERID_PROP: self.serverid,
+ SER_GROUP_ID: self.groupid,
+ SER_DEPLOYED_DIR: self.prefix,
SER_BACKUP_INST_DIR: self.backupdir}
content = formatInfData(args)
- result = DirSrvTools.runInfProg(prog, content, verbose, prefix=self.prefix)
+ result = DirSrvTools.runInfProg(prog, content, verbose,
+ prefix=self.prefix)
if result != 0:
raise Exception('Failed to run setup-ds.pl')
def create(self):
"""
Creates an instance with the parameters sets in dirsrv
- The state change from DIRSRV_STATE_ALLOCATED -> DIRSRV_STATE_OFFLINE
+ The state change from DIRSRV_STATE_ALLOCATED ->
+ DIRSRV_STATE_OFFLINE
@param - self
@@ -786,15 +822,18 @@ class DirSrv(SimpleLDAPObject):
"""
# check that DirSrv was in DIRSRV_STATE_ALLOCATED state
if self.state != DIRSRV_STATE_ALLOCATED:
- raise ValueError("invalid state for calling create: %s" % self.state)
+ raise ValueError("invalid state for calling create: %s" %
+ self.state)
# Check that the instance does not already exist
props = self.list()
if len(props) != 0:
- raise ValueError("Error it already exists the instance (%s)" % props[0][CONF_INST_DIR])
+ raise ValueError("Error it already exists the instance (%s)" %
+ props[0][CONF_INST_DIR])
if not self.serverid:
- raise ValueError("SER_SERVERID_PROP is missing, it is required to create an instance")
+ raise ValueError("SER_SERVERID_PROP is missing, " +
+ "it is required to create an instance")
# Time to create the instance and retrieve the effective sroot
self._createDirsrv(verbose=self.verbose)
@@ -834,7 +873,8 @@ class DirSrv(SimpleLDAPObject):
# Now time to remove the instance
prog = get_sbin_dir(None, self.prefix) + CMD_PATH_REMOVE_DS
if (not self.prefix or self.prefix == '/') and os.geteuid() != 0:
- raise ValueError("Error: without prefix deployment it is required to be root user")
+ raise ValueError("Error: without prefix deployment it is " +
+ "required to be root user")
cmd = "%s -i %s%s" % (prog, DEFAULT_INST_HEAD, self.serverid)
self.log.debug("running: %s " % cmd)
try:
@@ -854,15 +894,18 @@ class DirSrv(SimpleLDAPObject):
try:
subprocess.call(cmd)
except subprocess.CalledProcessError as e:
- log.exception('Failed to delete default user (%s): error %s' %
- (DEFAULT_USER, e.output))
+ log.exception('Failed to delete default user ' +
+ '(%s): error %s' % (DEFAULT_USER,
+ e.output))
self.state = DIRSRV_STATE_ALLOCATED
def open(self):
'''
- It opens a ldap bound connection to dirsrv so that online administrative tasks are possible.
- It binds with the binddn property, then it initializes various fields from DirSrv (via __initPart2)
+ It opens a ldap bound connection to dirsrv so that online
+ administrative tasks are possible. It binds with the binddn
+ property, then it initializes various fields from DirSrv
+ (via __initPart2)
The state changes -> DIRSRV_STATE_ONLINE
@@ -909,7 +952,8 @@ class DirSrv(SimpleLDAPObject):
def close(self):
'''
- It closes connection to dirsrv. Online administrative tasks are no longer possible.
+ It closes connection to dirsrv. Online administrative tasks are no
+ longer possible.
The state changes from DIRSRV_STATE_ONLINE -> DIRSRV_STATE_OFFLINE
@@ -922,7 +966,8 @@ class DirSrv(SimpleLDAPObject):
# check that DirSrv was in DIRSRV_STATE_ONLINE state
if self.state != DIRSRV_STATE_ONLINE:
- raise ValueError("invalid state for calling close: %s" % self.state)
+ raise ValueError("invalid state for calling close: %s" %
+ self.state)
SimpleLDAPObject.unbind(self)
@@ -930,8 +975,8 @@ class DirSrv(SimpleLDAPObject):
def start(self, timeout):
'''
- It starts an instance and rebind it. Its final state after rebind (open)
- is DIRSRV_STATE_ONLINE
+ It starts an instance and rebind it. Its final state after rebind
+ (open) is DIRSRV_STATE_ONLINE
@param self
@param timeout (in sec) to wait for successful start
@@ -971,13 +1016,13 @@ class DirSrv(SimpleLDAPObject):
if DirSrvTools.stop(self, verbose=False, timeout=timeout):
self.log.error("Probable failure to stop the instance")
- #whatever the initial state, the instance is now Offline
+ # whatever the initial state, the instance is now Offline
self.state = DIRSRV_STATE_OFFLINE
def restart(self, timeout):
'''
- It restarts an instance and rebind it. Its final state after rebind (open)
- is DIRSRV_STATE_ONLINE.
+ It restarts an instance and rebind it. Its final state after rebind
+ (open) is DIRSRV_STATE_ONLINE.
@param self
@param timeout (in sec) to wait for successful stop
@@ -991,10 +1036,13 @@ class DirSrv(SimpleLDAPObject):
def _infoBackupFS(self):
"""
- Return the information to retrieve the backup file of a given instance
+ 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)
+ - 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" % (self.backupdir, self.serverid)
backup_pattern = os.path.join(backup_dir, "backup*.tar.gz")
@@ -1049,16 +1097,20 @@ class DirSrv(SimpleLDAPObject):
def backupFS(self):
"""
- Saves the files of an instance under /tmp/slapd-<instance_name>.bck/backup_HHMMSS.tar.gz
+ 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
+ If it already exists a such file, it assums it is a valid backup
+ and returns its name
self.sroot : root of the instance (e.g. /usr/lib64/dirsrv)
- self.inst : instance name (e.g. standalone for /etc/dirsrv/slapd-standalone)
+ self.inst : instance name
+ (e.g. standalone for /etc/dirsrv/slapd-standalone)
self.confdir : root of the instance config (e.g. /etc/dirsrv)
- self.dbdir: directory where is stored the database (e.g. /var/lib/dirsrv/slapd-standalone/db)
- self.changelogdir: directory where is stored the changelog (e.g. /var/lib/dirsrv/slapd-master/changelogdb)
+ self.dbdir: directory where is stored the database
+ (e.g. /var/lib/dirsrv/slapd-standalone/db)
+ self.changelogdir: directory where is stored the changelog
+ (e.g. /var/lib/dirsrv/slapd-master/changelogdb)
@param None
@@ -1072,8 +1124,8 @@ class DirSrv(SimpleLDAPObject):
backup_file = self.checkBackupFS()
if not os.path.exists(backup_dir):
os.makedirs(backup_dir)
- # make the backup directory accessible for anybody so that any user can run
- # the tests even if it existed a backup created by somebody else
+ # make the backup directory accessible for anybody so that any user can
+ # run the tests even if it existed a backup created by somebody else
os.chmod(backup_dir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
if backup_file:
@@ -1100,9 +1152,11 @@ class DirSrv(SimpleLDAPObject):
ldir.append(self.changelogdir)
if hasattr(self, 'errlog'):
ldir.append(os.path.dirname(self.errlog))
- if hasattr(self, 'accesslog') and os.path.dirname(self.accesslog) not in ldir:
+ if hasattr(self, 'accesslog') and \
+ os.path.dirname(self.accesslog) not in ldir:
ldir.append(os.path.dirname(self.accesslog))
- if hasattr(self, 'auditlog') and os.path.dirname(self.auditlog) not in ldir:
+ if hasattr(self, 'auditlog') and os.path.dirname(self.auditlog) \
+ not in ldir:
ldir.append(os.path.dirname(self.auditlog))
# now scan the directory list to find the files to backup
@@ -1111,13 +1165,15 @@ class DirSrv(SimpleLDAPObject):
for b_dir in dirs:
name = os.path.join(root, b_dir)
- log.debug("backupFS b_dir = %s (%s) [name=%s]" % (b_dir, self.prefix, name))
+ log.debug("backupFS b_dir = %s (%s) [name=%s]" %
+ (b_dir, self.prefix, name))
if prefix_pattern:
name = re.sub(prefix_pattern, '', name)
if os.path.isdir(name):
listFilesToBackup.append(name)
- log.debug("backupFS add = %s (%s)" % (name, self.prefix))
+ log.debug("backupFS add = %s (%s)" %
+ (name, self.prefix))
for file in files:
name = os.path.join(root, file)
@@ -1126,7 +1182,8 @@ class DirSrv(SimpleLDAPObject):
if os.path.isfile(name):
listFilesToBackup.append(name)
- log.debug("backupFS add = %s (%s)" % (name, self.prefix))
+ log.debug("backupFS add = %s (%s)" %
+ (name, self.prefix))
# create the archive
name = "backup_%s.tar.gz" % (time.strftime("%m%d%Y_%H%M%S"))
@@ -1159,8 +1216,10 @@ class DirSrv(SimpleLDAPObject):
log.warning("Unable to restore the instance (missing backup)")
raise ValueError("Unable to restore the instance (missing backup)")
if not os.path.isfile(backup_file):
- log.warning("Unable to restore the instance (%s is not a file)" % backup_file)
- raise ValueError("Unable to restore the instance (%s is not a file)" % backup_file)
+ log.warning("Unable to restore the instance (%s is not a file)" %
+ backup_file)
+ raise ValueError("Unable to restore the instance " +
+ "(%s is not a file)" % backup_file)
#
# Second do some clean up
@@ -1171,7 +1230,8 @@ class DirSrv(SimpleLDAPObject):
for root, dirs, files in os.walk(self.dbdir):
for d in dirs:
if d not in ("bak", "ldif"):
- log.debug("restoreFS: before restore remove directory %s/%s" % (root, d))
+ log.debug("restoreFS: before restore remove directory" +
+ " %s/%s" % (root, d))
shutil.rmtree("%s/%s" % (root, d))
# previous error/access logs
@@ -1208,7 +1268,8 @@ class DirSrv(SimpleLDAPObject):
log.debug("restoreFS: restored %s" % member.name)
tar.extract(member.name)
else:
- log.debug("restoreFS: not restored %s (no write access)" % member.name)
+ log.debug("restoreFS: not restored %s (no write access)" %
+ member.name)
else:
log.debug("restoreFS: restored %s" % member.name)
tar.extract(member.name)
@@ -1233,8 +1294,9 @@ class DirSrv(SimpleLDAPObject):
'''
Check if an instance exists.
It checks that both exists:
- - configuration directory (<prefix>/etc/dirsrv/slapd-<serverid>)
- - environment file (/etc/sysconfig/dirsrv-<serverid> or $HOME/.dirsrv/dirsrv-<serverid>)
+ - configuration directory (<prefix>/etc/dirsrv/slapd-<servid>)
+ - environment file (/etc/sysconfig/dirsrv-<serverid> or
+ $HOME/.dirsrv/dirsrv-<serverid>)
@param None
@@ -1260,10 +1322,13 @@ class DirSrv(SimpleLDAPObject):
# Get entries
#
def getEntry(self, *args, **kwargs):
- """Wrapper around SimpleLDAPObject.search. It is common to just get one entry.
+ """Wrapper around SimpleLDAPObject.search. It is common to just get
+ one entry.
@param - entry dn
- @param - search scope, in ldap.SCOPE_BASE (default), ldap.SCOPE_SUB, ldap.SCOPE_ONE
- @param filterstr - filterstr, default '(objectClass=*)' from SimpleLDAPObject
+ @param - search scope, in ldap.SCOPE_BASE (default),
+ ldap.SCOPE_SUB, ldap.SCOPE_ONE
+ @param filterstr - filterstr, default '(objectClass=*)' from
+ SimpleLDAPObject
@param attrlist - list of attributes to retrieve. eg ['cn', 'uid']
@oaram attrsonly - default None from SimpleLDAPObject
eg. getEntry(dn, scope, filter, attributes)
@@ -1294,14 +1359,16 @@ class DirSrv(SimpleLDAPObject):
log.info("Found entry %s" % entry)
return entry
except NoSuchEntryError:
- log.exception("Entry %s was added successfully, but I cannot search it" % dn)
- raise MissingEntryError("Entry %s was added successfully, but I cannot search it" % dn)
+ log.exception("Entry %s was added successfully, but I cannot " +
+ "search it" % dn)
+ raise MissingEntryError("Entry %s was added successfully, but " +
+ "I cannot search it" % dn)
def __wrapmethods(self):
"""This wraps all methods of SimpleLDAPObject, so that we can intercept
- the methods that deal with entries. Instead of using a raw list of tuples
- of lists of hashes of arrays as the entry object, we want to wrap entries
- in an Entry class that provides some useful methods"""
+ the methods that deal with entries. Instead of using a raw list of
+ tuples of lists of hashes of arrays as the entry object, we want to
+ wrap entries in an Entry class that provides some useful methods"""
for name in dir(self.__class__.__bases__[0]):
attr = getattr(self, name)
if isinstance(attr, collections.Callable):
@@ -1310,7 +1377,8 @@ class DirSrv(SimpleLDAPObject):
def addLDIF(self, input_file, cont=False):
class LDIFAdder(ldif.LDIFParser):
def __init__(self, input_file, conn, cont=False,
- ignored_attr_types=None, max_entries=0, process_url_schemes=None
+ ignored_attr_types=None, max_entries=0,
+ process_url_schemes=None
):
myfile = input_file
if isinstance(input_file, six.string_types):
@@ -1386,10 +1454,15 @@ class DirSrv(SimpleLDAPObject):
# global db stats
ret += "\n\nglobal db stats"
- dbattrs = 'dbcachehits dbcachetries dbcachehitratio dbcachepagein dbcachepageout dbcacheroevict dbcacherwevict'.split(' ')
- cols = {'dbcachehits': [len('cachehits'), 'cachehits'], 'dbcachetries': [10, 'cachetries'],
- 'dbcachehitratio': [5, 'ratio'], 'dbcachepagein': [6, 'pagein'],
- 'dbcachepageout': [7, 'pageout'], 'dbcacheroevict': [7, 'roevict'],
+ dbattrs = ('dbcachehits dbcachetries dbcachehitratio ' +
+ 'dbcachepagein dbcachepageout dbcacheroevict ' +
+ 'dbcacherwevict'.split(' '))
+ cols = {'dbcachehits': [len('cachehits'), 'cachehits'],
+ 'dbcachetries': [10, 'cachetries'],
+ 'dbcachehitratio': [5, 'ratio'],
+ 'dbcachepagein': [6, 'pagein'],
+ 'dbcachepageout': [7, 'pageout'],
+ 'dbcacheroevict': [7, 'roevict'],
'dbcacherwevict': [7, 'rwevict']}
dbrec = {}
for attr, vals in monent.iterAttrs():
@@ -1408,11 +1481,15 @@ class DirSrv(SimpleLDAPObject):
ret += "\n" + (fmtstr % dbrec)
# other db stats
- skips = {'nsslapd-db-cache-hit': 'nsslapd-db-cache-hit', 'nsslapd-db-cache-try': 'nsslapd-db-cache-try',
- 'nsslapd-db-page-write-rate': 'nsslapd-db-page-write-rate',
+ skips = {'nsslapd-db-cache-hit': 'nsslapd-db-cache-hit',
+ 'nsslapd-db-cache-try': 'nsslapd-db-cache-try',
+ 'nsslapd-db-page-write-rate':
+ 'nsslapd-db-page-write-rate',
'nsslapd-db-page-read-rate': 'nsslapd-db-page-read-rate',
- 'nsslapd-db-page-ro-evict-rate': 'nsslapd-db-page-ro-evict-rate',
- 'nsslapd-db-page-rw-evict-rate': 'nsslapd-db-page-rw-evict-rate'}
+ 'nsslapd-db-page-ro-evict-rate':
+ 'nsslapd-db-page-ro-evict-rate',
+ 'nsslapd-db-page-rw-evict-rate':
+ 'nsslapd-db-page-rw-evict-rate'}
hline = '' # header line
vline = '' # val line
@@ -1432,13 +1509,16 @@ class DirSrv(SimpleLDAPObject):
# per file db stats
ret += "\n\nper file stats"
# key is number
- # data is dict - key is attr name without the number - val is the attr val
+ # data is dict - key is attr name without the number -
+ # val is the attr val
dbrec = {}
dbattrs = ['dbfilename', 'dbfilecachehit',
'dbfilecachemiss', 'dbfilepagein', 'dbfilepageout']
# cols maps dbattr name to column header and width
- cols = {'dbfilename': [len('dbfilename'), 'dbfilename'], 'dbfilecachehit': [9, 'cachehits'],
- 'dbfilecachemiss': [11, 'cachemisses'], 'dbfilepagein': [6, 'pagein'],
+ cols = {'dbfilename': [len('dbfilename'), 'dbfilename'],
+ 'dbfilecachehit': [9, 'cachehits'],
+ 'dbfilecachemiss': [11, 'cachemisses'],
+ 'dbfilepagein': [6, 'pagein'],
'dbfilepageout': [7, 'pageout']}
for attr, vals in ent.iterAttrs():
match = RE_DBMONATTR.match(attr)
@@ -1525,9 +1605,10 @@ class DirSrv(SimpleLDAPObject):
confdn = ','.join(("cn=config", DN_CHAIN))
try:
self.modify_s(confdn, [(ldap.MOD_ADD, 'nsTransmittedControl',
- ['2.16.840.1.113730.3.4.12', '1.3.6.1.4.1.1466.29539.12'])])
+ ['2.16.840.1.113730.3.4.12',
+ '1.3.6.1.4.1.1466.29539.12'])])
except ldap.TYPE_OR_VALUE_EXISTS:
- log.error("chaining backend config already has the required controls")
+ log.error("chaining backend config already has the required ctrls")
def setupChainingMux(self, suffix, isIntermediate, binddn, bindpw, urls):
self.addSuffix(suffix, binddn, bindpw, urls)
@@ -1540,8 +1621,9 @@ class DirSrv(SimpleLDAPObject):
self.addSuffix(suffix) # step 2 - create the suffix
# step 3 - add the proxy ACI to the suffix
try:
- acival = "(targetattr = \"*\")(version 3.0; acl \"Proxied authorization for database links\"" + \
- "; allow (proxy) userdn = \"ldap:///%s\";)" % binddn
+ acival = ("(targetattr = \"*\")(version 3.0; acl \"Proxied " +
+ "authorization for database links\"; allow (proxy) " +
+ "userdn = \"ldap:///%s\";)" % binddn)
self.modify_s(suffix, [(ldap.MOD_ADD, 'aci', [acival])])
except ldap.TYPE_OR_VALUE_EXISTS:
log.error("proxy aci already exists in suffix %s for %s" % (
@@ -1549,7 +1631,8 @@ class DirSrv(SimpleLDAPObject):
def setupChaining(self, to, suffix, isIntermediate):
"""Setup chaining from self to to - self is the mux, to is the farm
- if isIntermediate is set, this server will chain requests from another server to to
+ if isIntermediate is set, this server will chain requests from another
+ server to to
"""
bindcn = "chaining user"
binddn = "cn=%s,cn=config" % bindcn
@@ -1570,21 +1653,24 @@ class DirSrv(SimpleLDAPObject):
attrlist=['nsslapd-pluginPath'])
path = e_plugin.getValue('nsslapd-pluginPath')
- mod = [(ldap.MOD_REPLACE, MT_PROPNAME_TO_ATTRNAME[MT_STATE], MT_STATE_VAL_BACKEND),
+ mod = [(ldap.MOD_REPLACE, MT_PROPNAME_TO_ATTRNAME[MT_STATE],
+ MT_STATE_VAL_BACKEND),
(ldap.MOD_ADD, MT_PROPNAME_TO_ATTRNAME[MT_BACKEND], bename),
(ldap.MOD_ADD, MT_PROPNAME_TO_ATTRNAME[MT_CHAIN_PATH], path),
- (ldap.MOD_ADD, MT_PROPNAME_TO_ATTRNAME[MT_CHAIN_FCT], MT_CHAIN_UPDATE_VAL_ON_UPDATE)]
+ (ldap.MOD_ADD, MT_PROPNAME_TO_ATTRNAME[MT_CHAIN_FCT],
+ MT_CHAIN_UPDATE_VAL_ON_UPDATE)]
try:
self.modify_s(dn, mod)
except ldap.TYPE_OR_VALUE_EXISTS:
print("chainOnUpdate already enabled for %s" % suffix)
- def setupConsumerChainOnUpdate(self, suffix, isIntermediate, binddn, bindpw, urls, beargs=None):
+ def setupConsumerChainOnUpdate(self, suffix, isIntermediate, binddn,
+ bindpw, urls, beargs=None):
beargs = beargs or {}
# suffix should already exist
# we need to create a chaining backend
- if not 'nsCheckLocalACI' in beargs:
+ if 'nsCheckLocalACI' not in beargs:
beargs['nsCheckLocalACI'] = 'on' # enable local db aci eval.
chainbe = self.setupBackend(suffix, binddn, bindpw, urls, beargs)
# do the stuff for intermediate chains
@@ -1594,7 +1680,8 @@ class DirSrv(SimpleLDAPObject):
return self.enableChainOnUpdate(suffix, chainbe)
def setupBindDN(self, binddn, bindpw, attrs=None):
- """ Return - eventually creating - a person entry with the given dn and pwd.
+ """ Return - eventually creating - a person entry with the given dn
+ and pwd.
binddn can be a lib389.Entry
"""
@@ -1662,12 +1749,14 @@ class DirSrv(SimpleLDAPObject):
args['onewaysync'].lower() == 'towindows':
entry.setValues("oneWaySync", args['onewaysync'])
else:
- raise Exception("Error: invalid value %s for oneWaySync: must be fromWindows or toWindows"
+ raise Exception("Error: invalid value %s for oneWaySync: " +
+ "must be fromWindows or toWindows"
% args['onewaysync'])
# args - DirSrv consumer (repoth), suffix, binddn, bindpw, timeout
# also need an auto_init argument
- def createAgreement(self, consumer, args, cn_format=r'meTo_%s:%s', description_format=r'me to %s:%s'):
+ def createAgreement(self, consumer, args, cn_format=r'meTo_%s:%s',
+ description_format=r'me to %s:%s'):
"""Create (and return) a replication agreement from self to consumer.
- self is the supplier,
- consumer is a DirSrv object (consumer can be a master)
@@ -1702,10 +1791,11 @@ class DirSrv(SimpleLDAPObject):
if not binddn:
binddn = defaultProperties.get(REPLICATION_BIND_DN, None)
if not binddn:
- # weird, internal error we do not retrieve the default replication bind DN
- # this replica agreement will fail to update the consumer until the
- # property will be set
- log.warning("createAgreement: binddn not provided and default value unavailable")
+ # weird, internal error we do not retrieve the default
+ # replication bind DN this replica agreement will fail
+ # to update the consumer until the property will be set
+ log.warning("createAgreement: binddn not provided and " +
+ "default value unavailable")
pass
# get the RA binddn password
@@ -1713,10 +1803,12 @@ class DirSrv(SimpleLDAPObject):
if not bindpw:
bindpw = defaultProperties.get(REPLICATION_BIND_PW, None)
if not bindpw:
- # weird, internal error we do not retrieve the default replication bind DN password
- # this replica agreement will fail to update the consumer until the
- # property will be set
- log.warning("createAgreement: bindpw not provided and default value unavailable")
+ # weird, internal error we do not retrieve the default
+ # replication bind DN password this replica agreement
+ # will fail to update the consumer until the property will be
+ # set
+ log.warning("createAgreement: bindpw not provided and " +
+ "default value unavailable")
pass
# get the RA bind method
@@ -1724,10 +1816,11 @@ class DirSrv(SimpleLDAPObject):
if not bindmethod:
bindmethod = defaultProperties.get(REPLICATION_BIND_METHOD, None)
if not bindmethod:
- # weird, internal error we do not retrieve the default replication bind method
- # this replica agreement will fail to update the consumer until the
- # property will be set
- log.warning("createAgreement: bindmethod not provided and default value unavailable")
+ # weird, internal error we do not retrieve the default
+ # replication bind method this replica agreement will
+ # fail to update the consumer until the property will be set
+ log.warning("createAgreement: bindmethod not provided and " +
+ "default value unavailable")
pass
nsuffix = normalizeDN(suffix)
@@ -1737,7 +1830,7 @@ class DirSrv(SimpleLDAPObject):
# adding agreement to previously created replica
# eventually setting self.suffixes dict.
- if not nsuffix in self.suffixes:
+ if nsuffix not in self.suffixes:
replica_entries = self.replica.list(suffix)
if not replica_entries:
raise NoSuchEntryError(
@@ -1877,18 +1970,20 @@ class DirSrv(SimpleLDAPObject):
while loop <= 30:
try:
- entry = replica.getEntry(suffix, ldap.SCOPE_BASE, "(objectclass=*)")
+ entry = replica.getEntry(suffix, ldap.SCOPE_BASE,
+ "(objectclass=*)")
if entry.hasValue('description', test_value):
replicated = True
break
except ldap.LDAPError as e:
- log.fatal('testReplication() failed to modify (%s), error (%d)'
- % (suffix, str(e)))
+ log.fatal('testReplication() failed to modify (%s),' +
+ ' error (%d)' % (suffix, str(e)))
return False
loop += 1
time.sleep(2)
if not replicated:
- log.fatal('Replication is not in sync with replica server (%s)' % replica.serverid)
+ log.fatal('Replication is not in sync with replica server (%s)'
+ % replica.serverid)
return False
return True
@@ -1904,14 +1999,19 @@ class DirSrv(SimpleLDAPObject):
suffix - suffix to set up for replication (eventually create)
optional fields and their default values
bename - name of backend corresponding to suffix, otherwise
- it will use the *first* backend found (isn't that dangerous?)
- parent - parent suffix if suffix is a sub-suffix - default is undef
+ it will use the *first* backend found (isn't that
+ dangerous?
+ parent - parent suffix if suffix is a sub-suffix - default is
+ undef
ro - put database in read only mode - default is read write
- type - replica type (MASTER_TYPE, HUB_TYPE, LEAF_TYPE) - default is master
+ type - replica type (MASTER_TYPE, HUB_TYPE, LEAF_TYPE) -
+ default is master
legacy - make this replica a legacy consumer - default is no
- binddn - bind DN of the replication manager user - default is REPLBINDDN
- bindpw - bind password of the repl manager - default is REPLBINDPW
+ binddn - bind DN of the replication manager user - default is
+ REPLBINDDN
+ bindpw - bind password of the repl manager - default is
+ REPLBINDPW
log - if true, replication logging is turned on - default false
id - the replica ID - default is an auto incremented number
@@ -1919,7 +2019,8 @@ class DirSrv(SimpleLDAPObject):
TODO: passing the repArgs as an object or as a **repArgs could be
a better documentation choiche
- eg. replicaSetupAll(self, suffix, type=MASTER_TYPE, log=False, ...)
+ eg. replicaSetupAll(self, suffix, type=MASTER_TYPE,
+ log=False, ...)
"""
repArgs.setdefault('type', MASTER_TYPE)
@@ -1974,8 +2075,10 @@ class DirSrv(SimpleLDAPObject):
args = {'basedn': basedn, 'escdn': escapeDNValue(
normalizeDN(basedn))}
condn = "cn=nsPwPolicyContainer,%(basedn)s" % args
- poldn = "cn=cn\\=nsPwPolicyEntry\\,%(escdn)s,cn=nsPwPolicyContainer,%(basedn)s" % args
- temdn = "cn=cn\\=nsPwTemplateEntry\\,%(escdn)s,cn=nsPwPolicyContainer,%(basedn)s" % args
+ poldn = ("cn=cn\\=nsPwPolicyEntry\\,%(escdn)s,cn=nsPwPolicyContainer" +
+ ",%(basedn)s" % args)
+ temdn = ("cn=cn\\=nsPwTemplateEntry\\,%(escdn)s,cn=nsPwPolicyContain" +
+ "er,%(basedn)s" % args)
cosdn = "cn=nsPwPolicy_cos,%(basedn)s" % args
conent = Entry(condn)
conent.setValues('objectclass', 'nsContainer')
@@ -1998,7 +2101,8 @@ class DirSrv(SimpleLDAPObject):
if verbose:
print("created subtree pwpolicy entry", ent.dn)
except ldap.ALREADY_EXISTS:
- print("subtree pwpolicy entry", ent.dn, "already exists - skipping")
+ print("subtree pwpolicy entry", ent.dn,
+ "already exists - skipping")
self.setPwdPolicy({'nsslapd-pwpolicy-local': 'on'})
self.setDNPwdPolicy(poldn, pwdpolicy, **pwdargs)
@@ -2008,7 +2112,8 @@ class DirSrv(SimpleLDAPObject):
escuser = escapeDNValue(normalizeDN(user))
args = {'par': par, 'udn': user, 'escudn': escuser}
condn = "cn=nsPwPolicyContainer,%(par)s" % args
- poldn = "cn=cn\\=nsPwPolicyEntry\\,%(escudn)s,cn=nsPwPolicyContainer,%(par)s" % args
+ poldn = ("cn=cn\\=nsPwPolicyEntry\\,%(escudn)s,cn=nsPwPolicyCont" +
+ "ainer,%(par)s" % args)
conent = Entry(condn)
conent.setValues('objectclass', 'nsContainer')
polent = Entry(poldn)
@@ -2019,7 +2124,8 @@ class DirSrv(SimpleLDAPObject):
if verbose:
print("created user pwpolicy entry", ent.dn)
except ldap.ALREADY_EXISTS:
- print("user pwpolicy entry", ent.dn, "already exists - skipping")
+ print("user pwpolicy entry", ent.dn,
+ "already exists - skipping")
mod = [(ldap.MOD_REPLACE, 'pwdpolicysubentry', poldn)]
self.modify_s(user, mod)
self.setPwdPolicy({'nsslapd-pwpolicy-local': 'on'})
@@ -2075,21 +2181,24 @@ class DirSrv(SimpleLDAPObject):
"""
@param filename - the name of the test script calling this function
@param dirtype - Either DATA_DIR and TMP_DIR are the allowed values
- @return - absolute path of the dirsrvtests data directory, or 'None' on error
+ @return - absolute path of the dirsrvtests data directory, or 'None'
+ on error
Return the shared data/tmp directory relative to the ticket filename.
- The caller should always use "__file__" as the argument to this function.
+ 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'
+ 'ds/dirsrvtests/tickets/ticket_#####_test.py' -->
+ 'ticket_#####_test.py'
- Get the full path to the filename, and convert it to the data directory:
+ 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/'
- '/home/user/389-ds-base/ds/dirsrvtests/suites/dyanmic-plugins/test-dynamic-plugins_test.py' -->
- '/home/user/389-ds-base/ds/dirsrvtests/data/'
+ 'ds/dirsrvtests/tickets/ticket_#####_test.py' -->
+ 'ds/dirsrvtests/data/'
+ 'ds/dirsrvtests/suites/dyanmic-plugins/dynamic-plugins_test.py' -->
+ '/ds/dirsrvtests/data/'
"""
dir_path = None
if os.path.exists(filename):
@@ -2109,8 +2218,8 @@ class DirSrv(SimpleLDAPObject):
elif dirtype == DATA_DIR:
dir_path = filename[:idx] + '/data/'
else:
- raise ValueError("Invalid directory type (%s), acceptable values are DATA_DIR and TMP_DIR"
- % dirtype)
+ raise ValueError("Invalid directory type (%s), acceptable" +
+ " values are DATA_DIR and TMP_DIR" % dirtype)
return dir_path
@@ -2119,7 +2228,8 @@ class DirSrv(SimpleLDAPObject):
@param filename - the name of the test script calling this function
@return - nothing
- Clear the contents of the "tmp" dir, but leave the README file in place.
+ Clear the contents of the "tmp" dir, but leave the README file in
+ place.
"""
if os.path.exists(filename):
filename = os.path.abspath(filename)
@@ -2133,7 +2243,8 @@ class DirSrv(SimpleLDAPObject):
dir_path = filename[:idx] + '/tmp/'
if dir_path:
- filelist = [tmpfile for tmpfile in os.listdir(dir_path) if tmpfile != 'README']
+ filelist = [tmpfile for tmpfile in os.listdir(dir_path)
+ if tmpfile != 'README']
for tmpfile in filelist:
tmpfile = os.path.abspath(dir_path + tmpfile)
if os.path.isdir(tmpfile):
@@ -2157,9 +2268,11 @@ class DirSrv(SimpleLDAPObject):
DirSrvTools.runUpgrade(self.prefix, online)
#
- # The following are the functions to perform offline scripts(when the server is stopped)
+ # The following are the functions to perform offline scripts(when the
+ # server is stopped)
#
- def ldif2db(self, bename, suffixes, excludeSuffixes, encrypt, *import_files):
+ def ldif2db(self, bename, suffixes, excludeSuffixes, encrypt,
+ *import_files):
"""
@param bename - The backend name of the database to import
@param suffixes - List/tuple of suffixes to import
@@ -2206,7 +2319,8 @@ class DirSrv(SimpleLDAPObject):
return result
- def db2ldif(self, bename, suffixes, excludeSuffixes, encrypt, repl_data, outputfile):
+ def db2ldif(self, bename, suffixes, excludeSuffixes, encrypt, repl_data,
+ outputfile):
"""
@param bename - The backend name of the database to export
@param suffixes - List/tuple of suffixes to export
@@ -2383,13 +2497,13 @@ class DirSrv(SimpleLDAPObject):
self.stop(timeout=10)
log.info('Running script: %s' % cmd)
- result = True
proc = Popen(cmd.split(), stdout=PIPE)
outs = ''
try:
outs = proc.communicate()
except OSError as e:
- log.exception('dbscan: error executing (%s): error %d - %s' % (cmd, e.errno, e.strerror))
+ log.exception('dbscan: error executing (%s): error %d - %s' %
+ (cmd, e.errno, e.strerror))
raise e
self.start(timeout=10)
@@ -2409,10 +2523,13 @@ class DirSrv(SimpleLDAPObject):
def detectDisorderlyShutdown(self):
return DirSrvTools.searchFile(self.errlog, DISORDERLY_SHUTDOWN)
- def get_effective_rights(self, sourcedn, base=DEFAULT_SUFFIX, scope=ldap.SCOPE_SUBTREE, *args, **kwargs):
+ def get_effective_rights(self, sourcedn, base=DEFAULT_SUFFIX,
+ scope=ldap.SCOPE_SUBTREE, *args, **kwargs):
"""
- Conduct a search on effective rights for some object (sourcedn) against a filter.
- For arguments to this function, please see LDAPObject.search_s. For example:
+ Conduct a search on effective rights for some object (sourcedn)
+ against a filter.
+ For arguments to this function, please see LDAPObject.search_s.
+ For example:
@param sourcedn - DN of entry to check
@param base - Base DN of the suffix to check
@@ -2421,14 +2538,19 @@ class DirSrv(SimpleLDAPObject):
@param kwargs -
@return - ldap result
- LDAPObject.search_s(base, scope[, filterstr='(objectClass=*)'[, attrlist=None[, attrsonly=0]]]) -> list|None
+ LDAPObject.search_s(base, scope[, filterstr='(objectClass=*)'
+ [, attrlist=None[, attrsonly=0]]]) -> list|None
- The sourcedn is the object that is having it's rights checked against all objects matched by filterstr
+ The sourcedn is the object that is having it's rights checked against
+ all objects matched by filterstr
If sourcedn is '', anonymous is checked.
- If you set targetattrs to "*" you will see ALL possible attributes for all possible objectclasses on the object.
+ If you set targetattrs to "*" you will see ALL possible attributes for
+ all possible objectclasses on the object.
If you set targetattrs to "+" you will see operation attributes only.
- If you set targetattrs to "*@objectclass" you will only see the attributes from that class.
- You will want to look at entryLevelRights and attributeLevelRights in the result.
+ If you set targetattrs to "*@objectclass" you will only see the
+ attributes from that class.
+ You will want to look at entryLevelRights and attributeLevelRights in
+ the result.
entryLevelRights:
* a - add
* d - delete
@@ -2442,18 +2564,19 @@ class DirSrv(SimpleLDAPObject):
* c - Compare the attributes directory side
* W - self write the attribute
* O - self obliterate
- See: https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/10/html/Administration_Guide/Viewing_the_ACIs_for_an_Entry-Get_Effective_Rights_Control.html
"""
- #Is there a better way to do this check?
+ # Is there a better way to do this check?
if not (MAJOR >= 3 or (MAJOR == 2 and MINOR >= 7)):
- raise Exception("UNSUPPORTED EXTENDED OPERATION ON THIS VERSION OF PYTHON")
+ raise Exception("UNSUPPORTED EXTENDED OPERATION ON THIS VERSION " +
+ "OF PYTHON")
ldap_result = None
# This may not be thread safe. Is there a better way to do this?
try:
- gerc = GetEffectiveRightsControl(True, authzId='dn:' + sourcedn.encode('UTF-8'))
+ gerc = GetEffectiveRightsControl(True, authzId='dn:' +
+ sourcedn.encode('UTF-8'))
sctrl = [gerc]
self.set_option(ldap.OPT_SERVER_CONTROLS, sctrl)
- #ldap_result = self.search_s(base, scope, *args, **kwargs)
+ # ldap_result = self.search_s(base, scope, *args, **kwargs)
res = self.search(base, scope, *args, **kwargs)
restype, ldap_result = self.result(res)
finally:
@@ -2461,11 +2584,13 @@ class DirSrv(SimpleLDAPObject):
return ldap_result
# Is there a better name for this function?
- def dereference(self, deref, base=DEFAULT_SUFFIX, scope=ldap.SCOPE_SUBTREE, *args, **kwargs):
+ def dereference(self, deref, base=DEFAULT_SUFFIX, scope=ldap.SCOPE_SUBTREE,
+ *args, **kwargs):
"""
- Perform a search which dereferences values from attributes such as member
- or unique member.
- For arguments to this function, please see LDAPObject.search_s. For example:
+ Perform a search which dereferences values from attributes such as
+ member or unique member.
+ For arguments to this function, please see LDAPObject.search_s. For
+ example:
@param deref - Dereference query
@param base - Base DN of the suffix to check
@@ -2474,7 +2599,8 @@ class DirSrv(SimpleLDAPObject):
@param kwargs -
@return - ldap result
- LDAPObject.search_s(base, scope[, filterstr='(objectClass=*)'[, attrlist=None[, attrsonly=0]]]) -> list|None
+ LDAPObject.search_s(base, scope[, filterstr='(objectClass=*)'
+ [, attrlist=None[, attrsonly=0]]]) -> list|None
A deref query is of the format:
@@ -2482,20 +2608,25 @@ class DirSrv(SimpleLDAPObject):
"uniqueMember:dn,objectClass"
- This will return the dn's and objectClasses of the dereferenced members of the group.
+ This will return the dn's and objectClasses of the dereferenced members
+ of the group.
"""
if not (MAJOR >= 3 or (MAJOR == 2 and MINOR >= 7)):
- raise Exception("UNSUPPORTED EXTENDED OPERATION ON THIS VERSION OF PYTHON")
- ldap_result = None
+ raise Exception("UNSUPPORTED EXTENDED OPERATION ON THIS VERSION " +
+ " OF PYTHON")
+
# This may not be thread safe. Is there a better way to do this?
try:
drc = DereferenceControl(True, deref=deref.encode('UTF-8'))
sctrl = [drc]
self.set_option(ldap.OPT_SERVER_CONTROLS, sctrl)
- #ldap_result = self.search_s(base, scope, *args, **kwargs)
+ # ldap_result = self.search_s(base, scope, *args, **kwargs)
res = self.search(base, scope, *args, **kwargs)
- resp_type, resp_data, resp_msgid, decoded_resp_ctrls, _, _ = self.result4(res, add_ctrls=1, resp_ctrl_classes={CONTROL_DEREF: DereferenceControl})
+ resp_type, resp_data, resp_msgid, decoded_resp_ctrls, _, _ = \
+ self.result4(res, add_ctrls=1,
+ resp_ctrl_classes={CONTROL_DEREF:
+ DereferenceControl})
finally:
self.set_option(ldap.OPT_SERVER_CONTROLS, [])
return resp_data, decoded_resp_ctrls
@@ -2519,5 +2650,6 @@ class DirSrv(SimpleLDAPObject):
gid = grp.getgrnam(self.userid).gr_gid
os.chown(ldif_file, uid, gid)
except OSError as e:
- log.exception('Failed to create ldif file (%s): error %d - %s' % (ldif_file, e.errno, e.strerror))
+ log.exception('Failed to create ldif file (%s): error %d - %s' %
+ (ldif_file, e.errno, e.strerror))
raise e
diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py
index dcf88ea88..999001959 100644
--- a/src/lib389/lib389/backend.py
+++ b/src/lib389/lib389/backend.py
@@ -5,13 +5,11 @@ Created on Dec 13, 2013
'''
import ldap
-from compiler.ast import Not
-
from lib389._constants import *
from lib389.properties import *
-from lib389.utils import normalizeDN, suffixfilt
+from lib389.utils import normalizeDN
from lib389 import DirSrv, Entry
-from lib389 import NoSuchEntryError, InvalidArgumentError, UnwillingToPerformError
+from lib389 import NoSuchEntryError, InvalidArgumentError
class Backend(object):
@@ -28,11 +26,14 @@ class Backend(object):
def list(self, suffix=None, backend_dn=None, bename=None):
"""
- Returns a search result of the backend(s) entries with all their attributes
+ Returns a search result of the backend(s) entries with all their
+ attributes
- If 'suffix'/'backend_dn'/'benamebase' are specified. It uses 'backend_dn' first, then 'suffix', then 'benamebase'.
+ If 'suffix'/'backend_dn'/'benamebase' are specified. It uses
+ 'backend_dn' first, then 'suffix', then 'benamebase'.
- If neither 'suffix', 'backend_dn' and 'benamebase' are specified, it returns all the backend entries
+ If neither 'suffix', 'backend_dn' and 'benamebase' are specified,
+ it returns all the backend entries
Get backends by name or suffix
@@ -48,18 +49,22 @@ class Backend(object):
filt = "(objectclass=%s)" % BACKEND_OBJECTCLASS_VALUE
if backend_dn:
self.log.info("List backend %s" % backend_dn)
- base = backend_dn
+ base = backend_dn
scope = ldap.SCOPE_BASE
elif suffix:
self.log.info("List backend with suffix=%s" % suffix)
- base = DN_PLUGIN
+ base = DN_PLUGIN
scope = ldap.SCOPE_SUBTREE
- filt = "(&%s(|(%s=%s)(%s=%s)))" % (filt,
- BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX],suffix,
- BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX], normalizeDN(suffix))
+ filt = ("(&%s(|(%s=%s)(%s=%s)))" %
+ (filt,
+ BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX], suffix,
+ BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX],
+ normalizeDN(suffix))
+ )
elif bename:
self.log.info("List backend 'cn=%s'" % bename)
- base = "%s=%s,%s" % (BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME], bename, DN_LDBM)
+ base = "%s=%s,%s" % (BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME],
+ bename, DN_LDBM)
scope = ldap.SCOPE_BASE
else:
self.log.info("List all the backends")
@@ -73,7 +78,6 @@ class Backend(object):
return ents
-
def _readonly(self, bename=None, readonly='on', suffix=None):
"""Put a database in readonly mode
@param bename - the backend name (eg. addressbook1)
@@ -93,10 +97,10 @@ class Backend(object):
raise NotImplementedError()
self.conn.modify_s(','.join(('cn=' + bename, DN_LDBM)), [
- (ldap.MOD_REPLACE, BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_READONLY], readonly)
+ (ldap.MOD_REPLACE, BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_READONLY],
+ readonly)
])
-
def delete(self, suffix=None, backend_dn=None, bename=None):
"""
Deletes the backend entry with the following steps:
@@ -105,56 +109,71 @@ class Backend(object):
Delete the encrypted attributes entries under this backend
Delete the encrypted attributes keys entries under this backend
- If a mapping tree entry uses this backend (nsslapd-backend), it raise UnwillingToPerformError
+ If a mapping tree entry uses this backend (nsslapd-backend),
+ it raise ldap.UNWILLING_TO_PERFORM
If 'suffix'/'backend_dn'/'benamebase' are specified.
It uses 'backend_dn' first, then 'suffix', then 'benamebase'.
- If neither 'suffix', 'backend_dn' and 'benamebase' are specified, it raise InvalidArgumentError
@param suffix - suffix of the backend
@param backend_dn - DN of the backend entry
@param bename - 'commonname'/'cn' of the backend (e.g. 'userRoot')
@return None
- @raise InvalidArgumentError - if missing arguments or invalid
- UnwillingToPerformError - if several backends match the argument
- provided suffix does not match backend suffix
- It exists a mapping tree that use that backend
+ @raise ldap.UNWILLING_TO_PERFORM - if several backends match the
+ argument provided suffix does not
+ match backend suffix. It exists a
+ mapping tree that use that backend
"""
# First check the backend exists and retrieved its suffix
- be_ents = self.conn.backend.list(suffix=suffix, backend_dn=backend_dn, bename=bename)
+ be_ents = self.conn.backend.list(suffix=suffix,
+ backend_dn=backend_dn,
+ bename=bename)
if len(be_ents) == 0:
- raise InvalidArgumentError("Unable to retrieve the backend (%r, %r, %r)" % (suffix, backend_dn, bename))
+ raise ldap.UNWILLING_TO_PERFORM(
+ "Unable to retrieve the backend (%r, %r, %r)" %
+ (suffix, backend_dn, bename))
elif len(be_ents) > 1:
for ent in be_ents:
- self.log.fatal("Multiple backend match the definition: %s" % ent.dn)
+ self.log.fatal("Multiple backend match the definition: %s" %
+ ent.dn)
if (not suffix) and (not backend_dn) and (not bename):
- raise InvalidArgumentError("suffix and backend DN and backend name are missing")
- raise UnwillingToPerformError("Not able to identify the backend to delete")
+ raise ldap.UNWILLING_TO_PERFORM(
+ "suffix and backend DN and backend name are missing")
+ raise ldap.UNWILLING_TO_PERFORM(
+ "Not able to identify the backend to delete")
else:
be_ent = be_ents[0]
- be_suffix = be_ent.getValue(BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX])
+ be_suffix = be_ent.getValue(
+ BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX])
# Verify the provided suffix is the one stored in the found backend
if suffix:
if normalizeDN(suffix) != normalizeDN(be_suffix):
- raise UnwillingToPerformError("provided suffix (%s) differs from backend suffix (%s)" % (suffix, be_suffix))
+ raise ldap.UNWILLING_TO_PERFORM(
+ "provided suffix (%s) differs from backend suffix (%s)"
+ % (suffix, be_suffix))
# now check there is no mapping tree for that suffix
mt_ents = self.conn.mappingtree.list(suffix=be_suffix)
if len(mt_ents) > 0:
- raise UnwillingToPerformError("It still exists a mapping tree (%s) for that backend (%s)" % (mt_ents[0].dn, be_ent.dn))
+ raise ldap.UNWILLING_TO_PERFORM(
+ "It still exists a mapping tree (%s) for that backend (%s)" %
+ (mt_ents[0].dn, be_ent.dn))
# Now delete the indexes
- found_bename = be_ent.getValue(BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME])
+ found_bename = be_ent.getValue(
+ BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME])
if not bename:
bename = found_bename
elif bename.lower() != found_bename.lower():
- raise UnwillingToPerformError("Backend name specified (%s) differs from the retrieved one (%s)" % (bename, found_bename))
+ raise ldap.UNWILLING_TO_PERFORM(
+ "Backend name specified (%s) differs from the retrieved " +
+ "one (%s)" % (bename, found_bename))
self.conn.index.delete_all(bename)
@@ -173,11 +192,13 @@ class Backend(object):
"""
Creates backend entry and returns its dn.
- If the properties 'chain-bind-pwd' and 'chain-bind-dn' and 'chain-urls' are specified
- the backend is a chained backend.
- A chaining backend is created under 'cn=chaining database,cn=plugins,cn=config'.
+ If the properties 'chain-bind-pwd' and 'chain-bind-dn' and
+ 'chain-urls' are specified the backend is a chained backend. A
+ chaining backend is created under
+ 'cn=chaining database,cn=plugins,cn=config'.
- A local backend is created under 'cn=ldbm database,cn=plugins,cn=config'
+ A local backend is created under
+ 'cn=ldbm database,cn=plugins,cn=config'
@param suffix - suffix stored in the backend
@param properties - dictionary with properties values
@@ -196,8 +217,7 @@ class Backend(object):
@return backend DN of the created backend
- @raise ValueError - If missing suffix
- InvalidArgumentError - If it already exists a backend for that suffix or a backend with the same DN
+ @raise LDAPError
"""
def _getBackendName(parent):
@@ -207,30 +227,34 @@ class Backend(object):
index = 1
while True:
bename = "local%ddb" % index
- base = "%s=%s,%s" % (BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME], bename, parent)
- scope = ldap.SCOPE_BASE
- filt = "(objectclass=%s)" % BACKEND_OBJECTCLASS_VALUE
- self.log.debug("_getBackendName: baser=%s : fileter=%s" % (base, filt))
+ base = ("%s=%s,%s" %
+ (BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME],
+ bename, parent))
+ filt = "(objectclass=%s)" % BACKEND_OBJECTCLASS_VALUE
+ self.log.debug("_getBackendName: baser=%s : fileter=%s" %
+ (base, filt))
try:
- ents = self.conn.getEntry(base, ldap.SCOPE_BASE, filt)
- except (NoSuchEntryError, ldap.NO_SUCH_OBJECT) as e:
+ self.conn.getEntry(base, ldap.SCOPE_BASE, filt)
+ except (NoSuchEntryError, ldap.NO_SUCH_OBJECT):
self.log.info("backend name will be %s" % bename)
return bename
index += 1
# suffix is mandatory
if not suffix:
- raise ValueError("suffix is mandatory")
+ raise ldap.UNWILLING_TO_PERFORM('Missing Suffix')
else:
nsuffix = normalizeDN(suffix)
# Check it does not already exist a backend for that suffix
ents = self.conn.backend.list(suffix=suffix)
if len(ents) != 0:
- raise InvalidArgumentError("It already exists backend(s) for %s: %s" % (suffix, ents[0].dn))
-
+ raise ldap.ALREADY_EXISTS
# Check if we are creating a local/chained backend
- chained_suffix = properties and (BACKEND_CHAIN_BIND_DN in properties) and (BACKEND_CHAIN_BIND_PW in properties) and (BACKEND_CHAIN_URLS in properties)
+ chained_suffix = (properties and
+ (BACKEND_CHAIN_BIND_DN in properties) and
+ (BACKEND_CHAIN_BIND_PW in properties) and
+ (BACKEND_CHAIN_URLS in properties))
if chained_suffix:
self.log.info("Creating a chaining backend")
dnbase = DN_CHAIN
@@ -247,26 +271,32 @@ class Backend(object):
# Check the future backend name does not already exists
# we can imagine having no backends for 'suffix' but having a backend
# with the same name
- dn = "%s=%s,%s" % (BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME], cn, dnbase)
+ dn = "%s=%s,%s" % (BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME], cn,
+ dnbase)
ents = self.conn.backend.list(backend_dn=dn)
if ents:
- raise InvalidArgumentError("It already exists a backend with that DN: %s" % ents[0].dn)
+ raise ldap.ALREADY_EXISTS("Backend already exists with that DN: %s"
+ % ents[0].dn)
# All checks are done, Time to create the backend
try:
entry = Entry(dn)
entry.update({
- 'objectclass': ['top', 'extensibleObject', BACKEND_OBJECTCLASS_VALUE],
+ 'objectclass': ['top', 'extensibleObject',
+ BACKEND_OBJECTCLASS_VALUE],
BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_NAME]: cn,
BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX]: nsuffix
})
if chained_suffix:
- entry.update({
- BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_CHAIN_URLS]: properties[BACKEND_CHAIN_URLS],
- BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_CHAIN_BIND_DN]: properties[BACKEND_CHAIN_BIND_DN],
- BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_CHAIN_BIND_PW]: properties[BACKEND_CHAIN_BIND_PW]
- })
+ entry.update(
+ {BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_CHAIN_URLS]:
+ properties[BACKEND_CHAIN_URLS],
+ BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_CHAIN_BIND_DN]:
+ properties[BACKEND_CHAIN_BIND_DN],
+ BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_CHAIN_BIND_PW]:
+ properties[BACKEND_CHAIN_BIND_PW]
+ })
self.log.debug("adding entry: %r" % entry)
self.conn.add_s(entry)
@@ -275,22 +305,26 @@ class Backend(object):
raise ldap.ALREADY_EXISTS("%s : %r" % (e, dn))
except ldap.LDAPError as e:
self.log.error("Could not add backend entry: %r" % dn)
+ raise e
backend_entry = self.conn._test_entry(dn, ldap.SCOPE_BASE)
return backend_entry
- def getProperties(self, suffix=None, backend_dn=None, bename=None, properties=None):
+ def getProperties(self, suffix=None, backend_dn=None, bename=None,
+ properties=None):
raise NotImplemented
- def setProperties(self, suffix=None, backend_dn=None, bename=None, properties=None):
+ def setProperties(self, suffix=None, backend_dn=None, bename=None,
+ properties=None):
raise NotImplemented
def toSuffix(self, entry=None, name=None):
'''
Return, for a given backend entry, the suffix values.
- Suffix values are identical from a LDAP point of views. Suffix values may
- be surrounded by ", or containing '\' escape characters.
+ Suffix values are identical from a LDAP point of views.
+ Suffix values may be surrounded by ", or containing '\'
+ escape characters.
@param entry - LDAP entry of the backend
@param name - backend DN
@@ -304,7 +338,8 @@ class Backend(object):
attr_suffix = BACKEND_PROPNAME_TO_ATTRNAME[BACKEND_SUFFIX]
if entry:
if not entry.hasValue(attr_suffix):
- raise ValueError("Entry has no %s attribute %r" % (attr_suffix, entry))
+ raise ValueError("Entry has no %s attribute %r" %
+ (attr_suffix, entry))
return entry.getValues(attr_suffix)
elif name:
filt = "(objectclass=%s)" % BACKEND_OBJECTCLASS_VALUE
@@ -317,7 +352,8 @@ class Backend(object):
raise ldap.NO_SUCH_OBJECT("Backend DN not found: %s" % name)
if not ent.hasValue(attr_suffix):
- raise ValueError("Entry has no %s attribute %r" % (attr_suffix, ent))
+ raise ValueError("Entry has no %s attribute %r" %
+ (attr_suffix, ent))
return ent.getValues(attr_suffix)
else:
raise InvalidArgumentError("entry or name are mandatory")
@@ -331,5 +367,3 @@ class Backend(object):
dn = entries_backend[0].dn
replace = [(ldap.MOD_REPLACE, 'nsslapd-require-index', 'on')]
self.modify_s(dn, replace)
-
-
diff --git a/src/lib389/lib389/mappingTree.py b/src/lib389/lib389/mappingTree.py
index d68ac9271..a154f7a0f 100644
--- a/src/lib389/lib389/mappingTree.py
+++ b/src/lib389/lib389/mappingTree.py
@@ -11,7 +11,7 @@ from lib389._constants import *
from lib389.properties import *
from lib389.utils import suffixfilt, normalizeDN
from lib389 import DirSrv, Entry
-from lib389 import NoSuchEntryError, UnwillingToPerformError, InvalidArgumentError
+from lib389 import NoSuchEntryError, InvalidArgumentError
class MappingTree(object):
@@ -22,7 +22,9 @@ class MappingTree(object):
proxied_methods = 'search_s getEntry'.split()
def __init__(self, conn):
- """@param conn - a DirSrv instance"""
+ """
+ @param conn - a DirSrv instance
+ """
self.conn = conn
self.log = conn.log
@@ -32,11 +34,14 @@ class MappingTree(object):
def list(self, suffix=None, bename=None):
'''
- Returns a search result of the mapping tree entries with all their attributes
+ Returns a search result of the mapping tree entries with all their
+ attributes
- If 'suffix'/'bename' are specified. It uses 'benamebase' first, then 'suffix'.
+ If 'suffix'/'bename' are specified. It uses 'benamebase' first,
+ then 'suffix'.
- If neither 'suffix' and 'bename' are specified, it returns all the mapping tree entries
+ If neither 'suffix' and 'bename' are specified, it returns all
+ the mapping tree entries
@param suffix - suffix of the backend
@param benamebase - backend common name (e.g. 'userRoot')
@@ -54,7 +59,8 @@ class MappingTree(object):
filt = "(objectclass=%s)" % MT_OBJECTCLASS_VALUE
try:
- ents = self.conn.search_s(DN_MAPPING_TREE, ldap.SCOPE_ONELEVEL, filt)
+ ents = self.conn.search_s(DN_MAPPING_TREE, ldap.SCOPE_ONELEVEL,
+ filt)
for ent in ents:
self.log.debug('list: %r' % ent)
except:
@@ -64,19 +70,23 @@ class MappingTree(object):
def create(self, suffix=None, bename=None, parent=None):
'''
- Create a mapping tree entry (under "cn=mapping tree,cn=config"), for the 'suffix'
- and that is stored in 'bename' backend.
- 'bename' backend must exists before creating the mapping tree entry.
+ Create a mapping tree entry (under "cn=mapping tree,cn=config"),
+ for the 'suffix' and that is stored in 'bename' backend.
+ 'bename' backend must exist before creating the mapping tree entry.
- If a 'parent' is provided that means that we are creating a sub-suffix mapping tree.
+ If a 'parent' is provided that means that we are creating a
+ sub-suffix mapping tree.
- @param suffix - suffix mapped by this mapping tree entry. It will be the common name ('cn') of the entry
+ @param suffix - suffix mapped by this mapping tree entry. It will
+ be the common name ('cn') of the entry
@param benamebase - backend common name (e.g. 'userRoot')
@param parent - if provided is a parent suffix of 'suffix'
@return DN of the mapping tree entry
- @raise ldap.NO_SUCH_OBJECT - if the backend entry or parent mapping tree does not exist
+ @raise ldap.NO_SUCH_OBJECT - if the backend entry or parent mapping
+ tree does not exist
+ ValueError - if missing a parameter,
'''
# Check suffix is provided
@@ -95,7 +105,8 @@ class MappingTree(object):
nparent = normalizeDN(parent)
filt = suffixfilt(parent)
try:
- entry = self.conn.getEntry(DN_MAPPING_TREE, ldap.SCOPE_SUBTREE, filt)
+ entry = self.conn.getEntry(DN_MAPPING_TREE, ldap.SCOPE_SUBTREE,
+ filt)
pass
except NoSuchEntryError:
raise ValueError("parent suffix has no mapping tree")
@@ -105,9 +116,10 @@ class MappingTree(object):
# Check if suffix exists, return
filt = suffixfilt(suffix)
try:
- entry = self.conn.getEntry(DN_MAPPING_TREE, ldap.SCOPE_SUBTREE, filt)
+ entry = self.conn.getEntry(DN_MAPPING_TREE, ldap.SCOPE_SUBTREE,
+ filt)
return entry
- except NoSuchEntryError:
+ except ldap.NO_SUCH_OBJECT:
entry = None
#
@@ -121,7 +133,8 @@ class MappingTree(object):
'objectclass': ['top', 'extensibleObject', MT_OBJECTCLASS_VALUE],
'nsslapd-state': 'backend',
# the value in the dn has to be DN escaped
- # internal code will add the quoted value - unquoted value is useful for searching
+ # internal code will add the quoted value - unquoted value is
+ # useful for searching.
MT_PROPNAME_TO_ATTRNAME[MT_SUFFIX]: nsuffix,
MT_PROPNAME_TO_ATTRNAME[MT_BACKEND]: bename
})
@@ -142,22 +155,26 @@ class MappingTree(object):
def delete(self, suffix=None, bename=None, name=None):
'''
- Delete a mapping tree entry (under "cn=mapping tree,cn=config"), for the 'suffix' and
- that is stored in 'benamebase' backend.
+ Delete a mapping tree entry (under "cn=mapping tree,cn=config"),
+ for the 'suffix' and that is stored in 'benamebase' backend.
'benamebase' backend is not changed by the mapping tree deletion.
- If 'name' is specified. It uses it to retrieve the mapping tree to delete
- Else if 'suffix'/'benamebase' are specified. It uses both to retrieve the mapping tree to delete
+ If 'name' is specified. It uses it to retrieve the mapping tree
+ to delete. Else if 'suffix'/'benamebase' are specified. It uses
+ both to retrieve the mapping tree to delete
- @param suffix - suffix mapped by this mapping tree entry. It is the common name ('cn') of the entry
+ @param suffix - suffix mapped by this mapping tree entry. It is
+ the common name ('cn') of the entry
@param benamebase - backend common name (e.g. 'userRoot')
@param name - DN of the mapping tree entry
@return None
@raise ldap.NO_SUCH_OBJECT - the entry is not found
- KeyError if 'name', 'suffix' and 'benamebase' are missing
- UnwillingToPerformError - If the mapping tree has subordinates
+ KeyError if 'name', 'suffix' and
+ 'benamebase' are missing
+ UnwillingToPerformError - If the mapping tree has
+ subordinates
'''
if name:
filt = "(objectclass=%s)" % MT_OBJECTCLASS_VALUE
@@ -165,7 +182,8 @@ class MappingTree(object):
ent = self.conn.getEntry(name, ldap.SCOPE_BASE, filt)
self.log.debug("delete: %s found by its DN" % ent.dn)
except NoSuchEntryError:
- raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" % name)
+ raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" %
+ name)
else:
filt = None
@@ -174,15 +192,21 @@ class MappingTree(object):
if bename:
if filt:
- filt = "(&(%s=%s)%s)" % (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND], bename, filt)
+ filt = ("(&(%s=%s)%s)" %
+ (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND],
+ bename,
+ filt))
else:
- filt = "(%s=%s)" % (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND], bename)
+ filt = ("(%s=%s)" %
+ (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND], bename))
try:
- ent = self.conn.getEntry(DN_MAPPING_TREE, ldap.SCOPE_ONELEVEL, filt)
+ ent = self.conn.getEntry(DN_MAPPING_TREE, ldap.SCOPE_ONELEVEL,
+ filt)
self.log.debug("delete: %s found by with %s" % (ent.dn, filt))
except NoSuchEntryError:
- raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" % name)
+ raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" %
+ name)
#
# At this point 'ent' contains the mapping tree entry to delete
@@ -190,30 +214,39 @@ class MappingTree(object):
# First Check there is no child (replica, replica agreements)
try:
- ents = self.conn.search_s(ent.dn, ldap.SCOPE_SUBTREE, "objectclass=*")
+ ents = self.conn.search_s(ent.dn, ldap.SCOPE_SUBTREE,
+ "objectclass=*")
except:
raise
if len(ents) != 1:
for entry in ents:
- self.log.warning("Error: it exists %s under %s" % (entry.dn, ent.dn))
- raise UnwillingToPerformError("Unable to delete %s, it is not a leaf" % ent.dn)
+ self.log.warning("Error: it exists %s under %s" %
+ (entry.dn, ent.dn))
+ raise ldap.UNWILLING_TO_PERFORM(
+ "Unable to delete %s, it is not a leaf" % ent.dn)
else:
for entry in ents:
self.log.warning("Warning: %s (%s)" % (entry.dn, ent.dn))
self.conn.delete_s(ent.dn)
- def getProperties(self, suffix=None, bename=None, name=None, properties=None):
+ def getProperties(self, suffix=None, bename=None, name=None,
+ properties=None):
'''
Returns a dictionary of the requested properties.
If properties is missing, it returns all the properties.
- The returned properties are those of the 'suffix' and that is stored in 'benamebase' backend.
+ The returned properties are those of the 'suffix' and that is
+ stored in 'benamebase' backend.
- If 'name' is specified. It uses it to retrieve the mapping tree to delete Else if 'suffix'/'benamebase' are specified. It uses both to retrieve the mapping tree to
+ If 'name' is specified. It uses it to retrieve the mapping tree
+ to delete Else if 'suffix'/'benamebase' are specified. It uses
+ both to retrieve the mapping tree to
- If 'name', 'benamebase' and 'suffix' are missing it raise an exception
+ If 'name', 'benamebase' and 'suffix' are missing it raise an
+ exception
- @param suffix - suffix mapped by this mapping tree entry. It is the common name ('cn') of the entry
+ @param suffix - suffix mapped by this mapping tree entry.
+ It is the common name ('cn') of the entry
@param benamebase - backend common name (e.g. 'userRoot')
@param name - DN of the mapping tree entry
@param - properties - list of properties
@@ -229,10 +262,13 @@ class MappingTree(object):
filt = "(objectclass=%s)" % MT_OBJECTCLASS_VALUE
try:
- ent = self.conn.getEntry(name, ldap.SCOPE_BASE, filt, list(MT_PROPNAME_TO_ATTRNAME.values()))
+ ent = self.conn.getEntry(name, ldap.SCOPE_BASE, filt,
+ list(MT_PROPNAME_TO_ATTRNAME.values())
+ )
self.log.debug("delete: %s found by its DN" % ent.dn)
except NoSuchEntryError:
- raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" % name)
+ raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" %
+ name)
else:
filt = None
@@ -241,16 +277,22 @@ class MappingTree(object):
if bename:
if filt:
- filt = "(&(%s=%s)%s)" % (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND], bename, filt)
+ filt = ("(&(%s=%s)%s)" %
+ (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND],
+ bename, filt))
else:
- filt = "(%s=%s)" % (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND], bename)
+ filt = ("(%s=%s)" % (MT_PROPNAME_TO_ATTRNAME[MT_BACKEND],
+ bename))
try:
ent = self.conn.getEntry(DN_MAPPING_TREE, ldap.SCOPE_ONELEVEL,
- filt, list(MT_PROPNAME_TO_ATTRNAME.values()))
+ filt,
+ list(MT_PROPNAME_TO_ATTRNAME.values())
+ )
self.log.debug("delete: %s found by with %s" % (ent.dn, filt))
except NoSuchEntryError:
- raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" % name)
+ raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" %
+ name)
result = {}
attrs = []
@@ -262,15 +304,18 @@ class MappingTree(object):
prop_attr = MT_PROPNAME_TO_ATTRNAME[prop_name]
if not prop_attr:
raise ValueError("Improper property name: %s ", prop_name)
- self.log.debug("Look for attr %s (property: %s)" % (prop_attr, prop_name))
+ self.log.debug("Look for attr %s (property: %s)" %
+ (prop_attr, prop_name))
attrs.append(prop_attr)
# now look for each attribute from the MT entry
for attr in ent.getAttrs():
# given an attribute name retrieve the property name
- props = [k for k, v in six.iteritems(MT_PROPNAME_TO_ATTRNAME) if v.lower() == attr.lower()]
+ props = [k for k, v in six.iteritems(MT_PROPNAME_TO_ATTRNAME)
+ if v.lower() == attr.lower()]
- # If this attribute is present in the MT properties and was requested, adds it to result
+ # If this attribute is present in the MT properties and was
+ # requested, adds it to result.
if len(props) > 0:
if len(attrs) > 0:
if MT_PROPNAME_TO_ATTRNAME[props[0]] in attrs:
@@ -281,14 +326,16 @@ class MappingTree(object):
result[props[0]] = ent.getValues(attr)
return result
- def setProperties(self, suffix=None, bename=None, name=None, properties=None):
+ def setProperties(self, suffix=None, bename=None, name=None,
+ properties=None):
raise NotImplemented()
def toSuffix(self, entry=None, name=None):
'''
Return, for a given mapping tree entry, the suffix values.
- Suffix values are identical from a LDAP point of views. Suffix values may
- be surrounded by ", or containing '\' escape characters.
+ Suffix values are identical from a LDAP point of views.
+ Suffix values may be surrounded by ", or containing '\'
+ escape characters.
@param entry - LDAP entry of the mapping tree
@param name - mapping tree DN
@@ -302,7 +349,8 @@ class MappingTree(object):
attr_suffix = MT_PROPNAME_TO_ATTRNAME[MT_SUFFIX]
if entry:
if not entry.hasValue(attr_suffix):
- raise ValueError("Entry has no %s attribute %r" % (attr_suffix, entry))
+ raise ValueError("Entry has no %s attribute %r" %
+ (attr_suffix, entry))
return entry.getValues(attr_suffix)
elif name:
filt = "(objectclass=%s)" % MT_OBJECTCLASS_VALUE
@@ -312,11 +360,12 @@ class MappingTree(object):
ent = self.conn.getEntry(name, ldap.SCOPE_BASE, filt, attrs)
self.log.debug("toSuffix: %s found by its DN" % ent.dn)
except NoSuchEntryError:
- raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" % name)
+ raise ldap.NO_SUCH_OBJECT("mapping tree DN not found: %s" %
+ name)
if not ent.hasValue(attr_suffix):
- raise ValueError("Entry has no %s attribute %r" % (attr_suffix, ent))
+ raise ValueError("Entry has no %s attribute %r" %
+ (attr_suffix, ent))
return ent.getValues(attr_suffix)
else:
raise InvalidArgumentError("entry or name are mandatory")
-
| 0 |
cffbb308f5dee17679005964cd82b992d07d9aea
|
389ds/389-ds-base
|
[195258] Changes for the internal build
NSPR version: v4.6 -> v4.6.2
NSS version: NSS_3_11_RTM -> NSS_3_11_1_RTM
|
commit cffbb308f5dee17679005964cd82b992d07d9aea
Author: Noriko Hosoi <[email protected]>
Date: Thu Jun 15 01:32:00 2006 +0000
[195258] Changes for the internal build
NSPR version: v4.6 -> v4.6.2
NSS version: NSS_3_11_RTM -> NSS_3_11_1_RTM
diff --git a/component_versions.mk b/component_versions.mk
index 67da0afb9..c9e0f859f 100644
--- a/component_versions.mk
+++ b/component_versions.mk
@@ -52,12 +52,12 @@
# naming scheme.
# NSPR
ifndef NSPR_RELDATE
- NSPR_RELDATE = v4.6
+ NSPR_RELDATE = v4.6.2
endif
# SECURITY (NSS) LIBRARY
ifndef SECURITY_RELDATE
- SECURITY_RELDATE = NSS_3_11_RTM
+ SECURITY_RELDATE = NSS_3_11_1_RTM
endif
# LIBDB
| 0 |
ee96ec73de037ae666edaeef584f8b8e48527ab5
|
389ds/389-ds-base
|
Ticket 48251 - Improve the basic test suite
Description: Refactor basic suite code, because it should
correspond pytest and PEP 8 standarts.
Added a minor fix(that addresses false failures)
written by Mark Reynolds
https://fedorahosted.org/389/ticket/48251
Signed-off-by: Mark Reynolds <[email protected]>
|
commit ee96ec73de037ae666edaeef584f8b8e48527ab5
Author: Simon Pichugin <[email protected]>
Date: Wed Aug 19 17:46:10 2015 +0200
Ticket 48251 - Improve the basic test suite
Description: Refactor basic suite code, because it should
correspond pytest and PEP 8 standarts.
Added a minor fix(that addresses false failures)
written by Mark Reynolds
https://fedorahosted.org/389/ticket/48251
Signed-off-by: Mark Reynolds <[email protected]>
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index d35f7d9dd..0c1b83bf7 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -40,9 +40,8 @@ class TopologyStandalone(object):
@pytest.fixture(scope="module")
def topology(request):
- '''
- This fixture is used to standalone topology for the 'module'.
- '''
+ """This fixture is used to standalone topology for the 'module'."""
+
global installation_prefix
if installation_prefix:
@@ -70,6 +69,11 @@ def topology(request):
# Used to retrieve configuration information (dbdir, confdir...)
standalone.open()
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
# clear the tmp directory
standalone.clearTmpDir(__file__)
@@ -77,27 +81,24 @@ def topology(request):
return TopologyStandalone(standalone)
-def test_basic_init(topology):
- '''
- Initialize our setup
- '''
- #
- # Import the Example LDIF for the tests in this suite
- #
[email protected](scope="module")
+def import_example_ldif(topology):
+ """Import the Example LDIF for the tests in this suite"""
+
log.info('Initializing the "basic" test suite')
import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix)
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, args={TASK_WAIT: True})
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
+ args={TASK_WAIT: True})
except ValueError:
log.error('Online import failed')
assert False
-def test_basic_ops(topology):
- '''
- Test doing adds, mods, modrdns, and deletes
- '''
+def test_basic_ops(topology, import_example_ldif):
+ """Test doing adds, mods, modrdns, and deletes"""
log.info('Running test_basic_ops...')
@@ -113,31 +114,34 @@ def test_basic_ops(topology):
# Adds
#
try:
- topology.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '1',
- 'cn': 'user1',
- 'uid': 'user1',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER1_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '1',
+ 'cn': 'user1',
+ 'uid': 'user1',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER1_DN + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '2',
- 'cn': 'user2',
- 'uid': 'user2',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER2_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '2',
+ 'cn': 'user2',
+ 'uid': 'user2',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER2_DN + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER3_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '3',
- 'cn': 'user3',
- 'uid': 'user3',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER3_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '3',
+ 'cn': 'user3',
+ 'uid': 'user3',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER3_DN + ': error ' + e.message['desc'])
assert False
@@ -146,19 +150,22 @@ def test_basic_ops(topology):
# Mods
#
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description', 'New description')])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description',
+ 'New description')])
except ldap.LDAPError, e:
log.error('Failed to add description: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description', 'Modified description')])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description',
+ 'Modified description')])
except ldap.LDAPError, e:
log.error('Failed to modify description: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description', None)])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description',
+ None)])
except ldap.LDAPError, e:
log.error('Failed to delete description: error ' + e.message['desc'])
assert False
@@ -180,7 +187,8 @@ def test_basic_ops(topology):
# Modrdn - New superior
try:
- topology.standalone.rename_s(USER3_DN, USER3_NEWDN, newsuperior=NEW_SUPERIOR, delold=1)
+ topology.standalone.rename_s(USER3_DN, USER3_NEWDN,
+ newsuperior=NEW_SUPERIOR, delold=1)
except ldap.LDAPError, e:
log.error('Failed to modrdn(new superior) user3: error ' + e.message['desc'])
assert False
@@ -209,10 +217,8 @@ def test_basic_ops(topology):
log.info('test_basic_ops: PASSED')
-def test_basic_import_export(topology):
- '''
- Test online and offline LDIF imports & exports
- '''
+def test_basic_import_export(topology, import_example_ldif):
+ """Test online and offline LDIF imports & exports"""
log.info('Running test_basic_import_export...')
@@ -227,12 +233,14 @@ def test_basic_import_export(topology):
try:
topology.standalone.buildLDIF(50000, import_ldif)
except OSError as e:
- log.fatal('test_basic_import_export: failed to create test ldif, error: %s - %s' % (e.errno, e.strerror))
+ log.fatal('test_basic_import_export: failed to create test ldif,\
+ error: %s - %s' % (e.errno, e.strerror))
assert False
# Online
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif,
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_import_export: Online import failed')
@@ -258,7 +266,8 @@ def test_basic_import_export(topology):
assert False
# Offline export
- if not topology.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,), None, None, None, export_ldif):
+ if not topology.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,),
+ None, None, None, export_ldif):
log.fatal('test_basic_import_export: Failed to run offline db2ldif')
assert False
@@ -267,7 +276,9 @@ def test_basic_import_export(topology):
#
import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix)
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, args={TASK_WAIT: True})
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_import_export: Online import failed')
assert False
@@ -275,10 +286,8 @@ def test_basic_import_export(topology):
log.info('test_basic_import_export: PASSED')
-def test_basic_backup(topology):
- '''
- Test online and offline back and restore
- '''
+def test_basic_backup(topology, import_example_ldif):
+ """Test online and offline back and restore"""
log.info('Running test_basic_backup...')
@@ -286,14 +295,16 @@ def test_basic_backup(topology):
# Test online backup
try:
- topology.standalone.tasks.db2bak(backup_dir=backup_dir, args={TASK_WAIT: True})
+ topology.standalone.tasks.db2bak(backup_dir=backup_dir,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_backup: Online backup failed')
assert False
# Test online restore
try:
- topology.standalone.tasks.bak2db(backup_dir=backup_dir, args={TASK_WAIT: True})
+ topology.standalone.tasks.bak2db(backup_dir=backup_dir,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_backup: Online restore failed')
assert False
@@ -311,10 +322,8 @@ def test_basic_backup(topology):
log.info('test_basic_backup: PASSED')
-def test_basic_acl(topology):
- '''
- Run some basic access control(ACL) tests
- '''
+def test_basic_acl(topology, import_example_ldif):
+ """Run some basic access control(ACL) tests"""
log.info('Running test_basic_acl...')
@@ -325,27 +334,32 @@ def test_basic_acl(topology):
# Add two users
#
try:
- topology.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '1',
- 'cn': 'user 1',
- 'uid': 'user1',
- 'userpassword': PASSWORD})))
+ topology.standalone.add_s(Entry((USER1_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '1',
+ 'cn': 'user 1',
+ 'uid': 'user1',
+ 'userpassword': PASSWORD})))
except ldap.LDAPError, e:
- log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN + ': error ' + e.message['desc'])
+ log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
+ + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '2',
- 'cn': 'user 2',
- 'uid': 'user2',
- 'userpassword': PASSWORD})))
+ topology.standalone.add_s(Entry((USER2_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '2',
+ 'cn': 'user 2',
+ 'uid': 'user2',
+ 'userpassword': PASSWORD})))
except ldap.LDAPError, e:
- log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN + ': error ' + e.message['desc'])
+ log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
+ + ': error ' + e.message['desc'])
assert False
#
- # Add an aci that denies USER1 from doing anything, and also set the default anonymous access
+ # Add an aci that denies USER1 from doing anything,
+ # and also set the default anonymous access
#
try:
topology.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', DENY_ACI)])
@@ -363,7 +377,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=*)')
if entries:
log.fatal('test_basic_acl: User1 was incorrectly able to search the suffix!')
assert False
@@ -379,7 +395,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=user1)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=user1)')
if not entries:
log.fatal('test_basic_acl: User1 incorrectly not able to search the suffix')
assert False
@@ -400,7 +418,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=*)')
if not entries:
log.fatal('test_basic_acl: Root DN incorrectly not able to search the suffix')
assert False
@@ -432,10 +452,8 @@ def test_basic_acl(topology):
log.info('test_basic_acl: PASSED')
-def test_basic_searches(topology):
- '''
- The search results are gathered from testing with Example.ldif
- '''
+def test_basic_searches(topology, import_example_ldif):
+ """The search results are gathered from testing with Example.ldif"""
log.info('Running test_basic_searches...')
@@ -458,9 +476,12 @@ def test_basic_searches(topology):
for (search_filter, search_result) in filters:
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter)
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ search_filter)
if len(entries) != search_result:
- log.fatal('test_basic_searches: An incorrect number of entries was returned from filter (%s): (%d) expected (%d)' %
+ log.fatal('test_basic_searches: An incorrect number of entries\
+ was returned from filter (%s): (%d) expected (%d)' %
(search_filter, len(entries), search_result))
assert False
except ldap.LDAPError, e:
@@ -470,10 +491,10 @@ def test_basic_searches(topology):
log.info('test_basic_searches: PASSED')
-def test_basic_referrals(topology):
- '''
- Set the server to referral mode, and make sure we recive the referal error(10)
- '''
+def test_basic_referrals(topology, import_example_ldif):
+ """Set the server to referral mode,
+ and make sure we recive the referal error(10)
+ """
log.info('Running test_basic_referrals...')
@@ -483,16 +504,20 @@ def test_basic_referrals(topology):
# Set the referral, adn the backend state
#
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-referral',
- 'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
+ topology.standalone.modify_s(SUFFIX_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-referral',
+ 'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
except ldap.LDAPError, e:
log.fatal('test_basic_referrals: Failed to set referral: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-state', 'Referral')])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-state', 'Referral')])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to set backend state: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to set backend state: error '
+ + e.message['desc'])
assert False
#
@@ -516,26 +541,29 @@ def test_basic_referrals(topology):
# Cleanup
#
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-state', 'Backend')])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-state', 'Backend')])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to set backend state: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to set backend state: error '
+ + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE, 'nsslapd-referral', None)])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE,
+ 'nsslapd-referral', None)])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to delete referral: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to delete referral: error '
+ + e.message['desc'])
assert False
topology.standalone.set_option(ldap.OPT_REFERRALS, 1)
log.info('test_basic_referrals: PASSED')
-def test_basic_systemctl(topology):
- '''
- Test systemctl can stop and start the server. Also test that start reports an
+def test_basic_systemctl(topology, import_example_ldif):
+ """Test systemctl can stop and start the server. Also test that start reports an
error when the instance does not start. Only for RPM builds
- '''
+ """
log.info('Running test_basic_systemctl...')
@@ -596,12 +624,13 @@ def test_basic_systemctl(topology):
log.info('Server failed to start as expected')
#
- # Fix the dse.ldif, nad make sure the server starts up,
+ # Fix the dse.ldif, and make sure the server starts up,
# and systemctl correctly identifies the successful start
#
shutil.copy(tmp_dir + 'dse.ldif', config_dir)
log.info('Starting the server...')
rc = os.system(start_ds)
+ time.sleep(10)
log.info('Check the status...')
if rc != 0 or os.system(is_running) != 0:
log.fatal('test_basic_systemctl: Failed to start the server')
@@ -612,17 +641,16 @@ def test_basic_systemctl(topology):
log.info('test_basic_systemctl: PASSED')
-def test_basic_ldapagent(topology):
- '''
- Test that the ldap agnet starts
- '''
+def test_basic_ldapagent(topology, import_example_ldif):
+ """Test that the ldap agent starts"""
log.info('Running test_basic_ldapagent...')
tmp_dir = topology.standalone.getDir(__file__, TMP_DIR)
var_dir = topology.standalone.prefix + '/var'
config_file = tmp_dir + '/agent.conf'
- cmd = 'sudo %s/ldap-agent %s' % (get_sbin_dir(prefix=topology.standalone.prefix), config_file)
+ cmd = 'sudo %s/ldap-agent %s' % (get_sbin_dir(prefix=topology.standalone.prefix),
+ config_file)
agent_config_file = open(config_file, 'w')
agent_config_file.write('agentx-master ' + var_dir + '/agentx/master\n')
@@ -647,10 +675,10 @@ def test_basic_ldapagent(topology):
log.info('test_basic_ldapagent: PASSED')
-def test_basic_dse(topology):
- '''
- Test that the dse.ldif is not wipped out after the process is killed (bug 910581)
- '''
+def test_basic_dse(topology, import_example_ldif):
+ """Test that the dse.ldif is not wipped out
+ after the process is killed (bug 910581)
+ """
log.info('Running test_basic_dse...')
@@ -667,37 +695,8 @@ def test_basic_dse(topology):
log.info('test_basic_dse: PASSED')
-def test_basic_final(topology):
- topology.standalone.delete()
- log.info('Basic test suite PASSED')
-
-
-def run_isolated():
- '''
- run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
- To run isolated without py.test, you need to
- - edit this file and comment '@pytest.fixture' line before 'topology' function.
- - set the installation prefix
- - run this program
- '''
- global installation_prefix
- installation_prefix = None
-
- topo = topology(True)
-
- test_basic_init(topo)
- test_basic_ops(topo)
- test_basic_import_export(topo)
- test_basic_backup(topo)
- test_basic_acl(topo)
- test_basic_searches(topo)
- test_basic_referrals(topo)
- test_basic_systemctl(topo)
- test_basic_ldapagent(topo)
- test_basic_dse(topo)
-
- test_basic_final(topo)
-
-
if __name__ == '__main__':
- run_isolated()
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
| 0 |
17dac298661e4bdead2f453e7a920799daadac56
|
389ds/389-ds-base
|
Issue 6755 - RFE use of Session Tracking Control in replication agreement (#6766)
Bug description:
Replication agreement can use Session Tracking Control
to correlated replication sessions between suppliers
and consumers.
Since https://github.com/389ds/389-ds-base/issues/6367 the
server sides (consumer) logs session tracking control in
access logs.
This ticket is to implement the client side (supplier)
Fix description:
This is described https://www.port389.org/docs/389ds/design/session-identifier-clients.html
Each replication agreement implement a session identifier
string that is sent for each replicated operation
including extended op.
The session identifier is logged, on client side,
if the replication debug log is turned on
fixes: #6755
Reviewed by: Pierre Rogier, Mark Reynolds (Thanks !)
|
commit 17dac298661e4bdead2f453e7a920799daadac56
Author: tbordaz <[email protected]>
Date: Mon Jun 2 16:21:23 2025 +0200
Issue 6755 - RFE use of Session Tracking Control in replication agreement (#6766)
Bug description:
Replication agreement can use Session Tracking Control
to correlated replication sessions between suppliers
and consumers.
Since https://github.com/389ds/389-ds-base/issues/6367 the
server sides (consumer) logs session tracking control in
access logs.
This ticket is to implement the client side (supplier)
Fix description:
This is described https://www.port389.org/docs/389ds/design/session-identifier-clients.html
Each replication agreement implement a session identifier
string that is sent for each replicated operation
including extended op.
The session identifier is logged, on client side,
if the replication debug log is turned on
fixes: #6755
Reviewed by: Pierre Rogier, Mark Reynolds (Thanks !)
diff --git a/dirsrvtests/tests/suites/replication/acceptance_test.py b/dirsrvtests/tests/suites/replication/acceptance_test.py
index 5fd275418..59117bda0 100644
--- a/dirsrvtests/tests/suites/replication/acceptance_test.py
+++ b/dirsrvtests/tests/suites/replication/acceptance_test.py
@@ -616,13 +616,19 @@ def test_password_repl_error(topo_m4, create_entry):
m1 = topo_m4.ms["supplier1"]
m2 = topo_m4.ms["supplier2"]
+ m3 = topo_m4.ms["supplier3"]
+ m4 = topo_m4.ms["supplier4"]
TEST_ENTRY_NEW_PASS = 'new_{}'.format(TEST_ENTRY_NAME)
log.info('Clean the error log')
m2.deleteErrorLogs()
log.info('Set replication loglevel')
+ m1.config.loglevel((ErrorLog.REPLICA,))
m2.config.loglevel((ErrorLog.REPLICA,))
+ m3.config.loglevel((ErrorLog.REPLICA,))
+ m4.config.loglevel((ErrorLog.REPLICA,))
+
log.info('Modifying entry {} - change userpassword on supplier 2'.format(TEST_ENTRY_DN))
test_user_m1 = UserAccount(topo_m4.ms["supplier1"], TEST_ENTRY_DN)
diff --git a/dirsrvtests/tests/suites/session_tracking/session_test.py b/dirsrvtests/tests/suites/session_tracking/session_test.py
index 452ca04fb..ec860598f 100644
--- a/dirsrvtests/tests/suites/session_tracking/session_test.py
+++ b/dirsrvtests/tests/suites/session_tracking/session_test.py
@@ -13,6 +13,7 @@ from lib389 import Entry
from ldap import SCOPE_SUBTREE, ALREADY_EXISTS
from ldap.controls import SimplePagedResultsControl
from ldap.controls.sessiontrack import SessionTrackingControl, SESSION_TRACKING_CONTROL_OID
+from lib389.topologies import topology_m2 as topo_m2
from ldap.extop import ExtendedRequest
from lib389._constants import DEFAULT_SUFFIX, PW_DM, PLUGIN_MEMBER_OF
@@ -1571,6 +1572,66 @@ def test_escaped_session_tracking_extop(topology_st, request):
request.addfinalizer(fin)
+def test_sid_replication(topo_m2, request):
+ """Check that session ID are logged on
+ supplier side (errorLog) and consumer side (accessLog)
+
+ :id: e716b04c-152b-4964-ae7a-b18fb4655cb9
+ :setup: 2 Supplier Instances
+ :steps:
+ 1. Initialize replication
+ 2. Enable replication debug logging
+ 3. Create and update a test user
+ 4. Stop instances
+ 5. Check that 'sid=' exist both on supplier/consumer sides
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ """
+ m1 = topo_m2.ms["supplier1"]
+ m2 = topo_m2.ms["supplier2"]
+
+ m1.config.loglevel((ErrorLog.REPLICA,))
+ m2.config.loglevel((ErrorLog.REPLICA,))
+
+ TEST_ENTRY_NAME = 'sid_test'
+ TEST_ENTRY_DN = 'uid={},{}'.format(TEST_ENTRY_NAME, DEFAULT_SUFFIX)
+ test_user = UserAccount(m1, TEST_ENTRY_DN)
+ test_user.create(properties={
+ 'uid': TEST_ENTRY_NAME,
+ 'cn': TEST_ENTRY_NAME,
+ 'sn': TEST_ENTRY_NAME,
+ 'userPassword': TEST_ENTRY_NAME,
+ 'uidNumber' : '1000',
+ 'gidNumber' : '2000',
+ 'homeDirectory' : '/home/sid_test',
+ })
+
+ # create a large value set so that it is sorted
+ for i in range(1,20):
+ test_user.add('description', 'value {}'.format(str(i)))
+
+ time.sleep(2)
+ m1.stop()
+ m2.stop()
+ log_lines = m1.ds_access_log.match('.* sid=".*')
+ assert len(log_lines) > 0
+ log_lines = m2.ds_error_log.match('.* - sid=".*')
+ assert len(log_lines) > 0
+ m1.start()
+ m2.start()
+
+ def fin():
+ log.info('Deleting entry {}'.format(TEST_ENTRY_DN))
+ test_user.delete()
+ m1.config.loglevel((ErrorLog.DEFAULT,), service='error')
+ m2.config.loglevel((ErrorLog.DEFAULT,), service='error')
+
+ request.addfinalizer(fin)
+
if __name__ == "__main__":
CURRENT_FILE = os.path.realpath(__file__)
pytest.main("-s -v %s" % CURRENT_FILE)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 027d8634d..44f8052ed 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -433,6 +433,8 @@ int agmt_set_transportinfo_from_entry(Repl_Agmt *ra, const Slapi_Entry *e, PRBoo
int agmt_set_port_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
int agmt_set_host_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
const char *agmt_get_long_name(const Repl_Agmt *ra);
+void agmt_set_session_id(Repl_Agmt *ra);
+char *agmt_get_session_id(Repl_Agmt *ra);
int agmt_initialize_replica(const Repl_Agmt *agmt);
void agmt_replica_init_done(const Repl_Agmt *agmt);
void agmt_notify_change(Repl_Agmt *ra, Slapi_PBlock *pb);
@@ -634,6 +636,7 @@ void conn_set_agmt_changed(Repl_Connection *conn);
ConnResult conn_read_result(Repl_Connection *conn, int *message_id);
ConnResult conn_read_result_ex(Repl_Connection *conn, char **retoidp, struct berval **retdatap, LDAPControl ***returned_controls, int send_msgid, int *resp_msgid, int noblock);
LDAP *conn_get_ldap(Repl_Connection *conn);
+const Repl_Agmt *conn_get_agmt(Repl_Connection *conn);
void conn_lock(Repl_Connection *conn);
void conn_unlock(Repl_Connection *conn);
void conn_delete_internal_ext(Repl_Connection *conn);
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c
index 6ffb074d4..c818c5857 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -58,6 +58,9 @@
#include "slapi-plugin.h"
#include "slap.h"
#include "../../slapd/back-ldbm/dbimpl.h" /* for dblayer_is_lmdb */
+#include <pk11func.h>
+#include <pk11pqg.h>
+#include <plbase64.h>
#define DEFAULT_TIMEOUT 120 /* (seconds) default outbound LDAP connection */
#define DEFAULT_FLOWCONTROL_WINDOW 1000 /* #entries sent without acknowledgment (bdb) */
@@ -95,6 +98,10 @@ typedef struct repl5agmt
const Slapi_DN *dn; /* DN of replication agreement entry */
const Slapi_RDN *rdn; /* RDN of replication agreement entry */
char *long_name; /* Long name (rdn + host, port) of entry, for logging */
+ int session_id_cnt; /* use to differentiate sessions */
+ char *session_id_prefix; /* use for debugging purpose on server/client sides */
+#define SESSION_ID_STR_SZ 15
+ char session_id[SESSION_ID_STR_SZ + 49];
Repl_Protocol *protocol; /* Protocol object - manages protocol */
struct changecounter **changecounters; /* changes sent/skipped since server start up */
int64_t num_changecounters;
@@ -180,7 +187,87 @@ nsds5ReplicaBusyWaitTime - time to wait after getting a REPLICA BUSY from the co
nsds5ReplicaSessionPauseTime - time to pause after sending updates to allow another supplier to send
*/
+/* It sets various fields related to client side (repl_agmt)
+ * of the session tracking
+ * - session_id_cnt (counting the the outbound connection)
+ * - session_tracking_supported (a flag stating if the server side support SID)
+ * - session_id_prefix (fixed part of the session identifier for this repl_agmt)
+ */
+static void
+agmt_init_session_id(Repl_Agmt *ra)
+{
+ char hash_out[HASH_LENGTH_MAX] = {0};
+ char *enc = NULL;
+ char *root = NULL; /* e.g. dc=example,dc=com */
+ char *host = NULL; /* e.g. localhost.domain */
+ char port[10]; /* e.g. 389 */
+ char sport[10]; /* e.g. 636 */
+ char *hash_in;
+ int32_t max_str_sid = SESSION_ID_STR_SZ - 4;
+
+ if (ra == NULL) {
+ goto fail;
+ }
+ ra->session_id_cnt = 1;
+ root = slapi_ch_strdup(slapi_sdn_get_dn(ra->replarea));
+ if (root == NULL) {
+ root = slapi_ch_strdup("unknown suffix");
+ }
+ host = get_localhost_DNS();
+ if (host == NULL) {
+ host = slapi_ch_strdup("unknown host");
+ }
+ snprintf(port, sizeof(port), "%d", config_get_port());
+ snprintf(sport, sizeof(sport),"%d", config_get_secureport());
+ hash_in = slapi_ch_calloc(1, strlen(root) + strlen(host) + strlen(port) + strlen(sport) + 1);
+ if (hash_in == NULL) {
+ goto fail;
+ }
+ sprintf(hash_in, "%s%s%s%s", root, host, port, sport);
+ PK11_HashBuf(SEC_OID_SHA1, (unsigned char *)hash_out, (unsigned char *)hash_in, strlen(hash_in));
+
+ if ((enc = slapi_ch_calloc(LDIF_BASE64_LEN(SHA1_LENGTH) + 1, sizeof(char))) == NULL) {
+ goto fail;
+ }
+ (void)PL_Base64Encode(hash_out, SHA1_LENGTH, enc);
+ goto done;
+
+fail:
+ enc = slapi_ch_strdup("dummyID");
+
+done:
+ if (hash_in) {
+ slapi_ch_free_string(&hash_in);
+ }
+ if (root) {
+ slapi_ch_free_string(&root);
+ }
+ if (host) {
+ slapi_ch_free_string(&host);
+ }
+ if (strlen(enc) > max_str_sid) {
+ enc[max_str_sid] = '\0';
+ }
+ ra->session_id_prefix = enc;
+ sprintf(ra->session_id, "%s ---", ra->session_id_prefix);
+}
+
+void
+agmt_set_session_id(Repl_Agmt *ra)
+{
+ if (ra->session_id_cnt == 999) {
+ ra->session_id_cnt = 1;
+ } else {
+ ra->session_id_cnt++;
+ }
+ sprintf(ra->session_id, "%s %3d", ra->session_id_prefix, ra->session_id_cnt);
+}
+char *
+agmt_get_session_id(Repl_Agmt *ra)
+{
+ return(ra->session_id);
+}
/*
* Validate an agreement, making sure that it's valid.
* Return 1 if the agreement is valid, 0 otherwise.
@@ -500,6 +587,8 @@ agmt_new_from_entry(Slapi_Entry *e)
}
ra->long_name = slapi_ch_smprintf("agmt=\"%s\" (%s:%" PRId64 ")", agmtname, hostname, ra->port);
}
+ /* init the RA session id structs */
+ agmt_init_session_id(ra);
/* DBDB: review this code */
if (slapi_entry_attr_hasvalue(e, "objectclass", "nsDSWindowsReplicationAgreement")) {
@@ -742,6 +831,7 @@ agmt_delete(void **rap)
}
schedule_destroy(ra->schedule);
slapi_ch_free_string(&ra->long_name);
+ slapi_ch_free_string(&ra->session_id_prefix);
slapi_counter_destroy(&ra->protocol_timeout);
diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c
index 690241ebd..1799a7df3 100644
--- a/ldap/servers/plugins/replication/repl5_connection.c
+++ b/ldap/servers/plugins/replication/repl5_connection.c
@@ -732,14 +732,26 @@ perform_operation(Repl_Connection *conn, int optype, const char *dn, LDAPMod **a
{
int rc = -1;
ConnResult return_value = CONN_OPERATION_FAILED;
- LDAPControl *server_controls[3];
+ LDAPControl *session_tracking_control = NULL;
+ LDAPControl *server_controls[4];
/* LDAPControl **loc_returned_controls; */
const char *op_string = NULL;
int msgid = 0;
+ int control_idx = 0;
- server_controls[0] = &manageDSAITControl;
- server_controls[1] = update_control;
- server_controls[2] = NULL;
+ server_controls[control_idx] = &manageDSAITControl;
+ control_idx++;
+ if (update_control) {
+ server_controls[control_idx] = update_control;
+ control_idx++;
+ }
+ if (create_sessiontracking_ctrl((const char *) agmt_get_session_id((Repl_Agmt *) conn->agmt), &session_tracking_control) == 0) {
+ server_controls[control_idx] = session_tracking_control;
+ control_idx++;
+ server_controls[control_idx] = NULL;
+ } else {
+ server_controls[control_idx] = NULL;
+ }
/*
* Lock the conn to prevent the result reader thread
@@ -758,6 +770,9 @@ perform_operation(Repl_Connection *conn, int optype, const char *dn, LDAPMod **a
"perform_operation - %s - Connection is not available (%d)\n",
agmt_get_long_name(conn->agmt),
return_value);
+ if (session_tracking_control) {
+ ldap_control_free(session_tracking_control);
+ }
return return_value;
}
conn->last_operation = optype;
@@ -827,6 +842,9 @@ perform_operation(Repl_Connection *conn, int optype, const char *dn, LDAPMod **a
if (message_id) {
*message_id = msgid;
}
+ if (session_tracking_control) {
+ ldap_control_free(session_tracking_control);
+ }
return return_value;
}
@@ -1204,6 +1222,7 @@ conn_connect_with_bootstrap(Repl_Connection *conn, PRBool bootstrap)
(secure == SLAPI_LDAP_INIT_FLAG_startTLS) ? "startTLS " : "");
goto done;
}
+ agmt_set_session_id((Repl_Agmt *) conn->agmt);
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
"conn_connect - %s - binddn = %s, passwd = %s\n",
@@ -1837,6 +1856,15 @@ conn_get_ldap(Repl_Connection *conn)
}
}
+const Repl_Agmt *
+conn_get_agmt(Repl_Connection *conn)
+{
+ if (conn) {
+ return conn->agmt;
+ } else {
+ return NULL;
+ }
+}
void
conn_set_agmt_changed(Repl_Connection *conn)
{
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
index 66a61f6e0..0af96e0b0 100644
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
@@ -325,8 +325,8 @@ repl5_inc_result_threadmain(void *param)
conn_get_error_ex(conn, &operation_code, &connection_error, &ldap_error_string);
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "repl5_inc_result_threadmain - Result %d, %d, %d, %d, %s\n",
- operation_code, connection_error, conres, message_id, ldap_error_string);
+ "repl5_inc_result_threadmain - sid=\"%s\" - Result %d, %d, %d, %d, %s\n",
+ agmt_get_session_id(rd->prp->agmt), operation_code, connection_error, conres, message_id, ldap_error_string);
return_value = repl5_inc_update_from_op_result(rd->prp, conres, connection_error,
csn_str, uniqueid, replica_id, &should_finish,
&(rd->num_changes_sent));
@@ -480,8 +480,8 @@ repl5_inc_waitfor_async_results(result_data *rd)
PR_Lock(rd->lock);
/* Are we caught up ? */
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "repl5_inc_waitfor_async_results - %d %d\n",
- rd->last_message_id_received, rd->last_message_id_sent);
+ "repl5_inc_waitfor_async_results - sid=\"%s\" - %d %d\n",
+ agmt_get_session_id((Repl_Agmt *) rd->prp->agmt), rd->last_message_id_received, rd->last_message_id_sent);
if (rd->last_message_id_received >= rd->last_message_id_sent) {
/* If so then we're done */
done = 1;
@@ -896,8 +896,8 @@ repl5_inc_run(Private_Repl_Protocol *prp)
next_fire_time = backoff_step(prp_priv->backoff);
/* And go back to sleep */
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "repl5_inc_run - %s: Replication session backing off for %ld seconds\n",
- agmt_get_long_name(prp->agmt), next_fire_time - now);
+ "repl5_inc_run - sid=\"%s\" - %s: Replication session backing off for %ld seconds\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt), next_fire_time - now);
protocol_sleep(prp, 0);
} else {
/* Destroy the backoff timer, since we won't need it anymore */
@@ -1117,8 +1117,8 @@ repl5_inc_run(Private_Repl_Protocol *prp)
/* the while loop is so that we don't just sleep and sleep if an
* event comes in that we should handle immediately (like shutdown) */
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "repl5_inc_run - %s: Pausing updates for %ld seconds to allow other senders to update receiver\n",
- agmt_get_long_name(prp->agmt), pausetime);
+ "repl5_inc_run - sid=\"%s\" - %s: Pausing updates for %ld seconds to allow other senders to update receiver\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt), pausetime);
while (loops-- && !(PROTOCOL_IS_SHUTDOWN(prp))) {
DS_Sleep(PR_SecondsToInterval(1));
}
@@ -1184,8 +1184,8 @@ repl5_inc_run(Private_Repl_Protocol *prp)
break;
}
- slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "repl5_inc_run - %s: State: %s -> %s\n",
- agmt_get_long_name(prp->agmt), state2name(current_state), state2name(next_state));
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "repl5_inc_run - sid=\"%s\" - %s: State: %s -> %s\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt), state2name(current_state), state2name(next_state));
current_state = next_state;
} while (!done);
@@ -1310,8 +1310,8 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m
} else {
if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "replay_update - %s: Sending %s operation (dn=\"%s\" csn=%s)\n",
- agmt_get_long_name(prp->agmt),
+ "replay_update - sid=\"%s\" - %s: Sending %s operation (dn=\"%s\" csn=%s)\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt),
op2string(op->operation_type), REPL_GET_DN(&op->target_address),
csn_as_string(op->csn, PR_FALSE, csn_str));
}
@@ -1397,14 +1397,14 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m
if (CONN_OPERATION_SUCCESS == return_value) {
if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "replay_update - %s: Receiver successfully sent operation with csn %s\n",
- agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str));
+ "replay_update - sid=\"%s\" - %s: Receiver successfully sent operation with csn %s\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str));
}
} else {
if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "replay_update - %s: Receiver could not replay operation with csn %s\n",
- agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str));
+ "replay_update - sid=\"%s\" - %s: Receiver could not replay operation with csn %s\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str));
}
}
return return_value;
@@ -1600,8 +1600,8 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
break;
case CL5_NOTFOUND: /* we have no changes to send */
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "send_updates - %s: No changes to send\n",
- agmt_get_long_name(prp->agmt));
+ "send_updates - sid=\"%s\" - %s: No changes to send\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt));
return_value = UPDATE_NO_MORE_UPDATES;
break;
case CL5_MEMORY_ERROR: /* memory allocation failed */
@@ -1812,8 +1812,8 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
break;
case CL5_NOTFOUND:
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "send_updates - %s: No more updates to send (cl5GetNextOperationToReplay)\n",
- agmt_get_long_name(prp->agmt));
+ "send_updates - sid=\"%s\" - %s: No more updates to send (cl5GetNextOperationToReplay)\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt));
return_value = UPDATE_NO_MORE_UPDATES;
finished = 1;
break;
@@ -1867,8 +1867,8 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
return_value = UPDATE_YIELD;
finished = 1;
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "send_updates - Aborting send_updates...(%s)\n",
- agmt_get_long_name(rd->prp->agmt));
+ "send_updates - sid=\"%s\" - Aborting send_updates...(%s)\n",
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(rd->prp->agmt));
}
}
@@ -1912,9 +1912,9 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
PR_Lock(rd->lock);
if (rd->flowcontrol_detection) {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "send_updates - %s: Incremental update flow control triggered %d times\n"
+ "send_updates - sid=\"%s\" - %s: Incremental update flow control triggered %d times\n"
"You may increase %s and/or decrease %s in the replica agreement configuration\n",
- agmt_get_long_name(prp->agmt),
+ agmt_get_session_id((Repl_Agmt *) prp->agmt), agmt_get_long_name(prp->agmt),
rd->flowcontrol_detection,
type_nsds5ReplicaFlowControlPause,
type_nsds5ReplicaFlowControlWindow);
diff --git a/ldap/servers/slapd/control.c b/ldap/servers/slapd/control.c
index 5efdf75fe..f8744901a 100644
--- a/ldap/servers/slapd/control.c
+++ b/ldap/servers/slapd/control.c
@@ -167,6 +167,37 @@ slapi_get_supported_controls_copy(char ***ctrloidsp, unsigned long **ctrlopsp)
return (0);
}
+int
+create_sessiontracking_ctrl(const char *session_tracking_id, LDAPControl **session_tracking_ctrl)
+{
+ BerElement *ctrlber = NULL;
+ char *undefined_sid = "undefined sid";
+ char *sid;
+ int rc = 0;
+ int tag;
+ LDAPControl *ctrl = NULL;
+
+ if (session_tracking_id) {
+ sid = session_tracking_id;
+ } else {
+ sid = undefined_sid;
+ }
+ ctrlber = ber_alloc();
+ tag = ber_printf( ctrlber, "{nnno}", sid, strlen(sid));
+ if (rc == LBER_ERROR) {
+ tag = -1;
+ goto done;
+ }
+ slapi_build_control(LDAP_CONTROL_X_SESSION_TRACKING, ctrlber, 0, &ctrl);
+ *session_tracking_ctrl = ctrl;
+
+done:
+ if (ctrlber) {
+ ber_free(ctrlber, 1);
+ }
+ return rc;
+}
+
/* Parse the Session Tracking control
* see https://datatracker.ietf.org/doc/html/draft-wahl-ldap-session-03
* LDAPString ::= OCTET STRING -- UTF-8 encoded
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 415c81f0c..184bb3334 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -5599,6 +5599,7 @@ int slapi_get_supported_controls_copy(char ***ctrloidsp,
unsigned long **ctrlopsp);
int slapi_build_control(char *oid, BerElement *ber, char iscritical, LDAPControl **ctrlp);
int slapi_build_control_from_berval(char *oid, struct berval *bvp, char iscritical, LDAPControl **ctrlp);
+int create_sessiontracking_ctrl(const char *session_tracking_id, LDAPControl **session_tracking_ctrl);
/* Given an array of controls e.g. LDAPControl **ctrls, add the given
control to the end of the array, growing the array with realloc
| 0 |
0cea6d717bfc212ca83635b3008f844b2c2e031e
|
389ds/389-ds-base
|
Bug 697027 - 4 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 4]
Description: Removing unnecessary slapi_ch_strdup calls.
Adding slapi_ch_free_string to free password, binddn, binddn2
and url to cb_instance_free.
|
commit 0cea6d717bfc212ca83635b3008f844b2c2e031e
Author: Noriko Hosoi <[email protected]>
Date: Fri Apr 15 10:54:20 2011 -0700
Bug 697027 - 4 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 4]
Description: Removing unnecessary slapi_ch_strdup calls.
Adding slapi_ch_free_string to free password, binddn, binddn2
and url to cb_instance_free.
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 9a54004e9..e3cb932b2 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -214,7 +214,7 @@ static cb_backend_instance * cb_instance_alloc(cb_backend * cb, char * name, cha
inst->monitor_availability.cpt = 0 ; /* set up the failed conn counter to 0 */
/* create RW lock to protect the config */
- inst->rwl_config_lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, slapi_ch_strdup(name));
+ inst->rwl_config_lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, name);
/* quick hack */
/* put a ref to the config lock in the pool */
@@ -262,6 +262,10 @@ void cb_instance_free(cb_backend_instance * inst) {
{
cb_close_conn_pool(inst->pool);
slapi_destroy_condvar(inst->pool->conn.conn_list_cv);
+ slapi_ch_free_string(&inst->pool->password);
+ slapi_ch_free_string(&inst->pool->binddn);
+ slapi_ch_free_string(&inst->pool->binddn2);
+ slapi_ch_free_string(&inst->pool->url);
slapi_destroy_mutex(inst->pool->conn.conn_list_mutex);
slapi_ch_free((void **) &inst->pool);
}
@@ -1869,7 +1873,7 @@ int cb_instance_add_config_callback(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entr
Slapi_PBlock *aPb=NULL;
- inst->inst_be = slapi_be_new(CB_CHAINING_BACKEND_TYPE,slapi_ch_strdup(inst->inst_name),0,0);
+ inst->inst_be = slapi_be_new(CB_CHAINING_BACKEND_TYPE,inst->inst_name,0,0);
aPb=slapi_pblock_new();
slapi_pblock_set(aPb, SLAPI_PLUGIN, inst->backend_type->plugin);
slapi_be_setentrypoint(inst->inst_be,0,(void *)NULL,aPb);
| 0 |
9225222f48f0374fb958c7f14ecc463ede3a61c2
|
389ds/389-ds-base
|
Issue 48056 - Add docstrings to basic test suite
Description: Add and refactor the basic test suite docstrings
for creating test plans.
https://pagure.io/389-ds-base/issue/48056
Reviewed by: Dear Simon Pichugin
Signed-off-by: Simon Pichugin <[email protected]>
|
commit 9225222f48f0374fb958c7f14ecc463ede3a61c2
Author: Amita Sharma <[email protected]>
Date: Wed Aug 16 18:59:18 2017 +0530
Issue 48056 - Add docstrings to basic test suite
Description: Add and refactor the basic test suite docstrings
for creating test plans.
https://pagure.io/389-ds-base/issue/48056
Reviewed by: Dear Simon Pichugin
Signed-off-by: Simon Pichugin <[email protected]>
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py
index 1a35efed2..21f69bade 100644
--- a/dirsrvtests/tests/suites/basic/basic_test.py
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
@@ -6,16 +6,18 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
#
+
+"""
+ :Requirement: Basic Directory Server Operations
+"""
+
from subprocess import check_output
-import time
-import ldap.sasl
import pytest
from lib389.tasks import *
from lib389.utils import *
-from lib389.topologies import topology_st
-
from lib389._constants import DN_DM, PASSWORD, PW_DM
+from lib389.topologies import topology_st
log = logging.getLogger(__name__)
@@ -87,10 +89,25 @@ def rootdse_attr(topology_st, request):
def test_basic_ops(topology_st, import_example_ldif):
- """Test doing adds, mods, modrdns, and deletes"""
+ """Tests adds, mods, modrdns, and deletes operations
- log.info('Running test_basic_ops...')
+ :id: 33f97f55-60bf-46c7-b880-6c488517ae19
+
+ :setup: Standalone instance
+ :steps:
+ 1. Add 3 test users USER1, USER2 and USER3 to database
+ 2. Modify (ADD, REPLACE and DELETE) description for USER1 in database
+ 3. Rename USER1, USER2 and USER3 using Modrds
+ 4. Delete test entries USER1, USER2 and USER3
+
+ :expectedresults:
+ 1. Add operation should PASS.
+ 2. Modify operations should PASS.
+ 3. Rename operations should PASS.
+ 4. Delete operations should PASS.
+ """
+ log.info('Running test_basic_ops...')
USER1_NEWDN = 'cn=user1'
USER2_NEWDN = 'cn=user2'
USER3_NEWDN = 'cn=user3'
@@ -100,8 +117,7 @@ def test_basic_ops(topology_st, import_example_ldif):
USER3_RDN_DN = 'cn=user3,' + NEW_SUPERIOR # New superior test
#
- # Adds
- #
+ # Adds#
try:
topology_st.standalone.add_s(Entry((USER1_DN,
{'objectclass': "top extensibleObject".split(),
@@ -172,16 +188,14 @@ def test_basic_ops(topology_st, import_example_ldif):
topology_st.standalone.rename_s(USER2_DN, USER2_NEWDN, delold=0)
except ldap.LDAPError as e:
log.error('Failed to modrdn user2: error ' + e.message['desc'])
- assert False
+ assert False # Modrdn - New superior
- # Modrdn - New superior
try:
topology_st.standalone.rename_s(USER3_DN, USER3_NEWDN,
newsuperior=NEW_SUPERIOR, delold=1)
except ldap.LDAPError as e:
log.error('Failed to modrdn(new superior) user3: error ' + e.message['desc'])
assert False
-
#
# Deletes
#
@@ -202,12 +216,32 @@ def test_basic_ops(topology_st, import_example_ldif):
except ldap.LDAPError as e:
log.error('Failed to delete test entry3: ' + e.message['desc'])
assert False
-
log.info('test_basic_ops: PASSED')
def test_basic_import_export(topology_st, import_example_ldif):
- """Test online and offline LDIF imports & exports"""
+ """Test online and offline LDIF import & export
+
+ :id: 3ceeea11-9235-4e20-b80e-7203b2c6e149
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Generate a test ldif (50k entries)
+ 2. Import test ldif file using Online import.
+ 3. Import test ldif file using Offline import (ldif2db).
+ 4. Export test ldif file using Online export.
+ 5. Export test ldif file using Offline export (db2ldif).
+ 6. Cleanup - Import the Example LDIF for the other tests in this suite
+
+ :expectedresults:
+ 1. Test ldif file creation should PASS.
+ 2. Online import should PASS.
+ 3. Offline import should PASS.
+ 4. Online export should PASS.
+ 5. Offline export should PASS.
+ 6. Cleanup should PASS.
+ """
log.info('Running test_basic_import_export...')
@@ -224,7 +258,7 @@ def test_basic_import_export(topology_st, import_example_ldif):
topology_st.standalone.buildLDIF(50000, import_ldif)
except OSError as e:
log.fatal('test_basic_import_export: failed to create test ldif,\
- error: %s - %s' % (e.errno, e.strerror))
+ error: %s - %s' % (e.errno, e.strerror))
assert False
# Online
@@ -284,7 +318,24 @@ def test_basic_import_export(topology_st, import_example_ldif):
def test_basic_backup(topology_st, import_example_ldif):
- """Test online and offline back and restore"""
+ """Tests online and offline backup and restore
+
+ :id: 0e9d91f8-8748-40b6-ab03-fbd1998eb985
+
+ :setup: Standalone instance and import example.ldif
+
+ :steps:
+ 1. Test online backup using db2bak.
+ 2. Test online restore using bak2db.
+ 3. Test offline backup using db2bak.
+ 4. Test offline restore using bak2db.
+
+ :expectedresults:
+ 1. Online backup should PASS.
+ 2. Online restore should PASS.
+ 3. Offline backup should PASS.
+ 4. Offline restore should PASS.
+ """
log.info('Running test_basic_backup...')
@@ -322,10 +373,32 @@ def test_basic_backup(topology_st, import_example_ldif):
def test_basic_acl(topology_st, import_example_ldif):
- """Run some basic access control(ACL) tests"""
+ """Run some basic access control (ACL) tests
+
+ :id: 4f4e705f-32f4-4065-b3a8-2b0c2525798b
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Add two test users USER1_DN and USER2_DN.
+ 2. Add an aci that denies USER1 from doing anything.
+ 3. Set the default anonymous access for USER2.
+ 4. Try searching entries using USER1.
+ 5. Try searching entries using USER2.
+ 6. Try searching entries using root dn.
+ 7. Cleanup - delete test users and test ACI.
+
+ :expectedresults:
+ 1. Test Users should be added.
+ 2. ACI should be added.
+ 3. This operation should PASS.
+ 4. USER1 should not be able to search anything.
+ 5. USER2 should be able to search everything except password.
+ 6. RootDN should be allowed to search everything.
+ 7. Cleanup should PASS.
+ """
log.info('Running test_basic_acl...')
- topology_st.standalone.start()
DENY_ACI = ('(targetattr = "*") (version 3.0;acl "deny user";deny (all)' +
'(userdn = "ldap:///' + USER1_DN + '");)')
@@ -409,7 +482,7 @@ def test_basic_acl(topology_st, import_example_ldif):
log.fatal('test_basic_acl: Search for user1 failed(as user2): ' + e.message['desc'])
assert False
- # Make sure Root DN can also search (this also resets the bind dn to the
+ # Make sure RootDN can also search (this also resets the bind dn to the
# Root DN for future operations)
try:
topology_st.standalone.simple_bind_s(DN_DM, PW_DM)
@@ -453,7 +526,20 @@ def test_basic_acl(topology_st, import_example_ldif):
def test_basic_searches(topology_st, import_example_ldif):
- """The search results are gathered from testing with Example.ldif"""
+ """Tests basic search operations with filters.
+
+ :id: 426a59ff-49b8-4a70-b377-0c0634a29b6f
+
+ :setup: Standalone instance, add example.ldif to the database
+
+ :steps:
+ 1. Execute search command while using different filters.
+ 2. Check number of entries returned by search filters.
+
+ :expectedresults:
+ 1. Search command should PASS.
+ 2. Number of result entries returned should match number of the database entries according to the search filter.
+ """
log.info('Running test_basic_searches...')
@@ -481,7 +567,7 @@ def test_basic_searches(topology_st, import_example_ldif):
search_filter)
if len(entries) != search_result:
log.fatal('test_basic_searches: An incorrect number of entries\
- was returned from filter (%s): (%d) expected (%d)' %
+ was returned from filter (%s): (%d) expected (%d)' %
(search_filter, len(entries), search_result))
assert False
except ldap.LDAPError as e:
@@ -492,16 +578,33 @@ def test_basic_searches(topology_st, import_example_ldif):
def test_basic_referrals(topology_st, import_example_ldif):
- """Set the server to referral mode,
- and make sure we recive the referal error(10)
+ """Test LDAP server in referral mode.
+
+ :id: c586aede-7ac3-4e8d-a1cf-bfa8b8d78cc2
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Set the referral and the backenidealyd state
+ 2. Set backend state to referral mode.
+ 3. Set server to not follow referral.
+ 4. Search using referral.
+ 5. Make sure server can restart in referral mode.
+ 6. Cleanup - Delete referral.
+
+ :expectedresults:
+ 1. Set the referral, and the backend state should PASS.
+ 2. Set backend state to referral mode should PASS.
+ 3. Set server to not follow referral should PASS.
+ 4. referral error(10) should occur.
+ 5. Restart should PASS.
+ 6. Cleanup should PASS.
"""
log.info('Running test_basic_referrals...')
-
SUFFIX_CONFIG = 'cn="dc=example,dc=com",cn=mapping tree,cn=config'
-
#
- # Set the referral, adn the backend state
+ # Set the referral, and the backend state
#
try:
topology_st.standalone.modify_s(SUFFIX_CONFIG,
@@ -561,8 +664,27 @@ def test_basic_referrals(topology_st, import_example_ldif):
def test_basic_systemctl(topology_st, import_example_ldif):
- """Test systemctl/lib389 can stop and start the server. Also test that start reports an
- error when the instance does not start. Only for RPM builds
+ """Tests systemctl/lib389 can stop and start the server.
+
+ :id: a92a7438-ecfa-4583-a89c-5fbfc0220b69
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Stop the server.
+ 2. Start the server.
+ 3. Stop the server, break the dse.ldif and dse.ldif.bak, so a start fails.
+ 4. Verify that systemctl detects the failed start.
+ 5. Fix the dse.ldif, and make sure the server starts up.
+ 6. Verify systemctl correctly identifies the successful start.
+
+ :expectedresults:
+ 1. Server should be stopped.
+ 2. Server should start
+ 3. Stop should work but start after breaking dse.ldif should fail.
+ 4. Systemctl should be able to detect the failed start.
+ 5. Server should start.
+ 6. Systemctl should be able to detect the successful start.
"""
log.info('Running test_basic_systemctl...')
@@ -621,7 +743,20 @@ def test_basic_systemctl(topology_st, import_example_ldif):
def test_basic_ldapagent(topology_st, import_example_ldif):
- """Test that the ldap agent starts"""
+ """Tests that the ldap agent starts
+
+ :id: da1d1846-8fc4-4b8c-8e53-4c9c16eff1ba
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Start SNMP ldap agent using command.
+ 2. Cleanup - Kill SNMP agent process.
+
+ :expectedresults:
+ 1. SNMP agent should start.
+ 2. SNMP agent process should be successfully killed.
+ """
log.info('Running test_basic_ldapagent...')
@@ -653,10 +788,22 @@ def test_basic_ldapagent(topology_st, import_example_ldif):
def test_basic_dse(topology_st, import_example_ldif):
- """Test that the dse.ldif is not wipped out
- after the process is killed (bug 910581)
- """
+ """Tests that the dse.ldif is not wiped out after the process is killed (bug 910581)
+
+ :id: 10f141da-9b22-443a-885c-87271dcd7a59
+ :setup: Standalone instance
+
+ :steps:
+ 1. Check out pid of ns-slapd process and Kill ns-slapd process.
+ 2. Check the contents of dse.ldif file.
+ 3. Start server.
+
+ :expectedresults:
+ 1. ns-slapd process should be killed.
+ 2. dse.ldif should not be corrupted.
+ 3. Server should start successfully.
+ """
log.info('Running test_basic_dse...')
dse_file = topology_st.standalone.confdir + '/dse.ldif'
@@ -676,13 +823,24 @@ def test_basic_dse(topology_st, import_example_ldif):
@pytest.mark.parametrize("rootdse_attr_name", ROOTDSE_DEF_ATTR_LIST)
def test_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr_name):
- """Tests that operational attributes
- are not returned by default in rootDSE searches
+ """Tests that operational attributes are not returned by default in rootDSE searches
+
+ :id: 4fee33cc-4019-4c27-89e8-998e6c770dc0
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Make an ldapsearch for rootdse attribute
+ 2. Check the returned entries.
+
+ :expectedresults:
+ 1. Search should not fail
+ 2. Operational attributes should not be returned.
"""
topology_st.standalone.start()
- log.info(" Assert rootdse search hasn't %s attr" % rootdse_attr_name)
+ log.info(" Assert rootdse search hasn't %s attr" % rootdse_attr_name)
try:
entries = topology_st.standalone.search_s("", ldap.SCOPE_BASE)
entry = str(entries[0])
@@ -694,11 +852,23 @@ def test_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr_name):
def test_mod_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr):
- """Tests that operational attributes are returned
- by default in rootDSE searches after config modification
- """
+ """Tests that operational attributes are returned by default in rootDSE searches after config modification
+
+ :id: c7831e04-f458-4e23-83c7-b6f66109f639
- log.info(" Assert rootdse search has %s attr" % rootdse_attr)
+ :setup: Standalone instance and we are using rootdse_attr fixture which
+adds nsslapd-return-default-opattr attr with value of one operation attribute.
+
+ :steps:
+ 1. Make an ldapsearch for rootdse attribute
+ 2. Check the returned entries.
+
+ :expectedresults:
+ 1. Search should not fail
+ 2. Operational attributes should be returned after the config modification
+ """
+
+ log.info(" Assert rootdse search has %s attr" % rootdse_attr)
try:
entries = topology_st.standalone.search_s("", ldap.SCOPE_BASE)
entry = str(entries[0])
@@ -708,9 +878,10 @@ def test_mod_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr):
log.fatal('Search failed, error: ' + e.message['desc'])
assert False
-
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
CURRENT_FILE = os.path.realpath(__file__)
pytest.main("-s %s" % CURRENT_FILE)
+
+
| 0 |
0efccdb3791412040c671b6c41294d93289e6f73
|
389ds/389-ds-base
|
Resolves: 457329
Summary: Make better use of cached DNA config information
|
commit 0efccdb3791412040c671b6c41294d93289e6f73
Author: Nathan Kinder <[email protected]>
Date: Thu Jul 31 16:22:25 2008 +0000
Resolves: 457329
Summary: Make better use of cached DNA config information
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 05f99dfc7..e2d807ab0 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -695,7 +695,7 @@ static void deleteConfig()
Distributed ranges Helpers
****************************************************/
-static int dna_fix_maxval(Slapi_DN *dn, PRUint64 *cur, PRUint64 *max)
+static int dna_fix_maxval(struct configEntry *config_entry, PRUint64 *cur)
{
/* TODO: check the main partition to see if another range
* is available, and set the new local configuration
@@ -707,8 +707,13 @@ static int dna_fix_maxval(Slapi_DN *dn, PRUint64 *cur, PRUint64 *max)
return LDAP_OPERATIONS_ERROR;
}
-static void dna_notice_allocation(Slapi_DN *dn, PRUint64 new)
+static void dna_notice_allocation(struct configEntry *config_entry, PRUint64 new)
{
+ /* update our cached config entry with the newly allocated
+ * value.
+ */
+ config_entry->nextval = new;
+
/* TODO: check if we passed a new chunk threshold and update
* the shared configuration on the public partition.
*/
@@ -794,13 +799,11 @@ static LDAPControl *dna_build_sort_control(const char *attr)
than config and startup
****************************************************/
-/* we do search all values between newval and maxval asking the
+/* we do search all values between nextval and maxval asking the
* server to sort them, then we check the first free spot and
* use it as newval */
static int dna_first_free_value(struct configEntry *config_entry,
- PRUint64 *newval,
- PRUint64 maxval,
- PRUint64 increment)
+ PRUint64 *newval)
{
Slapi_Entry **entries = NULL;
Slapi_PBlock *pb = NULL;
@@ -816,7 +819,7 @@ static int dna_first_free_value(struct configEntry *config_entry,
prefix = config_entry->prefix;
type = config_entry->type;
- tmpval = *newval;
+ tmpval = config_entry->nextval;
attrs[0] = type;
attrs[1] = NULL;
@@ -834,7 +837,7 @@ static int dna_first_free_value(struct configEntry *config_entry,
filter = slapi_ch_smprintf("(&%s(&(%s>=%s%llu)(%s<=%s%llu)))",
config_entry->filter,
type, prefix?prefix:"", tmpval,
- type, prefix?prefix:"", maxval);
+ type, prefix?prefix:"", config_entry->maxval);
if (NULL == filter) {
ldap_control_free(ctrls[0]);
slapi_ch_free((void **)&ctrls);
@@ -870,6 +873,7 @@ static int dna_first_free_value(struct configEntry *config_entry,
if (NULL == entries || NULL == entries[0]) {
/* no values means we already have a good value */
+ *newval = tmpval;
status = LDAP_SUCCESS;
goto cleanup;
}
@@ -904,10 +908,10 @@ static int dna_first_free_value(struct configEntry *config_entry,
if (tmpval != sval)
break;
- if (maxval < sval)
+ if (config_entry->maxval < sval)
break;
- tmpval += increment;
+ tmpval += config_entry->interval;
}
*newval = tmpval;
@@ -924,201 +928,107 @@ cleanup:
/*
* Perform ldap operationally atomic increment
* Return the next value to be assigned
- * Method:
- * 1. retrieve entry
- * 2. do increment operations
- * 3. remove current value, add new value in one operation
- * 4. if failed, and less than 3 times, goto 1
*/
static int dna_get_next_value(struct configEntry *config_entry,
char **next_value_ret)
{
Slapi_PBlock *pb = NULL;
- char *old_value = NULL;
- Slapi_Entry *e = NULL;
- Slapi_DN *dn = NULL;
- char *attrlist[4];
- int attempts;
+ LDAPMod mod_replace;
+ LDAPMod *mods[2];
+ char *replace_val[2];
+ char next_value[16];
+ PRUint64 setval = 0;
+ PRUint64 nextval = 0;
int ret;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_get_next_value\n");
- /* get pre-requisites to search */
- dn = slapi_sdn_new_dn_byref(config_entry->dn);
- attrlist[0] = DNA_NEXTVAL;
- attrlist[1] = DNA_MAXVAL;
- attrlist[2] = DNA_INTERVAL;
- attrlist[3] = NULL;
-
-
- /* the operation is constructed such that race conditions
- * to increment the value are detected and avoided - one wins,
- * one loses - however, there is no need for the server to compete
- * with itself so we lock here
- */
-
+ /* get the lock to prevent contention with other threads over
+ * the next new value for this range. */
slapi_lock_mutex(config_entry->new_value_lock);
- for (attempts = 0; attempts < 3; attempts++) {
-
- LDAPMod mod_add;
- LDAPMod mod_delete;
- LDAPMod *mods[3];
- char *delete_val[2];
- char *add_val[2];
- char new_value[16];
- char *interval;
- char *max_value;
- PRUint64 increment = 1; /* default increment */
- PRUint64 setval = 0;
- PRUint64 newval = 0;
- PRUint64 maxval = -1;
-
- /* do update */
- ret = slapi_search_internal_get_entry(dn, attrlist, &e,
- getPluginID());
- if (LDAP_SUCCESS != ret) {
- ret = LDAP_OPERATIONS_ERROR;
- goto done;
- }
+ /* get the first value */
+ ret = dna_first_free_value(config_entry, &setval);
+ if (LDAP_SUCCESS != ret)
+ goto done;
- old_value = slapi_entry_attr_get_charptr(e, DNA_NEXTVAL);
- if (NULL == old_value) {
- ret = LDAP_OPERATIONS_ERROR;
+ /* try for a new range or fail */
+ if (setval > config_entry->maxval) {
+ ret = dna_fix_maxval(config_entry, &setval);
+ if (LDAP_SUCCESS != ret) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_get_next_value: no more IDs available!!\n");
goto done;
}
- setval = strtoul(old_value, 0, 0);
-
- max_value = slapi_entry_attr_get_charptr(e, DNA_MAXVAL);
- if (max_value) {
- maxval = strtoul(max_value, 0, 0);
- slapi_ch_free_string(&max_value);
- }
-
- /* if not present the default is 1 */
- interval = slapi_entry_attr_get_charptr(e, DNA_INTERVAL);
- if (NULL != interval) {
- increment = strtoul(interval, 0, 0);
- }
-
- slapi_entry_free(e);
- e = NULL;
-
- /* check the value is actually in range */
-
- /* verify the new value is actually free and get the first
- * one free if not*/
- ret = dna_first_free_value(config_entry, &setval, maxval, increment);
+ /* get the first value from our newly extended range */
+ ret = dna_first_free_value(config_entry, &setval);
if (LDAP_SUCCESS != ret)
goto done;
+ }
- /* try for a new range or fail */
- if (setval > maxval) {
- ret = dna_fix_maxval(dn, &setval, &maxval);
- if (LDAP_SUCCESS != ret) {
- slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
- "dna_get_next_value: no more IDs available!!\n");
- goto done;
- }
+ /* ensure that we haven't gone past the end of our range */
+ if (setval > config_entry->maxval) {
+ ret = LDAP_OPERATIONS_ERROR;
+ goto done;
+ }
- /* verify the new value is actually free and get the first
- * one free if not */
- ret = dna_first_free_value(config_entry, &setval, maxval, increment);
- if (LDAP_SUCCESS != ret)
- goto done;
- }
+ nextval = setval + config_entry->interval;
- if (setval > maxval) {
- ret = LDAP_OPERATIONS_ERROR;
+ /* try for a new range or fail */
+ if (nextval > config_entry->maxval) {
+ ret = dna_fix_maxval(config_entry, &nextval);
+ if (LDAP_SUCCESS != ret) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_get_next_value: no more IDs available!!\n");
goto done;
}
+ }
- newval = setval + increment;
-
- /* try for a new range or fail */
- if (newval > maxval) {
- ret = dna_fix_maxval(dn, &newval, &maxval);
- if (LDAP_SUCCESS != ret) {
- slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
- "dna_get_next_value: no more IDs available!!\n");
- goto done;
- }
- }
-
- /* try to set the new value */
+ /* try to set the new next value in the config entry */
+ snprintf(next_value, sizeof(next_value),"%llu", nextval);
- sprintf(new_value, "%llu", newval);
+ /* set up our replace modify operation */
+ replace_val[0] = next_value;
+ replace_val[1] = 0;
+ mod_replace.mod_op = LDAP_MOD_REPLACE;
+ mod_replace.mod_type = DNA_NEXTVAL;
+ mod_replace.mod_values = replace_val;
+ mods[0] = &mod_replace;
+ mods[1] = 0;
- delete_val[0] = old_value;
- delete_val[1] = 0;
+ pb = slapi_pblock_new();
+ if (NULL == pb) {
+ ret = LDAP_OPERATIONS_ERROR;
+ goto done;
+ }
- mod_delete.mod_op = LDAP_MOD_DELETE;
- mod_delete.mod_type = DNA_NEXTVAL;
- mod_delete.mod_values = delete_val;
+ slapi_modify_internal_set_pb(pb, config_entry->dn,
+ mods, 0, 0, getPluginID(), 0);
- add_val[0] = new_value;
- add_val[1] = 0;
+ slapi_modify_internal_pb(pb);
- mod_add.mod_op = LDAP_MOD_ADD;
- mod_add.mod_type = DNA_NEXTVAL;
- mod_add.mod_values = add_val;
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
- mods[0] = &mod_delete;
- mods[1] = &mod_add;
- mods[2] = 0;
+ slapi_pblock_destroy(pb);
+ pb = NULL;
- pb = slapi_pblock_new();
- if (NULL == pb) {
+ if (LDAP_SUCCESS == ret) {
+ *next_value_ret = slapi_ch_smprintf("%llu", setval);
+ if (NULL == *next_value_ret) {
ret = LDAP_OPERATIONS_ERROR;
goto done;
}
- slapi_modify_internal_set_pb(pb, config_entry->dn,
- mods, 0, 0, getPluginID(), 0);
-
- slapi_modify_internal_pb(pb);
-
- slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
-
- slapi_pblock_destroy(pb);
- pb = NULL;
- slapi_ch_free_string(&interval);
- slapi_ch_free_string(&old_value);
-
- if (LDAP_SUCCESS == ret) {
- *next_value_ret = slapi_ch_smprintf("%llu", setval);
- if (NULL == *next_value_ret) {
- ret = LDAP_OPERATIONS_ERROR;
- goto done;
- }
-
- dna_notice_allocation(dn, newval);
- goto done;
- }
-
- if (LDAP_NO_SUCH_ATTRIBUTE != ret) {
- /* not the result of a race
- to change the value
- */
- goto done;
- }
+ /* update our cached config */
+ dna_notice_allocation(config_entry, nextval);
}
done:
slapi_unlock_mutex(config_entry->new_value_lock);
- if (LDAP_SUCCESS != ret)
- slapi_ch_free_string(&old_value);
-
- if (dn)
- slapi_sdn_free(&dn);
-
- if (e)
- slapi_entry_free(e);
-
if (pb)
slapi_pblock_destroy(pb);
| 0 |
251cef910f0d2abc1ade58db1f75922d2b57b932
|
389ds/389-ds-base
|
Issue 51110 - Fix ASAN ODR warnings
Description: Fixed ODR issues with glboal attributes which were duplicated from
the core server into the replication and retrocl plugins.
relates: https://pagure.io/389-ds-base/issue/51110
Reviewed by: firstyear(Thanks!)
|
commit 251cef910f0d2abc1ade58db1f75922d2b57b932
Author: Mark Reynolds <[email protected]>
Date: Fri May 22 15:41:45 2020 -0400
Issue 51110 - Fix ASAN ODR warnings
Description: Fixed ODR issues with glboal attributes which were duplicated from
the core server into the replication and retrocl plugins.
relates: https://pagure.io/389-ds-base/issue/51110
Reviewed by: firstyear(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 79353e0e1..dce469011 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -280,15 +280,14 @@ struct berval *NSDS90StartReplicationRequest_new(const char *protocol_oid,
int multimaster_extop_NSDS50ReplicationEntry(Slapi_PBlock *pb);
/* From repl_globals.c */
-extern char *attr_changenumber;
-extern char *attr_targetdn;
-extern char *attr_changetype;
-extern char *attr_newrdn;
-extern char *attr_deleteoldrdn;
-extern char *attr_changes;
-extern char *attr_newsuperior;
-extern char *attr_changetime;
-extern char *attr_dataversion;
+extern char *repl_changenumber;
+extern char *repl_targetdn;
+extern char *repl_changetype;
+extern char *repl_newrdn;
+extern char *repl_deleteoldrdn;
+extern char *repl_changes;
+extern char *repl_newsuperior;
+extern char *repl_changetime;
extern char *attr_csn;
extern char *changetype_add;
extern char *changetype_delete;
diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c
index 355a0ffa1..c615c77da 100644
--- a/ldap/servers/plugins/replication/repl_globals.c
+++ b/ldap/servers/plugins/replication/repl_globals.c
@@ -48,15 +48,14 @@ char *changetype_delete = CHANGETYPE_DELETE;
char *changetype_modify = CHANGETYPE_MODIFY;
char *changetype_modrdn = CHANGETYPE_MODRDN;
char *changetype_moddn = CHANGETYPE_MODDN;
-char *attr_changenumber = ATTR_CHANGENUMBER;
-char *attr_targetdn = ATTR_TARGETDN;
-char *attr_changetype = ATTR_CHANGETYPE;
-char *attr_newrdn = ATTR_NEWRDN;
-char *attr_deleteoldrdn = ATTR_DELETEOLDRDN;
-char *attr_changes = ATTR_CHANGES;
-char *attr_newsuperior = ATTR_NEWSUPERIOR;
-char *attr_changetime = ATTR_CHANGETIME;
-char *attr_dataversion = ATTR_DATAVERSION;
+char *repl_changenumber = ATTR_CHANGENUMBER;
+char *repl_targetdn = ATTR_TARGETDN;
+char *repl_changetype = ATTR_CHANGETYPE;
+char *repl_newrdn = ATTR_NEWRDN;
+char *repl_deleteoldrdn = ATTR_DELETEOLDRDN;
+char *repl_changes = ATTR_CHANGES;
+char *repl_newsuperior = ATTR_NEWSUPERIOR;
+char *repl_changetime = ATTR_CHANGETIME;
char *attr_csn = ATTR_CSN;
char *type_copyingFrom = TYPE_COPYINGFROM;
char *type_copiedFrom = TYPE_COPIEDFROM;
diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c
index de1e77880..39f821d12 100644
--- a/ldap/servers/plugins/replication/replutil.c
+++ b/ldap/servers/plugins/replication/replutil.c
@@ -64,14 +64,14 @@ get_cleattrs()
{
if (cleattrs[0] == NULL) {
cleattrs[0] = type_objectclass;
- cleattrs[1] = attr_changenumber;
- cleattrs[2] = attr_targetdn;
- cleattrs[3] = attr_changetype;
- cleattrs[4] = attr_newrdn;
- cleattrs[5] = attr_deleteoldrdn;
- cleattrs[6] = attr_changes;
- cleattrs[7] = attr_newsuperior;
- cleattrs[8] = attr_changetime;
+ cleattrs[1] = repl_changenumber;
+ cleattrs[2] = repl_targetdn;
+ cleattrs[3] = repl_changetype;
+ cleattrs[4] = repl_newrdn;
+ cleattrs[5] = repl_deleteoldrdn;
+ cleattrs[6] = repl_changes;
+ cleattrs[7] = repl_newsuperior;
+ cleattrs[8] = repl_changetime;
cleattrs[9] = NULL;
}
return cleattrs;
diff --git a/ldap/servers/plugins/retrocl/retrocl.h b/ldap/servers/plugins/retrocl/retrocl.h
index 06482a14c..2ce76fcec 100644
--- a/ldap/servers/plugins/retrocl/retrocl.h
+++ b/ldap/servers/plugins/retrocl/retrocl.h
@@ -94,17 +94,17 @@ extern int retrocl_nattributes;
extern char **retrocl_attributes;
extern char **retrocl_aliases;
-extern const char *attr_changenumber;
-extern const char *attr_targetdn;
-extern const char *attr_changetype;
-extern const char *attr_newrdn;
-extern const char *attr_newsuperior;
-extern const char *attr_deleteoldrdn;
-extern const char *attr_changes;
-extern const char *attr_changetime;
-extern const char *attr_objectclass;
-extern const char *attr_nsuniqueid;
-extern const char *attr_isreplicated;
+extern const char *retrocl_changenumber;
+extern const char *retrocl_targetdn;
+extern const char *retrocl_changetype;
+extern const char *retrocl_newrdn;
+extern const char *retrocl_newsuperior;
+extern const char *retrocl_deleteoldrdn;
+extern const char *retrocl_changes;
+extern const char *retrocl_changetime;
+extern const char *retrocl_objectclass;
+extern const char *retrocl_nsuniqueid;
+extern const char *retrocl_isreplicated;
extern PRLock *retrocl_internal_lock;
extern Slapi_RWLock *retrocl_cn_lock;
diff --git a/ldap/servers/plugins/retrocl/retrocl_cn.c b/ldap/servers/plugins/retrocl/retrocl_cn.c
index 709d7a857..5fc5f586d 100644
--- a/ldap/servers/plugins/retrocl/retrocl_cn.c
+++ b/ldap/servers/plugins/retrocl/retrocl_cn.c
@@ -62,7 +62,7 @@ handle_cnum_entry(Slapi_Entry *e, void *callback_data)
Slapi_Attr *chattr = NULL;
sval = NULL;
value = NULL;
- if (slapi_entry_attr_find(e, attr_changenumber, &chattr) == 0) {
+ if (slapi_entry_attr_find(e, retrocl_changenumber, &chattr) == 0) {
slapi_attr_first_value(chattr, &sval);
if (NULL != sval) {
value = slapi_value_get_berval(sval);
@@ -79,7 +79,7 @@ handle_cnum_entry(Slapi_Entry *e, void *callback_data)
chattr = NULL;
sval = NULL;
value = NULL;
- if (slapi_entry_attr_find(e, attr_changetime, &chattr) == 0) {
+ if (slapi_entry_attr_find(e, retrocl_changetime, &chattr) == 0) {
slapi_attr_first_value(chattr, &sval);
if (NULL != sval) {
value = slapi_value_get_berval(sval);
@@ -134,7 +134,7 @@ retrocl_get_changenumbers(void)
cr.cr_time = 0;
slapi_seq_callback(RETROCL_CHANGELOG_DN, SLAPI_SEQ_FIRST,
- (char *)attr_changenumber, /* cast away const */
+ (char *)retrocl_changenumber, /* cast away const */
NULL, NULL, 0, &cr, NULL, handle_cnum_result,
handle_cnum_entry, NULL);
@@ -144,7 +144,7 @@ retrocl_get_changenumbers(void)
slapi_ch_free((void **)&cr.cr_time);
slapi_seq_callback(RETROCL_CHANGELOG_DN, SLAPI_SEQ_LAST,
- (char *)attr_changenumber, /* cast away const */
+ (char *)retrocl_changenumber, /* cast away const */
NULL, NULL, 0, &cr, NULL, handle_cnum_result,
handle_cnum_entry, NULL);
@@ -185,7 +185,7 @@ retrocl_getchangetime(int type, int *err)
return NO_TIME;
}
slapi_seq_callback(RETROCL_CHANGELOG_DN, type,
- (char *)attr_changenumber, /* cast away const */
+ (char *)retrocl_changenumber, /* cast away const */
NULL,
NULL, 0, &cr, NULL,
handle_cnum_result, handle_cnum_entry, NULL);
@@ -353,7 +353,7 @@ retrocl_update_lastchangenumber(void)
cr.cr_cnum = 0;
cr.cr_time = 0;
slapi_seq_callback(RETROCL_CHANGELOG_DN, SLAPI_SEQ_LAST,
- (char *)attr_changenumber, /* cast away const */
+ (char *)retrocl_changenumber, /* cast away const */
NULL, NULL, 0, &cr, NULL, handle_cnum_result,
handle_cnum_entry, NULL);
diff --git a/ldap/servers/plugins/retrocl/retrocl_po.c b/ldap/servers/plugins/retrocl/retrocl_po.c
index d2af79b31..e1488f56b 100644
--- a/ldap/servers/plugins/retrocl/retrocl_po.c
+++ b/ldap/servers/plugins/retrocl/retrocl_po.c
@@ -25,17 +25,17 @@ modrdn2reple(Slapi_Entry *e, const char *newrdn, int deloldrdn, LDAPMod **ldm, c
/******************************/
-const char *attr_changenumber = "changenumber";
-const char *attr_targetdn = "targetdn";
-const char *attr_changetype = "changetype";
-const char *attr_newrdn = "newrdn";
-const char *attr_deleteoldrdn = "deleteoldrdn";
-const char *attr_changes = "changes";
-const char *attr_newsuperior = "newsuperior";
-const char *attr_changetime = "changetime";
-const char *attr_objectclass = "objectclass";
-const char *attr_nsuniqueid = "nsuniqueid";
-const char *attr_isreplicated = "isreplicated";
+const char *retrocl_changenumber = "changenumber";
+const char *retrocl_targetdn = "targetdn";
+const char *retrocl_changetype = "changetype";
+const char *retrocl_newrdn = "newrdn";
+const char *retrocl_deleteoldrdn = "deleteoldrdn";
+const char *retrocl_changes = "changes";
+const char *retrocl_newsuperior = "newsuperior";
+const char *retrocl_changetime = "changetime";
+const char *retrocl_objectclass = "objectclass";
+const char *retrocl_nsuniqueid = "nsuniqueid";
+const char *retrocl_isreplicated = "isreplicated";
/*
* Function: make_changes_string
@@ -185,7 +185,7 @@ write_replog_db(
changenum, dn);
/* Construct the dn of this change record */
- edn = slapi_ch_smprintf("%s=%lu,%s", attr_changenumber, changenum, RETROCL_CHANGELOG_DN);
+ edn = slapi_ch_smprintf("%s=%lu,%s", retrocl_changenumber, changenum, RETROCL_CHANGELOG_DN);
/*
* Create the entry struct, and fill in fields common to all types
@@ -214,7 +214,7 @@ write_replog_db(
attributeAlias = attributeName;
}
- if (strcasecmp(attributeName, attr_nsuniqueid) == 0) {
+ if (strcasecmp(attributeName, retrocl_nsuniqueid) == 0) {
Slapi_Entry *entry = NULL;
const char *uniqueId = NULL;
@@ -236,7 +236,7 @@ write_replog_db(
extensibleObject = 1;
- } else if (strcasecmp(attributeName, attr_isreplicated) == 0) {
+ } else if (strcasecmp(attributeName, retrocl_isreplicated) == 0) {
int isReplicated = 0;
char *attributeValue = NULL;
@@ -298,17 +298,17 @@ write_replog_db(
sprintf(chnobuf, "%lu", changenum);
val.bv_val = chnobuf;
val.bv_len = strlen(chnobuf);
- slapi_entry_add_values(e, attr_changenumber, vals);
+ slapi_entry_add_values(e, retrocl_changenumber, vals);
/* Set the targetentrydn attribute */
val.bv_val = dn;
val.bv_len = strlen(dn);
- slapi_entry_add_values(e, attr_targetdn, vals);
+ slapi_entry_add_values(e, retrocl_targetdn, vals);
/* Set the changeTime attribute */
val.bv_val = format_genTime(curtime);
val.bv_len = strlen(val.bv_val);
- slapi_entry_add_values(e, attr_changetime, vals);
+ slapi_entry_add_values(e, retrocl_changetime, vals);
slapi_ch_free((void **)&val.bv_val);
/*
@@ -344,7 +344,7 @@ write_replog_db(
/* Set the changetype attribute */
val.bv_val = "delete";
val.bv_len = 6;
- slapi_entry_add_values(e, attr_changetype, vals);
+ slapi_entry_add_values(e, retrocl_changetype, vals);
}
break;
@@ -422,7 +422,7 @@ entry2reple(Slapi_Entry *e, Slapi_Entry *oe, int optype)
} else {
return (1);
}
- slapi_entry_add_values(e, attr_changetype, vals);
+ slapi_entry_add_values(e, retrocl_changetype, vals);
estr = slapi_entry2str(oe, &len);
p = estr;
@@ -435,7 +435,7 @@ entry2reple(Slapi_Entry *e, Slapi_Entry *oe, int optype)
}
val.bv_val = p;
val.bv_len = len - (p - estr); /* length + terminating \0 */
- slapi_entry_add_values(e, attr_changes, vals);
+ slapi_entry_add_values(e, retrocl_changes, vals);
slapi_ch_free_string(&estr);
return 0;
}
@@ -471,7 +471,7 @@ mods2reple(Slapi_Entry *e, LDAPMod **ldm)
if (NULL != l) {
val.bv_val = l->ls_buf;
val.bv_len = l->ls_len + 1; /* string + terminating \0 */
- slapi_entry_add_values(e, attr_changes, vals);
+ slapi_entry_add_values(e, retrocl_changes, vals);
lenstr_free(&l);
}
}
@@ -511,12 +511,12 @@ modrdn2reple(
val.bv_val = "modrdn";
val.bv_len = 6;
- slapi_entry_add_values(e, attr_changetype, vals);
+ slapi_entry_add_values(e, retrocl_changetype, vals);
if (newrdn) {
val.bv_val = (char *)newrdn; /* cast away const */
val.bv_len = strlen(newrdn);
- slapi_entry_add_values(e, attr_newrdn, vals);
+ slapi_entry_add_values(e, retrocl_newrdn, vals);
}
if (deloldrdn == 0) {
@@ -526,12 +526,12 @@ modrdn2reple(
val.bv_val = "TRUE";
val.bv_len = 4;
}
- slapi_entry_add_values(e, attr_deleteoldrdn, vals);
+ slapi_entry_add_values(e, retrocl_deleteoldrdn, vals);
if (newsuperior) {
val.bv_val = (char *)newsuperior; /* cast away const */
val.bv_len = strlen(newsuperior);
- slapi_entry_add_values(e, attr_newsuperior, vals);
+ slapi_entry_add_values(e, retrocl_newsuperior, vals);
}
if (NULL != ldm) {
@@ -540,7 +540,7 @@ modrdn2reple(
if (l->ls_len) {
val.bv_val = l->ls_buf;
val.bv_len = l->ls_len;
- slapi_entry_add_values(e, attr_changes, vals);
+ slapi_entry_add_values(e, retrocl_changes, vals);
}
lenstr_free(&l);
}
diff --git a/ldap/servers/plugins/retrocl/retrocl_trim.c b/ldap/servers/plugins/retrocl/retrocl_trim.c
index 0378eb7f6..d031dc3f8 100644
--- a/ldap/servers/plugins/retrocl/retrocl_trim.c
+++ b/ldap/servers/plugins/retrocl/retrocl_trim.c
@@ -49,15 +49,15 @@ static const char **
get_cleattrs(void)
{
if (cleattrs[0] == NULL) {
- cleattrs[0] = attr_objectclass;
- cleattrs[1] = attr_changenumber;
- cleattrs[2] = attr_targetdn;
- cleattrs[3] = attr_changetype;
- cleattrs[4] = attr_newrdn;
- cleattrs[5] = attr_deleteoldrdn;
- cleattrs[6] = attr_changes;
- cleattrs[7] = attr_newsuperior;
- cleattrs[8] = attr_changetime;
+ cleattrs[0] = retrocl_objectclass;
+ cleattrs[1] = retrocl_changenumber;
+ cleattrs[2] = retrocl_targetdn;
+ cleattrs[3] = retrocl_changetype;
+ cleattrs[4] = retrocl_newrdn;
+ cleattrs[5] = retrocl_deleteoldrdn;
+ cleattrs[6] = retrocl_changes;
+ cleattrs[7] = retrocl_newsuperior;
+ cleattrs[8] = retrocl_changetime;
cleattrs[9] = NULL;
}
return cleattrs;
@@ -81,7 +81,7 @@ delete_changerecord(changeNumber cnum)
char *dnbuf;
int delrc;
- dnbuf = slapi_ch_smprintf("%s=%ld, %s", attr_changenumber, cnum,
+ dnbuf = slapi_ch_smprintf("%s=%ld, %s", retrocl_changenumber, cnum,
RETROCL_CHANGELOG_DN);
pb = slapi_pblock_new();
slapi_delete_internal_set_pb(pb, dnbuf, NULL /*controls*/, NULL /* uniqueid */,
@@ -154,7 +154,7 @@ handle_getchangetime_search(Slapi_Entry *e, void *callback_data)
if (NULL != e) {
Slapi_Value *sval = NULL;
const struct berval *val = NULL;
- rc = slapi_entry_attr_find(e, attr_changetime, &attr);
+ rc = slapi_entry_attr_find(e, retrocl_changetime, &attr);
/* Bug 624442: Logic checking for lack of timestamp was
reversed. */
if (0 != rc || slapi_attr_first_value(attr, &sval) == -1 ||
@@ -174,14 +174,14 @@ handle_getchangetime_search(Slapi_Entry *e, void *callback_data)
/*
* Function: get_changetime
* Arguments: cnum - number of change record to retrieve
- * Returns: Taking the attr_changetime of the 'cnum' entry,
+ * Returns: Taking the retrocl_changetime of the 'cnum' entry,
* it converts it into time_t (parse_localTime) and returns this time value.
* It returns 0 in the following cases:
- * - changerecord entry has not attr_changetime
+ * - changerecord entry has not retrocl_changetime
* - attr_changetime attribute has no value
* - attr_changetime attribute value is empty
*
- * Description: Retrieve attr_changetime ("changetime") from a changerecord whose number is "cnum".
+ * Description: Retrieve retrocl_changetime ("changetime") from a changerecord whose number is "cnum".
*/
static time_t
get_changetime(changeNumber cnum, int *err)
@@ -198,7 +198,7 @@ get_changetime(changeNumber cnum, int *err)
}
crtp->crt_nentries = crtp->crt_err = 0;
crtp->crt_time = 0;
- PR_snprintf(fstr, sizeof(fstr), "%s=%ld", attr_changenumber, cnum);
+ PR_snprintf(fstr, sizeof(fstr), "%s=%ld", retrocl_changenumber, cnum);
pb = slapi_pblock_new();
slapi_search_internal_set_pb(pb, RETROCL_CHANGELOG_DN,
| 0 |
27b8987108d875e3e9ee0d844548f8d94db350d1
|
389ds/389-ds-base
|
Bug 1347760 - CI test: test case for bug 1347760
Description: Information disclosure via repeated use of LDAP ADD operation, etc.
|
commit 27b8987108d875e3e9ee0d844548f8d94db350d1
Author: Noriko Hosoi <[email protected]>
Date: Tue Jul 12 14:33:17 2016 -0700
Bug 1347760 - CI test: test case for bug 1347760
Description: Information disclosure via repeated use of LDAP ADD operation, etc.
diff --git a/dirsrvtests/tests/tickets/ticket1347760_test.py b/dirsrvtests/tests/tickets/ticket1347760_test.py
new file mode 100644
index 000000000..d2e9e3709
--- /dev/null
+++ b/dirsrvtests/tests/tickets/ticket1347760_test.py
@@ -0,0 +1,440 @@
+# --- 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 os
+import sys
+import time
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+CONFIG_DN = 'cn=config'
+BOU = 'BOU'
+BINDOU = 'ou=%s,%s' % (BOU, DEFAULT_SUFFIX)
+BUID = 'buser123'
+TUID = 'tuser0'
+BINDDN = 'uid=%s,%s' % (BUID, BINDOU)
+BINDPW = BUID
+TESTDN = 'uid=%s,ou=people,%s' % (TUID, DEFAULT_SUFFIX)
+TESTPW = TUID
+BOGUSDN = 'uid=bogus,%s' % DEFAULT_SUFFIX
+BOGUSDN2 = 'uid=bogus,ou=people,%s' % DEFAULT_SUFFIX
+BOGUSSUFFIX = 'uid=bogus,ou=people,dc=bogus'
+GROUPOU = 'ou=groups,%s' % DEFAULT_SUFFIX
+BOGUSOU = 'ou=OU,%s' % DEFAULT_SUFFIX
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
[email protected](scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+# def fin():
+# standalone.delete()
+# request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+def pattern_accesslog(file, log_pattern):
+ try:
+ pattern_accesslog.last_pos += 1
+ except AttributeError:
+ pattern_accesslog.last_pos = 0
+
+ found = None
+ file.seek(pattern_accesslog.last_pos)
+
+ # Use a while true iteration because 'for line in file: hit a
+ # python bug that break file.tell()
+ while True:
+ line = file.readline()
+ found = log_pattern.search(line)
+ if ((line == '') or (found)):
+ break
+
+ pattern_accesslog.last_pos = file.tell()
+ if found:
+ return line
+ else:
+ return None
+
+def check_op_result(server, op, dn, superior, exists, rc):
+ targetdn = dn
+ if op == 'search':
+ if exists:
+ opstr = 'Searching existing entry'
+ else:
+ opstr = 'Searching non-existing entry'
+ elif op == 'add':
+ if exists:
+ opstr = 'Adding existing entry'
+ else:
+ opstr = 'Adding non-existing entry'
+ elif op == 'modify':
+ if exists:
+ opstr = 'Modifying existing entry'
+ else:
+ opstr = 'Modifying non-existing entry'
+ elif op == 'modrdn':
+ if superior != None:
+ targetdn = superior
+ if exists:
+ opstr = 'Moving to existing superior'
+ else:
+ opstr = 'Moving to non-existing superior'
+ else:
+ if exists:
+ opstr = 'Renaming existing entry'
+ else:
+ opstr = 'Renaming non-existing entry'
+ elif op == 'delete':
+ if exists:
+ opstr = 'Deleting existing entry'
+ else:
+ opstr = 'Deleting non-existing entry'
+
+ if ldap.SUCCESS == rc:
+ expstr = 'be ok'
+ else:
+ expstr = 'fail with %s' % rc.__name__
+
+ log.info('%s %s, which should %s.' % (opstr, targetdn, expstr))
+ hit = 0
+ try:
+ if op == 'search':
+ centry = server.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*')
+ elif op == 'add':
+ server.add_s(Entry((dn, {'objectclass': 'top extensibleObject'.split(),
+ 'cn': 'test entry'})))
+ elif op == 'modify':
+ server.modify_s(dn, [(ldap.MOD_REPLACE, 'description', 'test')])
+ elif op == 'modrdn':
+ if superior != None:
+ server.rename_s(dn, 'uid=new', newsuperior=superior, delold=1)
+ else:
+ server.rename_s(dn, 'uid=new', delold=1)
+ elif op == 'delete':
+ server.delete_s(dn)
+ else:
+ log.fatal('Unknown operation %s' % op)
+ assert False
+ except ldap.LDAPError as e:
+ hit = 1
+ log.info("Exception (expected): %s" % type(e).__name__)
+ log.info('Desc ' + e.message['desc'])
+ assert isinstance(e, rc)
+ if e.message.has_key('matched'):
+ log.info('Matched is returned: ' + e.message['matched'])
+ if rc != ldap.NO_SUCH_OBJECT:
+ assert False
+
+ if ldap.SUCCESS == rc:
+ if op == 'search':
+ log.info('Search should return none')
+ assert len(centry) == 0
+ else:
+ if 0 == hit:
+ log.info('Expected to fail with %s, but passed' % rc.__name__)
+ assert False
+
+ log.info('PASSED\n')
+
+def test_ticket1347760(topology):
+ """
+ Prevent revealing the entry info to whom has no access rights.
+ """
+ log.info('Testing Bug 1347760 - Information disclosure via repeated use of LDAP ADD operation, etc.')
+
+ log.info('Disabling accesslog logbuffering')
+ topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-accesslog-logbuffering', 'off')])
+
+ log.info('Bind as {%s,%s}' % (DN_DM, PASSWORD))
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+
+ log.info('Adding ou=%s a bind user belongs to.' % BOU)
+ topology.standalone.add_s(Entry((BINDOU, {
+ 'objectclass': 'top organizationalunit'.split(),
+ 'ou': BOU})))
+
+ log.info('Adding a bind user.')
+ topology.standalone.add_s(Entry((BINDDN,
+ {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
+ 'cn': 'bind user',
+ 'sn': 'user',
+ 'userPassword': BINDPW})))
+
+ log.info('Adding a test user.')
+ topology.standalone.add_s(Entry((TESTDN,
+ {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
+ 'cn': 'test user',
+ 'sn': 'user',
+ 'userPassword': TESTPW})))
+
+ log.info('Deleting aci in %s.' % DEFAULT_SUFFIX)
+ topology.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_DELETE, 'aci', None)])
+
+ log.info('Bind case 1. the bind user has no rights to read the entry itself, bind should be successful.')
+ log.info('Bind as {%s,%s} who has no access rights.' % (BINDDN, BINDPW))
+ try:
+ topology.standalone.simple_bind_s(BINDDN, BINDPW)
+ except ldap.LDAPError as e:
+ log.info('Desc ' + e.message['desc'])
+ assert False
+
+ file_path = os.path.join(topology.standalone.prefix, 'var/log/dirsrv/slapd-%s/access' % topology.standalone.serverid)
+ file_obj = open(file_path, "r")
+ log.info('Access log path: %s' % file_path)
+
+ log.info('Bind case 2-1. the bind user does not exist, bind should fail with error %s' % ldap.INVALID_CREDENTIALS.__name__)
+ log.info('Bind as {%s,%s} who does not exist.' % (BOGUSDN, 'bogus'))
+ try:
+ topology.standalone.simple_bind_s(BOGUSDN, 'bogus')
+ except ldap.LDAPError as e:
+ log.info("Exception (expected): %s" % type(e).__name__)
+ log.info('Desc ' + e.message['desc'])
+ assert isinstance(e, ldap.INVALID_CREDENTIALS)
+ regex = re.compile('No such entry')
+ cause = pattern_accesslog(file_obj, regex)
+ if cause == None:
+ log.fatal('Cause not found - %s' % cause)
+ assert False
+ else:
+ log.info('Cause found - %s' % cause)
+
+ log.info('Bind case 2-2. the bind user\'s suffix does not exist, bind should fail with error %s' % ldap.INVALID_CREDENTIALS.__name__)
+ log.info('Bind as {%s,%s} who does not exist.' % (BOGUSSUFFIX, 'bogus'))
+ try:
+ topology.standalone.simple_bind_s(BOGUSSUFFIX, 'bogus')
+ except ldap.LDAPError as e:
+ log.info("Exception (expected): %s" % type(e).__name__)
+ log.info('Desc ' + e.message['desc'])
+ assert isinstance(e, ldap.INVALID_CREDENTIALS)
+ regex = re.compile('No such suffix')
+ cause = pattern_accesslog(file_obj, regex)
+ if cause == None:
+ log.fatal('Cause not found - %s' % cause)
+ assert False
+ else:
+ log.info('Cause found - %s' % cause)
+
+ log.info('Bind case 2-3. the bind user\'s password is wrong, bind should fail with error %s' % ldap.INVALID_CREDENTIALS.__name__)
+ log.info('Bind as {%s,%s} who does not exist.' % (BINDDN, 'bogus'))
+ try:
+ topology.standalone.simple_bind_s(BINDDN, 'bogus')
+ except ldap.LDAPError as e:
+ log.info("Exception (expected): %s" % type(e).__name__)
+ log.info('Desc ' + e.message['desc'])
+ assert isinstance(e, ldap.INVALID_CREDENTIALS)
+ regex = re.compile('Invalid credentials')
+ cause = pattern_accesslog(file_obj, regex)
+ if cause == None:
+ log.fatal('Cause not found - %s' % cause)
+ assert False
+ else:
+ log.info('Cause found - %s' % cause)
+
+ log.info('Adding aci for %s to %s.' % (BINDDN, BINDOU))
+ acival = '(targetattr="*")(version 3.0; acl "%s"; allow(all) userdn = "ldap:///%s";)' % (BUID, BINDDN)
+ log.info('aci: %s' % acival)
+ log.info('Bind as {%s,%s}' % (DN_DM, PASSWORD))
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(BINDOU, [(ldap.MOD_ADD, 'aci', acival)])
+
+ log.info('Bind case 3. the bind user has the right to read the entry itself, bind should be successful.')
+ log.info('Bind as {%s,%s} which should be ok.\n' % (BINDDN, BINDPW))
+ topology.standalone.simple_bind_s(BINDDN, BINDPW)
+
+ log.info('The following operations are against the subtree the bind user %s has no rights.' % BINDDN)
+ # Search
+ exists = True
+ rc = ldap.SUCCESS
+ log.info('Search case 1. the bind user has no rights to read the search entry, it should return no search results with %s' % rc)
+ check_op_result(topology.standalone, 'search', TESTDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.SUCCESS
+ log.info('Search case 2-1. the search entry does not exist, the search should return no search results with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'search', BOGUSDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.SUCCESS
+ log.info('Search case 2-2. the search entry does not exist, the search should return no search results with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'search', BOGUSDN2, None, exists, rc)
+
+ # Add
+ exists = True
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Add case 1. the bind user has no rights AND the adding entry exists, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'add', TESTDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Add case 2-1. the bind user has no rights AND the adding entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'add', BOGUSDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Add case 2-2. the bind user has no rights AND the adding entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'add', BOGUSDN2, None, exists, rc)
+
+ # Modify
+ exists = True
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modify case 1. the bind user has no rights AND the modifying entry exists, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modify', TESTDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modify case 2-1. the bind user has no rights AND the modifying entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modify', BOGUSDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modify case 2-2. the bind user has no rights AND the modifying entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modify', BOGUSDN2, None, exists, rc)
+
+ # Modrdn
+ exists = True
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modrdn case 1. the bind user has no rights AND the renaming entry exists, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', TESTDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modrdn case 2-1. the bind user has no rights AND the renaming entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', BOGUSDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modrdn case 2-2. the bind user has no rights AND the renaming entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', BOGUSDN2, None, exists, rc)
+
+ exists = True
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modrdn case 3. the bind user has no rights AND the node moving an entry to exists, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', TESTDN, GROUPOU, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modrdn case 4-1. the bind user has no rights AND the node moving an entry to does not, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', TESTDN, BOGUSOU, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Modrdn case 4-2. the bind user has no rights AND the node moving an entry to does not, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', TESTDN, BOGUSOU, exists, rc)
+
+ # Delete
+ exists = True
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Delete case 1. the bind user has no rights AND the deleting entry exists, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'delete', TESTDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Delete case 2-1. the bind user has no rights AND the deleting entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'delete', BOGUSDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.INSUFFICIENT_ACCESS
+ log.info('Delete case 2-2. the bind user has no rights AND the deleting entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'delete', BOGUSDN2, None, exists, rc)
+
+ log.info('EXTRA: Check no regressions')
+ log.info('Adding aci for %s to %s.' % (BINDDN, DEFAULT_SUFFIX))
+ acival = '(targetattr="*")(version 3.0; acl "%s-all"; allow(all) userdn = "ldap:///%s";)' % (BUID, BINDDN)
+ log.info('Bind as {%s,%s}' % (DN_DM, PASSWORD))
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', acival)])
+
+ log.info('Bind as {%s,%s}.' % (BINDDN, BINDPW))
+ try:
+ topology.standalone.simple_bind_s(BINDDN, BINDPW)
+ except ldap.LDAPError as e:
+ log.info('Desc ' + e.message['desc'])
+ assert False
+
+ exists = False
+ rc = ldap.NO_SUCH_OBJECT
+ log.info('Search case. the search entry does not exist, the search should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'search', BOGUSDN2, None, exists, rc)
+ file_obj.close()
+
+ exists = True
+ rc = ldap.ALREADY_EXISTS
+ log.info('Add case. the adding entry already exists, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'add', TESTDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.NO_SUCH_OBJECT
+ log.info('Modify case. the modifying entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modify', BOGUSDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.NO_SUCH_OBJECT
+ log.info('Modrdn case 1. the renaming entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', BOGUSDN, None, exists, rc)
+
+ exists = False
+ rc = ldap.NO_SUCH_OBJECT
+ log.info('Modrdn case 2. the node moving an entry to does not, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'modrdn', TESTDN, BOGUSOU, exists, rc)
+
+ exists = False
+ rc = ldap.NO_SUCH_OBJECT
+ log.info('Delete case. the deleting entry does not exist, it should fail with %s' % rc.__name__)
+ check_op_result(topology.standalone, 'delete', BOGUSDN, None, exists, rc)
+
+ log.info('SUCCESS')
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
| 0 |
ff00b07402747aac403478a157adab75e306d7d1
|
389ds/389-ds-base
|
Ticket 50117 - after certain failed import operation, impossible to replay an import operation
Bug Description:
At the beginning of an import, a flag is set to mark the target backend is busy.
Then import tests if there are pending operations. If such operations exist the import can not proceed and fails.
The problem is that in such case of pending operations, the import fails without resetting the busy flag.
It let the backend busy (until next reboot) and prevent new import.
Fix Description:
It needs to reset the busy flag if there are pending operations
https://pagure.io/389-ds-base/issue/50117
Reviewed by: Mark Reynolds, William Brown
Platforms tested: F27
Flag Day: no
Doc impact: no
|
commit ff00b07402747aac403478a157adab75e306d7d1
Author: Thierry Bordaz <[email protected]>
Date: Fri Jan 4 12:24:56 2019 +0100
Ticket 50117 - after certain failed import operation, impossible to replay an import operation
Bug Description:
At the beginning of an import, a flag is set to mark the target backend is busy.
Then import tests if there are pending operations. If such operations exist the import can not proceed and fails.
The problem is that in such case of pending operations, the import fails without resetting the busy flag.
It let the backend busy (until next reboot) and prevent new import.
Fix Description:
It needs to reset the busy flag if there are pending operations
https://pagure.io/389-ds-base/issue/50117
Reviewed by: Mark Reynolds, William Brown
Platforms tested: F27
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index ab794a189..b8052f960 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -704,12 +704,22 @@ ldbm_back_ldif2ldbm(Slapi_PBlock *pb)
}
/* check if an import/restore is already ongoing... */
- if ((instance_set_busy(inst) != 0) ||
- (slapi_counter_get_value(inst->inst_ref_count) > 0)) {
+ if ((instance_set_busy(inst) != 0)) {
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_ldif2ldbm", "ldbm: '%s' is already in the middle of "
"another task and cannot be disturbed.\n",
inst->inst_name);
return -1;
+ } else {
+ 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)."
+ " Import can not proceed until they are completed.\n",
+ inst->inst_name,
+ refcnt);
+ instance_set_not_busy(inst);
+ return -1;
+ }
}
if ((task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE)) {
| 0 |
839c46c8124e6dabc40b568dc90968db9761cf98
|
389ds/389-ds-base
|
Ticket 208 - [RFE] Roles with explicit scoping in RHDS
Bug Description:
A limitation of the application using the role mechanism is that the scope of a role
is the subtree where the role is defined.
That means the role definitions are often mixed with the entries they are dealing with.
Usually configuration info are seperated from the data. This RFE aims to separate the
role definitions from the DIT subtree where are stored the entries
Fix Description:
This RFE introduces a new configuration attribute 'nsRoleScopeDN' in the role definition.
This attribute specifies the subtree where the role apply.
See http://directory.fedoraproject.org/wiki/Creation_of_an_explicit_scoping_for_the_roles_%28ticket_208%29
https://fedorahosted.org/389/ticket/208
Reviewed by: Noriko Hosoi (thanks Noriko !)
Platforms tested: Fedora 17
Flag Day: no
Doc impact: yes
A role definition (entry with Objectclass=nsRoleDefinition), may contain an optional single valued attribute
'nsRoleScopeDN'.
In that case, the role does not apply to the subtree where it is defined but to the subtree referred by 'nsRoleScopeDN'.
'nsRoleScopeDN' is a DN syntax attribute. To be taken into account, its value must be a subtree under the suffix
where the role is defined.
If not present or with invalid value, the role will apply to the subtree where it is defined.
|
commit 839c46c8124e6dabc40b568dc90968db9761cf98
Author: Thierry bordaz (tbordaz) <[email protected]>
Date: Fri Jun 28 14:30:59 2013 +0200
Ticket 208 - [RFE] Roles with explicit scoping in RHDS
Bug Description:
A limitation of the application using the role mechanism is that the scope of a role
is the subtree where the role is defined.
That means the role definitions are often mixed with the entries they are dealing with.
Usually configuration info are seperated from the data. This RFE aims to separate the
role definitions from the DIT subtree where are stored the entries
Fix Description:
This RFE introduces a new configuration attribute 'nsRoleScopeDN' in the role definition.
This attribute specifies the subtree where the role apply.
See http://directory.fedoraproject.org/wiki/Creation_of_an_explicit_scoping_for_the_roles_%28ticket_208%29
https://fedorahosted.org/389/ticket/208
Reviewed by: Noriko Hosoi (thanks Noriko !)
Platforms tested: Fedora 17
Flag Day: no
Doc impact: yes
A role definition (entry with Objectclass=nsRoleDefinition), may contain an optional single valued attribute
'nsRoleScopeDN'.
In that case, the role does not apply to the subtree where it is defined but to the subtree referred by 'nsRoleScopeDN'.
'nsRoleScopeDN' is a DN syntax attribute. To be taken into account, its value must be a subtree under the suffix
where the role is defined.
If not present or with invalid value, the role will apply to the subtree where it is defined.
diff --git a/ldap/schema/02common.ldif b/ldap/schema/02common.ldif
index fa604c60e..b67ec8dfc 100644
--- a/ldap/schema/02common.ldif
+++ b/ldap/schema/02common.ldif
@@ -146,6 +146,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.1004 NAME 'nsds7WindowsDomain' DESC 'Net
attributeTypes: ( 2.16.840.1.113730.3.1.1005 NAME 'nsds7DirsyncCookie' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.1099 NAME 'winSyncInterval' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.1100 NAME 'oneWaySync' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.1101 NAME 'nsRoleScopeDN' DESC 'Scope of a role' 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.2139 NAME 'winSyncMoveAction' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 1.3.6.1.1.4 NAME 'vendorName' EQUALITY 1.3.6.1.4.1.1466.109.114.1 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation X-ORIGIN 'RFC 3045' )
attributeTypes: ( 1.3.6.1.1.5 NAME 'vendorVersion' EQUALITY 1.3.6.1.4.1.1466.109.114.1 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation X-ORIGIN 'RFC 3045' )
@@ -171,7 +172,7 @@ objectClasses: ( 2.16.840.1.113730.3.2.32 NAME 'netscapeMachineData' DESC 'Netsc
objectClasses: ( 2.16.840.1.113730.3.2.38 NAME 'vlvSearch' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ vlvBase $ vlvScope $ vlvFilter ) MAY ( multiLineDescription ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.42 NAME 'vlvIndex' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ vlvSort ) MAY ( vlvEnabled $ vlvUses ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.84 NAME 'cosDefinition' DESC 'Netscape defined objectclass' SUP top MAY ( costargettree $ costemplatedn $ cosspecifier $ cosattribute $ aci $ cn $ uid ) X-ORIGIN 'Netscape Directory Server' )
-objectClasses: ( 2.16.840.1.113730.3.2.93 NAME 'nsRoleDefinition' DESC 'Netscape defined objectclass' SUP ldapSubEntry MAY ( description ) X-ORIGIN 'Netscape Directory Server' )
+objectClasses: ( 2.16.840.1.113730.3.2.93 NAME 'nsRoleDefinition' DESC 'Netscape defined objectclass' SUP ldapSubEntry MAY ( description $ nsRoleScopeDN ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.94 NAME 'nsSimpleRoleDefinition' DESC 'Netscape defined objectclass' SUP nsRoleDefinition X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.95 NAME 'nsComplexRoleDefinition' DESC 'Netscape defined objectclass' SUP nsRoleDefinition X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.96 NAME 'nsManagedRoleDefinition' DESC 'Netscape defined objectclass' SUP nsSimpleRoleDefinition X-ORIGIN 'Netscape Directory Server' )
diff --git a/ldap/servers/plugins/roles/roles_cache.c b/ldap/servers/plugins/roles/roles_cache.c
index 89acc59b3..664ced146 100644
--- a/ldap/servers/plugins/roles/roles_cache.c
+++ b/ldap/servers/plugins/roles/roles_cache.c
@@ -88,6 +88,7 @@ typedef struct _role_object_nested {
/* Role object structure */
typedef struct _role_object {
Slapi_DN *dn; /* dn of a role entry */
+ Slapi_DN *rolescopedn; /* if set, this role will apply to any entry in the scope of this dn */
int type; /* ROLE_TYPE_MANAGED|ROLE_TYPE_FILTERED|ROLE_TYPE_NESTED */
Slapi_Filter *filter; /* if ROLE_TYPE_FILTERED */
Avlnode *avl_tree; /* if ROLE_TYPE_NESTED: tree of nested DNs (avl_data is a role_object_nested struct) */
@@ -181,7 +182,7 @@ static int roles_is_entry_member_of_object_ext(vattr_context *c, caddr_t data, c
static int roles_check_managed(Slapi_Entry *entry_to_check, role_object *role, int *present);
static int roles_check_filtered(vattr_context *c, Slapi_Entry *entry_to_check, role_object *role, int *present);
static int roles_check_nested(caddr_t data, caddr_t arg);
-static int roles_is_inscope(Slapi_Entry *entry_to_check, Slapi_DN *role_dn);
+static int roles_is_inscope(Slapi_Entry *entry_to_check, role_object *this_role);
static void berval_set_string(struct berval *bv, const char* string);
static void roles_cache_role_def_delete(roles_cache_def *role_def);
static void roles_cache_role_def_free(roles_cache_def *role_def);
@@ -1110,6 +1111,7 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
int rc = 0;
int type = 0;
role_object *this_role = NULL;
+ char *rolescopeDN = NULL;
slapi_log_error(SLAPI_LOG_PLUGIN, ROLES_PLUGIN_SUBSYSTEM,
"--> roles_cache_create_object_from_entry\n");
@@ -1164,6 +1166,41 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
this_role->dn = slapi_sdn_new();
slapi_sdn_copy(slapi_entry_get_sdn(role_entry),this_role->dn);
+
+ rolescopeDN = slapi_entry_attr_get_charptr(role_entry, ROLE_SCOPE_DN);
+ if (rolescopeDN) {
+ Slapi_DN *rolescopeSDN;
+ Slapi_DN *top_rolescopeSDN, *top_this_roleSDN;
+
+ /* Before accepting to use this scope, first check if it belongs to the same suffix */
+ rolescopeSDN = slapi_sdn_new_dn_byref(rolescopeDN);
+ if ((strlen((char *) slapi_sdn_get_ndn(rolescopeSDN)) > 0) &&
+ (slapi_dn_syntax_check(NULL, (char *) slapi_sdn_get_ndn(rolescopeSDN), 1) == 0)) {
+ top_rolescopeSDN = roles_cache_get_top_suffix(rolescopeSDN);
+ top_this_roleSDN = roles_cache_get_top_suffix(this_role->dn);
+ if (slapi_sdn_compare(top_rolescopeSDN, top_this_roleSDN) == 0) {
+ /* rolescopeDN belongs to the same suffix as the role, we can use this scope */
+ this_role->rolescopedn = rolescopeSDN;
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
+ "%s: invalid %s - %s not in the same suffix. Scope skipped.\n",
+ (char*) slapi_sdn_get_dn(this_role->dn),
+ ROLE_SCOPE_DN,
+ rolescopeDN);
+ slapi_sdn_free(&rolescopeSDN);
+ }
+ slapi_sdn_free(&top_rolescopeSDN);
+ slapi_sdn_free(&top_this_roleSDN);
+ } else {
+ /* this is an invalid DN, just ignore this parameter*/
+ slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
+ "%s: invalid %s - %s not a valid DN. Scope skipped.\n",
+ (char*) slapi_sdn_get_dn(this_role->dn),
+ ROLE_SCOPE_DN,
+ rolescopeDN);
+ slapi_sdn_free(&rolescopeSDN);
+ }
+ }
/* Depending upon role type, pull out the remaining information we need */
switch (this_role->type)
@@ -1776,7 +1813,7 @@ static int roles_is_entry_member_of_object_ext(vattr_context *c, caddr_t data, c
goto done;
}
- if (!roles_is_inscope(entry_to_check, this_role->dn))
+ if (!roles_is_inscope(entry_to_check, this_role))
{
slapi_log_error(SLAPI_LOG_PLUGIN,
ROLES_PLUGIN_SUBSYSTEM, "roles_is_entry_member_of_object-> entry not in scope of role\n");
@@ -1955,7 +1992,7 @@ static int roles_check_nested(caddr_t data, caddr_t arg)
return rc;
}
/* get the role_object data associated to that dn */
- if ( roles_is_inscope(get_nsrole->is_entry_member_of, this_role->dn) )
+ if ( roles_is_inscope(get_nsrole->is_entry_member_of, this_role) )
{
/* The list of nested roles is contained in the role definition */
roles_is_entry_member_of_object((caddr_t)this_role, (caddr_t)get_nsrole);
@@ -1974,17 +2011,23 @@ static int roles_check_nested(caddr_t data, caddr_t arg)
----------------------
Tells us if a presented role is in scope with respect to the presented entry
*/
-static int roles_is_inscope(Slapi_Entry *entry_to_check, Slapi_DN *role_dn)
+static int roles_is_inscope(Slapi_Entry *entry_to_check, role_object *this_role)
{
int rc;
- Slapi_DN role_parent;
+ Slapi_DN role_parent;
+ Slapi_DN *scope_dn = NULL;
slapi_log_error(SLAPI_LOG_PLUGIN,
ROLES_PLUGIN_SUBSYSTEM, "--> roles_is_inscope\n");
+ if (this_role->rolescopedn) {
+ scope_dn = this_role->rolescopedn;
+ } else {
+ scope_dn = this_role->dn;
+ }
slapi_sdn_init(&role_parent);
- slapi_sdn_get_parent(role_dn,&role_parent);
+ slapi_sdn_get_parent(scope_dn,&role_parent);
rc = slapi_sdn_scope_test(slapi_entry_get_sdn( entry_to_check ),
&role_parent,
@@ -2000,7 +2043,7 @@ static int roles_is_inscope(Slapi_Entry *entry_to_check, Slapi_DN *role_dn)
slapi_log_error(SLAPI_LOG_PLUGIN,
ROLES_PLUGIN_SUBSYSTEM, "<-- roles_is_inscope: entry %s role %s result %d\n",
- slapi_entry_get_dn_const(entry_to_check),(char*)slapi_sdn_get_ndn(role_dn), rc);
+ slapi_entry_get_dn_const(entry_to_check),(char*)slapi_sdn_get_ndn(scope_dn), rc);
return (rc);
}
@@ -2127,6 +2170,7 @@ static void roles_cache_role_object_free(role_object *this_role)
}
slapi_sdn_free(&this_role->dn);
+ slapi_sdn_free(&this_role->rolescopedn);
/* Free the object */
slapi_ch_free((void**)&this_role);
diff --git a/ldap/servers/plugins/roles/roles_cache.h b/ldap/servers/plugins/roles/roles_cache.h
index 870f5a06e..3a1e26c00 100644
--- a/ldap/servers/plugins/roles/roles_cache.h
+++ b/ldap/servers/plugins/roles/roles_cache.h
@@ -62,6 +62,8 @@
#define ROLE_MANAGED_ATTR_NAME "nsRoleDN"
#define ROLE_NESTED_ATTR_NAME "nsRoleDN"
+#define ROLE_SCOPE_DN "nsRoleScopeDN"
+
#define SLAPI_ROLE_ERROR_NO_FILTER_SPECIFIED -1
#define SLAPI_ROLE_ERROR_FILTER_BAD -2
#define SLAPI_ROLE_DEFINITION_DOESNT_EXIST -3
| 0 |
cb07ce9b52d211ecc1481cfe20883e51034b1658
|
389ds/389-ds-base
|
start/stop may hang indefinitely (like SSL init fails)
Description:
when rerun a start/stop command, check the timeout is not hit
|
commit cb07ce9b52d211ecc1481cfe20883e51034b1658
Author: Thierry bordaz (tbordaz) <[email protected]>
Date: Mon Sep 8 10:43:34 2014 +0200
start/stop may hang indefinitely (like SSL init fails)
Description:
when rerun a start/stop command, check the timeout is not hit
diff --git a/src/lib389/lib389/tools.py b/src/lib389/lib389/tools.py
index f2838821a..7812d12f1 100644
--- a/src/lib389/lib389/tools.py
+++ b/src/lib389/lib389/tools.py
@@ -212,9 +212,13 @@ class DirSrvTools(object):
elif line.find("Initialization Failed") >= 0:
# sometimes the server fails to start - try again
rc = os.system(fullCmd)
+ pos = logfp.tell()
+ break
elif line.find("exiting.") >= 0:
# possible transient condition - try again
rc = os.system(fullCmd)
+ pos = logfp.tell()
+ break
pos = logfp.tell()
line = logfp.readline()
if line.find("PR_Bind") >= 0:
| 0 |
39e056a4fccbb95424f9b22cb5127c3a4972bc23
|
389ds/389-ds-base
|
Resolves: bug 458171
Description: approx search accidentally fails with timelimit although it hasn't hit timelimit.
Fix Description: string_filter_approx used to simply return the return value from
strcmp. The value could be evaluated as LDAP RETURN CODE.
string_filter_approx is a static function and it's called only from
string_filter_ava. The function returns -1 when it fails. Thus, adjusting the
return value of string_filter_approx to the caller function.
|
commit 39e056a4fccbb95424f9b22cb5127c3a4972bc23
Author: Rich Megginson <[email protected]>
Date: Thu Aug 7 21:55:30 2008 +0000
Resolves: bug 458171
Description: approx search accidentally fails with timelimit although it hasn't hit timelimit.
Fix Description: string_filter_approx used to simply return the return value from
strcmp. The value could be evaluated as LDAP RETURN CODE.
string_filter_approx is a static function and it's called only from
string_filter_ava. The function returns -1 when it fails. Thus, adjusting the
return value of string_filter_approx to the caller function.
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index e1aebfdb1..6a1d3c991 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -114,6 +114,10 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
return( -1 );
}
+/*
+ * return value: 0 -- approximately matched
+ * -1 -- did not match
+ */
static int
string_filter_approx( struct berval *bvfilter, Slapi_Value **bvals,
Slapi_Value **retVal)
@@ -181,6 +185,9 @@ string_filter_approx( struct berval *bvfilter, Slapi_Value **bvals,
break;
}
}
+ if (0 != rc) {
+ rc = -1;
+ }
LDAPDebug( LDAP_DEBUG_TRACE, "<= string_filter_approx %d\n",
rc, 0, 0 );
| 0 |
b3a80f2a1269f6595a6d22b2544b6ade9ebabc65
|
389ds/389-ds-base
|
bump nunc-stans version to 0.1.7
|
commit b3a80f2a1269f6595a6d22b2544b6ade9ebabc65
Author: Noriko Hosoi <[email protected]>
Date: Wed Nov 11 10:26:22 2015 -0800
bump nunc-stans version to 0.1.7
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index 724e625b1..ff8586397 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -16,7 +16,7 @@
%global use_nunc_stans __NUNC_STANS_ON__
%if %{use_nunc_stans}
-%global nunc_stans_ver 0.1.6
+%global nunc_stans_ver 0.1.7
%endif
# fedora 15 and later uses tmpfiles.d
| 0 |
6b7f980e80af3803bc395e50bd4228ded9bceb00
|
389ds/389-ds-base
|
Ticket 47888 - DES to AES password conversion fails if a backend is empty
Bug Description: The process of converting DES passwords to AES can incorrectly
disable the DES plugin if an error is encountered. In this case
it was because a backend was defined but was missing the top entry
which lead to an error 32 when searching for DES passwords. This
causes the existing DES passwords to fail to decode.
Fix Description: There are two issues here. One, we should ignore errors when
searching all the backends for passwords. Two, we should only
disable the DES plugin if all the DES passwords were successfully
converted.
https://fedorahosted.org/389/ticket/48777
Reviewed by: nhosoi(Thanks!)
|
commit 6b7f980e80af3803bc395e50bd4228ded9bceb00
Author: Mark Reynolds <[email protected]>
Date: Thu Mar 24 09:46:11 2016 -0400
Ticket 47888 - DES to AES password conversion fails if a backend is empty
Bug Description: The process of converting DES passwords to AES can incorrectly
disable the DES plugin if an error is encountered. In this case
it was because a backend was defined but was missing the top entry
which lead to an error 32 when searching for DES passwords. This
causes the existing DES passwords to fail to decode.
Fix Description: There are two issues here. One, we should ignore errors when
searching all the backends for passwords. Two, we should only
disable the DES plugin if all the DES passwords were successfully
converted.
https://fedorahosted.org/389/ticket/48777
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 4fb85d512..91ad13ef6 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -706,7 +706,8 @@ convert_pbe_des_to_aes()
char **attrs = NULL;
char **backends = NULL;
char *val = NULL;
- int converted_des = 0;
+ int converted_des_passwd = 0;
+ int disable_des = 1;
int result = -1;
int have_aes = 0;
int have_des = 0;
@@ -751,7 +752,7 @@ convert_pbe_des_to_aes()
char *cookie = NULL;
LDAPDebug(LDAP_DEBUG_ANY, "convert_pbe_des_to_aes: "
- "Converting DES passwords to AES...\n",0,0,0);
+ "Checking for DES passwords to convert to AES...\n",0,0,0);
be = slapi_get_first_backend(&cookie);
while (be){
@@ -789,10 +790,13 @@ convert_pbe_des_to_aes()
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
if (LDAP_SUCCESS != result) {
- LDAPDebug(LDAP_DEBUG_ANY,"convert_pbe_des_to_aes: "
- "failed to search for password on (%s) error (%d)\n",
- backends[be_idx], result, 0);
- goto done;
+ slapi_log_error(SLAPI_LOG_TRACE, "convert_pbe_des_to_aes: ",
+ "Failed to search for password attribute (%s) error (%d), skipping suffix (%s)\n",
+ attrs[i], result, backends[be_idx]);
+ slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
+ pb = NULL;
+ continue;
}
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
for (ii = 0; entries && entries[ii]; ii++){
@@ -811,9 +815,9 @@ convert_pbe_des_to_aes()
/* decode the DES password */
if(pw_rever_decode(val, &passwd, attrs[i]) == -1){
LDAPDebug(LDAP_DEBUG_ANY,"convert_pbe_des_to_aes: "
- "failed to decode existing DES password for (%s)\n",
+ "Failed to decode existing DES password for (%s)\n",
slapi_entry_get_dn(entries[ii]), 0, 0);
- converted_des = 0;
+ disable_des = 0;
goto done;
}
@@ -825,7 +829,7 @@ convert_pbe_des_to_aes()
slapi_entry_get_dn(entries[ii]), 0, 0);
slapi_ch_free_string(&passwd);
slapi_value_free(&sval);
- converted_des = 0;
+ disable_des = 0;
goto done;
}
@@ -846,22 +850,18 @@ convert_pbe_des_to_aes()
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
if (LDAP_SUCCESS != result) {
LDAPDebug(LDAP_DEBUG_ANY,"convert_pbe_des_to_aes: "
- "failed to convert password for (%s) error (%d)\n",
+ "Failed to convert password for (%s) error (%d)\n",
slapi_entry_get_dn(entries[ii]), result, 0);
- converted_des = -1;
+ disable_des = 0;
} else {
LDAPDebug(LDAP_DEBUG_ANY,"convert_pbe_des_to_aes: "
- "successfully converted password for (%s)\n",
+ "Successfully converted password for (%s)\n",
slapi_entry_get_dn(entries[ii]), result, 0);
- converted_des = 1;
-
+ converted_des_passwd = 1;
}
slapi_ch_free_string(&passwd);
slapi_value_free(&sval);
slapi_pblock_destroy(mod_pb);
- if(result){
- goto done;
- }
}
slapi_ch_free_string(&val);
}
@@ -872,6 +872,10 @@ convert_pbe_des_to_aes()
}
slapi_ch_free_string(&filter);
}
+ if (!converted_des_passwd){
+ slapi_log_error(SLAPI_LOG_FATAL, "convert_pbe_des_to_aes",
+ "No DES passwords found to convert.\n");
+ }
}
done:
@@ -882,9 +886,9 @@ done:
if (have_aes && have_des){
/*
- * If a conversion attempt did not fail, disable DES plugin
+ * If a conversion attempt did not fail then we can disable the DES plugin
*/
- if(converted_des != -1){
+ if(converted_des_passwd && disable_des){
/*
* Disable the DES plugin - this also prevents potentially expensive
* searches at every server startup.
@@ -917,14 +921,9 @@ done:
des_dn, 0, 0);
}
slapi_pblock_destroy(pb);
- }
- if(converted_des == 1){
- LDAPDebug(LDAP_DEBUG_ANY,"convert_pbe_des_to_aes: "
- "Finished - all DES passwords have been converted to AES.\n",
- 0, 0, 0);
- } else if (converted_des == 0){
- LDAPDebug(LDAP_DEBUG_ANY, "convert_pbe_des_to_aes: "
- "Finished - no DES passwords to convert.\n",0,0,0);
+ LDAPDebug(LDAP_DEBUG_ANY,"convert_pbe_des_to_aes: "
+ "All DES passwords have been converted to AES.\n",
+ 0, 0, 0);
}
}
}
| 0 |
8146fa551eb295aa873ba2bb721f6c2908092184
|
389ds/389-ds-base
|
Resolves: #214728
Summary: Cleaning up obsolete macros in the build
Changes: eliminated macro CYRUS_SASL and BUILD_GSSAPI (Comment #23)
|
commit 8146fa551eb295aa873ba2bb721f6c2908092184
Author: Noriko Hosoi <[email protected]>
Date: Fri Nov 10 01:46:59 2006 +0000
Resolves: #214728
Summary: Cleaning up obsolete macros in the build
Changes: eliminated macro CYRUS_SASL and BUILD_GSSAPI (Comment #23)
diff --git a/ldap/servers/slapd/sasl_io.c b/ldap/servers/slapd/sasl_io.c
index cd296bfbf..717a328fe 100644
--- a/ldap/servers/slapd/sasl_io.c
+++ b/ldap/servers/slapd/sasl_io.c
@@ -35,8 +35,6 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
-#define CYRUS_SASL 1
-
#include "slap.h"
#include "slapi-plugin.h"
#include "fe.h"
@@ -201,7 +199,6 @@ sasl_io_start_packet(Connection *c, PRInt32 *err)
return -1;
}
-#ifdef CYRUS_SASL
if (ret == sizeof(buffer)) {
/* Decode the length (could use ntohl here ??) */
packet_length = buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];
@@ -217,17 +214,6 @@ sasl_io_start_packet(Connection *c, PRInt32 *err)
c->c_sasl_io_private->encrypted_buffer_count = packet_length;
c->c_sasl_io_private->encrypted_buffer_offset = 4;
}
-#else
- if (ret == sizeof(buffer)) {
- /* Decode the length (could use ntohl here ??) */
- packet_length = buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];
- LDAPDebug( LDAP_DEBUG_CONNS,
- "read sasl packet length %ld on connection %d\n", packet_length, c->c_connid, 0 );
- sasl_io_resize_encrypted_buffer(c->c_sasl_io_private, packet_length);
- c->c_sasl_io_private->encrypted_buffer_count = packet_length;
- c->c_sasl_io_private->encrypted_buffer_offset = 0;
- }
-#endif
return 0;
}
static int
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index 8bd1a19ce..6ddac3401 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -36,24 +36,14 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
-#define CYRUS_SASL 1
-
#include <slap.h>
#include <fe.h>
#include <sasl.h>
#include <saslplug.h>
-#ifndef CYRUS_SASL
-#include <saslmod.h>
-#endif
#ifndef _WIN32
#include <unistd.h>
#endif
-/* No GSSAPI on Windows */
-#if !defined(_WIN32)
-#define BUILD_GSSAPI 1
-#endif
-
static char *serverfqdn;
/*
@@ -427,14 +417,8 @@ static int ids_sasl_canon_user(
sasl_conn_t *conn,
void *context,
const char *userbuf, unsigned ulen,
-#ifndef CYRUS_SASL
- const char *authidbuf, unsigned alen,
-#endif
unsigned flags, const char *user_realm,
char *out_user, unsigned out_umax, unsigned *out_ulen
-#ifndef CYRUS_SASL
- ,char *out_authid, unsigned out_amax, unsigned *out_alen
-#endif
)
{
struct propctx *propctx = sasl_auxprop_getctx(conn);
@@ -442,9 +426,6 @@ static int ids_sasl_canon_user(
Slapi_DN *sdn = NULL;
char *pw = NULL;
char *user = NULL;
-#ifndef CYRUS_SASL
- char *authid = NULL;
-#endif
const char *dn;
int isroot = 0;
char *clear = NULL;
@@ -454,17 +435,9 @@ static int ids_sasl_canon_user(
if (user == NULL) {
goto fail;
}
-#ifdef CYRUS_SASL
LDAPDebug(LDAP_DEBUG_TRACE,
"ids_sasl_canon_user(user=%s, realm=%s)\n",
user, user_realm ? user_realm : "", 0);
-#else
- authid = buf2str(authidbuf, alen);
-
- LDAPDebug(LDAP_DEBUG_TRACE,
- "ids_sasl_canon_user(user=%s, authzid=%s, realm=%s)\n",
- user, authid, user_realm ? user_realm : "");
-#endif
if (strncasecmp(user, "dn:", 3) == 0) {
sdn = slapi_sdn_new();
@@ -480,11 +453,9 @@ static int ids_sasl_canon_user(
/* map the sasl username into an entry */
entry = ids_sasl_user_to_entry(conn, context, user, user_realm);
if (entry == NULL) {
-#ifdef CYRUS_SASL
/* Specific return value is supposed to be set instead of
an generic error (SASL_FAIL) for Cyrus SASL */
returnvalue = SASL_NOAUTHZ;
-#endif
goto fail;
}
dn = slapi_entry_get_ndn(entry);
@@ -515,22 +486,8 @@ static int ids_sasl_canon_user(
/* TODO: canonicalize */
PL_strncpyz(out_user, dn, out_umax);
-#ifdef CYRUS_SASL
/* the length of out_user needs to be set for Cyrus SASL */
*out_ulen = strlen(out_user);
-#else
- if (authid )
- {
- int offset = 0;
- /* The authid can start with dn:. In such case remove it */
- if (strncasecmp(authid,"dn:",3) == 0 )
- offset = 3;
- PL_strncpyz(out_authid, authid+offset, out_amax);
- }
- *out_ulen = -1;
- *out_alen = -1;
- slapi_ch_free((void**)&authid);
-#endif
slapi_entry_free(entry);
slapi_ch_free((void**)&user);
@@ -542,16 +499,12 @@ static int ids_sasl_canon_user(
fail:
slapi_entry_free(entry);
slapi_ch_free((void**)&user);
-#ifndef CYRUS_SASL
- slapi_ch_free((void**)&authid);
-#endif
slapi_ch_free((void**)&pw);
slapi_sdn_free(&sdn);
return returnvalue;
}
-#ifdef CYRUS_SASL
static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
{
/* Try to get path from config, otherwise check for SASL_PATH environment
@@ -566,7 +519,6 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
*path = pluginpath;
return SASL_OK;
}
-#endif
static sasl_callback_t ids_sasl_callbacks[] =
{
@@ -586,21 +538,15 @@ static sasl_callback_t ids_sasl_callbacks[] =
NULL
},
{
-#ifdef CYRUS_SASL
SASL_CB_CANON_USER,
-#else
- SASL_CB_SERVER_CANON_USER,
-#endif
(IFP) ids_sasl_canon_user,
NULL
},
-#ifdef CYRUS_SASL
{
SASL_CB_GETPATH,
(IFP) ids_sasl_getpluginpath,
NULL
},
-#endif
{
SASL_CB_LIST_END,
(IFP) NULL,
@@ -636,25 +582,6 @@ int ids_sasl_init(void)
return result;
}
-#ifndef CYRUS_SASL
- result = sasl_server_add_plugin("USERDB", sasl_userdb_init);
-
- if (result != SASL_OK) {
- LDAPDebug(LDAP_DEBUG_TRACE, "failed to add LDAP sasl plugin\n",
- 0, 0, 0);
- return result;
- }
-
-#if defined(BUILD_GSSAPI)
- result = sasl_server_add_plugin("GSSAPI", sasl_gssapi_init);
-
- if (result != SASL_OK) {
- LDAPDebug(LDAP_DEBUG_TRACE, "failed to add LDAP gssapi plugin\n",
- 0, 0, 0);
- }
-#endif
-#endif
-
result = sasl_auxprop_add_plugin("iDS", ids_auxprop_plug_init);
LDAPDebug( LDAP_DEBUG_TRACE, "<= ids_sasl_init\n", 0, 0, 0 );
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.