diff options
| author | Rich Megginson <rmeggins@redhat.com> | 2007-09-07 15:02:25 +0000 |
|---|---|---|
| committer | Rich Megginson <rmeggins@redhat.com> | 2007-09-07 15:02:25 +0000 |
| commit | ba217f8884cadc1b05dee3ca49201787be4983eb (patch) | |
| tree | ba1d842b8b6aeb75a9e1057a186e44d6f600f27a /ldap/admin/src | |
| parent | 7c0f5346b5f6b4520cbca63513824ed9d3ec938b (diff) | |
| download | ds-ba217f8884cadc1b05dee3ca49201787be4983eb.tar.gz ds-ba217f8884cadc1b05dee3ca49201787be4983eb.tar.xz ds-ba217f8884cadc1b05dee3ca49201787be4983eb.zip | |
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.
Diffstat (limited to 'ldap/admin/src')
| -rw-r--r-- | ldap/admin/src/scripts/DSCreate.pm.in | 18 | ||||
| -rw-r--r-- | ldap/admin/src/scripts/Inf.pm | 25 | ||||
| -rw-r--r-- | ldap/admin/src/scripts/Setup.pm.in | 18 |
3 files changed, 58 insertions, 3 deletions
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index 2557f398..0c43f727 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/ldap/admin/src/scripts/DSCreate.pm.in @@ -306,6 +306,15 @@ sub createConfigFile { push @ldiffiles, "$inf->{General}->{prefix}@templatedir@/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 @@ sub installSchema { } else { push @schemafiles, "$inf->{General}->{prefix}@schemadir@/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); diff --git a/ldap/admin/src/scripts/Inf.pm b/ldap/admin/src/scripts/Inf.pm index 347404aa..4d413630 100644 --- a/ldap/admin/src/scripts/Inf.pm +++ b/ldap/admin/src/scripts/Inf.pm @@ -77,6 +77,7 @@ sub read { my $incontinuation = 0; my $curkey; + my $curval; my $inffh; if ($filename eq "-") { $inffh = \*STDIN; @@ -100,12 +101,32 @@ sub read { $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; diff --git a/ldap/admin/src/scripts/Setup.pm.in b/ldap/admin/src/scripts/Setup.pm.in index 512b5aa9..645b0a89 100644 --- a/ldap/admin/src/scripts/Setup.pm.in +++ b/ldap/admin/src/scripts/Setup.pm.in @@ -161,7 +161,23 @@ sub init { # 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(); |
