Branch '389-ds-base-1.3.2' - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/cos/cos_cache.c | 82 ++++++++++++++++++++---------------
1 file changed, 48 insertions(+), 34 deletions(-)
New commits:
commit 01c0794cde7eb91a1a4e477a0286533df4a4ae38
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Jan 24 18:12:32 2014 -0800
Ticket #47649 - Server hangs in cos_cache when adding a user entry
Bug description: cos_dn_defs_cb reads cosDefinition and sets up the cos
Definition part of cos cache. In the function, when processing
cosAttribute, cosTargetTree and cosTemlpateDn are missing, it sets the
parent dn of the cos definition dn. This parent setting is needed only
when the 2 attributes are completely missing from the cos definition.
But if the attributes are located below cosAttribute (see the Example
cos definition), in addition to "cn=cosTemplates,ou=people,dc=example,
dc=com", the parent of "cn=generatePostalCode,ou=People,dc=example,dc=com"
is added to the cos cache as cosTemplateDn.
Example cos definition:
dn: cn=generatePostalCode,ou=People,dc=example,dc=com
description: generate postalCode attr based on location
objectClass: top
objectClass: ldapsubentry
objectClass: cossuperdefinition
objectClass: cosClassicDefinition
cosAttribute: postalCode
costemplatedn: cn=cosTemplates,ou=people,dc=example,dc=com
cosSpecifier: l
cn: generatePostalCode
The mistakenly added cosTemplatedDn makes adding an entry under ou=People
notify recreating the cos cache. The notification needs to be outside of
backend transaction since it causes a deadlock with the cos_cache_wait_
on_change thread which cannot read the DB due to the transaction but holds
the lock that the notifier thread is waiting for.
Fix description: The parent of the cos definition dn is set to the
cosTargetTree and the cosTemlpateDn, only when the attributes are
completely missing.
https://fedorahosted.org/389/ticket/47649
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit 1e52401d3abd0377f55676f4a1508a02aaa7f955)
diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c
index 4a3a23a..80eee95 100644
--- a/ldap/servers/plugins/cos/cos_cache.c
+++ b/ldap/servers/plugins/cos/cos_cache.c
@@ -727,7 +727,8 @@ struct dn_defs_info {
* if a particular attempt to add a definition fails: info.ret gets set to
* zero only if we succed to add a def.
*/
-static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
+static int
+cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
{
struct dn_defs_info *info;
cosAttrValue **pSneakyVal = 0;
@@ -877,31 +878,10 @@ static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
dnVals[valIndex]->bv_val);
}
- if(!pCosTargetTree)
- {
- /* get the parent of the definition */
- char *orig = slapi_dn_parent(pDn->val);
- Slapi_DN *psdn = slapi_sdn_new_dn_byval(orig);
- char *parent = (char *)slapi_sdn_get_dn(psdn);
- if (!parent) {
- parent = (char *)slapi_sdn_get_udn(psdn);
- LDAPDebug(LDAP_DEBUG_ANY,
- "cos_cache_build_definition_list: "
- "failed to normalize parent dn %s. "
- "Adding the pre normalized dn.\n",
- parent, 0, 0);
- }
- cos_cache_add_attrval(&pCosTargetTree, parent);
- if (!pCosTemplateDn) {
- cos_cache_add_attrval(&pCosTemplateDn, parent);
- }
- slapi_sdn_free(&psdn);
- }
-
slapi_vattrspi_regattr((vattr_sp_handle *)vattr_handle,
dnVals[valIndex]->bv_val, NULL, NULL);
} /* if(attrType is cosAttribute) */
-
+
/*
* Add the attributetype to the appropriate
* list.
@@ -913,6 +893,47 @@ static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
ber_bvecfree( dnVals );
dnVals = NULL;
} while(!slapi_entry_next_attr(e, dnAttr, &dnAttr));
+
+ if (pCosAttribute && (!pCosTargetTree || !pCosTemplateDn)) {
+ /* get the parent of the definition */
+ char *orig = slapi_dn_parent(pDn->val);
+ char *parent = NULL;
+ if (orig) {
+ parent = slapi_create_dn_string("%s", orig);
+ if (!parent) {
+ parent = orig;
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "cos_dn_defs_cb: "
+ "failed to normalize parent dn %s. "
+ "Adding the pre normalized dn.\n",
+ parent);
+ }
+ if (!pCosTargetTree) {
+ cos_cache_add_attrval(&pCosTargetTree, parent);
+ }
+ if (!pCosTemplateDn) {
+ cos_cache_add_attrval(&pCosTemplateDn, parent);
+ }
+ if (parent != orig) {
+ slapi_ch_free_string(&parent);
+ }
+ slapi_ch_free_string(&orig);
+ } else {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "cos_dn_defs_cb: "
+ "failed to get parent dn of cos definition %s.\n",
+ pDn->val);
+ if (!pCosTemplateDn) {
+ if (!pCosTargetTree) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "cosTargetTree and cosTemplateDn are not set.\n");
+ } else {
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "cosTemplateDn is not set.\n");
+ }
+ } else if (!pCosTargetTree) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "cosTargetTree is not set.\n");
+ }
+ }
+ }
/*
determine the type of class of service scheme
@@ -951,9 +972,7 @@ static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
*/
/* these must exist */
- if( pDn &&
- pObjectclass &&
-
+ if(pDn && pObjectclass &&
(
(cosType == COSTYPE_CLASSIC &&
pCosTemplateDn &&
@@ -3582,14 +3601,9 @@ static int cos_cache_entry_is_cos_related( Slapi_Entry *e) {
{
pObj = (char*)slapi_value_get_string(val);
- /*
- * objectclasses are ascii--maybe strcasecmp() is faster than
- * slapi_utf8casecmp()
- */
- if( !strcasecmp(pObj, "cosdefinition") ||
- !strcasecmp(pObj, "cossuperdefinition") ||
- !strcasecmp(pObj, "costemplate")
- )
+ if(!strcasecmp(pObj, "cosdefinition") ||
+ !strcasecmp(pObj, "cossuperdefinition") ||
+ !strcasecmp(pObj, "costemplate"))
{
rc = 1;
}
10 years, 2 months
ldap/servers
by Noriko Hosoi
ldap/servers/plugins/cos/cos_cache.c | 82 ++++++++++++++++++++---------------
1 file changed, 48 insertions(+), 34 deletions(-)
New commits:
commit 1e52401d3abd0377f55676f4a1508a02aaa7f955
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Jan 24 18:12:32 2014 -0800
Ticket #47649 - Server hangs in cos_cache when adding a user entry
Bug description: cos_dn_defs_cb reads cosDefinition and sets up the cos
Definition part of cos cache. In the function, when processing
cosAttribute, cosTargetTree and cosTemlpateDn are missing, it sets the
parent dn of the cos definition dn. This parent setting is needed only
when the 2 attributes are completely missing from the cos definition.
But if the attributes are located below cosAttribute (see the Example
cos definition), in addition to "cn=cosTemplates,ou=people,dc=example,
dc=com", the parent of "cn=generatePostalCode,ou=People,dc=example,dc=com"
is added to the cos cache as cosTemplateDn.
Example cos definition:
dn: cn=generatePostalCode,ou=People,dc=example,dc=com
description: generate postalCode attr based on location
objectClass: top
objectClass: ldapsubentry
objectClass: cossuperdefinition
objectClass: cosClassicDefinition
cosAttribute: postalCode
costemplatedn: cn=cosTemplates,ou=people,dc=example,dc=com
cosSpecifier: l
cn: generatePostalCode
The mistakenly added cosTemplatedDn makes adding an entry under ou=People
notify recreating the cos cache. The notification needs to be outside of
backend transaction since it causes a deadlock with the cos_cache_wait_
on_change thread which cannot read the DB due to the transaction but holds
the lock that the notifier thread is waiting for.
Fix description: The parent of the cos definition dn is set to the
cosTargetTree and the cosTemlpateDn, only when the attributes are
completely missing.
https://fedorahosted.org/389/ticket/47649
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c
index 4a3a23a..80eee95 100644
--- a/ldap/servers/plugins/cos/cos_cache.c
+++ b/ldap/servers/plugins/cos/cos_cache.c
@@ -727,7 +727,8 @@ struct dn_defs_info {
* if a particular attempt to add a definition fails: info.ret gets set to
* zero only if we succed to add a def.
*/
-static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
+static int
+cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
{
struct dn_defs_info *info;
cosAttrValue **pSneakyVal = 0;
@@ -877,31 +878,10 @@ static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
dnVals[valIndex]->bv_val);
}
- if(!pCosTargetTree)
- {
- /* get the parent of the definition */
- char *orig = slapi_dn_parent(pDn->val);
- Slapi_DN *psdn = slapi_sdn_new_dn_byval(orig);
- char *parent = (char *)slapi_sdn_get_dn(psdn);
- if (!parent) {
- parent = (char *)slapi_sdn_get_udn(psdn);
- LDAPDebug(LDAP_DEBUG_ANY,
- "cos_cache_build_definition_list: "
- "failed to normalize parent dn %s. "
- "Adding the pre normalized dn.\n",
- parent, 0, 0);
- }
- cos_cache_add_attrval(&pCosTargetTree, parent);
- if (!pCosTemplateDn) {
- cos_cache_add_attrval(&pCosTemplateDn, parent);
- }
- slapi_sdn_free(&psdn);
- }
-
slapi_vattrspi_regattr((vattr_sp_handle *)vattr_handle,
dnVals[valIndex]->bv_val, NULL, NULL);
} /* if(attrType is cosAttribute) */
-
+
/*
* Add the attributetype to the appropriate
* list.
@@ -913,6 +893,47 @@ static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
ber_bvecfree( dnVals );
dnVals = NULL;
} while(!slapi_entry_next_attr(e, dnAttr, &dnAttr));
+
+ if (pCosAttribute && (!pCosTargetTree || !pCosTemplateDn)) {
+ /* get the parent of the definition */
+ char *orig = slapi_dn_parent(pDn->val);
+ char *parent = NULL;
+ if (orig) {
+ parent = slapi_create_dn_string("%s", orig);
+ if (!parent) {
+ parent = orig;
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "cos_dn_defs_cb: "
+ "failed to normalize parent dn %s. "
+ "Adding the pre normalized dn.\n",
+ parent);
+ }
+ if (!pCosTargetTree) {
+ cos_cache_add_attrval(&pCosTargetTree, parent);
+ }
+ if (!pCosTemplateDn) {
+ cos_cache_add_attrval(&pCosTemplateDn, parent);
+ }
+ if (parent != orig) {
+ slapi_ch_free_string(&parent);
+ }
+ slapi_ch_free_string(&orig);
+ } else {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "cos_dn_defs_cb: "
+ "failed to get parent dn of cos definition %s.\n",
+ pDn->val);
+ if (!pCosTemplateDn) {
+ if (!pCosTargetTree) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "cosTargetTree and cosTemplateDn are not set.\n");
+ } else {
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "cosTemplateDn is not set.\n");
+ }
+ } else if (!pCosTargetTree) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "cosTargetTree is not set.\n");
+ }
+ }
+ }
/*
determine the type of class of service scheme
@@ -951,9 +972,7 @@ static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data)
*/
/* these must exist */
- if( pDn &&
- pObjectclass &&
-
+ if(pDn && pObjectclass &&
(
(cosType == COSTYPE_CLASSIC &&
pCosTemplateDn &&
@@ -3582,14 +3601,9 @@ static int cos_cache_entry_is_cos_related( Slapi_Entry *e) {
{
pObj = (char*)slapi_value_get_string(val);
- /*
- * objectclasses are ascii--maybe strcasecmp() is faster than
- * slapi_utf8casecmp()
- */
- if( !strcasecmp(pObj, "cosdefinition") ||
- !strcasecmp(pObj, "cossuperdefinition") ||
- !strcasecmp(pObj, "costemplate")
- )
+ if(!strcasecmp(pObj, "cosdefinition") ||
+ !strcasecmp(pObj, "cossuperdefinition") ||
+ !strcasecmp(pObj, "costemplate"))
{
rc = 1;
}
10 years, 2 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/libglobs.c | 54 ++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 23 deletions(-)
New commits:
commit d68dc3235d04caf3736d3587801a3c96cfebccb6
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jan 23 18:07:56 2014 -0800
Ticket #443 - Deleting attribute present in nsslapd-allowed-to-delete-attrs returns Operations error
Description: commit 90dd9bb3c1411daca353d055d90618e67aa1fa7e introduced
an Invalid read/write. The commit meant to allow "on" and "off" as well
as integer 0 and 1 in on/off type of config parameters. This patch converts
the integers to "on" or "off" and pass it to config set function.
https://fedorahosted.org/389/ticket/443
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit c52987d295a9f4a091568d02679765f3a83beb69)
(cherry picked from commit 4266657727fc71afbb6b4f21886ebd86a68b2ed2)
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index cae8d24..8ca9489 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -3177,8 +3177,7 @@ config_set_security( const char *attrname, char *value, char *errorbuf, int appl
}
static int
-config_set_onoff ( const char *attrname, char *value, int *configvalue,
- char *errorbuf, int apply )
+config_set_onoff(const char *attrname, char *value, int *configvalue, char *errorbuf, int apply)
{
int retVal = LDAP_SUCCESS;
slapi_onoff_t newval = -1;
@@ -3186,33 +3185,27 @@ config_set_onoff ( const char *attrname, char *value, int *configvalue,
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
#endif
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
+ if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
+ return LDAP_OPERATIONS_ERROR;
}
CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
- if ( strcasecmp ( value, "on" ) != 0 &&
- strcasecmp ( value, "off") != 0 &&
- /* initializing the value */
- (*(int *)value != LDAP_ON) &&
- (*(int *)value != LDAP_OFF)) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
+ 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 );
+ retVal = LDAP_OPERATIONS_ERROR;
}
if ( !apply ) {
- /* we can return now if we aren't applying the changes */
- return retVal;
+ /* we can return now if we aren't applying the changes */
+ return retVal;
}
if ( strcasecmp ( value, "on" ) == 0 ) {
- newval = LDAP_ON;
+ newval = LDAP_ON;
} else if ( strcasecmp ( value, "off" ) == 0 ) {
- newval = LDAP_OFF;
- } else { /* assume it is an integer */
- newval = *(slapi_onoff_t *)value;
+ newval = LDAP_OFF;
}
#ifdef ATOMIC_GETSET_ONOFF
@@ -7001,6 +6994,18 @@ config_get_listen_backlog_size()
return retVal;
}
+static char *
+config_initvalue_to_onoff(struct config_get_and_set *cgas, char *initvalbuf, size_t initvalbufsize)
+{
+ char *retval = NULL;
+ if (cgas->config_var_type == CONFIG_ON_OFF) {
+ slapi_onoff_t *ival = (slapi_onoff_t *)(intptr_t)cgas->initvalue;
+ PR_snprintf(initvalbuf, initvalbufsize, "%s", (ival && *ival) ? "on" : "off");
+ retval = initvalbuf;
+ }
+ return retval;
+}
+
/*
* This function is intended to be used from the dse code modify callback. It
* is "optimized" for that case because it takes a berval** of values, which is
@@ -7049,12 +7054,15 @@ config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
default:
if ((NULL == values) &&
config_allowed_to_delete_attrs(cgas->attr_name)) {
+ char initvalbuf[64];
+ void *initval = cgas->initvalue;
+ if (cgas->config_var_type == CONFIG_ON_OFF) {
+ initval = (void *)config_initvalue_to_onoff(cgas, initvalbuf, sizeof(initvalbuf));
+ }
if (cgas->setfunc) {
- retval = (cgas->setfunc)(cgas->attr_name, cgas->initvalue,
- errorbuf, apply);
+ retval = (cgas->setfunc)(cgas->attr_name, initval, errorbuf, apply);
} else if (cgas->logsetfunc) {
- retval = (cgas->logsetfunc)(cgas->attr_name, cgas->initvalue,
- cgas->whichlog, errorbuf, apply);
+ retval = (cgas->logsetfunc)(cgas->attr_name, initval, cgas->whichlog, errorbuf, apply);
} else {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"config_set: the attribute %s is read only; "
10 years, 2 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/libglobs.c | 54 ++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 23 deletions(-)
New commits:
commit 4266657727fc71afbb6b4f21886ebd86a68b2ed2
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jan 23 18:07:56 2014 -0800
Ticket #443 - Deleting attribute present in nsslapd-allowed-to-delete-attrs returns Operations error
Description: commit 90dd9bb3c1411daca353d055d90618e67aa1fa7e introduced
an Invalid read/write. The commit meant to allow "on" and "off" as well
as integer 0 and 1 in on/off type of config parameters. This patch converts
the integers to "on" or "off" and pass it to config set function.
https://fedorahosted.org/389/ticket/443
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit c52987d295a9f4a091568d02679765f3a83beb69)
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 58256f4..a73c239 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -3232,8 +3232,7 @@ config_set_security( const char *attrname, char *value, char *errorbuf, int appl
}
static int
-config_set_onoff ( const char *attrname, char *value, int *configvalue,
- char *errorbuf, int apply )
+config_set_onoff(const char *attrname, char *value, int *configvalue, char *errorbuf, int apply)
{
int retVal = LDAP_SUCCESS;
slapi_onoff_t newval = -1;
@@ -3241,33 +3240,27 @@ config_set_onoff ( const char *attrname, char *value, int *configvalue,
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
#endif
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
+ if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
+ return LDAP_OPERATIONS_ERROR;
}
CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
- if ( strcasecmp ( value, "on" ) != 0 &&
- strcasecmp ( value, "off") != 0 &&
- /* initializing the value */
- (*(int *)value != LDAP_ON) &&
- (*(int *)value != LDAP_OFF)) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
+ 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 );
+ retVal = LDAP_OPERATIONS_ERROR;
}
if ( !apply ) {
- /* we can return now if we aren't applying the changes */
- return retVal;
+ /* we can return now if we aren't applying the changes */
+ return retVal;
}
if ( strcasecmp ( value, "on" ) == 0 ) {
- newval = LDAP_ON;
+ newval = LDAP_ON;
} else if ( strcasecmp ( value, "off" ) == 0 ) {
- newval = LDAP_OFF;
- } else { /* assume it is an integer */
- newval = *(slapi_onoff_t *)value;
+ newval = LDAP_OFF;
}
#ifdef ATOMIC_GETSET_ONOFF
@@ -7143,6 +7136,18 @@ config_get_listen_backlog_size()
return retVal;
}
+static char *
+config_initvalue_to_onoff(struct config_get_and_set *cgas, char *initvalbuf, size_t initvalbufsize)
+{
+ char *retval = NULL;
+ if (cgas->config_var_type == CONFIG_ON_OFF) {
+ slapi_onoff_t *ival = (slapi_onoff_t *)(intptr_t)cgas->initvalue;
+ PR_snprintf(initvalbuf, initvalbufsize, "%s", (ival && *ival) ? "on" : "off");
+ retval = initvalbuf;
+ }
+ return retval;
+}
+
/*
* This function is intended to be used from the dse code modify callback. It
* is "optimized" for that case because it takes a berval** of values, which is
@@ -7191,12 +7196,15 @@ config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
default:
if ((NULL == values) &&
config_allowed_to_delete_attrs(cgas->attr_name)) {
+ char initvalbuf[64];
+ void *initval = cgas->initvalue;
+ if (cgas->config_var_type == CONFIG_ON_OFF) {
+ initval = (void *)config_initvalue_to_onoff(cgas, initvalbuf, sizeof(initvalbuf));
+ }
if (cgas->setfunc) {
- retval = (cgas->setfunc)(cgas->attr_name, cgas->initvalue,
- errorbuf, apply);
+ retval = (cgas->setfunc)(cgas->attr_name, initval, errorbuf, apply);
} else if (cgas->logsetfunc) {
- retval = (cgas->logsetfunc)(cgas->attr_name, cgas->initvalue,
- cgas->whichlog, errorbuf, apply);
+ retval = (cgas->logsetfunc)(cgas->attr_name, initval, cgas->whichlog, errorbuf, apply);
} else {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"config_set: the attribute %s is read only; "
10 years, 2 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/libglobs.c | 54 ++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 23 deletions(-)
New commits:
commit c52987d295a9f4a091568d02679765f3a83beb69
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jan 23 18:07:56 2014 -0800
Ticket #443 - Deleting attribute present in nsslapd-allowed-to-delete-attrs returns Operations error
Description: commit 90dd9bb3c1411daca353d055d90618e67aa1fa7e introduced
an Invalid read/write. The commit meant to allow "on" and "off" as well
as integer 0 and 1 in on/off type of config parameters. This patch converts
the integers to "on" or "off" and pass it to config set function.
https://fedorahosted.org/389/ticket/443
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 93e49c3..e887ace 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -3233,8 +3233,7 @@ config_set_security( const char *attrname, char *value, char *errorbuf, int appl
}
static int
-config_set_onoff ( const char *attrname, char *value, int *configvalue,
- char *errorbuf, int apply )
+config_set_onoff(const char *attrname, char *value, int *configvalue, char *errorbuf, int apply)
{
int retVal = LDAP_SUCCESS;
slapi_onoff_t newval = -1;
@@ -3242,33 +3241,27 @@ config_set_onoff ( const char *attrname, char *value, int *configvalue,
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
#endif
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
+ if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
+ return LDAP_OPERATIONS_ERROR;
}
CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
- if ( strcasecmp ( value, "on" ) != 0 &&
- strcasecmp ( value, "off") != 0 &&
- /* initializing the value */
- (*(int *)value != LDAP_ON) &&
- (*(int *)value != LDAP_OFF)) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
+ 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 );
+ retVal = LDAP_OPERATIONS_ERROR;
}
if ( !apply ) {
- /* we can return now if we aren't applying the changes */
- return retVal;
+ /* we can return now if we aren't applying the changes */
+ return retVal;
}
if ( strcasecmp ( value, "on" ) == 0 ) {
- newval = LDAP_ON;
+ newval = LDAP_ON;
} else if ( strcasecmp ( value, "off" ) == 0 ) {
- newval = LDAP_OFF;
- } else { /* assume it is an integer */
- newval = *(slapi_onoff_t *)value;
+ newval = LDAP_OFF;
}
#ifdef ATOMIC_GETSET_ONOFF
@@ -7144,6 +7137,18 @@ config_get_listen_backlog_size()
return retVal;
}
+static char *
+config_initvalue_to_onoff(struct config_get_and_set *cgas, char *initvalbuf, size_t initvalbufsize)
+{
+ char *retval = NULL;
+ if (cgas->config_var_type == CONFIG_ON_OFF) {
+ slapi_onoff_t *ival = (slapi_onoff_t *)(intptr_t)cgas->initvalue;
+ PR_snprintf(initvalbuf, initvalbufsize, "%s", (ival && *ival) ? "on" : "off");
+ retval = initvalbuf;
+ }
+ return retval;
+}
+
/*
* This function is intended to be used from the dse code modify callback. It
* is "optimized" for that case because it takes a berval** of values, which is
@@ -7192,12 +7197,15 @@ config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
default:
if ((NULL == values) &&
config_allowed_to_delete_attrs(cgas->attr_name)) {
+ char initvalbuf[64];
+ void *initval = cgas->initvalue;
+ if (cgas->config_var_type == CONFIG_ON_OFF) {
+ initval = (void *)config_initvalue_to_onoff(cgas, initvalbuf, sizeof(initvalbuf));
+ }
if (cgas->setfunc) {
- retval = (cgas->setfunc)(cgas->attr_name, cgas->initvalue,
- errorbuf, apply);
+ retval = (cgas->setfunc)(cgas->attr_name, initval, errorbuf, apply);
} else if (cgas->logsetfunc) {
- retval = (cgas->logsetfunc)(cgas->attr_name, cgas->initvalue,
- cgas->whichlog, errorbuf, apply);
+ retval = (cgas->logsetfunc)(cgas->attr_name, initval, cgas->whichlog, errorbuf, apply);
} else {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"config_set: the attribute %s is read only; "
10 years, 2 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 2 +-
ldap/servers/slapd/entry.c | 14 ++++++++++++++
ldap/servers/slapd/libglobs.c | 16 ++++++++++++----
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/slap.h | 2 +-
ldap/servers/slapd/slapi-plugin.h | 10 ++++++++++
6 files changed, 39 insertions(+), 7 deletions(-)
New commits:
commit 75e760789f5b3fe03d5ee9e2f6433e7fb9a045f8
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 21 17:05:59 2014 -0500
Ticket 47638 - Overflow in nsslapd-disk-monitoring-threshold on 32bit platform
Bug Description: On 32bit platforms 3000000000 overflows when retrieving the value
from the dse. The value was internally processed correctly, but
the value returned to the client was incorrect.
Fix Description: Created a new CONFIG_LONG_LONG config value type, and the associated
slapi_entry_attr_set_* function.
https://fedorahosted.org/389/ticket/47638
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index a61ad37..3db8350 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -702,7 +702,7 @@ disk_monitoring_thread(void *nothing)
char *dirstr = NULL;
PRUint64 previous_mark = 0;
PRUint64 disk_space = 0;
- PRUint64 threshold = 0;
+ PRInt64 threshold = 0;
PRUint64 halfway = 0;
time_t start = 0;
time_t now = 0;
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index d7df631..d47e0f6 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2915,6 +2915,20 @@ slapi_entry_attr_set_long( Slapi_Entry* e, const char *type, long l)
}
void
+slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
+{
+ char value[20];
+ struct berval bv;
+ struct berval *bvals[2];
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+ sprintf(value,"%lld",l);
+ bv.bv_val = value;
+ bv.bv_len = strlen( value );
+ slapi_entry_attr_replace( e, type, bvals );
+}
+
+void
slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
{
char value[16];
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 0fc9022..8352fc7 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -85,6 +85,7 @@
#define REMOVE_CHANGELOG_CMD "remove"
#define DEFAULT_SASL_MAXBUFSIZE "65536"
#define SLAPD_DEFAULT_SASL_MAXBUFSIZE 65536
+#define DEFAULT_DISK_THRESHOLD "2097152"
/* On UNIX, there's only one copy of slapd_ldap_debug */
/* On NT, each module keeps its own module_ldap_debug, which */
@@ -107,6 +108,7 @@ typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
typedef enum {
CONFIG_INT, /* maps to int */
CONFIG_LONG, /* maps to long */
+ CONFIG_LONG_LONG, /* maps to a long long (PRInt64) */
CONFIG_STRING, /* maps to char* */
CONFIG_CHARRAY, /* maps to char** */
CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
@@ -680,7 +682,8 @@ static struct config_get_and_set {
{CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_threshold,
- CONFIG_LONG, (ConfigGetFunc)config_get_disk_threshold},
+ CONFIG_LONG_LONG, (ConfigGetFunc)config_get_disk_threshold,
+ DEFAULT_DISK_THRESHOLD},
{CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_grace_period,
@@ -3804,10 +3807,10 @@ config_get_disk_grace_period(){
return retVal;
}
-PRUint64
+PRInt64
config_get_disk_threshold(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
+ PRInt64 retVal;
CFG_LOCK_READ(slapdFrontendConfig);
retVal = slapdFrontendConfig->disk_threshold;
@@ -6357,7 +6360,12 @@ config_set_value(
else
slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
break;
-
+ case CONFIG_LONG_LONG:
+ if (value)
+ slapi_entry_attr_set_longlong(e, cgas->attr_name, *((long long*)value));
+ else
+ slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
+ break;
case CONFIG_STRING:
slapi_entry_attr_set_charptr(e, cgas->attr_name,
(value && *((char **)value)) ?
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 4b23aad..d705f30 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -546,7 +546,7 @@ 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();
-PRUint64 config_get_disk_threshold();
+PRInt64 config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_logging_critical();
int config_get_sasl_maxbufsize();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 4724f27..5394455 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2248,7 +2248,7 @@ typedef struct _slapdFrontendConfig {
/* disk monitoring */
int disk_monitoring;
- PRUint64 disk_threshold;
+ PRInt64 disk_threshold;
int disk_grace_period;
int disk_logging_critical;
int ignore_time_skew;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 5c37a70..dc7f87f 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1788,6 +1788,16 @@ void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
/**
+ * Replaces the value or values of an attribute in an entry with a specified long long
+ * data type value.
+ *
+ * \param e Entry in which you want to set the value.
+ * \param type Attribute type in which you want to set the value.
+ * \param l Long Long integer value that you want to assign to the attribute.
+ */
+void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l);
+
+/**
* Replaces the value or values of an attribute in an entry with a specified unsigned
* long data type value.
*
10 years, 2 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 2 +-
ldap/servers/slapd/entry.c | 14 ++++++++++++++
ldap/servers/slapd/libglobs.c | 14 ++++++++++----
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/slap.h | 2 +-
ldap/servers/slapd/slapi-plugin.h | 10 ++++++++++
6 files changed, 37 insertions(+), 7 deletions(-)
New commits:
commit 893d6df017dfd4313350ec5bd93e3efd211cb5eb
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 21 17:05:59 2014 -0500
Ticket 47638 - Overflow in nsslapd-disk-monitoring-threshold on 32bit platform
Bug Description: On 32bit platforms 3000000000 overflows when retrieving the value
from the dse. The value was internally processed correctly, but
the value returned to the client was incorrect.
Fix Description: Created a new CONFIG_LONG_LONG config value type, and the associated
slapi_entry_attr_set_* function.
https://fedorahosted.org/389/ticket/47638
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index b4b23f2..0ac93b0 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -704,7 +704,7 @@ disk_monitoring_thread(void *nothing)
char *dirstr = NULL;
PRUint64 previous_mark = 0;
PRUint64 disk_space = 0;
- PRUint64 threshold = 0;
+ PRInt64 threshold = 0;
PRUint64 halfway = 0;
time_t start = 0;
time_t now = 0;
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 6b93192..1a59427 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2941,6 +2941,20 @@ slapi_entry_attr_set_long( Slapi_Entry* e, const char *type, long l)
}
void
+slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
+{
+ char value[20];
+ struct berval bv;
+ struct berval *bvals[2];
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+ sprintf(value,"%lld",l);
+ bv.bv_val = value;
+ bv.bv_len = strlen( value );
+ slapi_entry_attr_replace( e, type, bvals );
+}
+
+void
slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
{
char value[16];
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 7a686c4..c103a02 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -105,6 +105,7 @@ typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
typedef enum {
CONFIG_INT, /* maps to int */
CONFIG_LONG, /* maps to long */
+ CONFIG_LONG_LONG, /* maps to a long long (PRInt64) */
CONFIG_STRING, /* maps to char* */
CONFIG_CHARRAY, /* maps to char** */
CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
@@ -984,7 +985,7 @@ static struct config_get_and_set {
{CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_threshold,
- CONFIG_LONG, (ConfigGetFunc)config_get_disk_threshold,
+ CONFIG_LONG_LONG, (ConfigGetFunc)config_get_disk_threshold,
DEFAULT_DISK_THRESHOLD},
{CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
NULL, 0,
@@ -4204,10 +4205,10 @@ config_get_disk_grace_period(){
return retVal;
}
-PRUint64
+PRInt64
config_get_disk_threshold(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
+ PRInt64 retVal;
CFG_LOCK_READ(slapdFrontendConfig);
retVal = slapdFrontendConfig->disk_threshold;
@@ -6867,7 +6868,12 @@ config_set_value(
else
slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
break;
-
+ case CONFIG_LONG_LONG:
+ if (value)
+ slapi_entry_attr_set_longlong(e, cgas->attr_name, *((long long*)value));
+ else
+ slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
+ break;
case CONFIG_STRING:
slapi_entry_attr_set_charptr(e, cgas->attr_name,
(value && *((char **)value)) ?
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 550e59c..bac8f9b 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -549,7 +549,7 @@ 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();
-PRUint64 config_get_disk_threshold();
+PRInt64 config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index e18967f..9837918 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2280,7 +2280,7 @@ typedef struct _slapdFrontendConfig {
/* disk monitoring */
int disk_monitoring;
- PRUint64 disk_threshold;
+ PRInt64 disk_threshold;
int disk_grace_period;
int disk_logging_critical;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 12c8ffa..c961d87 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1792,6 +1792,16 @@ void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
/**
+ * Replaces the value or values of an attribute in an entry with a specified long long
+ * data type value.
+ *
+ * \param e Entry in which you want to set the value.
+ * \param type Attribute type in which you want to set the value.
+ * \param l Long Long integer value that you want to assign to the attribute.
+ */
+void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l);
+
+/**
* Replaces the value or values of an attribute in an entry with a specified unsigned
* long data type value.
*
10 years, 2 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 2 +-
ldap/servers/slapd/entry.c | 14 ++++++++++++++
ldap/servers/slapd/libglobs.c | 14 ++++++++++----
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/slap.h | 2 +-
ldap/servers/slapd/slapi-plugin.h | 10 ++++++++++
6 files changed, 37 insertions(+), 7 deletions(-)
New commits:
commit 8937cd79d626e5f95b9a49814d85cf9bd228bed2
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 21 17:05:59 2014 -0500
Ticket 47638 - Overflow in nsslapd-disk-monitoring-threshold on 32bit platform
Bug Description: On 32bit platforms 3000000000 overflows when retrieving the value
from the dse. The value was internally processed correctly, but
the value returned to the client was incorrect.
Fix Description: Created a new CONFIG_LONG_LONG config value type, and the associated
slapi_entry_attr_set_* function.
https://fedorahosted.org/389/ticket/47638
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit 020c16333fea42c60108dcc475e7330fde7678a1)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 566f53a..dddbd5f 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -704,7 +704,7 @@ disk_monitoring_thread(void *nothing)
char *dirstr = NULL;
PRUint64 previous_mark = 0;
PRUint64 disk_space = 0;
- PRUint64 threshold = 0;
+ PRInt64 threshold = 0;
PRUint64 halfway = 0;
time_t start = 0;
time_t now = 0;
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 60e1dfe..36f57e9 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2903,6 +2903,20 @@ slapi_entry_attr_set_long( Slapi_Entry* e, const char *type, long l)
}
void
+slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
+{
+ char value[20];
+ struct berval bv;
+ struct berval *bvals[2];
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+ sprintf(value,"%lld",l);
+ bv.bv_val = value;
+ bv.bv_len = strlen( value );
+ slapi_entry_attr_replace( e, type, bvals );
+}
+
+void
slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
{
char value[16];
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index bcf7db4..cae8d24 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -105,6 +105,7 @@ typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
typedef enum {
CONFIG_INT, /* maps to int */
CONFIG_LONG, /* maps to long */
+ CONFIG_LONG_LONG, /* maps to a long long (PRInt64) */
CONFIG_STRING, /* maps to char* */
CONFIG_CHARRAY, /* maps to char** */
CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
@@ -999,7 +1000,7 @@ static struct config_get_and_set {
{CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_threshold,
- CONFIG_LONG, (ConfigGetFunc)config_get_disk_threshold,
+ CONFIG_LONG_LONG, (ConfigGetFunc)config_get_disk_threshold,
DEFAULT_DISK_THRESHOLD},
{CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
NULL, 0,
@@ -4332,10 +4333,10 @@ config_get_disk_grace_period(){
return retVal;
}
-PRUint64
+PRInt64
config_get_disk_threshold(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
+ PRInt64 retVal;
CFG_LOCK_READ(slapdFrontendConfig);
retVal = slapdFrontendConfig->disk_threshold;
@@ -7113,7 +7114,12 @@ config_set_value(
else
slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
break;
-
+ case CONFIG_LONG_LONG:
+ if (value)
+ slapi_entry_attr_set_longlong(e, cgas->attr_name, *((long long*)value));
+ else
+ slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
+ break;
case CONFIG_STRING:
slapi_entry_attr_set_charptr(e, cgas->attr_name,
(value && *((char **)value)) ?
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 39c1f54..b8a9bac 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -549,7 +549,7 @@ 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();
-PRUint64 config_get_disk_threshold();
+PRInt64 config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index eaa824d..d992d8f 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2323,7 +2323,7 @@ typedef struct _slapdFrontendConfig {
/* disk monitoring */
slapi_onoff_t disk_monitoring;
- PRUint64 disk_threshold;
+ PRInt64 disk_threshold;
int disk_grace_period;
slapi_onoff_t disk_logging_critical;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index b77895e..8291ab4 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1874,6 +1874,16 @@ void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
/**
+ * Replaces the value or values of an attribute in an entry with a specified long long
+ * data type value.
+ *
+ * \param e Entry in which you want to set the value.
+ * \param type Attribute type in which you want to set the value.
+ * \param l Long Long integer value that you want to assign to the attribute.
+ */
+void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l);
+
+/**
* Replaces the value or values of an attribute in an entry with a specified unsigned
* long data type value.
*
10 years, 2 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 2 +-
ldap/servers/slapd/entry.c | 14 ++++++++++++++
ldap/servers/slapd/libglobs.c | 14 ++++++++++----
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/slap.h | 2 +-
ldap/servers/slapd/slapi-plugin.h | 10 ++++++++++
6 files changed, 37 insertions(+), 7 deletions(-)
New commits:
commit cb67295ca04462b480833e78ec6c1a3a03885aa1
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 21 17:05:59 2014 -0500
Ticket 47638 - Overflow in nsslapd-disk-monitoring-threshold on 32bit platform
Bug Description: On 32bit platforms 3000000000 overflows when retrieving the value
from the dse. The value was internally processed correctly, but
the value returned to the client was incorrect.
Fix Description: Created a new CONFIG_LONG_LONG config value type, and the associated
slapi_entry_attr_set_* function.
https://fedorahosted.org/389/ticket/47638
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit 020c16333fea42c60108dcc475e7330fde7678a1)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index e7262dc..4620e70 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -704,7 +704,7 @@ disk_monitoring_thread(void *nothing)
char *dirstr = NULL;
PRUint64 previous_mark = 0;
PRUint64 disk_space = 0;
- PRUint64 threshold = 0;
+ PRInt64 threshold = 0;
PRUint64 halfway = 0;
time_t start = 0;
time_t now = 0;
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index a7c7010..de4a503 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3045,6 +3045,20 @@ slapi_entry_attr_set_long( Slapi_Entry* e, const char *type, long l)
}
void
+slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
+{
+ char value[20];
+ struct berval bv;
+ struct berval *bvals[2];
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+ sprintf(value,"%lld",l);
+ bv.bv_val = value;
+ bv.bv_len = strlen( value );
+ slapi_entry_attr_replace( e, type, bvals );
+}
+
+void
slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
{
char value[16];
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 940b60d..58256f4 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -105,6 +105,7 @@ typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
typedef enum {
CONFIG_INT, /* maps to int */
CONFIG_LONG, /* maps to long */
+ CONFIG_LONG_LONG, /* maps to a long long (PRInt64) */
CONFIG_STRING, /* maps to char* */
CONFIG_CHARRAY, /* maps to char** */
CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
@@ -1007,7 +1008,7 @@ static struct config_get_and_set {
{CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_threshold,
- CONFIG_LONG, (ConfigGetFunc)config_get_disk_threshold,
+ CONFIG_LONG_LONG, (ConfigGetFunc)config_get_disk_threshold,
DEFAULT_DISK_THRESHOLD},
{CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
NULL, 0,
@@ -4387,10 +4388,10 @@ config_get_disk_grace_period(){
return retVal;
}
-PRUint64
+PRInt64
config_get_disk_threshold(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
+ PRInt64 retVal;
CFG_LOCK_READ(slapdFrontendConfig);
retVal = slapdFrontendConfig->disk_threshold;
@@ -7255,7 +7256,12 @@ config_set_value(
else
slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
break;
-
+ case CONFIG_LONG_LONG:
+ if (value)
+ slapi_entry_attr_set_longlong(e, cgas->attr_name, *((long long*)value));
+ else
+ slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
+ break;
case CONFIG_STRING:
slapi_entry_attr_set_charptr(e, cgas->attr_name,
(value && *((char **)value)) ?
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index af7b553..4768c24 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -550,7 +550,7 @@ 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();
-PRUint64 config_get_disk_threshold();
+PRInt64 config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 5b23c69..679fdb0 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2372,7 +2372,7 @@ typedef struct _slapdFrontendConfig {
/* disk monitoring */
slapi_onoff_t disk_monitoring;
- PRUint64 disk_threshold;
+ PRInt64 disk_threshold;
int disk_grace_period;
slapi_onoff_t disk_logging_critical;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 13a332c..6e1dbb4 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1931,6 +1931,16 @@ void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
/**
+ * Replaces the value or values of an attribute in an entry with a specified long long
+ * data type value.
+ *
+ * \param e Entry in which you want to set the value.
+ * \param type Attribute type in which you want to set the value.
+ * \param l Long Long integer value that you want to assign to the attribute.
+ */
+void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l);
+
+/**
* Replaces the value or values of an attribute in an entry with a specified unsigned
* long data type value.
*
10 years, 2 months
ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 2 +-
ldap/servers/slapd/entry.c | 14 ++++++++++++++
ldap/servers/slapd/libglobs.c | 14 ++++++++++----
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/slap.h | 2 +-
ldap/servers/slapd/slapi-plugin.h | 10 ++++++++++
6 files changed, 37 insertions(+), 7 deletions(-)
New commits:
commit 020c16333fea42c60108dcc475e7330fde7678a1
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 21 17:05:59 2014 -0500
Ticket 47638 - Overflow in nsslapd-disk-monitoring-threshold on 32bit platform
Bug Description: On 32bit platforms 3000000000 overflows when retrieving the value
from the dse. The value was internally processed correctly, but
the value returned to the client was incorrect.
Fix Description: Created a new CONFIG_LONG_LONG config value type, and the associated
slapi_entry_attr_set_* function.
https://fedorahosted.org/389/ticket/47638
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 772f2a4..7594d53 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -704,7 +704,7 @@ disk_monitoring_thread(void *nothing)
char *dirstr = NULL;
PRUint64 previous_mark = 0;
PRUint64 disk_space = 0;
- PRUint64 threshold = 0;
+ PRInt64 threshold = 0;
PRUint64 halfway = 0;
time_t start = 0;
time_t now = 0;
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index cac02d5..d6e614f 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3065,6 +3065,20 @@ slapi_entry_attr_set_long( Slapi_Entry* e, const char *type, long l)
}
void
+slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
+{
+ char value[20];
+ struct berval bv;
+ struct berval *bvals[2];
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+ sprintf(value,"%lld",l);
+ bv.bv_val = value;
+ bv.bv_len = strlen( value );
+ slapi_entry_attr_replace( e, type, bvals );
+}
+
+void
slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
{
char value[16];
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 195c430..93e49c3 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -105,6 +105,7 @@ typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
typedef enum {
CONFIG_INT, /* maps to int */
CONFIG_LONG, /* maps to long */
+ CONFIG_LONG_LONG, /* maps to a long long (PRInt64) */
CONFIG_STRING, /* maps to char* */
CONFIG_CHARRAY, /* maps to char** */
CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
@@ -1008,7 +1009,7 @@ static struct config_get_and_set {
{CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_threshold,
- CONFIG_LONG, (ConfigGetFunc)config_get_disk_threshold,
+ CONFIG_LONG_LONG, (ConfigGetFunc)config_get_disk_threshold,
DEFAULT_DISK_THRESHOLD},
{CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
NULL, 0,
@@ -4388,10 +4389,10 @@ config_get_disk_grace_period(){
return retVal;
}
-PRUint64
+PRInt64
config_get_disk_threshold(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
+ PRInt64 retVal;
CFG_LOCK_READ(slapdFrontendConfig);
retVal = slapdFrontendConfig->disk_threshold;
@@ -7256,7 +7257,12 @@ config_set_value(
else
slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
break;
-
+ case CONFIG_LONG_LONG:
+ if (value)
+ slapi_entry_attr_set_longlong(e, cgas->attr_name, *((long long*)value));
+ else
+ slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
+ break;
case CONFIG_STRING:
slapi_entry_attr_set_charptr(e, cgas->attr_name,
(value && *((char **)value)) ?
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 358e103..9f77146 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -552,7 +552,7 @@ 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();
-PRUint64 config_get_disk_threshold();
+PRInt64 config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 710da22..6ef0916 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2375,7 +2375,7 @@ typedef struct _slapdFrontendConfig {
/* disk monitoring */
slapi_onoff_t disk_monitoring;
- PRUint64 disk_threshold;
+ PRInt64 disk_threshold;
int disk_grace_period;
slapi_onoff_t disk_logging_critical;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index cfac7c6..a4682b5 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1934,6 +1934,16 @@ void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
/**
+ * Replaces the value or values of an attribute in an entry with a specified long long
+ * data type value.
+ *
+ * \param e Entry in which you want to set the value.
+ * \param type Attribute type in which you want to set the value.
+ * \param l Long Long integer value that you want to assign to the attribute.
+ */
+void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l);
+
+/**
* Replaces the value or values of an attribute in an entry with a specified unsigned
* long data type value.
*
10 years, 2 months