Make vsched capable of configuring the new scheduler using a new configuration format...
[util-vserver.git] / src / secure-mount.c
index c3a2b48..db8dd7c 100644 (file)
@@ -52,6 +52,7 @@
 #include <sys/wait.h>
 #include <libgen.h>
 #include <signal.h>
+#include <stdlib.h>
 
 #define ENSC_WRAPPERS_FCNTL    1
 #define ENSC_WRAPPERS_UNISTD   1
@@ -409,9 +410,9 @@ canHandleInternal(struct MountInfo const *mnt)
   };
   char const **                i;
   
-  if (mnt!=0)                                  return false;
-  else if ((mnt->flag & (MS_BIND|MS_MOVE))!=0) return true;
-  else if (mnt->type==0)                       return false;
+  if (!mnt)                                 return false;
+  else if ((mnt->flag & (MS_BIND|MS_MOVE))) return true;
+  else if (mnt->type==0)                    return false;
 
   for (i=FS+0; *i!=0; ++i)
     if (strcmp(mnt->type, *i)==0) return true;
@@ -428,12 +429,9 @@ mountSingle(struct MountInfo const *mnt, struct Options const *opt)
     return false;
 
   if (canHandleInternal(mnt)) {
-    unsigned long      flag = mnt->flag;
-    if ((flag & MS_NODEV)!=0) flag |= MS_NODEV;
-    
     if (mount(mnt->src, ".",
              mnt->type ? mnt->type : "",
-             flag,  mnt->data)==-1) {
+             mnt->flag,  mnt->data)==-1) {
       perror("secure-mount: mount()");
       return false;
     }
@@ -464,6 +462,8 @@ static bool
 transformOptionList(struct MountInfo *info, size_t UNUSED *col)
 {
   char const *                 ptr = info->data;
+  char *                       data = malloc(strlen(info->data));
+  char *                       dst = data;
 
   do {
     char const *               pos = strchr(ptr, ',');
@@ -478,6 +478,13 @@ transformOptionList(struct MountInfo *info, size_t UNUSED *col)
       info->mask  |=  opt->mask;
       info->xflag |=  opt->xflag;
     }
+    else {
+      if (dst != data)
+        *(dst++) = ',';
+      strncpy(dst, ptr, pos-ptr);
+      dst += pos - ptr;
+      *dst = '\0';
+    }
 
     if (*pos!='\0')
       ptr = pos+1;
@@ -486,6 +493,7 @@ transformOptionList(struct MountInfo *info, size_t UNUSED *col)
 
   } while (*ptr!='\0');
 
+  info->data = data;
   return true;
 }
 
@@ -648,7 +656,7 @@ int main(int argc, char *argv[])
     .src         = 0,
     .dst         = 0,
     .type        = 0,
-    .flag        = 0,
+    .flag        = MS_NODEV,
     .xflag      = 0,
     .data        = 0,
   };