1 /* ks-engine-finger.c - Finger OpenPGP key access
2 * Copyright (C) 2011 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <https://www.gnu.org/licenses/>.
30 #include "ks-engine.h"
32 /* Print a help output for the schemata supported by this module. */
34 ks_finger_help (ctrl_t ctrl, parsed_uri_t uri)
37 "Handler for FINGER:\n"
38 " finger:<user>@<host>\n"
39 "Supported methods: fetch\n"
41 " finger:joe@example.org\n";
45 err = ks_print_help (ctrl, " finger");
46 else if (!strcmp (uri->scheme, "finger"))
47 err = ks_print_help (ctrl, data);
55 /* Get the key from URI which is expected to specify a finger scheme.
56 On success R_FP has an open stream to read the data. */
58 ks_finger_fetch (ctrl_t ctrl, parsed_uri_t uri, estream_t *r_fp)
69 if (strcmp (uri->scheme, "finger") || !uri->opaque || !uri->path)
70 return gpg_error (GPG_ERR_INV_ARG);
72 name = xtrystrdup (uri->path);
74 return gpg_error_from_syserror ();
76 server = strchr (name, '@');
79 err = gpg_error (GPG_ERR_INV_URI);
85 err = http_raw_connect (&http, server, 79,
86 ((opt.use_tor? HTTP_FLAG_FORCE_TOR : 0)
87 | (opt.disable_ipv4? HTTP_FLAG_IGNORE_IPv4 : 0)),
95 fp = http_get_write_ptr (http);
98 err = gpg_error (GPG_ERR_INTERNAL);
104 if (es_fputs (name, fp) || es_fputs ("\r\n", fp) || es_fflush (fp))
106 err = gpg_error_from_syserror ();
107 http_close (http, 0);
114 fp = http_get_read_ptr (http);
117 err = gpg_error (GPG_ERR_INTERNAL);
118 http_close (http, 0);
122 http_close (http, 1 /* Keep read ptr. */);