X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsecure-mount.c;h=520a0859c0d90c033b918148f9735ce11279d55d;hb=2822ba293eb308225c50d346930c47bf98d9927b;hp=afab07c41dd5ddca0632087c8ad2cc504d14726d;hpb=2894fc5a4c8335e4d7221311fed0556f33f8047c;p=util-vserver.git diff --git a/src/secure-mount.c b/src/secure-mount.c index afab07c..520a085 100644 --- a/src/secure-mount.c +++ b/src/secure-mount.c @@ -1,4 +1,4 @@ -// $Id: secure-mount.c 2403 2006-11-24 23:06:08Z dhozac $ --*- c++ -*-- +// $Id: secure-mount.c,v 1.24 2005/03/24 12:45:06 ensc Exp $ --*- c++ -*-- // Copyright (C) 2003 Enrico Scholz // @@ -52,7 +52,6 @@ #include #include #include -#include #define ENSC_WRAPPERS_FCNTL 1 #define ENSC_WRAPPERS_UNISTD 1 @@ -399,27 +398,6 @@ secureChdir(char const *dir, struct Options const *opt) return false; } -static bool -canHandleInternal(struct MountInfo const *mnt) -{ - static char const * FS[] = { - "tmpfs", "sysfs", "proc", "sockfs", "pipefs", "futexfs", - "inotifyfs", "devpts", "ext3", "ext2", "ramfs", - "hugetlbfs", "usbfs", "binfmt_misc", - 0 - }; - char const ** i; - - 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; - - return false; -} - static bool mountSingle(struct MountInfo const *mnt, struct Options const *opt) { @@ -428,10 +406,13 @@ mountSingle(struct MountInfo const *mnt, struct Options const *opt) if (!secureChdir(mnt->dst, opt)) return false; - if (canHandleInternal(mnt)) { + 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; } @@ -462,8 +443,6 @@ 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,13 +457,6 @@ 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; @@ -493,7 +465,6 @@ transformOptionList(struct MountInfo *info, size_t UNUSED *col) } while (*ptr!='\0'); - info->data = data; return true; } @@ -529,10 +500,7 @@ static enum {prDOIT, prFAIL, prIGNORE} 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; - info->flag &= ~MS_NODEV; - } + else if (strcmp(info->type, "devpts")==0) info->mask |= MS_NODEV; if (col) *col = err_col; if (!transformOptionList(info,col)) return prFAIL; @@ -656,7 +624,7 @@ int main(int argc, char *argv[]) .src = 0, .dst = 0, .type = 0, - .flag = MS_NODEV, + .flag = 0, .xflag = 0, .data = 0, }; @@ -696,7 +664,7 @@ int main(int argc, char *argv[]) default : WRITE_MSG(2, "Try '"); WRITE_STR(2, argv[0]); - WRITE_MSG(2, " --help' for more information.\n"); + WRITE_MSG(2, " --help\" for more information.\n"); return EXIT_FAILURE; break; }