1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-28 21:50:02 +02:00
Commit Graph

785 Commits

Author SHA1 Message Date
Werner Koch
05eff1f662
agent: Default to extended key format.
* agent/gpg-agent.c (oDisableExtendedKeyFormat, oNoop): New.
(oEnableExtendedKeyFormat): Remove.
(opts): Make --enable-extended-key-format a dummy option.  Add
disable-extended-key-format.
(parse_rereadable_options): Implement oDisableExtendedKeyFormat.
--

Extended key format is supported since vesion 2.1.12 which should have
long been replaced by a newer version inh all installations.  Thus for
2.3 we will make use of the extended-key-format by default.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-06 14:09:57 +01:00
Werner Koch
4e1f04a4cd
card: Allow PEM encoded certificates in "writecert".
* tools/gpg-card.c (cmd_writecert): Convert from base64.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-06 12:40:45 +01:00
Werner Koch
772bba34ea
card: Print the keyref also for non-initialized slots.
* tools/gpg-card.c (list_one_kinfo): Add arg label_keyref and change
callers.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-06 10:25:31 +01:00
Werner Koch
8d4af54ddd
card: Print card version. Check for bad Yubikeys.
* scd/app.c (app_new_register): Set card version for Yubikeys.
(app_write_learn_status): Print CARDVERSION and APPVERSION.
* tools/card-call-scd.c (learn_status_cb): Detect them.
* tools/gpg-card.h (struct card_info_s): Add appversion and
cardversion.
* tools/gpg-card.c (list_openpgp): Remove version printing from serial
number.
(print_a_version): New.
(list_card): Print card and app version.
(cmd_generate): Do not allow broken Yubikeys.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-05 17:40:08 +01:00
Werner Koch
e897e1e255
scd:piv: Implement import of private keys for Yubikeys.
* scd/app-piv.c (concat_tlv_list): Add arg 'secure' and adjust
 callers.
(writekey_rsa, writekey_ecc): New.
(do_writekey): New.
(do_writecert): Provide a better error message for an empty cert.
(app_select_piv): Register do_writekey.
* scd/iso7816.c (iso7816_send_apdu): New.
* scd/app-common.h (APP_WRITEKEY_FLAG_FORCE): New.
* agent/command.c (cmd_keytocard): Make the timestamp optional.
* tools/card-call-scd.c (inq_writekey_parms): Remove.
(scd_writekey): Rewrite.
* tools/gpg-card.c (cmd_writekey): New.
(enum cmdids): Add cmdWRITEKEY.
(dispatch_command, interactive_loop): Call cmd_writekey.
--

This has been tested with gpgsm and RSA keys.  For ECC keys only
partly tested using the sample OpenPGP nistp256 and nistp384 keys
because gpgsm does not yet support ECC certificates and thus we can't
write the certificates to the cert object after a writekey.  Note that
they nevertheless show up in "gpgcard list" because gpg-card searches
for them in gpg and gpgsm.  However, this does not work completely.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-05 15:49:20 +01:00
Werner Koch
280baee72d
card: Remove the "admin" command.
* tools/gpg-card.c (cmd_passwd): Remove arg allow_admin.
(enum cmdids): Rename cmdAUTHENTICATE to cmdAUTH and cmdFACTORYRESET
to cmdFACTRST.
(cmds): Remove column 'admin_only'.
(interactive_loop): Remove admin_only stuff.
--

That command has always been an annoyance.  Symbols have been renamed
for source cosmetics.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-03-01 12:20:24 +01:00
Werner Koch
ac485b4f25
conf: New option --show-socket.
* tools/gpgconf-comp.c (gc_component_t): Move this enum to ...
* tools/gpgconf.h: here.
* tools/gpgconf.c (oShowSocket): New.
(opts): Add new option.
(main): Implement new option.
--

This is a convenience options for software which directly connects to
gpg-agent and thus needs to new the socket.  By using --show-socket
along with --launch that software can also autostart the agent or the
dirmngr.  Without this two calls to gpgconf would be required.

Actually the same behaviour can be achieved by running
gpg-connect-agent to query the running gpg-agent's socket via GETINFO.
The gpg-connect also makes sure that the agent is started.  This is
not anymore suggested because gpgconf shall in future be used for all
such things.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-26 13:13:08 +01:00
Werner Koch
28de5c0ea5
card: Rename gpg-card-tool to gpg-card.
* tools/card-tool-keys.c: Rename to card-keys.c.
* tools/card-tool-misc.c: Rename to card-misc.c.
* tools/card-tool-yubikey.c: Rename to card-yubikey.c.
* tools/card-tool.h: Rename to gpg-card.h.
* tools/gpg-card-tool-w32info.rc: Rename to gpg-card-w32info.rc
* doc/card-tool.texi: Rename top gpg-card.texi

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-25 09:34:30 +01:00
Werner Koch
7317aeb3f4
card: Print usage info for each key.
* tools/card-call-scd.c (learn_status_cb): Handle extended
KEYPARIRINFO.
* tools/card-tool.h (struct key_info_s): Add field 'usage'.
* tools/gpg-card-tool.c (list_one_kinfo): Show usage flags.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-21 12:43:07 +01:00
Werner Koch
3384ba6c1c
card: Print the keyref in the listing.
* tools/gpg-card-tool.c (list_one_kinfo): Print the keyref.
--

The named keys are nice but knowing the actual keyref mapping to them
is also useful.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-21 08:51:54 +01:00
Werner Koch
7e1cd2cd41
card: New command "yubikey".
* tools/card-tool-yubikey.c: New.
* tools/Makefile.am (gpg_card_tool_SOURCES): Add it.
* tools/card-call-scd.c (scd_apdu): Allow returning data.
* tools/card-tool-misc.c (send_apdu): New.  Move from gpg-card-tool.c
and let it return data.  Change all callers.

* tools/gpg-card-tool.c (cmd_writecert): Prepend the certref with the
current application type.
(cmd_yubikey): New.
--

This command allows listing of active applications and to enable or
disable selected applications.  This is in particular useful to
disable the OpenPGP application so that the PIV support can easily be
tested.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-13 09:49:07 +01:00
Werner Koch
03bf8e967a
common: Provide function to get public key algo names in our format.
* tools/card-tool-misc.c (pubkey_algo_string): Move to  ...
* common/sexputil.c (pubkey_algo_string): here.
--

The new gpg format for public key algorithms is useful at other places
as well.  Thus we make this new function available.  Note that the
code we use in gpg is not based on s-expressions and thus a new
function was required.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-08 12:10:45 +01:00
Werner Koch
a1cb4a940f
card: Make "generate" work for PIV cards.
* tools/card-call-scd.c (scd_genkey_cb): Make createtime optional.
(scd_genkey_cb):  Ditto.  Add arg algo.
* tools/gpg-card-tool.c (cmd_generate): Add options and factor card
specific code out to ...
(generate_openpgp, generate_generic): new functions.
--

This patch keeps the interactive OpenPGP mode but adds a pure command
line mode for other cards; in particular PIV cards.  What we still
need to do is:
 a) Add an interactive mode for PIV cards
 b) Add a command line mode for OpenPGP cards.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-08 11:58:27 +01:00
Werner Koch
b79bc877f2
card: Print the used algorithm of all keys.
* tools/card-call-scd.c (scd_readkey): New.
* tools/card-tool-misc.c (pubkey_algo_string): New.
* tools/gpg-card-tool.c (list_one_kinfo): Print the algo.
--

It is convenient to see the actual algorithm of keys even if no
certificate has yet been created.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-07 20:28:43 +01:00
Werner Koch
df6ba6dfd2
card: Fix a NULL-ptr deref in key listings.
* tools/card-tool-keys.c (get_matching_keys): Fix segv.
* tools/gpg-card-tool.c (main): Init info.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-07 16:28:03 +01:00
Werner Koch
fcec5b40e5
card: Support reading and writing PIV certificates
* scd/app-piv.c (add_tlv): New.
(put_data): New.
(do_writecert): New.
(do_setattr): Remove usused special mode 0.
* tools/gpg-card-tool.c (cmd_writecert): Allow other cards than
OPENPGP.
(cmd_readcert): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-07 11:05:22 +01:00
Werner Koch
090b5f804a
card: Add readline completion for help arguments
--
2019-02-07 08:16:02 +01:00
Werner Koch
e9e876cb55
scd: Implement PIN changing and unblocking for PIV cards.
* scd/app-piv.c: Some refactoring
(do_change_chv): Implement.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-06 09:46:23 +01:00
Werner Koch
3231ecdafd
scd: Allow standard keyref scheme for app-openpgp.
* scd/app-openpgp.c (do_change_pin): Allow prefixing the CHVNO with
"OPENPGP."
* tools/card-call-scd.c (scd_change_pin): Change API to use strings.
* tools/gpg-card-tool.c (cmd_passwd): Adjust for change.
(cmd_unblock): Ditto.
--

The generic keyref allows for better error detection in case a keyref
is send to a wrong card.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-02-05 15:01:45 +01:00
Werner Koch
1c0fa3e6f7
card: Implement non-interactive mode.
* tools/card-tool.h (opt): Add field 'initialized'.
* tools/card-call-scd.c (scd_learn): Set it.
* tools/gpg-card-tool.c (main): Reworked.
(dispatch_command): New.
--

This work is not yet finished because most commands need some tweaks
for non-interactive work.  What you already can do are things like:

 $ gpg-card-tool list -- 'auth <oldkey' \
   -- auth --setkey --raw 123456781234567812345678 -- help auth

Which will list the current card, authenticate using a hex encoded key
from the file "oldkey", set the new admin key to "123...78", and print
help for the auth command.  Note that the -- acts as a delimiter
between commands.  To use a double dash as argument to a command the
entire command must be quoted.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-31 18:57:16 +01:00
Werner Koch
da38325740
card: New command 'authenticate'.
* tools/card-tool-misc.c (hex_to_buffer): New.
* tools/gpg-card-tool.c (get_data_from_file): Change to allow returning
a string.
(cmd_authenticate): New.
(cmds): Add command "authenticate".

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-31 16:06:47 +01:00
Werner Koch
0107984f9f
card: Cache the results from gpg and gpgsm.
* tools/card-tool-keys.c (keyblock_cache): New var.
(release_keyblock): Factor code out to a new do_release_keyblock.  Add
a cache.
(flush_keyblock_cache): New.
(get_matching_keys): Use the cache.
* tools/gpg-card-tool.c (cmds): Add command "reset".
(interactive_loop): Implement reset.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-30 17:51:32 +01:00
Werner Koch
833f27a6a7
card: Print matching OpenPGP and X.509 data.
* tools/card-tool-keys.c: New.
* tools/Makefile.am (gpg_card_tool_SOURCES): Add file.
* tools/card-tool.h (struct pubkey_s, pubkey_t): New.
(struct userid_s, userid_t): New.
(struct keyblock_s, keyblock_t): New.
* common/util.h (GNUPG_PROTOCOL_): New const
* tools/gpg-card-tool.c (aTest): Add temporary command.
(list_one_kinfo): Print info from gpg and gpgsm.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-30 15:01:34 +01:00
Werner Koch
79bed504e5
card: Support factory reset for Yubikey PIV application.
* scd/app-common.h (struct app_ctx_s): Add field cardtype.
* scd/app.c (app_new_register): Set cardtype for yubikey.
(app_getattr): Add CARDTYPE.
(app_write_learn_status): Emit new attribute.
* scd/app-piv.c (do_getattr): Add CHV-USAGE.
(do_learn_status): Emit it.
* tools/card-tool.h (struct card_info_s): Add field cardtype.
* tools/card-call-scd.c (learn_status_cb): Parse "CARDTYPE".

* tools/gpg-card-tool.c (list_piv): Print PIN usage policy.
(list_card): Print card type.
(cmd_factoryreset): Implement for Yubikey with PIV.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-29 13:46:52 +01:00
Werner Koch
9325c92284
card: Print keyinfo for PIV cards.
* scd/app-piv.c (do_learn_status): Print CHV-STATUS.
* tools/card-tool.h (struct card_info_s): Rename chvretry to chvinfo.
* tools/card-call-scd.c (learn_status_cb): Depend CHV-STATUS on app
type.
* tools/gpg-card-tool.c (list_piv): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-29 09:32:20 +01:00
Werner Koch
237880175f
card: Make printing of key information more flexible.
* tools/card-tool-misc.c: New.
* tools/card-tool.h: Rewored data structures for key infos.
* tools/gpg-card-tool.c: Ditto.
* tools/card-call-scd.c: Ditto.
--

Note that this also changes the way the key information is printed.
Formerly we printed it like:

  Signature key ....: <openpgp-fingerprint>
        created ....: <timestamp>
        keygrip ... : <keygrip>

now we do:

  Signature key ....: <keygrip>
        fingerprint : <openpgp-fingerprint>
        created ....: <timestamp>

This is because a keygrip is always available but a fingerprint and
the creation date are properties of an OpenPGP card.  A standard way
of listing keys is better than one depending on the type of card.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-29 09:32:20 +01:00
Werner Koch
1c92510045
card: Implement the bulk of OpenPGP stuff into gpg-card-tool.
* tools/card-call-scd.c: New.
* tools/card-tool.h: new.
* tools/gpg-card-tool.c: Largely extended.
--

gpg-card-tool will eventually replace the --card-edit command of gpg
because it makes more sense to have a multi-protocol aware tool and
not just one for OpenPGP cards.  Most OpenPGP card things works now
but a few, those which require close interaction with gpg, still need
to be implemented.  And of course the whole planned non-interactive
stuff needs to be written.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-27 20:12:00 +01:00
Werner Koch
e6d613711a
card-tool: Add skeleton for new tool
* tools/gpg-card-tool.c: New.
* tools/gpg-card-tool-w32info.rc: New.
* tools/Makefile.am: Add new tool.
--

To support more cards than the OpenPGP card it is useful to have a
separate tool.  It will have have the "gpg --card-edit" style
interactive interface as well as direct command line options for all
commands.  In a first step the OpenPGP card will be supported, to
allow its use as an alternative to the gpg command, and the
forthcoming PIV card support.

The tool can be though as a direct interface to scdaemon.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-01-22 09:07:24 +01:00
Werner Koch
70a8db0333
wks: Do not use compression for the encrypted data.
* tools/gpg-wks-client.c (encrypt_response): Add arg -z0.
* tools/gpg-wks-server.c (encrypt_stream): Ditto.
--

If for example a server was built without the development packages of
the compression libraries installed, the server will not be able to
decrypt a request.  In theory this can't happen due to the preference
system but it is just to easy to create the server's key using a
different version of gpg and then use gpg-wks-server built
differently.

For the short messages we exchange compression is not really required
and thus we better do without to make the system more robust.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-12-18 08:21:03 +01:00
Werner Koch
40c307fa8d
Silence a few compiler warnings new with gcc 8.
* dirmngr/dns.c: Include gpgrt.h.  Silence -Warray-bounds also gcc.
* tools/gpg-pair-tool.c (command_respond): Init two vars to silence
gcc.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-12-17 18:46:26 +01:00
Tomi Leppänen
2c35e67e34
tools: Use POSIX compatible arguments for find
* tools/addgnupghome (filelist): Remove bashism.
2018-12-11 08:42:33 +01:00
Werner Koch
0c36ec241d
wks: Fix filter expression syntax flaw.
* tools/wks-util.c (wks_get_key, wks_filter_uid): The filter
expression needs a space before the value.
(install_key_from_spec_file): Replace es_getline by es_read_line and
remove debug output.
--

A value of starting with '<' was considered an invalid operator due to
our tokenization method.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-12-04 16:28:27 +01:00
Werner Koch
ba46a359b9
wks: Allow reading of --install-key arguments from stdin.
* tools/wks-util.c (install_key_from_spec_file): New.
(wks_cmd_install_key): Call it.
* tools/gpg-wks-client.c (main): Allow --install-key w/o arguments.
* tools/gpg-wks-server.c (main): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-12-04 15:31:41 +01:00
Werner Koch
73e5b0ec9b
wks: Create sub-directories
* tools/wks-util.c (wks_compute_hu_fname): Stat and create directory
if needed.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-12-04 15:31:41 +01:00
Werner Koch
602b190963
wks: Add new commands --install-key and --remove-key to the client.
* tools/gpg-wks-client.c (aInstallKey, aRemoveKey, oDirectory): New.
(opts): Add "--install-key", "--remove-key" and "-C".
(parse_arguments): Parse them.
(main): Check that the given directory exists.  Implement the new
commands.
--

These commands maybe useful to prepare a WKD directory on a non-Unix
box using the standard wks client.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-12-04 15:31:41 +01:00
Werner Koch
99094c992c
wks: Move a few server functions to wks-util.
* tools/gpg-wks-server.c (write_to_file): Move to ...
* tools/wks-util.c: here.
* tools/gpg-wks-server.c (compute_hu_fname): Move to ...
* tools/wks-util.c (wks_compute_hu_fname): here.
* tools/gpg-wks-server.c (fname_from_userid): Move to ...
* tools/wks-util.c (wks_fname_from_userid): here.
* tools/gpg-wks-server.c (command_install_key): Move to ...
* tools/wks-util.c (wks_cmd_install_key): here and change caller.
* tools/gpg-wks-server.c (command_remove_key): Move to ...
* tools/wks-util.c (wks_cmd_remove_key): here and change callers.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-12-04 15:31:41 +01:00
Andre Heinecke
f12fcd9079
w32: Fix linkage of gpg-pair-tool
* tools/Makefile.am (gpg_pair_tool_LDADD): Add W32SOCKLIBS.

--
This is required because parts of libcommon depend on ws2_32.
2018-11-26 13:07:19 +01:00
Werner Koch
56022fb304
Merge branch 'seckey-sync-work' into master
--
2018-11-14 13:37:41 +01:00
Werner Koch
8b8ea802ca
Remove the gpg-zip script.
* tools/gpg-zip.in: Remove.
* m4/tar-ustar.m4: Remove.
--

Note that the script was even not anymore installed.  See also
GnuPG-bug-id: 4252

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-14 13:31:39 +01:00
Werner Koch
6b9f772914
common: Prepare for parsing mail sub-addresses.
* common/mbox-util.c (mailbox_from_userid): Add arg subaddress and
implement.  Change all callers to pass false for it.

* common/t-mbox-util.c (run_mbox_no_sub_test): New.
(run_filter): Add arg no_sub.
(main): Call new test and add option --no-sub.
--

Some stats: In the about 5300000 keys on the SKS servers we found 3055
unique mailboxes with a '+' in it.  After removing leading and
trailing '+' as well as multiple '+' (e.g. "c++" or "foo+bar+baz")
2697 were left which seem to be valid sub-addresses.

To filter mailboxes out from a line delimited list with
user-ids (e.g. an SQL output), the command

   t-mbox-util --verbose --filter

can be used; to output w/o sub-addresses add --no-sub.

GnuPG-bug-id: 4200
Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-12 07:44:33 +01:00
Werner Koch
e3a1e80d13
wks: New option --with-colons for gpg-wks-client.
* tools/gpg-wks.h (opt): Add field with_colons.
* tools/gpg-wks-client.c (oWithColons): New const.
(opts, parse_arguments): Add option --with-colons.
(main): Change aSupported to take several domains in --with-colons
mode.
(command_send): Factor policy getting code out to ...
(get_policy_and_sa): New function.
(command_supported): Make use of new function.
--

In addition to this the --create command now also supports a
submission address only in the policy file.  That means the
submission-address file is not anymore required and can be replaced by
the policy file.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-05 20:58:27 +01:00
Werner Koch
f248416bc9
wkd: Add option --directory to the server.
* tools/gpg-wks-server.c (opts): Add '--directory',
(main): Explain how to set correct permissions.
(command_list_domains): Create an empty policy file and remove the
warning for an empty policy file.
--

Note that a policy file is meanwhile required and thus is is useful to
create it.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-10-26 14:56:59 +02:00
Daniel Kahn Gillmor
a7c5d65eb5 all: fix more spelling errors 2018-10-25 16:53:05 -04:00
Daniel Kahn Gillmor
b39ece7d35 headers: fix spelling
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2018-10-25 16:53:05 -04:00
Daniel Kahn Gillmor
54eb375ff1 all: fix spelling and typos
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2018-10-24 15:56:18 -04:00
Werner Koch
378719f25f
tools: Fix FILE memory leak in gpg-connect-agent.
* tools/gpg-connect-agent.c (do_open): dup the fileno and close the
stream.

GnuPG-bug-id: 4220
Signed-off-by: Werner Koch <wk@gnupg.org>
2018-10-24 20:04:52 +02:00
Werner Koch
f03928b16c
tools: Replace duplicated code in mime-maker.
* tools/rfc822parse.c (HEADER_NAME_CHARS): New.  Taken from
mime-maker.c.
(rfc822_valid_header_name_p): New.  Based on code from mime-maker.c.
(rfc822_capitalize_header_name): New.  Copied from mime-maker.c.
(capitalize_header_name): Remove.  Replace calls by new func.
(my_toupper, my_strcasecmp): New.
* tools/mime-maker.c: Include rfc822parse.h.
(HEADER_NAME_CHARS, capitalize_header_name): Remove.
(add_header): Replace check and capitalization by new functions.
--

This is a straightforward change with two minor chnages:

- In rfc822parse.c the capitalization handles MIME-Version special.
- The check in mime-maker bow detects a zero-length name as invalid.

my_toupper and my_strcasecmp are introduced to allow standalone use
of that file.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-10-15 11:45:14 +02:00
Werner Koch
faf3c70c77
tools: Add experimental code for a pairing protocol
* configure.ac (GNUPG_CACHE_DIR): New const.
* tools/Makefile.am (libexec_PROGRAMS): Add gpg-pair-tool.
(gpg_pair_tool_SOURCES, gpg_pair_tool_CFLAGS)
(gpg_pair_tool_LDADD): New.
* tools/gpg-pair-tool.c: New.
--

This is a first try on a protocol to pair two devices so that they can
agree on a shared secret to exchange secret keys.  The idea is that if
you want to sync your secret keys to another machine (e.g. from
desktop to mobile) you have physical access to both devices and thus a
pairing protocol allows to authenitcate the connection using a short
string.  See the source for a protocol description.

How to test:

  $ gpg-pair-tool -va --homedir . --initiate >msg.commit
  $ gpg-pair-tool -va --homedir 2ndhome --respond  \
                                        <msg.commit >msg.dhpart1
  $ gpg-pair-tool -va --homedir . --respond \
                                        <msg.dhpart1 >msg.dhpart2
  $ gpg-pair-tool -va --homedir 2ndhome --respond \
                                        <msg.dhpart2 >msg.confirm

Now set the SAS as printed by the responder into SAS and run

  $ gpg-pair-tool -va --homedir . --respond --sas $SAS <msg.confirm

Storing the secret on disk is obviously not the right thing to do.
With the new PUT_SECRET and GET_SECRET commands of gpg-agent we can
change this to store it all in gpg-agent instead.  This will make it
also easier for gpg to access the secret and we won't need an option
to return it from gpg-pair-tool.  Thus gpg-pair-tool can be dedicated
to run the protocol and maybe to popup info dialogs.

Adding a second expiration time for running the protocol in addition
to the expiration of the secret is probably a better idea than just
that simple catch-all TTL.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-07-05 09:40:35 +02:00
Werner Koch
08147f8bbd
wks: Take name of sendmail from configure.
* configure.ac (NAME_OF_SENDMAIL): New ac_define.
* tools/send-mail.c (run_sendmail): Use it.
--

We used to ac_subst the SENDMAIL in the old keyserver via mail script.
We cab reuse this to avoid a fixed name for sendmail in the
send-mail.c helper.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-06-19 08:07:59 +02:00
Werner Koch
cb52eb76b3
Some preparations to eventuallt use gpgrt_argparse.
* configure.ac (GNUPG_DEF_COPYRIGHT_LINE: New.
* tools/watchgnupg.c (print_version): USe this macro.
* common/init.c (_init_common_subsystems): Register argparse
functions.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-06-12 16:11:19 +02:00
Werner Koch
f574aabeeb
Merge branch 'STABLE-BRANCH-2-2' into wk-master 2018-03-06 16:26:26 +01:00
Andre Heinecke
e43844c3b0
gpgconf, w32: Allow UNC paths
* tools/gpgconf-comp.c (get_config_filename): Allow UNC paths.

--
The homedir of GnuPG on Windows can be on a network share
e.g. if %APPDATA% is redirected to a network share. The
file API calls work and GnuPG itself works nicely
with such paths so gpgconf should work with them, too.

GnuPG-Bug-Id: T3818
Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
2018-02-28 16:33:23 +01:00
Werner Koch
20539ea5ca
Merge branch 'STABLE-BRANCH-2-2' 2018-02-22 16:19:56 +01:00
Werner Koch
685a5e1558
wks: Add special mode to --install-key.
* tools/gpg-wks-client.c (get_key_status_parm_s)
(get_key_status_cb, get_key): Move to ...
* tools/wks-util.c: ...here.
(get_key): Rename to wks_get_key.
* tools/gpg-wks-server.c: Include userids.h.
(command_install_key): Allow use of a fingerprint.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-02-20 15:23:19 +01:00
Werner Koch
ee474856ec
wks: Implement server command --install-key.
* tools/wks-util.c (wks_filter_uid): Add arg 'binary'.
* tools/gpg-wks-server.c (main): Expect 2 args for --install-key.
(write_to_file): New.
(check_and_publish): Factor some code out to ...
(compute_hu_fname): ... new.
(command_install_key): Implement.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-02-20 11:45:58 +01:00
Werner Koch
1877603761
wks: Support alternative submission address.
* tools/gpg-wks.h (policy_flags_s): Add field 'submission_address'.
* tools/wks-util.c (wks_parse_policy): Parse that field.
(wks_free_policy): New.
* tools/gpg-wks-client.c (command_send): Also try to take the
submission-address from the policy file.  Free POLICY.
* tools/gpg-wks-server.c (process_new_key): Free POLICYBUF.
(command_list_domains): Free POLICY.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-02-20 09:00:00 +01:00
Werner Koch
149369a92b
Merge branch 'STABLE-BRANCH-2-2' into master
Signed-off-by: Werner Koch <wk@gnupg.org>
2018-01-25 16:58:29 +01:00
Werner Koch
7449063b1a
wks: New server options --check, --with-dir, with-file.
* tools/gpg-wks-server.c (aCheck, oWithDir, oWithFile): New const.
(opts): New options --check, --with-dir, and --with-file.
(main): Call command_check_key.
(command_list_domains): Implement option --with-dir.
(fname_from_userid): New.
(command_check_key): New.
(command_remove_key): Implement existsing command.
(command_revoke_key): Call command_remove_key as a simple
implementation.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-12-19 17:42:10 +01:00
Werner Koch
482e000b8a
conf: New option --status-fd.
* tools/gpgconf.c (oStatusFD): New const.
(opts): New option --status-fd.
(statusfp): New var.
(set_status_fd): New.
(gpgconf_write_status): New.
(gpgconf_failure): New.
(main): Set status fd and replace exit by gpgconf_failure.
* tools/gpgconf-comp.c: Repalce exit by gpgconf_failure.
(gc_process_gpgconf_conf): Print a few warning status messages.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-12-18 17:46:05 +01:00
Werner Koch
c817e75028
Merge branch 'STABLE-BRANCH-2-2' into master
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-12-18 16:42:59 +01:00
Werner Koch
d74c40cef0
gpgconf: Show --compliance in expert mode.
* tools/gpgconf-comp.c (gc_options_gpg): Set compliance to expert.
(gc_options_gpgsm): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-12-18 16:31:54 +01:00
Werner Koch
8c878ae4c9
sm: Allow explicit setting of the default --compliance=gnupg
* sm/gpgsm.c (main): Allow setting of the default compliance.
* tools/gpgconf-comp.c (gc_options_gpgsm): Add "compliance".
--

This is required so that we can use this option in in gpgconf.conf.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-12-18 12:05:31 +01:00
Werner Koch
34defc9bce
Adjust for changed macro names in libgpg-error master.
* common/logging.h (GPGRT_LOGLVL_): New replacement macros for older
libgpg-error versions.

--

Updates-commit: b56dfdfc18
Signed-off-by: Werner Koch <wk@gnupg.org>
2017-12-11 10:42:23 +01:00
Andre Heinecke
878b8bfdcc
gpgtar: Prefer --set-filename over implicit name
* tools/gpgtar-extract.c: Prefer opt.filename over filename
for the directory prefix.

--
If you would extract from stdin (filename -) and use set-filename
to provide a real filename the "-" would be used for the directory
name. With this change an explicit filename is prefered.

GnuPG-Bug-Id: T3500
Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
2017-11-15 09:56:22 +01:00
Werner Koch
6e808ae470
gpgconf: Ignore non-installed components with --apply-profile.
* tools/gpgconf-comp.c (retrieve_options_from_program): Add arg
only_installed.
(gc_component_retrieve_options): Use this if we want to process all
components.
--

Note that this also also ignores them in --with-defaults.  This is
useful for systems which come without scdaemon.

GnuPG-bug-id: 3313
Signed-off-by: Werner Koch <wk@gnupg.org>
2017-10-24 12:01:35 +02:00
Werner Koch
50c8b6c88f
wks: Create a new user id if provider wants mailbox-only.
* tools/gpg-wks-client.c (get_key): Add arg 'exact'.
(add_user_id): New.
(command_send): Create new user id.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-18 15:41:51 +02:00
Werner Koch
7f7f5d06fa
wks: Send only the newest UID to the server.
* tools/wks-util.c (list_key_status_cb): Rename to key_status_cb.
(wks_filter_uid): New.
(wks_list_key): Allow FPR to be NULL.  Return an error if no
fingerprint was found.
* tools/gpg-wks-server.c (process_new_key)
(check_and_publish): Remove now useless extra check for FPR.
* tools/gpg-wks-client.c (command_check): Ditto.
(command_send): Filter out the newest uid.
--

This fixes the case of having several userids with all the the same
mailbox.  Now we use the latest user id created.  This patch is also a
prerequisite to automatically create a new user id for providers with
the mailbox-only policy.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-18 12:52:20 +02:00
Werner Koch
a0035986a8
wks: Print the UID creation time with gpg-wks-client --check.
* tools/gpg-wks.h (uidinfo_list_s): Add field 'created'.
* tools/wks-util.c (append_to_uidinfo_list): Add arf 'created'.
(wks_list_key): Pass timestamp to append_to_uidinfo_list.
* tools/gpg-wks-client.c (command_check): Print UID creation time.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-18 11:31:36 +02:00
Werner Koch
4e0696de89
wks: Use dedicated type to convey user ids.
* tools/gpg-wks.h (uidinfo_list_s, uidinfo_list_t): New.
* tools/wks-util.c (append_to_uidinfo_list): New.
(free_uidinfo_list): New.
(wks_list_key): Change arg r_mboxes to uidinfo_list_t.  Use
append_to_uidinfo_list.
* tools/gpg-wks-server.c (sserver_ctx_s): Replace strlist_t by
uidinfo_list_t.
(process_new_key): Ditto.
(check_and_publish): Ditto.
(command_receive_cb): Replace free_strlist by free_uidinfo_list.
* tools/gpg-wks-client.c (command_check): Replace strlist_t by
uidinfo_list_t.  Also print user id in verbose mode.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-18 11:16:07 +02:00
Werner Koch
a821b4f556
wks: Add hack for the broken posteo system
* tools/gpg-wks-client.c (command_send): Additional hack for posteo.
Check the protocol-version flag.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-12 18:08:09 +02:00
Werner Koch
332c9eaa2a
wks: Add new policy flag protocol-version
* tools/gpg-wks.h (policy_flags_s): Add field protocol_version.
* tools/wks-util.c (wks_parse_policy): Add new policy flag.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-12 18:05:00 +02:00
Werner Koch
c65a7bba73
wks: Use unencrypted draft-1 mode for posteo.de
* tools/gpg-wks-client.c (command_send): Allow sending in draft-1
mode.
--

Obviously Posteo did not implement the current draft and thus it was
not possible to send a request to them.  This hack uses the old method
for posteo.de.  Not sending it encrypted is okay here because they use
authenticated sending anyway.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-12 14:35:11 +02:00
Werner Koch
7d15ee8898
tools: New function mime_maker_add_body_data.
* tools/mime-maker.c (mime_maker_add_body_data): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-09-12 14:35:06 +02:00
Werner Koch
565e486b80
gpgconf: Swap "auto-key-retrieve" and "no-auto-key-retrieve".
* g10/gpg.c (gpgconf_list): Announce "auto-key-retrieve".
(main): Simplify setting of KEYSERVER_AUTO_KEY_RETRIEVE.
* tools/gpgconf-comp.c: Make "no-auto-key-retrieve" invisible.  Make
"auto-key-retrieve" an expert option.
--

This basically reverts 9bb13a0e81
because --no-auto-key-retrieve is again the default.  Note that we
allow both options for the sake of profiles.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-08-23 16:45:20 +02:00
Werner Koch
008ae0bd86
build: Change SWDB tag "gnupg21" to "gnupg22".
* configure.ac (GNUPG_SWDB_TAG): New ac_define.  Set it to "gnupg22".
* tools/gpgconf.c (query_swdb): Use it.
* build-aux/speedo.mk: Change tag "gnupg21" to "gnupg22".
* Makefile.am (distcheck-hook): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-08-23 14:52:29 +02:00
Damien Goutte-Gattat
0161225457
gpgconf: Make WoT settings configurable by gpgconf.
* tools/gpgconf-comp.c (gc_options_gpg): Add max-cert-depth,
completes-needed, and marginals-needed options.
* g10/gpg.c (gpgconf_list): Likewise.
--

Some tests to come for the PGP trust model will need to manipulate
these parameters.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
2017-08-21 16:50:01 +02:00
Justus Winter
c4506f624e
gpg: Add option '--disable-dirmngr'.
* doc/gpg.texi: Document new option.
* g10/call-dirmngr.c (create_context): Fail if option is given.
* g10/gpg.c (cmd_and_opt_values): New value.
(opts): New option.
(gpgconf_list): Add new option.
(main): Handle new option.
* g10/options.h (struct opt): New field 'disable_dirmngr'.
* tools/gpgconf-comp.c (gc_options_gpg): New option.

GnuPG-bug-id: 3334
Signed-off-by: Justus Winter <justus@g10code.com>
2017-08-08 11:43:22 +02:00
Werner Koch
69e97d909d
gpg: gpgconf needs to support the now default --auto-key-retrieve.
* tools/gpgconf-comp.c (gc_options_gpg): Re-add "auto-key_retrieve".
--

Although this option is invisible, it might be in use by gpgconf
profiles.  We don't want to break them.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-08-05 14:26:22 +02:00
Werner Koch
9bb13a0e81
gpg: Make --no-auto-key-retrieve gpgconf-igurable.
* g10/gpg.c (gpgconf_list): Print no-auto-key-retrieve instead of
auto-key-retrieve.
* tools/gpgconf-comp.c (gc_options_gpg): Replace auto-key-retrieve by
no-auto-key-retrieve and chnage level from invisible to advanced.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-08-04 22:19:37 +02:00
Werner Koch
3d78ae4d3d
agent: Make --no-grab the default.
* agent/gpg-agent.c (oGrab): New const.
(opts): New option --grab.  Remove description for --no-grab.
(parse_rereadable_options): Make --no-grab the default.
(finalize_rereadable_options): Allow --grab to override --no-grab.
(main) <gpgconflist>: Add "grab".
* tools/gpgconf-comp.c (gc_options_gpg_agent): Add "grab".

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-08-04 18:34:03 +02:00
Werner Koch
6cba56d436
wks: Allow gpg-wks-client --supported with just the domain name
* tools/gpg-wks-client.c (command_supported): Hack for missing local
part.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-08-03 21:16:34 +02:00
NIIBE Yutaka
fde9a8cc6c Simple typo fix.
* tools/rfc822parse.c: Fix.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-08-01 11:44:52 +09:00
Werner Koch
6c9899bede
agent: Make --ssh-fingerprint-digest re-readable.
* agent/gpg-agent.c (main): Move oSSHFingerprintDigest to ...
(parse_rereadable_options): here.
(opts): Change its description.
(main) <aGPGConfList>: Include this option.
* tools/gpgconf-comp.c (gc_options_gpg_agent): Add option at expert
level.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-07-28 18:23:46 +02:00
Werner Koch
c76398da5b
wks: Fix program names in the usage diagnostics.
* tools/gpg-wks-client.c (my_strusage): Add case 12.
* tools/gpg-wks-server.c (my_strusage): Add case 12:

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-07-26 17:53:00 +02:00
Werner Koch
b428dd495a
wks: Add stubs for new gpg-wks-server commands.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-07-26 17:53:00 +02:00
NIIBE Yutaka
99791184ac gpgconf: Make vars read-only explicitly.
* tools/gpgconf-comp.c (gc_backend, gc_arg_type, gc_level, gc_flag)
(gc_component): Add const qualifier.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-07-19 13:43:23 +09:00
NIIBE Yutaka
fa63db89f9 Fix usage of ARGPARSE_OPTS.
* agent/gpg-agent.c, agent/preset-passphrase.c,
dirmngr/dirmngr-client.c, dirmngr/dirmngr_ldap.c, kbx/kbxutil.c,
tools/gpg-check-pattern.c, tools/gpgconf.c, tools/gpgsplit.c,
tools/symcryptrun.c: Use ARGPARSE_end.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-07-19 13:41:18 +09:00
Werner Koch
3419a339d9
Change license of some files to LGPLv2.1.
* COPYING.LIB: Rename to COPYING.LGPL3.
* COPYING.LGPL21: New.
* COPYING.GPL2: New.
* Makefile.am: Distribute them.
* AUTHORS: Update license pointers.  Add BSI as copyright holder.
* common/compliance.c, common/compliance.h: Add BSI copyright notice.
Break overlong lines.
* dirmngr/loadswdb.c: Add BSI copyright notices.
* dirmngr/server.c: Ditto.
* tools/call-dirmngr.c: Change license to LGPLv2.1.  Add BSI
copyright notice.
* tools/call-dirmngr.h: Ditto.
* tools/gpg-wks-client.c: Ditto.
* tools/gpg-wks-server.c: Ditto.
* tools/gpg-wks.h: Ditto.
* tools/mime-maker.c: Ditto.
* tools/mime-maker.h: Ditto.
* tools/mime-parser.c: Ditto.
* tools/mime-parser.h: Ditto.
* tools/send-mail.c: Ditto.
* tools/send-mail.h: Ditto.
* tools/wks-receive.c: Ditto.
* tools/wks-util.c: Ditto.
* tools/rfc822parse.c, tools/rfc822parse.h: Change license to LGPLv2.1.
--

For better deployment it seems to be better to make the Web Key
Directory code more easily available.

Some code was been developed under contract of the BSI.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-06-19 12:42:13 +02:00
NIIBE Yutaka
5c8fe54809 Spelling fixes in docs and comments.
--

In addition, fix trailing spaces in tests/inittests.

GnuPG-bug-id: 3121
Reported-by: ka7 (klemens)
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-28 10:06:33 +09:00
NIIBE Yutaka
f52f6af834 tools: Fix condition for gpg-connect-agent.
* tools/gpg-connect-agent.c (start_agent): Add paren.

--

The intention is comparing the error code depending opt.use_dirmngr.
Considering C Operator Precedence, we should have paren here.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-12 16:01:16 +09:00
NIIBE Yutaka
03d77b60be g10,tools: Fix bzlib.h include order.
* g10/compress-bz2.c: Include bzlib.h after gcrypt.h.
* tools/gpgsplit.c: Likewise.

--

bzlib.h may include windows.h on Windows.  It is better
after gcrypt.h which may include winsock2.h.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-11 13:52:19 +09:00
NIIBE Yutaka
a1446163d5 tools: Portability fix for gpgparsemail.
* tools/rfc822parse.c (my_stpcpy): Rename from stpcpy.

--

When HAVE_STPCPY is not defined (no definition in libc), still,
compiler may have definition as a built-in function (for some specific
case like second argument is constant).  In that case, having stpcpy
implementation with the same name but different signature ("static"
qualifier) is not good.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-11 11:23:05 +09:00
Werner Koch
d23052b04e
gpgconf: Add --enable-extended-key-format for the agent.
* tools/gpgconf-conf.c: Add option.
* agent/gpg-agent.c (main) <aGPGConfList>: Add option.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-04-03 16:54:43 +02:00
Werner Koch
2c9d9ac55e
tests: Use gpgconf to stop the agent.
* tests/openpgp/defs.scm (stop-agent): Swap order of actions.  Kill
all daemons using gpgconf.
* tools/gpgconf.c (main) <aRemoveSocketDir>: Try to remove known
socketfails on rmdir failure.  Do no fail for ENONET.
--

Killing all daemons is not really required but it does not harm to be
prepared for the future.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-03-23 17:55:21 +01:00
Werner Koch
ed5575ec55
wks: Put stdout into binary mode for Windows at another place.
* tools/wks-util.c (wks_send_mime): Set stdout to binary.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-03-08 17:48:55 +01:00
Werner Koch
5c83759364
wks: Put stdout into binary mode for Windows.
* tools/send-mail.c (send_mail_to_file): Call es_set_binary.
--

Without that, output to stdout via --send is mangled: The "\r\n" is
translated to "\r\r\n" which is bad because other
software (e.g. Thunderbird) translates this again to "\n\n" and thus
put all mail header liens after the first into the body.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-03-08 17:25:27 +01:00
NIIBE Yutaka
80fb1a8a05 tools: Removal of -Icommon.
* tools/gpg-wks-server.c: Follow the change.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-03-07 20:38:22 +09:00
NIIBE Yutaka
d6c7bf1f8a More change for common.
* g10, scd, test, tools: Follow the change of removal of -Icommon.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-03-07 20:32:09 +09:00
NIIBE Yutaka
70aca95d68 Remove -I option to common.
* dirmngr/Makefile.am (AM_CPPFLAGS): Remove -I$(top_srcdir)/common.
* g10/Makefile.am (AM_CPPFLAGS): Ditto.
* g13/Makefile.am (AM_CPPFLAGS): Ditto.
* kbx/Makefile.am (AM_CPPFLAGS): Ditto.
* scd/Makefile.am (AM_CPPFLAGS): Ditto.
* sm/Makefile.am (AM_CPPFLAGS): Ditto.
* tools/Makefile.am (AM_CPPFLAGS): Ditto.
* Throughout: Follow the change.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-03-07 20:25:54 +09:00
NIIBE Yutaka
ce37ada871 tools: More portable for openpty use.
* configure.ac (AC_CHECK_HEADERS): Add util.h libutil.h and termios.h.
* tools/symcryptrun.c: Include those headers.

--

This is for OpenBSD and FreeBSD.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-03-07 10:42:28 +09:00
Werner Koch
e3589110e0
wks: Set published keys world-readable.
* tools/gpg-wks-server.c (check_and_publish): Set the permissions.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-03-06 13:21:50 +01:00
Werner Koch
b1f48da02b
tools: Fix compile error with older gcc versions.
* tools/mime-parser.h: Include rfc822parse.h.
(struct rfc822parse_context): Remove duplicate definition.
--

GnuPG-bug-id: 2851
Signed-off-by: Werner Koch <wk@gnupg.org>
2017-03-02 20:07:12 +01:00
Justus Winter
e064c75b08
common,tools: Always escape newlines when escaping data.
* common/stringhelp.c (do_percent_escape): Always escape newlines.
* tools/gpgconf-comp.c (gc_percent_escape): Likewise.
--
Newlines always pose a problem for a line-based communication format.

GnuPG-bug-id: 2387
Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-02 09:31:11 +01:00
Justus Winter
d379a0174c
gpg,tools: Make auto-key-retrieve configurable via gpgconf.
* g10/gpg.c (gpgconf_list): Add 'auto-key-retrieve'.
* tools/gpgconf-comp.c (gc_options_gpg): Likewise.

GnuPG-bug-id: 2381
Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-28 14:59:11 +01:00
Justus Winter
ebeccd73eb
gpg,tools: Make trust-model configurable via gpgconf.
* g10/gpg.c (gpgconf_list): Add 'trust-model'.
* tools/gpgconf-comp.c (gc_options_gpg): Likewise.

GnuPG-bug-id: 2381
Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-28 13:15:42 +01:00
Werner Koch
d30e17ac62
wks: Make sure that the draft 2 request is correctly detected.
* tools/gpg-wks.h (WKS_DRAFT_VERSION): New.
* tools/wks-receive.c (new_part): Move test wks draft version to ...
(t2body): new callback.
(wks_receive): Register this callback.
* tools/gpg-wks-server.c (send_confirmation_request): Emit draft
version header.
(send_congratulation_message): Ditto.
* tools/gpg-wks-client.c (decrypt_stream_parm_s): New.
(decrypt_stream_status_cb): Check DECRYTPION_KEY status.
(decrypt_stream): Get infor from new callback.
(process_confirmation_request): New arg 'mainfpr'.  Check that it
matches the decryption key.
(read_confirmation_request): Check that the decryption key has been
generated by us.
(command_send): Use macro from draft version header.
(send_confirmation_response): Emit draft version header.
--

This patch also adds a check to only send a confirmation when the
decryption has been done by an ultimately trusted (self-generated)
key.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-02-23 20:10:59 +01:00
Werner Koch
a209025082
wks: New callback for the mime parser.
* tools/mime-parser.c (mime_parser_context_s): New field 't2body'.
(parse_message_cb): Call that callback.
(mime_parser_set_t2body): New.
--

This callback allows to process header values even on the outer level.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-02-23 20:01:30 +01:00
Daniel Kahn Gillmor
ccb420380b Fix spelling.
--

Clean up several other misspellings noticed while reviewing Yuri's
de-duplication patch.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2017-02-21 13:11:46 -05:00
Yuri Chornoivan
24cf0606b4 Clean up word replication.
--

This fixes extra word repetitions (like "the the" or "is is") in the
code and docs.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2017-02-21 13:11:46 -05:00
Werner Koch
30dac0486b
gpgconf: No ENOENT warning with --change-options et al.
* tools/gpgconf-comp.c (retrieve_options_from_program): Check ERRNO
before printing a warning.
--

It is common that a conf files does not exist - thus we should not
print a warning.

GnuPG-bug-id: 2944

BTW: The error messages in gpgconf should be reworked to match those
of the other components.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-02-13 20:13:05 +01:00
Werner Koch
b30ac663ce
wks: Add WKS-Phase headers to the server messages.
* tools/gpg-wks-server.c (send_confirmation_request): Add custom
header.
(send_congratulation_message): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-02-07 11:49:21 +01:00
Justus Winter
73d6572bd0 tools: Use platform abstraction for I/O.
* tools/gpg-connect-agent.c (main): Use a gpgrt_stream_t for
'script_fp'.  Adapt accordingly.
--
Werner asked me to make gpgconf use the platform abstractions that
were introduced after gpgconf's inception.  After doing that, I
realized that 'read_line' is only used in two more places, one of
which this patch takes care of.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 15:44:16 +01:00
Justus Winter
77b8aff4e1 tools: Use platform abstraction for I/O.
* tools/gpgconf-comp.c (retrieve_options_from_file): Use a
gpgrt_stream_t for 'list_file'.  Adapt accordingly.
(copy_file): Likewise for 'src' and 'dst'.
(change_options_file): Likewise for 'src_file' and 'dest_file'.
(change_options_program): Likewise for 'src_file' and 'dest_file'.
(gc_process_gpgconf_conf): Likewise for 'config'.
--
Werner asked me to make gpgconf use the platform abstractions that
were introduced after gpgconf's inception.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 15:44:16 +01:00
Justus Winter
bfd75e9492 tools: Use platform abstraction for renaming files.
* tools/gpgconf-comp.c (gc_component_change_options): Use
'gnupg_rename_file'.  Also, block signals across all renames in an
attempt to make the whole process atomic.
--
Werner asked me to make gpgconf use the platform abstractions that
were introduced after gpgconf's inception.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 15:44:16 +01:00
Justus Winter
82e309ad06 tools: Add comments explaining the functions parameters.
* tools/gpgconf-comp.c (change_options_file): Add comments explaining
the functions parameters.
(change_options_program): Likewise.
--
From reading those two functions it is not clear why we write the new
configuration to the source file, and read the current configuration
from the destination file.  The identifiers are named for the benefit
of the callee.

Note that identifiers that require that much explanation are poorly
chosen.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 15:44:16 +01:00
Justus Winter
b0348fdb26 tools: Improve error handling.
* tools/gpgconf-comp.c (gp_component_change_options): Improve error
handling when reading from stdin.
--
Previously, errors encountered while reading the configuration changes
were ignored.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 15:44:16 +01:00
Justus Winter
5b28f02508 tools: Fix memory leak.
* tools/gpgconf-comp.c (change_options_file): Fix leak.
--
Previously, 'src_filename' and 'orig_filename' leaked if creating the
backup file failed.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 14:35:56 +01:00
Werner Koch
707c47f559
Update copyright notices for 2017.
--

Also some http:// -> https:// fixes.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-01-23 19:16:55 +01:00
Werner Koch
af5979a42b
Fix format string errors and some missing error case initialization.
* common/logging.c (do_logv): Remove extra parentheses in comparison.

* dirmngr/dns-stuff.c (resolve_addr_libdns): Init RES so that
dns_res_close is given a defined value in the error case.

* dirmngr/http.c (cookie_read, cookie_write) [HTTP_USE_NTBTLS]: Fix
format string char.

* dirmngr/ks-engine-hkp.c (ks_hkp_help): Remove duplicate "const".
* dirmngr/ks-engine-http.c (ks_http_help): Ditto.
* dirmngr/ks-engine-kdns.c (ks_kdns_help): Ditto.
* dirmngr/ks-engine-ldap.c (ks_ldap_help): Ditto.

* scd/app-p15.c (send_keypairinfo, do_getattr): Fix format string
char.
* tools/gpgconf-comp.c (gpg_agent_runtime_change): Init PID for the
error case.
(scdaemon_runtime_change): Ditto.
(dirmngr_runtime_change): Ditto.

* tools/gpgconf.c (query_swdb): Init VALUE_SIZE_UL.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-01-23 16:33:01 +01:00
Werner Koch
2312248b2e
gpgconf: Allow "all" for --launch, --kill, and --reload.
* tools/gpgconf-comp.c (gc_component_launch): Allow -1 for COMPONENT.
(gc_component_kill): Ditto.
(gc_component_reload): For robustness change the condition to < 0.
* tools/gpgconf.c (main) <aLaunch, aKill, aReload>: Support argument
"all".

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-01-18 10:07:53 +01:00
Justus Winter
1f5caf90bf tools: Fix memory leaks and improve error handling.
* tools/gpgconf-comp.c (gc_option_free): New function.
(gc_components_free): Likewise.
(gc_components_init): Likewise.
(retrieve_options_from_program): Use 'xfree', fix memory leak.
(change_options_program): Improve error handling.
(gc_component_change_options): Fix memory leaks.
* tools/gpgconf.c (main): Initialize components.
* tools/gpgconf.h (gc_components_init): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-10 15:42:27 +01:00
Werner Koch
6170eb8090
Silence two -Wlogical-op warnings.
* common/tlv.c (parse_ber_header): Avoid compiler warning about a
duplicate condition.
* tools/gpgtar-create.c (pattern_valid_p): Likewise.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-01-05 20:43:40 +01:00
Neal H. Walfield
1909e994cb tools: Show a clearer error message if a server doesn't support WKS
* tools/gpg-wks-client.c (command_send): If we fail to lookup the
submission address, print a better error message.  If it is because
the corresponding file doesn't exist, provide the hint that the server
probably doesn't support WKS.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-12-22 16:06:13 +01:00
Werner Koch
e917dfcd97
wks: Let the client ignore missing policy flags.
* tools/gpg-wks-client.c (command_send): Ignore missing policy flags.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-22 14:40:43 +01:00
Werner Koch
81c012787f
dirmngr: New option --resolver-timeout.
* dirmngr/dns-stuff.c (DEFAULT_TIMEOUT): New.
(opt_timeout): New var.
(set_dns_timeout): New.
(libdns_res_open): Set the default timeout.
(libdns_res_wait): Use configurable timeout.
(resolve_name_libdns): Ditto.

* dirmngr/dirmngr.c (oResolverTimeout): New const.
(opts): New option --resolver-timeout.
(parse_rereadable_options): Set that option.
(main) <aGPGConfList>: Add --nameserver and --resolver-timeout.
* tools/gpgconf-comp.c (gc_options_dirmngr): Add --resolver-timeout
and --nameserver.

* dirmngr/http.c (connect_server): Fix yesterday introduced bug in
error diagnostic.
--

This timeout is a pretty crude thing because libdns has a few other
internal timeouts as well.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-20 09:53:58 +01:00
Werner Koch
76cd64a5ba
gpgconf: New command --apply-profile.
* tools/gpgconf.c (aApplyProfile): New.
(opts): New command --apply-profile.
(main): Implement that command.
* tools/gpgconf-comp.c (option_check_validity): Add arg VERBATIM.
(change_options_program): Ditto.
(change_one_value): Ditto.
(gc_component_change_options): Ditto.
(gc_apply_profile): New.

--

Here is an example for a profile

--8<---------------cut here---------------start------------->8---
# foo.prf - Sample profile

[gpg]
compliance de-vs
default-new-key-algo brainpoolP256r1+brainpoolP256r1

[gpgsm]
enable-crl-checks

[gpg-agent]
default-cache-ttl 900
max-cache-ttl [] 3600
no-allow-mark-trusted
no-allow-external-cache
enforce-passphrase-constraints
min-passphrase-len 9
min-passphrase-nonalpha 0

[dirmngr]
keyserver hkp://keys.gnupg.net
allow-ocsp
--8<---------------cut here---------------end--------------->8---

Note that flags inside of brackets are allowed after the option name.
The only defined flag for now is "[default]".  In case the value
starts with a bracket, it is possible to insert "[]" as a nop-flag.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-16 16:05:02 +01:00
Werner Koch
6ca3c28da4
gpgconf: Fix --apply-defaults.
* tools/gpgconf-comp.c: Skip pinentry also in process_all mode.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-16 16:05:02 +01:00
Justus Winter
ca1e9749bf common: Support locating components in the build tree.
* common/homedir.c (gnupg_build_directory): New variable.
(gnupg_module_name_called): Likewise.
(gnupg_set_builddir): New function.
(gnupg_set_builddir_from_env): Likewise.
(gnupg_module_name): Support locating components in the build tree.
* common/util.h (gnupg_set_builddir): New prototype.
* tests/openpgp/defs.scm (tools): Drop 'gpg and 'gpg-agent.
(tool): Rename to 'tool-hardcoded.
(gpg-conf): New function, with accessors for the results.
(gpg-components): New variable.
(tool): New function.
* tools/gpgconf.c (enum cmd_and_opt_values): New key.
(opts): New option '--build-prefix'.
(main): Handle new option.
--

This change makes sure that the components from the build tree are
used, and not some older installed version in PATH.  It also lets us
make GPGME use components from the build tree, making it possible to
execute GPGME's test suite with them.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-14 16:41:18 +01:00
Werner Koch
4a04277ad1
wks: New option --status-fd for gpg-wks-client.
* tools/wks-util.c: Include status.h.
(statusfp): New global var.
(wks_set_status_fd): New func.
(wks_write_status): New func.
* tools/gpg-wks-client.c: Include status.h.
(oStatusFD): New constant.
(opts): New option --status-fd.
(parse_arguments): Handle that option.
(main): Return STATUS_SUCCESS or STATUS_FAILURE.
--

This option is useful in case gpg-wks-client is spawed using a double
fork approach which does not allow to return the exit code.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-08 17:56:12 +01:00
Werner Koch
d8c5e8ccfd
wks: New option --check for gpg-wks-client.
* tools/call-dirmngr.c (wkd_get_key): New.
* tools/gpg-wks-client.c (aCheck): New constant.
(opts): New option "--check".
(main): Call command_check.
(command_check): New.
--

GnuPG-bug-id: 2866
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-08 16:59:12 +01:00
Werner Koch
c3138decd7
tools: Move a function from gpg-wks-server to wks-util.c.
* tools/gpg-wks-server.c (list_key_status_cb): Remove.
(list_key): Move to ...
* tools/wks-util.c (wks_list_key): here and rename.  Add new args
R_FPR and R_MBOXES and remove the CTX.
(list_key_status_cb): New.
* tools/wks-util.c: Include ccparray.h, exectool.h, and mbox-util.h.
* tools/gpg-wks-server.c (process_new_key): Replace list_key by
wks_list_key.
(check_and_publish): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-08 16:59:12 +01:00
Werner Koch
dd03667ab1
tools: Fix use of uninitialized var in mime-maker.
* tools/mime-maker.c (ensure_part): Make sure to set R_PARENT on
error.
(add_missing_headers): Ensure that ERR is set on success.

* tools/wks-util.c (wks_parse_policy): Fix indentation.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-08 13:08:02 +01:00
Werner Koch
b265969154
tools: Fix memleak in gpgconf.
* tools/gpgconf.c (main): Free SOCKETDIR.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-12-08 13:08:02 +01:00
Justus Winter
9fb5e9c145 tools,build: Build WKS tools against libintl.
* tools/Makefile.am (gpg_wks_server_LDADD): Link against libintl.
(gpg_wks_client_LDADD): Likewise.

GnuPG-bug-id: 2846
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-29 16:00:48 +01:00
Werner Koch
bd91f92ace
dirmngr: Auto-sownload the swdb.lst
* dirmngr/dirmngr.h (struct opt): Add field allow_version_check.
* dirmngr/dirmngr.c (oAllowVersionCheck): New.
(opts): Add --allow-version-check.
(network_activity_seen): New variable.
(parse_rereadable_options): Set opt.allow_version_check.
(main) <aGPGConfList>: Do not anymore set the no change flag for
Windows.  Add allow-version-check.
(netactivity_action): Set network_activity_seen.
(housekeeping_thread): Call dirmngr_load_swdb.
* tools/gpgconf-comp.c (gc_options_dirmngr): Add allow-version-check.
Make "use-tor" available at Basic level.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-11-17 10:14:14 +01:00
Werner Koch
d8da5bc50b
gpgconf: Change the displayed names of the components.
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-11-17 10:07:59 +01:00
Werner Koch
c564790df7
wks: Always build gpg-wks-client.
* tools/Makefile.am (gpg_wks_client): Remove macro.
(libexec_PROGRAMS): Add gpg-wks-client.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-11-16 12:48:27 +01:00
Werner Koch
56e1864aa3
wks: Encrypt all client mails also the target key,
* tools/gpg-wks-client.c (encrypt_response): Add arg FINGERPRINT.
(send_confirmation_response): Ditto.
(process_confirmation_request): Parse out fingerprint and pass
send_confirmation_response.
--

This is useful for debugging the protocol and to avoid surprises when
the sender tries to open a message from the Sent folder.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-11-07 14:04:47 +01:00
Justus Winter
70215ff470 tests,tools: Reimplement 'mk-tdata' in Scheme.
* tests/openpgp/defs.scm (tools): Drop 'mk-tdata'.
* tests/openpgp/setup.scm (make-test-data): New function.
* tests/openpgp/verify.scm: Avoid 'mk-tdata'.
* tools/Makefile.am (noinst_PROGRAMS): Drop 'mk-tdata'.
* tools/mk-tdata.c: Drop file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 13:28:55 +01:00
Werner Koch
4d7dc432b5
Change all http://www.gnu.org in license notices to https://
--
2016-11-05 12:02:19 +01:00
Werner Koch
d10b67b9bc
gpgconf: Add a new field to the --query-swdb output.
* tools/gpgconf.c (query_swdb): Insert new field with the installed
version.  Check that the supplied version does not contain a colon.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-11-03 10:58:19 +01:00
Werner Koch
0ed6a6df5a
gpgconf: Add command --query-swdb.
* tools/gpgconf.c (aQuerySWDB): New.
(opts): Add --query-swdb.
(valid_swdb_name_p): New.
(query_swdb): New.
(main): Implement command --query-swdb.
--

Right now this command is not very useful because dimngr has not yet
been changed to create the swdb.lst.  For manual tests the swdb.lst
file from the Net can be used with these additional lines:

  .filedate 20161102T130337
  .verified 20161102T150000
2016-11-02 17:58:11 +01:00
NIIBE Yutaka
70a8584ec4 gpgconf: Fix for --homedir.
* tools/gpgconf-comp.c (gpg_agent_runtime_change,
scdaemon_runtime_change, dirmngr_runtime_change): Provide the homedir
arguments by --homedir when it's not default.

--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2016-10-17 11:36:45 +09:00
Justus Winter
5afbfdfd59 tools: Fix error handling.
* tools/gpgtar-create.c (gpgtar_create): Do not crash if opening the
tarball failed.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-07 16:25:55 +02:00
Justus Winter
32f81f56a8 tools: Improve error handling.
* tools/gpg-wks-server.c (copy_key_as_binary): Initialize 'argv'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-06 14:17:03 +02:00
Werner Koch
8ce800d219
wks: Send key encrypted as required by draft -02
* tools/gpg-wks-client.c (get_key): Encrypt.
(encrypt_response): Take care of --fake-submission-addr.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-10-05 14:38:37 +02:00
Werner Koch
e514a5b725
wks: Add option --fake-submission-addr to gpg-wks-client.
* tools/gpg-wks-client.c (oFakeSubmissionAddr): New.
(opts): Add option --fake-submission-addr.
(fake_submission_addr): New variable.
(parse_arguments): Set it.
(command_send): Use --fake-submission-addr.
--

This option is useful for testing.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-10-05 11:51:32 +02:00
Justus Winter
fbc83c0cdd tools: Ignore existing directories in gpgtar.
* tools/gpgtar-extract.c (extract_directory): Ignore existing
directories now that we have '--directory'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-04 13:23:17 +02:00
Werner Koch
80cc16e072
agent: Create the extra sockets in the standard socket dir.
* agent/gpg-agent.c (main): Take the socketdir in account for the
default sockets.
* tools/gpgconf.c (list_dirs): Add "agent-extra-socket" and
"agent-browser-socket".

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-30 19:21:51 +02:00
Werner Koch
de67055aff
wks: Avoid long trustdb checks.
* tools/wks-receive.c (verify_signature): Use --always-trust.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-30 18:12:44 +02:00
Justus Winter
6054e8aaec build: Fix build against libiconv.
* agent/Makefile.am: Add INCICONV and LIBICONV.
* common/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-30 17:45:59 +02:00
Werner Koch
33800280da
wks: Partly implement draft-koch-openpgp-webkey-service-02.
* tools/gpg-wks.h (WKS_RECEIVE_DRAFT2): New.
* tools/wks-receive.c: Include rfc822parse.h.
(struct receive_ctx_s): Add fields PARSER, DRAFT_VERSION_2, and
MULTIPART_MIXED_SEEN.
(decrypt_data): Add --no-options.
(verify_signature): Ditto.
(new_part): Check for Wks-Draft-Version header.  Take care of text
parts.
(wks_receive): Set Parser and pass a flag value to RESULT_CB.
* tools/gpg-wks-client.c (read_confirmation_request): New.
(main) <aRead>: Call read_confirmation_request instead of
process_confirmation_request.
(command_receive_cb): Ditto.  Add arg FLAGS..
(decrypt_stream_status_cb, decrypt_stream): New.
(command_send): Set header Wks-Draft-Version.
* tools/gpg-wks-server.c (struct server_ctx_s): Add field
DRAFT_VERSION_2.
(sign_stream_status_cb, sign_stream): New.
(command_receive_cb): Set draft flag.
(send_confirmation_request): Rework to implement protocol draft
version 2.

* tools/gpg-wks.h (DBG_MIME_VALUE, DBG_PARSER_VALUE): New.
(DBG_MIME, DBG_PARSER, DBG_CRYPTO): New.  Use instead of a plain
opt.debug where useful.
* tools/gpg-wks-client.c (debug_flags): Add "mime" and "parser".
* tools/gpg-wks-server.c (debug_flags): Ditto.
--

If a client supporting the version 2 of the protocol is used, it will
tell this the server using a mail header.  An old server will ignore
that but a recent server will use the new protocol.  Next task is to
actually write draft-02.

There are still a lot of FIXMEs - take care.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-29 17:59:41 +02:00
Werner Koch
c738f92c19
tools: Convey signeddata also to the part_data callback in mime-parser.
* tools/mime-parser.c (mime_parser_parse): Factor some code out to ...
(process_part_data): new.
((mime_parser_parse): Also call process_part_data for signed data.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-29 17:59:38 +02:00
Werner Koch
f776757ea9
tools: Allow retrieval of signed data from mime-maker.
* tools/mime-maker.c (find_part): New.
(mime_maker_get_part): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-29 17:56:37 +02:00
Werner Koch
29db3be6e8
tools: Change mime-maker to write out CR,LF.
* tools/mime-maker.c (struct part_s): Add field PARTID.
(struct mime_maker_context_s): Add field PARTID_COUNTER.
(dump_parts): Print part ids.
(mime_maker_add_header): Assign PARTID.
(mime_maker_add_container): Ditto.
(mime_maker_get_partid): New.
(write_ct_with_boundary): Remove.
(add_header): Strip trailing white spaces.
(write_header): Remove trailing spaces trimming.  Add arg BOUNDARY.
Handle emdedded LFs.
(write_gap, write_boundary, write_body): New.
(write_tree): Use new functions.
--

These changes prepare for forthcoming enhancements.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-29 17:56:37 +02:00
Werner Koch
95d60c6ce9
tools: Simplify the mime-maker container creation.
* tools/mime-maker.c (struct part_s): Remove field MEDIATYPE.
(release_parts): Ditto.
(dump_parts): Print a body line only if tehre is a body.
(mime_maker_add_header): Check for body or container.
(mime_maker_add_container): Remove arg MEDIATYPE.  Change all callers.
(mime_maker_end_container): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-29 17:56:37 +02:00
Werner Koch
4ac138c84d
tools: Give mime parser callbacks access to the rfc822 parser.
* tools/mime-parser.c (mime_parser_context_s): Add field MSG.
(parse_message_cb): Set it.
(mime_parser_rfc822parser): New.
* tools/mime-parser.h: Declare rfc822parse_t for the new prototype.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-29 17:56:37 +02:00
Justus Winter
20a16833ee build: Do not link gpg-connect-agent against npth.
* tools/Makefile.am: Do not link gpg-connect-agent against npth.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-27 17:45:52 +02:00
Daniel Kahn Gillmor
0d67241e31 Fix more spelling
* NEWS, acinclude.m4, agent/command-ssh.c, agent/command.c,
  agent/gpg-agent.c, agent/keyformat.txt, agent/protect-tool.c,
  common/asshelp.c, common/b64enc.c, common/recsel.c, doc/DETAILS,
  doc/HACKING, doc/Notes, doc/TRANSLATE, doc/dirmngr.texi,
  doc/faq.org, doc/gpg-agent.texi, doc/gpg.texi, doc/gpgsm.texi,
  doc/instguide.texi, g10/armor.c, g10/gpg.c, g10/keyedit.c,
  g10/mainproc.c, g10/pkclist.c, g10/tofu.c, g13/sh-cmd.c,
  g13/sh-dmcrypt.c, kbx/keybox-init.c, m4/pkg.m4, sm/call-dirmngr.c,
  sm/gpgsm.c, tests/Makefile.am, tests/gpgscm/Manual.txt,
  tests/gpgscm/scheme.c, tests/openpgp/gpgv-forged-keyring.scm,
  tests/openpgp/multisig.test, tests/openpgp/verify.scm,
  tests/pkits/README, tools/applygnupgdefaults,
  tools/gpg-connect-agent.c, tools/mime-maker.c, tools/mime-parser.c:
  minor spelling cleanup.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-09-17 16:00:37 +09:00
Werner Koch
9da780e5c4
tools: Minor fix to the usbmon debugging tool.
--
* tools/ccidmon.c (GNUPG_NAME): Define if not defined.
(digitp, hexdigitp): Change to our common semantics.

--
Note that this tool only exists in the repo.

GnuPG-bug-id: 2678
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-13 08:26:56 +02:00
Werner Koch
0ac671f8a2
common: Add an assuan logging monitor.
* common/asshelp.c (my_log_monitor): New var.
(my_libassuan_log_handler): Run that monitor.
(setup_libassuan_logging): Add arg to set a log monitor and change all
callers.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-05 11:58:48 +02:00
Werner Koch
46362cbc0e
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>
2016-09-02 16:56:04 +02:00
Werner Koch
04c042f3f2
wks: Send a final message to the user.
* tools/gpg-wks-server.c (send_congratulation_message): New.
(check_and_publish): Call it.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-31 19:13:37 +02:00
Werner Koch
e4eac16330
wks: Relax permission check for the top directory.
* tools/gpg-wks-server.c: Allow S_IXOTH for the top directory.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-31 19:13:37 +02:00
Werner Koch
8e3fa5a4b2
gpgconf: Print the plain socket directory with --list-dirs.
* tools/gpgconf.c (list_dirs): Add plain socketdir out.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-29 11:53:06 +02:00
Werner Koch
460568d341
wks: Add command --supported to gpg-wks-client.
* tools/gpg-wks-client.c (aSupported): New.
(opts): Add --supported.
(parse_arguments): Ditto.
(main): Call command_supported.
(command_supported): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-24 15:48:21 +02:00
Werner Koch
c47386a11a
wks: Install gpg-wks-client under libexec
* tools/Makefile.am (bin_PROGRAMS): Move gpg-wks-client to ...
(libexec_PROGRAMS): ...here.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-22 17:05:00 +02:00
Werner Koch
d83ba4897b
dirmngr: Remove all system daemon features.
* dirmngr/dirmngr.h (opts): Remove fields 'system_service' and
'system_daemon'.
* common/homedir.c (dirmngr_sys_socket_name): Remove.
(dirmngr_user_socket_name): Rename to ...
(dirmngr_socket_name): this.  Change call callers.
* common/asshelp.c (start_new_dirmngr): Remove the system socket
feature.
* tools/gpgconf.c (list_dirs): Do not print "dirmngr-sys-socket".
* sm/server.c (gpgsm_server): Adjust for removed system socket feature.
* dirmngr/server.c (cmd_getinfo): Ditto.
(cmd_killdirmngr): Remove check for system daemon.
(cmd_reloaddirmngr): Ditto.
* dirmngr/dirmngr.c (USE_W32_SERVICE): Remove macro.
(aService): Remove.
(opts): Remove --service.
(w32_service_control): Remove.
(real_main, call_real_main) [W32]: Remove wrapper.
(main): Remove Windows system service feature.  Remove system dameon
feature.  Use only the "~/.gnupg/dirmngr_ldapservers.conf" file.
* dirmngr/certcache.c (load_certs_from_dir): Remove warning in the
system dameon case.
* dirmngr/crlcache.c (DBDIR_D): Always use "~/.gnupg/crls.d".
* dirmngr/ocsp.c (validate_responder_cert): Do not call
validate_cert_chain which was used only in system daemon mode.
* dirmngr/validate.c (validate_cert_chain): Always use the code.
--

We are now starting dirmngr as needed as a user daemon.  The
deprecated system daemon mode does not anymore make sense.  In case a
system wide daemon is required, it is better to setup a dedicated
account to run dirmngr and tweak socket permissions accordingly.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-18 11:23:40 +02:00
Daniel Kahn Gillmor
61c2a1fa6d
Call log_set_prefix() with human-readable labels.
* agent/preset-passphrase.c, agent/protect-tool.c, dirmngr/dirmngr.c
* dirmngr/t-http.c, g10/gpg.c, g10/gpgv.c, g13/g13-syshelp.c
* g13/g13.c, kbx/kbxutil.c, scd/scdaemon.c, sm/gpgsm.c
* tests/gpgscm/main.c, tools/gpg-check-pattern.c
* tools/gpg-connect-agent.c, tools/gpgconf.c, tools/gpgtar.c
* tools/symcryptrun.c: Invoke log_set_prefix() with
human-readable labels.

--

Some invocations of log_set_prefix() were done with raw numeric values
instead of values that humans can understand.  Use symbolic
representations instead of numeric for better readability.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-12 12:16:19 +02:00
Justus Winter
14479e2515 common: Rework the simple password query module.
* common/simple-pwquery.c (writen, readline): Drop.
(agent_send_option, agent_send_all_options, agent_open): Just use
libassuan.
(simple_pw_set_socket): Simplify.
(default_inq_cb): New function.
(simple_pwquery, simple_query): Just use libassuan.
* agent/Makefile.am (gpg_preset_passphrase_LDADD): Add libassuan.
* tools/Makefile.am (symcryptrun_LDADD): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-11 12:49:30 +02:00
Justus Winter
9e6503b7ce common: Remove simple password query error codes.
* common/simple-pwquery.h: Remove mapping function.  Move all
definitions of status codes...
* common/simple-pwquery.c: ... here, and define them to meaningful gpg
error values.
* agent/preset-passphrase.c (preset_passphrase): Use error code as-is.
(forget_passphrase): Likewise.
* tools/symcryptrun.c (confucius_get_pass): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-11 09:52:08 +02:00
Ben Kibbey
49829c29e5 Cleanup initialization of libgcrypt.
* common/init.c (init_common_subsystems): Initialize libgcrypt.
* dirmngr/Makefile.am (dirmngr_ldap): Link with libgcrypt.

--
Most other modules already call gcry_check_version() after
init_common_subsystems() so may as well move initialization of libgcrypt
to here. Also fixes a warning in the system log from gpgconf --homedir.

Signed-off-by: Ben Kibbey <bjk@luxsci.net>
2016-08-09 10:47:46 +02:00
Werner Koch
db6f3eb926
gpgconf: Add limited support for -0.
* tools/gpgconf.h (opt): Add field 'null'.
* tools/gpgconf.c: Add option --null/-0.
(list_dirs): Use it here.
--

This option changes the delimites for --list-dir with arguments from
LF to Nul.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-04 13:02:37 +02:00
Daniel Kahn Gillmor
dc107b7850 More cleanup of "allow to".
* README, agent/command.c, agent/keyformat.txt, common/i18n.c,
  common/iobuf.c, common/keyserver.h, dirmngr/cdblib.c,
  dirmngr/ldap-wrapper.c, doc/DETAILS, doc/TRANSLATE,
  doc/announce-2.1.txt, doc/gpg.texi, doc/gpgsm.texi,
  doc/scdaemon.texi, doc/tools.texi, doc/whats-new-in-2.1.txt,
  g10/export.c, g10/getkey.c, g10/import.c, g10/keyedit.c, m4/ksba.m4,
  m4/libgcrypt.m4, m4/ntbtls.m4, po/ca.po, po/cs.po, po/da.po,
  po/de.po, po/el.po, po/eo.po, po/es.po, po/et.po, po/fi.po,
  po/fr.po, po/gl.po, po/hu.po, po/id.po, po/it.po, po/ja.po,
  po/nb.po, po/pl.po, po/pt.po, po/ro.po, po/ru.po, po/sk.po,
  po/sv.po, po/tr.po, po/uk.po, po/zh_CN.po, po/zh_TW.po,
  scd/app-p15.c, scd/ccid-driver.c, scd/command.c, sm/gpgsm.c,
  sm/sign.c, tools/gpgconf-comp.c, tools/gpgtar.h: replace "Allow to"
  with clearer text.

In standard English, the normal construction is "${XXX} allows ${YYY}
to" -- that is, the subject (${XXX}) of the sentence is allowing the
object (${YYY}) to do something.  When the object is missing, the
phrasing sounds awkward, even if the object is implied by context.
There's almost always a better construction that isn't as awkward.

These changes should make the language a bit clearer.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-03 16:55:33 +02:00
Daniel Kahn Gillmor
cd45cf782b Fix spelling and grammar.
* agent/learncard.c: s/coccured/occurred/
* doc/dirmngr.texi: s/ommitted/omitted/, s/orginally/originally/,
  s/reponses/responses/i
* doc/gpg-agent.texi, doc/dirmngr.texi, doc/gpg.texi: Fix "allows
  to" to more conventional english usage.
* doc/tools.texi, g10/gpgcommpose.c, tests/openpgp/armor.scm,
  tests/openpgp/armor.test: s/occured/occurred/
* tools/gpgsplit.c: s/calcualting/calculating/
* sm/server.c: s/formated/formatted/

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-03 16:54:01 +02:00
Justus Winter
7f4dd24b88 build: Always build gpgtar.
We use gpgtar to unpack test data, hence we always build it.  If the
user opts out, we simply don't install it.

* configure.ac: Add comment.
* tests/migrations/Makefile.am (required_pgms): Make sure gpgtar is
built.
* tools/Makefile.am: Always build gpgtar, but do not install it if the
user used '--disable-gpgtar'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-15 17:24:49 +02:00
Werner Koch
b7b37716b9
wks: Publish as binary file.
* tools/gpg-wks-server.c (copy_key_as_binary): New.
(check_and_publish): Use new function instead of rename.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-15 17:21:25 +02:00
Werner Koch
95810929f7
wks: Use correct key for the confirmation
* tools/gpg-wks-client.c (send_confirmation_response): Actually
encrypt to the recipient.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-13 12:12:21 +02:00
Werner Koch
44ecc33b4a
wks: New server command --list-domains
* tools/gpg-wks-server.c (aListDomains): New.
(opts): Add --list-domains.
(parse_arguments): Implement.
(main): Ditto.  Use only one final diagnostic message.
(command_list_domains): New.
(check_and_publish): Remove directory creation.
(get_domain_list): New.
(expire_pending_confirmations): Rewrite using a list of directories.
(command_cron): Get domain list and pass to
expire_pending_confirmations.
--

  gpg-wks-server --list-domains

is required once to create the sub directories
2016-07-13 11:44:48 +02:00
Werner Koch
38eb5f81d2
wks: Add --cron command to gpg-wks-server.
* tools/gpg-wks-server.c (PENDING_TTL): New.
(expire_one_domain, expire_pending_confirmations): New.
(command_cron): New.
(main): Implement --cron.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-12 20:18:22 +02:00
Werner Koch
5de41c4ece
wks: Try to send an encrypted confirmation back.
* tools/gpg-wks-client.c (encrypt_response_status_cb): New.
(encrypt_response): New.
(send_confirmation_response): Encrypt the response.

* tools/gpg-wks-server.c (send_confirmation_request): Use freeing of
BODY and BODYENC.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-12 18:18:19 +02:00
Werner Koch
d3837e0435
wks: Also create DANE record.
* tools/gpg-wks-server.c (copy_key_as_dane): New.
(check_and_publish): Also publish as DANE record.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-12 16:59:20 +02:00
Werner Koch
7732b33288
gpgconf: Enhance --list-dirs.
* tools/gpgconf.c (main) <aListDir>: Factor code out to ...
(list_dirs): new.  Rewrite to use a table.  Allow selection of a
items.  Add "agent-ssh-socket".
--

This change makes the use of gpgconf in scripts easier.  For example,
to set the envvar with the name of the socket used by ssh, it is now
possible to do this:

  SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"

which guarantees that the right name is used.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-11 13:06:48 +02:00
Werner Koch
e5896da666
wks: Let the server take the encrytion key from the file.
* tools/gpg-wks-server.c (encrypt_stream): Change arg 'fingerprint' to
'keyfile'.
(store_key_as_pending): Add arg 'r_fname' to make of the keyfile.
(send_confirmation_request): Add arg 'keyfile'.
(process_new_key): Pass on the name of the keyfile.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-06 15:50:57 +02:00
Justus Winter
0b8a335879 tools/gpgtar: Provide --create and --extract.
* tools/gpgtar.c (cmd_and_opt_values): New values.
(opts): New actions.
(parse_arguments): Handle new actions.
* tests/openpgp/gpgtar.scm: Test new interface.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-05 15:18:30 +02:00
Werner Koch
8c8ae043b8
wks: Add command --read to gpg-wks-client.
* tools/gpg-wks-client.c (aRead): New.
(opts): Add command "--read".
(main): Implement that.
--

This command allows to process alread decrypted Web Key Service
messages.  It can for example be used in /etc/mailcap

--8<---------------cut here---------------start------------->8---
application/vnd.gnupg.wks; gpg-wks-client -v --read --send;\
      needsterminal; description=Web Key Service message
--8<---------------cut here---------------end--------------->8---

to allow Mutt to process confirmation requests.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-04 11:29:12 +02:00
Werner Koch
1bfed0bbc5
wks: Let the client only export the requested UID.
* tools/gpg-wks-client.c (get_key): Export only the requested uid.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-03 10:27:39 +02:00
Werner Koch
7705f310f1
tools: Call sendmail directly from the wks tools.
* tools/send-mail.c, tools/send-mail.h: New.
* tools/wks-util.c: New.
* tools/Makefile.am (gpg_wks_server_SOURCES): Add them.
(gpg_wks_client_SOURCES): Ditto.
* tools/gpg-wks.h (opt): Add fields use_sendmail and output.
* tools/gpg-wks-client.c: Add options --send and --output.  Rename
command --send to --create.
(command_send, send_confirmation_response): Output via wks_send_mime.
* tools/gpg-wks-server.c:  Add options --send and --output.
(send_confirmation_request): Output via wks_send_mime.
(check_and_publish): Add hack for name-value bug.
--

With this code, a dedicated user on the server along with a procmail
script, it was possible to run a basic test.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-03 00:41:30 +02:00
Werner Koch
c619035d9c
tools: Add options to gpg-wks-server.
* tools/gpg-wks.h (opt): Add 'default_from' and 'extra_headers'.
* tools/gpg-wks-server.c (oFrom, oHeader): New.
(parse_arguments): Set them and check args.
(get_submission_address): New.
(send_confirmation_request): Set correct From address.  Add extra
headers.
(process_new_key): Return an error code.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-02 18:59:22 +02:00
Werner Koch
0e36a1d1fb
tools: Extend mime-maker.c:mime_maker_add_header.
* tools/mime-maker.c (add_header): Check header name and allow
name-value syntax.
(mime_maker_add_header): Add mode for a syntax check.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-02 18:55:22 +02:00
Justus Winter
cff63da930 tools/gpgtar: Annotate semi-static allocation.
* tools/gpgtar.c (shell_parse_argv): Annotate argument vector as
leaked.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-01 14:16:05 +02:00
Justus Winter
8f39185d7b tools: Fix trivial memory leak.
* tools/gpg-connect-agent.c (main): Fix trivial memory leak.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-30 18:50:16 +02:00
Werner Koch
5d6c83deaa
tools: Add gpg-wks-client and gpg-wks-server.
* configure.ac: Add option --enable-wks-tools
* tools/gpg-wks-client.c: New.
* tools/gpg-wks-server.c: New.
* tools/gpg-wks.h: new.
* tools/wks-receive.c: New.
* tools/call-dirmngr.c, tools/call-dirmngr.h: New.
--

Note that this is just a starting point and not a finished
implementation.  Here is how to test the system using
foo@test.gnupg.org as example.

Prepare:

  mkdir /var/lib/gnupg/wks
  chmod o-rwx /var/lib/gnupg/wks
  mkdir /var/lib/gnupg/wks/test.gnupg.org

Run the protocol:

  ./gpg-wks-client -v  --send FPR USERID >x
  ./gpg-wks-server -v --receive  <x >y
  ./gpg-wks-client --receive <y >z
  ./gpg-wks-server -v --receive  <z

You should also setup a cron job to rsync
/var/lib/gnupg/wks/test.gnupg.org/hu/* to the webserver.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-29 12:04:11 +02:00
Werner Koch
c334fa8df0
tools: Add modules for MIME parsing and creating.
* tools/mime-maker.c: New.
* tools/mime-maker.h: New.
* tools/mime-parser.c: New.
* tools/mime-parser.h: New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-29 12:04:11 +02:00
Justus Winter
4819f687c4 tools/gpgtar: Fix handling of '-'.
* tools/gpgtar-extract.c (gpgtar_extract): Use stdin if file is '-'.
* tools/gpgtar-list.c (gpgtar_list): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-28 15:03:07 +02:00
Werner Koch
4d7d292cd5
Add missing files so that make distcheck works again,
* tests/openpgp/Makefile.am (CLEANFILES): Add created file
"passphrases".
* tools/Makefile.am (EXTRA_DIST): Add no-libgcrypt.c.
--

dirmngr/Makefile uses a copy no-libgcrypt.c from tools/.  tools/ does
not anymore require no-libgcrypt.c but we keep it there in case we
eventually make use of it again.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-16 16:56:42 +02:00
Werner Koch
e44dd878df
tools: Fix typo in function name of symcryptrun.
* tools/symcryptrun.c (main): Fix typo.
--

Fixes-commit: 36550dde99
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-16 11:25:20 +02:00
Werner Koch
cf4910419e
gpgconf: New commands --create-socketdir and --remove-socketdir.
* tools/gpgconf.c: Include unistd.h.
(aCreateSocketDir, aRemoveSocketDir): New.
(opts): Add --create-socketdir and --remove-socketdir.
(main): Implement them.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-08 14:04:47 +02:00
Werner Koch
aab8a0b052
Implement /run/user/UID/gnupg based sockets.
* common/homedir.c: Include sys/stat.h and zb32.h.
(w32_portable_app, w32_bin_is_bin): Change type from int to byte.
(non_default_homedir): New.
(is_gnupg_default_homedir): New.
(default_homedir): Set non_default_homedir.
(gnupg_set_homedir): Set non_default_homedir and make
the_gnupg_homedir and absolute directory name.
(gnupg_homedir): Return an absolute directory name.
(_gnupg_socketdir_internal): New.
(gnupg_socketdir): Implement /run/user/ based sockets.
* tools/gpg-connect-agent.c (get_var_ext): Replace now obsolete
make_filename by xstrdup.
* tools/gpgconf.c (main): Sue gnupg_homedir for the "homedir:" output.
--

If a [/var]/run/user/$(id -u)/ directory exists, a gnupg subdir is
created as needed and the permissions of the directories are checked.
If that all matches that directory name is returned instead of the
homedir.

To cope with non standard homedirs (via GNUPGHOME or --homedir) the
SHA-1 hash of the homedir is computed, left truncated to 120 bits,
zBase-32 encoded, prefixed with "d.", and appended to
"[/var]/run/user/$(id -u)/gnupg/".  If that directory exists and has
proper permissions it is returned as socket dir - if not the homedir
is used.  Due to cleanup issues, this directory will not be
auto-created but needs to be created by the user in advance.

The required permissions are: directory owned by the user, group and
others bits not set.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-08 13:59:28 +02:00
Werner Koch
def512eb67
gpgconf: Add option --homedir
* tools/gpgconf.c (opts): Add --homedir.
(main): Set homedir.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-08 09:54:09 +02:00