swanctl: Allow specifying pubkeys directly via 0x/0s prefix
This commit is contained in:
parent
bd6ef6be7e
commit
75665375b7
|
@ -98,13 +98,23 @@ static void add_list_key(vici_req_t *req, char *key, char *value)
|
||||||
static bool add_file_list_key(vici_req_t *req, char *key, char *value)
|
static bool add_file_list_key(vici_req_t *req, char *key, char *value)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
chunk_t *map;
|
chunk_t *map, blob;
|
||||||
char *token, buf[PATH_MAX];
|
char *token, buf[PATH_MAX];
|
||||||
bool ret = TRUE;
|
bool ret = TRUE;
|
||||||
|
|
||||||
vici_begin_list(req, key);
|
vici_begin_list(req, key);
|
||||||
enumerator = enumerator_create_token(value, ",", " ");
|
enumerator = enumerator_create_token(value, ",", " ");
|
||||||
while (enumerator->enumerate(enumerator, &token))
|
while (enumerator->enumerate(enumerator, &token))
|
||||||
|
{
|
||||||
|
if (strcasepfx(token, "0x") || strcasepfx(token, "0s"))
|
||||||
|
{
|
||||||
|
blob = chunk_from_str(token + 2);
|
||||||
|
blob = strcasepfx(token, "0x") ? chunk_from_hex(blob, NULL)
|
||||||
|
: chunk_from_base64(blob, NULL);
|
||||||
|
vici_add_list_item(req, blob.ptr, blob.len);
|
||||||
|
chunk_free(&blob);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!path_absolute(token))
|
if (!path_absolute(token))
|
||||||
{
|
{
|
||||||
|
@ -127,7 +137,6 @@ static bool add_file_list_key(vici_req_t *req, char *key, char *value)
|
||||||
token = buf;
|
token = buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
map = chunk_map(token, FALSE);
|
map = chunk_map(token, FALSE);
|
||||||
if (map)
|
if (map)
|
||||||
{
|
{
|
||||||
|
@ -142,6 +151,7 @@ static bool add_file_list_key(vici_req_t *req, char *key, char *value)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
vici_end_list(req);
|
vici_end_list(req);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue