diff options
Diffstat (limited to 'src/swanctl/commands')
-rw-r--r-- | src/swanctl/commands/load_all.c | 5 | ||||
-rw-r--r-- | src/swanctl/commands/load_authorities.c | 11 | ||||
-rw-r--r-- | src/swanctl/commands/load_conns.c | 20 | ||||
-rw-r--r-- | src/swanctl/commands/load_creds.c | 20 | ||||
-rw-r--r-- | src/swanctl/commands/load_pools.c | 5 | ||||
-rw-r--r-- | src/swanctl/commands/rekey.c | 2 | ||||
-rw-r--r-- | src/swanctl/commands/terminate.c | 2 |
7 files changed, 36 insertions, 29 deletions
diff --git a/src/swanctl/commands/load_all.c b/src/swanctl/commands/load_all.c index 26f043a6a..d0032467a 100644 --- a/src/swanctl/commands/load_all.c +++ b/src/swanctl/commands/load_all.c @@ -31,7 +31,7 @@ static int load_all(vici_conn_t *conn) bool clear = FALSE, noprompt = FALSE; command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; - char *arg, *file = SWANCTL_CONF; + char *arg, *file = NULL; int ret = 0; while (TRUE) @@ -63,10 +63,9 @@ static int load_all(vici_conn_t *conn) break; } - cfg = settings_create(file); + cfg = load_swanctl_conf(file); if (!cfg) { - fprintf(stderr, "parsing '%s' failed\n", file); return EINVAL; } diff --git a/src/swanctl/commands/load_authorities.c b/src/swanctl/commands/load_authorities.c index 61682a386..a4e1f46d3 100644 --- a/src/swanctl/commands/load_authorities.c +++ b/src/swanctl/commands/load_authorities.c @@ -55,8 +55,9 @@ static bool add_file_key_value(vici_req_t *req, char *key, char *value) else { path = buf; - snprintf(path, PATH_MAX, "%s%s%s", - SWANCTL_X509CADIR, DIRECTORY_SEPARATOR, value); + snprintf(path, PATH_MAX, "%s%s%s%s%s", swanctl_dir, + DIRECTORY_SEPARATOR, SWANCTL_X509CADIR, + DIRECTORY_SEPARATOR, value); } map = chunk_map(path, FALSE); @@ -83,7 +84,6 @@ static bool add_key_values(vici_req_t *req, enumerator_t *enumerator) char *key, *value; bool ret = TRUE; - while (enumerator->enumerate(enumerator, &key, &value)) { if (streq(key, "cacert")) @@ -310,7 +310,7 @@ static int load_authorities(vici_conn_t *conn) { command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; - char *arg, *file = SWANCTL_CONF; + char *arg, *file = NULL; int ret; while (TRUE) @@ -336,10 +336,9 @@ static int load_authorities(vici_conn_t *conn) break; } - cfg = settings_create(file); + cfg = load_swanctl_conf(file); if (!cfg) { - fprintf(stderr, "parsing '%s' failed\n", file); return EINVAL; } diff --git a/src/swanctl/commands/load_conns.c b/src/swanctl/commands/load_conns.c index dad03945d..de23816fb 100644 --- a/src/swanctl/commands/load_conns.c +++ b/src/swanctl/commands/load_conns.c @@ -120,20 +120,23 @@ static bool add_file_list_key(vici_req_t *req, char *key, char *value) { if (streq(key, "certs")) { - snprintf(buf, sizeof(buf), "%s%s%s", - SWANCTL_X509DIR, DIRECTORY_SEPARATOR, token); + snprintf(buf, sizeof(buf), "%s%s%s%s%s", swanctl_dir, + DIRECTORY_SEPARATOR, SWANCTL_X509DIR, + DIRECTORY_SEPARATOR, token); token = buf; } else if (streq(key, "cacerts")) { - snprintf(buf, sizeof(buf), "%s%s%s", - SWANCTL_X509CADIR, DIRECTORY_SEPARATOR, token); + snprintf(buf, sizeof(buf), "%s%s%s%s%s", swanctl_dir, + DIRECTORY_SEPARATOR, SWANCTL_X509CADIR, + DIRECTORY_SEPARATOR, token); token = buf; } else if (streq(key, "pubkeys")) { - snprintf(buf, sizeof(buf), "%s%s%s", - SWANCTL_PUBKEYDIR, DIRECTORY_SEPARATOR, token); + snprintf(buf, sizeof(buf), "%s%s%s%s%s", swanctl_dir, + DIRECTORY_SEPARATOR, SWANCTL_PUBKEYDIR, + DIRECTORY_SEPARATOR, token); token = buf; } } @@ -425,7 +428,7 @@ static int load_conns(vici_conn_t *conn) { command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; - char *arg, *file = SWANCTL_CONF; + char *arg, *file = NULL; int ret; while (TRUE) @@ -451,10 +454,9 @@ static int load_conns(vici_conn_t *conn) break; } - cfg = settings_create(file); + cfg = load_swanctl_conf(file); if (!cfg) { - fprintf(stderr, "parsing '%s' failed\n", file); return EINVAL; } diff --git a/src/swanctl/commands/load_creds.c b/src/swanctl/commands/load_creds.c index a9e352f7e..9a38b5d1e 100644 --- a/src/swanctl/commands/load_creds.c +++ b/src/swanctl/commands/load_creds.c @@ -106,10 +106,13 @@ static void load_certs(load_ctx_t *ctx, char *type_str, char *dir) x509_flag_t flag; struct stat st; chunk_t *map; - char *path; + char *path, buf[PATH_MAX]; vici_cert_info_from_str(type_str, &type, &flag); + snprintf(buf, sizeof(buf), "%s%s%s", swanctl_dir, DIRECTORY_SEPARATOR, dir); + dir = buf; + enumerator = enumerator_create_directory(dir); if (enumerator) { @@ -428,7 +431,10 @@ static void load_keys(load_ctx_t *ctx, char *type, char *dir) enumerator_t *enumerator; struct stat st; chunk_t *map; - char *path, *rel; + char *path, *rel, buf[PATH_MAX]; + + snprintf(buf, sizeof(buf), "%s%s%s", swanctl_dir, DIRECTORY_SEPARATOR, dir); + dir = buf; enumerator = enumerator_create_directory(dir); if (enumerator) @@ -535,7 +541,10 @@ static void load_containers(load_ctx_t *ctx, char *type, char *dir) enumerator_t *enumerator; struct stat st; chunk_t *map; - char *path, *rel; + char *path, *rel, buf[PATH_MAX]; + + snprintf(buf, sizeof(buf), "%s%s%s", swanctl_dir, DIRECTORY_SEPARATOR, dir); + dir = buf; enumerator = enumerator_create_directory(dir); if (enumerator) @@ -946,7 +955,7 @@ static int load_creds(vici_conn_t *conn) bool clear = FALSE, noprompt = FALSE; command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; - char *arg, *file = SWANCTL_CONF; + char *arg, *file = NULL; int ret; while (TRUE) @@ -978,10 +987,9 @@ static int load_creds(vici_conn_t *conn) break; } - cfg = settings_create(file); + cfg = load_swanctl_conf(file); if (!cfg) { - fprintf(stderr, "parsing '%s' failed\n", file); return EINVAL; } diff --git a/src/swanctl/commands/load_pools.c b/src/swanctl/commands/load_pools.c index ec9508efb..0ff6827e1 100644 --- a/src/swanctl/commands/load_pools.c +++ b/src/swanctl/commands/load_pools.c @@ -251,7 +251,7 @@ static int load_pools(vici_conn_t *conn) { command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; - char *arg, *file = SWANCTL_CONF; + char *arg, *file = NULL; int ret; while (TRUE) @@ -277,10 +277,9 @@ static int load_pools(vici_conn_t *conn) break; } - cfg = settings_create(file); + cfg = load_swanctl_conf(file); if (!cfg) { - fprintf(stderr, "parsing '%s' failed\n", file); return EINVAL; } diff --git a/src/swanctl/commands/rekey.c b/src/swanctl/commands/rekey.c index f44ecaa3c..65a402029 100644 --- a/src/swanctl/commands/rekey.c +++ b/src/swanctl/commands/rekey.c @@ -118,7 +118,7 @@ static void __attribute__ ((constructor))reg() { command_register((command_t) { rekey, 'R', "rekey", "rekey an SA", - {"--child <name> | --ike <name | --child-id <id> | --ike-id <id>", + {"--child <name> | --ike <name> | --child-id <id> | --ike-id <id>", "[--reauth] [--raw|--pretty]"}, { {"help", 'h', 0, "show usage information"}, diff --git a/src/swanctl/commands/terminate.c b/src/swanctl/commands/terminate.c index bce404a54..2309843b2 100644 --- a/src/swanctl/commands/terminate.c +++ b/src/swanctl/commands/terminate.c @@ -150,7 +150,7 @@ static void __attribute__ ((constructor))reg() { command_register((command_t) { terminate, 't', "terminate", "terminate a connection", - {"--child <name> | --ike <name | --child-id <id> | --ike-id <id>", + {"--child <name> | --ike <name> | --child-id <id> | --ike-id <id>", "[--timeout <s>] [--raw|--pretty]"}, { {"help", 'h', 0, "show usage information"}, |