[PATCH 7/9] add a gpg_path value for notmuch_database_t

J. Lewis Muir jlmuir at imca-cat.org
Fri Dec 11 14:35:58 PST 2015


On 12/9/15 9:39 PM, Daniel Kahn Gillmor wrote:
> +static notmuch_bool_t
> +_find_in_path(const char* path)
> +{
> +    char *c = NULL, *save = NULL, *tok;
> +    size_t n;
> +    int dfd = -1;
> +    notmuch_bool_t ret = FALSE;
> +
> +    n = confstr(_CS_PATH, NULL, 0);
> +    c = (char*)talloc_size(NULL, n);
> +    if (!c)
> +	return FALSE;
> +    confstr(_CS_PATH, c, n);
> +
> +    tok = strtok_r(c, ":", &save);
> +    while (tok) {
> +	dfd = open(tok, O_DIRECTORY | O_RDONLY);
> +	if (dfd != -1) {
> +	    if (!faccessat(dfd, path, X_OK, 0)) {
> +		ret = TRUE;
> +		goto done;
> +	    }
> +	    close(dfd);
> +	}
> +	tok = strtok_r(NULL, ":", &save);
> +    }
> +done:
> +    if (dfd != -1)
> +	close(dfd);
> +    if (c)
> +	talloc_free(c);
> +    return ret;
> +}

I guess I still don't get it.  Why even have a _find_in_path function?
Why not just expect the gpg executable path to have already been
specified somehow (e.g. Notmuch configuration file, build-time constant,
or environment variable)?

Regards,

Lewis


More information about the notmuch mailing list