diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-01-19 11:26:48 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-01-19 11:35:21 +0200 |
commit | 4d1258de786a83888d123f4e8f791f1ad6ecf605 (patch) | |
tree | e172edcda699af4b7db72f42e30f4399866b339b /src/eclat.c | |
parent | 0766417065bfec9747bf0f41f9b68c27e378f817 (diff) | |
download | eclat-4d1258de786a83888d123f4e8f791f1ad6ecf605.tar.gz eclat-4d1258de786a83888d123f4e8f791f1ad6ecf605.tar.bz2 |
Initial support for IAM
* NEWS: Update.
* doc/eclat.1man: Update.
* lib/.gitignore: Update.
* lib/Makefile.am (libeclat_a_SOURCES): Add new files.
* lib/json.h: New file.
* lib/jsongrm.y: New file.
* lib/jsonlex.l: New file.
* lib/yytrans: New file.
* lib/libeclat.h (ec2_query) <token>: New member
(eclat_query_create): Change signature.
* lib/qcreat.c (eclat_query_create): Take security token as 5th
argument.
* lib/reqsign.c (querysign2): Add security token.
* src/cmdline.opt: Update copyright years
* src/ec2map.c (ec2_map_get): Pass security token to
eclat_query_create.
* src/eclat.c (security_token): New variable.
(eclat_do_command): Pass security token to
eclat_query_create.
(main): Get authentication credentials from the instance
store, if not found in the access file.
* src/eclat.h (security_token): New extern.
(eclat_get_instance_creds): New proto.
* src/util.c (eclat_get_instance_zone): Use json parser.
(eclat_get_instance_creds): New function.
* tests/Makefile.am (noinst_PROGRAMS): add tjson
* tests/tjson.c: New file.
Diffstat (limited to 'src/eclat.c')
-rw-r--r-- | src/eclat.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/eclat.c b/src/eclat.c index 88592d2..5bbe7c4 100644 --- a/src/eclat.c +++ b/src/eclat.c @@ -26,6 +26,7 @@ char *endpoint = "ec2.amazonaws.com"; char *signature_version = "2"; char *access_key; char *secret_key; +char *security_token; char *region_name; int use_ssl; int ssl_verify_peer = 1; @@ -645,7 +646,8 @@ eclat_do_command(eclat_command_env_t *env, struct eclat_command *command, if (!(command->flags & CMD_NOQRY)) { env->query = eclat_query_create(use_ssl ? EC2_QF_HTTPS : 0, endpoint, "/", - region_name, access_key); + region_name, access_key, + security_token); } if (command->tag) @@ -769,9 +771,16 @@ main(int argc, char **argv) "cannot find endpoint for region %s", region_name); if (!secret_key) { - if (get_access_creds(access_key, &access_key, &secret_key)) - die(EX_UNAVAILABLE, - "cannot find authentication credentials"); + 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); + } } debug(ECLAT_DEBCAT_MAIN, 1, ("using access key %s", access_key)); |