Thursday, April 21, 2016

[389-commits] 5 commits - dirsrvtests/tests ldap/admin ldap/schema ldap/servers

dirsrvtests/tests/tickets/ticket47536_test.py | 528 +++++++++
dirsrvtests/tests/tickets/ticket48784_test.py | 434 +++++++
ldap/admin/src/scripts/DSUtil.pm.in | 13
ldap/schema/01core389.ldif | 7
ldap/servers/plugins/acl/acllas.c | 64 -
ldap/servers/plugins/acl/aclutil.c | 52
ldap/servers/plugins/replication/repl5_connection.c | 14
ldap/servers/plugins/replication/windows_connection.c | 14
ldap/servers/plugins/retrocl/retrocl.c | 22
ldap/servers/plugins/syntaxes/string.c | 13
ldap/servers/slapd/add.c | 6
ldap/servers/slapd/attr.c | 19
ldap/servers/slapd/back-ldbm/import-threads.c | 23
ldap/servers/slapd/back-ldbm/ldbm_config.c | 110 -
ldap/servers/slapd/back-ldbm/ldbm_instance_config.c | 19
ldap/servers/slapd/bind.c | 10
ldap/servers/slapd/compare.c | 2
ldap/servers/slapd/config.c | 4
ldap/servers/slapd/daemon.c | 3
ldap/servers/slapd/delete.c | 2
ldap/servers/slapd/detach.c | 5
ldap/servers/slapd/dn.c | 6
ldap/servers/slapd/ldaputil.c | 162 ++
ldap/servers/slapd/libglobs.c | 578 ++++------
ldap/servers/slapd/log.c | 78 -
ldap/servers/slapd/mapping_tree.c | 54
ldap/servers/slapd/modify.c | 7
ldap/servers/slapd/modrdn.c | 3
ldap/servers/slapd/opshared.c | 3
ldap/servers/slapd/proto-slap.h | 2
ldap/servers/slapd/pw.c | 60 -
ldap/servers/slapd/saslbind.c | 3
ldap/servers/slapd/schema.c | 16
ldap/servers/slapd/slap.h | 4
ldap/servers/slapd/slapi-plugin.h | 23
ldap/servers/slapd/slapi-private.h | 12
ldap/servers/slapd/ssl.c | 1009 +++++++++++++++---
ldap/servers/slapd/util.c | 138 +-
38 files changed, 2673 insertions(+), 849 deletions(-)

New commits:
commit fa620fc7911d824048909b83125259743378f6a6
Author: Noriko Hosoi <nhosoi@redhat.com>
Date: Wed Apr 20 17:21:20 2016 -0700

Ticket #48800 - Cleaning up error buffers

Description: The changes in this patch is mainly one of these,
1. unifying error buffer size to SLAPI_DSE_RETURNTEXT_SIZE.
An error buf is filled either in config, mapping-tree, log, pass-
word code, where the size SLAPI_DSE_RETURNTEXT_SIZE is expected,
while some callers declare BUFSIZ array and pass it.
Note: SLAPI_DSE_RETURNTEXT_SIZE is defined as 512 in slapi-plugin.h.

2. replacing PR_snprintf with slapi_create_errormsg.
slapi_create_errormsg is almost the same as PR_snprintf except
2-1 the former does not do anything if the place to write the error
message is NULL. With this change, we can skip returning an
error message if it is not needed.
2-2 If buffer size 0 is given, sizeof(buffer) is used as the size
of buffer. The strict size is supposed to be passed only when
the error buffer is allocated on the heap.

3. Avoiding unnecessary array.
Caller sometimes declares an error buffer even though it does not
use it. This patch removed such error buffer declaration or moved
it in the local block where it is being used.

https://fedorahosted.org/389/ticket/48800

Reviewed by wibrown@redhat.com (Thank you, William!!)

diff --git a/ldap/servers/plugins/acl/acllas.c b/ldap/servers/plugins/acl/acllas.c
index 8ab6f58..ff9b450 100644
--- a/ldap/servers/plugins/acl/acllas.c
+++ b/ldap/servers/plugins/acl/acllas.c
@@ -1306,9 +1306,7 @@ DS_LASUserDnAttrEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator,
/* Wow it matches */
slapi_log_error( SLAPI_LOG_ACL, plugin_name,
"%s matches(%s, %s) level (%d)\n", attr_name,
- val,
- ACL_ESCAPE_STRING_WITH_PUNCTUATION (lasinfo.clientDn, ebuf),
- 0);
+ val, ACL_ESCAPE_STRING_WITH_PUNCTUATION (lasinfo.clientDn, ebuf), 0);
matched = ACL_TRUE;
slapi_ch_free ( (void **) &val);
break;
@@ -2844,7 +2842,6 @@ acllas__eval_memberGroupDnAttr (char *attrName, Slapi_Entry *e,
char *str, *s_str, *base, *groupattr = NULL;
int i,j,k,matched, enumerate_groups;
aclUserGroup *u_group;
- char ebuf [ BUFSIZ ];
Slapi_Value *sval=NULL;
const struct berval *attrVal;

@@ -2967,14 +2964,18 @@ acllas__eval_memberGroupDnAttr (char *attrName, Slapi_Entry *e,

slapi_ch_free_string(&filter_str_ptr);

- if (tt == info.lu_idx) {
- slapi_log_error( SLAPI_LOG_ACL, plugin_name, "currDn:(%s) \n\tNO MEMBER ADDED\n",
- ACL_ESCAPE_STRING_WITH_PUNCTUATION (curMemberDn, ebuf));
- } else {
- for (i=tt; i < info.lu_idx; i++)
- slapi_log_error( SLAPI_LOG_ACL, plugin_name,
- "currDn:(%s) \n\tADDED MEMBER[%d]=%s\n",
- ACL_ESCAPE_STRING_WITH_PUNCTUATION (curMemberDn, ebuf), i, info.member[i]);
+ if (slapi_is_loglevel_set(SLAPI_LOG_ACL)) {
+ char ebuf[BUFSIZ];
+ if (tt == info.lu_idx) {
+ slapi_log_error(SLAPI_LOG_ACL, plugin_name, "currDn:(%s) \n\tNO MEMBER ADDED\n",
+ ACL_ESCAPE_STRING_WITH_PUNCTUATION (curMemberDn, ebuf));
+ } else {
+ for (i=tt; i < info.lu_idx; i++) {
+ slapi_log_error(SLAPI_LOG_ACL, plugin_name,
+ "currDn:(%s) \n\tADDED MEMBER[%d]=%s\n",
+ ACL_ESCAPE_STRING_WITH_PUNCTUATION (curMemberDn, ebuf), i, info.member[i]);
+ }
+ }
}

if (info.c_idx >= info.lu_idx) {
@@ -3019,10 +3020,14 @@ acllas__eval_memberGroupDnAttr (char *attrName, Slapi_Entry *e,
}
}

- for (j=0; j < u_group->aclug_numof_member_group; j++)
- slapi_log_error( SLAPI_LOG_ACL, plugin_name,
- "acllas__eval_memberGroupDnAttr:GROUP[%d] IN CACHE:%s\n",
- j, ACL_ESCAPE_STRING_WITH_PUNCTUATION (u_group->aclug_member_groups[j], ebuf));
+ if (slapi_is_loglevel_set(SLAPI_LOG_ACL)) {
+ char ebuf[BUFSIZ];
+ for (j = 0; j < u_group->aclug_numof_member_group; j++) {
+ slapi_log_error(SLAPI_LOG_ACL, plugin_name,
+ "acllas__eval_memberGroupDnAttr:GROUP[%d] IN CACHE:%s\n",
+ j, ACL_ESCAPE_STRING_WITH_PUNCTUATION (u_group->aclug_member_groups[j], ebuf));
+ }
+ }

matched = ACL_FALSE;
slapi_entry_attr_find( e, groupattr, &attr);
@@ -4467,7 +4472,6 @@ acllas_eval_one_role(char *role, lasInfo *lasinfo) {

Slapi_DN *roleDN = NULL;
int rc = ACL_FALSE;
- char ebuf [ BUFSIZ ];

/*
* See if lasinfo.clientDn has role rolebuf.
@@ -4478,26 +4482,24 @@ acllas_eval_one_role(char *role, lasInfo *lasinfo) {

roleDN = slapi_sdn_new_dn_byval(role);
if (role) {
- rc = acllas__user_has_role(
- lasinfo->aclpb,
- roleDN,
- lasinfo->aclpb->aclpb_authorization_sdn);
+ rc = acllas__user_has_role(lasinfo->aclpb, roleDN, lasinfo->aclpb->aclpb_authorization_sdn);
} else { /* The user does not have the empty role */
rc = ACL_FALSE;
}
slapi_sdn_free(&roleDN );

/* Some useful logging */
- if (rc == ACL_TRUE ) {
- slapi_log_error( SLAPI_LOG_ACL, plugin_name,
- "role evaluation: user '%s' does have role '%s'\n",
- ACL_ESCAPE_STRING_WITH_PUNCTUATION (lasinfo->clientDn, ebuf),
- role);
- } else {
- slapi_log_error( SLAPI_LOG_ACL, plugin_name,
- "role evaluation: user '%s' does NOT have role '%s'\n",
- ACL_ESCAPE_STRING_WITH_PUNCTUATION (lasinfo->clientDn, ebuf),
- role);
+ if (slapi_is_loglevel_set(SLAPI_LOG_ACL)) {
+ char ebuf[BUFSIZ];
+ if (rc == ACL_TRUE ) {
+ slapi_log_error(SLAPI_LOG_ACL, plugin_name,
+ "role evaluation: user '%s' does have role '%s'\n",
+ ACL_ESCAPE_STRING_WITH_PUNCTUATION (lasinfo->clientDn, ebuf), role);
+ } else {
+ slapi_log_error(SLAPI_LOG_ACL, plugin_name,
+ "role evaluation: user '%s' does NOT have role '%s'\n",
+ ACL_ESCAPE_STRING_WITH_PUNCTUATION (lasinfo->clientDn, ebuf), role);
+ }
}
return(rc);
}
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index 308cf8b..b0e9d71 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -165,14 +165,13 @@ void
aclutil_print_err (int rv , const Slapi_DN *sdn, const struct berval* val,
char **errbuf)
{
- char ebuf [BUFSIZ];
+ char ebuf[BUFSIZ];
/*
* The maximum size of line is ebuf_size + the log message
* itself (less than 200 characters for all but potentially ACL_INVALID_TARGET)
*/
- char line [BUFSIZ + 200];
- char str [1024];
- const char *dn;
+ char line[BUFSIZ + 200];
+ char str[1024];
char *lineptr = line;
char *newline = NULL;

@@ -185,68 +184,71 @@ aclutil_print_err (int rv , const Slapi_DN *sdn, const struct berval* val,
str[0] = '\0';
}

- dn = slapi_sdn_get_dn ( sdn );
- if (dn && (rv == ACL_INVALID_TARGET) && ((strlen(dn) + strlen(str)) > BUFSIZ)) {
- /*
- * if (str_length + dn_length + 200 char message) > (BUFSIZ + 200) line
- * we have to make space for a bigger line...
- */
- newline = slapi_ch_malloc(strlen(dn) + strlen(str) + 200);
- lineptr = newline;
- }
-
switch (rv) {
case ACL_TARGET_FILTER_ERR:
- sprintf (line, "ACL Internal Error(%d): "
+ sprintf (lineptr, "ACL Internal Error(%d): "
"Error in generating the target filter for the ACL(%s)\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
case ACL_TARGETATTR_FILTER_ERR:
- sprintf (line, "ACL Internal Error(%d): "
+ sprintf (lineptr, "ACL Internal Error(%d): "
"Error in generating the targetattr filter for the ACL(%s)\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
case ACL_TARGETFILTER_ERR:
- sprintf (line, "ACL Internal Error(%d): "
+ sprintf (lineptr, "ACL Internal Error(%d): "
"Error in generating the targetfilter filter for the ACL(%s)\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
case ACL_SYNTAX_ERR:
- sprintf (line, "ACL Syntax Error(%d):%s\n",
+ sprintf (lineptr, "ACL Syntax Error(%d):%s\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
case ACL_ONEACL_TEXT_ERR:
- sprintf (line, "ACL Syntax Error in the Bind Rules(%d):%s\n",
+ sprintf (lineptr, "ACL Syntax Error in the Bind Rules(%d):%s\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
case ACL_ERR_CONCAT_HANDLES:
- sprintf (line, "ACL Internal Error(%d): "
+ sprintf (lineptr, "ACL Internal Error(%d): "
"Error in Concatenating List handles\n",
rv);
break;
case ACL_INVALID_TARGET:
+ {
+ size_t newsize;
+ const char *dn = slapi_sdn_get_dn(sdn);
+ newsize = strlen(dn) + strlen(str) + 200;
+ if (dn && (newsize > sizeof(line))) {
+ /*
+ * if (str_length + dn_length + 200 char message) > (BUFSIZ + 200) line
+ * we have to make space for a bigger line...
+ */
+ newline = slapi_ch_malloc(newsize);
+ lineptr = newline;
+ }
sprintf (lineptr, "ACL Invalid Target Error(%d): "
"Target is beyond the scope of the ACL(SCOPE:%s)",
rv, dn ? escape_string_with_punctuation (dn, ebuf) : "NULL");
sprintf (lineptr + strlen(lineptr), " %s\n", escape_string_with_punctuation (str, ebuf));
break;
+ }
case ACL_INVALID_AUTHMETHOD:
- sprintf (line, "ACL Multiple auth method Error(%d):"
+ sprintf (lineptr, "ACL Multiple auth method Error(%d):"
"Multiple Authentication Metod in the ACL(%s)\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
case ACL_INVALID_AUTHORIZATION:
- sprintf (line, "ACL Syntax Error(%d):"
+ sprintf (lineptr, "ACL Syntax Error(%d):"
"Invalid Authorization statement in the ACL(%s)\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
case ACL_INCORRECT_ACI_VERSION:
- sprintf (line, "ACL Syntax Error(%d):"
+ sprintf (lineptr, "ACL Syntax Error(%d):"
"Incorrect version Number in the ACL(%s)\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
default:
- sprintf (line, "ACL Internal Error(%d):"
+ sprintf (lineptr, "ACL Internal Error(%d):"
"ACL generic error (%s)\n",
rv, escape_string_with_punctuation (str, ebuf));
break;
@@ -254,7 +256,7 @@ aclutil_print_err (int rv , const Slapi_DN *sdn, const struct berval* val,

if (errbuf) {
/* If a buffer is provided, then copy the error */
- aclutil_str_append(errbuf, lineptr );
+ aclutil_str_append(errbuf, lineptr);
}

slapi_log_error( SLAPI_LOG_FATAL, plugin_name, "%s", lineptr);
diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c
index 88f2a1d..1a491ef 100644
--- a/ldap/servers/plugins/replication/repl5_connection.c
+++ b/ldap/servers/plugins/replication/repl5_connection.c
@@ -2190,7 +2190,6 @@ static void
repl5_stop_debug_timeout(Slapi_Eq_Context eqctx, int *setlevel)
{
char buf[20];
- char msg[SLAPI_DSE_RETURNTEXT_SIZE];

if (eqctx && !*setlevel) {
(void)slapi_eq_cancel(eqctx);
@@ -2199,7 +2198,7 @@ repl5_stop_debug_timeout(Slapi_Eq_Context eqctx, int *setlevel)
if (s_debug_timeout && s_debug_level && *setlevel) {
void config_set_errorlog_level(const char *type, char *buf, char *msg, int apply);
sprintf(buf, "%d", 0);
- config_set_errorlog_level("nsslapd-errorlog-level", buf, msg, 1);
+ config_set_errorlog_level("nsslapd-errorlog-level", buf, NULL, 1);
}
}

@@ -2209,11 +2208,10 @@ repl5_debug_timeout_callback(time_t when, void *arg)
int *setlevel = (int *)arg;
void config_set_errorlog_level(const char *type, char *buf, char *msg, int apply);
char buf[20];
- char msg[SLAPI_DSE_RETURNTEXT_SIZE];

*setlevel = 1;
sprintf(buf, "%d", s_debug_level);
- config_set_errorlog_level("nsslapd-errorlog-level", buf, msg, 1);
+ config_set_errorlog_level("nsslapd-errorlog-level", buf, NULL, 1);

slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"repl5_debug_timeout_callback: set debug level to %d at %ld\n",
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index cab3715..1ac753d 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -2029,7 +2029,6 @@ static void
repl5_stop_debug_timeout(Slapi_Eq_Context eqctx, int *setlevel)
{
char buf[20];
- char msg[SLAPI_DSE_RETURNTEXT_SIZE];

LDAPDebug( LDAP_DEBUG_TRACE, "=> repl5_stop_debug_timeout\n", 0, 0, 0 );

@@ -2040,7 +2039,7 @@ repl5_stop_debug_timeout(Slapi_Eq_Context eqctx, int *setlevel)
if (s_debug_timeout && s_debug_level && *setlevel) {
/* No longer needed as we are including the one in slap.h */
sprintf(buf, "%d", 0);
- config_set_errorlog_level("nsslapd-errorlog-level", buf, msg, 1);
+ config_set_errorlog_level("nsslapd-errorlog-level", buf, NULL, 1);
}

LDAPDebug( LDAP_DEBUG_TRACE, "<= repl5_stop_debug_timeout\n", 0, 0, 0 );
@@ -2052,13 +2051,12 @@ repl5_debug_timeout_callback(time_t when, void *arg)
int *setlevel = (int *)arg;
/* No longer needed as we are including the one in slap.h */
char buf[20];
- char msg[SLAPI_DSE_RETURNTEXT_SIZE];

LDAPDebug( LDAP_DEBUG_TRACE, "=> repl5_debug_timeout_callback\n", 0, 0, 0 );

*setlevel = 1;
sprintf(buf, "%d", s_debug_level);
- config_set_errorlog_level("nsslapd-errorlog-level", buf, msg, 1);
+ config_set_errorlog_level("nsslapd-errorlog-level", buf, NULL, 1);

slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,
"repl5_debug_timeout_callback: set debug level to %d at %ld\n",
diff --git a/ldap/servers/plugins/retrocl/retrocl.c b/ldap/servers/plugins/retrocl/retrocl.c
index 4bcbb38..427448a 100644
--- a/ldap/servers/plugins/retrocl/retrocl.c
+++ b/ldap/servers/plugins/retrocl/retrocl.c
@@ -189,7 +189,7 @@ static int retrocl_select_backend(void)
Slapi_Backend *be = NULL;
Slapi_Entry *referral = NULL;
Slapi_Operation *op = NULL;
- char errbuf[BUFSIZ];
+ char errbuf[SLAPI_DSE_RETURNTEXT_SIZE];

pb = slapi_pblock_new();

@@ -204,19 +204,19 @@ static int retrocl_select_backend(void)
slapi_pblock_set(pb,SLAPI_OPERATION, op);

err = slapi_mapping_tree_select(pb,&be,&referral,errbuf);
- slapi_entry_free(referral);
+ slapi_entry_free(referral);

if (err != LDAP_SUCCESS || be == NULL || be == defbackend_get_backend()) {
- LDAPDebug2Args(LDAP_DEBUG_TRACE,"Mapping tree select failed (%d) %s.\n",
- err,errbuf);
-
- /* could not find the backend for cn=changelog, either because
- * it doesn't exist
- * mapping tree not registered.
- */
- err = retrocl_create_config();
+ slapi_log_error(SLAPI_LOG_FATAL, RETROCL_PLUGIN_NAME,
+ "Mapping tree select failed (%d) %s.\n", err, errbuf);
+
+ /* could not find the backend for cn=changelog, either because
+ * it doesn't exist
+ * mapping tree not registered.
+ */
+ err = retrocl_create_config();

- if (err != LDAP_SUCCESS) return err;
+ if (err != LDAP_SUCCESS) return err;
} else {
retrocl_be_changelog = be;
}
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 666016f..149663b 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -196,7 +196,6 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final,
size_t tmpbufsize;
char pat[BUFSIZ];
char buf[BUFSIZ];
- char ebuf[BUFSIZ];
time_t curtime = 0;
time_t time_up = 0;
time_t optime = 0; /* time op was initiated */
@@ -327,9 +326,9 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final,
pat, p, re_result?re_result:"unknown" );
rc = LDAP_OPERATIONS_ERROR;
goto bailout;
- } else {
- LDAPDebug( LDAP_DEBUG_TRACE, "re_comp (%s)\n",
- escape_string( p, ebuf ), 0, 0 );
+ } else if (slapi_is_loglevel_set(SLAPI_LOG_TRACE)) {
+ char ebuf[BUFSIZ];
+ LDAPDebug(LDAP_DEBUG_TRACE, "re_comp (%s)\n", escape_string(p, ebuf), 0, 0);
}
}

@@ -375,8 +374,10 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final,
tmprc = slapi_re_exec( re, realval, time_up );
}

- LDAPDebug( LDAP_DEBUG_TRACE, "re_exec (%s) %i\n",
- escape_string( realval, ebuf ), tmprc, 0 );
+ if (slapi_is_loglevel_set(SLAPI_LOG_TRACE)) {
+ char ebuf[BUFSIZ];
+ LDAPDebug(LDAP_DEBUG_TRACE, "re_exec (%s) %i\n", escape_string(realval, ebuf), tmprc, 0);
+ }
if ( tmprc == 1 ) {
rc = 0;
break;
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 5e50025..1d34d95 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -150,9 +150,9 @@ do_add( Slapi_PBlock *pb )

normtype = slapi_attr_syntax_normalize(type);
if ( !normtype || !*normtype ) {
- char ebuf[ BUFSIZ ];
+ char ebuf[SLAPI_DSE_RETURNTEXT_SIZE];
rc = LDAP_INVALID_SYNTAX;
- PR_snprintf (ebuf, BUFSIZ, "invalid type '%s'", type);
+ slapi_create_errormsg(ebuf, 0, "invalid type '%s'", type);
op_shared_log_error_access (pb, "ADD", slapi_sdn_get_dn (slapi_entry_get_sdn_const(e)), ebuf);
send_ldap_result( pb, rc, NULL, ebuf, 0, NULL );
slapi_ch_free_string(&type);
@@ -423,7 +423,7 @@ static void op_shared_add (Slapi_PBlock *pb)
char *pwdtype = NULL;
Slapi_Attr *attr = NULL;
Slapi_Entry *referral;
- char errorbuf[BUFSIZ];
+ char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
struct slapdplugin *p = NULL;
char *proxydn = NULL;
char *proxystr = NULL;
diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c
index 2b319f0..06fa6a4 100644
--- a/ldap/servers/slapd/attr.c
+++ b/ldap/servers/slapd/attr.c
@@ -942,14 +942,13 @@ attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval,
{
int retVal = LDAP_SUCCESS;

- if ( strcasecmp ( value, "on" ) != 0 &&
- strcasecmp ( value, "off") != 0 &&
- strcasecmp ( value, "1" ) != 0 &&
- strcasecmp ( value, "0" ) != 0 &&
- strcasecmp ( value, "true" ) != 0 &&
- strcasecmp ( value, "false" ) != 0 ) {
- PR_snprintf ( errorbuf, BUFSIZ,
- "%s: invalid value \"%s\".", attr_name, value );
+ if (strcasecmp ( value, "on" ) != 0 &&
+ strcasecmp ( value, "off") != 0 &&
+ strcasecmp ( value, "1" ) != 0 &&
+ strcasecmp ( value, "0" ) != 0 &&
+ strcasecmp ( value, "true" ) != 0 &&
+ strcasecmp ( value, "false" ) != 0 ) {
+ slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\".", attr_name, value);
retVal = LDAP_CONSTRAINT_VIOLATION;
}

@@ -965,9 +964,7 @@ attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval
val = strtol(value, NULL, 0);
if ( (minval != -1 ? (val < minval ? 1 : 0) : 0) ||
(maxval != -1 ? (val > maxval ? 1 : 0) : 0) ) {
- PR_snprintf ( errorbuf, BUFSIZ,
- "%s: invalid value \"%s\".",
- attr_name, value );
+ slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\".", attr_name, value);
retVal = LDAP_CONSTRAINT_VIOLATION;
}

diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index ae603bc..d279056 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -1761,7 +1761,7 @@ upgradedn_producer(void *param)
if (NULL == dn_norm_sp_conflicts) {
char buf[BUFSIZ];
int my_max = 8;
- while (fgets(buf, BUFSIZ-1, job->upgradefd)) {
+ while (fgets(buf, sizeof(buf)-1, job->upgradefd)) {
/* search "OID0: OID1 OID2 ... */
if (!isdigit(*buf) || (NULL == PL_strchr(buf, ':'))) {
continue;
@@ -3535,7 +3535,7 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
LDAPDebug(LDAP_DEBUG_TRACE, "\ndn: %s\n",
slapi_entry_get_dn_const(*ep), 0, 0);

- if (l <= BUFSIZ)
+ if (l <= sizeof(tmpbuf))
tp = tmpbuf;
else
tp = (char *)slapi_ch_malloc(l); /* should be very rare ... */
@@ -3547,11 +3547,11 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
"dse_conf_backup(%s): write %s failed: %d (%s)\n",
filter, PR_GetError(), slapd_pr_strerror(PR_GetError()));
rval = -1;
- if (l > BUFSIZ)
+ if (l > sizeof(tmpbuf))
slapi_ch_free_string(&tp);
goto out;
}
- if (l > BUFSIZ)
+ if (l > sizeof(tmpbuf))
slapi_ch_free_string(&tp);

for (slapi_entry_first_attr(*ep, &attr); attr;
@@ -3574,7 +3574,7 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
l = strlen(attr_val->bv_val) + attr_name_len + 3; /* : \n" */
LDAPDebug(LDAP_DEBUG_TRACE, "%s: %s\n", attr_name,
attr_val->bv_val, 0);
- if (l <= BUFSIZ)
+ if (l <= sizeof(tmpbuf))
tp = tmpbuf;
else
tp = (char *)slapi_ch_malloc(l);
@@ -3586,11 +3586,11 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char
"dse_conf_backup(%s): write %s failed: %d (%s)\n",
filter, PR_GetError(), slapd_pr_strerror(PR_GetError()));
rval = -1;
- if (l > BUFSIZ)
+ if (l > sizeof(tmpbuf))
slapi_ch_free_string(&tp);
goto out;
}
- if (l > BUFSIZ)
+ if (l > sizeof(tmpbuf))
slapi_ch_free_string(&tp);
}
}
@@ -3980,19 +3980,18 @@ _get_import_entryusn(ImportJob *job, Slapi_Value **usn_value)
/* import_init value is not digit.
* Use the counter which stores the old DB's
* next entryusn. */
- PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN,
- "%" NSPRIu64,
- slapi_counter_get_value(be->be_usn_counter));
+ PR_snprintf(counter_buf, sizeof(counter_buf),
+ "%" NSPRIu64, slapi_counter_get_value(be->be_usn_counter));
} else {
/* import_init value is digit.
* Initialize the entryusn values with the digit */
- PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN, "%s", usn_init_str);
+ PR_snprintf(counter_buf, sizeof(counter_buf), "%s", usn_init_str);
}
slapi_ch_free_string(&usn_init_str);
} else {
/* nsslapd-entryusn-import-init is not defined */
/* Initialize to 0 by default */
- PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN, "0");
+ PR_snprintf(counter_buf, sizeof(counter_buf), "0");
}
usn_berval.bv_val = counter_buf;
usn_berval.bv_len = strlen(usn_berval.bv_val);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 341fdff..58ab9a0 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -73,11 +73,9 @@ int ldbm_config_add_dse_entries(struct ldbminfo *li, char **entries, char *strin
rc = slapi_add_internal_pb(util_pb);
slapi_pblock_get(util_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
if (!rc && (result == LDAP_SUCCESS)) {
- LDAPDebug(LDAP_DEBUG_CONFIG, "Added database config entry [%s]\n",
- ebuf, 0, 0);
+ LDAPDebug1Arg(LDAP_DEBUG_CONFIG, "Added database config entry [%s]\n", ebuf);
} else if (result == LDAP_ALREADY_EXISTS) {
- LDAPDebug(LDAP_DEBUG_TRACE, "Database config entry [%s] already exists - skipping\n",
- ebuf, 0, 0);
+ LDAPDebug1Arg(LDAP_DEBUG_TRACE, "Database config entry [%s] already exists - skipping\n", ebuf);
} else {
LDAPDebug(LDAP_DEBUG_ANY, "Unable to add config entry [%s] to the DSE: %d %d\n",
ebuf, result, rc);
@@ -294,7 +292,9 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int
char *val = (char *) value;
char tmpbuf[BUFSIZ];

- errorbuf[0] = '\0';
+ if (errorbuf) {
+ errorbuf[0] = '\0';
+ }

if (!apply) {
/* we should really do some error checking here. */
@@ -425,10 +425,8 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
} else if (val > li->li_dbcachesize) {
delta = val - li->li_dbcachesize;
if (!util_is_cachesize_sane(&delta)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: dbcachememsize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: dbcachememsize value is too large.\n",
- 0, 0, 0);
+ slapi_create_errormsg(errorbuf, 0, "Error: dbcachememsize value is too large.");
+ LDAPDebug0Args(LDAP_DEBUG_ANY,"Error: dbcachememsize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
}
@@ -499,10 +497,8 @@ static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int
if (val > li->li_dbncache) {
delta = val - li->li_dbncache;
if (!util_is_cachesize_sane(&delta)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: dbncache size value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: dbncache size value is too large.\n",
- val, 0, 0);
+ slapi_create_errormsg(errorbuf, 0, "Error: dbncache size value is too large.");
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,"Error: dbncache size value is too large.\n", val);
return LDAP_UNWILLING_TO_PERFORM;
}
}
@@ -784,7 +780,7 @@ static int ldbm_config_db_old_idl_maxids_set(void *arg, void *value, char *error
if(val >= 0){
li->li_old_idl_maxids = val;
} else {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ slapi_create_errormsg(errorbuf, 0,
"Error: Invalid value for %s (%d). Value must be equal or greater than zero.",
CONFIG_DB_OLD_IDL_MAXIDS, val);
return LDAP_UNWILLING_TO_PERFORM;
@@ -848,10 +844,11 @@ static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *e
int val = (int) ((uintptr_t)value);

if (val < 0 || val > 100) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: Invalid value for %s (%d). Must be between 0 and 100\n", CONFIG_DB_TRICKLE_PERCENTAGE, val);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", errorbuf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
+ slapi_create_errormsg(errorbuf, 0, "Error: Invalid value for %s (%d). Must be between 0 and 100\n",
+ CONFIG_DB_TRICKLE_PERCENTAGE, val);
+ LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: Invalid value for %s (%d). Must be between 0 and 100\n",
+ CONFIG_DB_TRICKLE_PERCENTAGE, val);
+ return LDAP_UNWILLING_TO_PERFORM;
}

if (apply) {
@@ -1081,10 +1078,8 @@ static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int
if (val > li->li_dblayer_private->dblayer_cache_config) {
delta = val - li->li_dblayer_private->dblayer_cache_config;
if (!util_is_cachesize_sane(&delta)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: db cachesize value is too large");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: db cachesize value is too large.\n",
- val, 0, 0);
+ slapi_create_errormsg(errorbuf, 0, "Error: db cachesize value is too large");
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,"Error: db cachesize value is too large.\n", val);
return LDAP_UNWILLING_TO_PERFORM;
}
}
@@ -1214,10 +1209,8 @@ static int ldbm_config_import_cachesize_set(void *arg, void *value, char *errorb
if (val > li->li_import_cachesize) {
delta = val - li->li_import_cachesize;
if (!util_is_cachesize_sane(&delta)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: import cachesize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: import cachesize value is too large.\n",
- 0, 0, 0);
+ slapi_create_errormsg(errorbuf, 0, "Error: import cachesize value is too large.");
+ LDAPDebug0Args(LDAP_DEBUG_ANY,"Error: import cachesize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
}
@@ -1478,17 +1471,19 @@ static int ldbm_config_db_deadlock_policy_set(void *arg, void *value, char *erro
u_int32_t val = (u_int32_t) ((uintptr_t)value);

if (val > DB_LOCK_YOUNGEST) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ slapi_create_errormsg(errorbuf, 0,
"Error: Invalid value for %s (%d). Must be between %d and %d inclusive",
CONFIG_DB_DEADLOCK_POLICY, val, DB_LOCK_DEFAULT, DB_LOCK_YOUNGEST);
- LDAPDebug1Arg(LDAP_DEBUG_ANY, "%s\n", errorbuf);
+ LDAPDebug(LDAP_DEBUG_ANY, "Error: Invalid value for deadlock policy (%d). Must be between %d and %d inclusive",
+ val, DB_LOCK_DEFAULT, DB_LOCK_YOUNGEST);
return LDAP_UNWILLING_TO_PERFORM;
}
if (val == DB_LOCK_NORUN) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ slapi_create_errormsg(errorbuf, 0,
"Warning: Setting value for %s to (%d) will disable deadlock detection",
CONFIG_DB_DEADLOCK_POLICY, val);
- LDAPDebug1Arg(LDAP_DEBUG_ANY, "%s\n", errorbuf);
+ LDAPDebug2Args(LDAP_DEBUG_ANY, "Warning: Setting value for %s to (%d) will disable deadlock detection",
+ CONFIG_DB_DEADLOCK_POLICY, val);
}

if (apply) {
@@ -1907,15 +1902,15 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
config = get_config_info(config_array, attr_name);
if (NULL == config) {
LDAPDebug(LDAP_DEBUG_CONFIG, "Unknown config attribute %s\n", attr_name, 0, 0);
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown config attribute %s\n", attr_name);
+ slapi_create_errormsg(err_buf, 0, "Unknown config attribute %s\n", attr_name);
return LDAP_SUCCESS; /* Ignore unknown attributes */
}

/* Some config attrs can't be changed while the server is running. */
if (phase == CONFIG_PHASE_RUNNING &&
!(config->config_flags & CONFIG_FLAG_ALLOW_RUNNING_CHANGE)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "%s can't be modified while the server is running.\n", attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "%s can't be modified while the server is running.\n", attr_name);
+ slapi_create_errormsg(err_buf, 0, "%s can't be modified while the server is running.\n", attr_name);
return LDAP_UNWILLING_TO_PERFORM;
}

@@ -1933,9 +1928,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
previously set to a non-default value */
if (SLAPI_IS_MOD_ADD(mod_op) && apply_mod &&
(config->config_flags & CONFIG_FLAG_PREVIOUSLY_SET)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE,
- "cannot add a value to single valued attribute %s.\n",
- attr_name);
+ slapi_create_errormsg(err_buf, 0, "cannot add a value to single valued attribute %s.\n", attr_name);
return LDAP_OBJECT_CLASS_VIOLATION;
}
}
@@ -1946,9 +1939,8 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
char buf[BUFSIZ];
ldbm_config_get(arg, config, buf);
if (PL_strncmp(buf, bval->bv_val, bval->bv_len)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE,
- "value [%s] for attribute %s does not match existing value [%s].\n",
- bval->bv_val, attr_name, buf);
+ slapi_create_errormsg(err_buf, 0,
+ "value [%s] for attribute %s does not match existing value [%s].\n", bval->bv_val, attr_name, buf);
return LDAP_NO_SUCH_ATTRIBUTE;
}
}
@@ -1964,21 +1956,22 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
llval = db_atoi(str_val, &err);
/* check for parsing error (e.g. not a number) */
if (err) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
- str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is not a number\n", str_val, attr_name);
+ LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is not a number\n", str_val, attr_name);
return LDAP_UNWILLING_TO_PERFORM;
/* check for overflow */
} else if (LL_CMP(llval, >, llmaxint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is greater than the maximum %d\n",
+ str_val, attr_name, maxint);
+ LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is greater than the maximum %d\n",
str_val, attr_name, maxint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
/* check for underflow */
} else if (LL_CMP(llval, <, llminint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is less than the minimum %d\n",
+ str_val, attr_name, minint);
+ LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is less than the minimum %d\n",
str_val, attr_name, minint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
}
/* convert 64 bit value to 32 bit value */
@@ -2003,21 +1996,24 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
llval = db_atoi(str_val, &err);
/* check for parsing error (e.g. not a number) */
if (err) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is not a number\n",
+ str_val, attr_name);
+ LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is not a number\n",
str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
/* check for overflow */
} else if (LL_CMP(llval, >, llmaxint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is greater than the maximum %d\n",
+ str_val, attr_name, maxint);
+ LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is greater than the maximum %d\n",
str_val, attr_name, maxint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
/* check for underflow */
} else if (LL_CMP(llval, <, llminint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is less than the minimum %d\n",
+ str_val, attr_name, minint);
+ LDAPDebug(LDAP_DEBUG_ANY, "Error: value %s for attr %s is less than the minimum %d\n",
str_val, attr_name, minint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
}
/* convert 64 bit value to 32 bit value */
@@ -2036,15 +2032,17 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc

/* check for parsing error (e.g. not a number) */
if (err == EINVAL) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is not a number\n",
+ str_val, attr_name);
+ LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is not a number\n",
str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
/* check for overflow */
} else if (err == ERANGE) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is outside the range of representable values\n",
+ slapi_create_errormsg(err_buf, 0, "Error: value %s for attr %s is outside the range of representable values\n",
+ str_val, attr_name);
+ LDAPDebug2Args(LDAP_DEBUG_ANY, "Error: value %s for attr %s is outside the range of representable values\n",
str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
}
retval = config->config_set_fn(arg, (void *) sz_val, err_buf, phase, apply_mod);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index e469414..2506261 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -109,10 +109,8 @@ ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, in
if (val > inst->inst_cache.c_maxsize) {
delta = val - inst->inst_cache.c_maxsize;
if (!util_is_cachesize_sane(&delta)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: cachememsize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: cachememsize value is too large.\n",
- 0, 0, 0);
+ slapi_create_errormsg(errorbuf, 0, "Error: cachememsize value is too large.");
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "Error: cachememsize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
}
@@ -153,10 +151,8 @@ ldbm_instance_config_dncachememsize_set(void *arg, void *value, char *errorbuf,
if (val > inst->inst_dncache.c_maxsize) {
delta = val - inst->inst_dncache.c_maxsize;
if (!util_is_cachesize_sane(&delta)){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: dncachememsize value is too large.");
- LDAPDebug( LDAP_DEBUG_ANY,"Error: dncachememsize value is too large.\n",
- 0, 0, 0);
+ slapi_create_errormsg(errorbuf, 0, "Error: dncachememsize value is too large.");
+ LDAPDebug0Args(LDAP_DEBUG_ANY,"Error: dncachememsize value is too large.\n");
return LDAP_UNWILLING_TO_PERFORM;
}
}
@@ -311,10 +307,9 @@ void
ldbm_instance_config_setup_default(ldbm_instance *inst)
{
config_info *config;
- char err_buf[BUFSIZ];

for (config = ldbm_instance_config; config->config_name != NULL; config++) {
- ldbm_config_set((void *)inst, config->config_name, ldbm_instance_config, NULL /* use default */, err_buf, CONFIG_PHASE_INITIALIZATION, 1 /* apply */, LDAP_MOD_REPLACE);
+ ldbm_config_set((void *)inst, config->config_name, ldbm_instance_config, NULL /* use default */, NULL, CONFIG_PHASE_INITIALIZATION, 1 /* apply */, LDAP_MOD_REPLACE);
}
}

@@ -440,7 +435,7 @@ parse_ldbm_instance_config_entry(ldbm_instance *inst, Slapi_Entry *e, config_inf
char *attr_name = NULL;
Slapi_Value *sval = NULL;
struct berval *bval;
- char err_buf[BUFSIZ];
+ char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];

slapi_attr_get_type(attr, &attr_name);

@@ -833,7 +828,7 @@ out:
void
ldbm_instance_config_internal_set(ldbm_instance *inst, char *attrname, char *value)
{
- char err_buf[BUFSIZ];
+ char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
struct berval bval;

bval.bv_val = value;
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index f81edfb..0a630ac 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -100,7 +100,7 @@ do_bind( Slapi_PBlock *pb )
Slapi_DN *sdn = NULL;
int bind_sdn_in_pb = 0; /* is sdn set in the pb? */
Slapi_Entry *referral;
- char errorbuf[BUFSIZ];
+ char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE] = {0};
char **supported, **pmech;
char authtypebuf[256]; /* >26 (strlen(SLAPD_AUTH_SASL)+SASL_MECHNAMEMAX+1) */
Slapi_Entry *bind_target_entry = NULL;
@@ -655,7 +655,7 @@ do_bind( Slapi_PBlock *pb )
}

/* We could be serving multiple database backends. Select the appropriate one */
- if (slapi_mapping_tree_select(pb, &be, &referral, errorbuf) != LDAP_SUCCESS) {
+ if (slapi_mapping_tree_select(pb, &be, &referral, NULL) != LDAP_SUCCESS) {
send_nobackend_ldap_result( pb );
be = NULL;
goto free_and_return;
@@ -685,7 +685,7 @@ do_bind( Slapi_PBlock *pb )
Slapi_DN *pb_sdn;
slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &pb_sdn);
if (!pb_sdn) {
- PR_snprintf(errorbuf, sizeof(errorbuf), "Pre-bind plug-in set NULL dn\n");
+ slapi_create_errormsg(errorbuf, 0, "Pre-bind plug-in set NULL dn\n");
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
goto free_and_return;
} else if ((pb_sdn != sdn) || (sdn_updated = slapi_sdn_compare(original_sdn, pb_sdn))) {
@@ -696,7 +696,7 @@ do_bind( Slapi_PBlock *pb )
sdn = pb_sdn;
dn = slapi_sdn_get_dn(sdn);
if (!dn) {
- PR_snprintf(errorbuf, sizeof(errorbuf), "Pre-bind plug-in set corrupted dn\n");
+ slapi_create_errormsg(errorbuf, 0, "Pre-bind plug-in set corrupted dn\n");
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
goto free_and_return;
}
@@ -710,7 +710,7 @@ do_bind( Slapi_PBlock *pb )
slapi_be_Rlock(be);
slapi_pblock_set( pb, SLAPI_BACKEND, be );
} else {
- PR_snprintf(errorbuf, sizeof(errorbuf), "No matching backend for %s\n", dn);
+ slapi_create_errormsg(errorbuf, 0, "No matching backend for %s\n", dn);
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
goto free_and_return;
}
diff --git a/ldap/servers/slapd/compare.c b/ldap/servers/slapd/compare.c
index 88b803c..36a5be8 100644
--- a/ldap/servers/slapd/compare.c
+++ b/ldap/servers/slapd/compare.c
@@ -41,7 +41,7 @@ do_compare( Slapi_PBlock *pb )
int err;
Slapi_DN sdn;
Slapi_Entry *referral = NULL;
- char errorbuf[BUFSIZ];
+ char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];

LDAPDebug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );

diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c
index c25a586..fd31b7b 100644
--- a/ldap/servers/slapd/config.c
+++ b/ldap/servers/slapd/config.c
@@ -122,7 +122,7 @@ slapd_bootstrap_config(const char *configdir)
int done = 0;
PRInt32 nr = 0;
PRFileDesc *prfd = 0;
- char returntext[SLAPI_DSE_RETURNTEXT_SIZE] = "";
+ char returntext[SLAPI_DSE_RETURNTEXT_SIZE] = {0};
char *buf = 0;
char *lastp = 0;
char *entrystr = 0;
@@ -198,7 +198,7 @@ slapd_bootstrap_config(const char *configdir)
slapi_sdn_init_ndn_byref(&plug_dn, PLUGIN_BASE_DN);
while ((entrystr = dse_read_next_entry(buf, &lastp)) != NULL)
{
- char errorbuf[BUFSIZ];
+ char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
/*
* XXXmcs: it would be better to also pass
* SLAPI_STR2ENTRY_REMOVEDUPVALS in the flags, but
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 91ad13e..b6113c8 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -442,7 +442,6 @@ disk_mon_check_diskspace(char **dirs, PRUint64 threshold, PRUint64 *disk_space)
void
disk_monitoring_thread(void *nothing)
{
- char errorbuf[BUFSIZ];
char **dirs = NULL;
char *dirstr = NULL;
PRUint64 previous_mark = 0;
@@ -553,7 +552,7 @@ disk_monitoring_thread(void *nothing)
/* Setting the log level back to zero, actually sets the value to LDAP_DEBUG_ANY */
config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE,
STRINGIFYDEFINE(SLAPD_DEFAULT_ERRORLOG_LEVEL),
- errorbuf, CONFIG_APPLY);
+ NULL, CONFIG_APPLY);
continue;
}
/*
diff --git a/ldap/servers/slapd/delete.c b/ldap/servers/slapd/delete.c
index d3c4d8a..b2d8408 100644
--- a/ldap/servers/slapd/delete.c
+++ b/ldap/servers/slapd/delete.c
@@ -225,7 +225,7 @@ static void op_shared_delete (Slapi_PBlock *pb)
Slapi_Operation *operation;
Slapi_Entry *referral;
Slapi_Entry *ecopy = NULL;
- char errorbuf[BUFSIZ];
+ char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
int err;
char *proxydn = NULL;
char *proxystr = NULL;
diff --git a/ldap/servers/slapd/detach.c b/ldap/servers/slapd/detach.c
index f7750f1..b5af952 100644
--- a/ldap/servers/slapd/detach.c
+++ b/ldap/servers/slapd/detach.c
@@ -52,7 +52,6 @@ detach( int slapd_exemode, int importexport_encrypt,
char *workingdir = 0;
char *errorlog = 0;
char *ptr = 0;
- char errorbuf[BUFSIZ];
extern char *config_get_errorlog(void);

if ( should_detach ) {
@@ -92,12 +91,12 @@ detach( int slapd_exemode, int importexport_encrypt,
*ptr = 0;
}
(void) chdir( errorlog );
- config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, errorbuf, 1);
+ config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, NULL, 1);
slapi_ch_free_string(&errorlog);
}
} else {
/* calling config_set_workingdir to check for validity of directory, don't apply */
- if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, workingdir, errorbuf, 0) == LDAP_OPERATIONS_ERROR) {
+ if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, workingdir, NULL, 0) == LDAP_OPERATIONS_ERROR) {
return 1;
}
(void) chdir( workingdir );
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index a972f00..5f795cc 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2804,8 +2804,6 @@ ndn_cache_init()
void
ndn_cache_destroy()
{
- char *errorbuf = NULL;
-
if(!ndn_started){
return;
}
@@ -2818,11 +2816,11 @@ ndn_cache_destroy()
ndn_cache_lock = NULL;
}
if(ndn_cache_hashtable){
- ndn_cache_free();
+ ndn_cache_free();
PL_HashTableDestroy(ndn_cache_hashtable);
ndn_cache_hashtable = NULL;
}
- config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
+ config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", NULL, 1 );
slapi_counter_destroy(&ndn_cache->cache_hits);
slapi_counter_destroy(&ndn_cache->cache_tries);
slapi_counter_destroy(&ndn_cache->cache_misses);
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 7bbf10e..dffd67e 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1814,8 +1814,7 @@ config_value_is_null( const char *attrname, const char *value, char *errorbuf,
int or_zero_length )
{
if ( NULL == value || ( or_zero_length && *value == '\0' )) {
- PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: deleting the value is not allowed.", attrname );
+ slapi_create_errormsg(errorbuf, 0, "%s: deleting the value is not allowed.", attrname);
return 1;
}

@@ -1870,9 +1869,9 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in
errno = 0;
threshold = strtoll(value, &endp, 10);
if ( *endp != '\0' || threshold <= 4096 || errno == ERANGE ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid, threshold must be greater than 4096 and less then %lld",
- attrname, value, (long long int)LONG_MAX );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: \"%s\" is invalid, threshold must be greater than 4096 and less then %lld",
+ attrname, value, (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -1911,8 +1910,8 @@ config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf,

period = strtol(value, &endp, 10);
if ( *endp != '\0' || period < 1 || errno == ERANGE ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, grace period must be at least 1 minute",
- attrname, value);
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: \"%s\" is invalid, grace period must be at least 1 minute", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -1948,8 +1947,7 @@ config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf,
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) "
- "is invalid\n",attrname, value);
+ slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n", attrname, value);
return retVal;
}

@@ -1957,8 +1955,8 @@ config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf,
size = 0; /* same as -1 */
}
if(size > 0 && size < 1024000){
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "ndn_cache_max_size too low(%d), changing to "
- "%d bytes.\n",(int)size, NDN_DEFAULT_SIZE);
+ slapi_create_errormsg(errorbuf, 0,
+ "ndn_cache_max_size too low(%d), changing to %d bytes.\n",(int)size, NDN_DEFAULT_SIZE);
size = NDN_DEFAULT_SIZE;
}
if(apply){
@@ -1982,14 +1980,14 @@ config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, in
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) "
- "is invalid\n",attrname, value);
+ slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n", attrname, value);
return retVal;
}

if(size < default_size){
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "nsslapd-sasl-max-buffer-size is too low (%ld), "
- "setting to default value (%ld).\n",size, default_size);
+ slapi_create_errormsg(errorbuf, 0,
+ "nsslapd-sasl-max-buffer-size is too low (%ld), setting to default value (%ld).\n",
+ size, default_size);
size = default_size;
}
if(apply){
@@ -2027,10 +2025,9 @@ config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
nPort = strtol(port, &endp, 10);
if ( *endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort < 0 ) {
retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid, ports must range from 0 to %d",
- attrname, port, LDAP_PORT_MAX );
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: \"%s\" is invalid, ports must range from 0 to %d", attrname, port, LDAP_PORT_MAX);
+ return retVal;
}

if ( nPort == 0 ) {
@@ -2063,9 +2060,8 @@ config_set_secureport( const char *attrname, char *port, char *errorbuf, int app
nPort = strtol(port, &endp, 10);
if (*endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort <= 0 ) {
retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid, ports must range from 1 to %d",
- attrname, port, LDAP_PORT_MAX );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: \"%s\" is invalid, ports must range from 1 to %d", attrname, port, LDAP_PORT_MAX);
}

if (apply) {
@@ -2077,7 +2073,7 @@ config_set_secureport( const char *attrname, char *port, char *errorbuf, int app
}
return retVal;
}
-
+

int
config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int apply ) {
@@ -2093,9 +2089,7 @@ config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int
strcasecmp (value, "allowed") != 0 &&
strcasecmp (value, "required")!= 0 ) {
retVal = LDAP_OPERATIONS_ERROR;
- if( errorbuf )
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: unsupported value: %s", attrname, value );
+ slapi_create_errormsg(errorbuf, 0, "%s: unsupported value: %s", attrname, value);
return retVal;
}
else if ( !apply ) {
@@ -2116,9 +2110,7 @@ config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int
}
else {
retVal = LDAP_OPERATIONS_ERROR;
- if( errorbuf )
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: unsupported value: %s", attrname, value );
+ slapi_create_errormsg(errorbuf, 0, "%s: unsupported value: %s", attrname, value);
}

CFG_UNLOCK_WRITE(slapdFrontendConfig);
@@ -2198,9 +2190,10 @@ config_set_snmp_index(const char *attrname, char *value, char *errorbuf, int app
snmp_index = strtol(value, &endp, 10);

if (*endp != '\0' || errno == ERANGE || snmp_index < snmp_index_disable) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", %s must be greater or equal to %lu (%lu means disabled)",
- attrname, value, CONFIG_SNMP_INDEX_ATTRIBUTE, snmp_index_disable, snmp_index_disable);
- retVal = LDAP_OPERATIONS_ERROR;
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", %s must be greater or equal to %lu (%lu means disabled)",
+ attrname, value, CONFIG_SNMP_INDEX_ATTRIBUTE, snmp_index_disable, snmp_index_disable);
+ retVal = LDAP_OPERATIONS_ERROR;
}
}

@@ -2461,7 +2454,7 @@ config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int app
sizelimit = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || sizelimit < -1 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, sizelimit must range from -1 to %lld",
+ slapi_create_errormsg(errorbuf, 0, "%s: \"%s\" is invalid, sizelimit must range from -1 to %lld",
attrname, value, (long long int)LONG_MAX );
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
@@ -2505,8 +2498,9 @@ config_set_pagedsizelimit( const char *attrname, char *value, char *errorbuf, in
pagedsizelimit = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || pagedsizelimit < -1 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, pagedsizelimit must range from -1 to %lld",
- attrname, value, (long long int)LONG_MAX );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: \"%s\" is invalid, pagedsizelimit must range from -1 to %lld",
+ attrname, value, (long long int)LONG_MAX );
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -2545,16 +2539,14 @@ config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf,

new_scheme = pw_name2scheme(value);
if ( new_scheme == NULL) {
- if ( scheme_list != NULL ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s. Valid schemes are: %s",
- attrname, value, scheme_list );
- } else {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s (no pwdstorage scheme"
- " plugin loaded)",
- attrname, value);
- }
+ if ( scheme_list != NULL ) {
+ slapi_create_errormsg(errorbuf, 0, "%s: invalid scheme - %s. Valid schemes are: %s",
+ attrname, value, scheme_list );
+ } else {
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid scheme - %s (no pwdstorage scheme plugin loaded)",
+ attrname, value);
+ }
retVal = LDAP_OPERATIONS_ERROR;
slapi_ch_free_string(&scheme_list);
return retVal;
@@ -2566,9 +2558,9 @@ config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf,
directory already encrypted. The scheme cannot and don't encrypt password if
they are in clear. We don't take it */

- if ( scheme_list != NULL ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list );
+ if (scheme_list) {
+ slapi_create_errormsg(errorbuf, 0,
+ "pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list);
}
retVal = LDAP_UNWILLING_TO_PERFORM;
slapi_ch_free_string(&scheme_list);
@@ -2728,16 +2720,14 @@ config_set_pw_minlength( const char *attrname, char *value, char *errorbuf, int
minLength = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || minLength < 2 || minLength > 512 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum length \"%s\" is invalid. "
- "The minimum length must range from 2 to 512.",
- value );
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum length \"%s\" is invalid. The minimum length must range from 2 to 512.", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}

if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
+ CFG_LOCK_WRITE(slapdFrontendConfig);

slapdFrontendConfig->pw_policy.pw_minlength = minLength;

@@ -2763,12 +2753,11 @@ config_set_pw_mindigits( const char *attrname, char *value, char *errorbuf, int
minDigits = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || minDigits < 0 || minDigits > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of digits \"%s\" is invalid. "
- "The minimum number of digits must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum number of digits \"%s\" is invalid. "
+ "The minimum number of digits must range from 0 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -2798,12 +2787,11 @@ config_set_pw_minalphas( const char *attrname, char *value, char *errorbuf, int
minAlphas = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || minAlphas < 0 || minAlphas > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of alphas \"%s\" is invalid. "
- "The minimum number of alphas must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum number of alphas \"%s\" is invalid. "
+ "The minimum number of alphas must range from 0 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -2832,13 +2820,12 @@ config_set_pw_minuppers( const char *attrname, char *value, char *errorbuf, int
errno = 0;
minUppers = strtol(value, &endp, 10);

- if ( *endp != '\0' || errno == ERANGE || minUppers < 0 || minUppers > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of uppercase characters \"%s\" is invalid. "
- "The minimum number of uppercase characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ if ( *endp != '\0' || errno == ERANGE || minUppers < 0 || minUppers > 64 ) {
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum number of uppercase characters \"%s\" is invalid. "
+ "The minimum number of uppercase characters must range from 0 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -2868,12 +2855,11 @@ config_set_pw_minlowers( const char *attrname, char *value, char *errorbuf, int
minLowers = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || minLowers < 0 || minLowers > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of lowercase characters \"%s\" is invalid. "
- "The minimum number of lowercase characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum number of lowercase characters \"%s\" is invalid. "
+ "The minimum number of lowercase characters must range from 0 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -2903,12 +2889,11 @@ config_set_pw_minspecials( const char *attrname, char *value, char *errorbuf, in
minSpecials = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || minSpecials < 0 || minSpecials > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of special characters \"%s\" is invalid. "
- "The minimum number of special characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum number of special characters \"%s\" is invalid. "
+ "The minimum number of special characters must range from 0 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -2938,12 +2923,11 @@ config_set_pw_min8bit( const char *attrname, char *value, char *errorbuf, int ap
min8bit = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || min8bit < 0 || min8bit > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of 8-bit characters \"%s\" is invalid. "
- "The minimum number of 8-bit characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum number of 8-bit characters \"%s\" is invalid. "
+ "The minimum number of 8-bit characters must range from 0 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -2973,12 +2957,11 @@ config_set_pw_maxrepeats( const char *attrname, char *value, char *errorbuf, int
maxRepeats = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || maxRepeats < 0 || maxRepeats > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password maximum number of repeated characters \"%s\" is invalid. "
- "The maximum number of repeated characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password maximum number of repeated characters \"%s\" is invalid. "
+ "The maximum number of repeated characters must range from 0 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -3008,12 +2991,11 @@ config_set_pw_mincategories( const char *attrname, char *value, char *errorbuf,
minCategories = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || minCategories < 1 || minCategories > 5 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of categories \"%s\" is invalid. "
- "The minimum number of categories must range from 1 to 5.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum number of categories \"%s\" is invalid. "
+ "The minimum number of categories must range from 1 to 5.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -3043,12 +3025,11 @@ config_set_pw_mintokenlength( const char *attrname, char *value, char *errorbuf,
minTokenLength = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || minTokenLength < 1 || minTokenLength > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum token length \"%s\" is invalid. "
- "The minimum token length must range from 1 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "password minimum token length \"%s\" is invalid. "
+ "The minimum token length must range from 1 to 64.", value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -3078,10 +3059,8 @@ config_set_pw_maxfailure( const char *attrname, char *value, char *errorbuf, int
maxFailure = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || maxFailure <= 0 || maxFailure > 32767 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password maximum retry \"%s\" is invalid. "
- "Password maximum failure must range from 1 to 32767",
- value );
+ slapi_create_errormsg(errorbuf, 0,
+ "password maximum retry \"%s\" is invalid. Password maximum failure must range from 1 to 32767", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3115,10 +3094,8 @@ config_set_pw_inhistory( const char *attrname, char *value, char *errorbuf, int
history = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || history < 1 || history > 24 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password history length \"%s\" is invalid. "
- "The password history must range from 1 to 24",
- value );
+ slapi_create_errormsg(errorbuf, 0,
+ "password history length \"%s\" is invalid. The password history must range from 1 to 24", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3151,9 +3128,7 @@ config_set_pw_lockduration( const char *attrname, char *value, char *errorbuf, i
duration = parse_duration(value);

if ( errno == ERANGE || duration <= 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password lockout duration \"%s\" is invalid. ",
- value );
+ slapi_create_errormsg(errorbuf, 0, "password lockout duration \"%s\" is invalid. ", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3182,9 +3157,7 @@ config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorb
duration = parse_duration(value);

if ( errno == ERANGE || duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password reset count duration \"%s\" is invalid. ",
- value );
+ slapi_create_errormsg(errorbuf, 0, "password reset count duration \"%s\" is invalid. ", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3326,9 +3299,9 @@ config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int
gracelimit = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || gracelimit < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password grace limit \"%s\" is invalid, password grace limit must range from 0 to %lld",
- value , (long long int)LONG_MAX );
+ slapi_create_errormsg(errorbuf, 0,
+ "password grace limit \"%s\" is invalid, password grace limit must range from 0 to %lld",
+ value , (long long int)LONG_MAX);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3549,9 +3522,8 @@ config_set_onoff(const char *attrname, char *value, int *configvalue, char *erro

CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
if (strcasecmp(value, "on") && strcasecmp(value, "off")) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
- attrname, value );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}

@@ -3753,10 +3725,9 @@ config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply
/* pwd enc func returns slapi_ch_malloc memory */
slapdFrontendConfig->rootpw = (slapdFrontendConfig->rootpwstoragescheme->pws_enc)(value);
} else {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password scheme mismatch (passwd scheme is %s; "
- "password is clear text)", attrname,
- slapdFrontendConfig->rootpwstoragescheme->pws_name);
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: password scheme mismatch (passwd scheme is %s; password is clear text)",
+ attrname, slapdFrontendConfig->rootpwstoragescheme->pws_name);
retVal = LDAP_PARAM_ERROR;
}

@@ -3769,25 +3740,25 @@ int
config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
int retVal = LDAP_SUCCESS;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- struct pw_scheme *new_scheme = NULL;
+ struct pw_scheme *new_scheme = NULL;

if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
return LDAP_OPERATIONS_ERROR;
}

- new_scheme = pw_name2scheme ( value );
+ new_scheme = pw_name2scheme ( value );
if (new_scheme == NULL ) {
+ if (errorbuf) {
char * scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
- if ( scheme_list != NULL ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s. Valid schemes are: %s",
+ if ( scheme_list ) {
+ slapi_create_errormsg(errorbuf, 0, "%s: invalid scheme - %s. Valid schemes are: %s",
attrname, value, scheme_list );
} else {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s (no pwdstorage scheme"
- " plugin loaded)", attrname, value);
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid scheme - %s (no pwdstorage scheme plugin loaded)", attrname, value);
}
slapi_ch_free_string(&scheme_list);
+ }
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3863,12 +3834,12 @@ config_set_workingdir( const char *attrname, char *value, char *errorbuf, int ap
}

if ( PR_Access ( value, PR_ACCESS_EXISTS ) != 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" does not exist.", value );
+ slapi_create_errormsg(errorbuf, 0, "Working directory \"%s\" does not exist.", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
if ( PR_Access ( value, PR_ACCESS_WRITE_OK ) != 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" is not writeable.", value );
+ slapi_create_errormsg(errorbuf, 0, "Working directory \"%s\" is not writeable.", value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -3918,7 +3889,8 @@ config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int
threadnum = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || threadnum < 1 || threadnum > 65535 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number must range from 1 to 65535", attrname, value );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", maximum thread number must range from 1 to 65535", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}

@@ -3947,7 +3919,9 @@ config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf,
maxthreadnum = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || maxthreadnum < 1 || maxthreadnum > 65535 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number per connection must range from 1 to 65535", attrname, value );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", maximum thread number per connection must range from 1 to 65535",
+ attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}

@@ -3973,7 +3947,7 @@ config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, in
char *endp = NULL;

slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
+
if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
return LDAP_OPERATIONS_ERROR;
}
@@ -3986,15 +3960,15 @@ config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, in
nValue = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum "
- "file descriptors must range from 1 to %d (the current process limit). "
- "Server will use a setting of %d.", attrname, value, maxVal, maxVal);
- if ( nValue > maxVal ) {
- nValue = maxVal;
- retVal = LDAP_UNWILLING_TO_PERFORM;
- } else {
- retVal = LDAP_OPERATIONS_ERROR;
- }
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", maximum file descriptors must range from 1 to %d (the current process limit). "
+ "Server will use a setting of %d.", attrname, value, maxVal, maxVal);
+ if ( nValue > maxVal ) {
+ nValue = maxVal;
+ retVal = LDAP_UNWILLING_TO_PERFORM;
+ } else {
+ retVal = LDAP_OPERATIONS_ERROR;
+ }
}

if (apply) {
@@ -4014,7 +3988,7 @@ config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int
char *endp = NULL;
struct rlimit rlp;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
+
if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
return LDAP_OPERATIONS_ERROR;
}
@@ -4027,15 +4001,15 @@ config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int
nValue = strtol(value, &endp, 0);

if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", connection table "
- "size must range from 1 to %d (the current process maxdescriptors limit). "
- "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
- if ( nValue > maxVal) {
- nValue = maxVal;
- retVal = LDAP_UNWILLING_TO_PERFORM;
- } else {
- retVal = LDAP_OPERATIONS_ERROR;
- }
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", connection table size must range from 1 to %d (the current process maxdescriptors limit). "
+ "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
+ if ( nValue > maxVal) {
+ nValue = maxVal;
+ retVal = LDAP_UNWILLING_TO_PERFORM;
+ } else {
+ retVal = LDAP_OPERATIONS_ERROR;
+ }
}

if (apply) {
@@ -4069,15 +4043,15 @@ config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf
nValue = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", reserved file "
- "descriptors must range from 1 to %d (the current process maxdescriptors limit). "
- "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
- if ( nValue > maxVal) {
- nValue = maxVal;
- retVal = LDAP_UNWILLING_TO_PERFORM;
- } else {
- retVal = LDAP_OPERATIONS_ERROR;
- }
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", reserved file descriptors must range from 1 to %d (the current process maxdescriptors limit). "
+ "Server will use a setting of %d.", attrname, value, maxVal, maxVal);
+ if ( nValue > maxVal) {
+ nValue = maxVal;
+ retVal = LDAP_UNWILLING_TO_PERFORM;
+ } else {
+ retVal = LDAP_OPERATIONS_ERROR;
+ }
}

if (apply) {
@@ -4089,8 +4063,6 @@ config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf

}

-
-
int
config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
int retVal = LDAP_SUCCESS;
@@ -4107,10 +4079,10 @@ config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, in
nValue = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || nValue < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %lld",
- attrname, value, (long long int)LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %lld",
+ attrname, value, (long long int)LONG_MAX);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -4134,7 +4106,7 @@ config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int a
char *endp = NULL;

slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
+
if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
return LDAP_OPERATIONS_ERROR;
}
@@ -4143,10 +4115,10 @@ config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int a
nValue = strtol(value, &endp, 10);

if (*endp != '\0' || errno == ERANGE || nValue < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", idle timeout must range from 0 to %lld",
- attrname, value, (long long int)LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0, "%s: invalid value \"%s\", idle timeout must range from 0 to %lld",
+ attrname, value, (long long int)LONG_MAX);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if (apply) {
@@ -4167,7 +4139,7 @@ config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbu
char *endp = NULL;

slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
+
if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
return LDAP_OPERATIONS_ERROR;
}
@@ -4176,11 +4148,10 @@ config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbu
nValue = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || nValue < 0 || nValue > 5 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\", group eval nest level must range from 0 to 5",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", group eval nest level must range from 0 to 5", attrname, value);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}
if (apply) {
CFG_LOCK_WRITE(slapdFrontendConfig);
@@ -4235,8 +4206,6 @@ config_set_timelimit( const char *attrname, char *value, char *errorbuf, int app
Slapi_Backend *be = NULL;
char *cookie;

- *errorbuf = 0;
-
if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
return LDAP_OPERATIONS_ERROR;
}
@@ -4245,11 +4214,11 @@ config_set_timelimit( const char *attrname, char *value, char *errorbuf, int app
nVal = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || nVal < -1 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\", time limit must range from -1 to %lld",
- attrname, value, (long long int)LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\", time limit must range from -1 to %lld",
+ attrname, value, (long long int)LONG_MAX );
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -4260,7 +4229,7 @@ config_set_timelimit( const char *attrname, char *value, char *errorbuf, int app
while (be) {
be->be_timelimit = slapdFrontendConfig->timelimit;
be = slapi_get_next_backend (cookie);
- }
+ }
CFG_UNLOCK_WRITE(slapdFrontendConfig);

slapi_ch_free ((void **)&cookie);
@@ -4298,10 +4267,9 @@ config_set_accesslog( const char *attrname, char *value, char *errorbuf, int app

retVal = log_update_accesslogdir ( value, apply );

- if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open accesslog directory \"%s\", client accesses will "
- "not be logged.", value );
+ if (retVal != LDAP_SUCCESS) {
+ slapi_create_errormsg(errorbuf, 0,
+ "Cannot open accesslog directory \"%s\", client accesses will not be logged.", value);
}

if ( apply ) {
@@ -4325,12 +4293,10 @@ config_set_errorlog( const char *attrname, char *value, char *errorbuf, int appl
retVal = log_update_errorlogdir ( value, apply );

if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
- value );
+ slapi_create_errormsg(errorbuf, 0,
+ "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...", value);
syslog(LOG_ERR,
- "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
- value );
+ "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...", value);
g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
}

@@ -4354,9 +4320,8 @@ config_set_auditlog( const char *attrname, char *value, char *errorbuf, int appl

retVal = log_update_auditlogdir ( value, apply );

- if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open auditlog directory \"%s\"", value );
+ if (retVal != LDAP_SUCCESS) {
+ slapi_create_errormsg(errorbuf, 0, "Cannot open auditlog directory \"%s\"", value);
}

if ( apply ) {
@@ -4379,9 +4344,8 @@ config_set_auditfaillog( const char *attrname, char *value, char *errorbuf, int

retVal = log_update_auditfaillogdir ( value, apply );

- if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open auditfaillog directory \"%s\"", value );
+ if (retVal != LDAP_SUCCESS) {
+ slapi_create_errormsg(errorbuf, 0, "Cannot open auditfaillog directory \"%s\"", value);
}

if ( apply ) {
@@ -4409,9 +4373,7 @@ config_set_pw_maxage( const char *attrname, char *value, char *errorbuf, int app
age = parse_duration(value);

if ( age <= 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password maximum age \"%s\" is invalid. ",
- attrname, value );
+ slapi_create_errormsg(errorbuf, 0, "%s: password maximum age \"%s\" is invalid.", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -4436,9 +4398,7 @@ config_set_pw_minage( const char *attrname, char *value, char *errorbuf, int app
/* age in seconds */
age = parse_duration(value);
if ( age < 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password minimum age \"%s\" is invalid. ",
- attrname, value );
+ slapi_create_errormsg(errorbuf, 0, "%s: password minimum age \"%s\" is invalid.", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -4465,10 +4425,10 @@ config_set_pw_warning( const char *attrname, char *value, char *errorbuf, int ap
sec = parse_duration(value);

if (errno == ERANGE || sec < 0) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password warning age \"%s\" is invalid, password warning "
- "age must range from 0 to %lld seconds",
- attrname, value, (long long int)LONG_MAX );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: password warning age \"%s\" is invalid, password warning "
+ "age must range from 0 to %lld seconds",
+ attrname, value, (long long int)LONG_MAX );
retVal = LDAP_OPERATIONS_ERROR;
return retVal;
}
@@ -4497,11 +4457,11 @@ config_set_errorlog_level( const char *attrname, char *value, char *errorbuf, in
level = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: error log level \"%s\" is invalid,"
- " error log level must range from 0 to %lld",
- attrname, value, (long long int)LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0, "%s: error log level \"%s\" is invalid,"
+ " error log level must range from 0 to %lld",
+ attrname, value, (long long int)LONG_MAX);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -4532,11 +4492,11 @@ config_set_accesslog_level( const char *attrname, char *value, char *errorbuf, i
level = strtol(value, &endp, 10);

if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: access log level \"%s\" is invalid,"
- " access log level must range from 0 to %lld",
- attrname, value, (long long int)LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
+ slapi_create_errormsg(errorbuf, 0, "%s: access log level \"%s\" is invalid,"
+ " access log level must range from 0 to %lld",
+ attrname, value, (long long int)LONG_MAX);
+ retVal = LDAP_OPERATIONS_ERROR;
+ return retVal;
}

if ( apply ) {
@@ -4553,17 +4513,17 @@ int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, in
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();

- slapdFrontendConfig->refer_mode=REFER_MODE_OFF;
+ slapdFrontendConfig->refer_mode=REFER_MODE_OFF;

if ((!url) || (!url[0])) {
- strcpy(errorbuf, "referral url must have a value");
- return LDAP_OPERATIONS_ERROR;
+ slapi_create_errormsg(errorbuf, 0, "referral url must have a value");
+ return LDAP_OPERATIONS_ERROR;
}
if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->refer_url = slapi_ch_strdup(url);
- slapdFrontendConfig->refer_mode = REFER_MODE_ON;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapdFrontendConfig->refer_url = slapi_ch_strdup(url);
+ slapdFrontendConfig->refer_mode = REFER_MODE_ON;
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
}
return LDAP_SUCCESS;
}
@@ -4573,8 +4533,8 @@ config_set_versionstring( const char *attrname, char *version, char *errorbuf, i
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();

if ((!version) || (!version[0])) {
- PL_strncpyz(errorbuf, "versionstring must have a value", SLAPI_DSE_RETURNTEXT_SIZE);
- return LDAP_OPERATIONS_ERROR;
+ slapi_create_errormsg(errorbuf, 0, "versionstring must have a value");
+ return LDAP_OPERATIONS_ERROR;
}
if (apply) {
CFG_LOCK_WRITE(slapdFrontendConfig);
@@ -5949,9 +5909,8 @@ config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int ap
errno = 0;
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
+ slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n",attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) "
- "is invalid\n",attrname, value);
return retVal;
}

@@ -6015,9 +5974,9 @@ config_set_maxsasliosize( const char *attrname, char *value, char *errorbuf, int
}

if (retVal != LDAP_SUCCESS) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid. Value must range from -1 to %lld",
- attrname, value, (long long int)LONG_MAX );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: \"%s\" is invalid. Value must range from -1 to %lld",
+ attrname, value, (long long int)LONG_MAX);
} else if (apply) {
CFG_LOCK_WRITE(slapdFrontendConfig);
slapdFrontendConfig->maxsasliosize = maxsasliosize;
@@ -6069,9 +6028,8 @@ config_set_localssf( const char *attrname, char *value, char *errorbuf, int appl
}

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 );
+ slapi_create_errormsg(errorbuf, 0,
+ "%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;
@@ -6112,9 +6070,8 @@ config_set_minssf( const char *attrname, char *value, char *errorbuf, int apply
}

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 );
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: \"%s\" is invalid. Value must range from 0 to %d", attrname, value, INT_MAX);
} else if (apply) {
CFG_LOCK_WRITE(slapdFrontendConfig);
slapdFrontendConfig->minssf = minssf;
@@ -6190,9 +6147,8 @@ config_set_max_filter_nest_level( const char *attrname, char *value,
errno = 0;
level = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
+ slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) " "is invalid\n",attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) "
- "is invalid\n",attrname, value);
return retVal;
}

@@ -6880,9 +6836,7 @@ config_set_schemareplace( const char *attrname, char *value, char *errorbuf, int
0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_ON ) &&
0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY )) {
retVal = LDAP_OPERATIONS_ERROR;
- if( errorbuf ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "unsupported value: %s", value );
- }
+ slapi_create_errormsg(errorbuf, 0, "unsupported value: %s", value);
}
}

@@ -6914,8 +6868,7 @@ config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
errno = 0;
timeout = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) "
- "is invalid\n",attrname, value);
+ slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n",attrname, value);
return LDAP_OPERATIONS_ERROR;
}

@@ -6973,9 +6926,8 @@ config_set_anon_access_switch( const char *attrname, char *value,

if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
(strcasecmp(value, "rootdse") != 0)) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\", "
- "\"off\", or \"rootdse\".", attrname, value);
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\". Valid values are \"on\", \"off\", or \"rootdse\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}

@@ -7011,9 +6963,8 @@ config_set_validate_cert_switch( const char *attrname, char *value,

if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
(strcasecmp(value, "warn") != 0)) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\", "
- "\"off\", or \"warn\".", attrname, value);
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\". Valid values are \"on\", \"off\", or \"warn\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}

@@ -7266,10 +7217,7 @@ config_set_default_naming_context(const char *attrname,
int in_init = 0;
suffix = slapi_create_dn_string("%s", value);
if (NULL == suffix) {
- if (errorbuf) {
- PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s is not a valid suffix.", value);
- }
+ slapi_create_errormsg(errorbuf, 0, "%s is not a valid suffix.", value);
return LDAP_INVALID_DN_SYNTAX;
}
sdn = slapi_get_first_suffix(&node, 0);
@@ -7284,10 +7232,7 @@ config_set_default_naming_context(const char *attrname,
sdn = slapi_get_next_suffix(&node, 0);
}
if (!in_init && (NULL == sdn)) { /* not in startup && no match */
- if (errorbuf) {
- PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s is not an existing suffix.", value);
- }
+ slapi_create_errormsg(errorbuf, 0, "%s is not an existing suffix.", value);
slapi_ch_free_string(&suffix);
return LDAP_NO_SUCH_OBJECT;
}
@@ -7328,9 +7273,8 @@ config_set_unhashed_pw_switch(const char *attrname, char *value,

if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
(strcasecmp(value, "nolog") != 0)) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\", "
- "\"off\", or \"nolog\".", attrname, value);
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\". Valid values are \"on\", \"off\", or \"nolog\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}

@@ -7520,9 +7464,8 @@ config_set_connection_buffer( const char *attrname, char *value,

if ((strcasecmp(value, "0") != 0) && (strcasecmp(value, "1") != 0) &&
(strcasecmp(value, "2") != 0)) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"0\", "
- "\"1\", or \"2\".", attrname, value);
+ slapi_create_errormsg(errorbuf, 0,
+ "%s: invalid value \"%s\". Valid values are \"0\", \"1\", or \"2\".", attrname, value);
retVal = LDAP_OPERATIONS_ERROR;
}

@@ -7549,8 +7492,7 @@ config_set_listen_backlog_size( const char *attrname, char *value,
errno = 0;
size = strtol(value, &endp, 10);
if ( *endp != '\0' || errno == ERANGE){
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "(%s) value (%s) "
- "is invalid\n",attrname, value);
+ slapi_create_errormsg(errorbuf, 0, "(%s) value (%s) is invalid\n", attrname, value);
return LDAP_OPERATIONS_ERROR;
}

@@ -7631,8 +7573,8 @@ config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
#if 0
debugHashTable(attr);

No comments:

Post a Comment