From cb6b96cda22dbdb7a1fe636ec2f7de6664aaf8ec Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Tue, 5 Feb 2013 20:48:23 +0100 Subject: [PATCH] Summary: Path changes for new rpm packaging The path to the keyfile was hardcoded, so added an alternative path for compatibility with the packaging locations. Should ideally become a setting in the config file. --- .../cloud/utils/crypt/EncryptionSecretKeyChecker.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java b/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java index 63f841dbb7b..c717a3a705d 100755 --- a/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java +++ b/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java @@ -45,7 +45,9 @@ public class EncryptionSecretKeyChecker extends AdapterBase implements SystemInt private static final Logger s_logger = Logger.getLogger(EncryptionSecretKeyChecker.class); - private static final String s_keyFile = "/etc/cloud/management/key"; + // Two possible locations with the new packaging naming + private static final String s_altKeyFile = "/etc/cloud/management/key"; + private static final String s_keyFile = "/etc/cloudstack/management/key"; private static final String s_envKey = "CLOUD_SECRET_KEY"; private static StandardPBEStringEncryptor s_encryptor = new StandardPBEStringEncryptor(); private static boolean s_useEncryption = false; @@ -76,8 +78,12 @@ public class EncryptionSecretKeyChecker extends AdapterBase implements SystemInt SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig(); if(encryptionType.equals("file")){ + File keyFile = new File(s_keyFile); + if (!keyFile.exists()) { + keyFile = new File(s_altKeyFile); + } try { - BufferedReader in = new BufferedReader(new FileReader(s_keyFile)); + BufferedReader in = new BufferedReader(new FileReader(keyFile)); secretKey = in.readLine(); //Check for null or empty secret key } catch (FileNotFoundException e) {