Blame SOURCES/0015-Ticket-48119-Silent-install-needs-to-properly-exit-w.patch

a2f18f
From 8f298b2241bb1dc1342b3f7435806af0c22c9f69 Mon Sep 17 00:00:00 2001
a2f18f
From: Mark Reynolds <mreynolds@redhat.com>
a2f18f
Date: Mon, 13 Jul 2015 12:24:19 -0400
a2f18f
Subject: [PATCH 15/20] Ticket 48119 - Silent install needs to properly exit
a2f18f
 when INF file is missing
a2f18f
a2f18f
Bug Description:  If the INF file is not present, we don't log the error to the
a2f18f
                  setup log file.  We also don't properly check for the suitespot
a2f18f
                  user, which also does not properly exit if the calling user is root.
a2f18f
a2f18f
Fix Description:  Properly exit if the INF file is missing, or the suitespot user
a2f18f
                  is not set(and we are running the script as root).
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48119
a2f18f
a2f18f
Reviewed by: rmeggins(Thanks!)
a2f18f
a2f18f
(cherry picked from commit 5363898b122b1a7e7ad07fdc0ad074e91cd1510f)
a2f18f
(cherry picked from commit eeddc9f03b6131f5c8ba715a0a05bb1280a4f9ef)
a2f18f
---
a2f18f
 ldap/admin/src/scripts/DSCreate.pm.in  | 3 ++-
a2f18f
 ldap/admin/src/scripts/Inf.pm          | 8 ++++++--
a2f18f
 ldap/admin/src/scripts/Setup.pm.in     | 3 +++
a2f18f
 ldap/admin/src/scripts/setup-ds.res.in | 1 +
a2f18f
 4 files changed, 12 insertions(+), 3 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
a2f18f
index f44afbb..e4a4ed0 100644
a2f18f
--- a/ldap/admin/src/scripts/DSCreate.pm.in
a2f18f
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
a2f18f
@@ -797,8 +797,9 @@ sub setDefaults {
a2f18f
     if (!$inf->{General}->{SuiteSpotUserID}) {
a2f18f
         if ($> != 0) { # if not root, use the user's uid
a2f18f
             $inf->{General}->{SuiteSpotUserID} = getLogin;
a2f18f
+        } else {
a2f18f
+            return('error_missing_userid');
a2f18f
         }
a2f18f
-        # otherwise, the uid must be specified
a2f18f
     }
a2f18f
 
a2f18f
     if (!$inf->{General}->{SuiteSpotGroup}) {
a2f18f
diff --git a/ldap/admin/src/scripts/Inf.pm b/ldap/admin/src/scripts/Inf.pm
a2f18f
index ec433e2..d4c55f1 100644
a2f18f
--- a/ldap/admin/src/scripts/Inf.pm
a2f18f
+++ b/ldap/admin/src/scripts/Inf.pm
a2f18f
@@ -31,7 +31,9 @@ sub new {
a2f18f
     $self = bless $self, $type;
a2f18f
 
a2f18f
     if ($self->{filename}) {
a2f18f
-        $self->read();
a2f18f
+        if($self->read() != 0){
a2f18f
+            undef $self;
a2f18f
+        }
a2f18f
     }
a2f18f
 
a2f18f
     return $self;
a2f18f
@@ -61,7 +63,7 @@ sub read {
a2f18f
     } else {
a2f18f
         if (!open(INF, $filename)) {
a2f18f
             debug(0, "Error: could not open inf file $filename: $!\n");
a2f18f
-            return;
a2f18f
+            return -1;
a2f18f
         }
a2f18f
         $inffh = \*INF;
a2f18f
     }
a2f18f
@@ -118,6 +120,8 @@ sub read {
a2f18f
     if ($inffh ne \*STDIN) {
a2f18f
         close $inffh;
a2f18f
     }
a2f18f
+
a2f18f
+    return 0;
a2f18f
 }
a2f18f
 
a2f18f
 sub section {
a2f18f
diff --git a/ldap/admin/src/scripts/Setup.pm.in b/ldap/admin/src/scripts/Setup.pm.in
a2f18f
index cd49d95..99025ab 100644
a2f18f
--- a/ldap/admin/src/scripts/Setup.pm.in
a2f18f
+++ b/ldap/admin/src/scripts/Setup.pm.in
a2f18f
@@ -117,6 +117,9 @@ sub init {
a2f18f
     # if user supplied inf file, use that to initialize
a2f18f
     if (defined($inffile)) {
a2f18f
         $self->{inf} = new Inf($inffile);
a2f18f
+        if(!$self->{inf}){
a2f18f
+            $self->doExit(1);
a2f18f
+        }
a2f18f
     } else {
a2f18f
         $self->{inf} = new Inf;
a2f18f
     }
a2f18f
diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in
a2f18f
index 011bf36..7134e25 100644
a2f18f
--- a/ldap/admin/src/scripts/setup-ds.res.in
a2f18f
+++ b/ldap/admin/src/scripts/setup-ds.res.in
a2f18f
@@ -118,6 +118,7 @@ error_enabling_feature = Could not enable the directory server feature '%s'.  Er
a2f18f
 error_importing_ldif = Could not import LDIF file '%s'.  Error: %s.  Output: %s\n
a2f18f
 error_starting_server = Could not start the directory server using command '%s'.  The last line from the error log was '%s'.  Error: %s\n
a2f18f
 error_stopping_server = Could not stop the directory server '%s'.  Error: %s\n
a2f18f
+error_missing_userid = The SuiteSpotUserID is missing.  This must be set to valid user\n
a2f18f
 error_missing_port_and_ldapi = Either ServerPort or ldapifilepath must be specified.  The server must listen to something.\n
a2f18f
 error_missing_port = No ServerPort specified.  The server must have a port number to listen to (default 389).\n
a2f18f
 error_server_already_exists = Error: the server already exists at '%s'\
a2f18f
-- 
a2f18f
1.9.3
a2f18f