-
Notifications
You must be signed in to change notification settings - Fork 8
/
systemd-run-shim-user.patch
76 lines (71 loc) · 3.38 KB
/
systemd-run-shim-user.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This patch modifys systemd-run-shim to use systemd --user for starting the
# unit. This works on my local machine but fails on the server, where the
# playground worker itself runs inside a systemd unit. I'm not sure if that has
# to do with it. In any case, that's why this patch is currently not applied.
diff --git a/play-haskell-worker/bwrap-files/systemd-run-shim.c b/play-haskell-worker/bwrap-files/systemd-run-shim.c
index 0915e8b..993fffb 100644
--- a/play-haskell-worker/bwrap-files/systemd-run-shim.c
+++ b/play-haskell-worker/bwrap-files/systemd-run-shim.c
@@ -48,13 +48,13 @@ int main(int argc, char **argv) {
const uid_t parent_uid = getuid();
const uid_t parent_gid = getgid();
- if (parent_uid == 0 || parent_gid == 0) {
- fprintf(stderr,
- "%s must not be run as root, it must be marked setuid root "
- "and run as a normal user.\n",
- argv[0]);
- return 1;
- }
+ // if (parent_uid == 0 || parent_gid == 0) {
+ // fprintf(stderr,
+ // "%s must not be run as root, it must be marked setuid root "
+ // "and run as a normal user.\n",
+ // argv[0]);
+ // return 1;
+ // }
if (argc <= 1) {
fprintf(stderr,
@@ -75,29 +75,30 @@ int main(int argc, char **argv) {
// Note: the allocation size here must be increased if the number of
// arguments to systemd-run increases.
- const size_t num_pre_args = 17;
+ const size_t num_pre_args = 16;
char ** const run_args = malloc((num_pre_args + num_given_args + 1) * sizeof(*run_args));
run_args[0] = xstrdup("systemd-run");
run_args[1] = xstrdup("--description=play-haskell-worker cpuquota");
run_args[2] = xasprintf("--unit=%s", unit_name);
- run_args[3] = xasprintf("--uid=%u", parent_uid);
- run_args[4] = xasprintf("--gid=%u", parent_gid);
- run_args[5] = xstrdup("--pipe");
- run_args[6] = xstrdup("--wait");
- run_args[7] = xstrdup("--collect");
- run_args[8] = xstrdup("--same-dir");
- run_args[9] = xstrdup("--service-type=exec");
- run_args[10] = xasprintf("--setenv=PATH=%s", getenv("PATH"));
- run_args[11] = xstrdup("--quiet");
- run_args[12] = xstrdup("--property=CPUQuota=100%");
+ // run_args[3] = xasprintf("--uid=%u", parent_uid);
+ // run_args[4] = xasprintf("--gid=%u", parent_gid);
+ run_args[3] = xstrdup("--pipe");
+ run_args[4] = xstrdup("--wait");
+ run_args[5] = xstrdup("--collect");
+ run_args[6] = xstrdup("--same-dir");
+ run_args[7] = xstrdup("--service-type=exec");
+ run_args[8] = xasprintf("--setenv=PATH=%s", getenv("PATH"));
+ run_args[9] = xstrdup("--quiet");
+ run_args[10] = xstrdup("--property=CPUQuota=100%");
// Limit memory to 600 MiB. Note that the compiled program gets a 500 MiB memory
// limit via the GHC RTS, so this limit is 1. to constrain GHC itself (including
// any TH code), and 2. as a second-layer defense.
- run_args[13] = xstrdup("--property=MemoryMax=600M");
- run_args[14] = xstrdup("--property=TasksMax=50");
- run_args[15] = xstrdup("--property=LimitCORE=0");
- run_args[16] = xstrdup("--");
+ run_args[11] = xstrdup("--property=MemoryMax=600M");
+ run_args[12] = xstrdup("--property=TasksMax=50");
+ run_args[13] = xstrdup("--property=LimitCORE=0");
+ run_args[14] = xstrdup("--user");
+ run_args[15] = xstrdup("--");
// If more arguments are added above, please modify the run_args allocation above!
for (int i = 0; i < num_given_args; i++) {
run_args[num_pre_args + i] = xstrdup(given_args[i]);