unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 5eac3676835371492d1a0be85bb7072d8f60ad07 994 bytes (raw)
name: util/search-path.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
#include "search-path.h"
#include <stdlib.h>
#include <talloc.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


notmuch_bool_t
test_for_executable(const char* exename)
{
    char *c = NULL, *save = NULL, *tok;
    size_t n;
    int dfd = -1;
    notmuch_bool_t ret = FALSE;

    if (strchr(exename, '/')) {
	if (0 == access(exename, X_OK))
	    return TRUE;
	else
	    return FALSE;
    }
    
    c = getenv("PATH");
    if (c)
	c = talloc_strdup(NULL, c);
    else {
	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, exename, 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;
}

debug log:

solving 5eac367 ...
found 5eac367 in https://yhetil.org/notmuch/1454272801-23623-2-git-send-email-dkg@fifthhorseman.net/ ||
	https://yhetil.org/notmuch/1453258369-7366-2-git-send-email-dkg@fifthhorseman.net/

applying [1/1] https://yhetil.org/notmuch/1454272801-23623-2-git-send-email-dkg@fifthhorseman.net/
diff --git a/util/search-path.c b/util/search-path.c
new file mode 100644
index 0000000..5eac367

1:31: trailing whitespace.
    
Checking patch util/search-path.c...
Applied patch util/search-path.c cleanly.
warning: 1 line adds whitespace errors.

skipping https://yhetil.org/notmuch/1453258369-7366-2-git-send-email-dkg@fifthhorseman.net/ for 5eac367
index at:
100644 5eac3676835371492d1a0be85bb7072d8f60ad07	util/search-path.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).