diff options
author | Werner Koch <wk@gnupg.org> | 2016-09-02 16:54:42 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-09-02 16:56:04 +0200 |
commit | 46362cbc0e2260e989820795a6e4245c72335172 (patch) | |
tree | 9e21a8b9bd0e2e2bdebcd388f702d4c20b6c3c47 /tools/call-dirmngr.c | |
parent | dirmngr: Add --policy-flags option to WKD_GET. (diff) | |
download | gnupg2-46362cbc0e2260e989820795a6e4245c72335172.tar.xz gnupg2-46362cbc0e2260e989820795a6e4245c72335172.zip |
wks: Add framework for policy flags.
* tools/call-dirmngr.c (wkd_get_policy_flags): New.
* tools/gpg-wks.h (struct policy_flags_s, policy_flags_t): New.
* tools/wks-util.c (wks_parse_policy): New.
* tools/gpg-wks-client.c (command_send): Get the policy flags to show
a new info line.
* tools/gpg-wks-server.c (get_policy_flags): New.
(process_new_key): get policy flag and add a stub for "auth-submit".
(command_list_domains): Check policy flags.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tools/call-dirmngr.c')
-rw-r--r-- | tools/call-dirmngr.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/call-dirmngr.c b/tools/call-dirmngr.c index 0e591dd6d..9142350cd 100644 --- a/tools/call-dirmngr.c +++ b/tools/call-dirmngr.c @@ -203,3 +203,58 @@ wkd_get_submission_address (const char *addrspec, char **r_addrspec) assuan_release (ctx); return err; } + + +/* Ask the dirmngr for the policy flags and return them as an estream + * memory stream. If no policy flags are set, NULL is stored at + * R_BUFFER. */ +gpg_error_t +wkd_get_policy_flags (const char *addrspec, estream_t *r_buffer) +{ + gpg_error_t err; + assuan_context_t ctx; + struct wkd_get_parm_s parm; + char *line = NULL; + char *buffer = NULL; + + memset (&parm, 0, sizeof parm); + *r_buffer = NULL; + + err = connect_dirmngr (&ctx); + if (err) + return err; + + line = es_bsprintf ("WKD_GET --policy-flags -- %s", addrspec); + if (!line) + { + err = gpg_error_from_syserror (); + goto leave; + } + if (strlen (line) + 2 >= ASSUAN_LINELENGTH) + { + err = gpg_error (GPG_ERR_TOO_LARGE); + goto leave; + } + + parm.memfp = es_fopenmem (0, "rwb"); + if (!parm.memfp) + { + err = gpg_error_from_syserror (); + goto leave; + } + err = assuan_transact (ctx, line, wkd_get_data_cb, &parm, + NULL, NULL, wkd_get_status_cb, &parm); + if (err) + goto leave; + + es_rewind (parm.memfp); + *r_buffer = parm.memfp; + parm.memfp = 0; + + leave: + es_free (buffer); + es_fclose (parm.memfp); + xfree (line); + assuan_release (ctx); + return err; +} |