Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/tools
In directory
cvs-int.fedora.redhat.com:/tmp/cvs-serv32489/ldapserver/ldap/servers/slapd/tools
Modified Files:
migratecred.c
Log Message:
Resolves: bug 231905
Bug Description: migration: Migrate from 1.0.x to 1.1
Reviewed by: nhosoi (Thanks!)
Fix Description: The basic strategy is
1) shutdown the old servers - databases should be quiescent
2) run the migration script - this will copy all of the files (under
/opt/fedora-ds/slapd-* by default) to their new FHS style locations, and fix up any
entries and attributes that are obsolete or have changed (e.g. values that refer to
paths)
3) service fedora-ds start
The migration script does not need to do anything to the database files - the new database
code added by Noriko will handle the database upgrade automagically, but I'm leaving
the database upgrade code in the script, commented out, in case we need it in the future.
This also fixes an annoying problem with automake - it would build ds_newinst.pl from
ds_newinst.pl.in in the source ldap/admin/src directory, and use that version. This is
really a problem with multi platform builds, where you want to share the ldapserver source
code among multiple platforms. With the fix, built/ldap/admin/src/ds_newinst.pl is
generated from srcdir/ldap/admin/src/ds_newinst.pl.in, and
srcdir/ldap/admin/src/ds_newinst.pl is not written.
Platforms tested: FC6
Flag Day: no
Doc impact: Yes - we need to document migration
Index: migratecred.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/migratecred.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- migratecred.c 10 Nov 2006 23:45:51 -0000 1.7
+++ migratecred.c 16 Mar 2007 21:32:44 -0000 1.8
@@ -46,6 +46,9 @@
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#ifndef _WIN32
#include <sys/param.h> /* MAXPATHLEN */
@@ -56,7 +59,8 @@
static void usage(char *name)
{
- fprintf(stderr, "usage: %s -o 5.0InstancePath -n 5.1InstancePath -c
5.0Credential\n", name);
+ fprintf(stderr, "usage: %s -o OldInstancePath -n NewInstancePath -c OldCredential
[-p NewPluginPath]\n", name);
+ fprintf(stderr, "New plugin path defaults to [%s] if not given\n",
PLUGINDIR);
exit(1);
}
@@ -76,18 +80,18 @@
}
#endif
-/* Script used during 5.0 to 5.1 migration: replication and
+/* Script used during migration: replication and
chaining backend credentials must be converted.
Assumption: the built-in des-plugin.so lib has been used
- in 5.0 and is used in 5.1
+ in the old version and is used in the new version
Usage: migrateCred
- -o <5.0 instance path>
- -n <5.1 instance path>
- -c <5.0 credential, with prefix>
+ -o <old instance path>
+ -n <new instance path>
+ -c <old credential, with prefix>
- Return 5.1 credential with prefix
+ Return new credential with prefix
*/
int
@@ -96,6 +100,7 @@
char *cmd = argv[0];
char *oldpath = NULL;
char *newpath = NULL;
+ char *pluginpath = NULL;
char *prefixCred = NULL;
char *cred = NULL;
@@ -104,7 +109,7 @@
char libpath[MAXPATHLEN];
char *shared_lib;
- char *opts = "o:n:c:";
+ char *opts = "o:n:c:p:";
int i;
while (( i = getopt( argc, argv, opts )) != EOF )
@@ -144,6 +149,13 @@
}
}
break;
+ case 'p':
+ pluginpath = strdup(optarg);
+#ifdef _WIN32
+ dostounixpath(pluginpath);
+#endif /* _WIN32 */
+
+ break;
default:
usage(cmd);
}
@@ -177,13 +189,26 @@
#endif
#endif
- snprintf(libpath, sizeof(libpath), "%s/../lib/des-plugin%s", newpath,
shared_lib);
- libpath[sizeof(libpath)-1] = 0;
+ if (!pluginpath) {
+ pluginpath = strdup(PLUGINDIR);
+#ifdef _WIN32
+ dostounixpath(pluginpath);
+#endif /* _WIN32 */
+ }
+
+ if (access(pluginpath, R_OK)) {
+ snprintf(libpath, sizeof(libpath), "%s/../lib/des-plugin%s", newpath,
shared_lib);
+ libpath[sizeof(libpath)-1] = 0;
+ } else {
+ snprintf(libpath, sizeof(libpath), "%s/libdes-plugin%s", pluginpath,
shared_lib);
+ libpath[sizeof(libpath)-1] = 0;
+ }
fct = (migrate_fn_type)sym_load(libpath, "migrateCredentials",
"DES Plugin", 1 /* report errors */ );
if ( fct == NULL )
{
+ usage(cmd);
return(1);
}