summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR.J.V. Bertin <rjvbertin@gmail.com>2018-05-24 20:40:30 +0200
committerShawn Landden <slandden@gmail.com>2018-06-07 10:06:58 -0700
commit8bfdf1fa8b15c83d65cd8924a56c9886225112ad (patch)
treeb7e0ab55b7f640a1290eb86ff011dcc43687b2f8
parent07c1eaa4c1c9514c7ad4ce8414e9be768fd51c9f (diff)
downloaddistcc-git-8bfdf1fa8b15c83d65cd8924a56c9886225112ad.tar.gz
Fix the QtCreator support and print a more exhaustive workaround message
The original code would trigger the "/bin/" case even on "/usr/bin/foo" and convert it to "bin/foo" which was probably not the intention. The DISTCC_CMDLIST feature provides a better (safer) fallback than the botnet option, so should be mentioned in addition to (or instead of) that option.
-rw-r--r--src/serve.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/serve.c b/src/serve.c
index 71241e9..289c1dd 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -375,13 +375,20 @@ static int dcc_check_compiler_whitelist(char *_compiler_name)
/* Support QtCreator by treating /usr/bin and /bin absolute paths as non-absolute
* see https://github.com/distcc/distcc/issues/279
*/
- if (strstr(_compiler_name, "/bin/"))
- compiler_name = _compiler_name + strlen("/bin/");
- else if (strstr(_compiler_name, "/usr/bin/"))
- compiler_name = _compiler_name + strlen("/usr/bin/");
+ const char *creator_paths[] = { "/bin/", "/usr/bin/", NULL };
+ for (int i = 0 ; creator_paths[i] ; ++i) {
+ size_t len = strlen(creator_paths[i]);
+ // /bin and /usr/bin are absolute paths (= compare from the string start)
+ // use strncasecmp() to support case-insensitive / (= on Mac).
+ if (strncasecmp(_compiler_name, creator_paths[i], len) == 0) {
+ compiler_name = _compiler_name + len;
+ // stop at the first hit
+ break;
+ }
+ }
if (strchr(compiler_name, '/')) {
- rs_log_crit("compiler name <%s> cannot be an absolute path (or must pass --make-me-a-botnet)", _compiler_name);
+ rs_log_crit("compiler name <%s> cannot be an absolute path (or must set DISTCC_CMDLIST or pass --make-me-a-botnet)", _compiler_name);
return EXIT_BAD_ARGUMENTS;
}