#51153 Ticket 51152 - add changelog config to backup
Closed 3 years ago by spichugi. Opened 3 years ago by elkris.
elkris/389-ds-base t51152  into  master

@@ -3513,8 +3513,10 @@ 

   */

  #define DSE_INDEX "dse_index.ldif"

  #define DSE_INSTANCE "dse_instance.ldif"

+ #define DSE_CHANGELOG "dse_changelog.ldif"

  #define DSE_INDEX_FILTER "(objectclass=nsIndex)"

  #define DSE_INSTANCE_FILTER "(objectclass=nsBackendInstance)"

+ #define DSE_CHANGELOG_FILTER "(cn=changelog5)"

  static int

  dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char *filter)

  {
@@ -3524,6 +3526,7 @@ 

      Slapi_Attr *attr = NULL;

      char *attr_name;

      char *filename = NULL;

+     char *searchbase = NULL;

      PRFileDesc *prfd = NULL;

      int rval = 0;

      int dlen = 0;
@@ -3540,14 +3543,10 @@ 

      slapi_log_err(SLAPI_LOG_TRACE, "dse_conf_backup_core",

                    "(%s): backup file %s\n", filter, filename);

  

-     /* Open the file to write */

-     if ((prfd = PR_Open(filename, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,

-                         SLAPD_DEFAULT_FILE_MODE)) == NULL) {

-         slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core",

-                       "(%s): open %s failed: (%s)\n",

-                       filter, filename, slapd_pr_strerror(PR_GetError()));

-         rval = -1;

-         goto out;

+     if (strcmp(filter, DSE_CHANGELOG_FILTER)) {

+         searchbase = li->li_plugin->plg_dn;

+     } else {

+         searchbase = "cn=config";

      }

  

      srch_pb = slapi_pblock_new();
@@ -3558,10 +3557,27 @@ 

          goto out;

      }

  

-     slapi_search_internal_set_pb(srch_pb, li->li_plugin->plg_dn,

+     slapi_search_internal_set_pb(srch_pb, searchbase,

                                   LDAP_SCOPE_SUBTREE, filter, NULL, 0, NULL, NULL, li->li_identity, 0);

      slapi_search_internal_pb(srch_pb);

      slapi_pblock_get(srch_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);

+ 

+     if (entries == NULL || entries[0] == NULL) {

+         /* no entries found, don't write the file */

+         rval = 0;

+         goto out;

+     }

+ 

+     /* Open the file to write */

+     if ((prfd = PR_Open(filename, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,

+                         SLAPD_DEFAULT_FILE_MODE)) == NULL) {

+         slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core",

+                       "(%s): open %s failed: (%s)\n",

+                       filter, filename, slapd_pr_strerror(PR_GetError()));

+         rval = -1;

+         goto out;

+     }

+ 

      for (ep = entries; ep != NULL && *ep != NULL; ep++) {

          int32_t l = strlen(slapi_entry_get_dn_const(*ep)) + 5 /* "dn: \n" */;

          slapi_log_err(SLAPI_LOG_TRACE, "dse_conf_backup_core",
@@ -3663,6 +3679,7 @@ 

      int rval = 0;

      rval = dse_conf_backup_core(li, dest_dir, DSE_INSTANCE, DSE_INSTANCE_FILTER);

      rval += dse_conf_backup_core(li, dest_dir, DSE_INDEX, DSE_INDEX_FILTER);

+     rval += dse_conf_backup_core(li, dest_dir, DSE_CHANGELOG, DSE_CHANGELOG_FILTER);

      return rval;

  }

  

Bug: there is no chchangelog info in a backup

Fix: add a config info file

Reviewed by: ?

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/4206

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata