- revert a previous vc_add_dlimit() when vc_set_dlimit() fails
[util-vserver.git] / util-vserver / src / secure-mount.c
index 37baa3c..4e35a32 100644 (file)
@@ -54,6 +54,7 @@
 #include <signal.h>
 
 #define ENSC_WRAPPERS_FCNTL    1
+#define ENSC_WRAPPERS_UNISTD   1
 #include <wrappers.h>
 
 #define MNTPOINT       "/etc"
@@ -406,9 +407,12 @@ mountSingle(struct MountInfo const *mnt, struct Options const *opt)
     return false;
 
   if (mnt->flag & (MS_BIND|MS_MOVE)) {
+    unsigned long      flag = mnt->flag;
+    if ((flag & MS_NODEV)==0) flag |= MS_NODEV;
+    
     if (mount(mnt->src, ".",
              mnt->type ? mnt->type : "",
-             mnt->flag,  mnt->data)==-1) {
+             flag,  mnt->data)==-1) {
       perror("secure-mount: mount()");
       return false;
     }
@@ -490,12 +494,14 @@ static enum {prDOIT, prFAIL, prIGNORE}
   info->data = buf;
   MOVE_TO_NEXT_FIELD(buf, true);
 
-  if (strcmp(info->type, "swap")==0) return prIGNORE;
-  if (strcmp(info->type, "none")==0) info->type = 0;
-
   info->flag  = MS_NODEV;
   info->mask  = 0;
   info->xflag = 0;
+
+  if      (strcmp(info->type, "swap")  ==0) return prIGNORE;
+  else if (strcmp(info->type, "none")  ==0) info->type  = 0;
+  else if (strcmp(info->type, "devpts")==0) info->mask |= MS_NODEV;
+
   if (col) *col = err_col;
   if (!transformOptionList(info,col)) return prFAIL;
   if (info->xflag & XFLAG_NOAUTO)     return prIGNORE;
@@ -515,7 +521,7 @@ showFstabPosition(int fd, char const *fname, size_t line_nr, size_t col_nr)
   buf[len++] = ':';
   len += utilvserver_fmt_uint(buf+len, col_nr);
   WRITE_STR(fd, fname);
-  write(fd, buf, len);
+  Vwrite(fd, buf, len);
 }
 
 
@@ -567,7 +573,7 @@ mountFstab(struct Options const *opt)
        case prIGNORE   :  break;
        case prDOIT     : {
          bool          is_rootfs = (strcmp(mnt.dst, "/")==0);
-         chdir("/");
+         Echdir("/");
          if (( is_rootfs && opt->rootfs==rfsNO) ||
              (!is_rootfs && opt->rootfs==rfsONLY)) { /* ignore the entry */ }
          else if (!mountSingle(&mnt, opt)) {