Description of problem: db2bak /export/servers/ds72////var/lib/dirsrv/../dirsrv/slapd-laputa0/././/db/ Back up directory: /export/servers/ds72////var/lib/dirsrv/../dirsrv/slapd-laputa0/././/db/ [02/Oct/2007:12:04:19 -0700] - db2archive: /export/servers/ds72////var/lib/dirsrv/../dirsrv/slapd-laputa0/././/db/ exists. Renaming to /export/servers/ds72////var/lib/dirsrv/../dirsrv/slapd-laputa0/././/db/.bak [02/Oct/2007:12:04:19 -0700] - db2archive: Failed to rename "/export/servers/ds72////var/lib/dirsrv/../dirsrv/slapd-laputa0/././/db/" to "/export/servers/ds72////var/lib/dirsrv/../dirsrv/slapd-laputa0/././/db/.bak".[02/Oct/2007:12:04:19 -0700] - Netscape Portable Runtime error -5987 (Invalid function argument.)
Created attachment 214191 [details] cvs diff ldapserver/ldap/servers/slapd/back-ldbm/archive.c Fix description: 1. Use path normalize API rel2abspath to remove the trailing '/'. 2. db2bak renames the archive dir if the directory exists, checks the directory is the db dir or not. If it is, the command line rename back the existing db to the original and exits with the error: db2archive: Cannot archive to the db directory. Then, the original dir is renamed back. If the db2bak runs as a task (db2bak.pl or console), the server is up and running. Although the backend is disabled, we don't want to rename the db path even for a short time. That being said, changed the order to: check if the archive dir is the same as db dir or not. It exits immediately.
Created attachment 214951 [details] cvs commit message Reviewed by Nathan (Thank you!!) Checked in into CVS HEAD.
This fix caused a regression. If I try to perform a backup via Console, it causes ns-slapd to SIGSEGV. Here are some of the details: Console Debug output: LDAPTask.initTask(): adding entry LDAPEntry: cn=backup1191863537867, cn=backup, cn=tasks, cn=config; LDAPAttributeSet: LDAPAttribute {type='objectclass', values='top,extensibleObject'} LDAPAttribute {type='cn', values='backup1191863537867'} LDAPAttribute {type='ttl', values='4'} LDAPAttribute {type='nsArchiveDir', values='/var/lib/dirsrv/slapd-crunch/bak/2007_10_08_10_11_45'} LDAPAttribute {type='nsDatabaseType', values='ldbm database'} LDAPTask.testTaskEntry Stack: (gdb) where #0 0x00a7b777 in opendir () from /lib/tls/libc.so.6 #1 0x00dc472b in PR_OpenDir () from /usr/lib/dirsec/libnspr4.so #2 0x009bb07f in ldbm_delete_dirs () from /usr/lib/dirsrv/plugins/libback-ldbm.so #3 0x0097e2b5 in ldbm_back_ldbm2archive () from /usr/lib/dirsrv/plugins/libback-ldbm.so #4 0x006a5a3d in slapi_task_log_status () from /usr/lib/dirsrv/libslapd.so.0 #5 0x00dc5dff in PR_Select () from /usr/lib/dirsec/libnspr4.so #6 0x001573cc in start_thread () from /lib/tls/libpthread.so.0 #7 0x00abdc3e in clone () from /lib/tls/libc.so.6 Errors Log: [08/Oct/2007:10:09:55 -0700] - slapd started. Listening on All Interfaces port 389 for LDAP requests [08/Oct/2007:10:12:16 -0700] - Beginning backup of 'ldbm database' [08/Oct/2007:10:12:16 -0700] - db2archive: mkdir((null)) failed; errno 14 (Bad address) [08/Oct/2007:10:12:16 -0700] - db2archive: Rename (null) back to (null)
Created attachment 220021 [details] CVS Diffs These diffs initialize the normalized backup directory name before checking if the directory already exists. The prior case was only performing this initialization for the case where the backup directory already exists, which would cause it to be NULL for the other case. This would cause ns-slapd to SIGSEGV later.
Thanks a lot, Nathan, for finding out the problem and fixing it!
Checked into ldapserver (HEAD). Thanks to Noriko for her review! Checking in archive.c; /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/archive.c,v <-- archive.c new revision: 1.14; previous revision: 1.13 done
Argh... If the specified back up path only ends with '/' (not including redundant dirs with dots), the normalization was passed. I made the condition changed. Index: util.c =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/util.c,v retrieving revision 1.15 diff -t -w -U4 -r1.15 util.c --- util.c 3 Oct 2007 00:55:35 -0000 1.15 +++ util.c 29 Nov 2007 21:26:35 -0000 @@ -528,10 +528,10 @@ PL_strcatn( abspath, sizeof(abspath), relpath ); } } retpath = slapi_ch_strdup(abspath); - /* if there's no '.', no need to call normalize_path */ - if (NULL != strchr(abspath, '.') || NULL != strstr(abspath, _PSEP2)) + /* if there's no '.' or separators, no need to call normalize_path */ + if (NULL != strchr(abspath, '.') || NULL != strstr(abspath, _PSEP)) { char **norm_path = normalize_path(abspath); char **np, *rp; int pathlen = strlen(abspath) + 1;
Created attachment 274021 [details] cvs commit message Reviewed by Rich (Thank you!!) Checked in into CVS HEAD.