mod_nss nss_engine_io.c,1.12,1.13
by Rob Crittenden
Author: rcritten
Update of /cvs/dirsec/mod_nss
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv20681
Modified Files:
nss_engine_io.c
Log Message:
Bug 669118
memcpy of overlapping memory is no longer allowed by glibc.
This is mod_ssl bug https://issues.apache.org/bugzilla/show_bug.cgi?id=45444
Patch ported by Stephen Gallagher.
Index: nss_engine_io.c
===================================================================
RCS file: /cvs/dirsec/mod_nss/nss_engine_io.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- nss_engine_io.c 24 Sep 2010 02:06:57 -0000 1.12
+++ nss_engine_io.c 12 Jan 2011 19:43:23 -0000 1.13
@@ -123,13 +123,13 @@
if (buffer->length > inl) {
/* we have have enough to fill the caller's buffer */
- memcpy(in, buffer->value, inl);
+ memmove(in, buffer->value, inl);
buffer->value += inl;
buffer->length -= inl;
}
else {
/* swallow remainder of the buffer */
- memcpy(in, buffer->value, buffer->length);
+ memmove(in, buffer->value, buffer->length);
inl = buffer->length;
buffer->value = NULL;
buffer->length = 0;
13 years, 2 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/log.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
New commits:
commit 3bcba2416c21f2c297ade289f17549ae2bc6b4e9
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jan 12 11:27:35 2011 -0800
Bug 615100 - log rotationinfo always recreated at startup,
and corrupted on some platforms
https://bugzilla.redhat.com/show_bug.cgi?id=615100
Description:
1) At startup log__check_prevlogs() verifies that all logs are
referenced in the rotationinfo file. If the rotationinfo file
doesn't reference all the present log files, it will recreate
the rotationinfo file based on the log files that are present.
However, the logic to break out of the loop that performs the
verification is incorrect so it always considers the rotationinfo
file to be bogus and recreates it. I've corrected the logic.
2) Recreating the rotationinfo file isn't bad per se, but the
code that recreates the rotationinfo file is also broken on HP-UX
(and probably Solaris). It tries to use the libc function strptime()
to format a date such as "20100128-153532" into a struct tm, so that
it can create an epoch date from there. The format string being
used for strptime() is "%Y%m%d-%H%M%S", which works on Linux, but
the strptime() function requires whitespace or alpha-numeric
separators between format specifiers on HP-UX (and Solaris according
to their man page), so strptime() fails. My fix here was to convert
the compact date string into a string in ISO8601-like format with
separators so strptime() can parse it.
This patch was provided by Ulf Weltman (ulf.weltman(a)hp.com).
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index e4e98ce..98090e8 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -33,6 +33,7 @@
*
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
* Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
* All rights reserved.
* END COPYRIGHT BLOCK **/
@@ -2804,14 +2805,16 @@ log__check_prevlogs (FILE *fp, char *pathname)
fseek(fp, 0 ,SEEK_SET);
buf[BUFSIZ-1] = '\0';
+ rval = LOG_ERROR; /* pessmistic default */
while (fgets(buf, BUFSIZ - 1, fp)) {
if (strstr(buf, dirent->name)) {
rval = LOG_CONTINUE; /* found in .rotationinfo */
- continue;
- }
+ break;
+ }
+ }
+ if(LOG_ERROR == rval) {
+ goto done;
}
- rval = LOG_ERROR; /* not found in .rotationinfo */
- break;
}
}
done:
@@ -4101,8 +4104,18 @@ log_reverse_convert_time(char *tbuf)
{
struct tm tm = {0};
- if (strchr(tbuf, '-')) { /* short format */
- strptime(tbuf, "%Y%m%d-%H%M%S", &tm);
+ if (strchr(tbuf, '-') && strlen(tbuf) >= 15) {
+ /* short format: YYYYmmdd-HHMMSS
+ strptime requires whitespace or non-alpha characters between format
+ specifiers on some platforms, so convert to an ISO8601-like format
+ with separators */
+ char tbuf_with_sep[] = "yyyy-mm-dd HH:MM:SS";
+ if( sscanf(tbuf, "%4c%2c%2c-%2c%2c%2c", tbuf_with_sep,
+ tbuf_with_sep+5, tbuf_with_sep+8, tbuf_with_sep+11,
+ tbuf_with_sep+14, tbuf_with_sep+17) != 6 ) {
+ return 0;
+ }
+ strptime(tbuf_with_sep, "%Y-%m-%d %H:%M:%S", &tm);
} else if (strchr(tbuf, '/') && strchr(tbuf, ':')) { /* long format */
strptime(tbuf, "%d/%b/%Y:%H:%M:%S", &tm);
} else {
13 years, 2 months
ldap/servers
by Noriko Hosoi
ldap/servers/plugins/replication/cl5_api.c | 277 ++++++++++--
ldap/servers/plugins/replication/cl5_clcache.c | 15
ldap/servers/plugins/replication/repl5_replica_config.c | 345 +++++++++++++++-
ldap/servers/plugins/replication/repl5_ruv.c | 7
ldap/servers/slapd/slapi-private.h | 1
5 files changed, 576 insertions(+), 69 deletions(-)
New commits:
commit ad3c528db4824d4d5568b6b3c36ade917905f445
Author: Noriko Hosoi <nhosoi(a)jiji.usersys.redhat.com>
Date: Tue Jan 11 18:57:08 2011 -0800
Bug 663752 - Cert renewal for attrcrypt and encchangelog
https://bugzilla.redhat.com/show_bug.cgi?id=663752
Description: In fixing Bug 182507, the feature to encrypt changelogs
had been introduced. The changelog encryption depends on the server
certificate as the attrcrypt does. When the server certificate is
renewed, the encrypted changelog won't be decrypted. This patch
implements/completes the feature to export and import the contents
of the changelog to provide the scenario to update the encrypted
changelogs along with the cert renewal.
See also this section for the steps to export/import changelogs.
http://directory.fedoraproject.org/wiki/Changelog_Encryption#Steps_for_Ce...
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index e257ccd..9922131 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -852,8 +852,7 @@ done:;
Description: imports ldif file into changelog; changelog must be in the closed state
Parameters: clDir - changelog dir
ldifFile - absolute path to the ldif file to import
- replicas - optional list of replicas whose data should be imported;
- if the list is NULL, all data in the file is imported.
+ replicas - optional list of replicas whose data should be imported.
Return: CL5_SUCCESS if function is successfull;
CL5_BAD_DATA if invalid parameter is passed;
CL5_BAD_STATE if changelog is open or not inititalized;
@@ -861,7 +860,8 @@ done:;
CL5_SYSTEM_ERROR if NSPR call fails;
CL5_MEMORY_ERROR if memory allocation fials.
*/
-int cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
+int
+cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
{
#if defined(USE_OPENLDAP)
LDIFFP *file = NULL;
@@ -873,8 +873,19 @@ int cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
char *buff = NULL;
int lineno = 0;
slapi_operation_parameters op;
- Object *replica = NULL;
- char *replGen = NULL;
+ Object *prim_replica_obj = NULL;
+ Object *replica_obj = NULL;
+ Object *file_obj = NULL;
+ Replica *prim_replica = NULL;
+ char *replGen = NULL;
+ CL5DBFile *dbfile = NULL;
+ struct berval **purgevals = NULL;
+ struct berval **maxvals = NULL;
+ int purgeidx = 0;
+ int maxidx = 0;
+ int maxpurgesz = 8;
+ int maxmaxsz = 8;
+ int entryCount = 0;
/* validate params */
if (ldifFile == NULL)
@@ -891,6 +902,16 @@ int cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
return CL5_BAD_STATE;
}
+ prim_replica_obj = replicas[0];
+ if (NULL == prim_replica_obj)
+ {
+ /* Never happens for now. (see replica_execute_ldif2cl_task) */
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "cl5ImportLDIF: empty replica list\n");
+ return CL5_BAD_DATA;
+ }
+ prim_replica = (Replica*)object_get_data(prim_replica_obj);
+
/* make sure that nobody change changelog state while import is in progress */
PR_RWLock_Wlock (s_cl5Desc.stLock);
@@ -936,6 +957,7 @@ int cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
"cl5ImportLDIF: failed to open changelog\n");
goto done;
}
+ s_cl5Desc.dbState = CL5_STATE_OPEN; /* force to change the state */
/* read entries and write them to changelog */
#if defined(USE_OPENLDAP)
@@ -945,50 +967,154 @@ int cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
#endif
{
rc = _cl5LDIF2Operation (buff, &op, &replGen);
- slapi_ch_free_string(&buff);
if (rc != CL5_SUCCESS)
{
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "cl5ImportLDIF: failed to convert LDIF fragment to LDAP operation; "
- "end of fragment line number - %d\n", lineno);
- goto done;
+ /*
+ * clpurgeruv: {replicageneration} 4d13a124000000010000
+ * clpurgeruv: {replica 2 ldap://host:port}
+ * clpurgeruv: {replica 1 ldap://host:port}
+ * clmaxruv: {replicageneration} 4d13a124000000010000
+ * clmaxruv: {replica 2} <mincsn> <maxcsn> <timestamp>
+ * clmaxruv: {replica 1} <mincsn> <maxcsn> <timestamp>
+ */
+ char *line;
+ char *next = buff;
+ struct berval type, value;
+ int freeval = 0;
+
+ purgevals = (struct berval **)slapi_ch_malloc(
+ sizeof(struct berval *) * maxpurgesz);
+ maxvals = (struct berval **)slapi_ch_malloc(
+ sizeof(struct berval *) * maxmaxsz);
+ while ((line = ldif_getline(&next)) != NULL) {
+ rc = slapi_ldif_parse_line(line, &type, &value, &freeval);
+ /* ruv_dump (dbfile->purgeRUV, "clpurgeruv", prFile); */
+ if (0 == strcasecmp (type.bv_val, "clpurgeruv")) {
+ if (maxpurgesz == purgeidx + 2) {
+ maxpurgesz *= 2;
+ purgevals = (struct berval **)slapi_ch_realloc(
+ (char *)purgevals,
+ sizeof(struct berval *) * maxpurgesz);
+ }
+ purgevals[purgeidx++] = slapi_ch_bvdup(&value);
+ }
+ /* ruv_dump (dbfile->maxRUV, "clmaxruv", prFile); */
+ else if (0 == strcasecmp (type.bv_val, "clmaxruv")) {
+ if (maxmaxsz == maxidx + 2) {
+ maxmaxsz *= 2;
+ maxvals = (struct berval **)slapi_ch_realloc(
+ (char *)maxvals,
+ sizeof(struct berval *) * maxmaxsz);
+ }
+ /* {replica #} min_csn csn [last_modified] */
+ /* get rid of last_modified, if any */
+ maxvals[maxidx++] = slapi_ch_bvdup(&value);
+ }
+ if (freeval) {
+ slapi_ch_free_string(&value.bv_val);
+ }
+ }
+ slapi_ch_free_string(&buff);
+ goto next;
}
+ slapi_ch_free_string(&buff);
/* if we perform selective import, check if the operation should be wriiten to changelog */
- replica = _cl5GetReplica (&op, replGen);
- if (replica == NULL)
+ replica_obj = _cl5GetReplica (&op, replGen);
+ if (replica_obj == NULL)
{
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "cl5ImportLDIF: failed to locate replica for target dn (%s) and "
- "replica generation %s\n", op.target_address.dn, replGen);
-
- slapi_ch_free_string(&replGen);
- operation_parameters_done (&op);
- goto done;
+ /*
+ * changetype: delete
+ * replgen: 4d13a124000000010000
+ * csn: 4d23b909000000020000
+ * nsuniqueid: 00000000-00000000-00000000-00000000
+ * dn: cn=start iteration
+ */
+ rc = _cl5WriteOperation (replica_get_name(prim_replica),
+ replGen, &op, 1);
+ if (rc != CL5_SUCCESS)
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "cl5ImportLDIF: "
+ "failed to write operation to the changelog: "
+ "type: %lu, dn: %s\n",
+ op.operation_type, op.target_address.dn);
+ object_release (replica_obj);
+ slapi_ch_free_string(&replGen);
+ operation_parameters_done (&op);
+ goto done;
+ }
+ entryCount++;
+ goto next;
}
- if (!replicas || _cl5ReplicaInList (replica, replicas))
+ if (!replicas || _cl5ReplicaInList (replica_obj, replicas))
{
/* write operation creates the file if it does not exist */
- rc = _cl5WriteOperation (replica_get_name ((Replica*)object_get_data(replica)),
+ rc = _cl5WriteOperation (replica_get_name ((Replica*)object_get_data(replica_obj)),
replGen, &op, 1);
if (rc != CL5_SUCCESS)
{
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "cl5ImportLDIF: failed to write operation to the changelog\n");
- object_release (replica);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "cl5ImportLDIF: "
+ "failed to write operation to the changelog: "
+ "type: %lu, dn: %s\n",
+ op.operation_type, op.target_address.dn);
+ object_release (replica_obj);
slapi_ch_free_string(&replGen);
operation_parameters_done (&op);
goto done;
}
+ entryCount++;
}
-
- object_release (replica);
+next:
+ if (replica_obj) {
+ object_release (replica_obj);
+ }
slapi_ch_free_string(&replGen);
- operation_parameters_done (&op);
+ operation_parameters_done (&op);
}
-done:;
+ /* Set RUVs and entry count */
+ file_obj = objset_first_obj(s_cl5Desc.dbFiles);
+ while (file_obj)
+ {
+ dbfile = (CL5DBFile *)object_get_data(file_obj);
+ if (0 == strcasecmp(dbfile->replName, replica_get_name(prim_replica))) {
+ break;
+ }
+ dbfile = NULL;
+ file_obj = objset_next_obj(s_cl5Desc.dbFiles, file_obj);
+ }
+
+ if (dbfile) {
+ if (purgeidx > 0) {
+ ruv_destroy (&dbfile->purgeRUV);
+ purgevals[purgeidx] = NULL;
+ rc = ruv_init_from_bervals(purgevals, &dbfile->purgeRUV);
+ }
+ if (maxidx > 0) {
+ ruv_destroy (&dbfile->maxRUV);
+ maxvals[maxidx] = NULL;
+ rc = ruv_init_from_bervals(maxvals, &dbfile->maxRUV);
+ }
+
+ for (purgeidx = 0; purgevals && purgevals[purgeidx]; purgeidx++) {
+ slapi_ch_bvfree(&purgevals[purgeidx]);
+ }
+ slapi_ch_free((void **)&purgevals);
+ for (maxidx = 0; maxvals && maxvals[maxidx]; maxidx++) {
+ slapi_ch_bvfree(&maxvals[maxidx]);
+ }
+ slapi_ch_free((void **)&maxvals);
+
+ dbfile->entryCount = entryCount;
+ }
+ if (file_obj) {
+ object_release (file_obj);
+ }
+
+done:
if (file) {
#if defined(USE_OPENLDAP)
ldif_close(file);
@@ -996,7 +1122,10 @@ done:;
fclose(file);
#endif
}
- _cl5Close ();
+ if (CL5_STATE_OPEN == s_cl5Desc.dbState) {
+ _cl5Close ();
+ s_cl5Desc.dbState = CL5_STATE_CLOSED; /* force to change the state */
+ }
PR_RWLock_Unlock (s_cl5Desc.stLock);
return rc;
}
@@ -1702,6 +1831,9 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
goto done;
}
+ if (s_cl5Desc.dbDir) {
+ slapi_ch_free_string (&s_cl5Desc.dbDir);
+ }
s_cl5Desc.dbDir = slapi_ch_strdup (dir);
/* check database version */
@@ -1902,7 +2034,8 @@ static int _cl5DBOpen ()
PR_snprintf(fullpathname, MAXPATHLEN, "%s/%s", s_cl5Desc.dbDir, entry->name);
rc = s_cl5Desc.dbEnv->dbremove(s_cl5Desc.dbEnv,
- 0, fullpathname, 0, 0);
+ 0, fullpathname, 0,
+ DEFAULT_DB_OP_FLAGS);
if (rc != 0)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -3089,12 +3222,24 @@ static int _cl5Delete (const char *clDir, int rmDir)
PR_snprintf(filename, MAXPATHLEN, "%s/%s", clDir, entry->name);
/* _cl5Delete deletes the whole changelog directory with all the files
* underneath. Thus, we can just remove them physically. */
- rc = PR_Delete(filename);
- if (rc != PR_SUCCESS)
- {
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
- "_cl5Delete: failed to remove (%s) file; NSPR error - %d\n",
+ if (0 == strcmp(entry->name, VERSION_FILE)) {
+ /* DBVERSION */
+ rc = PR_Delete(filename) != PR_SUCCESS;
+ if (PR_SUCCESS != rc) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5Delete: failed to remove \"%s\"; NSPR error - %d\n",
filename, PR_GetError ());
+ }
+ } else {
+ /* DB files */
+ rc = s_cl5Desc.dbEnv->dbremove(s_cl5Desc.dbEnv, 0, filename, 0,
+ DEFAULT_DB_OP_FLAGS);
+ if (rc) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5Delete: failed to remove \"%s\"; "
+ "libdb error - %d (%s)\n",
+ filename, rc, db_strerror(rc));
+ }
}
}
@@ -4115,18 +4260,20 @@ static int
_cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **replGen)
{
int rc;
+ int rval = CL5_BAD_FORMAT;
char *next, *line;
struct berval type, value;
struct berval bv_null = {0, NULL};
int freeval = 0;
Slapi_Mods *mods;
char *rawDN = NULL;
+ char *ldifEntryWork = slapi_ch_strdup(ldifEntry);
PR_ASSERT (op && ldifEntry && replGen);
memset (op, 0, sizeof (*op));
- next = ldifEntry;
+ next = ldifEntryWork;
while ((line = ldif_getline(&next)) != NULL)
{
if ( *line == '\n' || *line == '\0' )
@@ -4144,8 +4291,9 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
"_cl5LDIF2Operation: warning - failed to parse ldif line\n");
continue;
}
-
- if (strncasecmp (type.bv_val, T_CHANGETYPESTR, type.bv_len) == 0)
+ if (strncasecmp (type.bv_val, T_CHANGETYPESTR,
+ strlen(T_CHANGETYPESTR)>type.bv_len?
+ strlen(T_CHANGETYPESTR):type.bv_len) == 0)
{
op->operation_type = _cl5Str2OperationType (value.bv_val);
}
@@ -4193,7 +4341,9 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
{
op->p.p_modrdn.modrdn_newsuperior_address.uniqueid = slapi_ch_strdup (value.bv_val);
}
- else if (strncasecmp (type.bv_val, T_CHANGESTR, type.bv_len) == 0)
+ else if (strncasecmp (type.bv_val, T_CHANGESTR,
+ strlen(T_CHANGESTR)>type.bv_len?
+ strlen(T_CHANGESTR):type.bv_len) == 0)
{
PR_ASSERT (op->operation_type);
@@ -4210,6 +4360,7 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
"_cl5LDIF2Operation: corrupted format "
"for operation type - %lu\n",
op->operation_type);
+ slapi_ch_free_string(&ldifEntryWork);
return CL5_BAD_FORMAT;
}
mods = parse_changes_string(value.bv_val);
@@ -4238,6 +4389,7 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
if (freeval) {
slapi_ch_free_string(&value.bv_val);
}
+ slapi_ch_free_string(&ldifEntryWork);
return CL5_BAD_FORMAT;
}
}
@@ -4246,12 +4398,21 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl
}
}
- if (IsValidOperation (op))
- return CL5_SUCCESS;
-
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5LDIF2Operation: invalid data format\n");
- return CL5_BAD_FORMAT;
+ if ((0 != strncmp(ldifEntryWork, "clpurgeruv", 10)) && /* skip RUV; */
+ (0 != strncmp(ldifEntryWork, "clmaxruv", 8))) /* RUV has NULL op */
+ {
+ if (IsValidOperation (op))
+ {
+ rval = CL5_SUCCESS;
+ }
+ else
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5LDIF2Operation: invalid data format\n");
+ }
+ }
+ slapi_ch_free_string(&ldifEntryWork);
+ return rval;
}
static int _cl5WriteOperation(const char *replName, const char *replGen,
@@ -5339,7 +5500,6 @@ static int _cl5DBOpenFileByReplicaName (const char *replName, const char *replGe
file_name = _cl5MakeFileName (replName, replGen);
tmpObj = objset_find (s_cl5Desc.dbFiles, _cl5CompareDBFile, file_name);
slapi_ch_free((void **)&file_name);
- file_name = NULL;
if (tmpObj) /* this file already exist */
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -5629,6 +5789,7 @@ done:
static void _cl5DBCloseFile (void **data)
{
CL5DBFile *file;
+ int rc = 0;
PR_ASSERT (data);
@@ -5651,18 +5812,23 @@ static void _cl5DBCloseFile (void **data)
/* close the db */
if (file->db) {
- file->db->close(file->db, 0);
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5DBCloseFile: "
- "Closed the changelog database handle for %s\n", file->name);
+ rc = file->db->close(file->db, 0);
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "_cl5DBCloseFile: "
+ "Closed the changelog database handle for %s "
+ "(rc: %d)\n", file->name, rc);
file->db = NULL;
}
if (file->flags & DB_FILE_DELETED)
{
- int rc = 0;
/* We need to use the libdb API to delete the files, otherwise we'll
* run into problems when we try to checkpoint transactions later. */
- rc = s_cl5Desc.dbEnv->dbremove(s_cl5Desc.dbEnv, 0, file->name, 0, 0);
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5DBCloseFile: "
+ "removing the changelog %s (flag %d)\n",
+ file->name, DEFAULT_DB_OP_FLAGS);
+ rc = s_cl5Desc.dbEnv->dbremove(s_cl5Desc.dbEnv, 0, file->name, 0,
+ DEFAULT_DB_OP_FLAGS);
if (rc != 0)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5DBCloseFile: "
@@ -5681,6 +5847,7 @@ static void _cl5DBCloseFile (void **data)
slapi_ch_free ((void**)&file->replGen);
ruv_destroy(&file->maxRUV);
ruv_destroy(&file->purgeRUV);
+ file->db = NULL;
if (file->sema) {
PR_CloseSemaphore (file->sema);
PR_DeleteSemaphore (file->semaName);
@@ -5838,7 +6005,7 @@ static int _cl5ExportFile (PRFileDesc *prFile, Object *obj)
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5ExportLDIF: failed to convert operation to ldif\n");
+ "_cl5ExportFile: failed to convert operation to ldif\n");
operation_parameters_done (&op);
break;
}
@@ -5848,7 +6015,7 @@ static int _cl5ExportFile (PRFileDesc *prFile, Object *obj)
if (wlen < len)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5ExportLDIF: failed to write to ldif file\n");
+ "_cl5ExportFile: failed to write to ldif file\n");
rc = CL5_SYSTEM_ERROR;
operation_parameters_done (&op);
break;
@@ -5867,7 +6034,7 @@ static int _cl5ExportFile (PRFileDesc *prFile, Object *obj)
if (rc != CL5_NOTFOUND)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5ExportLDIF: failed to retrieve changelog entry\n");
+ "_cl5ExportFile: failed to retrieve changelog entry\n");
}
else
{
@@ -5932,7 +6099,7 @@ static Object* _cl5GetReplica (const slapi_operation_parameters *op, const char*
replObj = NULL;
}
- slapi_ch_free ((void**)&replGen);
+ slapi_ch_free ((void**)&newGen);
}
slapi_sdn_free (&sdn);
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index af2b7fe..6fa6985 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -379,7 +379,7 @@ clcache_load_buffer_bulk ( CLC_Buffer *buf, int flag )
{
DB_TXN *txn = NULL;
DBC *cursor = NULL;
- int rc;
+ int rc = 0;
#if 0 /* txn control seems not improving anything so turn it off */
if ( *(_pool->pl_dbenv) ) {
@@ -387,6 +387,19 @@ clcache_load_buffer_bulk ( CLC_Buffer *buf, int flag )
}
#endif
+ if (NULL == buf) {
+ slapi_log_error ( SLAPI_LOG_FATAL, "clcache_load_buffer_bulk",
+ "NULL buf\n" );
+ return rc;
+ }
+ if (NULL == buf->buf_busy_list) {
+ slapi_log_error ( SLAPI_LOG_FATAL, "clcache_load_buffer_bulk",
+ "%s%sno buf_busy_list\n",
+ buf->buf_agmt_name?buf->buf_agmt_name:"",
+ buf->buf_agmt_name?": ":"" );
+ return rc;
+ }
+
PR_Lock ( buf->buf_busy_list->bl_lock );
if ( 0 == ( rc = clcache_open_cursor ( txn, buf, &cursor )) ) {
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 80b5361..df9c12a 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -46,20 +46,24 @@
#include "repl.h" /* ONREPL - this is bad */
#include "repl5.h"
#include "cl5_api.h"
+#include "cl5.h"
/* CONFIG_BASE: no need to optimize */
#define CONFIG_BASE "cn=mapping tree,cn=config"
#define CONFIG_FILTER "(objectclass=nsDS5Replica)"
#define TASK_ATTR "nsds5Task"
#define CL2LDIF_TASK "CL2LDIF"
+#define LDIF2CL_TASK "LDIF2CL"
#define CLEANRUV "CLEANRUV"
#define CLEANRUVLEN 8
+#define REPLICA_RDN "cn=replica"
int slapi_log_urp = SLAPI_LOG_REPL;
/* Forward Declartions */
static int replica_config_add (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
static int replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
+static int replica_config_post_modify (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
static int replica_config_delete (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
static int replica_config_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
@@ -68,7 +72,10 @@ static int replica_config_change_updatedn (Replica *r, const LDAPMod *mod, char
static int replica_config_change_flags (Replica *r, const char *new_flags, char *returntext, int apply_mods);
static int replica_execute_task (Object *r, const char *task_name, char *returntext, int apply_mods);
static int replica_execute_cl2ldif_task (Object *r, char *returntext);
+static int replica_execute_ldif2cl_task (Object *r, char *returntext);
static int replica_execute_cleanruv_task (Object *r, ReplicaId rid, char *returntext);
+static int replica_cleanup_task (Object *r, const char *task_name, char *returntext, int apply_mods);
+static int replica_task_done(Replica *replica);
static multimaster_mtnode_extension * _replica_config_get_mtnode_ext (const Slapi_Entry *e);
@@ -104,6 +111,10 @@ replica_config_init()
CONFIG_FILTER, replica_config_delete,NULL);
slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, CONFIG_BASE, LDAP_SCOPE_SUBTREE,
CONFIG_FILTER, replica_config_search,NULL);
+ slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_POSTOP,
+ CONFIG_BASE, LDAP_SCOPE_SUBTREE,
+ CONFIG_FILTER, replica_config_post_modify,
+ NULL);
return 0;
}
@@ -127,6 +138,9 @@ replica_config_destroy ()
CONFIG_FILTER, replica_config_delete);
slapi_config_remove_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, CONFIG_BASE, LDAP_SCOPE_SUBTREE,
CONFIG_FILTER, replica_config_search);
+ slapi_config_remove_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP,
+ CONFIG_BASE, LDAP_SCOPE_SUBTREE,
+ CONFIG_FILTER, replica_config_post_modify);
}
static int
@@ -448,6 +462,141 @@ done:
}
static int
+replica_config_post_modify(Slapi_PBlock *pb,
+ Slapi_Entry* entryBefore,
+ Slapi_Entry* e,
+ int *returncode,
+ char *returntext,
+ void *arg)
+{
+ int rc= 0;
+ LDAPMod **mods;
+ int i, apply_mods;
+ multimaster_mtnode_extension *mtnode_ext;
+ Replica *r = NULL;
+ char *replica_root = NULL;
+ char buf [SLAPI_DSE_RETURNTEXT_SIZE];
+ char *errortext = returntext ? returntext : buf;
+ char *config_attr, *config_attr_value;
+ Slapi_Operation *op;
+ void *identity;
+
+ if (returntext)
+ {
+ returntext[0] = '\0';
+ }
+ *returncode = LDAP_SUCCESS;
+
+ /* just let internal operations originated from replication plugin to go through */
+ slapi_pblock_get (pb, SLAPI_OPERATION, &op);
+ slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &identity);
+
+ if (operation_is_flag_set(op, OP_FLAG_INTERNAL) &&
+ (identity == repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION)))
+ {
+ *returncode = LDAP_SUCCESS;
+ return SLAPI_DSE_CALLBACK_OK;
+ }
+
+ replica_root = (char*)slapi_entry_attr_get_charptr (e, attr_replicaRoot);
+
+ PR_Lock (s_configLock);
+
+ mtnode_ext = _replica_config_get_mtnode_ext (e);
+ PR_ASSERT (mtnode_ext);
+
+ if (mtnode_ext->replica)
+ object_acquire (mtnode_ext->replica);
+
+ if (mtnode_ext->replica == NULL)
+ {
+ PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "replica does not exist for %s", replica_root);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "replica_config_post_modify: %s\n",
+ errortext);
+ *returncode = LDAP_OPERATIONS_ERROR;
+ goto done;
+ }
+
+ r = object_get_data (mtnode_ext->replica);
+ PR_ASSERT (r);
+
+ slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
+ for (apply_mods = 0; apply_mods <= 1; apply_mods++)
+ {
+ /* we only allow the replica ID and type to be modified together e.g.
+ if converting a read only replica to a master or vice versa -
+ we will need to change both the replica ID and the type at the same
+ time - we must disallow changing the replica ID if the type is not
+ being changed and vice versa
+ */
+ if (*returncode != LDAP_SUCCESS)
+ break;
+
+ for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++)
+ {
+ if (*returncode != LDAP_SUCCESS)
+ break;
+
+ config_attr = (char *) mods[i]->mod_type;
+ PR_ASSERT (config_attr);
+
+ /* disallow modifications or removal of replica root,
+ replica name and replica state attributes */
+ if (strcasecmp (config_attr, attr_replicaRoot) == 0 ||
+ strcasecmp (config_attr, attr_replicaName) == 0 ||
+ strcasecmp (config_attr, attr_state) == 0)
+ {
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "modification of %s attribute is not allowed",
+ config_attr);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "replica_config_post_modify: %s\n",
+ errortext);
+ }
+ /* this is a request to delete an attribute */
+ else if (mods[i]->mod_op & LDAP_MOD_DELETE ||
+ mods[i]->mod_bvalues == NULL ||
+ mods[i]->mod_bvalues[0]->bv_val == NULL)
+ {
+ ;
+ }
+ else /* modify an attribute */
+ {
+ config_attr_value = (char *) mods[i]->mod_bvalues[0]->bv_val;
+
+ if (strcasecmp (config_attr, TASK_ATTR) == 0)
+ {
+ *returncode = replica_cleanup_task(mtnode_ext->replica,
+ config_attr_value,
+ errortext, apply_mods);
+ }
+ }
+ }
+ }
+
+done:
+ if (mtnode_ext->replica)
+ object_release (mtnode_ext->replica);
+
+ /* slapi_ch_free accepts NULL pointer */
+ slapi_ch_free ((void**)&replica_root);
+
+ PR_Unlock (s_configLock);
+
+ if (*returncode != LDAP_SUCCESS)
+ {
+ return SLAPI_DSE_CALLBACK_ERROR;
+ }
+ else
+ {
+ return SLAPI_DSE_CALLBACK_OK;
+ }
+}
+
+static int
replica_config_delete (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
int *returncode, char *returntext, void *arg)
{
@@ -653,6 +802,15 @@ static int replica_execute_task (Object *r, const char *task_name, char *returnt
else
return LDAP_SUCCESS;
}
+ else if (strcasecmp (task_name, LDIF2CL_TASK) == 0)
+ {
+ if (apply_mods)
+ {
+ return replica_execute_ldif2cl_task (r, returntext);
+ }
+ else
+ return LDAP_SUCCESS;
+ }
else if (strncasecmp (task_name, CLEANRUV, CLEANRUVLEN) == 0)
{
int temprid = atoi(&(task_name[CLEANRUVLEN]));
@@ -680,6 +838,69 @@ static int replica_execute_task (Object *r, const char *task_name, char *returnt
}
+static int
+replica_cleanup_task (Object *r, const char *task_name, char *returntext,
+ int apply_mods)
+{
+ int rc = LDAP_SUCCESS;
+ if (apply_mods) {
+ Replica *replica = (Replica*)object_get_data (r);
+ if (NULL == replica) {
+ rc = LDAP_OPERATIONS_ERROR;
+ } else {
+ rc = replica_task_done(replica);
+ }
+ }
+ return rc;
+}
+
+static int
+replica_task_done(Replica *replica)
+{
+ int rc = LDAP_OPERATIONS_ERROR;
+ char *replica_dn = NULL;
+ Slapi_PBlock *pb = NULL;
+ LDAPMod *mods [2];
+ LDAPMod mod;
+ if (NULL == replica) {
+ return rc;
+ }
+ /* dn: cn=replica,cn=dc\3Dexample\2Cdc\3Dcom,cn=mapping tree,cn=config */
+ replica_dn = slapi_create_dn_string("%s,cn=\"%s\",%s",
+ REPLICA_RDN,
+ slapi_sdn_get_dn(replica_get_root(replica)),
+ CONFIG_BASE);
+ if (NULL == replica_dn) {
+ return rc;
+ }
+ pb = slapi_pblock_new();
+ mods[0] = &mod;
+ mods[1] = NULL;
+ mod.mod_op = LDAP_MOD_DELETE | LDAP_MOD_BVALUES;
+ mod.mod_type = (char *)TASK_ATTR;
+ mod.mod_bvalues = NULL;
+
+ slapi_modify_internal_set_pb(pb, replica_dn, mods, NULL/* controls */,
+ NULL/* uniqueid */,
+ repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION),
+ 0/* flags */);
+ slapi_modify_internal_pb (pb);
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ if ((rc != LDAP_SUCCESS) && (rc != LDAP_NO_SUCH_ATTRIBUTE)) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "replica_task_done: "
+ "failed to remove (%s) attribute from (%s) entry; "
+ "LDAP error - %d\n",
+ TASK_ATTR, replica_dn, rc);
+ }
+
+ slapi_pblock_destroy (pb);
+ slapi_ch_free_string(&replica_dn);
+
+ return rc;
+}
+
static int replica_execute_cl2ldif_task (Object *r, char *returntext)
{
int rc;
@@ -693,7 +914,8 @@ static int replica_execute_cl2ldif_task (Object *r, char *returntext)
PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE, "changelog is not open");
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"replica_execute_cl2ldif_task: %s\n", returntext);
- return LDAP_OPERATIONS_ERROR;
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bail;
}
rlist[0] = r;
@@ -702,25 +924,126 @@ static int replica_execute_cl2ldif_task (Object *r, char *returntext)
/* file is stored in the changelog directory and is named
<replica name>.ldif */
clDir = cl5GetDir ();
- PR_ASSERT (clDir);
+ if (NULL == clDir) {
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bail;
+ }
replica = (Replica*)object_get_data (r);
- PR_ASSERT (replica);
+ if (NULL == replica) {
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bail;
+ }
PR_snprintf (fName, MAXPATHLEN, "%s/%s.ldif", clDir, replica_get_name (replica));
slapi_ch_free ((void**)&clDir);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "Beginning changelog export of replica \"%s\"\n",
+ replica_get_name(replica));
rc = cl5ExportLDIF (fName, rlist);
- if (rc != CL5_SUCCESS)
+ if (rc == CL5_SUCCESS) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "Finished changelog export of replica \"%s\"\n",
+ replica_get_name(replica));
+ rc = LDAP_SUCCESS;
+ } else {
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Failed changelog export replica %s; "
+ "changelog error - %d", replica_get_name(replica), rc);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "replica_execute_cl2ldif_task: %s\n", returntext);
+ rc = LDAP_OPERATIONS_ERROR;
+ }
+bail:
+ return rc;
+}
+
+static int replica_execute_ldif2cl_task (Object *r, char *returntext)
+{
+ int rc, imprc = 0;
+ Object *rlist [2];
+ Replica *replica;
+ char fName [MAXPATHLEN];
+ char *clDir;
+ changelog5Config config;
+
+ if (cl5GetState () != CL5_STATE_OPEN)
{
- PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE, "failed to export changelog data to file %s; "
- "changelog error - %d", fName, rc);
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE, "changelog is not open");
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "replica_execute_cl2ldif_task: %s\n", returntext);
- return LDAP_OPERATIONS_ERROR;
+ "replica_execute_ldif2cl_task: %s\n", returntext);
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bail;
}
- return LDAP_SUCCESS;
+ rlist[0] = r;
+ rlist[1] = NULL;
+
+ /* file is stored in the changelog directory and is named
+ <replica name>.ldif */
+ clDir = cl5GetDir ();
+ if (NULL == clDir) {
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bail;
+ }
+
+ replica = (Replica*)object_get_data (r);
+ if (NULL == replica) {
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bail;
+ }
+
+ PR_snprintf (fName, MAXPATHLEN, "%s/%s.ldif", clDir, replica_get_name (replica));
+
+ rc = cl5Close();
+ if (rc != CL5_SUCCESS)
+ {
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "failed to close changelog to import changelog data; "
+ "changelog error - %d", rc);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "replica_execute_ldif2cl_task: %s\n", returntext);
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bail;
+ }
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "Beginning changelog import of replica \"%s\"\n",
+ replica_get_name(replica));
+ imprc = cl5ImportLDIF (clDir, fName, rlist);
+ slapi_ch_free ((void**)&clDir);
+ if (CL5_SUCCESS == imprc)
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "Finished changelog import of replica \"%s\"\n",
+ replica_get_name(replica));
+ }
+ else
+ {
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Failed changelog import replica %s; "
+ "changelog error - %d", replica_get_name(replica), rc);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "replica_execute_ldif2cl_task: %s\n", returntext);
+ imprc = LDAP_OPERATIONS_ERROR;
+ }
+ changelog5_read_config (&config);
+ /* restart changelog */
+ rc = cl5Open (config.dir, &config.dbconfig);
+ if (CL5_SUCCESS == rc)
+ {
+ rc = LDAP_SUCCESS;
+ }
+ else
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "replica_execute_ldif2cl_task: failed to start changelog at %s\n",
+ config.dir);
+ rc = LDAP_OPERATIONS_ERROR;
+ }
+bail:
+ /* if cl5ImportLDIF returned an error, report it first. */
+ return imprc?imprc:rc;
}
static multimaster_mtnode_extension *
@@ -739,7 +1062,7 @@ _replica_config_get_mtnode_ext (const Slapi_Entry *e)
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_add: "
"configuration entry %s missing %s attribute\n",
escape_string(slapi_entry_get_dn((Slapi_Entry *)e), ebuf),
- attr_replicaRoot);
+ attr_replicaRoot);
return NULL;
}
@@ -756,7 +1079,7 @@ _replica_config_get_mtnode_ext (const Slapi_Entry *e)
else
{
/* check if replica object already exists for the specified subtree */
- ext = (multimaster_mtnode_extension *)repl_con_get_ext (REPL_CON_EXT_MTNODE, mtnode);
+ ext = (multimaster_mtnode_extension *)repl_con_get_ext (REPL_CON_EXT_MTNODE, mtnode);
}
slapi_sdn_free (&sdn);
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index 02f9c1b..4a55d0b 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -1715,9 +1715,12 @@ get_ruvelement_from_berval(const struct berval *bval)
}
else
{
- if (bval->bv_len - mincsnbegin != (_CSN_VALIDCSN_STRLEN * 2) + 1)
+ if ((bval->bv_len - mincsnbegin != (_CSN_VALIDCSN_STRLEN * 2) + 1)
+ && (bval->bv_len - mincsnbegin != (_CSN_VALIDCSN_STRLEN * 2) + 10))
{
- /* Malformed - incorrect length for 2 CSNs + space */
+ /* Malformed - incorrect length for 2 CSNs + space AND
+ * incorrect length for 2 CSNs + 2 spaces +
+ * last_modified (see ruv_dump) */
goto loser;
}
else
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index d9da346..91a6023 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -182,6 +182,7 @@ CSN *csn_new();
CSN *csn_new_by_string(const char *s);
void csn_init_by_csn(CSN *csn1,const CSN *csn2);
void csn_init_by_string(CSN *csn, const char *s);
+void csn_init(CSN *csn);
CSN *csn_dup(const CSN *csn);
void csn_free(CSN **csn);
void csn_set_replicaid(CSN *csn, ReplicaId rid);
13 years, 2 months
ldap/servers
by Nathan Kinder
ldap/servers/slapd/pw_mgmt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 66a666c669bc2e954758cbfb02209fab5e446ccf
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Tue Jan 11 10:52:41 2011 -0800
Bug 201652 - LDAPv2 bind with expired password doesn't unbind correctly
When an LDAPv2 client binds with an expired password, we call the
unbind code to disconnect the client. The unbind code doesn't handle
this well since we don't have an actual unbind operation to parse.
It seems wrong to call the unbind code to disconnect the client, as
we don't have an actual unbind operation to process and we don't
want to call any unbind plug-ins. The proper thing would be to
just disconnect the client without going through all of the unbind
operation processing.
diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c
index 97b51c8..7aca148 100644
--- a/ldap/servers/slapd/pw_mgmt.c
+++ b/ldap/servers/slapd/pw_mgmt.c
@@ -210,7 +210,8 @@ skip:
pre and post ops. Maybe we don't want to call them */
if (pb->pb_conn && (LDAP_VERSION2 == pb->pb_conn->c_ldapversion)) {
/* We close the connection only with LDAPv2 connections */
- do_unbind( pb );
+ disconnect_server( pb->pb_conn, pb->pb_op->o_connid,
+ pb->pb_op->o_opid, SLAPD_DISCONNECT_UNBIND, 0);
}
/* Apply current modifications */
pw_apply_mods(dn, &smods);
13 years, 2 months
Changes to 'refs/tags/389-admin-1.1.14'
by Richard Allen Megginson
Changes since 389-admin-1.1.11:
Endi S. Dewata (2):
Bug 573889 - Migration does not remove deprecated schema
Bug 644929 - FDS to 389 DS migration results in both Fedora and 389 entries
Nathan Kinder (3):
Bug 648949 - Merge selinux policy into base OS
Regenerated autoconf files
Bug 638511 - dirsrv-admin crashes at startup with SELinux enabled
Rich Megginson (17):
bump version to 1.1.12.a1
initial support for openldap
add selinux policy for dsgw
skip LD_PRELOAD if using openldap
add more log information if nss init fails
add even more nss debugging
Bug 618454 - mod_admserv should only clear NSS caches and shutdown if NSS is initialized
bump version to 1.1.12.a2
fix building with mozldap
bump version to 1.1.12.a3
fix autotool build issues with properties files
setup-ds-admin.pl -u exits with ServerAdminID and as_uid related error
Bug 656441 - Missing library path entry causes LD_PRELOAD error
bump version to 1.1.13
bump version to 1.1.14.a1
Bug 664671 - Admin server segfault when full SSL access (http+ldap+console) required
bump version to 1.1.14
---
Makefile.am | 39 +
Makefile.in | 76 +-
VERSION.sh | 4
admserv/cfgstuff/start-ds-admin.in | 25
admserv/cgi-src40/admlib.mk | 119 ----
admserv/cgi-src40/admpw.c | 67 --
admserv/cgi-src40/dllglue.c | 42 -
admserv/cgi-src40/dsconfig.c | 9
admserv/cgi-src40/htmladmin.c | 166 +++---
admserv/cgi-src40/security.c | 2
admserv/cgi-src40/viewdata.c | 150 +++--
admserv/cgi-src40/viewlog.c | 21
admserv/newinst/src/25changefedorato389.pl | 36 -
admserv/newinst/src/AdminMigration.pm.in | 55 +-
admserv/newinst/src/AdminUtil.pm.in | 1
config.h.in | 12
configure | 790 ++++++++++++++++++++++++++---
configure.ac | 15
include/libadmin/libadmin.h | 62 ++
include/libdsa/dsalib.h | 6
lib/libadmin/dllglue.c | 77 --
lib/libadmin/util.c | 737 +++++++++++++++++++++++++++
lib/libdsa/dsalib_conf.c | 15
lib/libdsa/dsalib_confs.c | 68 ++
m4/mozldap.m4 | 116 ++--
m4/openldap.m4 | 131 ++++
m4/selinux.m4 | 3
mod_admserv/mod_admserv.c | 148 ++---
mod_admserv/mod_admserv.h | 15
selinux/dirsrv-admin.fc.in | 5
selinux/dirsrv-admin.te | 2
tests/ds_create/testget.1 | 2
tests/htmladmin/testget.2 | 2
tests/htmladmin/testget.3 | 2
tests/htmladmin/testget.4 | 2
tests/htmladmin/testget.5 | 2
tests/htmladmin/testget.6 | 2
tests/htmladmin/testget.7 | 2
tests/htmladmin/testget.8 | 2
tests/setup.sh | 250 ++++++---
tests/ugdsconfig/testget.10 | 2
tests/viewdata/testget.2 | 2
tests/viewdata/testget.3 | 2
tests/viewdata/testget.4 | 2
tests/viewlog/testget.3 | 2
tests/viewlog/testget.4 | 2
46 files changed, 2437 insertions(+), 855 deletions(-)
---
13 years, 2 months
2 commits - mod_admserv/mod_admserv.c VERSION.sh
by Richard Allen Megginson
VERSION.sh | 2 +-
mod_admserv/mod_admserv.c | 27 +++++++++++----------------
2 files changed, 12 insertions(+), 17 deletions(-)
New commits:
commit 3be563760e82ee6bab5248dc2ea5f4ecc8ffd5c5
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Jan 7 14:57:44 2011 -0700
bump version to 1.1.14
diff --git a/VERSION.sh b/VERSION.sh
index 5c14b42..33599fe 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -15,7 +15,7 @@ VERSION_MAINT=14
# if this is a PRERELEASE, set VERSION_PREREL
# otherwise, comment it out
# be sure to include the dot prefix in the prerel
-VERSION_PREREL=.a1
+#VERSION_PREREL=.a1
# NOTES on VERSION_PREREL
# use aN for an alpha release e.g. a1, a2, etc.
# use rcN for a release candidate e.g. rc1, rc2, etc.
commit f08ab2ae5a9ce1ed7d5187f5e93a7e7854faacf3
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Jan 5 15:47:28 2011 -0700
Bug 664671 - Admin server segfault when full SSL access (http+ldap+console) required
https://bugzilla.redhat.com/show_bug.cgi?id=664671
Resolves: bug 664671
Bug Description: Admin server segfault when full SSL access (http+ldap+console) required
Reviewed by: ???
Branch: master
Fix Description: Do not call NSS_Shutdown in mod_admserv. It should always
be called in mod_nss, after mod_admserv_unload is called. The only thing
we need to do in mod_admserv_unload() is to clear the session cache to
release any resources acquired by mod_admserv. mod_nss unload will take
care of the rest.
Platforms tested: RHEL5 i386
Flag Day: no
Doc impact: no
diff --git a/mod_admserv/mod_admserv.c b/mod_admserv/mod_admserv.c
index ec7397c..6f96669 100644
--- a/mod_admserv/mod_admserv.c
+++ b/mod_admserv/mod_admserv.c
@@ -2223,28 +2223,23 @@ host_ip_init(apr_pool_t *p, apr_pool_t *plog,
* NSS caches SSL client session information - this cache must be cleared, otherwise
* NSS_Shutdown will give an error. mod_nss also does this (along with the NSS_Shutdown)
* It is ok to call SSL_ClearSessionCache multiple times.
+ * The actual NSS_Shutdown is done in mod_nss. Note that we cannot call NSS_Shutdown
+ * here - if NSS_Shutdown fails because mod_nss still has server caches referenced,
+ * NSS will be left in a bad state - it won't really be shutdown because of the outstanding
+ * references, but NSS_IsInitialized will return false, and NSS_Initialize will fail.
+ * So we must be careful here to just release any references we have.
+ * The assumption here is that mod_nss is loaded before mod_admserv (which will usually
+ * happen since it is listed first in the httpd.conf) - but note that module unload
+ * happens in _reverse_ order - so mod_admserv_unload will be called _before_ the
+ * mod_nss unload function. If this ever changes, we will need to figure out some other
+ * way to ensure that NSS_Shutdown is only ever called once, and only after all caches
+ * and other resources have been released.
*/
static
apr_status_t mod_admserv_unload(void *data)
{
if (NSS_IsInitialized()) {
- SECStatus status;
SSL_ClearSessionCache();
- status = NSS_Shutdown();
- if (status != SECSuccess) {
- PRErrorCode prerr = PR_GetError();
- if (prerr == SEC_ERROR_NOT_INITIALIZED) {
- ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
- "Unable to shutdown NSS - not initialized");
- } else if (prerr == SEC_ERROR_BUSY) {
- ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
- "Unable to shutdown NSS - still busy - assume mod_nss is holding references - continuing");
- } else {
- ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
- "Unable to shutdown NSS - [%d:%s]",
- prerr, SSL_Strerror(prerr));
- }
- }
}
return OK;
}
13 years, 2 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 12 ------------
1 file changed, 12 deletions(-)
New commits:
commit 573b529b3c44084cfa8b4659b803f8fc596021f1
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Jan 7 13:21:33 2011 -0800
Bug 667488 - Cannot recreate numsubordinates index with db2index
https://bugzilla.redhat.com/show_bug.cgi?id=667488
Description: Special thanks to Orion Poplawski(orion(a)cora.nwra.com)
for his in-depth analysis on the bug. As he figured out, a helper
function add_op_attrs called from the reindex API ldbm_back_ldbm2index
removes the numsubordinates attribute-value pair from entries to
be reindexed, which makes reindexing numsubordinates fail.
The helper function add_op_attrs adds operational attributes parentid,
entryid and entrydn to entries as well as removes numsubordinates
from them before the entries are reindexed/imported. The add and
remove are necessary for the import, but not for the reindex since
these to-be-added operational attributes are already in entries
in the primary database id2entry. And numsubordinates is necessary
when the attribute is reindexed.
This patch updates ldbm_back_ldbm2index (ldif2ldbm.c) not to call
add_op_attrs.
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 4f8e198..a89f5e9 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -2110,18 +2110,6 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
continue;
}
- if ( add_op_attrs( pb, li, ep, NULL ) != 0 ) {
- if (task) {
- slapi_task_log_notice(task,
- "%s: ERROR: Could not add op attrs to entry (id %lu)",
- inst->inst_name, (u_long)ep->ep_id);
- }
- LDAPDebug(LDAP_DEBUG_ANY,
- "%s: ERROR: Could not add op attrs to entry (id %lu)\n",
- inst->inst_name, (u_long)ep->ep_id, 0);
- goto err_out;
- }
-
/*
* Update the attribute indexes
*/
13 years, 2 months
ldap/servers
by Nathan Kinder
ldap/servers/slapd/saslbind.c | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 186137e184bd12c4b2b68750cf50f9f4e8c149b2
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Jan 7 14:38:09 2011 -0800
Bug 193297 - Call pre-bind plug-ins for all SASL bind steps
A pre-bind plug-in is currently only called after the final step
has been completed in a multi-step SASL bind operation. We need
to call the pre-bind functions for each step of the bind.
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index 401a82f..5204b56 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -1043,6 +1043,10 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
case SASL_CONTINUE: /* another step needed */
pb->pb_conn->c_flags |= CONN_FLAG_SASL_CONTINUE;
+ if (plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) != 0){
+ break;
+ }
+
/* attach the sasl data */
bvr.bv_val = (char*)sdata;
bvr.bv_len = slen;
13 years, 2 months
ldap/servers
by Nathan Kinder
ldap/servers/plugins/mep/mep.c | 176 +++++++++++++++++++++++++++--------------
1 file changed, 117 insertions(+), 59 deletions(-)
New commits:
commit 2e35351caf93e7338cd82b1c3eba46fc019f7121
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Jan 7 10:19:59 2011 -0800
Bug 661102 - Rename of managed entries not handled correctly
When usign the managed entry plug-in, a modify operation against
an origin entry that should trigger a rename of a managed entry
does not trigger the rename. In addition, an error message is
logged since we try to do a modify of the RDN attribute of the
managed entry.
This patch makes the modify callback check if the changes require
a rename of the managed entry when an origin entry is updated. If
a rename is needed, we perform a MODRDN. We also need to skip the
RDN attribute when generating the mapped modifications that we use
to update a managed entry.
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index 63c2dd8..211a4cf 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -105,8 +105,10 @@ static Slapi_Entry *mep_create_managed_entry(struct configEntry *config,
Slapi_Entry *origin);
static void mep_add_managed_entry(struct configEntry *config,
Slapi_Entry *origin);
+static void mep_rename_managed_entry(Slapi_Entry *origin,
+ char *new_dn, char *old_dn);
static Slapi_Mods *mep_get_mapped_mods(struct configEntry *config,
- Slapi_Entry *origin);
+ Slapi_Entry *origin, char **mapped_dn);
static int mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin,
char **type, char **value);
static int mep_is_managed_entry(Slapi_Entry *e);
@@ -1193,6 +1195,77 @@ mep_add_managed_entry(struct configEntry *config,
slapi_pblock_destroy(mod_pb);
}
+/* mep_rename_managed_entry()
+ *
+ * Renames a managed entry and updates the pointer in the
+ * origin entry.
+ */
+static void mep_rename_managed_entry(Slapi_Entry *origin,
+ char *new_dn, char *old_dn)
+{
+ Slapi_RDN *srdn = slapi_rdn_new();
+ Slapi_PBlock *mep_pb = slapi_pblock_new();
+ LDAPMod mod;
+ LDAPMod *mods[2];
+ char *vals[2];
+ int result = LDAP_SUCCESS;
+
+ /* Just bail if any of our parameters are NULL. */
+ if (origin == NULL || new_dn == NULL || old_dn == NULL) {
+ goto bail;
+ }
+
+ /* Create new RDN */
+ slapi_rdn_set_dn(srdn, new_dn);
+
+ /* Rename the managed entry. */
+ slapi_rename_internal_set_pb(mep_pb, old_dn,
+ slapi_rdn_get_rdn(srdn),
+ NULL, 1, NULL, NULL, mep_get_plugin_id(), 0);
+ slapi_modrdn_internal_pb(mep_pb);
+ slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
+
+ if (result != LDAP_SUCCESS) {
+ slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
+ "mep_rename_managed_entry: Unable to rename managed "
+ "entry \"%s\" to \"%s\" (%s).\n", old_dn,
+ new_dn, ldap_err2string(result));
+ } else {
+ /* Clear out the pblock for reuse. */
+ slapi_pblock_init(mep_pb);
+
+ /* Update the link to the managed entry in the origin entry. */
+ vals[0] = new_dn;
+ vals[1] = 0;
+ mod.mod_op = LDAP_MOD_REPLACE;
+ mod.mod_type = MEP_MANAGED_ENTRY_TYPE;
+ mod.mod_values = vals;
+ mods[0] = &mod;
+ mods[1] = 0;
+
+ /* Perform the modify operation. */
+ slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
+ "mep_rename_managed_entry: Updating %s pointer to "
+ "\"%s\" in entry \"%s\"\n.", MEP_MANAGED_ENTRY_TYPE,
+ vals[0], slapi_entry_get_dn(origin));
+ slapi_modify_internal_set_pb(mep_pb, slapi_entry_get_dn(origin), mods,
+ 0, 0, mep_get_plugin_id(), 0);
+ slapi_modify_internal_pb(mep_pb);
+ slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
+
+ if (result != LDAP_SUCCESS) {
+ slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
+ "mep_rename_managed_entry: Unable to update %s "
+ "pointer in entry \"%s\" (%s).\n", MEP_MANAGED_ENTRY_TYPE,
+ slapi_entry_get_dn(origin), ldap_err2string(result));
+ }
+ }
+
+bail:
+ slapi_rdn_free(&srdn);
+ slapi_pblock_destroy(mep_pb);
+}
+
/*
* mep_get_mapped_mods()
*
@@ -1201,7 +1274,7 @@ mep_add_managed_entry(struct configEntry *config,
* returned mods when it is finished using them.
*/
static Slapi_Mods *mep_get_mapped_mods(struct configEntry *config,
- Slapi_Entry *origin)
+ Slapi_Entry *origin, char **mapped_dn)
{
Slapi_Mods *smods = NULL;
Slapi_Entry *template = NULL;
@@ -1209,6 +1282,7 @@ static Slapi_Mods *mep_get_mapped_mods(struct configEntry *config,
char **vals = NULL;
char *type = NULL;
char *value = NULL;
+ char *rdn_type = NULL;
int i = 0;
/* If no template was supplied, there's nothing we can do. */
@@ -1227,12 +1301,31 @@ static Slapi_Mods *mep_get_mapped_mods(struct configEntry *config,
slapi_mods_init(smods, numvals);
}
+ /* Find the the RDN type for the managed entry. */
+ if ((rdn_type = slapi_entry_attr_get_charptr(template, MEP_RDN_ATTR_TYPE)) == NULL) {
+ slapi_log_error( SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
+ "mep_get_mapped_mods: Error getting RDN type from tempate "
+ "\"%s\".\n", config->template_dn);
+ slapi_mods_free(&smods);
+ goto bail;
+ }
+
/* Go through the template and find the mapped attrs. */
vals = slapi_entry_attr_get_charray(template, MEP_MAPPED_ATTR_TYPE);
for (i = 0; vals && vals[i]; ++i) {
if (mep_parse_mapped_attr(vals[i], origin, &type, &value) == 0) {
- /* Add a modify that replaces all values with the new value. */
- slapi_mods_add_string(smods, LDAP_MOD_REPLACE, type, value);
+ /* Don't attempt to modify the RDN type, but create
+ * the mapped DN if requested. It is up to the caller
+ * to free the returned DN. */
+ if (slapi_attr_type_cmp(type, rdn_type, SLAPI_TYPE_CMP_EXACT) == 0) {
+ if (mapped_dn) {
+ *mapped_dn = slapi_create_dn_string("%s=%s,%s", rdn_type,
+ value, config->managed_base);
+ }
+ } else {
+ /* Add a modify that replaces all values with the new value. */
+ slapi_mods_add_string(smods, LDAP_MOD_REPLACE, type, value);
+ }
slapi_ch_free_string(&type);
slapi_ch_free_string(&value);
} else {
@@ -1245,6 +1338,7 @@ static Slapi_Mods *mep_get_mapped_mods(struct configEntry *config,
}
bail:
+ slapi_ch_free_string(&rdn_type);
slapi_ch_array_free(vals);
return smods;
@@ -1881,6 +1975,9 @@ mep_mod_post_op(Slapi_PBlock *pb)
Slapi_Entry *e = NULL;
char *dn = NULL;
char *managed_dn = NULL;
+ Slapi_DN *managed_sdn = NULL;
+ char *mapped_dn = NULL;
+ Slapi_DN *mapped_sdn = NULL;
struct configEntry *config = NULL;
int result = 0;
@@ -1918,7 +2015,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
mep_config_read_lock();
mep_find_config(e, &config);
if (config) {
- smods = mep_get_mapped_mods(config, e);
+ smods = mep_get_mapped_mods(config, e, &mapped_dn);
if (smods) {
/* Clear out the pblock for reuse. */
mep_pb = slapi_pblock_new();
@@ -1944,6 +2041,19 @@ mep_mod_post_op(Slapi_PBlock *pb)
slapi_mods_free(&smods);
slapi_pblock_destroy(mep_pb);
}
+
+ /* Check if we need to rename the managed entry. */
+ if (mapped_dn) {
+ mapped_sdn = slapi_sdn_new_dn_passin(mapped_dn);
+ managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
+
+ if (slapi_sdn_compare(managed_sdn, mapped_sdn) != 0) {
+ mep_rename_managed_entry(e, mapped_dn, managed_dn);
+ }
+
+ slapi_sdn_free(&mapped_sdn);
+ slapi_sdn_free(&managed_sdn);
+ }
} else {
slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
"mep_mod_post_op: Unable to find config for origin "
@@ -2223,70 +2333,18 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
/* See if we need to rename the managed entry. */
managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
if (slapi_sdn_compare(slapi_entry_get_sdn(new_managed_entry), managed_sdn) != 0) {
- Slapi_RDN *srdn = slapi_rdn_new();
-
- /* Clear out the pblock for reuse. */
- slapi_pblock_init(mep_pb);
-
- /* Create new RDN */
- slapi_rdn_set_dn(srdn, slapi_entry_get_dn(new_managed_entry));
-
/* Rename the managed entry. */
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
"mep_modrdn_post_op: Renaming managed entry "
"\"%s\" to \"%s\" due to rename of origin "
"entry \"%s\".\n ", managed_dn,
slapi_entry_get_dn(new_managed_entry), old_dn);
- slapi_rename_internal_set_pb(mep_pb, managed_dn,
- slapi_rdn_get_rdn(srdn),
- NULL, 1, NULL, NULL, mep_get_plugin_id(), 0);
- slapi_modrdn_internal_pb(mep_pb);
- slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
-
- if (result != LDAP_SUCCESS) {
- slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
- "mep_modrdn_post_op: Unable to rename managed "
- "entry \"%s\" to \"%s\" (%s).\n", managed_dn,
- slapi_entry_get_dn(new_managed_entry),
- ldap_err2string(result));
- } else {
- /* Clear out the pblock for reuse. */
- slapi_pblock_init(mep_pb);
-
- /* Update the link to the managed entry in the origin
- * entry. We can just reuse the mod structure. */
- vals[0] = slapi_entry_get_dn(new_managed_entry);
- mod.mod_op = LDAP_MOD_REPLACE;
- mod.mod_type = MEP_MANAGED_ENTRY_TYPE;
- mod.mod_values = vals;
-
- /* Perform the modify operation. */
- slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
- "mep_modrdn_post_op: Updating %s pointer to "
- "\"%s\" in entry \"%s\"\n.", MEP_MANAGED_ENTRY_TYPE,
- vals[0], new_dn);
- slapi_modify_internal_set_pb(mep_pb, new_dn, mods, 0, 0,
- mep_get_plugin_id(), 0);
- slapi_modify_internal_pb(mep_pb);
- slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
-
- if (result != LDAP_SUCCESS) {
- slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
- "mep_modrdn_post_op: Unable to rename managed "
- "entry \"%s\" to \"%s\" (%s).\n", managed_dn,
- slapi_entry_get_dn(new_managed_entry),
- ldap_err2string(result));
- slapi_rdn_free(&srdn);
- goto bail;
- }
- }
-
- slapi_rdn_free(&srdn);
+ mep_rename_managed_entry(post_e, slapi_entry_get_dn(new_managed_entry), managed_dn);
}
/* Update all of the mapped attributes
* to be sure they are up to date. */
- smods = mep_get_mapped_mods(config, post_e);
+ smods = mep_get_mapped_mods(config, post_e, NULL);
if (smods) {
/* Clear out the pblock for reuse. */
slapi_pblock_init(mep_pb);
13 years, 2 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
New commits:
commit 3c021b261277d26e2943ff3d6a6fae74c6bdca5b
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jan 6 14:01:10 2011 -0800
Bug 653007 - db2ldif export of clear text passwords lacks storage scheme
https://bugzilla.redhat.com/show_bug.cgi?id=653007
Description: Export utility db2ldif{.pl} used to export clear
text passwords without the storage scheme name {CLEAR}.
This patch checks each userPassword value. If the value is
not hashed, put "{CLEAR}" in front of the value as follows.
userPassword: {CLEAR}notsosecret
m4/ltversio.nm4
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index e6ef4d9..4f8e198 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -955,6 +955,32 @@ export_one_entry(struct ldbminfo *li,
slapi_sdn_get_dn(&expargs->ep->ep_entry->e_sdn), rc, 0);
}
}
+ /*
+ * Check if userPassword value is hashed or not.
+ * If it is not, put "{CLEAR}" in front of the password value.
+ */
+ {
+ char *pw = slapi_entry_attr_get_charptr(expargs->ep->ep_entry,
+ "userpassword");
+ if (pw && !slapi_is_encoded(pw)) {
+ /* clear password does not have {CLEAR} storage scheme */
+ struct berval *vals[2];
+ struct berval val;
+ val.bv_val = slapi_ch_smprintf("{CLEAR}%s", pw);
+ val.bv_len = strlen(val.bv_val);
+ vals[0] = &val;
+ vals[1] = NULL;
+ rc = slapi_entry_attr_replace(expargs->ep->ep_entry,
+ "userpassword", vals);
+ if (rc) {
+ LDAPDebug2Args(LDAP_DEBUG_ANY,
+ "%s: Failed to add clear password storage scheme: %d\n",
+ slapi_sdn_get_dn(&expargs->ep->ep_entry->e_sdn), rc);
+ }
+ slapi_ch_free_string(&val.bv_val);
+ }
+ slapi_ch_free_string(&pw);
+ }
rc = 0;
data.data = slapi_entry2str_with_options(expargs->ep->ep_entry,
&len, expargs->options);
13 years, 2 months