From 28d39b6dd71e6a054aa06c66f683a1e15439e56b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 21 May 2009 13:20:10 +0200 Subject: mount: fix undefined reference to `security_get_initial_context' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Gentoo-hardened stable have: sys-libs/libselinux-1.34.14 > I have: > mount.c:(.text+0x12ce): undefined reference to `security_get_initial_context' Reported-by: Максим Бритов Addresses-Gentoo-Bug: #270168 Signed-off-by: Karel Zak --- mount/mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mount/mount.c') diff --git a/mount/mount.c b/mount/mount.c index f48f9d40..cc5b88ae 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1561,7 +1561,7 @@ mount_retry: out: -#ifdef HAVE_LIBSELINUX +#if defined(HAVE_LIBSELINUX) && defined(HAVE_SECURITY_GET_INITIAL_CONTEXT) if (res != EX_FAIL && verbose && is_selinux_enabled() > 0) { security_context_t raw = NULL, def = NULL; -- cgit v1.2.3 From c4966ccb16868fa748009a826340fac9d1b1ce39 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 10 Jun 2009 00:00:09 +0200 Subject: mount: use "none" fstype for MS_PROPAGATION mounts Reported-by: Al Viro Signed-off-by: Karel Zak --- mount/mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mount/mount.c') diff --git a/mount/mount.c b/mount/mount.c index cc5b88ae..e002ebbb 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -895,7 +895,7 @@ guess_fstype_and_mount(const char *spec, const char *node, const char **types, if (*types && strcasecmp (*types, "auto") == 0) *types = NULL; - if (flags & (MS_BIND | MS_MOVE)) + if (flags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) *types = "none"; if (!*types && !(flags & MS_REMOUNT)) { -- cgit v1.2.3 From 0fae284a7a13d4d2dba7a908e0662a6d9c46f877 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 10 Jun 2009 09:37:43 +0200 Subject: mount: move MS_{PROPAGATION,BIND,MOVE} detection The previous commit does not properly fix the problem with "none" fstype and MS_{PROPAGATION,BIND,MOVE} flags. The real fstype has to be replaced with "none" before we try to use /sbin/mount. helper. Old version: # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw # ./mount -v -v -v --make-private /mnt/test mount: fstab path: "/etc/fstab" mount: mtab path: "/etc/mtab" mount: lock path: "/etc/mtab~" mount: temp path: "/etc/mtab.tmp" mount: UID: 0 mount: eUID: 0 mount: spec: "tmpfs" mount: node: "/mnt/test" mount: types: "tmpfs" mount: opts: "rw" mount: external mount: argv[0] = "/sbin/mount.tmpfs" mount: external mount: argv[1] = "tmpfs" mount: external mount: argv[2] = "/mnt/test" mount: external mount: argv[3] = "-v" mount: external mount: argv[4] = "-o" mount: external mount: argv[5] = "rw" tmpfs on /mnt/test type tmpfs (rw) # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw 17 16 0:20 / /mnt/test rw,relatime - tmpfs tmpfs rw Fixed version: # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw # ./mount -v -v -v --make-private /mnt/test mount: fstab path: "/etc/fstab" mount: mtab path: "/etc/mtab" mount: lock path: "/etc/mtab~" mount: temp path: "/etc/mtab.tmp" mount: UID: 0 mount: eUID: 0 mount: spec: "tmpfs" mount: node: "/mnt/test" mount: types: "tmpfs" mount: opts: "rw" mount: mount(2) syscall: source: "tmpfs", target: "/mnt/test", filesystemtype: "none", mountflags: 262144, data: (null) # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw Signed-off-by: Karel Zak --- mount/mount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mount/mount.c') diff --git a/mount/mount.c b/mount/mount.c index e002ebbb..c636e9dc 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -895,9 +895,6 @@ guess_fstype_and_mount(const char *spec, const char *node, const char **types, if (*types && strcasecmp (*types, "auto") == 0) *types = NULL; - if (flags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) - *types = "none"; - if (!*types && !(flags & MS_REMOUNT)) { *types = guess_fstype_by_devname(spec); if (*types) { @@ -1302,6 +1299,9 @@ try_mount_one (const char *spec0, const char *node0, const char *types0, if (loop) opt_loopdev = loopdev; + if (flags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) + types = "none"; + /* * Call mount.TYPE for types that require a separate mount program. * For the moment these types are ncpfs and smbfs. Maybe also vxfs. -- cgit v1.2.3 From 3bb3fe8cb0233a07919125f5e839cae80fe28a38 Mon Sep 17 00:00:00 2001 From: Valerie Aurora Date: Tue, 14 Jul 2009 13:21:34 -0400 Subject: mount: when a remount to rw fails, quit and return an error A nice feature of mount is that when you attempt to mount a file system read-write, and that fails because it can only be mounted read-only, it goes ahead and retries the mount with the "ro" option and returns success if that succeeds. However, this code path is also followed when you are doing a remount for the sole purpose of changing the mount from read-only to read-write - the change fails, but mount returns success. Instead, check if we are attempting to remount and fail out immediately, instead of retrying with the old "ro" option and whee, happily "succeeding." Signed-off-by: Valerie Aurora (Henson) Signed-off-by: Karel Zak --- mount/mount.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mount/mount.c') diff --git a/mount/mount.c b/mount/mount.c index c636e9dc..ef478c79 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1523,6 +1523,10 @@ mount_retry: error (_("mount: %s%s is write-protected but explicit `-w' flag given"), bd, spec); break; + } else if (flags & MS_REMOUNT) { + error (_("mount: cannot remount %s%s read-write, is write-protected"), + bd, spec); + break; } else { opts = opts0; types = types0; -- cgit v1.2.3