[Fedora-directory-commits] ldapserver Makefile.am, 1.33, 1.34 aclocal.m4, 1.26, 1.27 configure, 1.35, 1.36 missing, 1.20, 1.21 install-sh, 1.20, 1.21 compile, 1.20, 1.21 depcomp, 1.20, 1.21 config.sub, 1.19, 1.20 config.guess, 1.19, 1.20 Makefile.in, 1.38, 1.39
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9059/ldapserver
Modified Files:
Makefile.am aclocal.m4 configure missing install-sh compile
depcomp config.sub config.guess Makefile.in
Log Message:
Resolves: bug 232684
Description: need initscripts for Solaris
Fix Description: I messed up the linux init script - turns out linux echo doesn't like \c, so I created a echo_n() function which is stolen from configure. I had to add @ECHO_N@ and @ECHO_C@ to Makefile.am and have them replaced in initscript.in.
Index: Makefile.am
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.am,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Makefile.am 16 Mar 2007 21:32:38 -0000 1.33
+++ Makefile.am 16 Mar 2007 23:06:57 -0000 1.34
@@ -981,7 +981,9 @@
-e 's,@sysconfdir\@,$(sysconfdir),g' \
-e 's,@localstatedir\@,$(localstatedir),g' \
-e 's,@package_name\@,$(PACKAGE_NAME),g' \
- -e 's,@instconfigdir\@,$(instconfigdir),g'
+ -e 's,@instconfigdir\@,$(instconfigdir),g' \
+ -e 's,@ECHO_N\@,$(ECHO_N),g' \
+ -e 's,@ECHO_C\@,$(ECHO_C),g'
else
fixupcmd = sed \
-e 's,@bindir\@,$(bindir),g' \
@@ -1005,7 +1007,9 @@
-e 's,@sysconfdir\@,$(sysconfdir),g' \
-e 's,@localstatedir\@,$(localstatedir),g' \
-e 's,@package_name\@,$(PACKAGE_NAME),g' \
- -e 's,@instconfigdir\@,$(instconfigdir),g'
+ -e 's,@instconfigdir\@,$(instconfigdir),g' \
+ -e 's,@ECHO_N\@,$(ECHO_N),g' \
+ -e 's,@ECHO_C\@,$(ECHO_C),g'
endif
%: %.in
Index: Makefile.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.in,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- Makefile.in 16 Mar 2007 21:32:39 -0000 1.38
+++ Makefile.in 16 Mar 2007 23:06:58 -0000 1.39
@@ -1859,7 +1859,9 @@
@BUNDLE_FALSE@ -e 's,@sysconfdir\@,$(sysconfdir),g' \
@BUNDLE_FALSE@ -e 's,@localstatedir\@,$(localstatedir),g' \
@BUNDLE_FALSE@ -e 's,@package_name\@,$(PACKAGE_NAME),g' \
-@BUNDLE_FALSE@ -e 's,@instconfigdir\@,$(instconfigdir),g'
+@BUNDLE_FALSE@ -e 's,@instconfigdir\@,$(instconfigdir),g' \
+@BUNDLE_FALSE@ -e 's,@ECHO_N\@,$(ECHO_N),g' \
+@BUNDLE_FALSE@ -e 's,@ECHO_C\@,$(ECHO_C),g'
# these are for the config files and scripts that we need to generate and replace
@@ -1890,7 +1892,9 @@
@BUNDLE_TRUE@ -e 's,@sysconfdir\@,$(sysconfdir),g' \
@BUNDLE_TRUE@ -e 's,@localstatedir\@,$(localstatedir),g' \
@BUNDLE_TRUE@ -e 's,@package_name\@,$(PACKAGE_NAME),g' \
-@BUNDLE_TRUE@ -e 's,@instconfigdir\@,$(instconfigdir),g'
+@BUNDLE_TRUE@ -e 's,@instconfigdir\@,$(instconfigdir),g' \
+@BUNDLE_TRUE@ -e 's,@ECHO_N\@,$(ECHO_N),g' \
+@BUNDLE_TRUE@ -e 's,@ECHO_C\@,$(ECHO_C),g'
all: $(BUILT_SOURCES) config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
17 years
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools migratecred.c, 1.7, 1.8
by Doctor Conrad
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);
}
17 years
[Fedora-directory-commits] ldapserver/ldap/admin/src migrateTo11.in, NONE, 1.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32489/ldapserver/ldap/admin/src
Added Files:
migrateTo11.in
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
--- NEW FILE migrateTo11.in ---
#!/usr/bin/env perl
#
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
#
# In addition, as a special exception, Red Hat, Inc. gives You the additional
# right to link the code of this Program with code not covered under the GNU
# General Public License ("Non-GPL Code") and to distribute linked combinations
# including the two, subject to the limitations in this paragraph. Non-GPL Code
# permitted under this exception must only link to the code of this Program
# through those well defined interfaces identified in the file named EXCEPTION
# found in the source code files (the "Approved Interfaces"). The files of
# Non-GPL Code may instantiate templates or use macros or inline functions from
# the Approved Interfaces without causing the resulting work to be covered by
# the GNU General Public License. Only Red Hat, Inc. may make changes or
# additions to the list of Approved Interfaces. You must obey the GNU General
# Public License in all respects for all of the Program code and other code used
# in conjunction with the Program except the Non-GPL Code covered by this
# exception. If you modify this file, you may extend this exception to your
# version of the file, but you are not obligated to do so. If you do not wish to
# provide this exception without modification, you must delete this exception
# statement from your version and license this file solely under the GPL without
# exception.
#
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#
# cmd line parsing
use Getopt::Long;
# tempfiles
use File::Temp qw(tempfile tempdir);
# load perldap
use Mozilla::LDAP::Conn;
use Mozilla::LDAP::Utils qw(normalizeDN);
use Mozilla::LDAP::API qw(ldap_explode_dn);
use Mozilla::LDAP::LDIF;
# these are the attributes for which we will always use
# the new value, or which do not apply anymore
my %ignoreOld =
(
'nsslapd-errorlog' => 'nsslapd-errorlog',
'nsslapd-accesslog' => 'nsslapd-accesslog',
'nsslapd-auditlog' => 'nsslapd-auditlog',
'nskeyfile' => 'nsKeyfile',
'nscertfile' => 'nsCertfile',
'nsslapd-pluginpath' => 'nsslapd-pluginPath',
'nsslapd-plugintype' => 'nsslapd-pluginType',
'nsslapd-pluginversion' => 'nsslapd-pluginVersion',
'nsslapd-plugin-depends-on-named' => 'nsslapd-plugin-depends-on-named',
# these are new attrs that we should just pass through
'nsslapd-schemadir' => 'nsslapd-schemadir',
'nsslapd-lockdir' => 'nsslapd-lockdir',
'nsslapd-tmpdir' => 'nsslapd-tmpdir',
'nsslapd-certdir' => 'nsslapd-certdir',
'nsslapd-ldapifilepath' => 'nsslapd-ldapifilepath',
'nsslapd-ldapilisten' => 'nsslapd-ldapilisten',
'nsslapd-ldapiautobind' => 'nsslapd-ldapiautobind',
'nsslapd-ldapimaprootdn' => 'nsslapd-ldapimaprootdn',
'nsslapd-ldapimaptoentries' => 'nsslapd-ldapimaptoentries',
'nsslapd-ldapiuidnumbertype' => 'nsslapd-ldapiuidnumbertype',
'nsslapd-ldapigidnumbertype' => 'nsslapd-ldapigidnumbertype',
'nsslapd-ldapientrysearchbase' => 'nsslapd-ldapientrysearchbase',
'nsslapd-ldapiautodnsuffix' => 'nsslapd-ldapiautodnsuffix'
);
# these are the attributes for which we will always use
# the old value
my %alwaysUseOld =
(
'aci' => 'aci'
);
# global vars used throughout script + subs
my $pkgname = "@package_name@";
# this is the new pkgname which may be something like
# fedora-ds-base - we have to strip off the -suffix
if ($pkgname =~ /-(core|base)$/) {
$pkgname =~ s/-(core|base)$//;
}
my $oldpkgname = $pkgname;
my $oldsroot = "/opt/$oldpkgname";
# figure out the current bdb version
my $db_version=`db_verify -V`;
my ($db_major_version, $db_minor_version);
if ($db_version =~ /Berkeley DB (\d+)\.(\d+)/) {
$db_major_version = $1;
$db_minor_version = $2;
}
my $db_verstr = "bdb/${db_major_version}.${db_minor_version}/libback-ldbm";
my $debuglevel = 0;
# use like this:
# debug(3, "message");
# this will only print "message" if $debuglevel is 3 or higher (-vvv on the command line)
sub debug {
my ($level, @rest) = @_;
if ($level <= $debuglevel) {
print STDERR "+" x $level, @rest;
}
}
sub getNewDbDir {
my ($ent, $attr, $inst) = @_;
my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
my $cn = $ent->getValues('cn');
my $newval;
if ($objclasses{nsbackendinstance}) {
$newval = "@localstatedir@/lib/$pkgname/$inst/db/$cn";
} elsif (lc $cn eq 'config') {
$newval = "@localstatedir@/lib/$pkgname/$inst/db";
} elsif (lc $cn eq 'changelog5') {
$newval = "@localstatedir@/lib/$pkgname/$inst/cldb";
}
debug(2, "New value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
return $newval;
}
sub migrateCredentials {
my ($ent, $attr, $inst) = @_;
my $oldval = $ent->getValues($attr);
debug(3, "Executing migratecred -o $oldsroot/$inst -n @instconfigdir@/$inst -c $oldval . . .\n");
my $newval = `migratecred -o $oldsroot/$inst -n @instconfigdir@/$inst -c $oldval`;
debug(3, "Converted old value [$oldval] to new value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
return $newval;
}
# these are attributes that we have to transform from
# the old value to the new value (e.g. a pathname)
# The key of this hash is the attribute name. The value
# is an anonymous sub which takes two arguments - the entry
# and the old value. The return value of the sub is
# the new value
my %transformAttr =
(
'nsslapd-directory' => \&getNewDbDir,
'nsslapd-db-logdirectory' => \&getNewDbDir,
'nsslapd-changelogdir' => \&getNewDbDir,
'nsds5replicacredentials' => \&migrateCredentials,
'nsmultiplexorcredentials' => \&migrateCredentials
);
#nsslapd-directory - if same as old path, convert to new, otherwise, leave it
#nsslapd-logdirectory - if same as old path, convert to new, otherwise, leave it
#nsslapd-accesslog
#nsslapd-errorlog
#nsslapd-auditlog
#nskeyfile
#nscertfile
#dn: cn=Internationalization Plugin
#nsslapd-pluginArg0: $inst/config/slapd-collations.conf
#dn: cn=referential integrity postoperation
#nsslapd-pluginarg1: $inst/logs/referint
# don't forget changelogdb and certmap.conf
# [General]
# FullMachineName= localhost.localdomain
# SuiteSpotUserID= nobody
# ServerRoot= /usr/lib64/fedora-ds
# [slapd]
# ServerPort= 1100
# ServerIdentifier= localhost
# Suffix= dc=example,dc=com
# RootDN= cn=Directory Manager
# RootDNPwd= Secret123
sub createInfFileFromDseLdif {
my $oldroot = shift;
my $inst = shift;
my $fname = "$oldroot/$inst/config/dse.ldif";
my $id;
($id = $inst) =~ s/^slapd-//;
open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
my ($outfh, $inffile) = tempfile(SUFFIX => '.inf');
my $in = new Mozilla::LDAP::LDIF(*DSELDIF) ;
while ($ent = readOneEntry $in) {
my $dn = $ent->getDN();
if ($dn =~ /cn=config/) {
print $outfh "[General]\n";
print $outfh "FullMachineName = ", $ent->getValues('nsslapd-localhost'), "\n";
print $outfh "SuiteSpotUserID = ", $ent->getValues('nsslapd-localuser'), "\n";
print $outfh "ServerRoot = @serverdir@\n";
print $outfh "[slapd]\n";
print $outfh "RootDN = ", $ent->getValues('nsslapd-rootdn'), "\n";
print $outfh "RootDNPwd = ", $ent->getValues('nsslapd-rootpw'), "\n";
print $outfh "ServerPort = ", $ent->getValues('nsslapd-port'), "\n";
print $outfh "ServerIdentifier = $id\n";
print $outfh "Suffix = o=deleteAfterMigration\n";
print $outfh "start_server= 0\n";
last;
}
}
close $outfh;
close DSELDIF;
return $inffile;
}
sub makeNewInst {
my ($ds_newinst, $inffile) = @_;
system ($ds_newinst, $inffile) == 0 or
die "Could not create new instance using $ds_newinst with inffile $inffile: $?";
}
sub copyDatabaseDirs {
my $srcdir = shift;
my $destdir = shift;
if (-d $srcdir && ! -d $destdir) {
debug(0, "Copying database directory $srcdir to $destdir\n");
system ("cp -p -r $srcdir $destdir") == 0 or
die "Could not copy database directory $srcdir to $destdir: $?";
} elsif (! -d $srcdir) {
die "Error: database directory $srcdir does not exist";
} else {
debug(0, "The destination directory $destdir already exists, copying files/dirs individually\n");
foreach my $file (glob("$srcdir/*")) {
debug(3, "Copying $file to $destdir\n");
if (-f $file) {
system ("cp -p $file $destdir") == 0 or
die "Error: could not copy $file to $destdir: $!";
} elsif (-d $file) {
system ("cp -p -r $file $destdir") == 0 or
die "Error: could not copy $file to $destdir: $!";
}
}
}
}
sub copyDatabases {
my $oldroot = shift;
my $inst = shift;
my $newdbdir = shift;
# global config and instance specific config are children of this entry
my $basedbdn = normalizeDN("cn=ldbm database,cn=plugins,cn=config");
# get the list of databases, their index and transaction log locations
my $fname = "$oldroot/$inst/config/dse.ldif";
open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
my $in = new Mozilla::LDAP::LDIF(*DSELDIF);
my $targetdn = normalizeDN("cn=config,cn=ldbm database,cn=plugins,cn=config");
while ($ent = readOneEntry $in) {
next if (!$ent->getDN()); # just skip root dse
# look for the one level children of $basedbdn
my @rdns = ldap_explode_dn($ent->getDN(), 0);
my $parentdn = normalizeDN(join(',', @rdns[1..$#rdns]));
if ($parentdn eq $basedbdn) {
my $cn = $ent->getValues('cn');
my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
if ($cn eq 'config') { # global config
debug(1, "Found ldbm database plugin config entry ", $ent->getDN(), "\n");
my $dir = $ent->getValues('nsslapd-directory');
my $homedir = $ent->getValues('nsslapd-db-home-directory');
my $logdir = $ent->getValues('nsslapd-db-logdirectory');
debug(1, "old db dir = $dir homedir = $homedir logdir = $logdir\n");
my $srcdir = $homedir || $dir || "$oldroot/$inst/db";
copyDatabaseDirs($srcdir, $newdbdir);
copyDatabaseDirs($logdir, $newdbdir) if ($logdir && $logdir ne $srcdir);
} elsif ($objclasses{nsbackendinstance}) {
debug(1, "Found ldbm database instance entry ", $ent->getDN(), "\n");
my $dir = $ent->getValues('nsslapd-directory');
# the default db instance directory is
# $oldroot/$inst/$cn
debug(1, "old instance $cn dbdir $dir\n");
my $srcdir = $dir || "$oldroot/$inst/db/$cn";
copyDatabaseDirs($srcdir, "$newdbdir/$cn");
} # else just ignore for now
}
}
close DSELDIF;
# server automagically upgrades database if needed
# upgradeDatabase($newdbdir);
# fix the DBVERSION files
# updateDBVERSION($newdbdir);
# fix guardian files
# updateDBguardian($newdbdir);
}
sub copySecurityFiles {
my $oldroot = shift;
my $inst = shift;
my $destdir = shift;
if (! -d "$oldroot/alias") {
debug(0, "Error: security file directory $oldroot/alias not found\n");
} elsif (! -d $destdir) {
debug(0, "Error: new security file directory $destdir not found\n");
} else {
debug(1, "Copying $oldroot/alias/$inst-cert8.db to $destdir/cert8.db\n");
system ("cp -p $oldroot/alias/$inst-cert8.db $destdir/cert8.db") == 0 or
die "Error: could not copy $oldroot/alias/$inst-cert8.db to $destdir/cert8.db: $!";
debug(1, "Copying $oldroot/alias/$inst-key3.db to $destdir/key3.db\n");
system ("cp -p $oldroot/alias/$inst-key3.db $destdir/key3.db") == 0 or
die "Error: could not copy $oldroot/alias/$inst-key3.db to $destdir/key3.db: $!";
debug(1, "Copying $oldroot/alias/secmod.db to $destdir/secmod.db\n");
system ("cp -p $oldroot/alias/secmod.db $destdir/secmod.db") == 0 or
die "Error: could not copy $oldroot/alias/secmod.db to $destdir/secmod.db: $!";
if (-f "$oldroot/alias/$inst-pin.txt") {
debug(1, "Copying $oldroot/alias/$inst-pin.txt to $destdir/pin.txt\n");
system ("cp -p $oldroot/alias/$inst-pin.txt $destdir/pin.txt") == 0 or
die "Error: could not copy $oldroot/alias/$inst-pin.txt to $destdir/pin.txt: $!";
}
if (-f "$oldroot/shared/config/certmap.conf") {
debug(1, "Copying $oldroot/shared/config/certmap.conf to $destdir/certmap.conf\n");
system ("cp -p $oldroot/shared/config/certmap.conf $destdir/certmap.conf") == 0 or
die "Error: could not copy $oldroot/shared/config/certmap.conf to $destdir/certmap.conf: $!";
}
}
}
sub copyChangelogDB {
my $oldroot = shift;
my $inst = shift;
my $newdbdir = shift;
# changelog config entry
my $cldn = normalizeDN("cn=changelog5, cn=config");
my $fname = "$oldroot/$inst/config/dse.ldif";
open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
my $in = new Mozilla::LDAP::LDIF(*DSELDIF);
while ($ent = readOneEntry $in) {
my $targetdn = normalizeDN($ent->getDN());
if ($targetdn eq $cldn) {
my $oldcldir = $ent->getValues('nsslapd-changelogdir');
debug(1, "old cldb dir = $oldcldir\n");
my $srcdir = $oldcldir || "$oldroot/$inst/cldb";
copyDatabaseDirs($srcdir, $newdbdir);
# server automagically upgrades database if needed
# upgradeDatabase($newdbdir);
last;
}
}
close DSELDIF;
}
sub fixAttrsInEntry {
my ($ent, $inst) = @_;
for my $attr (keys %{$ent}) {
my $lcattr = lc $attr;
if ($transformAttr{$lcattr}) {
$ent->setValues($attr, &{$transformAttr{$lcattr}}($ent, $attr, $inst));
}
}
}
sub mergeEntries {
my ($old, $new, $inst) = @_;
my %inoldonly; # attrs in old entry but not new one
my %innewonly; # attrs in new entry but not old one
my @attrs; # attrs common to old and new
# if the attribute exists in the old entry but not the new one
# we should probably add it (checking for special cases first)
# if the attribute exists in the new entry but not the old one
# we might have to delete it from the new entry
# first, get a list of all attributes
foreach my $attr (keys %{$old}) {
if (! $new->exists($attr)) {
$inoldonly{$attr} = $attr;
} else {
push @attrs, $attr;
}
}
foreach my $attr (keys %{$new}) {
if (! $old->exists($attr)) {
$innewonly{$attr} = $attr;
}
}
# iterate through the attr lists
my $cn = lc $new->getValues("cn");
foreach my $attr (keys %inoldonly, keys %innewonly, @attrs) {
my $lcattr = lc $attr;
if ($ignoreOld{$lcattr}) {
next; # use new value or just omit if attr is obsolete
} elsif ($transformAttr{$lcattr}) {
# only transform if the value is in the old entry
if (!$innewonly{$attr}) {
$new->setValues($attr, &{$transformAttr{$lcattr}}($old, $attr, $inst));
}
} elsif ($cn eq "internationalization plugin" and $lcattr eq "nsslapd-pluginarg0") {
next; # use the new value of this path name
} elsif ($cn eq "referential integrity postoperation" and $lcattr eq "nsslapd-pluginarg1") {
next; # use the new value of this path name
} elsif ($innewonly{$attr}) {
$new->remove($attr); # in new but not old - just remove it
} else {
$new->setValues($attr, $old->getValues($attr)); # use old value
}
}
}
sub mergeDseLdif {
my $oldroot = shift;
my $inst = shift;
my $ent;
# first, read in old file
my %olddse; # map of normalized DN to Entry
my @olddns; # the DNs in their original order
my $fname = "$oldroot/$inst/config/dse.ldif";
open( OLDDSELDIF, $fname ) || die "Can't open $fname: $!";
my $in = new Mozilla::LDAP::LDIF(*OLDDSELDIF);
while ($ent = readOneEntry $in) {
my $dn = normalizeDN($ent->getDN());
push @olddns, $dn;
$olddse{$dn} = $ent;
}
close OLDDSELDIF;
# next, read in new file
my %newdse; # map of normalized DN to Entry
my @newdns; # the DNs in their original order that are not in olddns
$fname = "@instconfigdir(a)/$inst/dse.ldif";
open( NEWDSELDIF, $fname ) || die "Can't open $fname: $!";
$in = new Mozilla::LDAP::LDIF(*NEWDSELDIF);
while ($ent = readOneEntry $in) {
my $dn = normalizeDN($ent->getDN());
$newdse{$dn} = $ent;
if (! exists $olddse{$dn}) {
push @newdns, $dn;
}
}
close NEWDSELDIF;
# temp file for new, merged dse.ldif
my ($dsefh, $tmpdse) = tempfile(SUFFIX => '.ldif');
# now, compare entries
# if the entry exists in the old tree but not the new, add it
# if the entry exists in the new tree but not the old, delete it
# otherwise, merge the entries
# @olddns contains the dns in the old dse.ldif, including ones that
# may also be in the new dse.ldif
# @newdns contains dns that are only in the new dse.ldif
for my $dn (@olddns, @newdns) {
my $oldent = $olddse{$dn};
my $newent = $newdse{$dn};
my $outputent;
if ($oldent && !$newent) {
# may have to fix up some values in the old entry
fixAttrsInEntry($oldent, $inst);
# output $oldent
$outputent = $oldent;
} elsif (!$oldent && $newent) {
next if ($dn =~ /o=deleteAfterMigration/i);
# output $newent
$outputent = $newent;
} else { #merge
# $newent will contain the merged entry
mergeEntries($oldent, $newent, $inst);
$outputent = $newent;
}
# special fix for rootDSE - perldap doesn't like "" for a dn
if (! $outputent->getDN()) {
my $ary = $outputent->getLDIFrecords();
shift @$ary; # remove "dn"
shift @$ary; # remove the empty dn value
print $dsefh "dn:\n";
print $dsefh (Mozilla::LDAP::LDIF::pack_LDIF (78, $ary), "\n");
} else {
Mozilla::LDAP::LDIF::put_LDIF($dsefh, 78, $outputent);
}
}
close $dsefh;
return $tmpdse;
}
sub usage {
print STDERR <<EOF;
Usage: $0 [-h] [-v....v] [-o /path/to/oldserverroot] [-i slapd-instance ... -i slapd-instanceN]
INTRODUCTION
This script will copy instances (data and configuration) from the old
server root directory to their new FHS locations. This script does a
copy only - the data in the old instances will be left untouched. The
old instances must be shutdown first to ensure that the databases are
copied safely. The new instances will not be started by migration,
but can be started after running migration by doing
service $pkgname start
WARNINGS
You will not be able to use the console or Admin Express to manage
instances that have been migrated. You will be able to use the web
applications such as the Directory Server Gateway, Directory Express,
and Org Chart.
If you have configured your main database or replication changelog
database to use separate partitions for log files and index files,
this configuration will not be migrated. All of your data
will be copied to the standard FHS location
@localstatedir@/lib/$pkgname/slapd-INSTANCE/db (or cldb).
OPTIONS
-v Increase the verbosity - you can specify this more than once
(e.g. -vvvv) for more output
-o The old server root directory (default $oldsroot)
-i Instance to migrate - by default, all instances in $oldsroot
will be migrated, but you can specify one or more if you do
not want all of them (e.g. -i slapd-inst1 -i slapd-inst2)
-h This message
EOF
exit 1;
}
#################################################################
# Main script begins here
#################################################################
my @instances; # the instances to migrate
# process command line options
Getopt::Long::Configure(qw(bundling)); # bundling allows -vvvvvv
GetOptions('verbose|v+' => \$debuglevel,
'instance|i=s' => \@instances,
'oldsroot|o=s' => \$oldsroot,
'help|h' => sub { &usage });
# get list of instances to migrate
if (! @instances) {
# an instance must be a directory called $oldsroot/slapd-something and the file
# $oldsroot/slapd-something/config/dse.ldif must exist
@instances = grep { -d && -f "$_/config/dse.ldif" && ($_ =~ s,$oldsroot/,,) } glob("$oldsroot/slapd-*");
}
die "No instances found to migrate" unless (@instances);
# find ds_newinst.pl - in same directory as this script or in PATH
my $ds_newinst;
($ds_newinst = $0) =~ s|/[^/]+$|/ds_newinst.pl|;
if (! -x $ds_newinst) {
$ds_newinst = "ds_newinst.pl"; # just get from path
}
# for each instance
foreach my $inst (@instances) {
# set instance specific defaults
my $newdbdir = "@localstatedir@/lib/$pkgname/$inst/db";
my $newcertdir = "@instconfigdir@/$inst";
my $newcldbdir = "@localstatedir@/lib/$pkgname/$inst/cldb";
# extract the information needed for ds_newinst.pl
my $inffile = createInfFileFromDseLdif($oldsroot, $inst);
debug(2, "Using inffile $inffile created from $oldsroot/$inst\n");
# create the new instance
makeNewInst($ds_newinst, $inffile);
unlink($inffile);
# copy over the files/directories
# copy the databases
copyDatabases($oldsroot, $inst, $newdbdir);
# copy the security related files
copySecurityFiles($oldsroot, $inst, $newcertdir);
# copy the repl changelog database
copyChangelogDB($oldsroot, $inst, $newcldbdir);
# merge the old info into the new dse.ldif
my $tmpdse = mergeDseLdif($oldsroot, $inst);
# get user/group of new dse
my ($dev, $ino, $mode, $uid, $gid, @rest) = stat "@instconfigdir(a)/$inst/dse.ldif";
# save the original new dse.ldif
system("cp -p @instconfigdir(a)/$inst/dse.ldif @instconfigdir(a)/$inst/dse.ldif.premigrate");
# copy the new one
system("cp $tmpdse @instconfigdir(a)/$inst/dse.ldif");
# change owner/group
chmod $mode, "@instconfigdir(a)/$inst/dse.ldif";
chown $uid, $gid, "@instconfigdir(a)/$inst/dse.ldif";
# remove the temp one
unlink($tmpdse);
}
debug(0, "\n\nDone! Migration is complete.\n");
debug(0, "You can start your new servers with: service fedora-ds start\n");
# the server automagically upgrades the databases, so these are not needed for now
# sub upgradeDatabase {
# my $newdbdir = shift;
# # now, recover the database to flush the data from the log file(s)
# # into the .db4 (index) files
# debug(0, "Recovering and flushing log files in $newdbdir . . .\n");
# my $vflag = "";
# if ($debuglevel > 2) {
# $vflag = "-v";
# }
# system("db42_recover $vflag -h $newdbdir") == 0 or
# die "Error: could not recover the db files in $newdbdir: $!";
# # then, remove the log file(s) (log.xxxxx) and the old memory region files (__db.XXX files)
# debug(0, "Removing old log and memory region files in $newdbdir . . .\n");
# system("rm -f $newdbdir/log.* $newdbdir/__db.*") == 0 or
# die "Error: could not remove log and mem region files in $newdbdir: $!";
# # finally, upgrade the index files
# debug(0, "Upgrading all database files in $newdbdir . . .\n");
# for my $dbfile (<$newdbdir/*/*.db4>) {
# debug(2, "Upgrading database file $dbfile . . .\n");
# system("db_upgrade -h $newdbdir $dbfile") == 0 or
# die "Error: could not upgrade database file $dbfile: $!";
# }
# for my $dbfile (<$newdbdir/*.db4>) {
# debug(2, "Upgrading database file $dbfile . . .\n");
# system("db_upgrade -h $newdbdir $dbfile") == 0 or
# die "Error: could not upgrade database file $dbfile: $!";
# }
# }
# sub updateDBVERSION {
# my $newdbdir = shift;
# my $fname = "$newdbdir/DBVERSION";
# my @flist = ($fname);
# push @flist, glob("$newdbdir/*/DBVERSION");
# for $fname (@flist) {
# if (-f $fname) {
# debug(2, "Updating $fname to $db_verstr\n");
# open(FNAME, ">$fname") or die "Can't write $fname: $!";
# print FNAME $db_verstr, "\n";
# close FNAME;
# } else {
# debug(0, "No $fname - skipping\n");
# }
# }
# }
# sub updateDBguardian {
# my $newdbdir = shift;
# my $fname = "$newdbdir/guardian";
# my @flist = ($fname);
# push @flist, glob("$newdbdir/*/guardian");
# for $fname (@flist) {
# if (-f $fname) {
# debug(2, "Updating $fname to $db_verstr\n");
# open(FNAME, "$fname") or die "Can't read $fname: $!";
# my @lines = <FNAME>;
# close FNAME;
# open(FNAME, ">$fname") or die "Can't write $fname: $!";
# for (@lines) {
# if (/^version:/) {
# print FNAME "version:$db_verstr\n";
# } else {
# print FNAME;
# }
# }
# close FNAME;
# } else {
# debug(0, "No $fname - skipping\n");
# }
# }
# }
17 years
[Fedora-directory-commits] ldapserver Makefile.am, 1.32, 1.33 aclocal.m4, 1.25, 1.26 configure, 1.34, 1.35 missing, 1.19, 1.20 install-sh, 1.19, 1.20 compile, 1.19, 1.20 depcomp, 1.19, 1.20 config.sub, 1.18, 1.19 config.guess, 1.18, 1.19 Makefile.in, 1.37, 1.38
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32489/ldapserver
Modified Files:
Makefile.am aclocal.m4 configure missing install-sh compile
depcomp config.sub config.guess Makefile.in
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: Makefile.am
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.am,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Makefile.am 3 Mar 2007 00:32:16 -0000 1.32
+++ Makefile.am 16 Mar 2007 21:32:38 -0000 1.33
@@ -21,7 +21,7 @@
PATH_DEFINES = -DLOCALSTATEDIR="\"$(localstatedir)\"" -DSYSCONFDIR="\"$(sysconfdir)\"" \
-DLIBDIR="\"$(libdir)\"" -DBINDIR="\"$(bindir)\"" \
-DDATADIR="\"$(datadir)\"" -DDOCDIR="\"$(docdir)\"" \
- -DSBINDIR="\"$(sbindir)\""
+ -DSBINDIR="\"$(sbindir)\"" -DPLUGINDIR="\"$(serverplugindir)\""
AM_CPPFLAGS = $(DEBUG_DEFINES) $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES)
PLUGIN_CPPFLAGS = $(AM_CPPFLAGS) @ldapsdk_inc@ @nss_inc@ @nspr_inc@
@@ -148,13 +148,14 @@
bin_SCRIPTS = $(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl \
wrappers/dbscan \
wrappers/ds_newinst \
- $(srcdir)/ldap/admin/src/ds_newinst.pl \
+ ldap/admin/src/ds_newinst.pl \
wrappers/dsktune \
wrappers/infadd \
wrappers/ldap-agent \
wrappers/ldclt \
wrappers/ldif \
$(srcdir)/ldap/admin/src/logconv.pl \
+ ldap/admin/src/migrateTo11 \
wrappers/migratecred \
wrappers/mmldif \
wrappers/pwdhash \
Index: Makefile.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.in,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- Makefile.in 3 Mar 2007 00:32:16 -0000 1.37
+++ Makefile.in 16 Mar 2007 21:32:39 -0000 1.38
@@ -981,7 +981,7 @@
PATH_DEFINES = -DLOCALSTATEDIR="\"$(localstatedir)\"" -DSYSCONFDIR="\"$(sysconfdir)\"" \
-DLIBDIR="\"$(libdir)\"" -DBINDIR="\"$(bindir)\"" \
-DDATADIR="\"$(datadir)\"" -DDOCDIR="\"$(docdir)\"" \
- -DSBINDIR="\"$(sbindir)\""
+ -DSBINDIR="\"$(sbindir)\"" -DPLUGINDIR="\"$(serverplugindir)\""
AM_CPPFLAGS = $(DEBUG_DEFINES) $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES)
PLUGIN_CPPFLAGS = $(AM_CPPFLAGS) @ldapsdk_inc@ @nss_inc@ @nspr_inc@
@@ -1064,13 +1064,14 @@
bin_SCRIPTS = $(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl \
wrappers/dbscan \
wrappers/ds_newinst \
- $(srcdir)/ldap/admin/src/ds_newinst.pl \
+ ldap/admin/src/ds_newinst.pl \
wrappers/dsktune \
wrappers/infadd \
wrappers/ldap-agent \
wrappers/ldclt \
wrappers/ldif \
$(srcdir)/ldap/admin/src/logconv.pl \
+ ldap/admin/src/migrateTo11 \
wrappers/migratecred \
wrappers/mmldif \
wrappers/pwdhash \
17 years
[Fedora-directory-commits] ldapserver/wrappers initscript.in, 1.3, 1.4
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/wrappers
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv27240
Modified Files:
initscript.in
Log Message:
Resolves: bug 232684
Description: need initscripts for Solaris
Reviewed by: nhosoi (Thanks!)
Fix Description: I was able to mostly use the linux initscript. The biggest issue was that Solaris does not support bash for init scripts, so I had to convert all of the bash-isms to just use plain old Bourne shell syntax. I removed the grep for the pids and just used kill -0, so I don't need the pids list or pidof anymore. Solaris mounts /var/run in tmpfs (i.e. memory disk) which is removed upon reboot, so we have to create and set permission on /var/run if it doesn't exist. Solaris also doesn't provide a library of useful shell functions, so I had to define success() and failure() if they don't exist.
Platforms tested: Solaris 9
Flag day: no
Doc: Yes - we will need to document the init scripts.
Index: initscript.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/wrappers/initscript.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- initscript.in 12 Feb 2007 20:10:21 -0000 1.3
+++ initscript.in 16 Mar 2007 20:29:57 -0000 1.4
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# @package_name@ This starts and stops @package_name@
#
@@ -11,24 +11,66 @@
#
# Source function library.
+if [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
+fi
# Source networking configuration.
+if [ -f /etc/sysconfig/network ] ; then
. /etc/sysconfig/network
+fi
# Check that networking is up.
-if [ ${NETWORKING} = "no" ]
+if [ "${NETWORKING}" = "no" ]
then
echo "Networking is down"
exit 0
fi
+# failure and success are not defined on some platforms
+type failure > /dev/null 2>&1 || {
+failure()
+{
+ echo " FAILED\c"
+}
+}
+
+type success > /dev/null 2>&1 || {
+success()
+{
+ echo " SUCCESS\c"
+}
+}
-exec="@sbindir@/ns-slapd"
+# On Solaris /var/run is in tmpfs and gets wiped out upon reboot
+# we have to recreate the /var/run/@package_name@ directory
+# We also have to make sure that the directory is writable
+# by the directory server process
+# the argument to this function is the server instance directory,
+# which must have a dse.ldif file in it
+fix_pid_dir_ownership()
+{
+ if [ ! -d $piddir ] ; then
+ mkdir -p $piddir
+ owner=`grep \^nsslapd-localuser $1/dse.ldif | awk '{print $2}'`
+ if [ -n "$owner" ] ; then
+ chown $owner $piddir
+ chmod 700 $piddir
+ fi
+ fi
+}
+
+baseexec="ns-slapd"
+exec="@sbindir@/$baseexec"
prog="@package_name@"
# Lockfile
-lockfile="@localstatedir@/lock/subsys/@package_name@"
+if [ -d "@localstatedir@/lock/subsys" ] ; then
+ lockfile="@localstatedir@/lock/subsys/@package_name@"
+else
+ lockfile="@localstatedir@/lock/@package_name@/lock"
+fi
# PID directory
piddir="@localstatedir@/run/@package_name@"
+
# Instance basedir
instbase="@instconfigdir@"
@@ -38,13 +80,11 @@
umask 077
-pids=$(pidof $exec)
-
INSTANCES=""
for FILE in `/bin/ls -d $instbase/slapd-* 2>/dev/null`; do
if [ -d "$FILE" ] ; then
- inst=$(echo "$FILE" | sed -e "s|$instbase/slapd-||")
+ inst=`echo "$FILE" | sed -e "s|$instbase/slapd-||"`
INSTANCES="$INSTANCES $inst"
fi
done
@@ -56,7 +96,7 @@
fi
done
if [ "$2" != "$INSTANCES" ]; then
- echo -n "$2 is an invalid @package_name@ instance"
+ echo "$2 is an invalid @package_name@ instance\c"
failure; echo
exit 1
fi
@@ -64,13 +104,14 @@
start() {
if [ -n "$INSTANCES" ]; then
- export LD_LIBRARY_PATH=@libdir@/@package_name@:@nss_libdir@
+ LD_LIBRARY_PATH=@libdir@/@package_name@:@nss_libdir@
+ export LD_LIBRARY_PATH
echo "Starting $prog: "
# Start every slapd instance that isn't already running
errors=0
successes=0
for instance in $INSTANCES; do
- echo -n " $instance..."
+ echo " $instance...\c"
# the server creates pidfile and writes the pid to it when it is fully
# started and available to serve clients
pidfile=$piddir/slapd-$instance.pid
@@ -79,15 +120,15 @@
# die a horrible death (e.g. shared lib problem, oom, etc.)
startpidfile=$piddir/slapd-$instance.startpid
server_running=0
- if [ -e $pidfile ]; then
- pid=$(cat $pidfile)
- if [ $(echo "$pids" | grep -c $pid) -ge 1 ]; then
- echo -n " already running"
+ if [ -f $pidfile ]; then
+ pid=`cat $pidfile`
+ if kill -0 $pid > /dev/null 2>&1 ; then
+ echo " already running\c"
success; echo
- let successes=successes+1
+ successes=`expr $successes + 1`
server_running=1
else
- echo -n " not running, but pid file exists - attempt to start anyway..."
+ echo " not running, but pid file exists - attempt to start anyway...\c"
rm -f $pidfile
fi
fi
@@ -95,12 +136,13 @@
if [ $server_running -eq 0 ] ; then
rm -f $pidfile
rm -f $startpidfile
+ fix_pid_dir_ownership $instbase/slapd-$instance
$exec -D $instbase/slapd-$instance -i $pidfile -w $startpidfile
if [ $? -eq 0 ]; then
server_started=1 # well, perhaps not running, but started ok
else
failure; echo
- let errors=errors+1
+ errors=`expr $errors + 1`
fi
fi
# ok, if we started the server successfully, let's see if it is really
@@ -119,7 +161,7 @@
done
if test ! -f $startpidfile ; then
failure; echo
- let errors=errors+1
+ errors=`expr $errors + 1`
server_started=0
fi
fi
@@ -144,10 +186,10 @@
done
if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
- let successes=successes+1
+ successes=`expr $successes + 1`
else
failure; echo
- let errors=errors+1
+ errors=`expr $errors + 1`
fi
fi
rm -f $startpidfile
@@ -168,17 +210,17 @@
errors=0
for instance in $INSTANCES; do
pidfile=$piddir/slapd-$instance.pid
- if [ -e $pidfile ]; then
- pid=$(cat $pidfile)
- echo -n " $instance..."
+ if [ -f $pidfile ]; then
+ pid=`cat $pidfile`
+ echo " $instance...\c"
server_stopped=0
- if [ $(echo "$pids" | grep -c $pid) -ge 1 ]; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
server_stopped=1
else
failure; echo
- let errors=errors+1
+ errors=`expr $errors + 1`
fi
fi
if [ $server_stopped -eq 1 ] ; then
@@ -198,7 +240,7 @@
done
if test -f $pidfile ; then
failure; echo
- let errors=errors+1
+ errors=`expr $errors + 1`
else
success; echo
rm -f $pidfile
@@ -207,7 +249,7 @@
fi
done
if [ $errors -ge 1 ]; then
- echo -n "*** Error: $errors instance(s) unsuccessfully stopped"
+ echo "*** Error: $errors instance(s) unsuccessfully stopped\c"
failure; echo
else
rm -f $lockfile
@@ -222,9 +264,9 @@
status() {
for instance in $INSTANCES; do
- if [ -e $piddir/slapd-$instance.pid ]; then
- pid=$(cat $piddir/slapd-$instance.pid)
- if [ $(echo "$pids" | grep -c $pid) -ge 1 ]; then
+ if [ -f $piddir/slapd-$instance.pid ]; then
+ pid=`cat $piddir/slapd-$instance.pid`
+ if kill -0 $pid > /dev/null 2>&1 ; then
echo "$prog $instance (pid $pid) is running..."
else
echo "$prog $instance dead but pid file exists"
@@ -244,6 +286,7 @@
[ ! -f $lockfile ] || restart
;;
*)
- echo $"Usage: $0 {start|stop|status|restart|condrestart} [instance-name]"
+ echo Unknown command $1
+ echo "Usage: $0 {start|stop|status|restart|condrestart} [instance-name]"
exit 2
esac
17 years
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication cl5_api.c, 1.13, 1.14 cl5_api.h, 1.6, 1.7 repl_shared.h, 1.6, 1.7
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11001
Modified Files:
cl5_api.c cl5_api.h repl_shared.h
Log Message:
Resolves: 232050
Summary: Change format of DBVERSION and guardian files (Comment #6)
1) introduced new strings for DBVERSION
2) added the logic to compare the new DBVERSION strings
note: we don't store the current db version string in the replication
code any more. Instead, we get it from Berkeley DB header file db.h.
Index: cl5_api.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- cl5_api.c 12 Feb 2007 21:13:07 -0000 1.13
+++ cl5_api.c 15 Mar 2007 21:40:34 -0000 1.14
@@ -62,8 +62,6 @@
#include "cl5_clcache.h" /* To use the Changelog Cache */
#include "repl5.h" /* for agmt_get_consumer_rid() */
-#define CL5_TYPE "Changelog5" /* changelog type */
-#define VERSION_SIZE 127 /* size of the buffer to hold changelog version */
#define GUARDIAN_FILE "guardian" /* name of the guardian file */
#define VERSION_FILE "DBVERSION" /* name of the version file */
#define MAX_TRIALS 50 /* number of retries on db operations */
@@ -287,7 +285,7 @@
static void _cl5SetDBConfig (const CL5DBConfig *config);
static void _cl5InitDBEnv(DB_ENV *dbEnv);
static int _cl5CheckDBVersion ();
-static int _cl5ReadDBVersion (const char *dir, char *clVersion);
+static int _cl5ReadDBVersion (const char *dir, char *clVersion, int buflen);
static int _cl5WriteDBVersion ();
static int _cl5CheckGuardian ();
static int _cl5ReadGuardian (char *buff);
@@ -2214,6 +2212,52 @@
return CL5_SUCCESS;
}
+static int _cl5RemoveLogs ()
+{
+ int rc = CL5_DB_ERROR;
+ char filename1[MAXPATHLEN];
+ PRDir *dirhandle = NULL;
+ dirhandle = PR_OpenDir(s_cl5Desc.dbDir);
+ if (NULL != dirhandle) {
+ PRDirEntry *direntry = NULL;
+ int pre = 0;
+ PRFileInfo info;
+
+ while (NULL != (direntry =
+ PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT)))
+ {
+ if (NULL == direntry->name) {
+ /* NSPR doesn't behave like the docs say it should */
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5RemoveLogs: PR_ReadDir failed (%d): %s\n",
+ PR_GetError(),slapd_pr_strerror(PR_GetError()));
+ break;
+ }
+ PR_snprintf(filename1, MAXPATHLEN,
+ "%s/%s", s_cl5Desc.dbDir, direntry->name);
+ pre = PR_GetFileInfo(filename1, &info);
+ if (pre == PR_SUCCESS && PR_FILE_DIRECTORY == info.type) {
+ continue;
+ }
+ if (0 == strncmp(direntry->name, "log.", 4))
+ {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "Deleting log file: (%s)\n", filename1);
+ unlink(filename1);
+ }
+ rc = CL5_SUCCESS;
+ }
+ PR_CloseDir(dirhandle);
+ }
+ else if (PR_FILE_NOT_FOUND_ERROR != PR_GetError())
+ {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "_cl5RemoveLogs:: PR_OpenDir(%s) failed (%d): %s\n",
+ s_cl5Desc.dbDir, PR_GetError(),slapd_pr_strerror(PR_GetError()));
+ }
+ return rc;
+}
+
static int _cl5AppInit (PRBool *didRecovery)
{
int rc;
@@ -2286,7 +2330,10 @@
if ((flags & DB_RECOVER) || (flags & DB_RECOVER_FATAL))
{
if (CL5_OPEN_CLEAN_RECOVER == s_cl5Desc.dbOpenMode)
+ {
_cl5RemoveEnv();
+ _cl5RemoveLogs();
+ }
rc = _cl5Recover (flags, dbEnv);
if (rc != CL5_SUCCESS)
@@ -3219,7 +3266,8 @@
/* upgrade from db33 to db41
* 1. Run recovery on the database environment using the DB_ENV->open method
* 2. Remove any Berkeley DB environment using the DB_ENV->remove method
- * 3. extention .db3 -> .db4 ### koko kara !!!
+ * 3. Remove any Berkeley DB transaction log files
+ * 4. extention .db3 -> .db4
*/
static int _cl5Upgrade3_4(char *fromVersion, char *toVersion)
{
@@ -3239,6 +3287,7 @@
"_cl5Upgrade3_4: failed to open the db env\n");
return rc;
}
+ s_cl5Desc.dbOpenMode = backup;
dir = PR_OpenDir(s_cl5Desc.dbDir);
if (dir == NULL)
@@ -3317,6 +3366,48 @@
return rc;
}
+/* upgrade from db41 -> db42 -> db43 -> db44 -> db45
+ * 1. Run recovery on the database environment using the DB_ENV->open method
+ * 2. Remove any Berkeley DB environment using the DB_ENV->remove method
+ * 3. Remove any Berkeley DB transaction log files
+ */
+static int _cl5Upgrade4_4(char *fromVersion, char *toVersion)
+{
+ PRDirEntry *entry = NULL;
+ DB *thisdb = NULL;
+ CL5OpenMode backup;
+ int rc = 0;
+
+ backup = s_cl5Desc.dbOpenMode;
+ s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
+ /* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
+ rc = _cl5AppInit (NULL);
+ if (rc != CL5_SUCCESS)
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5Upgrade4_4: failed to open the db env\n");
+ return rc;
+ }
+ s_cl5Desc.dbOpenMode = backup;
+
+ /* update the version file */
+ _cl5WriteDBVersion ();
+
+ /* update the guardian file */
+ _cl5WriteGuardian ();
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "Upgrading from %s to %s is successfully done (%s)\n",
+ fromVersion, toVersion, s_cl5Desc.dbDir);
+
+ if (s_cl5Desc.dbEnv)
+ {
+ DB_ENV *dbEnv = s_cl5Desc.dbEnv;
+ dbEnv->close(dbEnv, 0);
+ s_cl5Desc.dbEnv = NULL;
+ }
+ return rc;
+}
+
static int _cl5CheckDBVersion ()
{
char clVersion [VERSION_SIZE + 1];
@@ -3332,48 +3423,87 @@
}
}
else
- {
- PR_snprintf (clVersion, VERSION_SIZE, "%s/%s/%s", CL5_TYPE, REPL_PLUGIN_NAME,
- CHANGELOG_DB_VERSION);
- rc = _cl5ReadDBVersion (s_cl5Desc.dbDir, dbVersion);
+ {
+ char *versionp = NULL;
+ char *versionendp = NULL;
+ char *dotp = NULL;
+ int dbmajor = 0;
+ int dbminor = 0;
+
+ PR_snprintf (clVersion, VERSION_SIZE, "%s/%d.%d/%s",
+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN);
+
+ rc = _cl5ReadDBVersion (s_cl5Desc.dbDir, dbVersion, sizeof(dbVersion));
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
"_cl5CheckDBVersion: invalid dbversion\n");
rc = CL5_BAD_DBVERSION;
+ goto bailout;
+ }
+ versionendp = dbVersion + strlen(dbVersion);
+ /* get the version number */
+ /* old DBVERSION string: CL5_TYPE/REPL_PLUGIN_NAME/#.# */
+ if (PL_strncmp(dbVersion, CL5_TYPE, strlen(CL5_TYPE)) == 0)
+ {
+ versionp = strrchr(dbVersion, '/');
+ }
+ /* new DBVERSION string: bdb/#.#/libreplication-plugin */
+ else if (PL_strncmp(dbVersion, BDB_IMPL, strlen(BDB_IMPL)) == 0)
+ {
+ versionp = strchr(dbVersion, '/');
+ }
+ if (NULL == versionp || versionp == versionendp)
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5CheckDBVersion: invalid dbversion: %s\n", dbVersion);
+ rc = CL5_BAD_DBVERSION;
+ goto bailout;
+ }
+ dotp = strchr(++versionp, '.');
+ if (NULL != dotp)
+ {
+ *dotp = '\0';
+ dbmajor = strtol(versionp, (char **)NULL, 10);
+ dbminor = strtol(++dotp, (char **)NULL, 10);
+ *dotp = '.';
+ }
+ else
+ {
+ dbmajor = strtol(versionp, (char **)NULL, 10);
}
- else if (strcasecmp (clVersion, dbVersion) != 0)
+
+ if (dbmajor < DB_VERSION_MAJOR)
{
- char prevClVersion [VERSION_SIZE + 1];
- PR_snprintf (prevClVersion, VERSION_SIZE, "%s/%s/%s",
- CL5_TYPE, REPL_PLUGIN_NAME, CHANGELOG_DB_VERSION_PREV);
- if (strcasecmp (prevClVersion, dbVersion) == 0)
+ /* upgrade */
+ rc = _cl5Upgrade3_4(dbVersion, clVersion);
+ if (rc != CL5_SUCCESS)
{
- /* upgrade */
- rc = _cl5Upgrade3_4(prevClVersion, clVersion);
- if (rc != CL5_SUCCESS)
- {
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
"_cl5CheckDBVersion: upgrade %s -> %s failed\n",
- CHANGELOG_DB_VERSION_PREV, CHANGELOG_DB_VERSION);
- rc = CL5_BAD_DBVERSION;
- }
+ dbVersion, clVersion);
+ rc = CL5_BAD_DBVERSION;
}
- else
+ }
+ else if (dbminor < DB_VERSION_MINOR)
+ {
+ /* minor upgrade */
+ rc = _cl5Upgrade4_4(dbVersion, clVersion);
+ if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5CheckDBVersion: invalid dbversion\n");
+ "_cl5CheckDBVersion: upgrade %s -> %s failed\n",
+ dbVersion, clVersion);
rc = CL5_BAD_DBVERSION;
}
}
-
}
-
+bailout:
return rc;
}
-static int _cl5ReadDBVersion (const char *dir, char *clVersion)
+static int _cl5ReadDBVersion (const char *dir, char *clVersion, int buflen)
{
int rc;
PRFileDesc *file;
@@ -3416,7 +3546,7 @@
{
if (clVersion)
{
- strcpy(clVersion, tok);
+ PL_strncpyz(clVersion, tok, buflen);
}
}
@@ -3442,7 +3572,8 @@
PR_snprintf (fName, MAXPATHLEN, "%s/%s", s_cl5Desc.dbDir, VERSION_FILE);
- file = PR_Open (fName, PR_WRONLY | PR_CREATE_FILE, s_cl5Desc.dbConfig.fileMode);
+ file = PR_Open (fName, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
+ s_cl5Desc.dbConfig.fileMode);
if (file == NULL)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -3452,10 +3583,10 @@
}
/* write changelog version */
- PR_snprintf (clVersion, VERSION_SIZE, "%s/%s/%s\n", CL5_TYPE, REPL_PLUGIN_NAME,
- CHANGELOG_DB_VERSION);
+ PR_snprintf (clVersion, VERSION_SIZE, "%s/%d.%d/%s\n",
+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN);
- len = strlen (clVersion);
+ len = strlen(clVersion);
size = slapi_write_buffer (file, clVersion, len);
if (size != len)
{
@@ -3492,15 +3623,26 @@
}
else
{
- PR_snprintf (plVersion, VERSION_SIZE, "%s/%s/%s", CL5_TYPE, REPL_PLUGIN_NAME,
- CHANGELOG_DB_VERSION);
+ PR_snprintf (plVersion, VERSION_SIZE, "%s/%d.%d/%s\n",
+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN);
rc = _cl5ReadGuardian (dbVersion);
if (rc != CL5_SUCCESS || strcasecmp (plVersion, dbVersion) != 0)
{
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
- "_cl5CheckGuardian: missing or invalid guardian file\n");
- return (CL5_BAD_FORMAT);
+ PR_snprintf (plVersion, VERSION_SIZE, "%s/%s/%s",
+ CL5_TYPE, REPL_PLUGIN_NAME, CHANGELOG_DB_VERSION);
+ if (strcasecmp (plVersion, dbVersion) != 0)
+ {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "_cl5CheckGuardian: found old style of guardian file: %s\n",
+ dbVersion);
+ }
+ else
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5CheckGuardian: missing or invalid guardian file\n");
+ return (CL5_BAD_FORMAT);
+ }
}
/* remove guardian file */
@@ -3534,8 +3676,8 @@
return CL5_SYSTEM_ERROR;
}
- PR_snprintf (version, VERSION_SIZE, "%s/%s/%s\n", CL5_TYPE, REPL_PLUGIN_NAME,
- CHANGELOG_DB_VERSION);
+ PR_snprintf (version, VERSION_SIZE, "%s/%d.%d/%s\n",
+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_REPLPLUGIN);
len = strlen (version);
size = slapi_write_buffer (file, version, len);
Index: cl5_api.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- cl5_api.h 10 Nov 2006 23:45:17 -0000 1.6
+++ cl5_api.h 15 Mar 2007 21:40:34 -0000 1.7
@@ -48,6 +48,10 @@
#include "repl5.h"
#include "repl5_prot_private.h"
+#define BDB_IMPL "bdb" /* changelog type */
+#define BDB_REPLPLUGIN "libreplication-plugin" /* This backend plugin */
+
+
#define CL5_TYPE "Changelog5" /* changelog type */
#define VERSION_SIZE 127 /* size of the buffer to hold changelog version */
#define CL5_DEFAULT_CONFIG -1 /* value that indicates to changelog to use default */
Index: repl_shared.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_shared.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- repl_shared.h 10 Nov 2006 23:45:17 -0000 1.6
+++ repl_shared.h 15 Mar 2007 21:40:34 -0000 1.7
@@ -128,11 +128,8 @@
* a different version for the plugin itself and this particular version is only
* used for the changelog database
*/
-/*
- * Changed version from 2.0 to 3.0 when we switched from libdb33 to libdb41
- * noriko 20021203
- */
-#define CHANGELOG_DB_VERSION_PREV "3.0"
+/* the current CHANGELOG_DB_VERSION: DB_VERSION_MAJOR"."DB_VERSION_MINOR" */
+/* this string is left for the backward compatibility */
#define CHANGELOG_DB_VERSION "4.0"
extern char *repl_plugin_name;
extern char *windows_repl_plugin_name;
17 years
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm back-ldbm.h, 1.8, 1.9 dblayer.c, 1.17, 1.18 dbversion.c, 1.7, 1.8 ldbm_config.c, 1.10, 1.11 proto-back-ldbm.h, 1.10, 1.11 start.c, 1.6, 1.7 upgrade.c, 1.6, 1.7
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10655
Modified Files:
back-ldbm.h dblayer.c dbversion.c ldbm_config.c
proto-back-ldbm.h start.c upgrade.c
Log Message:
Resolves: 232050
Summary: Change format of DBVERSION and guardian files (Comment #4)
1) introduced new strings for DBVERSION
2) added the logic to compare the new DBVERSION strings
note: we don't store the current db version string in the backend source
code any more. Instead, we get it from Berkeley DB header file db.h.
Index: back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/back-ldbm.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- back-ldbm.h 10 Nov 2006 23:45:39 -0000 1.8
+++ back-ldbm.h 15 Mar 2007 21:34:32 -0000 1.9
@@ -134,26 +134,29 @@
#define LDBM_VERSION_MAXBUF 64
#define LDBM_DATABASE_TYPE_NAME "ldbm database"
/*
+ * 232050: Change format of DBVERSION and guardian files
+ * new format:
+ * implementation/version/server backend plugin name[/other tag][/other tag]....
+ * For example:
+ * bdb/4.2/libback-ldbm/newidl
+ * This indicates that the files use Berkeley DB version 4.2, they are used
+ * by the server libback-ldbm database plugin, and the index files use the
+ * newidl format.
+ * Starting from DS7.2
+ */
+#define BDB_IMPL "bdb"
+#define BDB_BACKEND "libback-ldbm" /* This backend plugin */
+
+/*
* While we support both new and old idl index,
* we distinguish them by the following 2 macros.
* When we drop the old idl code, we eliminate LDBM_VERSION_OLD.
* bug #604922
*/
-/* To set new idl default, uncomment it. */
-#define USE_NEW_IDL 1
-
#define LDBM_VERSION_BASE "Netscape-ldbm/"
#define LDBM_VERSION "Netscape-ldbm/7.0" /* db42: new idl -> old */
#define LDBM_VERSION_NEW "Netscape-ldbm/7.0_NEW" /* db42: new idl */
- /* used only when
- * USE_NEW_IDL is
- * NOT defined
- */
#define LDBM_VERSION_OLD "Netscape-ldbm/7.0_CLASSIC" /* db42: old idl */
- /* used only when
- * USE_NEW_IDL is
- * defined
- */
#define LDBM_VERSION_62 "Netscape-ldbm/6.2" /* db33: new idl */
#define LDBM_VERSION_61 "Netscape-ldbm/6.1" /* db33: new idl */
#define LDBM_VERSION_60 "Netscape-ldbm/6.0" /* db33: old idl */
@@ -364,7 +367,7 @@
void *ai_plugin;
char **ai_index_rules; /* matching rule OIDs */
void *ai_dblayer; /* private data used by the dblayer code */
- PRInt32 ai_dblayer_count; /* used by the dblayer code */
+ PRInt32 ai_dblayer_count; /* used by the dblayer code */
idl_private *ai_idl; /* private data used by the IDL code (eg locking the IDLs) */
attrcrypt_private *ai_attrcrypt; /* private data used by the attribute encryption code (eg is it enabled or not) */
};
@@ -380,7 +383,9 @@
typedef struct id_array Id_Array;
struct _db_upgrade_info {
- char* old_version_string;
+ char *old_version_string;
+ int old_dbversion_major;
+ int old_dbversion_minor;
int type;
int action;
};
@@ -396,8 +401,17 @@
#define DBVERSION_NO_UPGRADE 0x0
#define DBVERSION_NEED_IDL_OLD2NEW 0x100
#define DBVERSION_NEED_IDL_NEW2OLD 0x200
-#define DBVERSION_UPGRADE_3_4 0x400
-#define DBVERSION_NOT_SUPPORTED 0x800
+#define DBVERSION_UPGRADE_3_4 0x400 /* bdb 3.3 -> 4.2 */
+ /* The log file format changed;
+ * No database formats changed;
+ * db extention: .db3 -> .db4
+ */
+#define DBVERSION_UPGRADE_4_4 0x800 /* bdb 4.2 -> 4.3 -> 4.4 -> 4.5 */
+ /* The log file format changed;
+ * No database formats changed;
+ * no db extention change
+ */
+#define DBVERSION_NOT_SUPPORTED 0x10000000
#define DBVERSION_TYPE 0x1
#define DBVERSION_ACTION 0x2
Index: dblayer.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- dblayer.c 12 Feb 2007 21:13:07 -0000 1.17
+++ dblayer.c 15 Mar 2007 21:34:32 -0000 1.18
@@ -346,7 +346,7 @@
dblayer_private *priv = (dblayer_private*)li->li_dblayer_private;
DB_ENV *pEnv = priv->dblayer_env->dblayer_DB_ENV;
char *home_dir = dblayer_get_home_dir(li, NULL);
- if (home_dir)
+ if (home_dir && *home_dir)
pEnv->remove(pEnv, home_dir, DB_FORCE);
}
@@ -815,18 +815,18 @@
#ifdef LINUX
{
struct sysinfo si;
- size_t pages_per_mem_unit = 0;
- size_t mem_units_per_page = 0; /* We don't know if these units are really pages */
+ size_t pages_per_mem_unit = 0;
+ size_t mem_units_per_page = 0; /* We don't know if these units are really pages */
sysinfo(&si);
*pagesize = getpagesize();
- if (si.mem_unit > *pagesize) {
- pages_per_mem_unit = si.mem_unit / *pagesize;
- *pages = si.totalram * pages_per_mem_unit;
- } else {
- mem_units_per_page = *pagesize / si.mem_unit;
- *pages = si.totalram / mem_units_per_page;
- }
+ if (si.mem_unit > *pagesize) {
+ pages_per_mem_unit = si.mem_unit / *pagesize;
+ *pages = si.totalram * pages_per_mem_unit;
+ } else {
+ mem_units_per_page = *pagesize / si.mem_unit;
+ *pages = si.totalram / mem_units_per_page;
+ }
*availpages = dblayer_getvirtualmemsize() / *pagesize;
/* okay i take that back, linux's method is more retarded here.
* hopefully linux doesn't have the FILE* problem that solaris does
@@ -861,7 +861,7 @@
if (rval < 0) /* pstat_getstatic failed */
return;
*pagesize = pst.page_size;
- *pages = pst.physical_memory;
+ *pages = pst.physical_memory;
*availpages = dblayer_getvirtualmemsize() / *pagesize;
if (procpages)
{
@@ -894,21 +894,21 @@
}
}
#endif
- /* If this is a 32-bit build, it might be running on a 64-bit machine,
- * in which case, if the box has tons of ram, we can end up telling
- * the auto cache code to use more memory than the process can address.
- * so we cap the number returned here.
- */
+ /* If this is a 32-bit build, it might be running on a 64-bit machine,
+ * in which case, if the box has tons of ram, we can end up telling
+ * the auto cache code to use more memory than the process can address.
+ * so we cap the number returned here.
+ */
#if defined(__LP64__) || defined (_LP64)
#else
- {
- size_t one_gig_pages = GIGABYTE / *pagesize;
- if (*pages > (2 * one_gig_pages) ) {
- LDAPDebug(LDAP_DEBUG_TRACE,"More than 2Gbytes physical memory detected. Since this is a 32-bit process, truncating memory size used for auto cache calculations to 2Gbytes\n",
- 0, 0, 0);
- *pages = (2 * one_gig_pages);
- }
- }
+ {
+ size_t one_gig_pages = GIGABYTE / *pagesize;
+ if (*pages > (2 * one_gig_pages) ) {
+ LDAPDebug(LDAP_DEBUG_TRACE,"More than 2Gbytes physical memory detected. Since this is a 32-bit process, truncating memory size used for auto cache calculations to 2Gbytes\n",
+ 0, 0, 0);
+ *pages = (2 * one_gig_pages);
+ }
+ }
#endif
}
@@ -921,21 +921,21 @@
dblayer_sys_pages(&pagesize, &pages, &procpages, &availpages);
if (!pagesize || !pages)
return 1; /* do nothing when we can't get the avail mem */
- /* If the requested cache size is larger than the remaining pysical memory
- * after the current working set size for this process has been subtracted,
- * then we say that's insane and try to correct.
- */
+ /* If the requested cache size is larger than the remaining pysical memory
+ * after the current working set size for this process has been subtracted,
+ * then we say that's insane and try to correct.
+ */
issane = (int)(*cachesize / pagesize) <= (pages - procpages);
if (!issane) {
- *cachesize = (size_t)((pages - procpages) * pagesize);
- }
- /* We now compensate for DB's own compensation for metadata size
- * They increase the actual cache size by 25%, but only for sizes
- * less than 500Meg.
- */
- if (*cachesize < 500*MEGABYTE) {
- *cachesize = (size_t)((double)*cachesize * (double)0.8);
- }
+ *cachesize = (size_t)((pages - procpages) * pagesize);
+ }
+ /* We now compensate for DB's own compensation for metadata size
+ * They increase the actual cache size by 25%, but only for sizes
+ * less than 500Meg.
+ */
+ if (*cachesize < 500*MEGABYTE) {
+ *cachesize = (size_t)((double)*cachesize * (double)0.8);
+ }
return issane;
}
@@ -1153,7 +1153,8 @@
}
home_dir = dblayer_get_home_dir(li, NULL);
/* user specified db home */
- if (!charray_utf8_inlist(priv->dblayer_data_directories, home_dir))
+ if (home_dir && *home_dir &&
+ !charray_utf8_inlist(priv->dblayer_data_directories, home_dir))
{
charray_add(&(priv->dblayer_data_directories), home_dir);
}
@@ -1206,6 +1207,10 @@
else
{
parent_dir = dblayer_get_home_dir(li, NULL);
+ if (!parent_dir || !*parent_dir) {
+ buf = NULL;
+ return buf;
+ }
mylen = strlen(parent_dir);
inst->inst_parent_dir_name = slapi_ch_strdup(parent_dir);
}
@@ -1382,6 +1387,7 @@
log_dir = priv->dblayer_log_directory; /* nsslapd-db-logdirectory */
if (log_dir && *log_dir) {
+ /* checking the user defined log dir's accessability */
return_value = dblayer_grok_directory(log_dir,
DBLAYER_DIRECTORY_READWRITE_ACCESS);
if (0 != return_value) {
@@ -1391,6 +1397,11 @@
return return_value;
}
}
+ else
+ {
+ /* using the home dir for the log dir, which is already checked */
+ log_dir = dblayer_get_home_dir(li, NULL);
+ }
/* Sanity check on cache size on platforms which allow us to figure out
* the available phys mem */
@@ -1525,6 +1536,15 @@
dblayer_strerror(return_value), 0);
return return_value;
}
+ /* remove transaction logs */
+ return_value = dblayer_delete_transaction_logs(log_dir);
+ if (return_value)
+ {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "dblayer_start: failed to remove old transaction logs (%d)\n",
+ return_value, 0, 0);
+ return return_value;
+ }
dbmode = DBLAYER_NORMAL_MODE;
if ((return_value = dblayer_make_env(&pEnv, li)) != 0)
@@ -1687,22 +1707,22 @@
if (pagesize) {
char s[32]; /* big enough to hold %ld */
int import_pages;
- int pages_limit = (200 * 1024) / (pagesize/1024);
+ int pages_limit = (200 * 1024) / (pagesize/1024);
import_pages = (li->li_import_cache_autosize * pages) / 125;
- /* We don't want to go wild with memory when auto-sizing, cap the
- * cache size at 200 Megs to try to avoid situations where we
- * attempt to allocate more memory than there is free page pool for, or
- * where there's some system limit on the size of process memory
- */
- if (import_pages > pages_limit) {
- import_pages = pages_limit;
- }
+ /* We don't want to go wild with memory when auto-sizing, cap the
+ * cache size at 200 Megs to try to avoid situations where we
+ * attempt to allocate more memory than there is free page pool for, or
+ * where there's some system limit on the size of process memory
+ */
+ if (import_pages > pages_limit) {
+ import_pages = pages_limit;
+ }
LDAPDebug(LDAP_DEBUG_ANY, "cache autosizing: import cache: %dk \n",
import_pages*(pagesize/1024), NULL, NULL);
LDAPDebug(LDAP_DEBUG_ANY,
"li_import_cache_autosize: %d, import_pages: %d, pagesize: %d\n",
li->li_import_cache_autosize, import_pages,
- pagesize);
+ pagesize);
sprintf(s, "%lu", (unsigned long)(import_pages * pagesize));
ldbm_config_internal_set(li, CONFIG_IMPORT_CACHESIZE, s);
@@ -1742,7 +1762,7 @@
return 0;
}
- attrcrypt_init(inst);
+ attrcrypt_init(inst);
/* Get the name of the directory that holds index files
* for this instance. */
@@ -1753,8 +1773,14 @@
}
inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
- return_value = dblayer_grok_directory(inst_dirp,
+ if (inst_dirp && *inst_dirp) {
+ return_value = dblayer_grok_directory(inst_dirp,
DBLAYER_DIRECTORY_READWRITE_ACCESS);
+ } else {
+ LDAPDebug(LDAP_DEBUG_ANY,"Can't start because the database instance "
+ "directory is NULL\n", 0, 0, 0);
+ goto errout;
+ }
if (0 != return_value) {
LDAPDebug(LDAP_DEBUG_ANY,"Can't start because the database instance "
"directory \"%s\" either doesn't exist, "
@@ -1770,18 +1796,20 @@
/* Read the dbversion file if there is one, and create it
* if it doesn't exist. */
if (dbversion_exists(li, inst_dirp)) {
- char ldbmversion[LDBM_VERSION_MAXBUF];
- char dataversion[LDBM_VERSION_MAXBUF];
+ char *ldbmversion = NULL;
+ char *dataversion = NULL;
- if (dbversion_read(li, inst_dirp, ldbmversion, dataversion) != 0) {
+ if (dbversion_read(li, inst_dirp, &ldbmversion, &dataversion) != 0) {
LDAPDebug(LDAP_DEBUG_ANY, "Warning: Unable to read dbversion "
"file in %s\n", inst->inst_dir_name, 0, 0);
} else {
int rval = 0;
/* check the DBVERSION and reset idl-switch if needed (DS6.2) */
/* from the next major rel, we won't do this and just upgrade */
- if (!(li->li_flags & LI_FORCE_MOD_CONFIG))
+ if (!(li->li_flags & LI_FORCE_MOD_CONFIG)) {
adjust_idl_switch(ldbmversion, li);
+ }
+ slapi_ch_free_string(&ldbmversion);
/* check to make sure these instance was made with the correct
* version. */
@@ -1810,8 +1838,10 @@
}
/* record the dataversion */
- if (dataversion[0] != '\0') {
- inst->inst_dataversion = slapi_ch_strdup(dataversion);
+ if (dataversion != NULL && *dataversion != '\0') {
+ inst->inst_dataversion = dataversion;
+ } else {
+ slapi_ch_free_string(&dataversion);
}
rval = ldbm_upgrade(inst, rval);
@@ -1888,8 +1918,8 @@
cachesize = 1048576;
}
priv->dblayer_cachesize = cachesize;
- /* We always auto-calculate ncache for the import region */
- priv->dblayer_ncache = 0;
+ /* We always auto-calculate ncache for the import region */
+ priv->dblayer_ncache = 0;
/* use our own env */
return_value = dblayer_make_env(&mypEnv, li);
@@ -2026,10 +2056,10 @@
if (mode & DBLAYER_NORMAL_MODE) {
dbversion_write(li, inst_dirp, NULL);
- /* richm - not sure if need to acquire the be lock first? */
- /* need to set state back to started - set to stopped in
- dblayer_instance_close */
- be->be_state = BE_STATE_STARTED;
+ /* richm - not sure if need to acquire the be lock first? */
+ /* need to set state back to started - set to stopped in
+ dblayer_instance_close */
+ be->be_state = BE_STATE_STARTED;
}
/*
@@ -2136,8 +2166,17 @@
priv->dblayer_spin_count = 0;
inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
- priv->dblayer_home_directory =
- slapi_ch_smprintf("%s/dbenv", inst_dirp);
+ if (inst_dirp && *inst_dirp)
+ {
+ priv->dblayer_home_directory = slapi_ch_smprintf("%s/dbenv", inst_dirp);
+ }
+ else
+ {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "Instance dir is NULL: persistent id2entry is not available\n",
+ 0, 0, 0);
+ goto done;
+ }
priv->dblayer_log_directory = slapi_ch_strdup(priv->dblayer_home_directory);
prst = PR_GetFileInfo(inst_dirp, &prfinfo);
@@ -2263,7 +2302,10 @@
inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
inst_dir, MAXPATHLEN);
- envdir = slapi_ch_smprintf("%s/dbenv", inst_dirp);
+ if (inst_dirp && *inst_dirp)
+ {
+ envdir = slapi_ch_smprintf("%s/dbenv", inst_dirp);
+ }
done:
if (pDB)
@@ -2272,8 +2314,8 @@
pEnv->close(pEnv, 0);
if (envdir) {
ldbm_delete_dirs(envdir);
- slapi_ch_free_string(&envdir);
- }
+ slapi_ch_free_string(&envdir);
+ }
if (inst_dirp != inst_dir)
slapi_ch_free_string(&inst_dirp);
return 0;
@@ -2336,7 +2378,13 @@
char inst_dir[MAXPATHLEN];
char *inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
inst_dir, MAXPATHLEN);
- return_value = env->remove(env, inst_dirp, 0);
+ if (inst_dirp && *inst_dir) {
+ return_value = env->remove(env, inst_dirp, 0);
+ }
+ else
+ {
+ return_value = -1;
+ }
if (return_value == EBUSY) {
return_value = 0; /* something else is using the env so ignore */
}
@@ -2457,7 +2505,7 @@
if (return_value == 0) {
char *home_dir = dblayer_get_home_dir(li, NULL);
if (home_dir)
- return_value = env->remove(env, home_dir, 0);
+ return_value = env->remove(env, home_dir, 0);
if (0 == return_value
&& !((DBLAYER_ARCHIVE_MODE|DBLAYER_EXPORT_MODE) & dbmode)
&& !priv->dblayer_bad_stuff_happened) {
@@ -2670,6 +2718,11 @@
/* create a file with abs path, then try again */
inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
+ if (!inst_dirp || !*inst_dirp)
+ {
+ return_value = -1;
+ goto out;
+ }
abs_file_name = slapi_ch_smprintf("%s%c%s",
inst_dirp, get_sep(inst_dirp), file_name);
DB_OPEN(pENV->dblayer_openflags,
@@ -2678,7 +2731,9 @@
dbp->close(dbp, 0);
return_value = db_create(ppDB, pENV->dblayer_DB_ENV, 0);
if (0 != return_value)
+ {
goto out;
+ }
dbp = *ppDB;
slapi_ch_free_string(&abs_file_name);
@@ -2895,7 +2950,7 @@
dblayer_private *priv = (dblayer_private*) li->li_dblayer_private;
struct dblayer_private_env *pEnv = priv->dblayer_env;
ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
- dblayer_handle *handle;
+ dblayer_handle *handle = NULL;
char dbName[MAXPATHLEN];
char *dbNamep;
char *p;
@@ -2961,19 +3016,26 @@
}
}
dbNamep = dblayer_get_full_inst_dir(li, inst, dbName, MAXPATHLEN);
- dbbasenamelen = strlen(dbNamep);
- dbnamelen = dbbasenamelen + strlen(a->ai_type) + 6;
- if (dbnamelen > MAXPATHLEN)
+ if (dbNamep && *dbNamep) {
+ dbbasenamelen = strlen(dbNamep);
+ dbnamelen = dbbasenamelen + strlen(a->ai_type) + 6;
+ if (dbnamelen > MAXPATHLEN)
+ {
+ dbNamep = (char *)slapi_ch_realloc(dbNamep, dbnamelen);
+ }
+ p = dbNamep + dbbasenamelen;
+ sprintf(p, "%c%s%s",
+ get_sep(dbNamep), a->ai_type, LDBM_FILENAME_SUFFIX);
+ rc = dblayer_db_remove_ex(pEnv, dbNamep, 0, use_lock);
+ a->ai_dblayer = NULL;
+ if (dbNamep != dbName)
+ slapi_ch_free_string(&dbNamep);
+ }
+ else
{
- dbNamep = (char *)slapi_ch_realloc(dbNamep, dbnamelen);
+ rc = -1;
}
- p = dbNamep + dbbasenamelen;
- sprintf(p, "%c%s%s", get_sep(dbNamep), a->ai_type, LDBM_FILENAME_SUFFIX);
- rc = dblayer_db_remove_ex(pEnv, dbNamep, 0, use_lock);
- a->ai_dblayer = NULL;
slapi_ch_free((void **)&handle);
- if (dbNamep != dbName)
- slapi_ch_free_string(&dbNamep);
} else {
/* no handle to close */
}
@@ -3262,7 +3324,7 @@
/* sleep for a while, updating perf counters if we need to */
perfctrs_wait(1000,priv->perf_private,priv->dblayer_env->dblayer_DB_ENV);
}
-
+
DECR_THREAD_COUNT(priv);
LDAPDebug(LDAP_DEBUG_TRACE, "Leaving perf_threadmain\n", 0, 0, 0);
return 0;
@@ -3448,7 +3510,7 @@
interval = PR_MillisecondsToInterval(DBLAYER_SLEEP_INTERVAL);
home_dir = dblayer_get_home_dir(li, NULL);
- if (NULL == home_dir)
+ if (NULL == home_dir || '\0' == *home_dir)
{
LDAPDebug(LDAP_DEBUG_ANY,
"Checkpoint thread failed due to missing db home directory info\n",
@@ -3869,7 +3931,7 @@
return -1;
}
PR_snprintf(line,sizeof(line),"cachesize:%lu\nncache:%d\nversion:%d\n",
- priv->dblayer_cachesize, priv->dblayer_ncache, 3);
+ priv->dblayer_cachesize, priv->dblayer_ncache, DB_VERSION_MAJOR);
num_bytes = strlen(line);
return_value = slapi_write_buffer(prfd, line, num_bytes);
if (return_value != num_bytes)
@@ -4079,17 +4141,17 @@
if (NULL != li)
{
- if (startdb)
- {
- /* close immediately; no need to run db threads */
- rval = dblayer_start(li, DBLAYER_NORMAL_MODE|DBLAYER_NO_DBTHREADS_MODE);
- if (rval)
- {
- LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_start failed! %s (%d)\n",
- dblayer_strerror(rval), rval, 0);
- goto done;
- }
- }
+ if (startdb)
+ {
+ /* close immediately; no need to run db threads */
+ rval = dblayer_start(li, DBLAYER_NORMAL_MODE|DBLAYER_NO_DBTHREADS_MODE);
+ if (rval)
+ {
+ LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_start failed! %s (%d)\n",
+ dblayer_strerror(rval), rval, 0);
+ goto done;
+ }
+ }
priv = (dblayer_private*)li->li_dblayer_private;
if (NULL != priv)
{
@@ -4101,16 +4163,23 @@
dblayer_get_instance_data_dir(inst->inst_be);
inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
- dirhandle = PR_OpenDir(inst_dirp);
+ if (inst_dirp && *inst_dirp) {
+ dirhandle = PR_OpenDir(inst_dirp);
+ }
if (! dirhandle) {
if ( PR_GetError() == PR_FILE_NOT_FOUND_ERROR ) {
/* the directory does not exist... that's not an error */
rval = 0;
goto done;
}
- LDAPDebug(LDAP_DEBUG_ANY,
- "_dblayer_delete_instance_dir: PR_OpenDir(%s) failed (%d): %s\n",
- inst_dirp, PR_GetError(),slapd_pr_strerror(PR_GetError()));
+ if (inst_dirp && *inst_dirp) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "_dblayer_delete_instance_dir: inst_dir is NULL\n", 0, 0, 0);
+ } else {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "_dblayer_delete_instance_dir: PR_OpenDir(%s) failed (%d): %s\n",
+ inst_dirp, PR_GetError(),slapd_pr_strerror(PR_GetError()));
+ }
rval = -1;
goto done;
}
@@ -4148,15 +4217,15 @@
}
}
PR_CloseDir(dirhandle);
- if (pEnv && startdb)
- {
- rval = dblayer_close(li, DBLAYER_NORMAL_MODE);
- if (rval)
- {
- LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_close failed! %s (%d)\n",
- dblayer_strerror(rval), rval, 0);
- }
- }
+ if (pEnv && startdb)
+ {
+ rval = dblayer_close(li, DBLAYER_NORMAL_MODE);
+ if (rval)
+ {
+ LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_close failed! %s (%d)\n",
+ dblayer_strerror(rval), rval, 0);
+ }
+ }
done:
/* remove the directory itself too */
if (0 == rval)
@@ -4276,7 +4345,7 @@
{
log_dir = dblayer_get_home_dir(li, NULL);
}
- if (instance == NULL)
+ if (instance == NULL && log_dir && *log_dir)
{
ret = dblayer_delete_transaction_logs(log_dir);
if(ret) {
@@ -4565,17 +4634,25 @@
return return_value;
}
- inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
- inst_dir, MAXPATHLEN);
if (is_fullpath(src_dir))
new_src_dir = src_dir;
else
{
- int len = strlen(inst_dirp);
+ int len;
+ inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
+ inst_dir, MAXPATHLEN);
+ if (!inst_dirp || !*inst_dirp)
+ {
+ LDAPDebug(LDAP_DEBUG_ANY, "Instance dir is NULL.\n", 0, 0, 0);
+ return return_value;
+ }
+ len = strlen(inst_dirp);
sep = get_sep(inst_dirp);
if (*(inst_dirp+len-1) == sep)
sep = '\0';
new_src_dir = slapi_ch_smprintf("%s%c%s", inst_dirp, sep, src_dir);
+ if (inst_dirp != inst_dir)
+ slapi_ch_free_string(&inst_dirp);
}
dirhandle = PR_OpenDir(new_src_dir);
@@ -4619,6 +4696,10 @@
if (!is_fullpath(dest_dir))
{
prefix = dblayer_get_home_dir(li, NULL);
+ if (!prefix || !*prefix)
+ {
+ continue;
+ }
mysep = get_sep(prefix);
}
@@ -4711,7 +4792,7 @@
priv = (dblayer_private*)li->li_dblayer_private;
PR_ASSERT(NULL != priv);
home_dir = dblayer_get_home_dir(li, NULL);
- if (NULL == home_dir)
+ if (NULL == home_dir || '\0' == *home_dir)
{
LDAPDebug(LDAP_DEBUG_ANY,
"Backup failed due to missing db home directory info\n", 0, 0, 0);
@@ -4789,8 +4870,25 @@
inst = (ldbm_instance *)object_get_data(inst_obj);
inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
inst_dir, MAXPATHLEN);
- return_value = dblayer_copy_directory(li, task, inst_dirp,
- dest_dir, 0 /* backup */, &cnt, 0, 0, 0);
+ if (inst_dirp && *inst_dirp)
+ {
+ return_value = dblayer_copy_directory(li, task, inst_dirp,
+ dest_dir, 0 /* backup */, &cnt, 0, 0, 0);
+ }
+ else
+ {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: Instance dir is empty\n", 0, 0, 0);
+ if (task) {
+ slapi_task_log_notice(task,
+ "ERROR: Instance dir is empty\n");
+ }
+ if (listA) {
+ free(listA);
+ }
+ dblayer_txn_abort(li,&txn);
+ return -1;
+ }
if (return_value != 0) {
LDAPDebug(LDAP_DEBUG_ANY,
"ERROR: error copying directory (%s -> %s): err=%d\n",
@@ -5266,7 +5364,7 @@
home_dir = dblayer_get_home_dir(li, NULL);
- if (NULL == home_dir)
+ if (NULL == home_dir || '\0' == *home_dir)
{
LDAPDebug(LDAP_DEBUG_ANY,
"Restore failed due to missing db home directory info\n", 0, 0, 0);
@@ -5470,10 +5568,10 @@
/* [605024] check the DBVERSION and reset idl-switch if needed */
if (dbversion_exists(li, home_dir))
{
- char ldbmversion[LDBM_VERSION_MAXBUF];
- char dataversion[LDBM_VERSION_MAXBUF];
+ char *ldbmversion = NULL;
+ char *dataversion = NULL;
- if (dbversion_read(li, home_dir, ldbmversion, dataversion) != 0)
+ if (dbversion_read(li, home_dir, &ldbmversion, &dataversion) != 0)
{
LDAPDebug(LDAP_DEBUG_ANY, "Warning: Unable to read dbversion "
"file in %s\n", home_dir, 0, 0);
@@ -5481,11 +5579,13 @@
else
{
adjust_idl_switch(ldbmversion, li);
+ slapi_ch_free_string(&ldbmversion);
+ slapi_ch_free_string(&ldbmversion);
}
}
return_value = check_db_version(li, &action);
- if (action & DBVERSION_UPGRADE_3_4)
+ if (action & (DBVERSION_UPGRADE_3_4|DBVERSION_UPGRADE_4_4))
{
dbmode = DBLAYER_CLEAN_RECOVER_MODE;/* upgrade: remove logs & recover */
}
@@ -5586,6 +5686,9 @@
*/
full_namep = dblayer_get_full_inst_dir(inst->inst_li, inst,
full_name, MAXPATHLEN);
+ if (!full_namep || !*full_namep) {
+ return ret;
+ }
/* Does this directory already exist? */
if ((db_dir = PR_OpenDir(full_namep)) != NULL) {
/* yep. */
@@ -5622,6 +5725,11 @@
inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
inst_dir, MAXPATHLEN);
+ if (!inst_dirp || !*inst_dirp)
+ {
+ rval = -1;
+ goto done;
+ }
dirhandle = PR_OpenDir(inst_dirp);
if (NULL == dirhandle)
@@ -5672,6 +5780,11 @@
li = inst->inst_li;
priv = (dblayer_private*)li->li_dblayer_private;
inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
+ if (!inst_dirp || *inst_dirp) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "update_db_ext: instance dir is NULL\n", 0, 0, 0);
+ return -1; /* non zero */
+ }
for (a = (struct attrinfo *)avl_getfirst(inst->inst_attrs);
NULL != a;
a = (struct attrinfo *)avl_getnext())
Index: dbversion.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dbversion.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- dbversion.c 10 Nov 2006 23:45:39 -0000 1.7
+++ dbversion.c 15 Mar 2007 21:34:32 -0000 1.8
@@ -105,19 +105,13 @@
* (406922) */
if (idl_get_idl_new())
{
-#if defined(USE_NEW_IDL)
- sprintf( buf, "%s\n", LDBM_VERSION );
-#else
- sprintf( buf, "%s\n", LDBM_VERSION_NEW );
-#endif
+ sprintf(buf, "%s/%d.%d/%s\n",
+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_BACKEND);
}
else
{
-#if defined(USE_NEW_IDL)
- sprintf( buf, "%s\n", LDBM_VERSION_OLD );
-#else
- sprintf( buf, "%s\n", LDBM_VERSION );
-#endif
+ sprintf(buf, "%s/%d.%d/%s\n",
+ BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_BACKEND);
}
len = strlen( buf );
if ( slapi_write_buffer( prfd, buf, len ) != len )
@@ -149,7 +143,7 @@
*/
int
dbversion_read(struct ldbminfo *li, const char *directory,
- char *ldbmversion, char *dataversion)
+ char **ldbmversion, char **dataversion)
{
char filename[ MAXPATHLEN*2 ];
PRFileDesc *prfd;
@@ -157,15 +151,15 @@
char * iter = NULL;
if (!is_fullpath((char *)directory)) {
- rc = -1;
+ return rc;
+ }
+
+ if (NULL == ldbmversion) {
return rc;
}
mk_dbversion_fullpath(li, directory, filename);
- ldbmversion[0]= '\0';
- dataversion[0]= '\0';
-
/* Open the file */
if (( prfd = PR_Open( filename, PR_RDONLY, SLAPD_DEFAULT_FILE_MODE )) ==
NULL )
@@ -180,15 +174,15 @@
if ( nr > 0 && nr != (PRInt32)LDBM_VERSION_MAXBUF-1 )
{
char *t;
- buf[nr]= '\0';
- t= ldap_utf8strtok_r(buf,"\n", &iter);
- if(t!=NULL)
+ buf[nr] = '\0';
+ t = ldap_utf8strtok_r(buf,"\n", &iter);
+ if(NULL != t)
{
- strcpy(ldbmversion,t);
- t= ldap_utf8strtok_r(NULL,"\n", &iter);
- if(t!=NULL && t[0]!='\0')
+ *ldbmversion = slapi_ch_strdup(t);
+ t = ldap_utf8strtok_r(NULL,"\n", &iter);
+ if(NULL != dataversion && t != NULL && t[0] != '\0')
{
- strcpy(dataversion,t);
+ *dataversion = slapi_ch_strdup(t);
}
}
}
Index: ldbm_config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_config.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ldbm_config.c 4 Dec 2006 18:36:57 -0000 1.10
+++ ldbm_config.c 15 Mar 2007 21:34:32 -0000 1.11
@@ -1214,11 +1214,7 @@
{CONFIG_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "0", &ldbm_config_cache_autosize_get, &ldbm_config_cache_autosize_set, 0},
{CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "50", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, 0},
{CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "20000000", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
-#if defined(USE_NEW_IDL)
{CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
-#else
- {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "old", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
-#endif
{CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_USE_VLV_INDEX, CONFIG_TYPE_ONOFF, "on", &ldbm_config_get_use_vlv_index, &ldbm_config_set_use_vlv_index, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_DB_LOCKDOWN, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_lockdown_get, &ldbm_config_db_lockdown_set, 0},
Index: proto-back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- proto-back-ldbm.h 1 Dec 2006 21:57:57 -0000 1.10
+++ proto-back-ldbm.h 15 Mar 2007 21:34:32 -0000 1.11
@@ -563,7 +563,7 @@
*/
int dbversion_write(struct ldbminfo *li, const char *dir, const char *dversion);
int dbversion_read(struct ldbminfo *li, const char *directory,
- char *ldbmversion, char *dataversion);
+ char **ldbmversion, char **dataversion);
int dbversion_exists(struct ldbminfo *li, const char *directory);
/*
Index: start.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/start.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- start.c 10 Nov 2006 23:45:39 -0000 1.6
+++ start.c 15 Mar 2007 21:34:32 -0000 1.7
@@ -163,7 +163,7 @@
return SLAPI_FAIL_GENERAL;
}
- if (action & DBVERSION_UPGRADE_3_4)
+ if (action & (DBVERSION_UPGRADE_3_4|DBVERSION_UPGRADE_4_4))
{
retval = dblayer_start(li,DBLAYER_CLEAN_RECOVER_MODE);
}
Index: upgrade.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/upgrade.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- upgrade.c 10 Nov 2006 23:45:39 -0000 1.6
+++ upgrade.c 15 Mar 2007 21:34:32 -0000 1.7
@@ -45,9 +45,6 @@
#include "back-ldbm.h"
-#if 0
-static char* filename = "upgrade.c";
-#endif
/*
* ldbm_compat_versions holds DBVERSION strings for all versions of the
* database with which we are (upwards) compatible. If check_db_version
@@ -56,16 +53,13 @@
*/
db_upgrade_info ldbm_version_suss[] = {
-#if defined(USE_NEW_IDL)
- {LDBM_VERSION,DBVERSION_NEW_IDL,DBVERSION_NO_UPGRADE},
- {LDBM_VERSION_OLD,DBVERSION_OLD_IDL,DBVERSION_NO_UPGRADE},
-#else
- /* default: old idl (DS6.2) */
- {LDBM_VERSION_NEW,DBVERSION_NEW_IDL,DBVERSION_NO_UPGRADE},
- {LDBM_VERSION,DBVERSION_OLD_IDL,DBVERSION_NO_UPGRADE},
-#endif
- {LDBM_VERSION_61,DBVERSION_NEW_IDL,DBVERSION_UPGRADE_3_4},
- {LDBM_VERSION_60,DBVERSION_OLD_IDL,DBVERSION_UPGRADE_3_4},
+ /* for bdb/#.#/..., we don't have to put the version number in the 2nd col
+ since DBVERSION keeps it */
+ {BDB_IMPL, 0, 0, DBVERSION_NEW_IDL, DBVERSION_NO_UPGRADE},
+ {LDBM_VERSION, 4, 2, DBVERSION_NEW_IDL, DBVERSION_NO_UPGRADE},
+ {LDBM_VERSION_OLD, 4, 2, DBVERSION_OLD_IDL, DBVERSION_NO_UPGRADE},
+ {LDBM_VERSION_61, 3, 3, DBVERSION_NEW_IDL, DBVERSION_UPGRADE_3_4},
+ {LDBM_VERSION_60, 3, 3, DBVERSION_OLD_IDL, DBVERSION_UPGRADE_3_4},
{NULL,0,0}
};
@@ -79,11 +73,12 @@
lookup_dbversion(char *dbversion, int flag)
{
int i, matched = 0;
- int rval = 0;
+ int rval = DBVERSION_NO_UPGRADE;
for ( i = 0; ldbm_version_suss[i].old_version_string != NULL; ++i )
{
- if ( strcmp( dbversion, ldbm_version_suss[i].old_version_string ) == 0 )
+ if (PL_strncasecmp(dbversion, ldbm_version_suss[i].old_version_string,
+ strlen(ldbm_version_suss[i].old_version_string)) == 0)
{
matched = 1;
break;
@@ -97,7 +92,42 @@
}
if ( flag & DBVERSION_ACTION )
{
- rval |= ldbm_version_suss[i].action;
+ int dbmajor = 0, dbminor = 0;
+ if (0 == ldbm_version_suss[i].old_dbversion_major)
+ {
+ /* case of bdb/#.#/... */
+ char *p = strchr(dbversion, '/');
+ char *endp = dbversion + strlen(dbversion);
+ if (NULL != p && p < endp)
+ {
+ char *dotp = strchr(++p, '.');
+ if (NULL != dotp)
+ {
+ *dotp = '\0';
+ dbmajor = strtol(p, (char **)NULL, 10);
+ dbminor = strtol(++dotp, (char **)NULL, 10);
+ }
+ else
+ {
+ dbmajor = strtol(p, (char **)NULL, 10);
+ }
+ }
+ }
+ else
+ {
+ dbmajor = ldbm_version_suss[i].old_dbversion_major;
+ dbminor = ldbm_version_suss[i].old_dbversion_minor;
+ }
+ if (dbmajor < DB_VERSION_MAJOR)
+ {
+ /* 3.3 -> 4.x */
+ rval |= ldbm_version_suss[i].action;
+ }
+ else if (dbminor < DB_VERSION_MINOR)
+ {
+ /* 4.low -> 4.high */
+ rval |= DBVERSION_UPGRADE_4_4;
+ }
}
}
return rval;
@@ -113,20 +143,23 @@
*
* action: 0: nothing is needed
* DBVERSION_UPGRADE_3_4: db3->db4 uprev is needed
+ * DBVERSION_UPGRADE_4_4: db4->db4 uprev is needed
*/
int
check_db_version( struct ldbminfo *li, int *action )
{
int value = 0;
- char ldbmversion[BUFSIZ];
- char dataversion[BUFSIZ];
+ char *ldbmversion = NULL;
+ char *dataversion = NULL;
*action = 0;
- dbversion_read(li, li->li_directory,ldbmversion,dataversion);
- if (0 == strlen(ldbmversion))
+ dbversion_read(li, li->li_directory, &ldbmversion, &dataversion);
+ if (NULL == ldbmversion || '\0' == *ldbmversion) {
+ slapi_ch_free_string(&dataversion);
return 0;
+ }
- value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION);
+ value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION );
if ( !value )
{
LDAPDebug( LDAP_DEBUG_ANY,
@@ -136,6 +169,8 @@
/*
* A non-zero return here will cause slapd to exit during startup.
*/
+ slapi_ch_free_string(&ldbmversion);
+ slapi_ch_free_string(&dataversion);
return DBVERSION_NOT_SUPPORTED;
}
if ( value & DBVERSION_UPGRADE_3_4 )
@@ -143,6 +178,13 @@
dblayer_set_recovery_required(li);
*action = DBVERSION_UPGRADE_3_4;
}
+ else if ( value & DBVERSION_UPGRADE_4_4 )
+ {
+ dblayer_set_recovery_required(li);
+ *action = DBVERSION_UPGRADE_4_4;
+ }
+ slapi_ch_free_string(&ldbmversion);
+ slapi_ch_free_string(&dataversion);
return 0;
}
@@ -160,13 +202,14 @@
* DBVERSION_NOT_SUPPORTED: not supported
*
* DBVERSION_UPGRADE_3_4: db3->db4 uprev is needed
+ * DBVERSION_UPGRADE_4_4: db4->db4 uprev is needed
*/
int
check_db_inst_version( ldbm_instance *inst )
{
int value = 0;
- char ldbmversion[BUFSIZ];
- char dataversion[BUFSIZ];
+ char *ldbmversion = NULL;
+ char *dataversion = NULL;
int rval = 0;
char inst_dir[MAXPATHLEN*2];
char *inst_dirp = NULL;
@@ -174,11 +217,12 @@
inst_dirp =
dblayer_get_full_inst_dir(inst->inst_li, inst, inst_dir, MAXPATHLEN*2);
- dbversion_read(inst->inst_li, inst_dirp,ldbmversion,dataversion);
- if (0 == strlen(ldbmversion))
+ dbversion_read(inst->inst_li, inst_dirp, &ldbmversion, &dataversion);
+ if (NULL == ldbmversion || '\0' == *ldbmversion) {
return rval;
+ }
- value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION);
+ value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION );
if ( !value )
{
LDAPDebug( LDAP_DEBUG_ANY,
@@ -188,6 +232,8 @@
/*
* A non-zero return here will cause slapd to exit during startup.
*/
+ slapi_ch_free_string(&ldbmversion);
+ slapi_ch_free_string(&dataversion);
return DBVERSION_NOT_SUPPORTED;
}
@@ -205,8 +251,14 @@
{
rval |= DBVERSION_UPGRADE_3_4;
}
+ else if ( value & DBVERSION_UPGRADE_4_4 )
+ {
+ rval |= DBVERSION_UPGRADE_4_4;
+ }
if (inst_dirp != inst_dir)
slapi_ch_free_string(&inst_dirp);
+ slapi_ch_free_string(&ldbmversion);
+ slapi_ch_free_string(&dataversion);
return rval;
}
@@ -221,13 +273,9 @@
int rval = 0;
li->li_flags |= LI_FORCE_MOD_CONFIG;
-#if defined(USE_NEW_IDL)
- if ((0 == strcmp(ldbmversion, LDBM_VERSION)) ||
- (0 == strcmp(ldbmversion, LDBM_VERSION_61))) /* db: new idl */
-#else
- if ((0 == strcmp(ldbmversion, LDBM_VERSION_NEW)) ||
- (0 == strcmp(ldbmversion, LDBM_VERSION_61))) /* db: new idl */
-#endif
+ if ((0 == PL_strncasecmp(ldbmversion, BDB_IMPL, strlen(BDB_IMPL))) ||
+ (0 == PL_strcmp(ldbmversion, LDBM_VERSION)) ||
+ (0 == PL_strcmp(ldbmversion, LDBM_VERSION_61))) /* db: new idl */
{
if (!idl_get_idl_new()) /* config: old idl */
{
@@ -239,13 +287,8 @@
ldbmversion, 0, 0);
}
}
-#if defined(USE_NEW_IDL)
else if ((0 == strcmp(ldbmversion, LDBM_VERSION_OLD)) ||
(0 == strcmp(ldbmversion, LDBM_VERSION_60))) /* db: old */
-#else
- else if ((0 == strcmp(ldbmversion, LDBM_VERSION)) || /* ds6.2: old */
- (0 == strcmp(ldbmversion, LDBM_VERSION_60))) /* db: old */
-#endif
{
if (idl_get_idl_new()) /* config: new */
{
@@ -289,7 +332,6 @@
int rval = dblayer_update_db_ext(inst, LDBM_SUFFIX_OLD, LDBM_SUFFIX);
if (0 == rval)
{
-#if defined(USE_NEW_IDL)
if (idl_get_idl_new())
{
LDAPDebug(LDAP_DEBUG_ANY,
@@ -302,11 +344,6 @@
"ldbm_upgrade: Upgrading instance %s to %s%s is successfully done.\n",
inst->inst_name, LDBM_VERSION_OLD, 0);
}
-#else
- LDAPDebug(LDAP_DEBUG_ANY,
- "ldbm_upgrade: Upgrading instance %s to %s%s is successfully done.\n",
- inst->inst_name, LDBM_VERSION_BASE, PRODUCTTEXT);
-#endif
}
else
{
17 years
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm instance.c, 1.6, 1.7
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26089/ldapserver/ldap/servers/slapd/back-ldbm
Modified Files:
instance.c
Log Message:
Resolves: bug 232377
Bug Description: PAM passthru ENTRY method not working
Reviewed by: prowley (Thanks!)
Fix Description: There are several problems.
1) For the ENTRY method to perform the internal search to get the entry for the bind DN, it must have a component ID (aka plugin identity). The code was already there to get/set it, but it was never initialized in the init function.
2) You cannot mix slapi_sdn_new* with slapi_sdn_init* - slapi_sdn_init will erase the knowledge that the Slapi_DN was allocated with malloc and it will not free it in slapi_sdn_free().
3) People may assume they can specify a subtree (e.g. ou=people,dc=example,dc=com) instead of a suffix for the list of included/excluded suffixes. The error message will not print a list of valid suffixes for the admin to use.
4) slapi_be_exist was failing because the database does not notify the mapping tree code that the backend is started during startup. This works fine under normal conditions because most all of the code in mapping_tree.c will lookup the backend if the mtn_be pointer in the mapping tree node is NULL. However, slapi_be_exist and slapi_be_select do not do this. The proper solution is to call slapi_mtn_be_started() at database startup time. This is the same thing that happens when a backend is added at runtime.
Platforms tested: FC6
Flag Day: no
Doc impact: no
Index: instance.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/instance.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- instance.c 7 Mar 2007 21:54:03 -0000 1.6
+++ instance.c 15 Mar 2007 18:21:43 -0000 1.7
@@ -278,6 +278,7 @@
rc = rc1;
} else {
vlv_init(inst);
+ slapi_mtn_be_started(inst->inst_be);
}
inst_obj = objset_next_obj(li->li_instance_set, inst_obj);
}
17 years
[Fedora-directory-commits] ldapserver/ldap/servers/slapd backend_manager.c, 1.7, 1.8 mapping_tree.c, 1.8, 1.9
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26089/ldapserver/ldap/servers/slapd
Modified Files:
backend_manager.c mapping_tree.c
Log Message:
Resolves: bug 232377
Bug Description: PAM passthru ENTRY method not working
Reviewed by: prowley (Thanks!)
Fix Description: There are several problems.
1) For the ENTRY method to perform the internal search to get the entry for the bind DN, it must have a component ID (aka plugin identity). The code was already there to get/set it, but it was never initialized in the init function.
2) You cannot mix slapi_sdn_new* with slapi_sdn_init* - slapi_sdn_init will erase the knowledge that the Slapi_DN was allocated with malloc and it will not free it in slapi_sdn_free().
3) People may assume they can specify a subtree (e.g. ou=people,dc=example,dc=com) instead of a suffix for the list of included/excluded suffixes. The error message will not print a list of valid suffixes for the admin to use.
4) slapi_be_exist was failing because the database does not notify the mapping tree code that the backend is started during startup. This works fine under normal conditions because most all of the code in mapping_tree.c will lookup the backend if the mtn_be pointer in the mapping tree node is NULL. However, slapi_be_exist and slapi_be_select do not do this. The proper solution is to call slapi_mtn_be_started() at database startup time. This is the same thing that happens when a backend is added at runtime.
Platforms tested: FC6
Flag Day: no
Doc impact: no
Index: backend_manager.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/backend_manager.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- backend_manager.c 10 Nov 2006 23:45:40 -0000 1.7
+++ backend_manager.c 15 Mar 2007 18:21:37 -0000 1.8
@@ -80,6 +80,10 @@
backends[i] = be;
nbackends++;
+
+ slapi_log_error(SLAPI_LOG_TRACE, "slapi_be_new",
+ "Added new backend name [%s] type [%s] nbackends [%d]\n",
+ name, type, nbackends);
return( be );
}
Index: mapping_tree.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/mapping_tree.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- mapping_tree.c 14 Dec 2006 23:16:54 -0000 1.8
+++ mapping_tree.c 15 Mar 2007 18:21:37 -0000 1.9
@@ -324,6 +324,12 @@
node->mtn_dstr_plg_name = plg_fct;
node->mtn_dstr_plg = plg;
+ slapi_log_error(SLAPI_LOG_TRACE, "mapping_tree",
+ "Created new mapping tree node for suffix [%s] backend [%s] [%p]\n",
+ slapi_sdn_get_dn(dn),
+ backend_names && backend_names[0] ? backend_names[0] : "null",
+ be ? be[0] : NULL);
+
return node;
}
17 years
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/pam_passthru README, 1.5, 1.6 pam_ptconfig.c, 1.8, 1.9 pam_ptpreop.c, 1.6, 1.7
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/pam_passthru
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26089/ldapserver/ldap/servers/plugins/pam_passthru
Modified Files:
README pam_ptconfig.c pam_ptpreop.c
Log Message:
Resolves: bug 232377
Bug Description: PAM passthru ENTRY method not working
Reviewed by: prowley (Thanks!)
Fix Description: There are several problems.
1) For the ENTRY method to perform the internal search to get the entry for the bind DN, it must have a component ID (aka plugin identity). The code was already there to get/set it, but it was never initialized in the init function.
2) You cannot mix slapi_sdn_new* with slapi_sdn_init* - slapi_sdn_init will erase the knowledge that the Slapi_DN was allocated with malloc and it will not free it in slapi_sdn_free().
3) People may assume they can specify a subtree (e.g. ou=people,dc=example,dc=com) instead of a suffix for the list of included/excluded suffixes. The error message will not print a list of valid suffixes for the admin to use.
4) slapi_be_exist was failing because the database does not notify the mapping tree code that the backend is started during startup. This works fine under normal conditions because most all of the code in mapping_tree.c will lookup the backend if the mtn_be pointer in the mapping tree node is NULL. However, slapi_be_exist and slapi_be_select do not do this. The proper solution is to call slapi_mtn_be_started() at database startup time. This is the same thing that happens when a backend is added at runtime.
Platforms tested: FC6
Flag Day: no
Doc impact: no
Index: README
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/pam_passthru/README,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- README 15 Sep 2006 21:20:36 -0000 1.5
+++ README 15 Mar 2007 18:21:37 -0000 1.6
@@ -155,7 +155,9 @@
pam_acct_mgmt() somewhere during the pam handshakes and before
pam_end() to get this information. We also try to return an
appropriate LDAP error code.
+
PAM Error Code LDAP Error Code Meaning
+============== =============== =======
PAM_USER_UNKNOWN LDAP_NO_SUCH_OBJECT User ID does not exist
PAM_AUTH_ERROR LDAP_INVALID_CREDENTIALS Password is not correct
PAM_ACCT_EXPIRED LDAP_INVALID_CREDENTIALS User's password is expired
@@ -163,6 +165,7 @@
PAM_NEW_AUTHTOK_REQD LDAP_INVALID_CREDENTIALS User's password has expired and must be renewed
PAM_MAXTRIES LDAP_CONSTRAINT_VIOLATION Max retry count has been exceeded
Other codes LDAP_OPERATIONS_ERROR PAM config is incorrect, machine problem, etc.
+
There are three controls we might possibly add to the response:
* the auth response control - returned upon success - contains the BIND DN (u: not currently supported)
* LDAP_CONTROL_PWEXPIRED - returned when PAM reports ACCT_EXPIRED or NEW_AUTHTOK_REQD
@@ -182,7 +185,7 @@
1. Shutdown the server
2. Make sure the slapd-instance/config/schema contains the 60pam-config.ldif file
-3. Make sure serverroot/lib/pam-passthru-plugin.so exists
+3. Make sure plugindir/libpam-passthru-plugin.so exists
4. Make sure /etc/pam.d/ldapserver exists and is configured correctly
5. If the configuration is not already in dse.ldif, append the following to slapd-instance/config/dse.ldif
@@ -192,7 +195,7 @@
objectclass: extensibleObject
objectclass: pamConfig
cn: PAM Pass Through Auth
-nsslapd-pluginpath: /opt/ldapserver/lib/pam-passthru-plugin.so
+nsslapd-pluginpath: /path/to/libpam-passthru-plugin.so
nsslapd-plugininitfunc: pam_passthruauth_init
nsslapd-plugintype: preoperation
nsslapd-pluginenabled: on
@@ -210,7 +213,25 @@
o=NetscapeRoot may be omitted if this is not a configuration DS. Then
restart slapd.
+Testing
+
+I find it convenient to just test against regular /etc/passwd accounts.
+0) Create a server instance with suffix dc=example,dc=com and load the Example.ldif file
+1) cd /etc/pam.d
+2) cp system-auth ldapserver (make sure ldapserver is readable by nobody or whatever your ldap server account is)
+3) useradd scarter (or any uid from Example.ldif)
+4) passwd scarter - use a different password than the LDAP password
+5) Make sure /etc/shadow is readable by nobody or whatever your ldap server account is
+
+You might want to turn off pamSecure for testing purposes unless you have already set up your server and ldap clients to use TLS.
+
+Then you can run a test like this:
+ldapsearch -x -D "uid=scarter,ou=people,dc=example,dc=com" -w thepassword -s base -b ""
+
+Check /var/log/secure for any PAM authentication failures
+
See Also
+
PAM API for Linux http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/pam_appl.html
PAM API for Solaris Writing PAM Applications and Services from the Solaris Security for Developers Guide http://docs.sun.com/app/docs/doc/816-4863/6mb20lvfh?a=view
PAM API for HP-UX http://docs.hp.com/en/B2355-60103/pam.3.html
Index: pam_ptconfig.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/pam_passthru/pam_ptconfig.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- pam_ptconfig.c 10 Nov 2006 23:45:03 -0000 1.8
+++ pam_ptconfig.c 15 Mar 2007 18:21:37 -0000 1.9
@@ -266,7 +266,23 @@
return err;
}
-
+
+static void
+print_suffixes()
+{
+ void *cookie = NULL;
+ Slapi_DN *sdn = NULL;
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "The following is the list of valid suffixes to use with "
+ PAMPT_EXCLUDES_ATTR " and " PAMPT_INCLUDES_ATTR ":\n");
+ for (sdn = slapi_get_first_suffix(&cookie, 1);
+ sdn && cookie;
+ sdn = slapi_get_next_suffix(&cookie, 1)) {
+ slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
+ "\t%s\n", slapi_sdn_get_dn(sdn));
+ }
+}
+
/*
Validate the pending changes in the e entry.
*/
@@ -295,30 +311,27 @@
if (missing_suffix != PAMPT_MISSING_SUFFIX_IGNORE) {
char **missing_list = NULL;
- Slapi_DN *comp_dn = slapi_sdn_new();
/* get the list of excluded suffixes */
excludes = slapi_entry_attr_get_charray(e, PAMPT_EXCLUDES_ATTR);
for (ii = 0; excludes && excludes[ii]; ++ii) {
- slapi_sdn_init_dn_byref(comp_dn, excludes[ii]);
+ Slapi_DN *comp_dn = slapi_sdn_new_dn_byref(excludes[ii]);
if (!slapi_be_exist(comp_dn)) {
charray_add(&missing_list, slapi_ch_strdup(excludes[ii]));
}
- slapi_sdn_done(comp_dn);
+ slapi_sdn_free(&comp_dn);
}
/* get the list of included suffixes */
includes = slapi_entry_attr_get_charray(e, PAMPT_INCLUDES_ATTR);
for (ii = 0; includes && includes[ii]; ++ii) {
- slapi_sdn_init_dn_byref(comp_dn, includes[ii]);
+ Slapi_DN *comp_dn = slapi_sdn_new_dn_byref(includes[ii]);
if (!slapi_be_exist(comp_dn)) {
charray_add(&missing_list, slapi_ch_strdup(includes[ii]));
}
- slapi_sdn_done(comp_dn);
+ slapi_sdn_free(&comp_dn);
}
- slapi_sdn_free(&comp_dn);
-
if (missing_list) {
PRUint32 size =
PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
@@ -333,6 +346,7 @@
}
slapi_ch_array_free(missing_list);
missing_list = NULL;
+ print_suffixes();
if (missing_suffix != PAMPT_MISSING_SUFFIX_ERROR) {
slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"Warning: %s\n", returntext);
@@ -398,8 +412,7 @@
Pam_PassthruSuffix *newone = NULL;
if (suffix) {
newone = (Pam_PassthruSuffix *)slapi_ch_malloc(sizeof(Pam_PassthruSuffix));
- newone->pamptsuffix_dn = slapi_sdn_new();
- slapi_sdn_init_dn_byval(newone->pamptsuffix_dn, suffix);
+ newone->pamptsuffix_dn = slapi_sdn_new_dn_byval(suffix);
newone->pamptsuffix_next = NULL;
}
return newone;
@@ -532,8 +545,7 @@
Pam_PassthruSuffix *try;
int ret = LDAP_SUCCESS;
- comp_dn = slapi_sdn_new();
- slapi_sdn_init_dn_byref(comp_dn, binddn);
+ comp_dn = slapi_sdn_new_dn_byref(binddn);
slapi_lock_mutex(cfg->lock);
if (!cfg->pamptconfig_includes && !cfg->pamptconfig_excludes) {
Index: pam_ptpreop.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/pam_passthru/pam_ptpreop.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- pam_ptpreop.c 10 Nov 2006 23:45:03 -0000 1.6
+++ pam_ptpreop.c 15 Mar 2007 18:21:37 -0000 1.7
@@ -85,6 +85,9 @@
slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"=> pam_passthruauth_init\n" );
+ slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &pam_passthruauth_plugin_identity);
+ PR_ASSERT (pam_passthruauth_plugin_identity);
+
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
(void *)SLAPI_PLUGIN_VERSION_01 ) != 0
|| slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
17 years