Improve keyring environment variables

Rename to SERVALD_...

Interpret SERVALD_KEYRING_PATH relative to instance dir unless absolute.

Explicitly unset them in setup_servald() test defs function
This commit is contained in:
Andrew Bettison 2013-08-30 11:14:56 +09:30
parent 3164172c08
commit aa20fd1a9b
2 changed files with 9 additions and 8 deletions

View File

@ -1500,20 +1500,19 @@ keyring_file *keyring_open_instance()
if (create_serval_instance_dir() == -1)
RETURN(NULL);
// Work out the absolute path to the keyring file.
const char *keyringpath = getenv("SERVAL_KEYRING_PATH");
const char *env = getenv("SERVALD_KEYRING_PATH");
if (!env)
env = "serval.keyring";
char keyringFile[1024];
if (!keyringpath) {
if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, "serval.keyring"))
RETURN(NULL);
keyringpath = keyringFile;
}
if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, env))
RETURN(NULL);
// Work out if the keyring file is writeable.
int writeable = 0;
const char *readonly_env = getenv("SERVAL_KEYRING_READONLY");
const char *readonly_env = getenv("SERVALD_KEYRING_READONLY");
bool_t readonly_b;
if (readonly_env == NULL || cf_opt_boolean(&readonly_b, readonly_env) != CFOK || !readonly_b)
writeable = 1;
if ((k = keyring_open(keyringpath, writeable)) == NULL)
if ((k = keyring_open(keyringFile, writeable)) == NULL)
RETURN(NULL);
RETURN(k);
OUT();

View File

@ -90,6 +90,8 @@ setup_servald() {
unset SERVALD_SERVER_CHDIR
unset SERVALD_START_POST_SLEEP
unset SERVALD_LOG_FILE
unset SERVALD_KEYRING_PATH
unset SERVALD_KEYRING_READONLY
servald_instances_dir="$SERVALD_VAR/instance"
set_instance +Z
}