2.23-0.2: libmount fixes

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2013-03-27 10:53:32 +01:00
parent 27a5499f1e
commit 4788cbd6e7
3 changed files with 129 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 17206c059dc2e42e7081079b76eafda68cc9a5b8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 26 Mar 2013 16:05:07 +0100
Subject: [PATCH] libmount: fix user-mount by root for mount.<type> helpers
Append options like "exec" "suid" and "dev" to mount.<type> helpers
command line if the options are in fstab. This is relevant for root
user who calls mount(8) for fstab entries with "user,exec" etc.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/context_mount.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index 00738b4..3b280ab 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -275,6 +275,28 @@ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
if (!*optstr)
return -ENOMEM;
+ if (cxt->user_mountflags & MNT_MS_USER) {
+ /*
+ * This is unnecessary for real user-mounts as mount.<type>
+ * helpers have to always follow fstab rather than mount
+ * options on command line.
+ *
+ * But if you call mount.<type> as root then the helper follows
+ * command line. If there is (for example) "user,exec" in fstab
+ * then we have to manually append the "exec" back to the options
+ * string, bacause there is nothing like MS_EXEC (we have only
+ * MS_NOEXEC in mount flags and we don't care about the original
+ * mount string in libmount for VFS options).
+ */
+ if (!(cxt->mountflags & MS_NOEXEC))
+ mnt_optstr_append_option(optstr, "exec", NULL);
+ if (!(cxt->mountflags & MS_NOSUID))
+ mnt_optstr_append_option(optstr, "suid", NULL);
+ if (!(cxt->mountflags & MS_NODEV))
+ mnt_optstr_append_option(optstr, "dev", NULL);
+ }
+
+
if (cxt->flags & MNT_FL_SAVED_USER)
rc = mnt_optstr_set_option(optstr, "user", cxt->orig_user);
if (rc)
--
1.8.1.4

View File

@ -0,0 +1,69 @@
From 52a285bf4e8d3a78d7211694977f5894a748bdac Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 25 Mar 2013 09:17:52 +0100
Subject: [PATCH] libmount: umount crashes when trying to umount a
non-mountpoint
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reported-by: Mantas Mikulėnas <grawity@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/context_umount.c | 4 ++--
libmount/src/fs.c | 3 +++
libmount/src/libmount.h.in | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c
index 113c53e..96ae87a 100644
--- a/libmount/src/context_umount.c
+++ b/libmount/src/context_umount.c
@@ -183,7 +183,7 @@ err:
static int lookup_umount_fs(struct libmnt_context *cxt)
{
const char *tgt;
- struct libmnt_fs *fs;
+ struct libmnt_fs *fs = NULL;
int rc;
assert(cxt);
@@ -198,7 +198,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
rc = mnt_context_find_umount_fs(cxt, tgt, &fs);
if (rc < 0)
return rc;
- if (!fs) {
+ if (rc == 1 || !fs) {
DBG(CXT, mnt_debug_h(cxt, "umount: cannot find %s in mtab", tgt));
return 0;
}
diff --git a/libmount/src/fs.c b/libmount/src/fs.c
index 96c13d3..bb9006d 100644
--- a/libmount/src/fs.c
+++ b/libmount/src/fs.c
@@ -129,6 +129,9 @@ struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest,
{
const struct libmnt_fs *org = dest;
+ if (!src)
+ return NULL;
+
if (!dest) {
dest = mnt_new_fs();
if (!dest)
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in
index ccd260d..bb18ba1 100644
--- a/libmount/src/libmount.h.in
+++ b/libmount/src/libmount.h.in
@@ -318,7 +318,7 @@ extern void mnt_reset_fs(struct libmnt_fs *fs)
__ul_attribute__((nonnull));
extern struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest,
const struct libmnt_fs *src)
- __ul_attribute__((nonnull(2), warn_unused_result));
+ __ul_attribute__((warn_unused_result));
extern void *mnt_fs_get_userdata(struct libmnt_fs *fs)
__ul_attribute__((nonnull));
extern int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data);
--
1.8.1.4

View File

@ -2,7 +2,7 @@
Summary: A collection of basic system utilities Summary: A collection of basic system utilities
Name: util-linux Name: util-linux
Version: 2.23 Version: 2.23
Release: 0.1%{?dist} Release: 0.2%{?dist}
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
Group: System Environment/Base Group: System Environment/Base
URL: http://en.wikipedia.org/wiki/Util-linux URL: http://en.wikipedia.org/wiki/Util-linux
@ -86,6 +86,12 @@ Patch2: util-linux-2.19-floppy-generic.patch
# 151635 - makeing /var/log/lastlog # 151635 - makeing /var/log/lastlog
Patch3: util-linux-ng-2.22-login-lastlog.patch Patch3: util-linux-ng-2.22-login-lastlog.patch
### Upstream patches for v2.23-rc2
###
Patch100: 0001-libmount-fix-user-mount-by-root-for-mount.-type-help.patch
Patch101: 0001-libmount-umount-crashes-when-trying-to-umount-a-non-.patch
%description %description
The util-linux package contains a large variety of low-level system The util-linux package contains a large variety of low-level system
utilities that are necessary for a Linux system to function. Among utilities that are necessary for a Linux system to function. Among
@ -745,6 +751,9 @@ fi
%{_libdir}/pkgconfig/uuid.pc %{_libdir}/pkgconfig/uuid.pc
%changelog %changelog
* Wed Mar 27 2013 Karel Zak <kzak@redhat.com> 2.23-0.2
- add upstream patches for to fix umount and mount.<type>
* Fri Mar 22 2013 Karel Zak <kzak@redhat.com> 2.23-0.1 * Fri Mar 22 2013 Karel Zak <kzak@redhat.com> 2.23-0.1
- upgrade to the release 2.22-rc1 - upgrade to the release 2.22-rc1
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.23/v2.23-ReleaseNotes ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.23/v2.23-ReleaseNotes