diff options
| author | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-26 17:30:29 -0700 |
|---|---|---|
| committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-31 10:37:35 -0700 |
| commit | a0282b832d09951a893a4293707a2586020d09cf (patch) | |
| tree | 722c08df4ee3c2ad18b15276978b71ae2773af83 /ldap/servers/plugins/usn | |
| parent | 7cd57ad2fc78c90a2405128df1e5414161e1ff9d (diff) | |
| download | ds-a0282b832d09951a893a4293707a2586020d09cf.tar.gz ds-a0282b832d09951a893a4293707a2586020d09cf.tar.xz ds-a0282b832d09951a893a4293707a2586020d09cf.zip | |
Bug 531642 - EntryUSN: RFE: a configuration option to make entryusn "global"
https://bugzilla.redhat.com/show_bug.cgi?id=531642
Resolves: 531642
Fix description:
1. Introduced a config parameter nsslapd-entryusn-global: on|off to
enable | disable the global mode. By default, off.
In the global mode, search on root dse returns "lastusn: <num>"
without the backend subtype (e.g., "lastusn;userroot: <num>")
2. Added slapi_get_next_suffix_ext to mapping_tree.c, which visits
children as well as siblings in the mapping tree.
(Note: slapi_get_next_suffix does just siblings.)
3. import (ldif2db) adds "entryusn: 0" to every entry unless the
entry already contains the entryusn attribute.
4. ldbm_back_delete, ldbm_back_modify, ldbm_back_modrdn: set
ldap_result_code to pblock so that bepost plugin could see if
the operation was successful or not.
See also http://directory.fedoraproject.org/wiki/Entry_USN#Global_mode
Diffstat (limited to 'ldap/servers/plugins/usn')
| -rw-r--r-- | ldap/servers/plugins/usn/usn.c | 63 | ||||
| -rw-r--r-- | ldap/servers/plugins/usn/usn.h | 2 |
2 files changed, 46 insertions, 19 deletions
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c index fff9d8e8..75c80ba2 100644 --- a/ldap/servers/plugins/usn/usn.c +++ b/ldap/servers/plugins/usn/usn.c @@ -565,31 +565,58 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int attr_len = 64; /* length of lastusn;<backend_name> */ char *attr = (char *)slapi_ch_malloc(attr_len); char *attr_subp = NULL; + int isglobal = config_get_entryusn_global(); slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "--> usn_rootdse_search\n"); usn_berval.bv_val = counter_buf; - PR_snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN+1, "%s;", USN_LAST_USN); - attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN; - for (be = slapi_get_first_backend(&cookie); be; - be = slapi_get_next_backend(cookie)) { - if (NULL == be->be_usn_counter) { /* no counter == not a db backend */ - continue; + if (isglobal) { + /* nsslapd-entryusn-global: on*/ + /* root dse shows ... + * lastusn: <num> */ + PR_snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 1, "%s", USN_LAST_USN); + for (be = slapi_get_first_backend(&cookie); be; + be = slapi_get_next_backend(cookie)) { + if (be->be_usn_counter) { + break; + } + } + if (be->be_usn_counter) { + /* get a next USN counter from be_usn_counter; + * then minus 1 from it */ + PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d", + slapi_counter_get_value(be->be_usn_counter)-1); + usn_berval.bv_len = strlen(usn_berval.bv_val); + slapi_entry_attr_replace(e, attr, vals); } - /* get a next USN counter from be_usn_counter; then minus 1 from it */ - PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d", - slapi_counter_get_value(be->be_usn_counter)-1); - usn_berval.bv_len = strlen(usn_berval.bv_val); - - if (USN_LAST_USN_ATTR_CORE_LEN + strlen(be->be_name) + 1 > attr_len) { - attr_len *= 2; - attr = (char *)slapi_ch_realloc(attr, attr_len); - attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN; + } else { + /* nsslapd-entryusn-global: off (default) */ + /* root dse shows ... + * lastusn;<backend>: <num> */ + PR_snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 2, "%s;", USN_LAST_USN); + attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN + 1; + for (be = slapi_get_first_backend(&cookie); be; + be = slapi_get_next_backend(cookie)) { + if (NULL == be->be_usn_counter) { + /* no counter == not a db backend */ + continue; + } + /* get a next USN counter from be_usn_counter; + * then minus 1 from it */ + PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d", + slapi_counter_get_value(be->be_usn_counter)-1); + usn_berval.bv_len = strlen(usn_berval.bv_val); + + if (USN_LAST_USN_ATTR_CORE_LEN+strlen(be->be_name)+2 > attr_len) { + attr_len *= 2; + attr = (char *)slapi_ch_realloc(attr, attr_len); + attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN; + } + PR_snprintf(attr_subp, attr_len - USN_LAST_USN_ATTR_CORE_LEN, + "%s", be->be_name); + slapi_entry_attr_replace(e, attr, vals); } - PR_snprintf(attr_subp, attr_len - USN_LAST_USN_ATTR_CORE_LEN, - "%s", be->be_name); - slapi_entry_attr_replace(e, attr, vals); } slapi_ch_free_string(&cookie); diff --git a/ldap/servers/plugins/usn/usn.h b/ldap/servers/plugins/usn/usn.h index ac9f86b1..8e6c5c8e 100644 --- a/ldap/servers/plugins/usn/usn.h +++ b/ldap/servers/plugins/usn/usn.h @@ -44,7 +44,7 @@ #define USN_CSNGEN_ID 65535 #define USN_LAST_USN "lastusn" -#define USN_LAST_USN_ATTR_CORE_LEN 8 /* lastusn; */ +#define USN_LAST_USN_ATTR_CORE_LEN 7 /* lastusn */ #define USN_COUNTER_BUF_LEN 64 /* enough size for 64 bit integers */ |
