Skip to content

Commit 0d86b83

Browse files
committed
config: Add back support for KEYLIME_DIR env var
Add back the support for overriding the 'keylime_dir' option by setting the 'KEYLIME_DIR' environment variable. Note that it is also possible to override the 'keylime_dir' option by setting the 'KEYLIME_AGENT_KEYLIME_DIR' environment variable, although 'KEYLIME_DIR' has priority. Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
1 parent cd95457 commit 0d86b83

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/config.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,33 +439,45 @@ fn config_translate_keywords(
439439
) -> Result<KeylimeConfig, Error> {
440440
let uuid = get_uuid(&config.agent.uuid);
441441

442+
let env_keylime_dir = env::var("KEYLIME_DIR").ok();
443+
let keylime_dir = match env_keylime_dir {
444+
Some(ref dir) => {
445+
if !dir.is_empty() {
446+
dir.to_string()
447+
} else {
448+
config.agent.keylime_dir.to_string()
449+
}
450+
}
451+
None => config.agent.keylime_dir.to_string(),
452+
};
453+
442454
let mut agent_data_path = config_get_file_path(
443455
&config.agent.agent_data_path,
444-
&config.agent.keylime_dir,
456+
&keylime_dir,
445457
DEFAULT_AGENT_DATA_PATH,
446458
);
447459

448460
let mut server_key = config_get_file_path(
449461
&config.agent.server_key,
450-
&config.agent.keylime_dir,
462+
&keylime_dir,
451463
DEFAULT_SERVER_KEY,
452464
);
453465

454466
let mut server_cert = config_get_file_path(
455467
&config.agent.server_cert,
456-
&config.agent.keylime_dir,
468+
&keylime_dir,
457469
DEFAULT_SERVER_CERT,
458470
);
459471

460472
let mut trusted_client_ca = config_get_file_path(
461473
&config.agent.trusted_client_ca,
462-
&config.agent.keylime_dir,
474+
&keylime_dir,
463475
DEFAULT_TRUSTED_CLIENT_CA,
464476
);
465477

466478
let mut revocation_cert = config_get_file_path(
467479
&config.agent.revocation_cert,
468-
&config.agent.keylime_dir,
480+
&keylime_dir,
469481
&format!("secure/unzipped/{}", DEFAULT_REVOCATION_CERT),
470482
);
471483

@@ -527,6 +539,7 @@ fn config_translate_keywords(
527539

528540
Ok(KeylimeConfig {
529541
agent: AgentConfig {
542+
keylime_dir,
530543
uuid,
531544
server_key,
532545
server_cert,

0 commit comments

Comments
 (0)