[lxc-devel] [PATCH 1/1] don't fail lxc-init if we couldn't mount proc
Serge Hallyn
serge.hallyn at ubuntu.com
Fri Nov 22 21:45:40 UTC 2013
In general proc gets mounted ahead of time, so init shouldn't
have to do it. Without this patch, you cannot
lxc-execute -n x1 -s lxc.cap.drop=sys_admin /bin/bash
(See https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1253669 for
a bug about this)
Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
src/lxc/lxc_init.c | 3 +--
src/lxc/utils.c | 8 +++-----
src/lxc/utils.h | 2 +-
3 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c
index 69ae3d8..968c25d 100644
--- a/src/lxc/lxc_init.c
+++ b/src/lxc/lxc_init.c
@@ -154,8 +154,7 @@ int main(int argc, char *argv[])
sigaction(i, &act, NULL);
}
- if (lxc_setup_fs())
- exit(EXIT_FAILURE);
+ lxc_setup_fs();
if (lxc_caps_reset())
exit(EXIT_FAILURE);
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index e80a782..5bfe9db 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -150,10 +150,10 @@ static int mount_fs(const char *source, const char *target, const char *type)
return 0;
}
-extern int lxc_setup_fs(void)
+extern void lxc_setup_fs(void)
{
if (mount_fs("proc", "/proc", "proc"))
- return -1;
+ INFO("failed to remount proc");
/* if we can't mount /dev/shm, continue anyway */
if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
@@ -163,14 +163,12 @@ extern int lxc_setup_fs(void)
/* Sure, but it's read-only per config :) */
if (access("/dev/mqueue", F_OK) && mkdir("/dev/mqueue", 0666)) {
DEBUG("failed to create '/dev/mqueue'");
- return 0;
+ return;
}
/* continue even without posix message queue support */
if (mount_fs("mqueue", "/dev/mqueue", "mqueue"))
INFO("failed to mount /dev/mqueue");
-
- return 0;
}
/* borrowed from iproute2 */
diff --git a/src/lxc/utils.h b/src/lxc/utils.h
index 9c47560..714e74c 100644
--- a/src/lxc/utils.h
+++ b/src/lxc/utils.h
@@ -34,7 +34,7 @@
/* returns 1 on success, 0 if there were any failures */
extern int lxc_rmdir_onedev(char *path);
-extern int lxc_setup_fs(void);
+extern void lxc_setup_fs(void);
extern int get_u16(unsigned short *val, const char *arg, int base);
extern int mkdir_p(const char *dir, mode_t mode);
extern void remove_trailing_slashes(char *p);
--
1.8.3.2
More information about the lxc-devel
mailing list