All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH user-cr] remount /proc for new pidns
@ 2009-12-04  2:06 Serge E. Hallyn
       [not found] ` <20091204020610.GA17971-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Serge E. Hallyn @ 2009-12-04  2:06 UTC (permalink / raw)
  To: Oren Laadan; +Cc: Linux Containers

Not doing this can be a pain for restarted software which relies on
proc...

Signed-off-by: root <root-Z+ypJZ3u8cnx6HRWoRZK3AC/G2K4zDHf@public.gmane.org>
---
 restart.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/restart.c b/restart.c
index d25561a..cefe639 100644
--- a/restart.c
+++ b/restart.c
@@ -1005,6 +1005,13 @@ static int ckpt_probe_child(pid_t pid, char *str)
 static int __ckpt_coordinator(void *arg)
 {
 	struct ckpt_ctx *ctx = (struct ckpt_ctx *) arg;
+	int ret;
+
+	ret = mount("proc", "/proc", "proc", 0, NULL);
+	if (ret) {
+		perror("mount -t proc proc /proc");
+		exit(1);
+	}
 
 	if (!ctx->args->wait)
 		close(ctx->pipe_coord[0]);
@@ -1869,6 +1876,13 @@ int ckpt_fork_stub(void *data)
 	struct task *task = (struct task *) data;
 	struct ckpt_ctx *ctx = task->ctx;
 
+	if (task->flags & TASK_NEWPID) {
+		int ret = mount("proc", "/proc", "proc", 0, NULL);
+		if (ret) {
+			perror("mount -t proc");
+			exit(1);
+		}
+	}
 	/*
 	 * In restart into a new pid namespace (--pidns), coordinator
 	 * is the container init, hence if it terminated permatutely
-- 
1.6.4.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH user-cr] remount /proc for new pidns
       [not found] ` <20091204020610.GA17971-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2009-12-10 19:04   ` Serge E. Hallyn
  0 siblings, 0 replies; 2+ messages in thread
From: Serge E. Hallyn @ 2009-12-10 19:04 UTC (permalink / raw)
  To: Oren Laadan; +Cc: Linux Containers

Quoting Serge E. Hallyn (serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org):
> Not doing this can be a pain for restarted software which relies on
> proc...

How embarrassing...  if we don't unshare(CLONE_NEWNS) for pidns we
mess up the proc mount for the whole system...  Pls use this version
instead.

From 57588540937a892a49b692a4630b34d5984a8792 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Date: Thu, 3 Dec 2009 21:40:30 -0600
Subject: [PATCH 1/1] remount /proc for new pidns

Changelog: Dec 10: unshare(CLONE_NEWNS) for --pidns

Signed-off-by: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 restart.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/restart.c b/restart.c
index ddd0a63..6c9ac5d 100644
--- a/restart.c
+++ b/restart.c
@@ -777,6 +777,14 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
+	if (args.pty || args.pidns) {
+		ret = unshare(CLONE_NEWNS);
+		if (ret) {
+			perror("unshare mounts ns (for -pty)");
+			exit(1);
+		}
+	}
+
 	/* private devpts namespace? */
 	if (args.pty) {
 		struct stat ptystat;
@@ -790,11 +798,6 @@ int main(int argc, char *argv[])
 			printf("Error: /dev/ptmx must be a link to /dev/pts/ptmx\n");
 			exit(1);
 		}
-		ret = unshare(CLONE_NEWNS);
-		if (ret) {
-			perror("unshare mounts ns (for -pty)");
-			exit(1);
-		}
 		ret = mount("pts", "/dev/pts", "devpts", 0, "newinstance");
 		if (ret) {
 			perror("mount -t devpts -o newinstance");
@@ -1005,6 +1008,13 @@ static int ckpt_probe_child(pid_t pid, char *str)
 static int __ckpt_coordinator(void *arg)
 {
 	struct ckpt_ctx *ctx = (struct ckpt_ctx *) arg;
+	int ret;
+
+	ret = mount("proc", "/proc", "proc", 0, NULL);
+	if (ret) {
+		perror("mount -t proc proc /proc");
+		exit(1);
+	}
 
 	if (!ctx->args->wait)
 		close(ctx->pipe_coord[0]);
@@ -1869,6 +1879,13 @@ int ckpt_fork_stub(void *data)
 	struct task *task = (struct task *) data;
 	struct ckpt_ctx *ctx = task->ctx;
 
+	if (task->flags & TASK_NEWPID) {
+		int ret = mount("proc", "/proc", "proc", 0, NULL);
+		if (ret) {
+			perror("mount -t proc");
+			exit(1);
+		}
+	}
 	/*
 	 * In restart into a new pid namespace (--pidns), coordinator
 	 * is the container init, hence if it terminated permatutely
-- 
1.6.4.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-10 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-04  2:06 [RFC PATCH user-cr] remount /proc for new pidns Serge E. Hallyn
     [not found] ` <20091204020610.GA17971-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-12-10 19:04   ` Serge E. Hallyn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.