diff options
| author | Werner Koch <[email protected]> | 2025-07-08 07:56:37 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2025-07-08 08:02:30 +0000 |
| commit | a0f7cde9daa7ed463beee00fb5fe75e8d90fa1d4 (patch) | |
| tree | 6402aab449e58435aa510f994a17b775b30d2478 /dirmngr/dirmngr.c | |
| parent | doc: Typo fixes and such (diff) | |
| download | gnupg-a0f7cde9daa7ed463beee00fb5fe75e8d90fa1d4.tar.gz gnupg-a0f7cde9daa7ed463beee00fb5fe75e8d90fa1d4.zip | |
dirmngr: Add option--user-agent and always use a User-Agent header.
* dirmngr/dirmngr.h (opt): Add user_agent.
* dirmngr/dirmngr.c (oUserAgent): New.
(opts): Add "user-agent".
(parse_rereadable_options): Set option.
* dirmngr/ks-engine-hkp.c (send_request): Send User-Agent.
* dirmngr/ks-engine-http.c (ks_http_fetch): Ditto.
* dirmngr/ocsp.c (do_ocsp_request): Ditto.
--
Note that the http_open_document function is not used by dirmngr. If
it ever gets used we may want to add a way to configure the http.c
module with a user-agent string, so that it is send by the
send_request function and we do not need to explictly do that in the
caller.
GnuPG-bug-id: 7715
Diffstat (limited to 'dirmngr/dirmngr.c')
| -rw-r--r-- | dirmngr/dirmngr.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index 08f313879..d418d09e2 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -161,6 +161,7 @@ enum cmd_and_opt_values { oListenBacklog, oFakeCRL, oCompatibilityFlags, + oUserAgent, aTest }; @@ -251,6 +252,7 @@ static gpgrt_opt_t opts[] = { N_("|URL|redirect all HTTP requests to URL")), ARGPARSE_s_n (oHonorHTTPProxy, "honor-http-proxy", N_("use system's HTTP proxy setting")), + ARGPARSE_s_s (oUserAgent, "user-agent", "@"), ARGPARSE_s_s (oLDAPWrapperProgram, "ldap-wrapper-program", "@"), ARGPARSE_header ("Keyserver", N_("Configuration for OpenPGP servers")), @@ -695,6 +697,7 @@ parse_rereadable_options (gpgrt_argparse_t *pargs, int reread) opt.ocsp_max_period = 90 * 86400; /* 90 days. */ opt.ocsp_current_period = 3 * 60 * 60; /* 3 hours. */ opt.max_replies = DEFAULT_MAX_REPLIES; + opt.user_agent = "GnuPG/2.6"; while (opt.ocsp_signer) { fingerprint_list_t tmp = opt.ocsp_signer->next; @@ -906,6 +909,15 @@ parse_rereadable_options (gpgrt_argparse_t *pargs, int reread) } break; + case oUserAgent: + if (strpbrk (pargs->r.ret_str, "\r\n")) + ; /* Ignore if the caller tried to insert CR or LF. */ + else if (!strcmp (pargs->r.ret_str, "none")) + opt.user_agent = ""; + else + opt.user_agent = pargs->r.ret_str; + break; + default: return 0; /* Not handled. */ } |
