Add VCMD_{enter,set}_space_v2 support, in preparation of pivot_root.
[util-vserver.git] / src / secure-mount.c
index a722f1f..6dc2c41 100644 (file)
@@ -279,8 +279,8 @@ updateMtab(struct MountInfo const *mnt, struct Options const *opt)
     goto err0;
   }
 
-  if (flock(fd, LOCK_EX)==-1) {
-    perror("secure-mount: flock()");
+  if (lockf(fd, F_LOCK, 0)==-1) {
+    perror("secure-mount: lockf()");
     goto err1;
   }
 
@@ -436,6 +436,20 @@ mountSingle(struct MountInfo const *mnt, struct Options const *opt)
       perror("secure-mount: mount()");
       return false;
     }
+    if ((mnt->flag & MS_BIND) &&
+       (mnt->flag & ~(MS_BIND|MS_REC))) {
+      /* This is needed to put us in the new mountpoint */
+      if (!secureChdir(mnt->dst, opt))
+       return false;
+      if (mount(mnt->src, ".",
+               mnt->type ? mnt->type : "",
+               ((mnt->flag & ~(MS_BIND|MS_REC)) |
+               MS_REMOUNT), NULL) == -1 &&
+         errno != EBUSY) { /* Returned on older kernels */
+       perror("secure-mount: mount()");
+       return false;
+      }
+    }
   }
   else if (!callExternalMount(mnt))
     return false;