From bd9b5bdc2ff6a2c44ba16f68901ec955295467b8 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 17 Jul 2023 14:33:43 -0400 Subject: [PATCH] Hopefully fixed an issue during initial setup after entering DB credentials and writing the config.php files. This was possible due to a rac condition where intially ITflow install checks to see if it can write config.php to currect directory by actually writing a config.php file then deleting it. This could sometimes interfere with the creation of the config.php file in the next step --- setup.php | 225 ++++++++++++++++++++++++++---------------------------- 1 file changed, 109 insertions(+), 116 deletions(-) diff --git a/setup.php b/setup.php index 1627be8f..c486c8e1 100644 --- a/setup.php +++ b/setup.php @@ -785,10 +785,10 @@ if (isset($_POST['add_database'])) { $installation_id = randomString(32); // Test database connection before writing it to config.php - try { - mysqli_connect($host, $username, $password, $database); - } catch (Exception $e) { - exit("Database connection failed - please check and try again

$e"); + + $conn = mysqli_connect($host, $username, $password, $database); + if (!$conn) { + exit("Database connection failed - please check and try again

" . mysqli_connect_error()); } $new_config = "Company Details
- - Database config invalid, or users already exist in the database. - -
+ -
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- -
-
- -
- +
+ +
+
+
+
+
-
- - -
+
+ + +
-
+
- + - - +
@@ -1521,12 +1517,9 @@ if (isset($_POST['add_telemetry'])) {

ITFlow is free software: you can redistribute and/or modify it under the terms of the GNU General Public License.
It is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

Warning: config.php is not writable. Ensure the webserver process has write access (chmod/chown). Check the docs for info.
"; - } else { - // Else, able to write. Tidy up - unlink("config.php"); + // Check that there is access to write to the current directory + if (!is_writable('.')) { + echo "
Warning: The current directory is not writable. Ensure the webserver process has write access (chmod/chown). Check the docs for info.
"; } ?>