diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx
index 0eb0679c..d68e4e89 100644
--- a/Site5/Pages/v5/Init/Default.aspx
+++ b/Site5/Pages/v5/Init/Default.aspx
@@ -33,8 +33,19 @@
@@ -225,7 +236,9 @@
return isValid;
}
- });
+ updateDatabasePermissionsAnalysis();
+
+ }); // end of document.ready
function recheckConfigurationWritability() {
@@ -308,7 +321,35 @@
}
});
}
-
+
+
+ function updateDatabasePermissionsAnalysis() {
+
+ $.ajax({
+ type: "POST",
+ url: "Default.aspx/TestDatabasePermissions",
+ data: "{}",
+ contentType: "application/json; charset=utf-8",
+ dataType: "json",
+ success: function (msg) {
+ if (!msg.d.AllPermissionsOk) {
+ updatePermissionsAnalysisDisplay(msg.d);
+ setTimeout('updateDatabasePermissionsAnalysis();', 2000);
+ } else {
+ alert('AllPermissionsOk = true');
+ // TODO: PROCEED
+ }
+ }
+ });
+ }
+
+ function updatePermissionsAnalysisDisplay(testResults) {
+ $('#CellPermissionAdminCredentialCanLogin').text(testResults.AdminCredentialsCanLogin);
+ $('#CellPermissionAdminCredentialCanSelect').text(testResults.AdminCredentialsCanSelect);
+ $('#CellPermissionAdminCredentialCanExecute').text(testResults.AdminCredentialsCanExecute);
+ $('#CellPermissionAdminCredentialCanAdmin').text(testResults.AdminCredentialsCanAdmin);
+ }
+
function beginInitDatabase() {
$.ajax({
@@ -384,7 +425,7 @@
Welcome to Swarmops
Congratulations! Since you're reading this, you have successfully installed the Swarmops packages and set up an Apache virtual server using mod_mono.
- However, before we proceed, we need to make sure that you are indeed the sysadmin of this server, and not a remote bot who just discovered an unfinished Swarmops installation. To do that, answer these simple questions:
+ However, before we proceed, we need to make sure that you are indeed the sysadmin of this server, and not a remote bot who just discovered an unfinished Swarmops installation. To cross that bridge, answer these three simple questions:
What is this server's /etc/hostname?
@@ -404,7 +445,36 @@
cd /etc/swarmops
sudo chown www-data:www-data database.config
sudo chmod o+w database.config
The installation will continue when it detects that these steps have been taken.
-
+
+
Fix Database Permissions
+
There seems to be an error with the database credentials, or more likely, the permissions for those credentials. Edit the database permissions until you have green ticks in all boxes below. (If you made a mistake filling in the database credentials, you can return to entering credentials.)
+
The installation will continue when it detects this has been corrected, and the table below will update continuously as you change database permissions.
+
+ | | Can login? | Can SELECT? | Can EXECUTE? | Can alter schema? |
+
+ | Read credentials |
+ YES |
+ YES |
+ YES |
+ YES |
+
+
+ | Write credentials |
+ YES |
+ YES |
+ YES |
+ YES |
+
+
+ | Admin credentials |
+ YES |
+ YES |
+ YES |
+ YES |
+
+
+
+
Connect to database
Before you fill this in, you will need to have created a database on a MySQL server that this web server can access, and set up user accounts that can access it. For security reasons, we require having three separate accounts - one for reading (needs SELECT only), one for writing (SELECT and EXECUTE), and one for admin. All three accounts also need SELECT permissions on the mysql database.
diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs
index d8411ecb..d3653861 100644
--- a/Site5/Pages/v5/Init/Default.aspx.cs
+++ b/Site5/Pages/v5/Init/Default.aspx.cs
@@ -614,6 +614,59 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
return SwarmDb.Configuration.TestConfigurationWritable();
}
+ [WebMethod(true)]
+ public static PermissionsAnalysis TestDatabasePermissions()
+ {
+ PermissionsAnalysis result = new PermissionsAnalysis();
+ result.AllPermissionsOk = false;
+ result.ReadCredentialsCanLogin = RandomBool();
+ result.ReadCredentialsCanSelect = RandomBool();
+ result.ReadCredentialsCanExecute = RandomBool();
+ result.ReadCredentialsCanAdmin = RandomBool();
+ result.WriteCredentialsCanLogin = RandomBool();
+ result.WriteCredentialsCanSelect = RandomBool();
+ result.WriteCredentialsCanExecute = RandomBool();
+ result.WriteCredentialsCanAdmin = RandomBool();
+ result.AdminCredentialsCanLogin = RandomBool();
+ result.AdminCredentialsCanSelect = RandomBool();
+ result.AdminCredentialsCanExecute = RandomBool();
+ result.AdminCredentialsCanAdmin = RandomBool();
+
+ return result;
+ }
+
+ private static bool RandomBool()
+ {
+ return (GetRandomNumber(0, 1) == 0);
+ }
+
+ //Function to get random number
+ private static readonly Random GetRandom = new Random();
+ private static readonly object syncLock = new object();
+ private static int GetRandomNumber(int min, int max)
+ {
+ lock(syncLock) { // synchronize
+ return GetRandom.Next(min, max+1);
+ }
+ }
+
+ public class PermissionsAnalysis
+ {
+ public bool AllPermissionsOk { get; set; }
+ public bool ReadCredentialsCanLogin { get; set; }
+ public bool ReadCredentialsCanSelect { get; set; }
+ public bool ReadCredentialsCanExecute { get; set; }
+ public bool ReadCredentialsCanAdmin { get; set; }
+ public bool WriteCredentialsCanLogin { get; set; }
+ public bool WriteCredentialsCanSelect { get; set; }
+ public bool WriteCredentialsCanExecute { get; set; }
+ public bool WriteCredentialsCanAdmin { get; set; }
+ public bool AdminCredentialsCanLogin { get; set; }
+ public bool AdminCredentialsCanSelect { get; set; }
+ public bool AdminCredentialsCanExecute { get; set; }
+ public bool AdminCredentialsCanAdmin { get; set; }
+ }
+
[WebMethod(true)]
public static void CreateFirstUser(string name, string mail, string password)
{