[PATCH 2/2] CLI: make gpg binary used by libgmime configurable.
Jani Nikula
jani at nikula.org
Sat Mar 7 09:20:12 PST 2015
On Tue, 09 Dec 2014, David Bremner <david at tethera.net> wrote:
> Previously we set up a way for the top level notmuch command to choose
> which gpg binary was invoked by libgmime. In this commit we add the
> (mostly boilplate) code to allow the notmuch-config command to read
> and write this path, and use it in the appropriate struct.
This should probably add the section comment in notmuch_config_open().
For a lot of things we add the default to the config if it isn't there
already. I'm undecided whether this is a good approach in general, and
whether we should push the "gpg" hardcoding to the config code. For the
time being I'm fine with this as it is, and we should probably have a
look at the config code at a later time anyway.
Is "gpg" as a section name too specific? Does this lead to having to add
other sections for crypto/security/privacy stuff if it isn't related to
gpg? *shrug*.
BR,
Jani.
> ---
> notmuch-client.h | 7 +++++++
> notmuch-config.c | 15 +++++++++++++++
> notmuch-reply.c | 2 ++
> notmuch-show.c | 2 ++
> 4 files changed, 26 insertions(+)
>
> diff --git a/notmuch-client.h b/notmuch-client.h
> index c25c4ea..fad81d5 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -279,6 +279,13 @@ notmuch_config_set_database_path (notmuch_config_t *config,
> const char *database_path);
>
> const char *
> +notmuch_config_get_gpg_path (notmuch_config_t *config);
> +
> +void
> +notmuch_config_set_gpg_path (notmuch_config_t *config,
> + const char *gpg_path);
> +
> +const char *
> notmuch_config_get_user_name (notmuch_config_t *config);
>
> void
> diff --git a/notmuch-config.c b/notmuch-config.c
> index a564bca..7aef1b6 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -107,6 +107,7 @@ struct _notmuch_config {
> notmuch_bool_t is_new;
>
> char *database_path;
> + char *gpg_path;
> char *user_name;
> char *user_primary_email;
> const char **user_other_email;
> @@ -690,6 +691,20 @@ notmuch_config_set_search_exclude_tags (notmuch_config_t *config,
> &(config->search_exclude_tags));
> }
>
> +const char *
> +notmuch_config_get_gpg_path (notmuch_config_t *config)
> +{
> + return _config_get (config, &config->gpg_path, "gpg", "path");
> +}
> +
> +void
> +notmuch_config_set_gpg_path (notmuch_config_t *config,
> + const char *gpg_path)
> +{
> + _config_set (config, &config->gpg_path, "gpg", "path", gpg_path);
> +}
> +
> +
> /* Given a configuration item of the form <group>.<key> return the
> * component group and key. If any error occurs, print a message on
> * stderr and return 1. Otherwise, return 0.
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index e18370f..d6d3315 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -822,6 +822,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
> return EXIT_FAILURE;
> }
>
> + params.crypto.gpgpath = notmuch_config_get_gpg_path (config);
> +
> if (notmuch_database_open (notmuch_config_get_database_path (config),
> NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
> return EXIT_FAILURE;
> diff --git a/notmuch-show.c b/notmuch-show.c
> index d292f29..b0d4609 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -1204,6 +1204,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
> return EXIT_FAILURE;
> }
>
> + params.crypto.gpgpath = notmuch_config_get_gpg_path (config);
> +
> if (notmuch_database_open (notmuch_config_get_database_path (config),
> NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
> return EXIT_FAILURE;
> --
> 2.1.3
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list