diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index ef366d91..cc7f2770 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -96,8 +96,6 @@ } else { // Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds. - alert('setting first timeout function'); - setTimeout('recheckConfigurationWritability();', 5000); // 5s until first re-check } } @@ -137,8 +135,6 @@ function recheckConfigurationWritability() { - alert('In timeout function'); - $.ajax({ type: "POST", url: "Default.aspx/IsConfigurationFileWritable", @@ -149,8 +145,6 @@ success: function (msg) { if (msg.d == true) { - alert('yes, writable'); - // Yes, config is writable. Hide "unwritable" div, show "writable" div, all is nice $('#DivDatabaseUnwritable').slideUp('fast').fadeOut('fast'); $('#DivDatabaseWritable').fadeIn('fast'); diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index 90f01944..412b8327 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -294,9 +294,21 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page [WebMethod] public static bool VerifyHostName(string input) { + if (System.Diagnostics.Debugger.IsAttached) + { + return true; // Cannot read "/etc/hostname" in Windows environment + } + // validate against /etc/hostname - - if (input == "/etc/hostname") + + string realHostName; + + using (TextReader reader = new StreamReader("/etc/hostname")) // This will throw in a Windows dev environment + { + realHostName = reader.ReadLine(); + } + + if (String.Compare(input, realHostName, true, CultureInfo.InvariantCulture) == 0) // case-insensitive compare { return true; } @@ -304,10 +316,12 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page return false; } - [WebMethod] + [WebMethod(true)] public static bool VerifyHostAddress (string input) { - if (input == "127.0.0.1") + string localAddress = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]; + + if (input == localAddress) { return true; } @@ -315,7 +329,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page return false; } - [WebMethod] + [WebMethod(true)] public static bool VerifyHostNameAndAddress (string name, string address) { return VerifyHostName(name) && VerifyHostAddress(address);