aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
AgeCommit message (Collapse)AuthorFiles
2023-10-30Update copyleft datesHEADmasterSergey Poznyakoff1
2021-01-06Update copyright yearsSergey Poznyakoff1
2018-03-15Minor fixesSergey Poznyakoff1
2018-03-15Upgrade grecsSergey Poznyakoff1
* grecs: pull * configure.ac: Enable json * lib/Makefile.am (AM_CPPFLAGS): Use @GRECS_INCLUDES@ (libeclat_a_SOURCES): Remove json sources. * src/Makefile.am (AM_CPPFLAGS): Use @GRECS_INCLUDES@ * tests/Makefile.am: Likewise. * lib/json.h: Remove. * lib/jsongrm.y: Remove. * lib/jsonlex.l: Remove. * tests/tjson.c: Remove. * src/config.c (eclat_kw): Mark statically initialized memory locations as such. * src/mktags.c (process_tags): Use wordsplit to process quoted arguments. * lib/bidimap.c (bidimap_config): Fill allocated memory with 0's * lib/filemap.c (filemap_config): Likewise. * lib/gdbmmap.c (gdbm_map_config): Likewise. * lib/seqmap.c (seqmap_config): Likewise.
2018-03-15Update docsSergey Poznyakoff1
2018-03-15Minor changesSergey Poznyakoff1
* src/util.c (eclat_send_request): Fix the AWS error string. Print a warning before sleeping. Fix memory leak.
2018-03-14Implement exponential backoff with jitter to handle RequestLimitExceededSergey Poznyakoff1
* src/eclat.h (eclat_command_env) <curl>: Remove. <xmltree>: New field. * src/util.c (translate_ids): Close the map when no longer needed (eclat_send_request): Implement exponential backoff. * src/ec2map.c: Reflect the above changes. * src/eclat.c: Likewise. * lib/libeclat.h (eclat_request_dup): New proto. * lib/reqcreat.c (eclat_request_dup): New function. * src/config.c: New configuration statements: max-retry-interval and retry-timeout.
2015-11-18Implement VPC and Internet Gateway commands.Sergey Poznyakoff1
New commands: lsvpc, lsvpcattr, mkvpc, setvpcattr, rmvpc, lsigw, mkigw, rmigw, atigw, deigw. * TODO: Update. * doc/Makefile.inc: Add mkvpc manpage. * etc/Makefile.am: Add create-vpc.fl and describe-vpcs.fln * etc/describe-vpc-attribute.fln: New file. * etc/describe-vpcs.fln: New file. * src/Makefile.am: Add new files. * src/igw.c: New file. * src/lsvpc.c: New file. * src/mkvpc-cl.opt: New file. * src/mkvpc.c: New file. * src/rmvpc.c: New file. * src/vpcattr.c: New file. * src/eclat.c (cmdtab): Register new subcommands. * src/eclat.h: Add new prototypes. * src/mksg-cl.opt: New option: --internet-gateway, -g * src/lsinst.c (parse_options): Define args_doc. * src/lsreg.c (parse_options): Remove useless return. * src/lstag-cl.opt: Likewise. * src/mktags-cl.opt: Remove stray character.
2015-01-23Implement HTTP POSTSergey Poznyakoff1
* NEWS: Update. * doc/eclat.conf.5: Document http-method. Reorganize description of endpoints and regions. * lib/libeclat.h (ec2_request) <postdata>: New member (eclat_request_finalize): New proto. * lib/req2url.c (eclat_request_to_url): Remove second argument. All uses changed. (eclat_request_finalize): New function. * lib/reqfree.c: Free postdata. * lib/reqsign.c (requestsign4): Implement post. * src/config.c: New configuration statement http-method. * src/eclat.c (use_post): New variable. * src/eclat.h (use_post): New extern. * src/util.c (eclat_send_request): Implement post.
2015-01-23Namespace fixup: use "request" consistentlySergey Poznyakoff1
2015-01-22Improve setting UserData attribute. Change lsistat defaults.Sergey Poznyakoff1
* NEWS: Update. * doc/eclat-setiattr.1: Document new options. * doc/eclat-lsistat.1: Update. * etc/describe-instance-attribute.fln: Decode userData. * grecs: Upgrade. * src/setiattr-cl.opt: New file. * src/Makefile.am (OPTFILES): Add setiattr-cl.opt * src/setiattr.c: Encode UserData. * src/eclat.h (read_file): New proto. * src/lsistat-cl.opt: New option -r (--running). * src/lsistat.c: Change default to show all instances, no matter their state. * src/mkinst-cl.opt (read_user_data): Remove. Use read_file instead. * src/sg.c: Add missing include. * src/util.c (read_file): New function.
2015-01-22Fix a typoSergey Poznyakoff1
2015-01-22authentication-provider instance-store does not require role name argumentSergey Poznyakoff1
* 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.
2015-01-19Initial support for IAMSergey Poznyakoff1
* 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.
2015-01-18If no region is specified, get it from the instance storeSergey Poznyakoff1
* src/eclat.c: If no region is specified, try to get it from the instance store. * src/eclat.h (eclat_trace_fun): New proto. (eclat_get_instance_zone): New proto. * src/io.c (eclat_trace_fun): Remove static qualifier. * src/util.c (eclat_get_instance_meta_data): New function. (eclat_get_instance_zone): New function.
2014-07-09Implement signature version 4 signing processSergey Poznyakoff1
* lib/libeclat.h (ec2_param) <encoded>: New member. (ec2_query) <signature>: Remove. <headers,region,access_key>: New members (eclat_query_create): Take two more arguments. All uses changed. (eclat_query_add_param_encoded) (eclat_query_add_header): New functions. * lib/q2url.c (eclat_query_to_url): Don't create Signature param: it is already in the param list (for v2 process). * lib/qaddparm.c (eclat_query_add_param_encoded): New function. (eclat_query_add_header): New function. * lib/qcreat.c (eclat_query_create): Take region and access key as additional parameters. * lib/qencode.c (encode_param): Skip parameters that have encoded set to true. * lib/reqsign.c (querysign2): Store access key in AWSAccessKeyId and the generated signature in the Signature parameters. (eclat_hex_encode): New function. (querysign4): Implement signature version 4 signing process. * src/ec2map.c: Update call to eclat_query_create. * src/eclat.c: Likewise. * src/util.c (eclat_send_query): Sign the query and add requested headers prior to sending. * doc/eclat.conf.5: Document signature-version. * NEWS: Likewise.
2014-02-04New commands: lsaattr and setaattr.Sergey Poznyakoff1
* TODO: Update. * doc/Makefile.inc: Add new files. * doc/eclat-lsaattr.1: New file. * doc/eclat-setaattr.1: New file. * etc/Makefile.am (FLNFILES): Add new files. * etc/describe-image-attribute.fln: New file. * etc/modify-image-attribute.fln: New file. * src/Makefile.am (eclat_SOURCES,OPTFILES): Add new files. * src/eclat.c (cmdtab): New commands: lsaattr and setaattr. * src/eclat.h (eclat_describe_image_attribute) (eclat_modify_image_attribute,canonattrname): New protos. * src/lsaattr.c: New file. * src/lsiattr.c: Use canonattrname to simplify usage. * src/lssattr.c (canonattrname): Remove. Use external version. * src/setaattr-cl.opt: New file. * src/setaattr.c: New file. * src/setiattr.c: New file. * src/util.c (canonattrname): New function.
2014-02-03Update copyright yearsSergey Poznyakoff1
2013-07-31Prepare for Signature Version 4.Sergey Poznyakoff1
* lib/hmac_sha256.c: New file. * lib/sha256.c: New file. * lib/sha256.h: New file. * lib/Makefile.am (libeclat_a_SOURCES): Add new files. * lib/libeclat.h (hmac_sha256): New proto. (eclat_query_signature): Rename to eclat_query_sign, take signature version as argument. (eclat_encode_devmap): Remove prototype. * lib/reqsign.c: Use HMAC256 * src/config.c (eclat_kw): New keyword: signature-version, * src/devmap.c (eclat_encode_devmap): Bugfixes. Translate snapshot ids. * src/eclat.c (signature_version): New variable. * src/eclat.h (signature_version): New proto. (eclat_encode_devmap): New proto. * src/util.c (eclat_send_query): Use eclat_query_sign. * tests/hmac01.at: Update. * tests/hmac02.at: Update. * tests/hmac03.at: Update. * tests/thmac.c: Use HMAC256
2013-05-04Bugfixes.Sergey Poznyakoff1
* src/cmdline.opt: Add closing double-quote in the -D preprocessor option. * src/util.c (translate_ids): Do not bail out if the map is not defined.
2013-04-26Improve ID mapping.Sergey Poznyakoff1
* doc/eclat.conf.5: Update. * src/cmdline.opt: New option --no-translate (-X) * src/config.c (eclat_kw): New statement: translate. * src/eclat.c (main): override the value of translation_enabled from the command line. * src/eclat.h (translate_option): Rename to translation_enabled. All uses changed. (MAP_IMAGE,MAP_INSTANCE) (MAP_GROUPID,MAP_GROUPNAME) (MAP_SNAPSHOT,MAP_VOLUME) (MAP_AZ,MAP_REG): New defines, to use instead of literal map names. All sources updated accordingly. * src/util.c (translate_option): Rename to translation_enabled. (translate_ids): It is not an error if the name is not found in the map. Use it as the resource ID in that case.
2013-04-25Improve help and usage output.Sergey Poznyakoff1
* NEWS: Version 0.9.90 * configure.ac: Likewise. * grecs: Upgrade. * src/allocaddr-cl.opt: Use OPTIONS_COMMAND_BEGIN to declare subcommand. Remove the nousage flag. * src/cpimg-cl.opt: Likewise. * src/cpsnap-cl.opt: Likewise. * src/asscaddr-cl.opt: Likewise. * src/detvol-cl.opt: Likewise. * src/disasaddr-cl.opt: Likewise. * src/freeaddr-cl.opt: Likewise. * src/lsaddr-cl.opt: Likewise. * src/lsattr-cl.opt: Likewise. * src/lsimg-cl.opt: Likewise. * src/lsistat-cl.opt: Likewise. * src/lssg-cl.opt: Likewise. * src/lssnap-cl.opt: Likewise. * src/lstag-cl.opt: Likewise. * src/mkimg-cl.opt: Likewise. * src/mkinst-cl.opt: Likewise. * src/mktags-cl.opt: Likewise. * src/mkvol-cl.opt: Likewise. * src/generic-cl.opt (generic_parse_options): Change signature. Use subcmd member of struct grecs_proginfo. * src/eclat.h (eclat_do_command): New proto. (generic_parse_options): Change signature. * src/atvol.c: Update call to generic_parse_options. * src/deimg.c: Likewise. * src/getconout.c: Likewise. * src/lsiattr.c: Likewise. * src/lsinst.c: Likewise. * src/lsreg.c: Likewise. * src/lssattr.c: Likewise. * src/lsvol.c: Likewise. * src/lszon.c: Likewise. * src/mksnap.c: Likewise. * src/rmsnap.c: Likewise. * src/rmvol.c: Likewise. * src/setiattr.c: Likewise. * src/startstop.c: Likewise. * src/util.c (translate_ids): Remove unused variable.
2013-02-09Make all tag-related subcommands accept the same set of options.Sergey Poznyakoff1
* src/dscrtags-cl.opt: New file. * src/Makefile.am (OPTFILES): Add dscrtags-cl.opt * src/cretags.c (process_tags): New parameter "require_tags". All uses updated. * src/dscrtags.c: Include dscrtags-cl.h. (eclat_describe_tags): Accept the same set of arguments as eclat_create_tags and eclat_delete_tags. * src/eclat.h (describe_query_update): New proto. * src/util.c (describe_query_update): New function. (describe_query_create): Rewrite as an entry point to describe_query_update. * doc/eclat-delete-tags.1: Update. * doc/eclat-describe-tags.1: Update * grecs: Upgrade * src/dscrsnapattr.c (eclat_modify_snapshot_attribute) (eclat_reset_snapshot_attribute): Remove unused locals.
2013-01-23Implement snapshot attribute commands.Sergey Poznyakoff1
* TODO: Update. * etc/describe-snapshot-attribute.fln: New file. * etc/modify-snapshot-attribute.fln: New file. * etc/reset-snapshot-attribute.fln: New file. * etc/Makefile.am: Add new files. * src/dscrsnapattr.c: New file. * src/Makefile.am: Add new files. * src/dscrinstattr.c (list_attrs): Remove. (eclat_describe_instance_attribute): Assign available_attrs. * src/eclat.c (cmdtab): New commands: describe-snapshot-attribute, modify-snapshot-attribute, and reset-snapshot-attribute. * src/eclat.h (eclat_describe_snapshot_attribute) (eclat_modify_snapshot_attribute) (eclat_reset_snapshot_attribute): New protos. (available_attrs): New extern. (list_attrs): New function. * src/modinstattr.c (list_attrs): Rename to list_mod_attrs. * src/util.c (available_attrs): New global. (list_attrs): New function.
2013-01-19Update copyright years.Sergey Poznyakoff1
2012-12-15Implement map lookup functions in forlan.Sergey Poznyakoff1
* lib/forlan.c: New functions "has_map" and "lookup". * lib/map.c (eclat_map_open): Don't issue error message if failed to open the map. Leave that to the caller. * src/util.c (translate_ids) (translate_resource_ids): Issue an error message if eclat_map_open fails.
2012-12-15Implement direct and reverse map lookups.Sergey Poznyakoff1
Not all maps support reverse lookups generically (for example, gdbm does not), therefore introduce a new "bidi" (bi-directional) map, which is a compound of two maps, each one used for a particular lookup direction. * lib/Makefile.am (maps): List all maps here. * lib/bidimap.c: New file. Implementation of a bi-directional map. * lib/filemap.c: Update to the changes in API. Implement reverse lookup. * lib/gdbmmap.c: Update to the changes in API. * lib/nullmap.c: Likewise. * lib/seqmap.c: Likewise. * lib/ldapmap.c: Update to the changes in API. Implement reverse lookup. New configuration keywords: reverse-filter, reverse-attr. * lib/libeclat.h (eclat_map_drv) <map_get>: Change signature, take search direction as a new argument. (eclat_map_get): Likewise. (eclat_map) <eclat_map_bad_dir>: New status code. (MAP_DIR, MAP_REV): New macros. (eclat_map_name_split): New function. (eclat_map_drv_bidi): New extern. * lib/map.c (eclat_map_get): Change signature, take search direction as a new argument. Pass new keyword to the "key" translation: "dir". (eclat_map_strerror): Handle new status code. (eclat_map_name_split): New function. * src/eclat.c (main): Register eclat_map_drv_bidi. * src/util.c (translate_ids): Use eclat_map_name_split to obtain direction code from the map name. (translate_resource_ids): Use direct lookups. * tests/Makefile.am: Add new testcases. * tests/testsuite.at: Likewise. * tests/bidimap.at: New testcase. * tests/filemap.at: Test reverse lookups.
2012-12-11Accept both Eclat command names and EC2 action names in format statements.Sergey Poznyakoff1
* src/util.c (eclat_actcmp): New function. * src/eclat.h (eclat_actcmp): New proto. * src/eclat.c (find_command_tag): Use eclat_actcmp.
2012-12-11Change handler invocation.Sergey Poznyakoff1
* src/eclat.c: Initialize query in main and pass it to each handler along with the curl pointer in a "runtime environment" structure. If the handler returns 0, send that query to the endpoint (from main, again). This avoids duplication of code. Reserve a CMD_NOQRY flag for commands that are supposed to do everything by themselves. Use command->tag member as the Action parameter. * src/eclat.h (eclat_command_env): New structure. Change all handler prototypes. * src/util.c (describe_query_create): Take a pointer to eclat_command_env_t as the first argument. Assume that the query structure is already initialized. The "verb" argument becomes superfluous and is removed. All uses changed. * src/allocaddr.c: Update. * src/asscaddr.c: Update. * src/attvol.c: Update. * src/cresnap.c: Update. * src/cretags.c: Update. * src/crevol.c: Update. * src/delsnap.c: Update. * src/delvol.c: Update. * src/detvol.c: Update. * src/disassaddr.c: Update. * src/dscraddrs.c: Update. * src/dscrazs.c: Update. * src/dscrinstattr.c: Update. * src/dscrinsts.c: Update. * src/dscrinststat.c: Update. * src/dscrregs.c: Update. * src/dscrsecgrps.c: Update. * src/dscrsnap.c: Update. * src/dscrtags.c: Update. * src/dscrvols.c: Update. * src/getconout.c: Update. * src/reladdr.c: Update. * src/startinst.c: Update.
2012-12-10Implement attach-volume and detach-volumeSergey Poznyakoff1
* TODO: Update * etc/attach-volume.fln: New file. * etc/detach-volume.fln: New file. * etc/Makefile.am: Add new files. * src/attvol.c: New file. * src/detvol-cl.opt: New file. * src/detvol.c: New file. * src/Makefile.am: Add new files. * src/eclat.c: Add new commands. * src/eclat.h: Add new protos. * src/util.c (translate_ids) (translate_resource_ids): Do nothing id argc is 0.
2012-10-11Trivial fixes.Sergey Poznyakoff1
2012-10-10Translate resource-id filters.Sergey Poznyakoff1
* src/dscrtags.c (eclat_describe_tags): Call translate_resource_ids. * src/eclat.h (translate_resource_ids): New proto. * src/util.c (translate_resource_ids): New function.
2012-10-09Implement test map mode.Sergey Poznyakoff1
* src/cmdline.opt: New options: --map, --test-map * src/eclat.c: Implement test map mode. (test_map_name): New variable. * src/eclat.h (test_map_name): new extern. * src/util.c (custom_map): New variable. (translate_ids): Use custom_map if specified.
2012-10-07Implement resource identifier mapping.Sergey Poznyakoff1
Resource identifier mapping permits to use more customized identifiers instead of the Amazon resource identifiers. For instance, you can use hostnames instead of the instance IDs, etc. * lib/Makefile.am: Add new files. * lib/filemap.c: New file. * lib/map.c: New file. * lib/libeclat.h (eclat_map_drv,eclat_map): New structs. (eclat_map_status): New enum. (eclat_map_init,eclat_map_lookup,eclat_map_config) (eclat_map_free,eclat_map_open,eclat_map_close) (eclat_map_get,eclat_map_strerror,eclat_map_drv_register) (eclat_map_foreach,eclat_map_free_all) (eclat_get_string_node): New protos. (eclat_map_drv_file): New extern. * src/accfile.c (access_file_lookup): Fix memory leak. * src/cmdline.opt: New option: --translate (-x) * src/config.c (eclat_kw) <map>: New block statement. (config_finish): Parse map configs. * src/asscaddr.c: Translate key. * src/dscrinstattr.c: Likewise. * src/dscrinsts.c: Likewise. * src/dscrinststat.c: Likewise. * src/dscrsecgrps.c: Likewise. * src/getconout.c: Likewise. * src/startinst.c: Likewise. * src/eclat.c (main): Initialize maps and free them when no more needed. * src/eclat.h (translate_option): New extern. (translate_ids): New proto. * src/util.c (translate_option): New variable. (translate_ids): New function.
2012-09-28Initial implementation of associate/dissociate address requests.Sergey Poznyakoff1
* etc/Makefile.am: Add new files. * etc/associate-address.fln: New file. * etc/disassociate-address.fln: New file. * lib/forlan.c (eval_expr): Fix boolean NOT. * src/Makefile.am: Add new files. * src/asscaddr.c: New file. * src/dscrtags.c (eclat_describe_tags): Remove unused variables. * src/eclat.c (cmdtab): Register new commands. * src/eclat.h (eclat_associate_address) (eclat_disassociate_address): New commands. * src/util.c: Add AWSAccessKeyId param in eclat_send_query instead of in describe_query_create. * tests/Makefile.am: Add new files. * tests/testsuite.at: Include new test cases. * tests/associate-address.at: New test case.
2012-09-28Minor fixes.Sergey Poznyakoff1
* src/dscrinsts-cl.opt: Document filters.. * src/eclat.c (aws_typestr): Add new types. (list_filters): Minor fix. * src/eclat.h (FILTER_BOOL) (FILTER_INT,FILTER_ENUM): New constants. * src/util.c (describe_query_create): Change signature. All uses updated.
2012-09-26Improve documentation output.Sergey Poznyakoff1
* src/dscrinststat-cl.opt: Document available filters. * src/dscrtags-cl.opt: Likewise. * src/eclat.c (list_filters): New function. * src/eclat.h (FILTER_STRING,FILTER_DATE) (FILTER_ENUM): : New defines. (filter_descr): New struct. * src/util.c (get_scr_cols): New function. (describe_query_create): Minor fix.
2012-09-26Implement DescribeInstanceStatus action.Sergey Poznyakoff1
* lib/forlan.c (generic_print): Skip NULL entries. * src/Makefile.am (eclat_SOURCES): Add new files. (OPTFILES): New variable. (BUILT_SOURCES,EXTRA_DIST): Add OPTFILES and their derivatives. * src/dscrinststat-cl.opt: New file. * src/dscrinststat.c: New file. * src/util.c: New file. * src/dscrtags.c: Use functions from util.c * src/eclat.c: New command describe-instance-status. (main): Don't coredump on NULL formats. * src/eclat.conf (DescribeInstanceStatus): New format. * src/eclat.h (eclat_describe_instance_status) (describe_query_create) (eclat_send_query): New protos.

Return to:

Send suggestions and report system problems to the System administrator.