summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arg.c3
-rw-r--r--src/dopt.c4
-rw-r--r--src/dopt.h1
-rw-r--r--src/serve.c26
4 files changed, 27 insertions, 7 deletions
diff --git a/src/arg.c b/src/arg.c
index 6ca5130..ec20097 100644
--- a/src/arg.c
+++ b/src/arg.c
@@ -199,9 +199,6 @@ int dcc_scan_args(char *argv[], char **input_file, char **output_file,
rs_trace("%s must be local", a);
return EXIT_DISTCC_FAILED;
}
- } else if (str_startswith("-specs=", a)) {
- rs_trace("%s must be local", a);
- return EXIT_DISTCC_FAILED;
} else if (!strcmp(a, "-S")) {
seen_opt_s = 1;
} else if (!strcmp(a, "-fprofile-arcs")
diff --git a/src/dopt.c b/src/dopt.c
index 71e5ae7..67c2cc2 100644
--- a/src/dopt.c
+++ b/src/dopt.c
@@ -114,6 +114,8 @@ int opt_lifetime = 0;
const char *arg_pid_file = NULL;
const char *arg_log_file = NULL;
+const char *arg_sysroot = NULL;
+
int opt_job_lifetime = 0;
/* Enumeration values for options that don't have single-letter name. These
@@ -181,6 +183,7 @@ const struct poptOption options[] = {
#endif
{ "make-me-a-botnet", 0, POPT_ARG_NONE, &opt_enable_tcp_insecure, 0, 0, 0 },
{ "enable-tcp-insecure", 0, POPT_ARG_NONE, &opt_enable_tcp_insecure, 0, 0, 0 },
+ { "sysroot", 0, POPT_ARG_STRING, &arg_sysroot, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0 }
};
@@ -214,6 +217,7 @@ static void distccd_show_usage(void)
" --blacklist=FILE control client access through a blacklist\n"
" --whitelist=FILE control client access through a whitelist\n"
#endif
+" --sysroot=DIR search resource file in this directory\n"
" --stats enable statistics reporting via HTTP server\n"
" --stats-port PORT TCP port to listen on for statistics requests\n"
#ifdef HAVE_AVAHI
diff --git a/src/dopt.h b/src/dopt.h
index 139167b..178dc5a 100644
--- a/src/dopt.h
+++ b/src/dopt.h
@@ -45,6 +45,7 @@ extern int opt_log_stderr;
extern int opt_lifetime;
extern char *opt_listen_addr;
extern int opt_niceness;
+extern const char *arg_sysroot;
#ifdef HAVE_LINUX
extern int opt_oom_score_adj;
diff --git a/src/serve.c b/src/serve.c
index 7dd4647..e3a3b75 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -70,6 +70,8 @@
#include <sys/socket.h>
#include <sys/time.h>
+#include <alloca.h>
+
#include "distcc.h"
#include "trace.h"
#include "util.h"
@@ -768,11 +770,27 @@ static int dcc_run_job(int in_fd,
on securing https://godbolt.org/ */
char *a;
int i;
- for (i = 0; (a = argv[i]); i++)
- if (strncmp(a, "-fplugin=", strlen("-fplugin=")) == 0 ||
- strncmp(a, "-specs=", strlen("-specs=")) == 0) {
- rs_log_warning("-fplugin= and/or -specs= passed, which are insecure and not supported.");
+ for (i = 0; (a = argv[i]); i++) {
+ if (strncmp(a, "-fplugin=", strlen("-fplugin=")) == 0) {
+ rs_log_warning("-fplugin= passed, which are insecure and not supported.");
goto out_cleanup;
+ }
+ if (strncmp(a, "-specs=", strlen("-specs=")) == 0) {
+ int fail = 1;
+ if (arg_sysroot) {
+ char *spec_file = strchr(a, '=') + 1;
+ char *spec_path = alloca(strlen(spec_file) + strlen(arg_sysroot) + 8);
+ sprintf(spec_path, "%s/%s", arg_sysroot, spec_file);
+ struct stat spec_stat;
+ if (stat(spec_path, &spec_stat) != -1 && (spec_stat.st_mode & S_IFMT) == S_IFREG) {
+ fail = 0;
+ }
+ }
+ if (fail) {
+ rs_log_warning("-specs= passed, but we cannot find the specs.");
+ goto out_cleanup;
+ }
+ }
}
if ((compile_ret = dcc_spawn_child(argv, &cc_pid,