diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-01-19 22:26:04 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-01-19 22:26:04 +0200 |
commit | 17627658ac616fcbb7d76977b3efacb14884a784 (patch) | |
tree | 9458d00f2a65669923b6e861a46e8dda3a2a5657 /src/eclat.c | |
parent | 9342c2d779b78b55e7e3b555930c5d3d0423ec40 (diff) | |
download | eclat-17627658ac616fcbb7d76977b3efacb14884a784.tar.gz eclat-17627658ac616fcbb7d76977b3efacb14884a784.tar.bz2 |
New configuration statement authentication-provide
* NEWS: Update.
* src/config.c: New statement "authentication-provider"
* src/eclat.c (authentication_provider): New variable.
(main): Select credentials depending on the value of
authentication_provider.
* src/eclat.h (authentication_provider): New enum and extern.
Diffstat (limited to 'src/eclat.c')
-rw-r--r-- | src/eclat.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/eclat.c b/src/eclat.c index 5bbe7c4..67b20dd 100644 --- a/src/eclat.c +++ b/src/eclat.c @@ -24,6 +24,8 @@ int preprocess_only = 0; char *endpoint = "ec2.amazonaws.com"; char *signature_version = "2"; + +enum authentication_provider authentication_provider = authp_undefined; char *access_key; char *secret_key; char *security_token; @@ -769,18 +771,29 @@ main(int argc, char **argv) if (!endpoint) die(EX_USAGE, "cannot find endpoint for region %s", region_name); - - if (!secret_key) { + + if (access_key && secret_key) + authentication_provider = authp_immediate; + + switch (authentication_provider) { + case authp_undefined: + die(EX_USAGE, "cannot find authentication credentials"); + + case authp_immediate: + break; + + case authp_file: if (get_access_creds(access_key, &access_key, &secret_key)) { - if (!access_key) - die(EX_UNAVAILABLE, - "cannot find authentication credentials"); - else - eclat_get_instance_creds(access_key, - &access_key, - &secret_key, - &security_token); + die(EX_UNAVAILABLE, + "cannot find authentication credentials"); } + break; + + case authp_instance: + eclat_get_instance_creds(access_key, + &access_key, + &secret_key, + &security_token); } debug(ECLAT_DEBCAT_MAIN, 1, ("using access key %s", access_key)); |