X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fsecure-mount.c;h=3ef6edf20b5a5035763d6fd3653c57866c267482;hb=e49854bb7ba6166ef48c925e75e0afec2c45e7ba;hp=a722f1fc637d7c75d03e30d69b17e44a7820f937;hpb=3a3702c1e9d56814fd40646745cdecbd3062fe23;p=util-vserver.git diff --git a/src/secure-mount.c b/src/secure-mount.c index a722f1f..3ef6edf 100644 --- a/src/secure-mount.c +++ b/src/secure-mount.c @@ -153,6 +153,11 @@ static struct FstabOption { { "noauto", 0, 0, XFLAG_NOAUTO, false }, { "user", 0, 0, 0, false }, { "nouser", 0, 0, 0, false }, + { "rec", MS_REC, MS_REC, 0, false }, + { "unbindable", MS_UNBINDABLE, MS_UNBINDABLE, 0, false }, + { "private", MS_PRIVATE, MS_PRIVATE, 0, false }, + { "slave", MS_SLAVE, MS_SLAVE, 0, false }, + { "shared", MS_SHARED, MS_SHARED, 0, false }, }; int wrapper_exit_code = 1; @@ -279,8 +284,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; } @@ -413,6 +418,8 @@ canHandleInternal(struct MountInfo const *mnt) if (!mnt) return false; else if ((mnt->flag & (MS_BIND|MS_MOVE))) return true; + else if ((mnt->flag & (MS_SHARED|MS_SLAVE|MS_PRIVATE| + MS_UNBINDABLE))) return true; else if (mnt->type==0) return false; for (i=FS+0; *i!=0; ++i) @@ -436,6 +443,19 @@ 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_REMOUNT), NULL) == -1 && + errno != EBUSY) { /* Returned on older kernels */ + perror("secure-mount: mount()"); + return false; + } + } } else if (!callExternalMount(mnt)) return false;