Package: cgmanager / 0.33-2+deb8u2

bind-mount-run-from-host.patch Patch series | download
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
commit 6dcd68be0c6d349f5754deb022761806ceb720ab
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Date:   Fri Feb 13 14:30:09 2015 -0600

    bind-mount /run from host into cgmanager's fs as well
    
    That's so that if host is running sysvinit, /run/cgmanager.pid
    shows up on the host's mounted /run, not the underlying rootfs
    /run/.
    
    Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

Index: cgmanager-0.33/fs.c
===================================================================
--- cgmanager-0.33.orig/fs.c
+++ cgmanager-0.33/fs.c
@@ -864,15 +864,6 @@ static int pivot_into_new_root(void) {
 		return -1;
 	}
 
-	/* create /proc and /run/cgmanager/fs, and move-mount those */
-	for (i = 0; createdirs[i]; i++) {
-		if (mkdir(createdirs[i], 0755) < 0 && errno != EEXIST) {
-			nih_fatal("%s: failed to create %s: %s\n", __func__,
-				createdirs[i], strerror(errno));
-			return -1;
-		}
-	}
-
 	ret = snprintf(path, 100, NEWROOT "/proc");
 	if (ret < 0 || ret > 100)
 		return -1;
@@ -881,6 +872,25 @@ static int pivot_into_new_root(void) {
 			__func__, strerror(errno));
 		return -1;
 	}
+
+	ret = snprintf(path, 100, NEWROOT "/run");
+	if (ret < 0 || ret > 100)
+		return -1;
+	ret = mount("/run", path, NULL, MS_BIND, 0);
+	if (ret < 0) {
+		nih_fatal("%s: failed to move /run into new root: %s",
+			__func__, strerror(errno));
+		return -1;
+	}
+
+	for (i = 0; createdirs[i]; i++) {
+		if (mkdir(createdirs[i], 0755) < 0 && errno != EEXIST) {
+			nih_fatal("%s: failed to create %s : %s\n", __func__,
+				createdirs[i], strerror(errno));
+			return -1;
+		}
+	}
+
 	ret = snprintf(path, 100, NEWROOT "/run/cgmanager/fs");
 	if (ret < 0 || ret > 100)
 		return -1;