summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/c-build.yml1
-rw-r--r--NEWS2
-rw-r--r--doc/web/man/distccd_1.html6
-rw-r--r--man/distccd.13
-rw-r--r--src/arg.c3
-rw-r--r--src/dopt.c4
-rw-r--r--src/dopt.h1
-rw-r--r--src/serve.c26
-rw-r--r--test/testdistcc.py20
9 files changed, 52 insertions, 14 deletions
diff --git a/.github/workflows/c-build.yml b/.github/workflows/c-build.yml
index 99d65b0..4a076b1 100644
--- a/.github/workflows/c-build.yml
+++ b/.github/workflows/c-build.yml
@@ -2,6 +2,7 @@ name: C build
on:
push:
+ pull_request:
jobs:
make_check:
diff --git a/NEWS b/NEWS
index 79e376f..c460cc5 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,8 @@ distcc-3.z 2024-6-10
* (Linux) Added dcc_free_mem reporting of available system memory in the
"stats" output. PR #523 (Whisperity)
+ * Add `sysroot` option and allow the `-specs` option. PR #531 from @wzssyqa.
+
distcc-3.4 "Lax lexer" 2021-4-11
FEATURES:
diff --git a/doc/web/man/distccd_1.html b/doc/web/man/distccd_1.html
index f285d76..865337c 100644
--- a/doc/web/man/distccd_1.html
+++ b/doc/web/man/distccd_1.html
@@ -230,6 +230,12 @@ Save daemon process id to file FILE. (Daemon mode only.)<BR>
If distccd gets executed as root, change to user USER.<BR>
</DD>
<DT>
+<B>--sysroot SYSROOT</B>
+</DT>
+<DD>
+Search resource file in this directory.<BR>
+</DD>
+<DT>
<B>-a, --allow IPADDR[/MASK]</B>
</DT>
<DD>
diff --git a/man/distccd.1 b/man/distccd.1
index 7a29401..586b4e0 100644
--- a/man/distccd.1
+++ b/man/distccd.1
@@ -145,6 +145,9 @@ Save daemon process id to file FILE. (Daemon mode only.)
.B --user USER
If distccd gets executed as root, change to user USER.
.TP
+.B --sysroot SYSROOT
+Search resource file in this directory.
+.TP
.B -a, --allow IPADDR[/MASK]
Instructs distccd to accept connections from the IP address
IPADDR. A CIDR mask length can be supplied optionally after a
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,
diff --git a/test/testdistcc.py b/test/testdistcc.py
index b3c3567..b007d1b 100644
--- a/test/testdistcc.py
+++ b/test/testdistcc.py
@@ -312,6 +312,7 @@ as soon as that happens we can go ahead and start the client."""
SimpleDistCC_Case.setup(self)
self.daemon_pidfile = os.path.join(os.getcwd(), "daemonpid.tmp")
self.daemon_logfile = os.path.join(os.getcwd(), "distccd.log")
+ self.daemon_sysroot = os.getcwd()
self.server_port = DISTCC_TEST_PORT # random.randint(42000, 43000)
self.startDaemon()
self.setupEnv()
@@ -349,11 +350,13 @@ as soon as that happens we can go ahead and start the client."""
"""Return command to start the daemon"""
return (self.distccd() +
"--verbose --lifetime=%d --daemon --log-file %s "
- "--pid-file %s --port %d --allow 127.0.0.1 --enable-tcp-insecure"
+ "--pid-file %s --port %d --allow 127.0.0.1 --enable-tcp-insecure "
+ "--sysroot %s"
% (self.daemon_lifetime(),
_ShellSafe(self.daemon_logfile),
_ShellSafe(self.daemon_pidfile),
- self.server_port))
+ self.server_port,
+ _ShellSafe(self.daemon_sysroot)))
def daemon_lifetime(self):
# Enough for most tests, even on a fairly loaded machine.
@@ -558,7 +561,7 @@ class ScanArgs_Case(SimpleDistCC_Case):
("gcc -xassembler-with-cpp -c foo.c", "local"),
("gcc -x assembler-with-cpp -c foo.c", "local"),
- ("gcc -specs=foo.specs -c foo.c", "local"),
+ ("gcc -specs=foo.specs -c foo.c", "distribute", "foo.c", "foo.o"),
# Fixed in 2.18.4 -- -dr writes rtl to a local file
("gcc -dr -c foo.c", "local"),
@@ -1561,10 +1564,11 @@ class NoDetachDaemon_Case(CompileHello_Case):
# port as an existing server, because we can't catch the error.
cmd = (self.distccd() +
"--no-detach --daemon --verbose --log-file %s --pid-file %s "
- "--port %d --allow 127.0.0.1 --enable-tcp-insecure" %
+ "--port %d --allow 127.0.0.1 --enable-tcp-insecure --sysroot %s" %
(_ShellSafe(self.daemon_logfile),
_ShellSafe(self.daemon_pidfile),
- self.server_port))
+ self.server_port,
+ _ShellSafe(self.daemon_sysroot)))
self.pid = self.runcmd_background(cmd)
self.add_cleanup(self.killDaemon)
# Wait until the server is ready for connections.
@@ -2058,11 +2062,13 @@ class AccessDenied_Case(CompileHello_Case):
def daemon_command(self):
return (self.distccd()
+ "--verbose --lifetime=%d --daemon --log-file %s "
- "--pid-file %s --port %d --allow 127.0.0.2 --enable-tcp-insecure"
+ "--pid-file %s --port %d --allow 127.0.0.2 --enable-tcp-insecure "
+ "--sysroot %s"
% (self.daemon_lifetime(),
_ShellSafe(self.daemon_logfile),
_ShellSafe(self.daemon_pidfile),
- self.server_port))
+ self.server_port,
+ _ShellSafe(self.daemon_sysroot)))
def compileCmd(self):
"""Return command to compile source and run tests"""