aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2015-01-22 00:44:27 +0200
committerSergey Poznyakoff <gray@gnu.org>2015-01-22 00:44:27 +0200
commit0c7bb2d5cb81eb6077a8907ce2049278fb8e47ce (patch)
tree7392dad30ac09b3ff32bfb2882710b5117fdde35 /src/config.c
parent03c5b9aac73c6a70b1c67f467bbd484d2a532f10 (diff)
downloadeclat-0c7bb2d5cb81eb6077a8907ce2049278fb8e47ce.tar.gz
eclat-0c7bb2d5cb81eb6077a8907ce2049278fb8e47ce.tar.bz2
authentication-provider instance-store does not require role name argument
* NEWS: Update. * doc/eclat.conf.5: Update. * lib/Makefile.am: Add new sources. * lib/istore.c: New file. * lib/path.c: New file. * lib/libeclat.h (path_concat) (instance_store_curl_new) (instance_store_read): New protos. * src/config.c (cb_authentication_provider): second argument is optional for instance-store type. New compound statement: instance-store. * src/eclat.h (instance_store_base_url) (instance_store_port,instance_store_document_path): (instance_store_credentials_path): New externs. * src/ispeek.c: Rewrite using new functions. * src/util.c: Likewise.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c72
1 files changed, 55 insertions, 17 deletions
diff --git a/src/config.c b/src/config.c
index d3c8a66..ec676b7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -261,37 +261,55 @@ cb_authentication_provider(enum grecs_callback_command cmd,
grecs_value_t *value,
void *cb_data)
{
- char *s;
+ char *type;
+ char *arg = NULL;
if (cmd != grecs_callback_set_value) {
grecs_error(locus, 0, "Unexpected block statement");
return 1;
}
- if (!value || value->type != GRECS_TYPE_ARRAY || value->v.arg.c != 2) {
- grecs_error(locus, 0, "expected two values");
- return 1;
- }
- if (value->v.arg.v[0]->type != GRECS_TYPE_STRING) {
- grecs_error(&value->v.arg.v[0]->locus, 0,
- "first argument not a string");
- return 1;
- }
- if (value->v.arg.v[1]->type != GRECS_TYPE_STRING) {
- grecs_error(&value->v.arg.v[1]->locus, 0,
- "second argument not a string");
+ if (!value) {
+ grecs_error(locus, 0, "expected one to two values");
return 1;
}
+ if (value->type == GRECS_TYPE_ARRAY) {
+ if (value->v.arg.c != 2) {
+ grecs_error(locus, 0, "expected one to two values");
+ return 1;
+ }
+ if (value->v.arg.v[0]->type != GRECS_TYPE_STRING) {
+ grecs_error(&value->v.arg.v[0]->locus, 0,
+ "first argument not a string");
+ return 1;
+ }
+ if (value->v.arg.v[1]->type != GRECS_TYPE_STRING) {
+ grecs_error(&value->v.arg.v[1]->locus, 0,
+ "second argument not a string");
+ return 1;
+ }
- s = value->v.arg.v[0]->v.string;
+ type = value->v.arg.v[0]->v.string;
+ arg = value->v.arg.v[1]->v.string;
+ } else if (value->type == GRECS_TYPE_STRING) {
+ type = value->v.string;
+ arg = NULL;
+ }
- if (strcmp(s, "file") == 0) {
+ if (strcmp(type, "file") == 0) {
+ if (arg) {
+ grecs_error(locus, 0, "requered argument missing");
+ return 1;
+ }
authentication_provider = authp_file;
free(access_file_name);
access_file_name = grecs_strdup(value->v.arg.v[1]->v.string);
- } else if (strcmp(s, "instance-store") == 0) {
+ } else if (strcmp(type, "instance-store") == 0) {
authentication_provider = authp_instance;
free(access_key);
- access_key = grecs_strdup(value->v.arg.v[1]->v.string);
+ if (arg)
+ access_key = grecs_strdup(arg);
+ else
+ access_key = NULL;
} else {
grecs_error(&value->locus, 0, "unknown provider");
}
@@ -320,6 +338,22 @@ cb_access_file(enum grecs_callback_command cmd,
return 0;
}
+static struct grecs_keyword instance_store_kw[] = {
+ { "base-url", "URL",
+ "Base URL of the instance store",
+ grecs_type_string, GRECS_DFLT, &instance_store_base_url },
+ { "port", "NUMBER",
+ "Port number",
+ grecs_type_ushort, GRECS_DFLT, &instance_store_port },
+ { "document-path", "PATH",
+ "Path to the instance identity document file",
+ grecs_type_ushort, GRECS_DFLT, &instance_store_document_path },
+ { "credentials-path", "PATH",
+ "Path to the instance store credentials directory",
+ grecs_type_ushort, GRECS_DFLT, &instance_store_credentials_path },
+ { NULL }
+};
+
static struct grecs_keyword eclat_kw[] = {
{ "default-endpoint", "hostname",
"Set default EC2 endpoint",
@@ -370,6 +404,10 @@ static struct grecs_keyword eclat_kw[] = {
{ "translate", NULL,
"Use ID translation by default",
grecs_type_bool, GRECS_DFLT, &translation_enabled },
+ { "instance-store", NULL,
+ "Configure instance store parameters",
+ grecs_type_section, GRECS_DFLT,
+ NULL, 0, NULL, NULL, instance_store_kw },
{ NULL }
};

Return to:

Send suggestions and report system problems to the System administrator.