diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-11-22 15:48:46 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2016-11-22 15:51:00 +0100 |
| commit | ab3f4a073671a0f36b23988e0ece7adbe476a053 (patch) | |
| tree | b387831f629b1aa68815b24a75e5773393ea7f37 /executor/common.h | |
| parent | 7f3778fa10dc9230a87f618af1e82a5a22f8424c (diff) | |
executor: fix sandbox=setuid
Need to chmod(0777) the work dir before we do setuid(nobody).
Otherwise nobody user won't have rights to use the temp dir.
Diffstat (limited to 'executor/common.h')
| -rw-r--r-- | executor/common.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/executor/common.h b/executor/common.h index 499d0076a..e1b8c9b08 100644 --- a/executor/common.h +++ b/executor/common.h @@ -2,7 +2,9 @@ // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. // This file is shared between executor and csource package. +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include <dirent.h> #include <errno.h> #include <fcntl.h> @@ -240,6 +242,8 @@ static void setup_main_process() char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) fail("failed to mkdtemp"); + if (chmod(tmpdir, 0777)) + fail("failed to chmod"); if (chdir(tmpdir)) fail("failed to chdir"); } @@ -292,8 +296,6 @@ static int do_sandbox_setuid() const int nobody = 65534; if (setgroups(0, NULL)) fail("failed to setgroups"); - // glibc versions do not we want -- they force all threads to setuid. - // We want to preserve the thread above as root. if (syscall(SYS_setresgid, nobody, nobody, nobody)) fail("failed to setresgid"); if (syscall(SYS_setresuid, nobody, nobody, nobody)) |
