-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsuexec.patch
59 lines (56 loc) · 1.57 KB
/
suexec.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
diff -rupN apache2-2.2.9_orig/support/suexec.c apache2-2.2.9/support/suexec.c
--- apache2-2.2.9_orig/support/suexec.c 2010-01-31 20:28:51.000000000 +0300
+++ apache2-2.2.9/support/suexec.c 2010-01-31 20:34:10.000000000 +0300
@@ -439,14 +439,34 @@ int main(int argc, char *argv[])
actual_uname = strdup(pw->pw_name);
target_homedir = strdup(pw->pw_dir);
+ /* patch start */
+
+ char cgroup_path[128];
+ sprintf(cgroup_path, "/mnt/cgroup/%s/tasks", actual_gname);
+
+
/*
* Log the transaction here to be sure we have an open log
* before we setuid().
*/
+
+ /* old version
log_no_err("uid: (%s/%s) gid: (%s/%s) cmd: %s\n",
target_uname, actual_uname,
target_gname, actual_gname,
cmd);
+ */
+
+ /* patched version */
+ log_no_err("pid: %d uid: (%s/%s) gid: (%s/%s) cmd: %s cgroup_path: %s\n",
+ getpid(),
+ target_uname, actual_uname,
+ target_gname, actual_gname,
+ cmd,
+ cgroup_path
+ );
+
+ /* patch end */
/*
* Error out if attempt is made to execute as root or as
@@ -466,6 +486,20 @@ int main(int argc, char *argv[])
exit(108);
}
+ /* patch start */
+
+ FILE* cgroup_tasks = fopen(cgroup_path, "w");
+
+ if (cgroup_tasks) {
+ fprintf(cgroup_tasks, "%d\n", getpid());
+
+ fclose(cgroup_tasks);
+ } else {
+ log_err("failed to open cgroup %s\n", cgroup_path);
+ }
+
+ /* patch end */
+
/*
* Change UID/GID here so that the following tests work over NFS.
*