Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory
cvs-int.fedora.redhat.com:/tmp/cvs-serv4739/ldapserver/ldap/admin/src/scripts
Modified Files:
DSCreate.pm.in Inf.pm Setup.pm.in
Log Message:
Resolves: bug 281631
Bug Description: Pass in schema and config LDIF files to setup
Reviewed by: nhosoi (Thanks!)
Fix Description: 1) Allow multi-valued parameters in .inf files and command line. These
values will be represented internally as an array ref. No existing parameters allow being
multi-valued (e.g. you can't use Suffix=o=foo and Suffix=o=bar)
2) Add two new .inf parameters - SchemaFile and ConfigFile. The files listed in
SchemaFile will be copied into the schema subdirectory of the new instance, so they must
already be named appropriately (e.g. 60foo.ldif). The files listed in ConfigFile must be
LDIF files with one or more whole entries to be added to the initial dse.ldif. These
could be additional suffixes/databases to create, plugin configuration, replication
configuration, or anything else.
Right now, if you have an LDIF file that relies on custom schema, you cannot use the
InstallLdifFile directive during setup. SchemaFile allows you to do that.
Platforms tested: RHEL5
Flag Day: no
Doc impact: Will need to document the two additional parameters.
Index: DSCreate.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSCreate.pm.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DSCreate.pm.in 7 Aug 2007 23:28:03 -0000 1.5
+++ DSCreate.pm.in 7 Sep 2007 15:02:25 -0000 1.6
@@ -306,6 +306,15 @@
push @ldiffiles,
"$inf->{General}->{prefix}@templatedir(a)/template-dnaplugin.ldif";
}
+ # additional configuration LDIF files
+ if (exists($inf->{slapd}->{ConfigFile})) {
+ if (ref($inf->{slapd}->{ConfigFile})) {
+ push @ldiffiles, @{$inf->{slapd}->{ConfigFile}};
+ } else {
+ push @ldiffiles, $inf->{slapd}->{ConfigFile};
+ }
+ }
+
getMappedEntries($mapper, \@ldiffiles, \@errs, \&check_and_add_entry,
[$conn]);
@@ -407,6 +416,15 @@
} else {
push @schemafiles,
"$inf->{General}->{prefix}@schemadir(a)/00core.ldif";
}
+
+ # additional schema files
+ if (exists($inf->{slapd}->{SchemaFile})) {
+ if (ref($inf->{slapd}->{SchemaFile})) {
+ push @schemafiles, @{$inf->{slapd}->{SchemaFile}};
+ } else {
+ push @schemafiles, $inf->{slapd}->{SchemaFile};
+ }
+ }
for (@schemafiles) {
my $src = $_;
my $basename = basename($src);
Index: Inf.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Inf.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Inf.pm 13 Jul 2007 19:51:48 -0000 1.4
+++ Inf.pm 7 Sep 2007 15:02:25 -0000 1.5
@@ -77,6 +77,7 @@
my $incontinuation = 0;
my $curkey;
+ my $curval;
my $inffh;
if ($filename eq "-") {
$inffh = \*STDIN;
@@ -100,12 +101,32 @@
$iscontinuation = 1;
}
if ($incontinuation) {
- $self->{$curSection}->{$curkey} .= "\n" . $_; # add line in
entirety to current value
+ if ($curval) {
+ $self->{$curSection}->{$curkey}->[$curval] .= "\n" .
$_; # add line in entirety to current value
+ } else {
+ $self->{$curSection}->{$curkey} .= "\n" . $_; # add line
in entirety to current value
+ }
} elsif (/^\[(.*?)\]/) { # e.g. [General]
$curSection = $1;
+ $iscontinuation = 0; # disallow section continuations
} elsif (/^\s*(.*?)\s*=\s*(.*?)\s*$/) { # key = value
$curkey = $1;
- $self->{$curSection}->{$curkey} = $2;
+ # a single value is just a single scalar
+ # multiple values are represented by an array ref
+ if (exists($self->{$curSection}->{$curkey})) {
+ if (!ref($self->{$curSection}->{$curkey})) {
+ # convert single scalar to array ref
+ my $ary = [$self->{$curSection}->{$curkey}];
+ $self->{$curSection}->{$curkey} = $ary;
+ }
+ # just push the new value
+ push @{$self->{$curSection}->{$curkey}}, $2;
+ $curval = @{$self->{$curSection}->{$curkey}} - 1; # curval is index
of last item
+ } else {
+ # single value
+ $self->{$curSection}->{$curkey} = $2;
+ $curval = 0; # only 1 value
+ }
}
if ($iscontinuation) { # if line ends with a backslash, continue the data on the
next line
$incontinuation = 1;
Index: Setup.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Setup.pm.in,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Setup.pm.in 18 Jul 2007 20:37:11 -0000 1.9
+++ Setup.pm.in 7 Sep 2007 15:02:25 -0000 1.10
@@ -161,7 +161,23 @@
# allows the reuse of .inf files with some parameters overridden
for (@ARGV) {
if (/^([\w_-]+)\.([\w_-]+)=(.*)$/) { # e.g. section.param=value
- $self->{inf}->{$1}->{$2} = $3;
+ my $sec = $1;
+ my $parm = $2;
+ my $val = $3;
+ # a single value is just a single scalar
+ # multiple values are represented by an array ref
+ if (exists($self->{inf}->{$sec}->{$parm})) {
+ if (!ref($self->{inf}->{$sec}->{$parm})) {
+ # convert single scalar to array ref
+ my $ary = [$self->{inf}->{$sec}->{$parm}];
+ $self->{inf}->{$sec}->{$parm} = $ary;
+ }
+ # just push the new value
+ push @{$self->{inf}->{$sec}->{$parm}}, $val;
+ } else {
+ # single value
+ $self->{inf}->{$sec}->{$parm} = $val;
+ }
} else { # error
print STDERR "Error: unknown command line option $_\n";
usage();
Show replies by date