瀏覽代碼

Resolves: bug 237356
Description: Move DS Admin Code into Admin Server - Inf, ds_newinst.pl
Fix Description: Some minor cleanup:
1) Setup must not write to the user supplied inf file. Setup uses the user supplied inf to initialize its cache, but creates a tempfile for writing.
2) When writing an Inf, preserve the continuation lines.
3) Added Noriko's fix for suffix generation to ds_newinst.pl
Platforms tested: RHEL4
Flag Day: No.
Doc impact: No.

Rich Megginson 18 年之前
父節點
當前提交
33f1e8722d
共有 3 個文件被更改,包括 15 次插入10 次删除
  1. 1 0
      ldap/admin/src/ds_newinst.pl.in
  2. 3 1
      ldap/admin/src/scripts/Inf.pm
  3. 11 9
      ldap/admin/src/scripts/Setup.pm.in

+ 1 - 0
ldap/admin/src/ds_newinst.pl.in

@@ -217,6 +217,7 @@ if (!$table{slapd}->{RootDN}) {
 if (!$table{slapd}->{Suffix}) {
     my $suffix = $table{General}->{FullMachineName};
     # convert fqdn to dc= domain components
+    $suffix =~ s/^[^\.]*\.//; # just the domain part
     $suffix = "dc=$suffix";
     $suffix =~ s/\./, dc=/g;
     $table{slapd}->{Suffix} = $suffix;

+ 3 - 1
ldap/admin/src/scripts/Inf.pm

@@ -131,7 +131,9 @@ sub writeSection {
         print $fh "[$name]\n";
         for my $key (keys %{$section}) {
             if (defined($section->{$key})) {
-                print $fh "$key = ", $section->{$key}, "\n";
+                my $val = $section->{$key};
+                $val =~ s/\n/\\\n/g; # make continuation lines
+                print $fh "$key = $val\n";
             }
         }
     }

+ 11 - 9
ldap/admin/src/scripts/Setup.pm.in

@@ -132,17 +132,17 @@ sub new {
     $self->{preonly} = $preonly;
     $self->{logfile} = $logfile;
     $self->{log} = new SetupLog($self->{logfile});
-    if (!$self->{inffile}) {
-        my ($fh, $filename) = tempfile("setupXXXXXX", UNLINK => !$keep,
-                                       SUFFIX => ".inf", OPEN => 0,
-                                       DIR => File::Spec->tmpdir);
-        $self->{inffile} = $filename;
-        $self->{inf} = new Inf;
-        $self->{inf}->{filename} = $self->{inffile};
-    } else {
+    # if user supplied inf file, use that to initialize
+    if (defined($self->{inffile})) {
         $self->{inf} = new Inf($self->{inffile});
-        $self->{keep} = 1; # do not delete user supplied inf file
     }
+    my $fh;
+    # create a temp inf file for writing for other processes
+    # never overwrite the user supplied inf file
+    ($fh, $self->{inffile}) = tempfile("setupXXXXXX", UNLINK => !$keep,
+                                       SUFFIX => ".inf", OPEN => 0,
+                                       DIR => File::Spec->tmpdir);
+    $self->{inf}->{filename} = $self->{inffile};
 
     # see if user passed in default inf values - also, command line
     # arguments override those passed in via an inf file - this
@@ -157,6 +157,8 @@ sub new {
         }
     }
 
+    # this is the base config directory - the directory containing
+    # the slapd-instance instance specific config directories
     $self->{configdir} = $ENV{DS_CONFIG_DIR} || "@instconfigdir@";
 
     $self = bless $self, $type;