Subject: Re: [vserver] readonly root not working (mkdir(): read-only filesystem on vcontext command)
From: Benjamin Sonntag <benjamin@octopuce.fr>
Date: Sun, 20 Mar 2011 23:12:15 +0100
Sun, 20 Mar 2011 23:12:15 +0100
Hi,

(replying off-topic since I was not subscribed when  the topic started (sorry))

We were using read-only (ro) root vserver since 2006 at lautre.net (a french mutualised
hosting non-profit organisation)

All went fine since then, but debian squeeze util-vserver version (0.30.216) now fails
to start vservers having Read-Only "/"

This is because of how pivot root works.

We have a tmpfs on /var/run for obvious reasons, so I propose you move the .oldroot
temporary folder to /var/run (since this
folder is likely to be rw  anyway ;) )


The patch is attached and works perfectly in our infrastructure.

I also told Debian guys about a bug in their packaging ( http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619063
) but that's
irrelevent here ;)

Do you think you will add this patch to your official source code ?


In the meantime, I will try to publish our way of running what Corin Langosch wanted
to do : we are providing exactly this
service since 2006 :)
- mutualised hosting
- wanted to give our users temporary shell providing standard commands (editors, source
code revision softwares, sql
dump/restore, ftp and rsync etc.)
- wanted to do it using temporary-launched read-only vserver with /home mounted to the
home of the user etc.


Thanks guys for this wonderful piece of code :)

Best Regards,

Benjamin Sonntag
Octopuce
Lautre Net




--- util-vserver-0.30.216-pre2864/src/vcontext.c	2011-03-20 22:58:29.000000000 +0100
+++ vcontext.c	2011-03-20 22:58:07.000000000 +0100
@@ -290,7 +290,7 @@
 	  perror(ENSC WRAPPERS PREFIX "unshare(NEWNS)");
 	  return wrapper exit code;
 	}
-	if (mkdir("./.oldroot", 0700) == -1) {
+	if (mkdir("./var/run/.oldroot", 0700) == -1) {
 	  if (errno == EEXIST)
 	    existed = true;
 	  else {
@@ -298,15 +298,15 @@
 	    return wrapper exit code;
 	  }
 	}
-	if (pivot root(".", "./.oldroot") == -1) {
+	if (pivot root(".", "./var/run/.oldroot") == -1) {
 	  perror(ENSC WRAPPERS PREFIX "pivot root()");
 	  return wrapper exit code;
 	}
-	if (umount2("/.oldroot", MNT DETACH) == -1) {
+	if (umount2("/var/run/.oldroot", MNT DETACH) == -1) {
 	  perror(ENSC WRAPPERS PREFIX "umount2()");
 	  return wrapper exit code;
 	}
-	if (!existed && rmdir("/.oldroot") == -1) {
+	if (!existed && rmdir("/var/run/.oldroot") == -1) {
 	  perror(ENSC WRAPPERS PREFIX "rmdir()");
 	  return wrapper exit code;
 	}


["application/pgp-signature" not shown]