setrunlevel takes a filename and a runlevel.
[util-vserver-pl.git] / python / vserver.py
index 24b4560..590ec1b 100644 (file)
@@ -245,7 +245,6 @@ class VServer:
         return None
 
     def __do_chroot(self):
-        self.config.cache_it()
         os.chroot(self.dir)
         os.chdir("/")
 
@@ -392,9 +391,7 @@ class VServer:
                 os.unlink(f)
 
         # set the initial runlevel
-        f = open(RUNDIR + "/utmp", "w")
-        vserverimpl.setrunlevel(f, runlevel)
-        f.close()
+        vserverimpl.setrunlevel(RUNDIR + "/utmp", runlevel)
 
         # mount /proc and /dev/pts
         self.__do_mount("none", self.dir, "/proc", "proc")
@@ -412,6 +409,7 @@ class VServer:
             raise ex
 
     def enter(self):
+        self.config.cache_it()
         self.__do_chroot()
         self.__do_chcontext(None)
 
@@ -434,6 +432,7 @@ class VServer:
                 if fd != 0:
                     os.dup2(fd, 0)
                     os.close(fd)
+                self.config.cache_it()
                 self.__do_chroot()
                 log = open("/var/log/boot.log", "w", 0)
                 if log.fileno() != 1: