Make sure the configuration directory exists and that it's usable
[util-vserver.git] / python / vserver.py
index e27f6bb..93a22a2 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 2005 Princeton University
 
-#$Id: vserver.py,v 1.65 2007/07/31 14:36:19 dhozac Exp $
+#$Id: vserver.py,v 1.68 2007/07/31 22:04:24 dhozac Exp $
 
 import errno
 import fcntl
@@ -61,6 +61,9 @@ class VServerConfig:
     def __init__(self, name, directory):
         self.name = name
         self.dir = directory
+        if not (os.path.isdir(self.dir) and
+                os.access(self.dir, os.R_OK | os.W_OK | os.X_OK):
+            raise NoSuchVServer, "%s does not exist" % self.dir
 
     def get(self, option, default = None):
         try:
@@ -405,11 +408,6 @@ class VServer:
                 state_file = open("/var/run/vservers/%s" % self.name, "w")
 
                 # use /dev/null for stdin, /var/log/boot.log for stdout/err
-                try:
-                    os.close(0)
-                    os.close(1)
-                except:
-                    pass
                 fd = os.open("/dev/null", os.O_RDONLY)
                 if fd != 0:
                     os.dup2(fd, 0)
@@ -436,7 +434,7 @@ class VServer:
                          cmd_args = [cmd[0]] + map(lambda x: x % arg_subst,
                                                    cmd[1:])
                          print >>log, "executing '%s'" % " ".join(cmd_args)
-                         os.spawnvp(os.P_WAIT,cmd[0],*cmd_args)
+                         os.spawnvp(os.P_WAIT,cmd[0],cmd_args)
                      except:
                          traceback.print_exc()
                          os._exit(1)