summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2010-06-07 17:24:52 -0600
committerRich Megginson <rmeggins@redhat.com>2010-08-31 13:35:53 -0600
commite30f96f03b95d7d7599cf7cf385de9280dcd1b48 (patch)
tree9aa618fb774f28ad0b9bd5a19e5dc0b1702e45d4 /ldap/servers/plugins
parent36101b6491afc0a843ba50b7e506e622271e9177 (diff)
downloadds-e30f96f03b95d7d7599cf7cf385de9280dcd1b48.tar.gz
ds-e30f96f03b95d7d7599cf7cf385de9280dcd1b48.tar.xz
ds-e30f96f03b95d7d7599cf7cf385de9280dcd1b48.zip
openldap - add support for missing controls, add ldif api, fix NSS usage
Added proxy auth control creation - mozldap has a function to do that but not openldap Do not use mozldap filter create function - just create one using slapi_smprintf Fix usage of TLS/SSL with new NSS functionality Created ldif parse wrapper - changed code to use it Reviewed by: nkinder (Thanks!) Platforms tested: Fedora 14 (rawhide)
Diffstat (limited to 'ldap/servers/plugins')
-rw-r--r--ldap/servers/plugins/chainingdb/cb_controls.c2
-rw-r--r--ldap/servers/plugins/mep/mep.c15
-rw-r--r--ldap/servers/plugins/referint/referint.c11
-rw-r--r--ldap/servers/plugins/replication/cl5_api.c69
-rw-r--r--ldap/servers/plugins/replication/replutil.c26
5 files changed, 65 insertions, 58 deletions
diff --git a/ldap/servers/plugins/chainingdb/cb_controls.c b/ldap/servers/plugins/chainingdb/cb_controls.c
index 142284a9..f6b0653a 100644
--- a/ldap/servers/plugins/chainingdb/cb_controls.c
+++ b/ldap/servers/plugins/chainingdb/cb_controls.c
@@ -281,7 +281,7 @@ int cb_update_controls( Slapi_PBlock * pb,
if (addauth) {
slapi_pblock_get( pb, SLAPI_REQUESTOR_DN, &proxyDN );
- if ( ldap_create_proxyauth_control(ld, proxyDN, isabandon?0:1, &ctrls[dCount] )) {
+ if ( slapi_ldap_create_proxyauth_control(ld, proxyDN, isabandon?0:1, 0, &ctrls[dCount] )) {
ldap_controls_free(ctrls);
slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
"LDAP_CONTROL_PROXYAUTH control encoding failed.\n");
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index ba142033..716b39b0 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -950,8 +950,6 @@ mep_create_managed_entry(struct configEntry *config, Slapi_Entry *origin)
char **vals = NULL;
char *type = NULL;
char *value = NULL;
- int vlen = 0;
- struct berval bval;
Slapi_Value *sval = NULL;
int found_rdn_map = 0;
int i = 0;
@@ -982,7 +980,9 @@ mep_create_managed_entry(struct configEntry *config, Slapi_Entry *origin)
* created managed entry. */
vals = slapi_entry_attr_get_charray(template, MEP_STATIC_ATTR_TYPE);
for (i = 0; vals && vals[i]; ++i) {
- if (ldif_parse_line(vals[i], &type, &value, &vlen) != 0) {
+ struct berval bvtype = {0, NULL}, bvvalue = {0, NULL};
+ int freeval = 0;
+ if (slapi_ldif_parse_line(vals[i], &bvtype, &bvvalue, &freeval) != 0) {
slapi_log_error( SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
"mep_create_managed_entry: Value for %s config setting "
"is not in the correct format in template \"%s\". "
@@ -992,14 +992,15 @@ mep_create_managed_entry(struct configEntry *config, Slapi_Entry *origin)
goto done;
} else {
/* Create a berval and add the value to the entry. */
- bval.bv_len = vlen;
- bval.bv_val = value;
- sval = slapi_value_new_berval(&bval);
- slapi_entry_add_value(managed_entry, type, sval);
+ sval = slapi_value_new_berval(&bvvalue);
+ slapi_entry_add_value(managed_entry, bvtype.bv_val, sval);
slapi_value_free(&sval);
/* Set type and value to NULL so they don't get
* free'd by mep_parse_mapped_attr(). */
+ if (freeval) {
+ slapi_ch_free_string(&bvvalue.bv_val);
+ }
type = NULL;
value = NULL;
}
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index 0f1598db..454c5162 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -686,11 +686,10 @@ update_integrity(char **argv, char *origDN,
for(i = 3; argv[i] != NULL; i++)
{
- unsigned long filtlen = strlen(argv[i]) + (strlen(origDN) * 3 ) + 5;
- filter = (char *)slapi_ch_calloc( filtlen, sizeof(char ));
- if (( search_result = ldap_create_filter( filter, filtlen,
- "(%a=*%e)", NULL, NULL, argv[i], origDN, NULL ))
- == LDAP_SUCCESS ) {
+ char buf[BUFSIZ];
+ size_t len = strlen(origDN);
+ filter = slapi_ch_smprintf("(%s=*%s)", argv[i], escape_filter_value(origDN, len, buf));
+ if ( filter ) {
/* Need only the current attribute and its subtypes */
char *attrs[2];
@@ -778,7 +777,7 @@ update_integrity(char **argv, char *origDN,
}
}
- slapi_ch_free((void**)&filter);
+ slapi_ch_free_string(&filter);
if (search_result_pb) {
slapi_free_search_results_internal(search_result_pb);
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 33536086..8e152b74 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -5147,13 +5147,10 @@ static int
_cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **replGen)
{
int rc;
-#if defined(USE_OPENLDAP)
- ber_len_t vlen;
-#else
- int vlen;
-#endif
char *next, *line;
- char *type, *value;
+ struct berval type, value;
+ struct berval bv_null = {0, NULL};
+ int freeval = 0;
Slapi_Mods *mods;
char *rawDN = NULL;
@@ -5170,7 +5167,9 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
}
/* this call modifies ldifEntry */
- rc = ldif_parse_line(line, &type, &value, &vlen);
+ type = bv_null;
+ value = bv_null;
+ rc = slapi_ldif_parse_line(line, &type, &value, &freeval);
if (rc != 0)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -5178,55 +5177,55 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
continue;
}
- if (strcasecmp (type, T_CHANGETYPESTR) == 0)
+ if (strncasecmp (type.bv_val, T_CHANGETYPESTR, type.bv_len) == 0)
{
- op->operation_type = _cl5Str2OperationType (value);
+ op->operation_type = _cl5Str2OperationType (value.bv_val);
}
- else if (strcasecmp (type, T_REPLGEN) == 0)
+ else if (strncasecmp (type.bv_val, T_REPLGEN, type.bv_len) == 0)
{
- *replGen = slapi_ch_strdup (value);
+ *replGen = slapi_ch_strdup (value.bv_val);
}
- else if (strcasecmp (type, T_CSNSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_CSNSTR, type.bv_len) == 0)
{
- op->csn = csn_new_by_string(value);
+ op->csn = csn_new_by_string(value.bv_val);
}
- else if (strcasecmp (type, T_UNIQUEIDSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_UNIQUEIDSTR, type.bv_len) == 0)
{
- op->target_address.uniqueid = slapi_ch_strdup (value);
+ op->target_address.uniqueid = slapi_ch_strdup (value.bv_val);
}
- else if (strcasecmp (type, T_DNSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_DNSTR, type.bv_len) == 0)
{
PR_ASSERT (op->operation_type);
if (op->operation_type == SLAPI_OPERATION_ADD)
{
- rawDN = slapi_ch_strdup (value);
+ rawDN = slapi_ch_strdup (value.bv_val);
op->target_address.dn = slapi_ch_strdup(rawDN);
}
else
- op->target_address.dn = slapi_ch_strdup (value);
+ op->target_address.dn = slapi_ch_strdup (value.bv_val);
}
- else if (strcasecmp (type, T_PARENTIDSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_PARENTIDSTR, type.bv_len) == 0)
{
- op->p.p_add.parentuniqueid = slapi_ch_strdup (value);
+ op->p.p_add.parentuniqueid = slapi_ch_strdup (value.bv_val);
}
- else if (strcasecmp (type, T_NEWRDNSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_NEWRDNSTR, type.bv_len) == 0)
{
- op->p.p_modrdn.modrdn_newrdn = slapi_ch_strdup (value);
+ op->p.p_modrdn.modrdn_newrdn = slapi_ch_strdup (value.bv_val);
}
- else if (strcasecmp (type, T_DRDNFLAGSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_DRDNFLAGSTR, type.bv_len) == 0)
{
- op->p.p_modrdn.modrdn_deloldrdn = (strcasecmp (value, "true") ? PR_FALSE : PR_TRUE);
+ op->p.p_modrdn.modrdn_deloldrdn = (strncasecmp (value.bv_val, "true", value.bv_len) ? PR_FALSE : PR_TRUE);
}
- else if (strcasecmp (type, T_NEWSUPERIORDNSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_NEWSUPERIORDNSTR, type.bv_len) == 0)
{
- op->p.p_modrdn.modrdn_newsuperior_address.dn = slapi_ch_strdup (value);
+ op->p.p_modrdn.modrdn_newsuperior_address.dn = slapi_ch_strdup (value.bv_val);
}
- else if (strcasecmp (type, T_NEWSUPERIORIDSTR) == 0)
+ else if (strncasecmp (type.bv_val, T_NEWSUPERIORIDSTR, type.bv_len) == 0)
{
- op->p.p_modrdn.modrdn_newsuperior_address.uniqueid = slapi_ch_strdup (value);
+ op->p.p_modrdn.modrdn_newsuperior_address.uniqueid = slapi_ch_strdup (value.bv_val);
}
- else if (strcasecmp (type, T_CHANGESTR) == 0)
+ else if (strncasecmp (type.bv_val, T_CHANGESTR, type.bv_len) == 0)
{
PR_ASSERT (op->operation_type);
@@ -5245,7 +5244,7 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
op->operation_type);
return CL5_BAD_FORMAT;
}
- mods = parse_changes_string(value);
+ mods = parse_changes_string(value.bv_val);
PR_ASSERT (mods);
slapi_mods2entry (&(op->p.p_add.target_entry), rawDN,
slapi_mods_get_ldapmods_byref(mods));
@@ -5253,13 +5252,13 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
slapi_mods_free (&mods);
break;
- case SLAPI_OPERATION_MODIFY: mods = parse_changes_string(value);
+ case SLAPI_OPERATION_MODIFY: mods = parse_changes_string(value.bv_val);
PR_ASSERT (mods);
op->p.p_modify.modify_mods = slapi_mods_get_ldapmods_passout (mods);
slapi_mods_free (&mods);
break;
- case SLAPI_OPERATION_MODRDN: mods = parse_changes_string(value);
+ case SLAPI_OPERATION_MODRDN: mods = parse_changes_string(value.bv_val);
PR_ASSERT (mods);
op->p.p_modrdn.modrdn_mods = slapi_mods_get_ldapmods_passout (mods);
slapi_mods_free (&mods);
@@ -5268,9 +5267,15 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
default: slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
"_cl5LDIF2Operation: invalid operation type - %lu\n",
op->operation_type);
+ if (freeval) {
+ slapi_ch_free_string(&value.bv_val);
+ }
return CL5_BAD_FORMAT;
}
}
+ if (freeval) {
+ slapi_ch_free_string(&value.bv_val);
+ }
}
if (IsValidOperation (op))
diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c
index aaa427bd..0da0f573 100644
--- a/ldap/servers/plugins/replication/replutil.c
+++ b/ldap/servers/plugins/replication/replutil.c
@@ -403,9 +403,9 @@ parse_changes_string(char *str)
Slapi_Mods *mods;
Slapi_Mod mod;
char *line, *next;
- char *type, *value;
- int vlen;
- struct berval bv;
+ struct berval type, value;
+ struct berval bv_null = {0, NULL};
+ int freeval = 0;
/* allocate mods array */
mods = slapi_mods_new ();
@@ -438,7 +438,9 @@ parse_changes_string(char *str)
break;
}
- rc = ldif_parse_line(line, &type, &value, &vlen);
+ type = bv_null;
+ value = bv_null;
+ rc = slapi_ldif_parse_line(line, &type, &value, &freeval);
if (rc != 0)
{
/* ONREPL - log warning */
@@ -447,15 +449,15 @@ parse_changes_string(char *str)
continue;
}
- if (strcasecmp (type, "add") == 0)
+ if (strncasecmp (type.bv_val, "add", type.bv_len) == 0)
{
slapi_mod_set_operation (&mod, LDAP_MOD_ADD | LDAP_MOD_BVALUES);
}
- else if (strcasecmp (type, "delete") == 0)
+ else if (strncasecmp (type.bv_val, "delete", type.bv_len) == 0)
{
slapi_mod_set_operation (&mod, LDAP_MOD_DELETE | LDAP_MOD_BVALUES);
}
- else if (strcasecmp (type, "replace") == 0)
+ else if (strncasecmp (type.bv_val, "replace", type.bv_len) == 0)
{
slapi_mod_set_operation (&mod, LDAP_MOD_REPLACE | LDAP_MOD_BVALUES);
}
@@ -464,15 +466,15 @@ parse_changes_string(char *str)
/* adding first value */
if (slapi_mod_get_type (&mod) == NULL)
{
- slapi_mod_set_type (&mod, type);
+ slapi_mod_set_type (&mod, type.bv_val);
}
- bv.bv_val = value;
- bv.bv_len = vlen;
-
- slapi_mod_add_value (&mod, &bv);
+ slapi_mod_add_value (&mod, &value);
}
+ if (freeval) {
+ slapi_ch_free_string(&value.bv_val);
+ }
line = ldif_getline (&next);
}
}