[libglnx] libcontainer: Fall back to noop if / is not a mountpoint
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx] libcontainer: Fall back to noop if / is not a mountpoint
- Date: Tue, 28 Jul 2015 20:42:56 +0000 (UTC)
commit 58a9a5c50ebd8415162251ce9235835dca3f6a37
Author: Colin Walters <walters verbum org>
Date: Tue Jul 28 16:40:29 2015 -0400
libcontainer: Fall back to noop if / is not a mountpoint
Trying to change the mount namespace was breaking in mock, which just
uses plain chroot.
glnx-libcontainer.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/glnx-libcontainer.c b/glnx-libcontainer.c
index 49fa095..3f50007 100644
--- a/glnx-libcontainer.c
+++ b/glnx-libcontainer.c
@@ -212,10 +212,24 @@ glnx_libcontainer_run_in_root (const char *dest,
if (container_available)
{
if (mount (NULL, "/", "none", MS_PRIVATE | MS_REC, NULL) != 0)
- _perror_fatal ("mount: ");
+ {
+ if (errno == EINVAL)
+ {
+ /* Ok, we may be inside a mock chroot or the like. In
+ * that case, let's just fall back to not
+ * containerizing.
+ */
+ container_available = FALSE;
+ }
+ else
+ _perror_fatal ("mount: ");
+ }
- if (mount (NULL, "/", "none", MS_PRIVATE | MS_REMOUNT | MS_NOSUID, NULL) != 0)
- _perror_fatal ("mount (MS_NOSUID): ");
+ if (container_available)
+ {
+ if (mount (NULL, "/", "none", MS_PRIVATE | MS_REMOUNT | MS_NOSUID, NULL) != 0)
+ _perror_fatal ("mount (MS_NOSUID): ");
+ }
}
if (chdir (dest) != 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]