Prechádzať zdrojové kódy

Ticket 48119 - Silent install needs to properly exit when INF file is missing

Bug Description:  If the INF file is not present, we don't log the error to the
                  setup log file.  We also don't properly check for the suitespot
                  user, which also does not properly exit if the calling user is root.

Fix Description:  Properly exit if the INF file is missing, or the suitespot user
                  is not set(and we are running the script as root).

https://fedorahosted.org/389/ticket/48119

Reviewed by: rmeggins(Thanks!)
Mark Reynolds 10 rokov pred
rodič
commit
5363898b12

+ 2 - 1
ldap/admin/src/scripts/DSCreate.pm.in

@@ -797,8 +797,9 @@ sub setDefaults {
     if (!$inf->{General}->{SuiteSpotUserID}) {
         if ($> != 0) { # if not root, use the user's uid
             $inf->{General}->{SuiteSpotUserID} = getLogin;
+        } else {
+            return('error_missing_userid');
         }
-        # otherwise, the uid must be specified
     }
 
     if (!$inf->{General}->{SuiteSpotGroup}) {

+ 6 - 2
ldap/admin/src/scripts/Inf.pm

@@ -31,7 +31,9 @@ sub new {
     $self = bless $self, $type;
 
     if ($self->{filename}) {
-        $self->read();
+        if($self->read() != 0){
+            undef $self;
+        }
     }
 
     return $self;
@@ -61,7 +63,7 @@ sub read {
     } else {
         if (!open(INF, $filename)) {
             debug(0, "Error: could not open inf file $filename: $!\n");
-            return;
+            return -1;
         }
         $inffh = \*INF;
     }
@@ -118,6 +120,8 @@ sub read {
     if ($inffh ne \*STDIN) {
         close $inffh;
     }
+
+    return 0;
 }
 
 sub section {

+ 3 - 0
ldap/admin/src/scripts/Setup.pm.in

@@ -117,6 +117,9 @@ sub init {
     # if user supplied inf file, use that to initialize
     if (defined($inffile)) {
         $self->{inf} = new Inf($inffile);
+        if(!$self->{inf}){
+            $self->doExit(1);
+        }
     } else {
         $self->{inf} = new Inf;
     }

+ 1 - 0
ldap/admin/src/scripts/setup-ds.res.in

@@ -118,6 +118,7 @@ error_enabling_feature = Could not enable the directory server feature '%s'.  Er
 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_stopping_server = Could not stop the directory server '%s'.  Error: %s\n
+error_missing_userid = The SuiteSpotUserID is missing.  This must be set to valid user\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'\