summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'ldap/servers/plugins')
-rw-r--r--ldap/servers/plugins/usn/usn.c63
-rw-r--r--ldap/servers/plugins/usn/usn.h2
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 */