diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Find a compressor on the default path when unset
With no PATH in the environment, the check that a compressor exists
gave up and refused every compressed snapshot, though execvp would have
found it on the system's default path.
Diffstat (limited to '')
| -rw-r--r-- | source/ui-snapshot.c | 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 14 insertions, 2 deletions
diff --git a/source/ui-snapshot.c b/source/ui-snapshot.c index 3c00f66..dae3459 100644 --- a/source/ui-snapshot.c +++ b/source/ui-snapshot.c @@ -67,11 +67,22 @@ static int write_zip_archive(const char *hex, const char *prefix) static int program_on_path(const char *program) { const char *path = getenv("PATH"); + struct strbuf defpath = STRBUF_INIT; struct strbuf full = STRBUF_INIT; int found = 0; - if (!path) - return 0; + // A server can run cgit with no PATH at all, and execvp then searches + // a default path of the system's, which confstr reports. + if (!path) { + size_t len = confstr(_CS_PATH, NULL, 0); + + if (!len) + return 0; + strbuf_grow(&defpath, len); + confstr(_CS_PATH, defpath.buf, len); + strbuf_setlen(&defpath, len - 1); + path = defpath.buf; + } while (!found) { const char *end = strchrnul(path, ':'); @@ -86,6 +97,7 @@ static int program_on_path(const char *program) path = end + 1; } strbuf_release(&full); + strbuf_release(&defpath); return found; } |
