Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 214191 Details for
Bug 316281
db2bak fails if the archive path exists and ends with '/'
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
cvs diff ldapserver/ldap/servers/slapd/back-ldbm/archive.c
archive.c.diff (text/plain), 8.68 KB, created by
Noriko Hosoi
on 2007-10-02 22:44:10 UTC
(
hide
)
Description:
cvs diff ldapserver/ldap/servers/slapd/back-ldbm/archive.c
Filename:
MIME Type:
Creator:
Noriko Hosoi
Created:
2007-10-02 22:44:10 UTC
Size:
8.68 KB
patch
obsolete
>Index: archive.c >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/archive.c,v >retrieving revision 1.12 >diff -t -w -U4 -r1.12 archive.c >--- archive.c 26 Mar 2007 23:04:17 -0000 1.12 >+++ archive.c 2 Oct 2007 22:35:24 -0000 >@@ -109,9 +109,9 @@ > { > slapi_task_log_notice(task, > "backup has old idl format; " > "to restore old formated backup onto the new server, " >- "please use command line utility \"bak2db\" .\n"); >+ "please use command line utility \"bak2db\" ."); > } > goto out; > } > /* server is up -- mark all backends busy */ >@@ -127,9 +127,9 @@ > inst->inst_name, 0, 0); > if (task) { > slapi_task_log_notice(task, > "Backend '%s' is already in the middle of " >- "another task and cannot be disturbed.\n", >+ "another task and cannot be disturbed.", > inst->inst_name); > } > > /* painfully, we have to clear the BUSY flags on the >@@ -256,36 +256,69 @@ > > int ldbm_back_ldbm2archive( Slapi_PBlock *pb ) > { > struct ldbminfo *li; >- char *directory = NULL; /* -a <directory> */ >+ char *rawdirectory = NULL; /* -a <directory> */ >+ char *directory = NULL; /* normalized */ > char *dir_bak = NULL; > int return_value = -1; > int task_flags = 0; > int run_from_cmdline = 0; > Slapi_Task *task; > struct stat sbuf; > > slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li ); >- slapi_pblock_get( pb, SLAPI_SEQ_VAL, &directory ); >+ slapi_pblock_get( pb, SLAPI_SEQ_VAL, &rawdirectory ); > slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags ); > li->li_flags = run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); > > slapi_pblock_get( pb, SLAPI_BACKEND_TASK, &task ); > >- if ( !directory || !*directory ) { >+ if ( !rawdirectory || !*rawdirectory ) { > LDAPDebug( LDAP_DEBUG_ANY, "db2archive: no archive name\n", > 0, 0, 0 ); >- return( -1 ); >+ return -1; >+ } >+ >+ /* start the database code up, do not attempt to perform recovery */ >+ if (run_from_cmdline) { >+ /* No ldbm be's exist until we process the config information. */ >+ mapping_tree_init(); >+ ldbm_config_load_dse_info(li); >+ if (0 != (return_value = >+ dblayer_start(li, >+ DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE))) { >+ LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to init database\n", >+ 0, 0, 0); >+ if (task) { >+ slapi_task_log_notice(task, "Failed to init database"); >+ } >+ return -1; >+ } >+ } >+ >+ if (stat(rawdirectory, &sbuf) == 0) { >+ int baklen = 0; >+ directory = rel2abspath(rawdirectory); >+ >+ if (slapd_comp_path(directory, li->li_directory) == 0) { >+ LDAPDebug(LDAP_DEBUG_ANY, >+ "db2archive: Cannot archive to the db directory.\n", 0, 0, 0); >+ if (task) { >+ slapi_task_log_notice(task, >+ "Cannot archive to the db directory."); > } >- if (stat(directory, &sbuf) == 0) { >- int baklen = strlen(directory) + 5; /* ".bak\0" */ >+ return_value = -1; >+ goto out; >+ } >+ >+ baklen = strlen(directory) + 5; /* ".bak\0" */ > dir_bak = slapi_ch_malloc(baklen); > PR_snprintf(dir_bak, baklen, "%s.bak", directory); > LDAPDebug(LDAP_DEBUG_ANY, "db2archive: %s exists. Renaming to %s\n", > directory, dir_bak, 0); > if (task) { >- slapi_task_log_notice(task, "%s exists. Renaming to %s\n", >+ slapi_task_log_notice(task, "%s exists. Renaming to %s", > directory, dir_bak); > } > if (stat(dir_bak, &sbuf) == 0) { > return_value = ldbm_delete_dirs(dir_bak); >@@ -294,9 +327,9 @@ > "db2archive: %s exists and failed to delete it.\n", > dir_bak, 0, 0); > if (task) { > slapi_task_log_notice(task, >- "%s exists and failed to delete it.\n", dir_bak); >+ "%s exists and failed to delete it.", dir_bak); > } > return_value = -1; > goto out; > } >@@ -304,12 +337,12 @@ > return_value = PR_Rename(directory, dir_bak); > if (return_value != PR_SUCCESS) { > PRErrorCode prerr = PR_GetError(); > LDAPDebug(LDAP_DEBUG_ANY, >- "db2archive: Failed to rename \"%s\" to \"%s\".", >+ "db2archive: Failed to rename \"%s\" to \"%s\".\n", > directory, dir_bak, 0); > LDAPDebug(LDAP_DEBUG_ANY, >- SLAPI_COMPONENT_NAME_NSPR " error %d (%s)", >+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n", > prerr, slapd_pr_strerror(prerr), 0); > if (task) { > slapi_task_log_notice(task, > "Failed to rename \"%s\" to \"%s\".", >@@ -335,13 +368,8 @@ > } > goto err; > } > >- /* No ldbm be's exist until we process the config information. */ >- if (run_from_cmdline) { >- mapping_tree_init(); >- ldbm_config_load_dse_info(li); >- } > /* to avoid conflict w/ import, do this check for commandline, as well */ > { > Object *inst_obj, *inst_obj2; > ldbm_instance *inst = NULL; >@@ -359,9 +387,9 @@ > inst->inst_name, 0, 0); > if (task) { > slapi_task_log_notice(task, > "Backend '%s' is already in the middle of " >- "another task and cannot be disturbed.\n", >+ "another task and cannot be disturbed.", > inst->inst_name); > } > > /* painfully, we have to clear the BUSY flags on the >@@ -380,47 +408,11 @@ > } > } > } > >- /* start the database code up, do not attempt to perform recovery */ >- if (run_from_cmdline && >- 0 != (return_value = dblayer_start(li,DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE))) { >- LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to init database\n", >- 0, 0, 0); >- if (task) { >- slapi_task_log_notice(task, "Failed to init database"); >- } >- goto rel_err; >- } >- >- if (slapd_comp_path(directory, li->li_directory) == 0) { >- LDAPDebug(LDAP_DEBUG_ANY, >- "db2archive: Cannot archive to the db directory.\n", 0, 0, 0); >- if (task) { >- slapi_task_log_notice(task, "Cannot archive to the db directory.\n"); >- } >- return_value = -1; >- goto rel_err; >- } >- > /* tell it to archive */ > return_value = dblayer_backup(li, directory, task); > >-rel_err: >- /* close the database down again */ >- if (run_from_cmdline && >- 0 != dblayer_close(li,DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE)) { >- LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to close database\n", >- 0, 0, 0); >- if (task) { >- slapi_task_log_notice(task, "Failed to close database"); >- } >- >- /* The backup succeeded, so a failed close is not really a >- total error... */ >- /*return( -1 );*/ >- } >- > if (! run_from_cmdline) { > ldbm_instance *inst; > Object *inst_obj; > >@@ -435,14 +427,25 @@ > if (return_value != 0) { > LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Rename %s back to %s\n", > dir_bak, directory, 0); > if (task) { >- slapi_task_log_notice(task, "Rename %s back to %s\n", >+ slapi_task_log_notice(task, "Rename %s back to %s", > dir_bak, directory); > } > ldbm_delete_dirs(directory); > PR_Rename(dir_bak, directory); > } > out: >+ /* close the database down again */ >+ if (run_from_cmdline && >+ 0 != dblayer_close(li,DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE)) { >+ LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to close database\n", >+ 0, 0, 0); >+ if (task) { >+ slapi_task_log_notice(task, "Failed to close database"); >+ } >+ } >+ > slapi_ch_free_string(&dir_bak); >+ slapi_ch_free_string(&directory); > return return_value; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 316281
: 214191 |
214951
|
220021
|
274021