Skip to content

Commit cb6b96c

Browse files
committed
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.
1 parent 3535f88 commit cb6b96c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public class EncryptionSecretKeyChecker extends AdapterBase implements SystemInt
4545

4646
private static final Logger s_logger = Logger.getLogger(EncryptionSecretKeyChecker.class);
4747

48-
private static final String s_keyFile = "/etc/cloud/management/key";
48+
// Two possible locations with the new packaging naming
49+
private static final String s_altKeyFile = "/etc/cloud/management/key";
50+
private static final String s_keyFile = "/etc/cloudstack/management/key";
4951
private static final String s_envKey = "CLOUD_SECRET_KEY";
5052
private static StandardPBEStringEncryptor s_encryptor = new StandardPBEStringEncryptor();
5153
private static boolean s_useEncryption = false;
@@ -76,8 +78,12 @@ public void check() {
7678
SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
7779

7880
if(encryptionType.equals("file")){
81+
File keyFile = new File(s_keyFile);
82+
if (!keyFile.exists()) {
83+
keyFile = new File(s_altKeyFile);
84+
}
7985
try {
80-
BufferedReader in = new BufferedReader(new FileReader(s_keyFile));
86+
BufferedReader in = new BufferedReader(new FileReader(keyFile));
8187
secretKey = in.readLine();
8288
//Check for null or empty secret key
8389
} catch (FileNotFoundException e) {

0 commit comments

Comments
 (0)