[Fedora-directory-commits] ldapserver/ldap/ldif template-baseacis.ldif.in, NONE, 1.1 template-country.ldif.in, NONE, 1.1 template-domain.ldif.in, NONE, 1.1 template-locality.ldif.in, NONE, 1.1 template-org.ldif.in, NONE, 1.1 template-orgunit.ldif.in, NONE, 1.1 template-state.ldif.in, NONE, 1.1 template-dse.ldif.in, 1.2, 1.3 template.ldif, 1.5, 1.6
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/ldif
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31095/ldapserver/ldap/ldif
Modified Files:
template-dse.ldif.in template.ldif
Added Files:
template-baseacis.ldif.in template-country.ldif.in
template-domain.ldif.in template-locality.ldif.in
template-org.ldif.in template-orgunit.ldif.in
template-state.ldif.in
Log Message:
Resolves: bug 248145
Bug Description: Replace ds_newinst binary with perl script
Reviewed by: nhosoi (Thanks!)
Fix Description: The time has come. We can finally get rid of the instance creation C code
once and for all. I've created a DSCreate module that has all of the functionality of the old
create_instance.c code, along with a few items from ldap/admin/lib. The way it works is
this: it first creates the dse.ldif file using template-dse.ldif and the suffix-db template to
create the initial db and suffix. It then adds additional optional configuration depending
on what optional features have been enabled. It creates other config files and copies in
the schema. It then initializes the database. It uses a template file based on the type of
entry implied by the suffix, then adds the default ACIs. If the user chose to do so, it
will also create the ou=people, ou=groups, etc. entries. The user can also supply an LDIF
file which will be used to populate the initial database, in which case none of the default
entries or ACIs will be used. It then starts the server (if desired).
I had to create a function makePaths that works like mkdir -p except that it will chown,
chgrp, and chmod all paths created.
I had to change the other places where instance creation was called to use the new
calling semantics. ds_create changed quite a bit, since it can just use an Inf to pass in the
information instead of calling ds_newinst as a CGI program.
I had to change FileConn to add support for namingContexts (i.e. entries with no parent),
and to have it write each change each time, and to return copies of entries when searching,
to avoid modifying the tree in place. This makes it act much more like LDAP.
I found and fixed a few bugs in Migration along the way that were revealed while integrating
the new DSCreate code.
Platforms tested: RHEL4, FC6
Flag Day: Yes. New instance creation code and autotool changes.
Doc impact: no
--- NEW FILE template-baseacis.ldif.in ---
dn: %ds_suffix%
changetype: modify
add: aci
aci: (targetattr!="userPassword")(version 3.0; acl "Enable anonymous access"; allow (read, search, compare) userdn="ldap:///anyone";)
aci: (targetattr="carLicense || description || displayName || facsimileTelephoneNumber || homePhone || homePostalAddress || initials || jpegPhoto || labeledURL || mail || mobile || pager || photo || postOfficeBox || postalAddress || postalCode || preferredDeliveryMethod || preferredLanguage || registeredAddress || roomNumber || secretary || seeAlso || st || street || telephoneNumber || telexNumber || title || userCertificate || userPassword || userSMIMECertificate || x500UniqueIdentifier")(version 3.0; acl "Enable self write for common attributes"; allow (write) userdn="ldap:///self";)
--- NEW FILE template-country.ldif.in ---
dn: %ds_suffix%
objectclass: top
objectclass: country
c: %naming_value%
--- NEW FILE template-domain.ldif.in ---
dn: %ds_suffix%
objectclass: top
objectclass: domain
dc: %naming_value%
--- NEW FILE template-locality.ldif.in ---
dn: %ds_suffix%
objectclass: top
objectclass: locality
l: %naming_value%
--- NEW FILE template-org.ldif.in ---
dn: %ds_suffix%
objectclass: top
objectclass: organization
o: %naming_value%
--- NEW FILE template-orgunit.ldif.in ---
dn: %ds_suffix%
objectclass: top
objectclass: organizationalUnit
ou: %naming_value%
--- NEW FILE template-state.ldif.in ---
dn: %ds_suffix%
objectclass: top
objectclass: locality
st: %naming_value%
Index: template-dse.ldif.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/ldif/template-dse.ldif.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- template-dse.ldif.in 29 Jun 2007 21:59:13 -0000 1.2
+++ template-dse.ldif.in 13 Jul 2007 18:35:33 -0000 1.3
@@ -9,7 +9,7 @@
nsslapd-certdir: %cert_dir%
nsslapd-ldifdir: %ldif_dir%
nsslapd-bakdir: %bak_dir%
-nsslapd-saslpath: %sasl_path%
+nsslapd-instancedir: %inst_dir%
nsslapd-accesslog-logging-enabled: on
nsslapd-accesslog-maxlogsperdir: 10
nsslapd-accesslog-mode: 600
@@ -22,7 +22,7 @@
nsslapd-accesslog: %log_dir%/access
nsslapd-enquote-sup-oc: off
nsslapd-localhost: %fqdn%
-nsslapd-schemacheck: 1
+nsslapd-schemacheck: on
nsslapd-rewrite-rfc1274: off
nsslapd-return-exact-case: on
nsslapd-ssl-check-hostname: on
@@ -493,7 +493,7 @@
nsslapd-plugininitfunc: orderingRule_init
nsslapd-plugintype: matchingRule
nsslapd-pluginenabled: on
-nsslapd-pluginarg0: @configdir(a)/slapd-collations.conf
+nsslapd-pluginarg0: %config_dir%/slapd-collations.conf
dn: cn=HTTP Client,cn=plugins,cn=config
objectclass: top
Index: template.ldif
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/ldif/template.ldif,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- template.ldif 18 Apr 2006 17:39:57 -0000 1.5
+++ template.ldif 13 Jul 2007 18:35:33 -0000 1.6
@@ -37,26 +37,24 @@
# All rights reserved.
# END COPYRIGHT BLOCK
#
-dn: %%%SUFFIX%%%
-objectclass: top
-aci: (targetattr ="*")(version 3.0;
- acl "Configuration Administrators Group";allow (all) (groupdn = "ldap:///
- cn=Configuration Administrators, ou=Groups, ou=TopologyManagement, o=NetscapeRoot");)
+dn: %ds_suffix%
+changetype: modify
+add: aci
aci: (targetattr ="*")(version 3.0;
acl "Directory Administrators Group";allow (all) (groupdn = "ldap:///
- cn=Directory Administrators, %%%SUFFIX%%%");)
+ cn=Directory Administrators, %ds_suffix%");)
-dn: cn=Directory Administrators, %%%SUFFIX%%%
+dn: cn=Directory Administrators, %ds_suffix%
objectClass: top
objectClass: groupofuniquenames
cn: Directory Administrators
-dn: ou=Groups, %%%SUFFIX%%%
+dn: ou=Groups, %ds_suffix%
objectclass: top
objectclass: organizationalunit
ou: Groups
-dn: ou=People, %%%SUFFIX%%%
+dn: ou=People, %ds_suffix%
objectclass: top
objectclass: organizationalunit
ou: People
@@ -66,48 +64,48 @@
aci: (targetattr !="cn || sn || uid")(t
argetfilter ="(ou=Accounting)")(version 3.0;acl "Accounting Managers G
roup Permissions";allow (write)(groupdn = "ldap:///cn=Accounting Managers,ou
- =groups,%%%SUFFIX%%%");)
+ =groups,%ds_suffix%");)
aci: (targetattr !="cn || sn || uid")(t
argetfilter ="(ou=Human Resources)")(version 3.0;acl "HR Group Permiss
- ions";allow (write)(groupdn = "ldap:///cn=HR Managers,ou=groups,%%%SUFFIX%%%
+ ions";allow (write)(groupdn = "ldap:///cn=HR Managers,ou=groups,%ds_suffix%
");)
aci: (targetattr !="cn ||sn || uid")(t
argetfilter ="(ou=Product Testing)")(version 3.0;acl "QA Group Permiss
- ions";allow (write)(groupdn = "ldap:///cn=QA Managers,ou=groups,%%%SUFFIX%%%
+ ions";allow (write)(groupdn = "ldap:///cn=QA Managers,ou=groups,%ds_suffix%
");)
aci: (targetattr !="cn || sn || uid")(t
argetfilter ="(ou=Product Development)")(version 3.0;acl "Engineering
Group Permissions";allow (write)(groupdn = "ldap:///cn=PD Managers,ou=groups
- ,%%%SUFFIX%%%");)
+ ,%ds_suffix%");)
-dn: ou=Special Users,%%%SUFFIX%%%
+dn: ou=Special Users,%ds_suffix%
objectclass: top
objectclass: organizationalUnit
ou: Special Users
description: Special Administrative Accounts
-dn: cn=Accounting Managers,ou=groups,%%%SUFFIX%%%
+dn: cn=Accounting Managers,ou=groups,%ds_suffix%
objectclass: top
objectclass: groupOfUniqueNames
cn: Accounting Managers
ou: groups
description: People who can manage accounting entries
-dn: cn=HR Managers,ou=groups,%%%SUFFIX%%%
+dn: cn=HR Managers,ou=groups,%ds_suffix%
objectclass: top
objectclass: groupOfUniqueNames
cn: HR Managers
ou: groups
description: People who can manage HR entries
-dn: cn=QA Managers,ou=groups,%%%SUFFIX%%%
+dn: cn=QA Managers,ou=groups,%ds_suffix%
objectclass: top
objectclass: groupOfUniqueNames
cn: QA Managers
ou: groups
description: People who can manage QA entries
-dn: cn=PD Managers,ou=groups,%%%SUFFIX%%%
+dn: cn=PD Managers,ou=groups,%ds_suffix%
objectclass: top
objectclass: groupOfUniqueNames
cn: PD Managers
16 years, 9 months
[Fedora-directory-commits] ldapserver/m4 fhs.m4,1.3,1.4
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/m4
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31095/ldapserver/m4
Modified Files:
fhs.m4
Log Message:
Resolves: bug 248145
Bug Description: Replace ds_newinst binary with perl script
Reviewed by: nhosoi (Thanks!)
Fix Description: The time has come. We can finally get rid of the instance creation C code
once and for all. I've created a DSCreate module that has all of the functionality of the old
create_instance.c code, along with a few items from ldap/admin/lib. The way it works is
this: it first creates the dse.ldif file using template-dse.ldif and the suffix-db template to
create the initial db and suffix. It then adds additional optional configuration depending
on what optional features have been enabled. It creates other config files and copies in
the schema. It then initializes the database. It uses a template file based on the type of
entry implied by the suffix, then adds the default ACIs. If the user chose to do so, it
will also create the ou=people, ou=groups, etc. entries. The user can also supply an LDIF
file which will be used to populate the initial database, in which case none of the default
entries or ACIs will be used. It then starts the server (if desired).
I had to create a function makePaths that works like mkdir -p except that it will chown,
chgrp, and chmod all paths created.
I had to change the other places where instance creation was called to use the new
calling semantics. ds_create changed quite a bit, since it can just use an Inf to pass in the
information instead of calling ds_newinst as a CGI program.
I had to change FileConn to add support for namingContexts (i.e. entries with no parent),
and to have it write each change each time, and to return copies of entries when searching,
to avoid modifying the tree in place. This makes it act much more like LDAP.
I found and fixed a few bugs in Migration along the way that were revealed while integrating
the new DSCreate code.
Platforms tested: RHEL4, FC6
Flag Day: Yes. New instance creation code and autotool changes.
Doc impact: no
Index: fhs.m4
===================================================================
RCS file: /cvs/dirsec/ldapserver/m4/fhs.m4,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- fhs.m4 26 Apr 2007 02:37:54 -0000 1.3
+++ fhs.m4 13 Jul 2007 18:35:33 -0000 1.4
@@ -39,6 +39,7 @@
[
with_fhs_opt=yes
AC_MSG_RESULT(yes)
+ AC_SUBST(with_fhs_opt)
],
AC_MSG_RESULT(no))
16 years, 9 months
[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts DSCreate.pm.in, NONE, 1.1 dscreate.map.in, NONE, 1.1 dsorgentries.map.in, NONE, 1.1 template-restart-slapd.in, NONE, 1.1 DSMigration.pm.in, 1.3, 1.4 FileConn.pm, 1.2, 1.3 Migration.pm.in, 1.2, 1.3 Util.pm.in, 1.7, 1.8 migrate-ds.pl.in, 1.1, 1.2 migrate-ds.res, 1.2, 1.3 setup-ds.pl.in, 1.5, 1.6 setup-ds.res.in, 1.7, 1.8
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31095/ldapserver/ldap/admin/src/scripts
Modified Files:
DSMigration.pm.in FileConn.pm Migration.pm.in Util.pm.in
migrate-ds.pl.in migrate-ds.res setup-ds.pl.in setup-ds.res.in
Added Files:
DSCreate.pm.in dscreate.map.in dsorgentries.map.in
template-restart-slapd.in
Log Message:
Resolves: bug 248145
Bug Description: Replace ds_newinst binary with perl script
Reviewed by: nhosoi (Thanks!)
Fix Description: The time has come. We can finally get rid of the instance creation C code
once and for all. I've created a DSCreate module that has all of the functionality of the old
create_instance.c code, along with a few items from ldap/admin/lib. The way it works is
this: it first creates the dse.ldif file using template-dse.ldif and the suffix-db template to
create the initial db and suffix. It then adds additional optional configuration depending
on what optional features have been enabled. It creates other config files and copies in
the schema. It then initializes the database. It uses a template file based on the type of
entry implied by the suffix, then adds the default ACIs. If the user chose to do so, it
will also create the ou=people, ou=groups, etc. entries. The user can also supply an LDIF
file which will be used to populate the initial database, in which case none of the default
entries or ACIs will be used. It then starts the server (if desired).
I had to create a function makePaths that works like mkdir -p except that it will chown,
chgrp, and chmod all paths created.
I had to change the other places where instance creation was called to use the new
calling semantics. ds_create changed quite a bit, since it can just use an Inf to pass in the
information instead of calling ds_newinst as a CGI program.
I had to change FileConn to add support for namingContexts (i.e. entries with no parent),
and to have it write each change each time, and to return copies of entries when searching,
to avoid modifying the tree in place. This makes it act much more like LDAP.
I found and fixed a few bugs in Migration along the way that were revealed while integrating
the new DSCreate code.
Platforms tested: RHEL4, FC6
Flag Day: Yes. New instance creation code and autotool changes.
Doc impact: no
--- NEW FILE DSCreate.pm.in ---
# 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
#
###########################
#
# This perl module provides a way to create a new instance of
# directory server.
#
##########################
package DSCreate;
use Util;
use Inf;
use FileConn;
use Net::Domain qw(hostfqdn);
# tempfiles
use File::Temp qw(tempfile tempdir);
use File::Path;
use File::Copy;
use File::Basename qw(basename);
# load perldap
use Mozilla::LDAP::Conn;
use Mozilla::LDAP::Utils qw(normalizeDN);
use Mozilla::LDAP::API qw(ldap_explode_dn);
use Mozilla::LDAP::LDIF;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(createDSInstance);
@EXPORT_OK = qw(createDSInstance);
use strict;
use SetupLog;
sub checkPort {
my $inf = shift;
# allow port 0 if ldapi is used
if ("@enable_ldapi@") {
if ($inf->{slapd}->{ldapifilepath} &&
($inf->{slapd}->{ServerPort} == 0)) {
return ();
}
}
if (!portAvailable($inf->{slapd}->{ServerPort})) {
return ('error_port_available', $inf->{slapd}->{ServerPort}, $!);
}
return ();
}
# checks the parameters in $inf to make sure the supplied values
# are valid
# returns null if successful, or an error string for use with getText()
sub sanityCheckParams {
my $inf = shift;
my @errs = ();
# if we don't need to start the server right away, we can skip the
# port number checks
if (!defined($inf->{slapd}->{start_server}) or
($inf->{slapd}->{start_server} == 1)) {
if (@errs = checkPort($inf)) {
return @errs;
}
}
if (!isValidServerID($inf->{slapd}->{ServerIdentifier})) {
return ('error_invalid_serverid', $inf->{slapd}->{ServerIdentifier});
} elsif (-d $inf->{slapd}->{config_dir}) {
return ('error_server_already_exists', $inf->{slapd}->{config_dir});
}
if (@errs = isValidUser($inf->{General}->{SuiteSpotUserID})) {
return @errs;
}
if (!isValidDN($inf->{slapd}->{Suffix})) {
return ('dialog_dssuffix_error', $inf->{slapd}->{Suffix});
}
if (!isValidDN($inf->{slapd}->{RootDN})) {
return ('dialog_dsrootdn_error', $inf->{slapd}->{RootDN});
}
if ($inf->{slapd}->{RootDNPwd} =~ /\{\w+\}.+/) {
debug(1, "The root password is already hashed - no checking will be performed\n");
} elsif (length($inf->{slapd}->{RootDNPwd}) < 8) {
debug(0, "WARNING: The root password is less than 8 characters long. You should choose a longer one.\n");
}
return ();
}
sub getMode {
my $inf = shift;
my $mode = shift;
if (defined($inf->{General}->{SuiteSpotGroup})) {
$mode = "0" . $mode . $mode . "0";
} else {
$mode = "0" . $mode . "00";
}
return oct($mode);
}
# This is used to change the ownership and permissions of files and directories
# The mode is just a single digit octal number (e.g. 4 6 7)
# If there is a group, the ownership and permissions will allow group access
# otherwise, only the owner will be allowed access
sub changeOwnerMode {
my $inf = shift;
my $mode = shift;
my $it = shift;
my $uid = getpwnam $inf->{General}->{SuiteSpotUserID};
my $gid = -1; # default to leave it alone
if (defined($inf->{General}->{SuiteSpotGroup})) {
$gid = getgrnam $inf->{General}->{SuiteSpotGroup};
}
$mode = getMode($inf, $mode);
$! = 0; # clear errno
chmod $mode, $it;
if ($!) {
return ('error_chmoding_file', $it, $!);
}
$! = 0; # clear errno
chown $uid, $gid, $it;
if ($!) {
return ('error_chowning_file', $it, $inf->{General}->{SuiteSpotUserID}, $!);
}
return ();
}
sub makeDSDirs {
my $inf = shift;
my $verbose = ($Util::debuglevel > 0);
my $mode = getMode($inf, 7);
my @errs;
# These paths are owned by the SuiteSpotGroup
# This allows the admin server to run as a different,
# more privileged user than the directory server, but
# still allows the admin server to manage directory
# server files/dirs without being root
for (qw(inst_dir config_dir schema_dir log_dir lock_dir run_dir tmp_dir
cert_dir db_dir ldif_dir bak_dir)) {
my $dir = $inf->{slapd}->{$_};
@errs = makePaths($dir, $mode, $inf->{General}->{SuiteSpotUserID},
$inf->{General}->{SuiteSpotGroup});
if (@errs) {
return @errs;
}
}
return @errs;
}
sub createInstanceScripts {
my $inf = shift;
my $myperl = "!/usr/bin/env perl";
my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
my %maptable = (
"DS-ROOT" => $inf->{General}->{prefix},
"SEP" => "/", # works on all platforms
"SERVER-NAME" => $inf->{General}->{FullMachineName},
"SERVER-PORT" => $inf->{slapd}->{ServerPort},
"PERL-EXEC" => $myperl,
"DEV-NULL" => $mydevnull,
"ROOT-DN" => $inf->{slapd}->{RootDN},
"LDIF-DIR" => $inf->{slapd}->{ldif_dir},
"SERV-ID" => $inf->{slapd}->{ServerIdentifier},
"BAK-DIR" => $inf->{slapd}->{bak_dir},
"SERVER-DIR" => $inf->{General}->{ServerRoot},
"CONFIG-DIR" => $inf->{slapd}->{config_dir},
"RUN-DIR" => $inf->{slapd}->{run_dir},
"PRODUCT-NAME" => "slapd",
"SERVERBIN-DIR" => $inf->{slapd}->{sbindir},
"DB-DIR" => $inf->{slapd}->{db_dir}
);
my $dir = "$inf->{General}->{prefix}@taskdir@";
for (glob("$dir/template-*")) {
my $basename = $_;
$basename =~ s/^.*template-//;
my $destfile = "$inf->{slapd}->{inst_dir}/$basename";
if (!open(SRC, "< $_")) {
return ("error_opening_scripttmpl", $_, $!);
}
if (!open(DEST, "> $destfile")) {
return ("error_opening_scripttmpl", $destfile, $!);
}
my $contents; # slurp entire file into memory
read SRC, $contents, int(-s $_);
close(SRC);
while (my ($key, $val) = each %maptable) {
$contents =~ s/\{\{$key\}\}/$val/g;
}
print DEST $contents;
close(DEST);
my @errs = changeOwnerMode($inf, 5, $destfile);
if (@errs) {
return @errs;
}
}
return ();
}
sub createConfigFile {
my $inf = shift;
my $conffile = "$inf->{slapd}->{config_dir}/dse.ldif";
my $conn = new FileConn;
my @errs;
# first, create the basic config
my $mapper = new Inf("$inf->{General}->{prefix}@infdir(a)/dscreate.map");
my $dsinf = new Inf("$inf->{General}->{prefix}@infdir(a)/slapd.inf");
if (!$inf->{slapd}->{ds_bename}) {
$inf->{slapd}->{ds_bename} = "userRoot"; # for suffix-db
}
$mapper = process_maptbl($mapper, \@errs, $inf, $dsinf);
if (!$mapper or @errs) {
$conn->close();
if (!@errs) {
@errs = ('error_creating_file', $conffile, $!);
}
return @errs;
}
my @ldiffiles = ("$inf->{General}->{prefix}@templatedir(a)/template-dse.ldif",
"$inf->{General}->{prefix}@templatedir(a)/template-suffix-db.ldif");
if ("@enable_pam_passthru@") {
push @ldiffiles, "$inf->{General}->{prefix}@templatedir(a)/template-pampta.ldif";
}
if ("@enable_bitwise@") {
push @ldiffiles, "$inf->{General}->{prefix}@templatedir(a)/template-bitwise.ldif";
}
if ("@enable_dna@") {
push @ldiffiles, "$inf->{General}->{prefix}@templatedir(a)/template-dnaplugin.ldif";
}
getMappedEntries($mapper, \@ldiffiles, \@errs, \&check_and_add_entry,
[$conn]);
if (@errs) {
$conn->close();
return @errs;
}
if ("@enable_ldapi@") {
my $ent = $conn->search("cn=config", "base", "(objectclass=*)");
if (defined($inf->{slapd}->{ldapifilepath})) {
$ent->setValues("nsslapd-ldapifilepath", $inf->{slapd}->{ldapifilepath});
$ent->setValues("nsslapd-ldapilisten", "on");
} else {
$ent->setValues("nsslapd-ldapifilepath",
"$inf->{slapd}->{run_dir}/slapd-$inf->{slapd}->{ServerIdentifier}.socket");
$ent->setValues("nsslapd-ldapilisten", "off");
}
if ("@enable_autobind@") {
$ent->setValues("nsslapd-ldapiautobind", "on");
}
$ent->setValues("nsslapd-ldapimaprootdn", $inf->{slapd}->{RootDN});
$ent->setValues("nsslapd-ldapimaptoentries", "off");
$ent->setValues("nsslapd-ldapiuidnumbertype", "uidNumber");
$ent->setValues("nsslapd-ldapigidnumbertype", "gidNumber");
$ent->setValues("nsslapd-ldapientrysearchbase", "dc=example, dc=com");
$ent->setValues("nsslapd-ldapiautodnsuffix", "cn=peercred,cn=external,cn=auth");
if (!$conn->update($ent)) {
$conn->close();
return ("error_enabling_feature", "ldapi", $conn->getErrorString());
}
}
if ($inf->{slapd}->{sasl_path}) {
my $ent = $conn->search("cn=config", "base", "(objectclass=*)");
$ent->setValues("nsslapd-saslpath", $inf->{slapd}->{sasl_path});
if (!$conn->update($ent)) {
$conn->close();
return ("error_enabling_feature", "sasl_path", $conn->getErrorString());
}
}
$conn->write($conffile);
$conn->close();
if (@errs = changeOwnerMode($inf, 6, $conffile)) {
return @errs;
}
# make a copy
my $origconf = "$inf->{slapd}->{config_dir}/dse_original.ldif";
$! = 0; # clear errno
copy($conffile, $origconf);
if ($!) {
return ('error_copying_file', $conffile, $origconf, $!);
}
if (@errs = changeOwnerMode($inf, 4, $origconf)) {
return @errs;
}
return @errs;
}
sub makeOtherConfigFiles {
my $inf = shift;
my @errs;
# install certmap.conf at <configdir>
my $src = "$inf->{General}->{prefix}@configdir(a)/certmap.conf";
my $dest = "$inf->{slapd}->{config_dir}/certmap.conf";
$! = 0; # clear errno
copy($src, $dest);
if ($!) {
return ('error_copying_file', $src, $dest, $!);
}
if (@errs = changeOwnerMode($inf, 4, $dest)) {
return @errs;
}
$src = "$inf->{General}->{prefix}@configdir(a)/slapd-collations.conf";
$dest = "$inf->{slapd}->{config_dir}/slapd-collations.conf";
$! = 0; # clear errno
copy($src, $dest);
if ($!) {
return ('error_copying_file', $src, $dest, $!);
}
if (@errs = changeOwnerMode($inf, 4, $dest)) {
return @errs;
}
return ();
}
sub installSchema {
my $inf = shift;
my @errs;
my @schemafiles = ();
if (!defined($inf->{slapd}->{install_full_schema}) or
$inf->{slapd}->{install_full_schema}) {
push @schemafiles, glob("$inf->{General}->{prefix}@schemadir@/*");
} else {
push @schemafiles, "$inf->{General}->{prefix}@schemadir(a)/00core.ldif";
}
for (@schemafiles) {
my $src = $_;
my $basename = basename($src);
my $dest = "$inf->{slapd}->{schema_dir}/$basename";
$! = 0; # clear errno
copy($src, $dest);
if ($!) {
return ('error_copying_file', $src, $dest, $!);
}
my $mode = 4; # default read only
if ($basename eq "99user.ldif") {
$mode = 6; # read write
}
if (@errs = changeOwnerMode($inf, $mode, $dest)) {
return @errs;
}
}
return ();
}
# maps the suffix attr to the filename to use
my %suffixTable = (
'o' => "@templatedir(a)/template-org.ldif",
'dc' => "@templatedir(a)/template-domain.ldif",
'ou' => "@templatedir(a)/template-orgunit.ldif",
'st' => "@templatedir(a)/template-state.ldif",
'l' => "@templatedir(a)/template-locality.ldif",
'c' => "@templatedir(a)/template-country.ldif"
);
sub initDatabase {
my $inf = shift;
# If the user has specified an LDIF file to use to initialize the database,
# load it now
my $ldiffile = $inf->{slapd}->{InstallLdifFile};
if ($ldiffile && -f $ldiffile) {
debug(1, "Loading initial ldif file $ldiffile\n");
} elsif (($inf->{slapd}->{Suffix} =~ /^(.*?)=/) && $suffixTable{$1}) {
my @errs;
my $template = $inf->{General}->{prefix} . $suffixTable{$1};
my $mapper = new Inf("$inf->{General}->{prefix}@infdir(a)/dsorgentries.map");
my $dsinf = new Inf("$inf->{General}->{prefix}@infdir(a)/slapd.inf");
my @rdns = ldap_explode_dn($inf->{slapd}->{Suffix}, 1);
$inf->{slapd}->{naming_value} = $rdns[0];
$mapper = process_maptbl($mapper, \@errs, $inf, $dsinf);
if (!$mapper or @errs) {
return @errs;
}
my @ldiffiles = ($template, "$inf->{General}->{prefix}@templatedir(a)/template-baseacis.ldif");
if (exists($inf->{slapd}->{InstallLdifFile}) and
($inf->{slapd}->{InstallLdifFile} =~ /suggest/i)) {
push @ldiffiles, "$inf->{General}->{prefix}@templatedir(a)/template.ldif";
}
my ($fh, $templdif) = tempfile("ldifXXXXXX", SUFFIX => ".ldif", OPEN => 0,
DIR => File::Spec->tmpdir);
my $conn = new FileConn;
$conn->setNamingContext($inf->{slapd}->{Suffix});
getMappedEntries($mapper, \@ldiffiles, \@errs, \&check_and_add_entry,
[$conn]);
$conn->write($templdif);
$conn->close();
if (@errs) {
return @errs;
}
# $templdif now contains the ldif to import
$ldiffile = $templdif;
}
if (!$ldiffile) {
return ();
}
my $cmd = "$inf->{slapd}->{inst_dir}/ldif2db -n userRoot -i \'$ldiffile\'";
$? = 0; # clear error condition
my $output = `$cmd 2>&1`;
if ($?) {
return ('error_importing_ldif', $ldiffile, $?, $output);
}
debug(1, $output);
return ();
}
sub startServer {
my $inf = shift;
return () if (defined($inf->{slapd}->{start_server}) && !$inf->{slapd}->{start_server});
my @errs;
# get error log
my $errLog = "$inf->{slapd}->{log_dir}/errors";
my $startcmd = "$inf->{slapd}->{inst_dir}/start-slapd";
# emulate tail -f
# if the last line we see does not contain "slapd started", try again
my $done = 0;
my $started = 0;
my $code = 0;
my $lastLine = "";
my $cmdPat = 'slapd started\.';
my $timeout = $inf->{slapd}->{startup_timeout};
$timeout = $timeout?$timeout:600; # default is 10 minutes
$timeout = time + $timeout;
debug(1, "Starting the server: $startcmd\n");
$? = 0; # clear error condition
my $output = `$startcmd 2>&1`;
$code = $?;
debug(1, "Started the server: code $code\n");
if ($code) {
debug(0, $output);
} else {
debug(1, $output);
}
# try to open the server error log
my $ii = 0;
while (time < $timeout) {
if (open(IN, $errLog)) {
last;
}
sleep(1);
if (!($ii % 10)) {
debug(0, "Attempting to obtain server status . . .\n");
}
++$ii;
}
if (! -f $errLog) {
debug(0, "Error: Could not read error log $errLog to get server startup status. Error: $!\n");
return ('error_starting_server', $startcmd, "no status", $!);
}
if (time >= $timeout) {
debug(0, "Error: timed out waiting for the server to start and write to $errLog");
return ('error_starting_server', $startcmd, "timeout", 0);
}
my $pos = tell(IN);
while (($done == 0) && (time < $timeout)) {
for (; ($done == 0) && ($_ = <IN>); $pos = tell(IN)) {
$lastLine = $_;
debug(1, $_);
if (/$cmdPat/) {
$done = 1;
$started = 1;
} elsif (/Initialization Failed/) {
debug(1, "Server failed to start, retrying . . .\n");
$code = system($startcmd);
} elsif (/exiting\./) {
debug(1, "Server failed to start, retrying . . .\n");
$code = system($startcmd);
}
}
if ($lastLine =~ /PR_Bind/) {
# server port conflicts with another one, just report and punt
debug(0, $lastLine);
@errs = ('error_port_available', $inf->{slapd}->{ServerPort}, $!);
$done = 1;
}
if ($done == 0) {
# rest a bit, then . . .
sleep(2);
# . . . reset the EOF status of the file desc
seek(IN, $pos, 0);
}
}
close(IN);
if (!$started) {
$! = $code;
my $now = time;
if ($now > $timeout) {
debug(0, "Possible timeout starting server: timeout=$timeout now=$now\n");
}
@errs = ('error_starting_server', $startcmd, $lastLine, $!);
} else {
debug(1, "Your new directory server has been started.\n");
}
return @errs;
}
sub set_path_attribute {
my $val = shift;
my $defaultval = shift;
my $prefix = shift;
if ($val) {
return "$prefix" . "$val";
} else {
return "$prefix" . "$defaultval";
}
}
sub setDefaults {
my $inf = shift;
# set default values
# this turns off the warnings
if (!defined($inf->{General}->{prefix})) {
$inf->{General}->{prefix} = "";
}
if (!$inf->{General}->{FullMachineName}) {
$inf->{General}->{FullMachineName} = hostfqdn;
}
if (!$inf->{General}->{SuiteSpotUserID}) {
if ($> != 0) { # if not root, use the user's uid
$inf->{General}->{SuiteSpotUserID} = getlogin;
}
# otherwise, the uid must be specified
}
if (!$inf->{slapd}->{RootDN}) {
$inf->{slapd}->{RootDN} = "cn=Directory Manager";
}
if (!$inf->{slapd}->{Suffix}) {
my $suffix = $inf->{General}->{FullMachineName};
# convert fqdn to dc= domain components
$suffix =~ s/^[^\.]*\.//; # just the domain part
$suffix = "dc=$suffix";
$suffix =~ s/\./, dc=/g;
$inf->{slapd}->{Suffix} = $suffix;
}
if (!$inf->{slapd}->{ServerIdentifier}) {
my $servid = $inf->{General}->{FullMachineName};
# strip out the leftmost domain component
$servid =~ s/\..*$//;
$inf->{slapd}->{ServerIdentifier} = $servid;
}
if ("@with_fhs_opt@") {
$inf->{General}->{ServerRoot} = "$inf->{General}->{prefix}/opt/@PACKAGE_NAME@";
} else {
$inf->{General}->{ServerRoot} = "$inf->{General}->{prefix}@serverdir@";
}
if (!defined($inf->{slapd}->{sasl_path})) {
if ($ ne "linux") {
$inf->{slapd}->{sasl_path} = "$inf->{General}->{prefix}@libdir@/sasl2";
}
}
if (!defined($inf->{slapd}->{ServerPort}) and
!defined($inf->{slapd}->{ldapifilepath})) {
if ("@enable_ldapi@") {
return ('error_missing_port_and_ldapi');
} else {
return ('error_missing_port');
}
}
if (!defined($inf->{slapd}->{ServerPort})) {
$inf->{slapd}->{ServerPort} = 0;
}
$inf->{slapd}->{HashedRootDNPwd} = getHashedPassword($inf->{slapd}->{RootDNPwd});
$inf->{slapd}->{localstatedir} = set_path_attribute($inf->{slapd}->{localstatedir},
"@localstatedir@",
$inf->{General}->{prefix});
my $localstatedir = $inf->{slapd}->{localstatedir};
my $servid = $inf->{slapd}->{ServerIdentifier};
$inf->{slapd}->{sysconfdir} = set_path_attribute($inf->{slapd}->{sysconfdir},
"@sysconfdir@",
$inf->{General}->{prefix});
my $sysconfdir = $inf->{slapd}->{sysconfdir};
$inf->{slapd}->{bindir} = set_path_attribute($inf->{slapd}->{bindir},
"@bindir@",
$inf->{General}->{prefix});
$inf->{slapd}->{sbindir} = set_path_attribute($inf->{slapd}->{sbindir},
"@sbindir@",
$inf->{General}->{prefix});
$inf->{slapd}->{datadir} = set_path_attribute($inf->{slapd}->{datadir},
"@datadir@",
$inf->{General}->{prefix});
if (!defined($inf->{slapd}->{inst_dir})) {
$inf->{slapd}->{inst_dir} = "$inf->{General}->{ServerRoot}/slapd-$servid";
}
if (!defined($inf->{slapd}->{config_dir})) {
$inf->{slapd}->{config_dir} = "$inf->{General}->{prefix}@instconfigdir@/slapd-$servid";
}
$ENV{DS_CONFIG_DIR} = $inf->{slapd}->{config_dir};
if (!defined($inf->{slapd}->{schema_dir})) {
$inf->{slapd}->{schema_dir} = "$sysconfdir/@PACKAGE_NAME@/slapd-$servid/schema";
}
if (!defined($inf->{slapd}->{lock_dir})) {
if ("@with_fhs_opt@") {
$inf->{slapd}->{lock_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/lock";
} else {
$inf->{slapd}->{lock_dir} = "$localstatedir/lock/@PACKAGE_NAME@/slapd-$servid";
}
}
if (!defined($inf->{slapd}->{log_dir})) {
if ("@with_fhs_opt@") {
$inf->{slapd}->{log_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/log";
} else {
$inf->{slapd}->{log_dir} = "$localstatedir/log/@PACKAGE_NAME@/slapd-$servid";
}
}
if (!defined($inf->{slapd}->{run_dir})) {
if ("@with_fhs_opt@") {
$inf->{slapd}->{run_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/run";
} else {
$inf->{slapd}->{run_dir} = "$localstatedir/run/@PACKAGE_NAME@";
}
}
$ENV{DS_RUN_DIR} = $inf->{slapd}->{run_dir};
if (!defined($inf->{slapd}->{db_dir})) {
if ("@with_fhs_opt@") {
$inf->{slapd}->{db_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/db";
} else {
$inf->{slapd}->{db_dir} = "$localstatedir/lib/@PACKAGE_NAME@/slapd-$servid/db";
}
}
if (!defined($inf->{slapd}->{bak_dir})) {
if ("@with_fhs_opt@") {
$inf->{slapd}->{bak_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/bak";
} else {
$inf->{slapd}->{bak_dir} = "$localstatedir/lib/@PACKAGE_NAME@/slapd-$servid/bak";
}
}
$ENV{DS_BAK_DIR} = $inf->{slapd}->{bak_dir};
if (!defined($inf->{slapd}->{ldif_dir})) {
if ("@with_fhs_opt@") {
$inf->{slapd}->{ldif_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/ldif";
} else {
$inf->{slapd}->{ldif_dir} = "$localstatedir/lib/@PACKAGE_NAME@/slapd-$servid/ldif";
}
}
if (!defined($inf->{slapd}->{tmp_dir})) {
if ("@with_fhs_opt@") {
$inf->{slapd}->{tmp_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/tmp";
} else {
$inf->{slapd}->{tmp_dir} = "$localstatedir/tmp/@PACKAGE_NAME@/slapd-$servid";
}
}
$ENV{DS_TMP_DIR} = $inf->{slapd}->{tmp_dir};
if (!defined($inf->{slapd}->{cert_dir})) {
$inf->{slapd}->{cert_dir} = $inf->{slapd}->{config_dir};
}
return ();
}
sub createDSInstance {
my $inf = shift;
my @errs;
if (@errs = setDefaults($inf)) {
return @errs;
}
if (@errs = sanityCheckParams($inf)) {
return @errs;
}
if (@errs = makeDSDirs($inf)) {
return @errs;
}
if (@errs = createConfigFile($inf)) {
return @errs;
}
if (@errs = makeOtherConfigFiles($inf)) {
return @errs;
}
if (@errs = createInstanceScripts($inf)) {
return @errs;
}
if (@errs = installSchema($inf)) {
return @errs;
}
if (@errs = initDatabase($inf)) {
return @errs;
}
if (@errs = startServer($inf)) {
return @errs;
}
return @errs;
}
1;
# emacs settings
# Local Variables:
# mode:perl
# indent-tabs-mode: nil
# tab-width: 4
# End:
--- NEW FILE dscreate.map.in ---
# 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
#
# [Parameter resolution rules]
# * If the right-hand value is in ` (backquote), the value is eval'ed by perl.
# The output should be stored in $returnvalue to pass to the internal hash.
# * If the right-hand value is in " (doublequote), the value is passed as is.
# * If the right-hand value is not in any quote, the value should be found
# in either of the setup inf file (static) or the install inf file (dynamic).
# * Variables surrounded by @ (e.g., @configdir@) are replaced with the
# system path at the compile time.
# * The right-hand value can contain variables surrounded by % (e.g., %asid%)
# which refers the right-hand value (key) of this map file.
#
fqdn = FullMachineName
dsid = ServerIdentifier
ds_user = SuiteSpotUserID
ds_port = ServerPort
rootdn = RootDN
ds_suffix = Suffix
ds_bename = ds_bename
ds_passwd = HashedRootDNPwd
schema_dir = schema_dir
lock_dir = lock_dir
tmp_dir = tmp_dir
cert_dir = cert_dir
ldif_dir = ldif_dir
bak_dir = bak_dir
inst_dir = inst_dir
log_dir = log_dir
config_dir = config_dir
db_dir = db_dir
--- NEW FILE dsorgentries.map.in ---
# 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
#
# [Parameter resolution rules]
# * If the right-hand value is in ` (backquote), the value is eval'ed by perl.
# The output should be stored in $returnvalue to pass to the internal hash.
# * If the right-hand value is in " (doublequote), the value is passed as is.
# * If the right-hand value is not in any quote, the value should be found
# in either of the setup inf file (static) or the install inf file (dynamic).
# * Variables surrounded by @ (e.g., @configdir@) are replaced with the
# system path at the compile time.
# * The right-hand value can contain variables surrounded by % (e.g., %asid%)
# which refers the right-hand value (key) of this map file.
#
ds_suffix = Suffix
naming_value = naming_value
--- NEW FILE template-restart-slapd.in ---
#!/bin/sh
# Script that restarts the ns-slapd server.
# Exit status can be:
# 0: Server restarted successfully
# 1: Server could not be started
# 2: Server started successfully (was not running)
# 3: Server could not be stopped
server_already_stopped=0
{{INST-DIR}}/stop-slapd
status=$?
if [ $status -eq 1 ] ; then
exit 3;
else
if [ $status -eq 2 ] ; then
server_already_stopped=1
fi
fi
{{INST-DIR}}/start-slapd
status=$?
if [ $server_already_stopped -eq 1 ] && [ $status -eq 0 ] ; then
exit 2;
fi
exit $status
Index: DSMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSMigration.pm.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DSMigration.pm.in 12 Jul 2007 13:52:42 -0000 1.3
+++ DSMigration.pm.in 13 Jul 2007 18:35:32 -0000 1.4
@@ -50,6 +50,7 @@
use Migration;
use Util;
use Inf;
+use DSCreate;
# tempfiles
use File::Temp qw(tempfile tempdir);
@@ -91,6 +92,7 @@
'nsslapd-certdir' => 'nsslapd-certdir',
'nsslapd-ldifdir' => 'nsslapd-ldifdir',
'nsslapd-bakdir' => 'nsslapd-bakdir',
+ 'nsslapd-instancedir' => 'nsslapd-instancedir',
'nsslapd-ldapifilepath' => 'nsslapd-ldapifilepath',
'nsslapd-ldapilisten' => 'nsslapd-ldapilisten',
'nsslapd-ldapiautobind' => 'nsslapd-ldapiautobind',
@@ -187,19 +189,28 @@
return ("error_dbsrcdir_not_exist", $srcdir);
} else {
debug(1, "The destination directory $destdir already exists, copying files/dirs individually\n");
+ $! = 0;
+ debug(1, "Removing any existing db files in $destdir\n");
+ unlink glob("$destdir/*");
+ if ($!) {
+ return ("error_removing_temp_db_files", $destdir, $!);
+ }
foreach my $file (glob("$srcdir/*")) {
- debug(3, "Copying $file to $destdir\n");
if (-f $file) {
+ debug(3, "Copying $file to $destdir\n");
if (system ("cp -p $file $destdir")) {
return ('error_copying_dbfile', $file, $destdir, $?);
}
} elsif (-d $file && !$filesonly) {
+ debug(3, "Copying $file to $destdir\n");
if (system ("cp -p -r $file $destdir")) {
return ('error_copying_dbdir', $file, $destdir, $?);
}
}
}
}
+
+ return ();
}
# migrate all of the databases in an instance
@@ -216,11 +227,14 @@
my $foundldif;
for (glob("$mig->{oldsroot}/$inst/db/*.ldif")) {
my $dbname = basename($_, '.ldif');
- my @cmd = ("@serverdir@/$inst/ldif2db", "-n", $dbname, "-i", $_);
- debug(1, "migrateDatabases: executing command ", @cmd);
- if (system(@cmd)) {
- return ('error_importing_migrated_db', $_, $?);
+ my $cmd = "@serverdir@/$inst/ldif2db -n \"$dbname\" -i \"$_\"";
+ debug(1, "migrateDatabases: executing command $cmd\n");
+ $? = 0; # clear error condition
+ my $output = `$cmd 2>&1`;
+ if ($?) {
+ return ('error_importing_migrated_db', $_, $?, $output);
}
+ debug(1, $output);
$foundldif = 1;
}
@@ -284,13 +298,13 @@
my $srcdir = $dir || "$olddefault/db/$cn";
my $newent = $dest->search($ent->getDN(), "base", "(objectclass=*)");
my $newdbdir = $newent->getValues('nsslapd-directory') ||
- "@localstatedir@/lib/$mig->{pkgname}/$inst/db";
+ "@localstatedir@/lib/$mig->{pkgname}/$inst/db/$cn";
if (-d $srcdir and ($srcdir !~ /^$olddefault/)) {
debug(2, "Not copying database indexes from [$srcdir]\n");
} else {
# replace the old sroot value with the actual physical location on the target/dest
$srcdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
- if (@errs = copyDatabaseDirs($srcdir, "$newdbdir/$cn")) {
+ if (@errs = copyDatabaseDirs($srcdir, "$newdbdir")) {
return @errs;
}
}
@@ -317,9 +331,14 @@
# replace the old sroot value with the actual physical location on the target/dest
$oldcldir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
my $newcldir = $newent->getValues('nsslapd-changelogdir');
- copyDatabaseDirs($oldcldir, $newcldir);
+ my @errs = copyDatabaseDirs($oldcldir, $newcldir);
+ if (@errs) {
+ return @errs;
+ }
}
}
+
+ return ();
}
sub fixAttrsInEntry {
@@ -358,27 +377,37 @@
# iterate through the attr lists
my $cn = lc $new->getValues("cn");
foreach my $attr (keys %inoldonly, keys %innewonly, @attrs) {
+ debug(3, "mergeEntries: merging entry ", $old->getDN(), " attr $attr\n");
my $lcattr = lc $attr;
if ($ignoreOld{$lcattr}) {
+ debug(3, "mergeEntries: ignoring old invalid or obsolete attr $attr\n");
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, $mig, $inst));
+ my $oldval = $old->getValues($attr);
+ my $newval = &{$transformAttr{$lcattr}}($old, $attr, $mig, $inst);
+ $new->setValues($attr, $newval);
+ debug(3, "mergeEntries: transformed old value $oldval to $newval\n");
}
} elsif ($cn eq "internationalization plugin" and $lcattr eq "nsslapd-pluginarg0") {
+ debug(3, "mergeEntries: using new value of internationalization plugin nsslapd-pluginarg0\n");
next; # use the new value of this path name
} elsif ($cn eq "referential integrity postoperation" and $lcattr eq "nsslapd-pluginarg1") {
+ debug(3, "mergeEntries: using new value of referential integrity postoperation nsslapd-pluginarg1\n");
next; # use the new value of this path name
} elsif ($innewonly{$attr}) {
+ debug(3, "mergeEntries: removing attr $attr from new entry\n");
$new->remove($attr); # in new but not old - just remove it
} else {
+ my $oldval = $old->getValues($attr);
+ my $newval = $new->getValues($attr);
$new->setValues($attr, $old->getValues($attr)); # use old value
+ debug(3, "mergeEntries: using old val $oldval instead of new val $newval\n");
}
}
}
-
my @allattrlist = ('*', 'aci', 'createTimestamp', 'creatorsName',
'modifyTimestamp', 'modifiersName');
@@ -598,14 +627,14 @@
}
# create the new instance
- my ($rc, $output) = createDSInstance($inf, \@errs);
+ @errs = createDSInstance($inf);
unlink($inf->{filename});
- if ($rc) {
+ if (@errs) {
$mig->msg(@errs);
- $mig->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
+ $mig->msg($FATAL, 'error_creating_dsinstance', $inst);
return 0;
} else {
- $mig->msg('created_dsinstance', $output);
+ $mig->msg('created_dsinstance', $inst);
}
my $src = new FileConn("$oldconfigdir/dse.ldif", 1); # read-only
@@ -627,3 +656,10 @@
# Mandatory TRUE return value.
#
1;
+
+# emacs settings
+# Local Variables:
+# mode:perl
+# indent-tabs-mode: nil
+# tab-width: 4
+# End:
Index: FileConn.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/FileConn.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileConn.pm 12 Jul 2007 13:52:42 -0000 1.2
+++ FileConn.pm 13 Jul 2007 18:35:32 -0000 1.3
@@ -46,6 +46,8 @@
use Mozilla::LDAP::Utils qw(normalizeDN);
use Mozilla::LDAP::LDIF;
+use Carp;
+
require Exporter;
@ISA = qw(Exporter Mozilla::LDAP::Conn);
@EXPORT = qw();
@@ -55,11 +57,16 @@
my $class = shift;
my $filename = shift;
my $readonly = shift;
+ my @namingContexts = @_;
my $self = {};
$self = bless $self, $class;
$self->{readonly} = $readonly;
+ for (@namingContexts) {
+ $self->setNamingContext($_);
+ }
+ $self->setNamingContext(""); # root DSE
$self->read($filename);
return $self;
@@ -86,16 +93,31 @@
return;
}
- open( MYLDIF, "$filename" ) || die "Can't open $filename: $!";
+ open( MYLDIF, "$filename" ) || confess "Can't open $filename: $!";
my $in = new Mozilla::LDAP::LDIF(*MYLDIF);
+ $self->{reading} = 1;
while ($ent = readOneEntry $in) {
if (!$self->add($ent)) {
- die "Error: could not add entry ", $ent->getDN(), ":", $self->getErrorString();
+ confess "Error: could not add entry ", $ent->getDN(), ":", $self->getErrorString();
}
}
+ delete $self->{reading};
close( MYLDIF );
}
+sub setNamingContext {
+ my $self = shift;
+ my $nc = shift;
+ my $ndn = normalizeDN($nc);
+ $self->{namingContexts}->{$ndn} = $ndn;
+}
+
+sub isNamingContext {
+ my $self = shift;
+ my $ndn = shift;
+ return exists($self->{namingContexts}->{$ndn});
+}
+
# return all nodes below the given node
sub iterate {
my $self = shift;
@@ -152,12 +174,16 @@
$filename = $self->{filename};
}
- if (!$self->{filename} or $self->{readonly}) {
+ if (!$self->{filename} or $self->{readonly} or $self->{reading}) {
return;
}
- open( MYLDIF, ">$filename" ) || die "Can't write $filename: $!";
+ open( MYLDIF, ">$filename" ) || confess "Can't write $filename: $!";
$self->iterate("", LDAP_SCOPE_SUBTREE, \&writecb, \*MYLDIF);
+ for (keys %{$self->{namingContexts}}) {
+ next if (!$_); # skip "" - we already did that
+ $self->iterate($_, LDAP_SCOPE_SUBTREE, \&writecb, \*MYLDIF);
+ }
close( MYLDIF );
}
@@ -307,9 +333,30 @@
return $self->nextEntry();
}
+sub cloneEntry {
+ my $src = shift;
+ if (!$src) {
+ return undef;
+ }
+ my $dest = new Mozilla::LDAP::Entry();
+ $dest->setDN($src->getDN());
+ for (keys %{$src}) {
+ if (ref($src->{$_})) {
+ my @copyary = @{$src->{$_}};
+ $dest->{$_} = [ @copyary ]; # make a deep copy
+ } else {
+ $dest->{$_} = $src->{$_};
+ }
+ }
+
+ return $dest;
+}
+
+# have to return a copy of the entry - disallow inplace updates
sub nextEntry {
my $self = shift;
- return shift @{$self->{entries}};
+ my $ent = shift @{$self->{entries}};
+ return cloneEntry($ent);
}
sub add {
@@ -320,10 +367,9 @@
my $parentdn = getParentDN($dn);
my $nparentdn = normalizeDN($parentdn);
-
$self->setErrorCode(0);
- # special case of root DSE
- if (!$ndn and exists($self->{$ndn}) and
+ # special case of naming context - has no parent
+ if ($self->isNamingContext($ndn) and
!exists($self->{$ndn}->{data})) {
$self->{$ndn}->{data} = $entry;
$self->write();
@@ -357,6 +403,8 @@
my $dn = $entry->getDN();
my $ndn = normalizeDN($dn);
+ confess "Attempt to modify read only $self->{filename} entry $dn" if ($self->{readonly});
+
$self->setErrorCode(0);
if (!exists($self->{$ndn})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
@@ -373,6 +421,8 @@
my $self = shift;
my $dn = shift;
+ confess "Attempt to modify read only $self->{filename} entry $dn" if ($self->{readonly});
+
if (ref($dn)) {
$dn = $dn->getDN(); # an Entry
}
Index: Migration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Migration.pm.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Migration.pm.in 12 Jul 2007 13:52:42 -0000 1.2
+++ Migration.pm.in 13 Jul 2007 18:35:32 -0000 1.3
@@ -217,7 +217,7 @@
$self->{pkgname} = $pkgname;
$self->{oldsroot} = $oldsroot || "/opt/$oldpkgname";
- $self->{actualsroot} = $actualsroot || $oldsroot;
+ $self->{actualsroot} = $actualsroot || $self->{oldsroot};
$self->{silent} = $silent;
$self->{inffile} = $inffile;
$self->{keep} = $keep;
Index: Util.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Util.pm.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Util.pm.in 12 Jul 2007 13:52:42 -0000 1.7
+++ Util.pm.in 13 Jul 2007 18:35:32 -0000 1.8
@@ -47,18 +47,19 @@
@ISA = qw(Exporter);
@EXPORT = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword debug createDSInstance createInfFromConfig
- isValidServerID);
+ getHashedPassword debug createInfFromConfig
+ isValidServerID isValidUser makePaths);
@EXPORT_OK = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword debug createDSInstance createInfFromConfig
- isValidServerID);
+ getHashedPassword debug createInfFromConfig
+ isValidServerID isValidUser makePaths);
use strict;
use Socket;
use File::Temp qw(tempfile tempdir);
+use File::Basename qw(dirname);
$Util::debuglevel = 0;
# use like this:
@@ -131,7 +132,7 @@
return ("dialog_ssuser_error", $user);
}
if (!$nuid) {
- return ("dialog_ssuser_root_warning");
+ debug(0, "Warning: using root as the server user id. You are strongly encouraged to use a non-root user.\n");
}
}
@@ -367,13 +368,17 @@
my $attr;
foreach $attr ( @addtypes )
{
- debug(3, "Adding attr=$attr values=" . $aentry->getValues($attr) . " to entry $aentry->{dn}\n");
- $sentry->addValue( $attr, $aentry->getValues($attr) );
+ foreach my $val ($aentry->getValues($attr))
+ {
+ debug(3, "Adding attr=$attr value=$val to entry $aentry->{dn}\n");
+ $sentry->addValue( $attr, $val );
+ }
}
foreach $attr ( @reptypes )
{
+ my @vals = $aentry->getValues($attr);
debug(3, "Replacing attr=$attr values=" . $aentry->getValues($attr) . " to entry $aentry->{dn}\n");
- $sentry->setValues($attr, $aentry->getValues($attr));
+ $sentry->setValues($attr, @vals);
}
foreach $attr ( @deltypes )
{
@@ -761,23 +766,6 @@
return $hashedpwd;
}
-sub createDSInstance {
- my $inf = shift;
- my $errs = shift; # unused for now
-# 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 = "@bindir(a)/ds_newinst.pl";
- }
- if (! -x $ds_newinst) {
- $ds_newinst = "ds_newinst.pl"; # just get from path
- }
- $? = 0; # clear error condition
- my $output = `$ds_newinst $inf->{filename}`;
- return ($?, $output);
-}
-
# this creates an Inf suitable for passing to createDSInstance
# except that it has a bogus suffix
sub createInfFromConfig {
@@ -787,35 +775,93 @@
my $fname = "$configdir/dse.ldif";
my $id;
($id = $inst) =~ s/^slapd-//;
- if (!open( DSELDIF, "$fname" )) {
+ if (! -f $fname) {
push @{$errs}, "error_opening_dseldif", $fname, $!;
return 0;
}
+ my $conn = new FileConn($fname, 1);
+
+ my $ent = $conn->search("cn=config", "base", "(objectclass=*)");
+ if (!$ent) {
+ push @{$errs}, "error_opening_dseldif", $fname, $!;
+ return 0;
+ }
+
my ($outfh, $inffile) = tempfile(SUFFIX => '.inf');
- my $in = new Mozilla::LDAP::LDIF(*DSELDIF) ;
- while (my $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;
- }
+ print $outfh "[General]\n";
+ print $outfh "FullMachineName = ", $ent->getValues('nsslapd-localhost'), "\n";
+ print $outfh "SuiteSpotUserID = ", $ent->getValues('nsslapd-localuser'), "\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 "start_server= 0\n";
+
+ my $suffix;
+ my $ent = $conn->search("cn=ldbm database,cn=plugins,cn=config",
+ "one", "(objectclass=*)");
+ if (!$ent) {
+ push @{$errs}, "error_opening_dseldif", $fname, $!;
+ close $outfh;
+ $conn->close();
+ return 0;
+ }
+ # use the userRoot suffix if available
+ while ($ent) {
+ $suffix = $ent->getValues('nsslapd-suffix');
+ last if ($ent->hasValue('cn', 'userRoot', 1));
+ $ent = $conn->nextEntry();
}
+ $conn->close();
+
+ print $outfh "Suffix = $suffix\n";
close $outfh;
- close DSELDIF;
my $inf = new Inf($inffile);
return $inf;
}
+# like File::Path mkpath, except we can set the owner and perm
+# of each new path and parent path created
+sub makePaths {
+ my ($path, $mode, $user, $group) = @_;
+ my $uid = getpwnam $user;
+ my $gid = -1; # default to leave it alone
+
+ if ($group) {
+ $gid = getgrnam $group;
+ }
+ my @dirnames = ($path);
+ my $parent = $path;
+ for ($parent = dirname($parent);
+ $parent and ($parent ne "/");
+ $parent = dirname($parent)) {
+ unshift @dirnames, $parent;
+ }
+ for (@dirnames) {
+ next if (-d $_);
+ $! = 0; # clear
+ mkdir $_, $mode;
+ if ($!) {
+ return ('error_creating_directory', $_, $!);
+ }
+ chown $uid, $gid, $_;
+ if ($!) {
+ return ('error_chowning_directory', $_, $!);
+ }
+ debug(1, "makePaths: created directory $_ mode $mode user $user group $group\n");
+ }
+
+ return ();
+}
+
1;
+
+# emacs settings
+# Local Variables:
+# mode:perl
+# indent-tabs-mode: nil
+# tab-width: 4
+# End:
Index: migrate-ds.pl.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/migrate-ds.pl.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- migrate-ds.pl.in 29 Jun 2007 21:12:21 -0000 1.1
+++ migrate-ds.pl.in 13 Jul 2007 18:35:32 -0000 1.2
@@ -61,5 +61,17 @@
my $mig = new Migration($res);
$mig->msg('begin_ds_migration', $mig->{oldsroot});
-migrateDS($mig);
+if (!migrateDS($mig)) {
+ exit 1;
+}
$mig->msg('end_ds_migration');
+
+END {
+ if ($mig) {
+ if (!$mig->{keep}) {
+ unlink $mig->{inffile};
+ }
+
+ $mig->doExit();
+ }
+}
Index: migrate-ds.res
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/migrate-ds.res,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- migrate-ds.res 12 Jul 2007 13:52:42 -0000 1.2
+++ migrate-ds.res 13 Jul 2007 18:35:32 -0000 1.3
@@ -4,10 +4,11 @@
instance_already_exists = The target directory server instance already exists at %s. Skipping migration. Note that if you want to migrate the old instance you will have to first remove the new one of the same name.\n\n
error_reading_entry = Could not read the entry '%s'. Error: %s\n
error_updating_merge_entry = Could not %s the migrated entry '%s' in the target directory server. Error: %s\n
-error_importing_migrated_db = Could not import the LDIF file '%s' for the migrated database. Error: %s. Please check the directory server error log for more details.\n
+error_importing_migrated_db = Could not import the LDIF file '%s' for the migrated database. Error: %s. Output: %s\n
error_reading_olddbconfig = Could not read the old database configuration information. Error: %s\n
error_migrating_schema = Could not copy old schema file '%s'. Error: %s\n
error_copying_dbdir = Could not copy database directory '%s' to '%s'. Error: %s\n
error_copying_dbfile = Could not copy database file '%s' to '%s'. Error: %s\n
error_dbsrcdir_not_exist = Could not copy from the database source directory '%s' because it does not exist. Please check your configuration.\n
error_no_instances = Could not find any instances in the old directory '%s' to migrate.\n
+error_removing_temp_db_files = Could not remove the temporary db files in '%s' to clear the directory in preparation for the migrated db files. Error: %s\n
Index: setup-ds.pl.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.pl.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- setup-ds.pl.in 12 Jul 2007 13:52:42 -0000 1.5
+++ setup-ds.pl.in 13 Jul 2007 18:35:32 -0000 1.6
@@ -47,6 +47,7 @@
use Resource;
use DialogManager;
use Util;
+use DSCreate;
my $res = new Resource("@propertydir(a)/setup-ds.res");
@@ -70,13 +71,14 @@
$setup->{inf}->write();
}
-my @errs;
-my ($rc, $output) = createDSInstance($setup->{inf}, \@errs);
-if ($rc) {
+my @errs = createDSInstance($setup->{inf});
+if (@errs) {
$setup->msg(@errs);
- $setup->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
+ $setup->msg($FATAL, 'error_creating_dsinstance',
+ $setup->{inf}->{slapd}->{ServerIdentifier});
} else {
- $setup->msg('created_dsinstance', $output);
+ $setup->msg('created_dsinstance',
+ $setup->{inf}->{slapd}->{ServerIdentifier});
}
END {
Index: setup-ds.res.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.res.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- setup-ds.res.in 12 Jul 2007 13:52:42 -0000 1.7
+++ setup-ds.res.in 13 Jul 2007 18:35:32 -0000 1.8
@@ -87,8 +87,8 @@
error_creating_suffix = Could not create the suffix '%s'. Error: %s\n\n
setup_exiting = Exiting . . .\nLog file is '%s'\n\n
-error_creating_dsinstance = Error: Could not create directory server instance. Error code %s. Output:\n%s\n
-created_dsinstance = Your new DS instance was successfully created. Output:\n%s\n
+error_creating_dsinstance = Error: Could not create directory server instance '%s'.\n
+created_dsinstance = Your new DS instance '%s' was successfully created.\n
no_mapvalue_for_key = The map value '%s' for key '%s' did not map to a value in any of the given information files.\n
error_opening_ldiftmpl = Could not open the LDIF template file '%s'. Error: %s\n
error_mapping_token_ldiftmpl = The entry '%s' in LDIF file '%s' contains a token '%s' for which there is no mapper.\nPlease check the file and your mapper to make sure all tokens are handled correctly.\n
@@ -96,7 +96,6 @@
error_adding_entry = Error adding entry '%s'. Error: %s\n
error_updating_entry = Error updating entry '%s'. Error: %s\n
-
error_invalid_param = The parameter '%s' has an invalid value '%s'.\n
error_port_available = The port number '%s' is not available for use. This may be due to an\
invalid port number, or the port already being in use by another\
@@ -104,3 +103,19 @@
ServerPort. Error: $!\n
error_invalid_serverid = The ServerIdentifier '%s' contains invalid characters. It must\
contain only alphanumeric characters and the following: #%,.:@_-\n
+error_opening_scripttmpl = Could not open the script template file '%s'. Error: %s\n
+error_creating_directory = Could not create directory '%s'. Error: %s\n
+error_chowning_directory = Could not change ownership of directory '%s' to userid '%s': Error: %s\n
+error_chowning_file = Could not change ownership of '%s' to userid '%s': Error: %s\n
+error_chmoding_file = Could not change permissions of '%s': Error: %s\n
+error_chgrping_directory = Could not change group of directory '%s' to group '%s': Error: %s\n
+error_creating_file = Could not create file '%s'. Error: %s\n
+error_copying_file = Could not copy file '%s' to '%s'. Error: %s\n
+error_enabling_feature = Could not enable the directory server feature '%s'. Error: %s\n
+error_importing_ldif = Could not import LDIF file '%s'. Error: %s. Output: %s\n
+error_starting_server = Could not start the directory server using command '%s'. The last line from the error log was '%s'. Error: %s\n
+error_missing_port_and_ldapi = Either ServerPort or ldapifilepath must be specified. The server must listen to something.\n
+error_missing_port = No ServerPort specified. The server must have a port number to listen to (default 389).\n
+error_server_already_exists = Error: the server already exists at '%s'\
+Please remove it first if you really want to recreate it,\
+or use a different ServerIdentifier to create another instance.\n
16 years, 9 months
[Fedora-directory-commits] ldapserver Makefile.am, 1.48, 1.49 configure.ac, 1.33, 1.34 aclocal.m4, 1.40, 1.41 configure, 1.51, 1.52 missing, 1.30, 1.31 install-sh, 1.30, 1.31 depcomp, 1.30, 1.31 compile, 1.30, 1.31 config.sub, 1.29, 1.30 config.guess, 1.29, 1.30 Makefile.in, 1.57, 1.58
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31095/ldapserver
Modified Files:
Makefile.am configure.ac aclocal.m4 configure missing
install-sh depcomp compile config.sub config.guess Makefile.in
Log Message:
Resolves: bug 248145
Bug Description: Replace ds_newinst binary with perl script
Reviewed by: nhosoi (Thanks!)
Fix Description: The time has come. We can finally get rid of the instance creation C code
once and for all. I've created a DSCreate module that has all of the functionality of the old
create_instance.c code, along with a few items from ldap/admin/lib. The way it works is
this: it first creates the dse.ldif file using template-dse.ldif and the suffix-db template to
create the initial db and suffix. It then adds additional optional configuration depending
on what optional features have been enabled. It creates other config files and copies in
the schema. It then initializes the database. It uses a template file based on the type of
entry implied by the suffix, then adds the default ACIs. If the user chose to do so, it
will also create the ou=people, ou=groups, etc. entries. The user can also supply an LDIF
file which will be used to populate the initial database, in which case none of the default
entries or ACIs will be used. It then starts the server (if desired).
I had to create a function makePaths that works like mkdir -p except that it will chown,
chgrp, and chmod all paths created.
I had to change the other places where instance creation was called to use the new
calling semantics. ds_create changed quite a bit, since it can just use an Inf to pass in the
information instead of calling ds_newinst as a CGI program.
I had to change FileConn to add support for namingContexts (i.e. entries with no parent),
and to have it write each change each time, and to return copies of entries when searching,
to avoid modifying the tree in place. This makes it act much more like LDAP.
I found and fixed a few bugs in Migration along the way that were revealed while integrating
the new DSCreate code.
Platforms tested: RHEL4, FC6
Flag Day: Yes. New instance creation code and autotool changes.
Doc impact: no
Index: Makefile.am
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.am,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- Makefile.am 4 Jul 2007 01:28:17 -0000 1.48
+++ Makefile.am 13 Jul 2007 18:35:32 -0000 1.49
@@ -98,13 +98,16 @@
# this is how to add optional plugins
if enable_pam_passthru
LIBPAM_PASSTHRU_PLUGIN = libpam-passthru-plugin.la
+enable_pam_passthru = 1
endif
if enable_dna
LIBDNA_PLUGIN = libdna-plugin.la
+enable_dna = 1
endif
if enable_bitwise
LIBBITWISE_PLUGIN = libbitwise-plugin.la
+enable_bitwise = 1
endif
serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \
@@ -145,6 +148,14 @@
ldap/ldif/template-pampta.ldif \
ldap/ldif/template-dnaplugin.ldif \
ldap/ldif/template-bitwise.ldif \
+ ldap/ldif/template-dse.ldif \
+ ldap/ldif/template-org.ldif \
+ ldap/ldif/template-domain.ldif \
+ ldap/ldif/template-state.ldif \
+ ldap/ldif/template-locality.ldif \
+ ldap/ldif/template-country.ldif \
+ ldap/ldif/template-orgunit.ldif \
+ ldap/ldif/template-baseacis.ldif \
$(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen-FamilyNames \
$(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen-GivenNames \
$(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen-OrgUnits
@@ -201,7 +212,8 @@
ldap/admin/src/scripts/Setup.pm \
ldap/admin/src/scripts/Migration.pm \
ldap/admin/src/scripts/DSMigration.pm \
- ldap/admin/src/scripts/FileConn.pm
+ ldap/admin/src/scripts/FileConn.pm \
+ ldap/admin/src/scripts/DSCreate.pm
property_DATA = ldap/admin/src/scripts/setup-ds.res \
ldap/admin/src/scripts/migrate-ds.res
@@ -217,6 +229,7 @@
ldap/admin/src/scripts/template-saveconfig \
ldap/admin/src/scripts/template-start-slapd \
ldap/admin/src/scripts/template-stop-slapd \
+ ldap/admin/src/scripts/template-restart-slapd \
ldap/admin/src/scripts/template-suffix2instance \
ldap/admin/src/scripts/template-vlvindex \
ldap/admin/src/scripts/template-bak2db.pl \
@@ -236,7 +249,9 @@
init_SCRIPTS = wrappers/$(PACKAGE_NAME)
-inf_DATA = ldap/admin/src/slapd.inf
+inf_DATA = ldap/admin/src/slapd.inf \
+ ldap/admin/src/scripts/dscreate.map \
+ ldap/admin/src/scripts/dsorgentries.map
#////////////////////////////////////////////////////////////////
#
@@ -938,6 +953,7 @@
#------------------------
if enable_ldapi
GETSOCKETPEER=ldap/servers/slapd/getsocketpeer.c
+ enable_ldapi = 1
endif
ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \
@@ -1034,20 +1050,29 @@
-e 's,@configdir\@,$(configdir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
-e 's,@localstatedir\@,$(localstatedir),g' \
+ -e 's,@infdir\@,$(infdir),g' \
+ -e 's,@templatedir\@,$(sampledatadir),g' \
-e 's,@package_name\@,$(PACKAGE_NAME),g' \
-e 's,@instconfigdir\@,$(instconfigdir),g' \
+ -e 's,@enable_ldapi\@,$(enable_ldapi),g' \
+ -e 's,@enable_pam_passthru\@,$(enable_pam_passthru),g' \
+ -e 's,@enable_bitwise\@,$(enable_bitwise),g' \
+ -e 's,@enable_dna\@,$(enable_dna),g' \
+ -e 's,@enable_autobind\@,$(enable_autobind),g' \
-e 's,@ECHO_N\@,$(ECHO_N),g' \
-e 's,@ECHO_C\@,$(ECHO_C),g' \
-e 's,@brand\@,$(brand),g' \
-e 's,@capbrand\@,$(capbrand),g' \
-e 's,@vendor\@,$(vendor),g' \
+ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
-e 's,@BUILDNUM\@,$(BUILDNUM),g' \
-e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
-e 's,@perldir\@,$(perldir),g' \
-e 's,@defaultuser\@,$(defaultuser),g' \
- -e 's,@defaultgroup\@,$(defaultgroup),g'
+ -e 's,@defaultgroup\@,$(defaultgroup),g' \
+ -e 's,@with_fhs_opt\@,@with_fhs_opt@,g'
else
fixupcmd = sed \
-e 's,@bindir\@,$(bindir),g' \
@@ -1070,20 +1095,29 @@
-e 's,@configdir\@,$(configdir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
-e 's,@localstatedir\@,$(localstatedir),g' \
+ -e 's,@infdir\@,$(infdir),g' \
+ -e 's,@templatedir\@,$(sampledatadir),g' \
-e 's,@package_name\@,$(PACKAGE_NAME),g' \
-e 's,@instconfigdir\@,$(instconfigdir),g' \
+ -e 's,@enable_ldapi\@,$(enable_ldapi),g' \
+ -e 's,@enable_pam_passthru\@,$(enable_pam_passthru),g' \
+ -e 's,@enable_bitwise\@,$(enable_bitwise),g' \
+ -e 's,@enable_dna\@,$(enable_dna),g' \
+ -e 's,@enable_autobind\@,$(enable_autobind),g' \
-e 's,@ECHO_N\@,$(ECHO_N),g' \
-e 's,@ECHO_C\@,$(ECHO_C),g' \
-e 's,@brand\@,$(brand),g' \
-e 's,@capbrand\@,$(capbrand),g' \
-e 's,@vendor\@,$(vendor),g' \
+ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
-e 's,@BUILDNUM\@,$(BUILDNUM),g' \
-e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
-e 's,@perldir\@,$(perldir),g' \
-e 's,@defaultuser\@,$(defaultuser),g' \
- -e 's,@defaultgroup\@,$(defaultgroup),g'
+ -e 's,@defaultgroup\@,$(defaultgroup),g' \
+ -e 's,@with_fhs_opt\@,@with_fhs_opt@,g'
endif
%: %.in
Index: configure.ac
===================================================================
RCS file: /cvs/dirsec/ldapserver/configure.ac,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- configure.ac 21 Jun 2007 21:57:22 -0000 1.33
+++ configure.ac 13 Jul 2007 18:35:32 -0000 1.34
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
# This version is the version returned by ns-slapd -v
-AC_INIT([fedora-ds], [1.1.0a3], [http://bugzilla.redhat.com/])
+AC_INIT([fedora-ds], [1.1.0a4], [http://bugzilla.redhat.com/])
# AC_CONFIG_HEADER must be called right after AC_INIT.
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.9 foreign subdir-objects])
Index: configure
===================================================================
RCS file: /cvs/dirsec/ldapserver/configure,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- configure 4 Jul 2007 01:28:17 -0000 1.51
+++ configure 13 Jul 2007 18:35:32 -0000 1.52
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for fedora-ds 1.1.0a3.
+# Generated by GNU Autoconf 2.59 for fedora-ds 1.1.0a4.
#
# Report bugs to <http://bugzilla.redhat.com/>.
#
@@ -423,8 +423,8 @@
# Identity of this package.
PACKAGE_NAME='fedora-ds'
PACKAGE_TARNAME='fedora-ds'
-PACKAGE_VERSION='1.1.0a3'
-PACKAGE_STRING='fedora-ds 1.1.0a3'
+PACKAGE_VERSION='1.1.0a4'
+PACKAGE_STRING='fedora-ds 1.1.0a4'
PACKAGE_BUGREPORT='http://bugzilla.redhat.com/'
# Factoring default headers for most tests.
@@ -465,7 +465,7 @@
#endif"
ac_default_prefix=/opt/$PACKAGE_NAME
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CP!
P CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_bitwise_TRUE enable_bitwise_FALSE configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir infdir defaultuser defaultgroup instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG PACKAGE_BASE_VERSION nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link brand capbrand vendor LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CP!
P CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE enable_ldapi_TRUE enable_ldapi_FALSE enable_bitwise_TRUE enable_bitwise_FALSE with_fhs_opt configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir perldir infdir defaultuser defaultgroup instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG PACKAGE_BASE_VERSION nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link brand capbrand vendor LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -954,7 +954,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures fedora-ds 1.1.0a3 to adapt to many kinds of systems.
+\`configure' configures fedora-ds 1.1.0a4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1020,7 +1020,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of fedora-ds 1.1.0a3:";;
+ short | recursive ) echo "Configuration of fedora-ds 1.1.0a4:";;
esac
cat <<\_ACEOF
@@ -1201,7 +1201,7 @@
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-fedora-ds configure 1.1.0a3
+fedora-ds configure 1.1.0a4
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1215,7 +1215,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by fedora-ds $as_me 1.1.0a3, which was
+It was created by fedora-ds $as_me 1.1.0a4, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1861,7 +1861,7 @@
# Define the identity of the package.
PACKAGE='fedora-ds'
- VERSION='1.1.0a3'
+ VERSION='1.1.0a4'
cat >>confdefs.h <<_ACEOF
@@ -23119,6 +23119,7 @@
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
+
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
@@ -25680,7 +25681,7 @@
} >&5
cat >&5 <<_CSEOF
-This file was extended by fedora-ds $as_me 1.1.0a3, which was
+This file was extended by fedora-ds $as_me 1.1.0a4, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -25743,7 +25744,7 @@
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-fedora-ds config.status 1.1.0a3
+fedora-ds config.status 1.1.0a4
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -26022,6 +26023,7 @@
s,@enable_ldapi_FALSE@,$enable_ldapi_FALSE,;t t
s,@enable_bitwise_TRUE@,$enable_bitwise_TRUE,;t t
s,@enable_bitwise_FALSE@,$enable_bitwise_FALSE,;t t
+s,@with_fhs_opt@,$with_fhs_opt,;t t
s,@configdir@,$configdir,;t t
s,@sampledatadir@,$sampledatadir,;t t
s,@propertydir@,$propertydir,;t t
Index: Makefile.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.in,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- Makefile.in 4 Jul 2007 01:28:17 -0000 1.57
+++ Makefile.in 13 Jul 2007 18:35:32 -0000 1.58
@@ -986,6 +986,7 @@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
vendor = @vendor@
+with_fhs_opt = @with_fhs_opt@
# look for included m4 files in the ./m4/ directory
ACLOCAL_AMFLAGS = -I m4
@@ -1045,8 +1046,11 @@
# this is how to add optional plugins
@enable_pam_passthru_TRUE@LIBPAM_PASSTHRU_PLUGIN = libpam-passthru-plugin.la
+@enable_pam_passthru_TRUE@enable_pam_passthru = 1
@enable_dna_TRUE@LIBDNA_PLUGIN = libdna-plugin.la
+@enable_dna_TRUE@enable_dna = 1
@enable_bitwise_TRUE@LIBBITWISE_PLUGIN = libbitwise-plugin.la
+@enable_bitwise_TRUE@enable_bitwise = 1
serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \
libback-ldbm.la libchainingdb-plugin.la libcos-plugin.la libdes-plugin.la \
libdistrib-plugin.la libhttp-client-plugin.la libcollation-plugin.la \
@@ -1082,6 +1086,14 @@
ldap/ldif/template-pampta.ldif \
ldap/ldif/template-dnaplugin.ldif \
ldap/ldif/template-bitwise.ldif \
+ ldap/ldif/template-dse.ldif \
+ ldap/ldif/template-org.ldif \
+ ldap/ldif/template-domain.ldif \
+ ldap/ldif/template-state.ldif \
+ ldap/ldif/template-locality.ldif \
+ ldap/ldif/template-country.ldif \
+ ldap/ldif/template-orgunit.ldif \
+ ldap/ldif/template-baseacis.ldif \
$(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen-FamilyNames \
$(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen-GivenNames \
$(srcdir)/ldap/servers/slapd/tools/rsearch/scripts/dbgen-OrgUnits
@@ -1138,7 +1150,8 @@
ldap/admin/src/scripts/Setup.pm \
ldap/admin/src/scripts/Migration.pm \
ldap/admin/src/scripts/DSMigration.pm \
- ldap/admin/src/scripts/FileConn.pm
+ ldap/admin/src/scripts/FileConn.pm \
+ ldap/admin/src/scripts/DSCreate.pm
property_DATA = ldap/admin/src/scripts/setup-ds.res \
ldap/admin/src/scripts/migrate-ds.res
@@ -1154,6 +1167,7 @@
ldap/admin/src/scripts/template-saveconfig \
ldap/admin/src/scripts/template-start-slapd \
ldap/admin/src/scripts/template-stop-slapd \
+ ldap/admin/src/scripts/template-restart-slapd \
ldap/admin/src/scripts/template-suffix2instance \
ldap/admin/src/scripts/template-vlvindex \
ldap/admin/src/scripts/template-bak2db.pl \
@@ -1172,7 +1186,10 @@
$(srcdir)/ldap/admin/src/scripts/template-migrateTo7
init_SCRIPTS = wrappers/$(PACKAGE_NAME)
-inf_DATA = ldap/admin/src/slapd.inf
+inf_DATA = ldap/admin/src/slapd.inf \
+ ldap/admin/src/scripts/dscreate.map \
+ ldap/admin/src/scripts/dsorgentries.map
+
#////////////////////////////////////////////////////////////////
#
@@ -1847,6 +1864,7 @@
# ns-slapd
#------------------------
@enable_ldapi_TRUE@GETSOCKETPEER = ldap/servers/slapd/getsocketpeer.c
+@enable_ldapi_TRUE@enable_ldapi = 1
ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \
ldap/servers/slapd/auth.c \
ldap/servers/slapd/bind.c \
@@ -1931,20 +1949,29 @@
@BUNDLE_FALSE@ -e 's,@configdir\@,$(configdir),g' \
@BUNDLE_FALSE@ -e 's,@sysconfdir\@,$(sysconfdir),g' \
@BUNDLE_FALSE@ -e 's,@localstatedir\@,$(localstatedir),g' \
+@BUNDLE_FALSE@ -e 's,@infdir\@,$(infdir),g' \
+@BUNDLE_FALSE@ -e 's,@templatedir\@,$(sampledatadir),g' \
@BUNDLE_FALSE@ -e 's,@package_name\@,$(PACKAGE_NAME),g' \
@BUNDLE_FALSE@ -e 's,@instconfigdir\@,$(instconfigdir),g' \
+@BUNDLE_FALSE@ -e 's,@enable_ldapi\@,$(enable_ldapi),g' \
+@BUNDLE_FALSE@ -e 's,@enable_pam_passthru\@,$(enable_pam_passthru),g' \
+@BUNDLE_FALSE@ -e 's,@enable_bitwise\@,$(enable_bitwise),g' \
+@BUNDLE_FALSE@ -e 's,@enable_dna\@,$(enable_dna),g' \
+@BUNDLE_FALSE@ -e 's,@enable_autobind\@,$(enable_autobind),g' \
@BUNDLE_FALSE@ -e 's,@ECHO_N\@,$(ECHO_N),g' \
@BUNDLE_FALSE@ -e 's,@ECHO_C\@,$(ECHO_C),g' \
@BUNDLE_FALSE@ -e 's,@brand\@,$(brand),g' \
@BUNDLE_FALSE@ -e 's,@capbrand\@,$(capbrand),g' \
@BUNDLE_FALSE@ -e 's,@vendor\@,$(vendor),g' \
+@BUNDLE_FALSE@ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
@BUNDLE_FALSE@ -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
@BUNDLE_FALSE@ -e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
@BUNDLE_FALSE@ -e 's,@BUILDNUM\@,$(BUILDNUM),g' \
@BUNDLE_FALSE@ -e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
@BUNDLE_FALSE@ -e 's,@perldir\@,$(perldir),g' \
@BUNDLE_FALSE@ -e 's,@defaultuser\@,$(defaultuser),g' \
-@BUNDLE_FALSE@ -e 's,@defaultgroup\@,$(defaultgroup),g'
+@BUNDLE_FALSE@ -e 's,@defaultgroup\@,$(defaultgroup),g' \
+@BUNDLE_FALSE@ -e 's,@with_fhs_opt\@,@with_fhs_opt@,g'
# these are for the config files and scripts that we need to generate and replace
@@ -1974,20 +2001,29 @@
@BUNDLE_TRUE@ -e 's,@configdir\@,$(configdir),g' \
@BUNDLE_TRUE@ -e 's,@sysconfdir\@,$(sysconfdir),g' \
@BUNDLE_TRUE@ -e 's,@localstatedir\@,$(localstatedir),g' \
+@BUNDLE_TRUE@ -e 's,@infdir\@,$(infdir),g' \
+@BUNDLE_TRUE@ -e 's,@templatedir\@,$(sampledatadir),g' \
@BUNDLE_TRUE@ -e 's,@package_name\@,$(PACKAGE_NAME),g' \
@BUNDLE_TRUE@ -e 's,@instconfigdir\@,$(instconfigdir),g' \
+@BUNDLE_TRUE@ -e 's,@enable_ldapi\@,$(enable_ldapi),g' \
+@BUNDLE_TRUE@ -e 's,@enable_pam_passthru\@,$(enable_pam_passthru),g' \
+@BUNDLE_TRUE@ -e 's,@enable_bitwise\@,$(enable_bitwise),g' \
+@BUNDLE_TRUE@ -e 's,@enable_dna\@,$(enable_dna),g' \
+@BUNDLE_TRUE@ -e 's,@enable_autobind\@,$(enable_autobind),g' \
@BUNDLE_TRUE@ -e 's,@ECHO_N\@,$(ECHO_N),g' \
@BUNDLE_TRUE@ -e 's,@ECHO_C\@,$(ECHO_C),g' \
@BUNDLE_TRUE@ -e 's,@brand\@,$(brand),g' \
@BUNDLE_TRUE@ -e 's,@capbrand\@,$(capbrand),g' \
@BUNDLE_TRUE@ -e 's,@vendor\@,$(vendor),g' \
+@BUNDLE_TRUE@ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
@BUNDLE_TRUE@ -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
@BUNDLE_TRUE@ -e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
@BUNDLE_TRUE@ -e 's,@BUILDNUM\@,$(BUILDNUM),g' \
@BUNDLE_TRUE@ -e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
@BUNDLE_TRUE@ -e 's,@perldir\@,$(perldir),g' \
@BUNDLE_TRUE@ -e 's,@defaultuser\@,$(defaultuser),g' \
-@BUNDLE_TRUE@ -e 's,@defaultgroup\@,$(defaultgroup),g'
+@BUNDLE_TRUE@ -e 's,@defaultgroup\@,$(defaultgroup),g' \
+@BUNDLE_TRUE@ -e 's,@with_fhs_opt\@,@with_fhs_opt@,g'
all: $(BUILT_SOURCES) config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
16 years, 9 months
[Fedora-directory-commits] directoryconsole/src/com/netscape/admin/dirserv DSContentPage.java, 1.2, 1.3
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/directoryconsole/src/com/netscape/admin/dirserv
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29649/com/netscape/admin/dirserv
Modified Files:
DSContentPage.java
Log Message:
Resolves: #248073
Summary: Directory Browser shows nothing if the suffix is empty
Description: always displays the system entries (cn=config, cn=monitor, and
cn=schema) regardless of the suffix's existence.
Index: DSContentPage.java
===================================================================
RCS file: /cvs/dirsec/directoryconsole/src/com/netscape/admin/dirserv/DSContentPage.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSContentPage.java 9 Sep 2005 18:23:11 -0000 1.2
+++ DSContentPage.java 13 Jul 2007 16:34:39 -0000 1.3
@@ -247,21 +247,22 @@
return null;
}
- public void finished() {
+ public void finished() {
_framework.setBusyCursor(false);
if (_suffixes != null) {
- // We populate the browser controller
- for (int i = 0; i < _suffixes.length; i++) {
+ // We populate the browser controller
+ for (int i = 0; i < _suffixes.length; i++) {
_controller.addSuffix(_suffixes[i], null);
}
- _controller.addSuffix("cn=schema", null);
- _controller.addSuffix("cn=monitor", null);
- _controller.addSuffix("cn=config", null);
}
else {
- // Probably an error
+ // Suffix has no entry
Debug.println(0, "DSContentPage.initialize: no suffix found");
- }
+ }
+ // Even if suffix has no entry, we should show system entries
+ _controller.addSuffix("cn=schema", null);
+ _controller.addSuffix("cn=monitor", null);
+ _controller.addSuffix("cn=config", null);
_childrenController.setSorted(isSorted);
_controller.setShowContainerOnly(_layout.equals(ContentMenuController.NODE_LEAF_LAYOUT));
16 years, 9 months
[Fedora-directory-commits] esc/src/app/xul/esc/chrome/icons/default esc-window.ico, NONE, 1.1 settings-window.ico, NONE, 1.1
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/app/xul/esc/chrome/icons/default
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15407
Added Files:
esc-window.ico settings-window.ico
Log Message:
Initial revision. r. mharmsen
--- NEW FILE esc-window.ico ---
/@
p�
8Y
p�
6W
�f}��<
��O�
G
S��nnnQ �w��.jg++�j�6O(�fZ�����"StP&���u�}�;�
;6O(�T�������DS�S�����<?q\�;��~`�6O(����'��������/�F_~�r���Ai0
��.�����a%%7������������������FHr�II��V?��������z���%gu I������}�X�����������@�rr�I8�
����.��4���a�%��I���������j(�������������V?
�����v �����a%u I����(�jj�^^������m�����)�s������ �e�a�����m��������t^^t��B��X�)�
���K !��a%� I�������m����������Utj��j�&t?s������ �Y�������-��
���
K����}����\x'I�+�\��In"��%��U��
�K�]�}���������\�m�++"�%B�U��}
�U�K��}��������������������nI\���%BK�U�Dh
���K��}������'�$,�$������������EH%BK�����d�U�K��}��������/eri�i��������4�Zc%��K�U�����UK�}������mn�������<<�,(7����V�%��U������;����K}����?�n��������/�i,i��sb�U��F%M�����������
--- NEW FILE settings-window.ico ---
/@
p�
8Y
p�
6W
�f}��<
��O�
G
S��nnnQ �w��.jg++�j�6O(�fZ�����"StP&���u�}�;�
;6O(�T�������DS�S�����<?q\�;��~`�6O(����'��������/�F_~�r���Ai0
��.�����a%%7������������������FHr�II��V?��������z���%gu I������}�X�����������@�rr�I8�
����.��4���a�%��I���������j(�������������V?
�����v �����a%u I����(�jj�^^������m�����)�s������ �e�a�����m��������t^^t��B��X�)�
���K !��a%� I�������m����������Utj��j�&t?s������ �Y�������-��
���
K����}����\x'I�+�\��In"��%��U��
�K�]�}���������\�m�++"�%B�U��}
�U�K��}��������������������nI\���%BK�U�Dh
���K��}������'�$,�$������������EH%BK�����d�U�K��}��������/eri�i��������4�Zc%��K�U�����UK�}������mn�������<<�,(7����V�%��U������;����K}����?�n��������/�i,i��sb�U��F%M�����������
16 years, 9 months
[Fedora-directory-commits] adminserver/admserv/newinst/src migrate-ds-admin.pl.in, 1.2, 1.3
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11394/adminserver/admserv/newinst/src
Modified Files:
migrate-ds-admin.pl.in
Log Message:
Resolves: bug 245815
Bug Description: DS Admin Migration framework - cross platform support
Reviewed by: nhosoi (Thanks!)
Fix Description: There are basically three parts to cross platform support
1) Allow a different physical server root than the logical server root. This allows you to copy the old server root directory to the target machine, either by making a tarball or by a network mount. Then you can migrate from e.g. /mnt/opt/fedora-ds, and specify that the real old server root was /opt/fedora-ds. This is the distinction between the --oldsroot and --actualsroot parameters.
2) Cross platform database migration requires the old data is converted to LDIF first. Migration makes the simplifying assumption that the database LDIF file is in the old db directory and has the name of <old backend name>.ldif e.g. userRoot.ldif
3) Cross platform replication migration doesn't preserve the state, so the changelog nor other associated state information can be migrated.
I rewrote the old migration script to use the FileConn - this theoretically will allow us to support migration using an LDAP::Conn as well.
I had to make some fixes to FileConn, primarily to support the root DSE.
Platforms tested: RHEL4
Flag Day: no
Doc impact: Yes, along with the rest of the new migration framework.
Index: migrate-ds-admin.pl.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/migrate-ds-admin.pl.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- migrate-ds-admin.pl.in 4 Jul 2007 01:31:33 -0000 1.2
+++ migrate-ds-admin.pl.in 12 Jul 2007 14:00:10 -0000 1.3
@@ -67,7 +67,9 @@
# either the config ds will be one of them, or we
# should have already migrated the config DS
$mig->msg('begin_ds_migration', $mig->{oldsroot});
-migrateDS($mig);
+if (!migrateDS($mig)) {
+ exit 1;
+}
# if the config ds is on the local machine, shut down the old one
# and bring up the new one - the rest of migration needs to update it
16 years, 9 months
[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts DSDialogs.pm, 1.2, 1.3 DSMigration.pm.in, 1.2, 1.3 FileConn.pm, 1.1, 1.2 Migration.pm.in, 1.1, 1.2 Util.pm.in, 1.6, 1.7 migrate-ds.res, 1.1, 1.2 setup-ds.pl.in, 1.4, 1.5 setup-ds.res.in, 1.6, 1.7
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10721/ldap/admin/src/scripts
Modified Files:
DSDialogs.pm DSMigration.pm.in FileConn.pm Migration.pm.in
Util.pm.in migrate-ds.res setup-ds.pl.in setup-ds.res.in
Log Message:
Resolves: bug 245815
Bug Description: DS Admin Migration framework - cross platform support
Reviewed by: nhosoi (Thanks!)
Fix Description: There are basically three parts to cross platform support
1) Allow a different physical server root than the logical server root. This allows you to copy the old server root directory to the target machine, either by making a tarball or by a network mount. Then you can migrate from e.g. /mnt/opt/fedora-ds, and specify that the real old server root was /opt/fedora-ds. This is the distinction between the --oldsroot and --actualsroot parameters.
2) Cross platform database migration requires the old data is converted to LDIF first. Migration makes the simplifying assumption that the database LDIF file is in the old db directory and has the name of <old backend name>.ldif e.g. userRoot.ldif
3) Cross platform replication migration doesn't preserve the state, so the changelog nor other associated state information can be migrated.
I rewrote the old migration script to use the FileConn - this theoretically will allow us to support migration using an LDAP::Conn as well.
I had to make some fixes to FileConn, primarily to support the root DSE.
Platforms tested: RHEL4
Flag Day: no
Doc impact: Yes, along with the rest of the new migration framework.
Index: DSDialogs.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSDialogs.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSDialogs.pm 19 Jun 2007 23:05:08 -0000 1.2
+++ DSDialogs.pm 12 Jul 2007 13:52:42 -0000 1.3
@@ -98,7 +98,7 @@
my $ans = shift;
my $res = $DialogManager::SAME;
my $path = $self->{manager}->{setup}->{configdir} . "/slapd-" . $ans;
- if ($ans !~ /^[0-9a-zA-Z_-]+$/) {
+ if (!isValidServerID($ans)) {
$self->{manager}->alert("dialog_dsserverid_error", $ans);
} elsif (-d $path) {
$self->{manager}->alert("dialog_dsserverid_inuse", $ans);
Index: DSMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSMigration.pm.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSMigration.pm.in 4 Jul 2007 01:28:17 -0000 1.2
+++ DSMigration.pm.in 12 Jul 2007 13:52:42 -0000 1.3
@@ -53,6 +53,7 @@
# tempfiles
use File::Temp qw(tempfile tempdir);
+use File::Basename qw(basename);
# load perldap
use Mozilla::LDAP::Conn;
@@ -88,6 +89,8 @@
'nsslapd-lockdir' => 'nsslapd-lockdir',
'nsslapd-tmpdir' => 'nsslapd-tmpdir',
'nsslapd-certdir' => 'nsslapd-certdir',
+ 'nsslapd-ldifdir' => 'nsslapd-ldifdir',
+ 'nsslapd-bakdir' => 'nsslapd-bakdir',
'nsslapd-ldapifilepath' => 'nsslapd-ldapifilepath',
'nsslapd-ldapilisten' => 'nsslapd-ldapilisten',
'nsslapd-ldapiautobind' => 'nsslapd-ldapiautobind',
@@ -106,34 +109,55 @@
'aci' => 'aci'
);
-my $pkgname; # global used in several different places - set in migrateDS
-my $oldsroot; # global used in several different places - set in migrateDS
-
sub getNewDbDir {
- my ($ent, $attr, $inst) = @_;
+ my ($ent, $attr, $mig, $inst) = @_;
my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
my $cn = $ent->getValues('cn');
+ my $oldval = $ent->getValues($attr);
my $newval;
+ # there is one case where we want to just use the existing db directory
+ # that's the case where the user has moved the indexes and/or the
+ # transaction logs to different partitions for performance
+ # in that case, the old directory will not be the same as the default,
+ # and the directory will exist
+ my $olddefault = "$mig->{actualsroot}/$inst";
+ if (-d $oldval and ($oldval !~ /^$olddefault/)) {
+ debug(2, "Keeping old value [$oldval] for attr $attr in entry ", $ent->getDN(), "\n");
+ return $oldval;
+ }
+ # otherwise, just use the new default locations
if ($objclasses{nsbackendinstance}) {
- $newval = "@localstatedir@/lib/$pkgname/$inst/db/$cn";
+ $newval = "@localstatedir@/lib/$mig->{pkgname}/$inst/db/$cn";
} elsif (lc $cn eq 'config') {
- $newval = "@localstatedir@/lib/$pkgname/$inst/db";
+ $newval = "@localstatedir@/lib/$mig->{pkgname}/$inst/db";
} elsif (lc $cn eq 'changelog5') {
- $newval = "@localstatedir@/lib/$pkgname/$inst/cldb";
+ $newval = "@localstatedir@/lib/$mig->{pkgname}/$inst/changelogdb";
}
debug(2, "New value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
return $newval;
}
sub migrateCredentials {
- my ($ent, $attr, $inst) = @_;
+ my ($ent, $attr, $mig, $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, "Executing migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c $oldval . . .\n");
+ my $newval = `migratecred -o $mig->{actualsroot}/$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;
}
+sub removensState {
+ my ($ent, $attr, $mig, $inst) = @_;
+ my $newval;
+
+ # nsstate is binary and cannot be migrated cross platform
+ if (!$mig->{crossplatform}) {
+ $newval = $ent->getValues($attr);
+ }
+
+ 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
@@ -146,110 +170,170 @@
'nsslapd-db-logdirectory' => \&getNewDbDir,
'nsslapd-changelogdir' => \&getNewDbDir,
'nsds5replicacredentials' => \&migrateCredentials,
- 'nsmultiplexorcredentials' => \&migrateCredentials
+ 'nsmultiplexorcredentials' => \&migrateCredentials,
+ 'nsstate' => \&removensState
);
sub copyDatabaseDirs {
my $srcdir = shift;
my $destdir = shift;
- if (-d $srcdir && ! -d $destdir) {
+ my $filesonly = shift;
+ if (-d $srcdir && ! -d $destdir && !$filesonly) {
debug(1, "Copying database directory $srcdir to $destdir\n");
- system ("cp -p -r $srcdir $destdir") == 0 or
- die "Could not copy database directory $srcdir to $destdir: $?";
+ if (system ("cp -p -r $srcdir $destdir")) {
+ return ('error_copying_dbdir', $srcdir, $destdir, $?);
+ }
} elsif (! -d $srcdir) {
- die "Error: database directory $srcdir does not exist";
+ return ("error_dbsrcdir_not_exist", $srcdir);
} else {
debug(1, "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: $!";
+ if (system ("cp -p $file $destdir")) {
+ return ('error_copying_dbfile', $file, $destdir, $?);
+ }
+ } elsif (-d $file && !$filesonly) {
+ if (system ("cp -p -r $file $destdir")) {
+ return ('error_copying_dbdir', $file, $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 (my $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;
-}
-
-sub copyChangelogDB {
- my $oldroot = shift;
- my $inst = shift;
- my $newdbdir = shift;
+# migrate all of the databases in an instance
+sub migrateDatabases {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+ my $olddefault = "$mig->{actualsroot}/$inst/db"; # old default db home directory
+ my @errs;
+
+ # first, look for an LDIF file in that directory with the same name as the
+ # database
+ my $foundldif;
+ for (glob("$mig->{oldsroot}/$inst/db/*.ldif")) {
+ my $dbname = basename($_, '.ldif');
+ my @cmd = ("@serverdir@/$inst/ldif2db", "-n", $dbname, "-i", $_);
+ debug(1, "migrateDatabases: executing command ", @cmd);
+ if (system(@cmd)) {
+ return ('error_importing_migrated_db', $_, $?);
+ }
+ $foundldif = 1;
+ }
+
+ if ($foundldif) {
+ return (); # done - can do nothing else for cross-platform
+ }
+
+ # if no LDIF files, just copy over the database directories
+ my $ent = $src->search("cn=ldbm database,cn=plugins,cn=config", "one",
+ "(objectclass=*)");
+ if (!$ent) {
+ return ("error_reading_olddbconfig", $src->getErrorString());
+ }
+ # there is one case where we want to just use the existing db directory
+ # that's the case where the user has moved the indexes and/or the
+ # transaction logs to different partitions for performance
+ # in that case, the old directory will not be the same as the default,
+ # and the directory will exist
+ my $olddefault = "$mig->{actualsroot}/$inst";
+ do {
+ my $cn = $ent->getValues('cn');
+ my %objclasses = map { lc($_) => $_ } $ent->getValues('objectclass');
+ if ($cn eq 'config') { # global config
+ my $newent = $dest->search($ent->getDN(), "base", "(objectclass=*)");
+ my $newdbdir = $newent->getValues('nsslapd-directory') ||
+ "@localstatedir@/lib/$mig->{pkgname}/$inst/db";
+ 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 || "$olddefault/db";
+ if (-d $srcdir and ($srcdir !~ /^$olddefault/)) {
+ debug(2, "Not copying database files from [$srcdir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $srcdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ if (@errs = copyDatabaseDirs($srcdir, $newdbdir, 1)) {
+ return @errs;
+ }
+ }
+ if ($logdir && ($logdir ne $srcdir)) {
+ if (-d $logdir and ($logdir !~ /^$olddefault/)) {
+ debug(2, "Not copying transaction logs from [$logdir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $newdbdir = $newent->getValues('nsslapd-db-logdirectory') ||
+ $newdbdir;
+ $logdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ if (@errs = copyDatabaseDirs($logdir, $newdbdir, 1)) {
+ return @errs;
+ }
+ }
+ }
+ } 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 || "$olddefault/db/$cn";
+ my $newent = $dest->search($ent->getDN(), "base", "(objectclass=*)");
+ my $newdbdir = $newent->getValues('nsslapd-directory') ||
+ "@localstatedir@/lib/$mig->{pkgname}/$inst/db";
+ if (-d $srcdir and ($srcdir !~ /^$olddefault/)) {
+ debug(2, "Not copying database indexes from [$srcdir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $srcdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ if (@errs = copyDatabaseDirs($srcdir, "$newdbdir/$cn")) {
+ return @errs;
+ }
+ }
+ }
+ } while ($ent = $src->nextEntry());
+
+ return ();
+}
+
+sub migrateChangelogs {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+ my $olddefault = "$mig->{actualsroot}/$inst"; # old default db home directory
# 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 (my $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);
- last;
+ my $oldent = $src->search("cn=changelog5, cn=config", "base", "(objectclass=*)");
+ my $newent = $dest->search("cn=changelog5, cn=config", "base", "(objectclass=*)");
+ if ($oldent and $newent) { # changelog configured
+ my $oldcldir = $oldent->getValues('nsslapd-changelogdir');
+ if (-d $oldcldir and ($oldcldir !~ /^$olddefault/)) {
+ debug(2, "Not copying changelogdb from [$oldcldir]\n");
+ } else {
+ # replace the old sroot value with the actual physical location on the target/dest
+ $oldcldir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ my $newcldir = $newent->getValues('nsslapd-changelogdir');
+ copyDatabaseDirs($oldcldir, $newcldir);
}
}
- close DSELDIF;
}
sub fixAttrsInEntry {
- my ($ent, $inst) = @_;
+ my ($ent, $mig, $inst) = @_;
for my $attr (keys %{$ent}) {
my $lcattr = lc $attr;
if ($transformAttr{$lcattr}) {
- $ent->setValues($attr, &{$transformAttr{$lcattr}}($ent, $attr, $inst));
+ $ent->setValues($attr, &{$transformAttr{$lcattr}}($ent, $attr, $mig, $inst));
}
}
}
sub mergeEntries {
- my ($old, $new, $inst) = @_;
+ my ($old, $new, $mig, $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
@@ -280,7 +364,7 @@
} elsif ($transformAttr{$lcattr}) {
# only transform if the value is in the old entry
if (!$innewonly{$attr}) {
- $new->setValues($attr, &{$transformAttr{$lcattr}}($old, $attr, $inst));
+ $new->setValues($attr, &{$transformAttr{$lcattr}}($old, $attr, $mig, $inst));
}
} elsif ($cn eq "internationalization plugin" and $lcattr eq "nsslapd-pluginarg0") {
next; # use the new value of this path name
@@ -294,41 +378,72 @@
}
}
-sub mergeDseLdif {
- my $oldroot = shift;
- my $inst = shift;
- my $ent;
+
+my @allattrlist = ('*', 'aci', 'createTimestamp', 'creatorsName',
+ 'modifyTimestamp', 'modifiersName');
+
+sub getAllEntries {
+ my $conn = shift;
+ my $href = shift;
+ my $aref = shift;
+
+ # these are the special DSEs for which we only need ACIs
+ for my $dn ("", "cn=monitor", "cn=config") {
+ my $scope = $dn ? "sub" : "base";
+ my @attrlist;
+ if ($dn eq "cn=config") {
+ @attrlist = @allattrlist;
+ } else {
+ @attrlist = qw(aci);
+ }
+ my $ent = $conn->search($dn, $scope, "(objectclass=*)", 0, @attrlist);
+ next if (!$ent or ($conn->getErrorCode() eq 32));
+ if ($conn->getErrorCode()) {
+ return ('error_reading_entry', $dn, $conn->getErrorString());
+ }
+ do {
+ my $ndn = normalizeDN($ent->getDN());
+ $href->{$ndn} = $ent;
+ push @{$aref}, $ndn;
+ } while ($ent = $conn->nextEntry());
+ }
+
+ return ();
+}
+
+# these entries cannot be migrated if doing cross platform
+my %noCrossPlatformDN = (
+ 'cn=uniqueid generator,cn=config' => 'cn=uniqueid generator,cn=config'
+);
+
+sub mergeConfigEntries {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
# 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;
+ my @errs;
+ if (@errs = getAllEntries($src, \%olddse, \@olddns)) {
+ return @errs;
}
- close OLDDSELDIF;
# next, read in new file
my %newdse; # map of normalized DN to Entry
+ my @allnewdns;
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;
+ if (@errs = getAllEntries($dest, \%newdse, \@allnewdns)) {
+ return @errs;
+ }
+
+ for my $ndn (@allnewdns) {
+ if (! exists $olddse{$ndn}) {
+ push @newdns, $ndn;
}
}
- 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
@@ -339,58 +454,144 @@
for my $dn (@olddns, @newdns) {
my $oldent = $olddse{$dn};
my $newent = $newdse{$dn};
- my $outputent;
- if ($oldent && !$newent) {
+ my $op;
+ my $rc = 1;
+ if ($mig->{crossplatform} && $noCrossPlatformDN{$dn}) {
+ debug(1, "Cannot migrate the entry $dn - skipping\n");
+ next;
+ } elsif ($oldent && !$newent) {
# may have to fix up some values in the old entry
- fixAttrsInEntry($oldent, $inst);
- # output $oldent
- $outputent = $oldent;
+ fixAttrsInEntry($oldent, $mig, $inst);
+ $rc = $dest->add($oldent);
+ $op = "add";
} elsif (!$oldent && $newent) {
- next if ($dn =~ /o=deleteAfterMigration/i);
- # output $newent
- $outputent = $newent;
+ if ($dn =~ /o=deleteAfterMigration/i) {
+ $rc = $dest->delete($dn);
+ $op = "delete";
+ } else {
+ # do nothing - no change to entry
+ }
} else { #merge
# $newent will contain the merged entry
- mergeEntries($oldent, $newent, $inst);
- $outputent = $newent;
+ mergeEntries($oldent, $newent, $mig, $inst);
+ $rc = $dest->update($newent);
+ $op = "update";
}
- # 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);
+
+ if (!$rc) {
+ return ('error_updating_merge_entry', $op, $dn, $dest->getErrorString());
+ }
+ }
+
+ return ();
+}
+
+my %deletedschema = (
+ '50ns-calendar' => '50ns-calendar.ldif',
+ '50ns-compass' => '50ns-compass.ldif',
+ '50ns-delegated-admin' => '50ns-delegated-admin.ldif',
+ '50ns-legacy' => '50ns-legacy.ldif',
+ '50ns-mail' => '50ns-mail.ldif',
+ '50ns-mcd-browser' => '50ns-mcd-browser.ldif',
+ '50ns-mcd-config' => '50ns-mcd-config.ldif',
+ '50ns-mcd-li' => '50ns-mcd-li.ldif',
+ '50ns-mcd-mail' => '50ns-mcd-mail.ldif',
+ '50ns-media' => '50ns-media.ldif',
+ '50ns-mlm' => '50ns-mlm.ldif',
+ '50ns-msg' => '50ns-msg.ldif',
+ '50ns-netshare' => '50ns-netshare.ldif',
+ '50ns-news' => '50ns-news.ldif',
+ '50ns-proxy' => '50ns-proxy.ldif',
+ '50ns-wcal' => '50ns-wcal.ldif',
+ '51ns-calendar' => '51ns-calendar.ldif'
+);
+
+sub migrateSchema {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+
+ my $cfgent = $dest->search("cn=config", "base", "(objectclass=*)");
+ my $newschemadir = $cfgent->getValues('nsslapd-schemadir') ||
+ "$mig->{configdir}/$inst/schema";
+ my %newschema = map {basename($_, '.ldif') => $_} glob("$newschemadir/*.ldif");
+ delete $newschema{"99user"}; # always copy this one
+ for (glob("$mig->{oldsroot}/$inst/config/schema/*.ldif")) {
+ my $fname = basename($_, '.ldif');
+ next if ($deletedschema{$fname}); # don't copy deleted schema
+ next if ($newschema{$fname}); # use new version
+ if (system("cp -p $_ $newschemadir")) {
+ return ("error_migrating_schema", $_, $!);
+ }
+ }
+
+ return ();
+}
+
+sub migrateDSInstance {
+ my $mig = shift; # the Migration object
+ my $inst = shift; # the instance name (e.g. slapd-instance)
+ my $src = shift; # a Conn to the source
+ my $dest = shift; # a Conn to the dest
+
+ my @errs;
+ # first, merge dse ldif
+ if (@errs = mergeConfigEntries($mig, $inst, $src, $dest)) {
+ return @errs;
+ }
+
+ # next, grab the old schema
+ if (@errs = migrateSchema($mig, $inst, $src, $dest)) {
+ return @errs;
+ }
+
+ # next, the databases
+ if (@errs = migrateDatabases($mig, $inst, $src, $dest)) {
+ return @errs;
+ }
+
+ # next, the changelogs
+ if (!$mig->{crossplatform}) {
+ if (@errs = migrateChangelogs($mig, $inst, $src, $dest)) {
+ return @errs;
}
}
- close $dsefh;
- return $tmpdse;
+ # next, the security files
+ my $cfgent = $dest->search("cn=config", "base", "(objectclass=*)");
+ my $newcertdir = $cfgent->getValues("nsslapd-certdir") ||
+ "@instconfigdir@/$inst";
+ $mig->migrateSecurityFiles($inst, $newcertdir);
+
+ return @errs;
}
sub migrateDS {
my $mig = shift;
- $pkgname = $mig->{pkgname}; # set globals
- $oldsroot = $mig->{oldsroot}; # set globals
my @errs;
# for each instance
foreach my $inst (@{$mig->{instances}}) {
- if (-f "@instconfigdir(a)/$inst/dse.ldif") {
- $mig->msg($WARN, 'instance_already_exists', "@instconfigdir(a)/$inst/dse.ldif");
+ if (-f "$mig->{configdir}/$inst/dse.ldif") {
+ $mig->msg($WARN, 'instance_already_exists', "$mig->{configdir}/$inst/dse.ldif");
next;
}
- # set instance specific defaults
- my $newdbdir = "@localstatedir@/lib/$pkgname/$inst/db";
- my $newcertdir = "@instconfigdir@/$inst";
- my $newcldbdir = "@localstatedir@/lib/$pkgname/$inst/cldb";
+
+ # you could theoretically make this work with either a remote source or
+ # remote dest
+ # $mig->{inf} would contain an entry for each instance e.g.
+ # $mig->{inf}->{$inst}
+ # each instance specific entry would contain a {General} and a {slapd}
+ # all the information necessary to open an LDAP::Conn to the server
+ # if the source, you could also change createInfFromConfig to read
+ # the info from the Conn (or FileConn) that's needed to create the
+ # instance on the dest
# extract the information needed for ds_newinst.pl
- my $configdir = "$oldsroot/$inst/config";
- my $inf = createInfFromConfig($configdir, $inst, \@errs);
- debug(2, "Using inffile $inf->{filename} created from $configdir\n");
+ my $oldconfigdir = "$mig->{oldsroot}/$inst/config";
+ my $inf = createInfFromConfig($oldconfigdir, $inst, \@errs);
+ debug(2, "Using inffile $inf->{filename} created from $oldconfigdir\n");
if (@errs) {
$mig->msg(@errs);
return 0;
@@ -407,31 +608,16 @@
$mig->msg('created_dsinstance', $output);
}
- # copy over the files/directories
- # copy the databases
- copyDatabases($oldsroot, $inst, $newdbdir);
-
- # copy the security related files
- $mig->migrateSecurityFiles($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";
+ my $src = new FileConn("$oldconfigdir/dse.ldif", 1); # read-only
+ my $dest = new FileConn("$mig->{configdir}/$inst/dse.ldif");
- # remove the temp one
- unlink($tmpdse);
+ @errs = migrateDSInstance($mig, $inst, $src, $dest);
+ $src->close();
+ $dest->close();
+ if (@errs) {
+ $mig->msg(@errs);
+ return 0;
+ }
}
return 1;
Index: FileConn.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/FileConn.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FileConn.pm 4 Jul 2007 01:28:17 -0000 1.1
+++ FileConn.pm 12 Jul 2007 13:52:42 -0000 1.2
@@ -54,10 +54,12 @@
sub new {
my $class = shift;
my $filename = shift;
+ my $readonly = shift;
my $self = {};
$self = bless $self, $class;
+ $self->{readonly} = $readonly;
$self->read($filename);
return $self;
@@ -103,8 +105,12 @@
my $context = shift;
my $suppress = shift;
my $ndn = normalizeDN($dn);
- my $children = $self->{$ndn}->{children};
- if (($scope != LDAP_SCOPE_ONELEVEL) && $self->{$ndn}->{data} && !$suppress) {
+ my $children;
+ if (exists($self->{$ndn}) and exists($self->{$ndn}->{children})) {
+ $children = $self->{$ndn}->{children};
+ }
+ if (($scope != LDAP_SCOPE_ONELEVEL) && exists($self->{$ndn}) &&
+ exists($self->{$ndn}->{data}) && $self->{$ndn}->{data} && !$suppress) {
&{$callback}($self->{$ndn}->{data}, $context);
}
@@ -146,7 +152,7 @@
$filename = $self->{filename};
}
- if (!$self->{filename}) {
+ if (!$self->{filename} or $self->{readonly}) {
return;
}
@@ -181,8 +187,14 @@
print "$str ", $self->getErrorString(), "\n";
}
+sub DESTROY {
+ my $self = shift;
+ $self->close();
+}
+
sub close {
my $self = shift;
+ return if ($self->{readonly});
$self->write();
}
@@ -280,7 +292,7 @@
$self->{entries} = [];
my $ndn = normalizeDN($basedn);
- if (!exists($self->{$ndn})) {
+ if (!exists($self->{$ndn}) or !exists($self->{$ndn}->{data})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return undef;
}
@@ -308,12 +320,22 @@
my $parentdn = getParentDN($dn);
my $nparentdn = normalizeDN($parentdn);
+
$self->setErrorCode(0);
+ # special case of root DSE
+ if (!$ndn and exists($self->{$ndn}) and
+ !exists($self->{$ndn}->{data})) {
+ $self->{$ndn}->{data} = $entry;
+ $self->write();
+ return 1;
+ }
+
if (exists($self->{$ndn})) {
$self->setErrorCode(LDAP_ALREADY_EXISTS);
return 0;
}
- if ($nparentdn && !exists($self->{$nparentdn})) {
+
+ if ($ndn && $nparentdn && !exists($self->{$nparentdn})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return 0;
}
@@ -321,7 +343,10 @@
# data is the actual Entry
# children is the array ref of the one level children of this dn
$self->{$ndn}->{data} = $entry;
- push @{$self->{$nparentdn}->{children}}, $self->{$ndn};
+ # don't add parent to list of children
+ if ($nparentdn ne $ndn) {
+ push @{$self->{$nparentdn}->{children}}, $self->{$ndn};
+ }
return 1;
}
@@ -339,6 +364,7 @@
}
$self->{$ndn}->{data} = $entry;
+ $self->write();
return 1;
}
@@ -370,20 +396,23 @@
my $parentdn = getParentDN($dn);
my $nparentdn = normalizeDN($parentdn);
# delete this node from its parent
- for (my $ii = 0; $ii < @{$self->{$nparentdn}->{children}}; ++$ii) {
- # find matching hash ref in parent's child list
- if ($self->{$nparentdn}->{children}->[$ii] eq $self->{$ndn}) {
- # remove that element from the array
- splice @{$self->{$nparentdn}->{children}}, $ii, 1;
- # done - should only ever be one matching child
- last;
+ if ($ndn ne $nparentdn) {
+ for (my $ii = 0; $ii < @{$self->{$nparentdn}->{children}}; ++$ii) {
+ # find matching hash ref in parent's child list
+ if ($self->{$nparentdn}->{children}->[$ii] eq $self->{$ndn}) {
+ # remove that element from the array
+ splice @{$self->{$nparentdn}->{children}}, $ii, 1;
+ # done - should only ever be one matching child
+ last;
+ }
}
}
# delete this node
delete $self->{$ndn};
- return 0;
+ $self->write();
+ return 1;
}
1;
Index: Migration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Migration.pm.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Migration.pm.in 29 Jun 2007 21:12:21 -0000 1.1
+++ Migration.pm.in 12 Jul 2007 13:52:42 -0000 1.2
@@ -101,16 +101,24 @@
--version Print the version and exit
--debug Turn on debugging
--oldsroot The old server root directory to migrate from
- --actualsroot This is the old location of the old server root. See below.
+ --actualsroot This is the old location of the old server root.
+ See below.
--silent Use silent setup - no user input
- --file=name Use the file 'name' in .inf format to supply the default answers
- --keepcache Do not delete the temporary .inf file generated by this program
- --logfile Log migration messages to this file - otherwise, a temp file will be used
- --instance By default, all directory server instances will be migrated. You can use
- this argument to specify one or more (e.g. -i slapd-foo -i slapd-bar) if
- you do not want to migrate all of them.
-For all options, you can also use the short name e.g. -h, -d, etc. For the -d argument,
-specifying it more than once will increase the debug level e.g. -ddddd
+ --file=name Use the file 'name' in .inf format to supply the
+ default answers
+ --keepcache Do not delete the temporary .inf file generated by
+ this program
+ --logfile Log migration messages to this file - otherwise, a temp
+ file will be used
+ --instance By default, all directory server instances will be
+ migrated. You can use this argument to specify one
+ or more (e.g. -i slapd-foo -i slapd-bar) if you do
+ not want to migrate all of them.
+ --cross See below.
+
+For all options, you can also use the short name e.g. -h, -d, etc.
+For the -d argument, specifying it more than once will increase the
+debug level e.g. -ddddd
args:
You can supply default .inf data in this format:
@@ -119,7 +127,18 @@
General.FullMachineName=foo.example.com
or
"slapd.Suffix=dc=example, dc=com"
-Values passed in this manner will override values in an .inf file given with the -f argument.
+Values passed in this manner will override values in an .inf file
+given with the -f argument. If you need to specify the cleartext
+directory manager password (e.g. in order to do remote migration),
+you must specify the password for each instance in a section whose
+name is the instance name e.g.
+ [slapd-ldap1]
+ RootDNPwd=ldap1password
+ [slapd-ldap2]
+ RootDNPwd=ldap2password
+or on the command line like this:
+ command ... slapd-ldap1.RootDNPwd=ldap1password \
+ slapd-ldap2.RootDNPwd=ldap2password ...
actualsroot:
This is used when you must migrate from one machine to another. The
@@ -142,13 +161,36 @@
--oldsroot argument. That is, the oldsroot is the physical location of
the files on disk. The actualsroot is the old value of the server root
on the source machine.
+
+cross:
+Also known as crossplatform, or 'c', or 'x'.
+This is when the source machine is a different architecture than the
+destination machine. In this case, only certain data will be available
+for migration. Changelog information will not be migrated, and replicas
+will need to be reinitialized (if migrating masters or hubs). This type
+of migration requires that all of your old databases have been dumped
+to LDIF format, and the LDIF file must be in the default database directory
+(usually /opt/@brand@-ds/slapd-instance/db), and the LDIF file must have
+the same name as the database instance directory, with a ".ldif". For
+example, if you have
+ /opt/@brand@-ds/slapd-instance/db/userRoot/ and
+ /opt/@brand@-ds/slapd-instance/db/NetscapeRoot/
+you must first use db2ldif to export these databases to LDIF e.g.
+ cd /opt/@brand@-ds/slapd-instance
+ ./db2ldif -n userRoot -a /opt/@brand(a)-ds/slapd-instance/db/userRoot.ldif and
+ ./db2ldif -n NetscapeRoot -a /opt/@brand(a)-ds/slapd-instance/db/NetscapeRoot.ldif
+
+Then you must somehow make your old server root directory available on
+the destination machine, either by creating a tar archive on the source
+and copying it to the destination, or by network mounting the source
+directory on the destination machine.
EOF
}
sub init {
my $self = shift;
$self->{res} = shift;
- my ($silent, $inffile, $keep, $preonly, $logfile, $oldsroot, $actualsroot);
+ my ($silent, $inffile, $keep, $preonly, $logfile, $oldsroot, $actualsroot, $crossplatform);
my @instances;
GetOptions('help|h|?' => sub { VersionMessage(); HelpMessage(); exit 0 },
@@ -161,6 +203,7 @@
'logfile|l=s' => \$logfile,
'oldsroot|o=s' => \$oldsroot,
'actualsroot|a=s' => \$actualsroot,
+ 'crossplatform|cross|c|x' => \$crossplatform,
'instance|i=s' => \@instances
);
@@ -180,6 +223,7 @@
$self->{keep} = $keep;
$self->{preonly} = $preonly;
$self->{logfile} = $logfile;
+ $self->{crossplatform} = $crossplatform;
$self->{log} = new SetupLog($self->{logfile}, "migrate");
# if user supplied inf file, use that to initialize
if (defined($self->{inffile})) {
@@ -220,7 +264,12 @@
glob("$self->{oldsroot}/slapd-*");
}
- die "No instances found to migrate" unless (@instances);
+ if (!@instances) {
+ $self->msg($FATAL, "error_no_instances", $self->{oldsroot});
+ VersionMessage();
+ HelpMessage();
+ exit 1;
+ }
$self->{instances} = \@instances;
}
Index: Util.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Util.pm.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Util.pm.in 6 Jul 2007 17:39:36 -0000 1.6
+++ Util.pm.in 12 Jul 2007 13:52:42 -0000 1.7
@@ -47,10 +47,12 @@
@ISA = qw(Exporter);
@EXPORT = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword debug createDSInstance createInfFromConfig);
+ getHashedPassword debug createDSInstance createInfFromConfig
+ isValidServerID);
@EXPORT_OK = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries
- getHashedPassword debug createDSInstance createInfFromConfig);
+ getHashedPassword debug createDSInstance createInfFromConfig
+ isValidServerID);
use strict;
@@ -102,6 +104,40 @@
return ($dn =~ /^[0-9a-zA-Z_-]+=.*$/);
}
+sub isValidServerID {
+ my $servid = shift;
+ my $validchars = '#%,.:\w@_-';
+ return $servid =~ /^[$validchars]+$/o;
+}
+
+sub isValidUser {
+ my $user = shift;
+ # convert numeric uid to string
+ my $strans = $user;
+ if ($user =~ /^\d+$/) { # numeric - convert to string
+ $strans = getpwuid $user;
+ if (!$strans) {
+ return ("dialog_ssuser_error", $user);
+ }
+ }
+ if ($> != 0) { # if not root, the user must be our uid
+ my $username = getlogin;
+ if ($strans ne $username) {
+ return ("dialog_ssuser_must_be_same", $username);
+ }
+ } else { # user is root - verify id
+ my $nuid = getpwnam $strans;
+ if (!defined($nuid)) {
+ return ("dialog_ssuser_error", $user);
+ }
+ if (!$nuid) {
+ return ("dialog_ssuser_root_warning");
+ }
+ }
+
+ return ();
+}
+
# delete the subtree starting from the passed entry
sub delete_all
{
Index: migrate-ds.res
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/migrate-ds.res,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- migrate-ds.res 29 Jun 2007 21:12:21 -0000 1.1
+++ migrate-ds.res 12 Jul 2007 13:52:42 -0000 1.2
@@ -1,4 +1,13 @@
begin_ds_migration = Beginning migration of directory server instances in %s . . .\n
end_ds_migration = Directory server migration is complete. Please check output and log files for details.\n
migration_exiting = Exiting . . .\nLog file is '%s'\n\n
-instance_already_exists = The target directory server instance already exists at %s. Skipping migration.\n\
+instance_already_exists = The target directory server instance already exists at %s. Skipping migration. Note that if you want to migrate the old instance you will have to first remove the new one of the same name.\n\n
+error_reading_entry = Could not read the entry '%s'. Error: %s\n
+error_updating_merge_entry = Could not %s the migrated entry '%s' in the target directory server. Error: %s\n
+error_importing_migrated_db = Could not import the LDIF file '%s' for the migrated database. Error: %s. Please check the directory server error log for more details.\n
+error_reading_olddbconfig = Could not read the old database configuration information. Error: %s\n
+error_migrating_schema = Could not copy old schema file '%s'. Error: %s\n
+error_copying_dbdir = Could not copy database directory '%s' to '%s'. Error: %s\n
+error_copying_dbfile = Could not copy database file '%s' to '%s'. Error: %s\n
+error_dbsrcdir_not_exist = Could not copy from the database source directory '%s' because it does not exist. Please check your configuration.\n
+error_no_instances = Could not find any instances in the old directory '%s' to migrate.\n
Index: setup-ds.pl.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.pl.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- setup-ds.pl.in 4 Jul 2007 01:28:17 -0000 1.4
+++ setup-ds.pl.in 12 Jul 2007 13:52:42 -0000 1.5
@@ -42,6 +42,7 @@
use strict;
use Setup;
+use SetupLog;
use Inf;
use Resource;
use DialogManager;
@@ -78,4 +79,12 @@
$setup->msg('created_dsinstance', $output);
}
-$setup->doExit();
+END {
+ if ($setup) {
+ if (!$setup->{keep}) {
+ unlink $setup->{inffile};
+ }
+
+ $setup->doExit();
+ }
+}
Index: setup-ds.res.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.res.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- setup-ds.res.in 4 Jul 2007 01:28:17 -0000 1.6
+++ setup-ds.res.in 12 Jul 2007 13:52:42 -0000 1.7
@@ -95,3 +95,12 @@
error_deleteall_entries = Error deleting entry '%s' and all children. Error: %s\n
error_adding_entry = Error adding entry '%s'. Error: %s\n
error_updating_entry = Error updating entry '%s'. Error: %s\n
+
+
+error_invalid_param = The parameter '%s' has an invalid value '%s'.\n
+error_port_available = The port number '%s' is not available for use. This may be due to an\
+invalid port number, or the port already being in use by another\
+program, or low port restriction. Please choose another value for\
+ServerPort. Error: $!\n
+error_invalid_serverid = The ServerIdentifier '%s' contains invalid characters. It must\
+contain only alphanumeric characters and the following: #%,.:@_-\n
16 years, 9 months
[Fedora-directory-commits] adminserver/admserv/cgi-src40 ds_create.in, 1.1, 1.2 ds_remove.in, 1.1, 1.2
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1046
Modified Files:
ds_create.in ds_remove.in
Log Message:
Resolves: #246683
Summary: Reimplement ds_create without setuputil code (comment #16)
Description: adding 'print "Content-type: text/plain\n\n";' to each output.
Index: ds_create.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/ds_create.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ds_create.in 4 Jul 2007 01:31:33 -0000 1.1
+++ ds_create.in 11 Jul 2007 21:36:47 -0000 1.2
@@ -75,6 +75,7 @@
my $status = $?;
# check for and report errors
if ($status) {
+ print "Content-type: text/plain\n\n";
print $output;
exit $status;
}
@@ -92,6 +93,7 @@
my @errs;
my $inf = createInfFromConfig("@instconfigdir@/slapd-$inst", $inst, \@errs);
if (@errs) {
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
@@ -110,6 +112,7 @@
$admConf->{AdminDomain};
if (!createSubDSNoConn($inf, \@errs)) {
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
@@ -127,11 +130,13 @@
my $output = `$prog 2>&1`;
my $status = $?;
if ($status) {
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: Could not start directory server: $output\n";
print "NMC_Status: $status\n";
exit $status;
}
} else {
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: The program $prog does not exist\n";
print "NMC_Status: 1\n";
exit 1;
@@ -146,11 +151,13 @@
# config ds info
if (!registerDSWithConfigDS($servid, \@errs, $inf)) {
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
}
# if we got here, report success
+print "Content-type: text/plain\n\n";
print "NMC_Status: 0\n";
exit 0;
Index: ds_remove.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/ds_remove.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ds_remove.in 11 Jul 2007 01:20:22 -0000 1.1
+++ ds_remove.in 11 Jul 2007 21:36:47 -0000 1.2
@@ -106,7 +106,7 @@
my @errs;
my $inf = createInfFromConfig("@instconfigdir@/slapd-$inst", $inst, \@errs);
if (@errs) {
- print "Content-type: text/html\n\n";
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
@@ -129,7 +129,7 @@
my $dn = "cn=config";
my $entry = $conn->search($dn, "base", "(cn=*)", 0);
if (!$entry) {
- print "Content-type: text/html\n\n";
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: Search $dn in $dseldif failed: $entry\n";
print "NMC_Status: 1\n";
exit 1;
@@ -149,12 +149,12 @@
my $status = $?;
if ($status) {
# Ignore the stop failure
- print "Content-type: text/html\n\n";
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: Could not stop directory server: $output\n";
}
$instdir = $path; # need to use it later...
} else {
- print "Content-type: text/html\n\n";
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: The program $prog does not exist\n";
print "NMC_Status: 1\n";
exit 1;
@@ -169,7 +169,7 @@
# get admin domain
# config ds info
if (!unregisterDSWithConfigDS($inst, \@errs, $inf)) {
- print "Content-type: text/html\n\n";
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
@@ -179,7 +179,7 @@
$dn = "cn=config,cn=ldbm database,cn=plugins,cn=config";
my $dbentry = $conn->search($dn, "base", "(cn=*)", 0);
if (!$dbentry) {
- print "Content-type: text/html\n\n";
+ print "Content-type: text/plain\n\n";
print "NMC_ErrInfo: Search $dn in $dseldif failed: $dbentry\n";
print "NMC_Status: 1\n";
exit 1;
@@ -203,6 +203,6 @@
}
# if we got here, report success
-print "Content-type: text/html\n\n";
+print "Content-type: text/plain\n\n";
print "NMC_Status: 0\n";
exit 0;
16 years, 9 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd ava.c, 1.6, 1.7
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30667
Modified Files:
ava.c
Log Message:
Resolves: #247725
Summary: rhds71 Invalid LDIF Syntax crashes directory server (comment #18)
Description: The problem was if an RDN ends with '\\', strcpy_special_undo
did not check if there is no more character, and incremented the pointer
beyond the end and accessed the address.
Index: ava.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/ava.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ava.c 10 Nov 2006 23:45:40 -0000 1.6
+++ ava.c 11 Jul 2007 21:29:06 -0000 1.7
@@ -113,7 +113,7 @@
strcpy_special_undo( char *d, const char *s )
{
const char *end = s + strlen(s);
- for ( ; *s; s++ )
+ for ( ; s < end && *s; s++ )
{
switch ( *s )
{
16 years, 9 months