diff --git a/BuildFiles/Packaging/scripts/repackage-one b/BuildFiles/Packaging/scripts/repackage-one index e95e6f93..8ad047f1 100755 --- a/BuildFiles/Packaging/scripts/repackage-one +++ b/BuildFiles/Packaging/scripts/repackage-one @@ -104,6 +104,7 @@ if [ "$COPYFILES" == "yes" ]; then mkdir -p etc/swarmops mv $DEPLOYDIR/$TARGETDIR/machineKey.config etc/swarmops/. sed -i 's/\"machineKey.config\"/\"..\/..\/..\/..\/etc\/swarmops\/machineKey.config\"/g' $DEPLOYDIR/$TARGETDIR/web.config + cat "UNINITIALIZED" > etc/swarmops/symmetricKey.config fi fi diff --git a/BuildFiles/Packaging/templates/conffiles-frontend.template b/BuildFiles/Packaging/templates/conffiles-frontend.template index 7a6ad444..85c0fac6 100644 --- a/BuildFiles/Packaging/templates/conffiles-frontend.template +++ b/BuildFiles/Packaging/templates/conffiles-frontend.template @@ -1,2 +1,3 @@ /etc/swarmops/machineKey.config +/etc/swarmops/symmetricKey.config /usr/share/swarmops/frontend/favicon.ico diff --git a/BuildFiles/Packaging/templates/postinst-frontend.template b/BuildFiles/Packaging/templates/postinst-frontend.template index 135bd74f..f5967518 100644 --- a/BuildFiles/Packaging/templates/postinst-frontend.template +++ b/BuildFiles/Packaging/templates/postinst-frontend.template @@ -18,6 +18,10 @@ chown www-data:www-data /etc/swarmops/machineKey.config chown www-data:www-data /etc/swarmops/database.config +# make sure the web frontend (and its init) can write to symmetricKey.config + +chown www-data:www-data /etc/swarmops/symmetricKey.config + # if we stopped Apache in preinst (1st install), restart it if [ -e /tmp/swarmops-restart-apache.flag ]; then diff --git a/Logic/Security/Authentication.cs b/Logic/Security/Authentication.cs index 0bb25ae2..e407e249 100644 --- a/Logic/Security/Authentication.cs +++ b/Logic/Security/Authentication.cs @@ -602,7 +602,10 @@ namespace Swarmops.Logic.Security if (File.Exists ("/etc/swarmops/symmetricKey.config")) { - throw new InvalidOperationException("Can't overwrite encryption key - BAD BAD BAD code!"); + if (!File.ReadAllText ("/etc/swarmops/symmetricKey.config").StartsWith ("UNINIT")) + { + throw new InvalidOperationException ("Can't overwrite encryption key - BAD BAD BAD code!"); + } } using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider()) diff --git a/Logic/Support/SystemSettings.cs b/Logic/Support/SystemSettings.cs index f87c4d8e..8ac268ea 100644 --- a/Logic/Support/SystemSettings.cs +++ b/Logic/Support/SystemSettings.cs @@ -180,14 +180,17 @@ namespace Swarmops.Logic.Support _cacheFileSystemSymmetricKey = new byte[32]; // return 256 bits all zero } - else if (!File.Exists ("/etc/swarmops/symmetricKey.config")) - { - _cacheFileSystemSymmetricKey = Authentication.InitializeSymmetricFileSystemKey(); - } else { string keyString = File.ReadAllText ("/etc/swarmops/symmetricKey.config", Encoding.ASCII); - _cacheFileSystemSymmetricKey = Convert.FromBase64String (keyString); + if (keyString.StartsWith ("UNINIT")) + { + _cacheFileSystemSymmetricKey = Authentication.InitializeSymmetricFileSystemKey(); + } + else + { + _cacheFileSystemSymmetricKey = Convert.FromBase64String(keyString); + } } return _cacheFileSystemSymmetricKey; diff --git a/Site5/Default.aspx.cs b/Site5/Default.aspx.cs index 1b137814..f99b799e 100644 --- a/Site5/Default.aspx.cs +++ b/Site5/Default.aspx.cs @@ -13,7 +13,7 @@ public partial class Default : PageV5Base PageIcon = "iconshock-steering-wheel"; this.PageAccessRequired = new Access(AccessAspect.Null, AccessType.Read); // dummy security until there's something to show on Dashboard - // byte[] symmetricKey = SystemSettings.SymmetricEncryptionKeyFileSystem; // Access forces initialization if it's not there: remove by Alpha-12 // TODO + byte[] symmetricKey = SystemSettings.SymmetricEncryptionKeyFileSystem; // Access forces initialization if it's not there: remove by Alpha-12 // TODO /* this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle;