3
0
forked from pool/util-linux

Accepting request 125114 from Base:System

- improve error messages from new mount (bnc#767208)
 - backport patches from upstream git:
  - mount-new-add-loopdev-specific-error-message.patch
  - mount-new-use-MNT_ERR-for-error-messages.patch
  - libmount-add-special-MNT_ERR-codes.patch
  - mount-new-improve-error-messages.patch
  - libmount-add-MNT_ERR_LOOPDEV.patch

- fix automount with quota (rh#825836)
  - mount-new-allow-sloppy-for-non-root.patch
- fix wrong mount options for CIFS mounts (bnc#766157)
  - libmount-don-t-use-nosuid-noexec-nodev-for-cifs-user.patch

OBS-URL: https://build.opensuse.org/request/show/125114
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/util-linux?expand=0&rev=149
This commit is contained in:
Stephan Kulow 2012-06-16 05:24:42 +00:00 committed by Git OBS Bridge
commit 322624cbfe
10 changed files with 460 additions and 4 deletions

View File

@ -0,0 +1,59 @@
From 82756a747e4bcfc13a27b7618d889af080649584 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 28 May 2012 12:26:36 +0200
Subject: [PATCH] libmount: add MNT_ERR_LOOPDEV
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
lib/loopdev.c | 4 ++++
libmount/src/context_loopdev.c | 1 +
libmount/src/libmount.h.in | 1 +
3 files changed, 6 insertions(+), 0 deletions(-)
Index: util-linux-2.21.2/lib/loopdev.c
===================================================================
--- util-linux-2.21.2.orig/lib/loopdev.c
+++ util-linux-2.21.2/lib/loopdev.c
@@ -173,6 +173,8 @@ int loopcxt_init(struct loopdev_cxt *lc,
*/
void loopcxt_deinit(struct loopdev_cxt *lc)
{
+ int errsv = errno;
+
if (!lc)
return;
@@ -183,6 +185,8 @@ void loopcxt_deinit(struct loopdev_cxt *
loopcxt_set_device(lc, NULL);
loopcxt_deinit_iterator(lc);
+
+ errno = errsv;
}
/*
Index: util-linux-2.21.2/libmount/src/context_loopdev.c
===================================================================
--- util-linux-2.21.2.orig/libmount/src/context_loopdev.c
+++ util-linux-2.21.2/libmount/src/context_loopdev.c
@@ -261,6 +261,7 @@ int mnt_context_setup_loopdev(struct lib
if (loopdev || rc != -EBUSY) {
DBG(CXT, mnt_debug_h(cxt, "failed to setup device"));
+ rc = -MNT_ERR_LOOPDEV;
goto done;
}
DBG(CXT, mnt_debug_h(cxt, "loopdev stolen...trying again"));
Index: util-linux-2.21.2/libmount/src/libmount.h.in
===================================================================
--- util-linux-2.21.2.orig/libmount/src/libmount.h.in
+++ util-linux-2.21.2/libmount/src/libmount.h.in
@@ -126,6 +126,7 @@ enum {
#define MNT_ERR_NOFSTAB 5000 /* not found required entry in fstab */
#define MNT_ERR_NOFSTYPE 5001 /* failed to detect filesystem type */
#define MNT_ERR_NOSOURCE 5002 /* required mount source undefined */
+#define MNT_ERR_LOOPDEV 5003 /* loopdev setup failed, errno set by libc */
/* init.c */
extern void mnt_init_debug(int mask);

View File

@ -0,0 +1,68 @@
From 47dea49b4cb4a4a98a6c518cc17f6d2c92be9528 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Apr 2012 11:57:32 +0200
Subject: [PATCH] libmount: add special MNT_ERR_ codes
... to detect some situations where standard -errno is too generic.
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
libmount/src/context.c | 20 ++++++++++----------
libmount/src/libmount.h.in | 12 ++++++++++++
2 files changed, 22 insertions(+), 10 deletions(-)
Index: util-linux-2.21.2/libmount/src/context.c
===================================================================
--- util-linux-2.21.2.orig/libmount/src/context.c
+++ util-linux-2.21.2/libmount/src/context.c
@@ -1186,7 +1186,7 @@ int mnt_context_prepare_srcpath(struct l
if (cache)
path = mnt_resolve_tag(t, v, cache);
- rc = path ? mnt_fs_set_source(cxt->fs, path) : -EINVAL;
+ rc = path ? mnt_fs_set_source(cxt->fs, path) : -MNT_ERR_NOSOURCE;
} else if (cache && !mnt_fs_is_pseudofs(cxt->fs)) {
/*
@@ -1247,7 +1247,7 @@ int mnt_context_prepare_target(struct li
cache = mnt_context_get_cache(cxt);
if (cache) {
char *path = mnt_resolve_path(tgt, cache);
- if (strcmp(path, tgt))
+ if (path && strcmp(path, tgt) != 0)
rc = mnt_fs_set_target(cxt->fs, path);
}
@@ -1543,7 +1543,7 @@ static int apply_table(struct libmnt_con
}
if (!fs)
- return -EINVAL;
+ return -MNT_ERR_NOFSTAB; /* not found */
DBG(CXT, mnt_debug_h(cxt, "apply entry:"));
DBG(CXT, mnt_fs_print_debug(fs, stderr));
Index: util-linux-2.21.2/libmount/src/libmount.h.in
===================================================================
--- util-linux-2.21.2.orig/libmount/src/libmount.h.in
+++ util-linux-2.21.2/libmount/src/libmount.h.in
@@ -115,6 +115,18 @@ enum {
MNT_ACT_UMOUNT
};
+/*
+ * Errors -- by default libmount returns -errno for generic errors (ENOMEM,
+ * EINVAL, ...) and for mount(2) errors, but for some specific operations it
+ * returns private error codes. Note that maximum system errno value should be
+ * 4095 on UNIXes.
+ *
+ * See also mnt_context_get_syscall_errno() and mnt_context_get_helper_status().
+ */
+#define MNT_ERR_NOFSTAB 5000 /* not found required entry in fstab */
+#define MNT_ERR_NOFSTYPE 5001 /* failed to detect filesystem type */
+#define MNT_ERR_NOSOURCE 5002 /* required mount source undefined */
+
/* init.c */
extern void mnt_init_debug(int mask);

View File

@ -0,0 +1,115 @@
From e90e7401d0c318c9dac4a0204e2bca86949b1d32 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 14 Jun 2012 14:19:26 +0200
Subject: [PATCH] libmount: don't use nosuid,noexec,nodev for cifs user=foo
mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
is incorrectly translated to
mount.cifs -o noexec,nosuid,nodev,user=root,password=linux ...
The command mount(8) should be sensitive to "user" (without "=<name>")
only. The correct cifs command line is:
mount.cifs -o user=root,password=linux
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=766157
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
libmount/src/context_mount.c | 29 +++++++++++++++++++++++++++--
libmount/src/optstr.c | 9 +++++----
2 files changed, 32 insertions(+), 6 deletions(-)
Index: util-linux-2.21.2/libmount/src/context_mount.c
===================================================================
--- util-linux-2.21.2.orig/libmount/src/context_mount.c
+++ util-linux-2.21.2/libmount/src/context_mount.c
@@ -53,6 +53,15 @@ static int fix_optstr(struct libmnt_cont
if (cxt->mountflags & MS_PROPAGATION)
cxt->mountflags &= (MS_PROPAGATION | MS_REC | MS_SILENT);
+ /*
+ * The "user" options is our business (so we can modify the option),
+ * but exception is command line for /sbin/mount.<type> helpers. Let's
+ * save the original user=<name> to call the helpers with unchanged
+ * "user" setting.
+ *
+ * Don't check for MNT_MS_USER in cxt->user_mountflags, the flag maybe
+ * removed by evaluate_permissions().
+ */
if (!mnt_optstr_get_option(fs->user_optstr, "user", &val, &valsz)) {
if (val) {
cxt->orig_user = strndup(val, valsz);
@@ -196,6 +205,10 @@ err:
/*
* this has to be called before fix_optstr()
+ *
+ * Note that user=<name> maybe be used by some filesystems as filesystem
+ * specific option (e.g. cifs). Yes, developers of such filesystems have
+ * allocated pretty hot place in hell...
*/
static int evaluate_permissions(struct libmnt_context *cxt)
{
@@ -233,10 +246,22 @@ static int evaluate_permissions(struct l
}
/*
- * Note that MS_OWNERSECURE and MS_SECURE mount options
- * are applied by mnt_optstr_get_flags() from mnt_context_merge_mflags()
+ * MS_OWNERSECURE and MS_SECURE mount options are already
+ * applied by mnt_optstr_get_flags() in mnt_context_merge_mflags()
+ * if "user" (but no user=<name> !) options is set.
+ *
+ * Let's ignore all user=<name> (if <name> is set) requests.
*/
+ if (cxt->user_mountflags & MNT_MS_USER) {
+ size_t valsz = 0;
+ if (!mnt_optstr_get_option(cxt->fs->user_optstr,
+ "user", NULL, &valsz) && valsz) {
+
+ DBG(CXT, mnt_debug_h(cxt, "perms: user=<name> detected, ignore"));
+ cxt->user_mountflags &= ~MNT_MS_USER;
+ }
+ }
/*
* MS_OWNER: Allow owners to mount when fstab contains the
Index: util-linux-2.21.2/libmount/src/optstr.c
===================================================================
--- util-linux-2.21.2.orig/libmount/src/optstr.c
+++ util-linux-2.21.2/libmount/src/optstr.c
@@ -579,7 +579,7 @@ int mnt_optstr_get_flags(const char *opt
{
struct libmnt_optmap const *maps[2];
char *name, *str = (char *) optstr;
- size_t namesz = 0;
+ size_t namesz = 0, valsz = 0;
int nmaps = 0;
assert(optstr);
@@ -596,7 +596,7 @@ int mnt_optstr_get_flags(const char *opt
*/
maps[nmaps++] = mnt_get_builtin_optmap(MNT_USERSPACE_MAP);
- while(!mnt_optstr_next_option(&str, &name, &namesz, NULL, NULL)) {
+ while(!mnt_optstr_next_option(&str, &name, &namesz, NULL, &valsz)) {
const struct libmnt_optmap *ent;
const struct libmnt_optmap *m;
@@ -610,9 +610,10 @@ int mnt_optstr_get_flags(const char *opt
else
*flags |= ent->id;
- } else if (nmaps == 2 && m == maps[1]) {
+ } else if (nmaps == 2 && m == maps[1] && valsz == 0) {
/*
- * Special case -- translate "user" to MS_ options
+ * Special case -- translate "user" (but no user=) to
+ * MS_ options
*/
if (ent->mask & MNT_INVERT)
continue;

View File

@ -0,0 +1,51 @@
From 10389b1e4535dda7d27e5ab39d3d4f9d7868a5c9 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 28 May 2012 12:26:41 +0200
Subject: [PATCH] mount: (new) add loopdev specific error message
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/mount.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
Index: util-linux-2.21.2/sys-utils/mount.c
===================================================================
--- util-linux-2.21.2.orig/sys-utils/mount.c
+++ util-linux-2.21.2/sys-utils/mount.c
@@ -354,6 +354,9 @@ try_readonly:
return MOUNT_EX_SUCCESS; /* mount(2) success */
}
+ mnt_context_get_mflags(cxt, &mflags); /* mount(2) flags */
+ mnt_context_get_user_mflags(cxt, &uflags); /* userspace flags */
+
if (!mnt_context_syscall_called(cxt)) {
/*
* libmount errors (extra library checks)
@@ -382,7 +385,15 @@ try_readonly:
else
warnx(_("mount source not defined"));
return MOUNT_EX_USAGE;
-
+ case -MNT_ERR_LOOPDEV:
+ if (errno == ENOENT
+ && (uflags & MNT_MS_ENCRYPTION)
+ && src && stat(src, &st) == 0)
+ warnx(_("%s: failed to setup loop device "
+ "(probably unknown encryption type)"), src);
+ else
+ warn(_("%s: failed to setup loop device"), src);
+ return MOUNT_EX_FAIL;
default:
return handle_generic_errors(rc, _("%s: mount failed"),
tgt ? tgt : src);
@@ -406,8 +417,6 @@ try_readonly:
*/
syserr = mnt_context_get_syscall_errno(cxt);
- mnt_context_get_mflags(cxt, &mflags); /* mount(2) flags */
- mnt_context_get_user_mflags(cxt, &uflags); /* userspace flags */
switch(syserr) {
case EPERM:

View File

@ -0,0 +1,25 @@
From e26de525e21677c680d87f63e4dafbe4859365bf Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 14 Jun 2012 14:43:21 +0200
Subject: [PATCH] mount: (new) allow sloppy for non-root
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=825836
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/mount.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Index: util-linux-2.21.2/sys-utils/mount.c
===================================================================
--- util-linux-2.21.2.orig/sys-utils/mount.c
+++ util-linux-2.21.2/sys-utils/mount.c
@@ -732,7 +732,7 @@ int main(int argc, char **argv)
longopts, NULL)) != -1) {
/* only few options are allowed for non-root users */
- if (mnt_context_is_restricted(cxt) && !strchr("hlLUVvpri", c))
+ if (mnt_context_is_restricted(cxt) && !strchr("hlLUVvpris", c))
exit_non_root(option_to_longopt(c, longopts));
switch(c) {

View File

@ -0,0 +1,46 @@
From 58f108ef2b9c8cc0362e7781a72e5e921dc383b3 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 17 Apr 2012 11:36:36 +0200
Subject: [PATCH] mount: (new) improve error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/mount.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
Index: util-linux-2.21.2/sys-utils/mount.c
===================================================================
--- util-linux-2.21.2.orig/sys-utils/mount.c
+++ util-linux-2.21.2/sys-utils/mount.c
@@ -367,16 +367,13 @@ try_readonly:
return MOUNT_EX_USAGE;
}
- /*
- * TODO: add mnt_context_fstab_applied() to check if we found
- * target/source in the file.
- */
- if (!tgt) {
- if (mflags & MS_REMOUNT)
- warnx(_("%s not mounted"), src ? src : tgt);
- else
+ if (!tgt || (!src && !(mflags & MS_PROPAGATION))) {
+ if (!mnt_context_fstab_applied(cxt))
warnx(_("can't find %s in %s"), src ? src : tgt,
mnt_get_fstab_path());
+ else if (mflags & MS_REMOUNT)
+ warnx(_("%s not mounted"), src ? src : tgt);
+
return MOUNT_EX_USAGE;
}
@@ -485,6 +482,8 @@ try_readonly:
case EINVAL:
if (mflags & MS_REMOUNT)
warnx(_("%s not mounted or bad option"), tgt);
+ else if (mflags & MS_PROPAGATION)
+ warnx(_("%s is not mountpoint or bad option"), tgt);
else
warnx(_("wrong fs type, bad option, bad superblock on %s,\n"
" missing codepage or helper program, or other error"),

View File

@ -0,0 +1,56 @@
From ba24923e97e099668b8c96dba9596c90cb58c417 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Apr 2012 11:59:18 +0200
Subject: [PATCH] mount: (new) use MNT_ERR_ for error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/mount.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
Index: util-linux-2.21.2/sys-utils/mount.c
===================================================================
--- util-linux-2.21.2.orig/sys-utils/mount.c
+++ util-linux-2.21.2/sys-utils/mount.c
@@ -365,29 +365,28 @@ try_readonly:
case -EBUSY:
warnx(_("%s is already mounted"), src);
return MOUNT_EX_USAGE;
- }
-
- if (!tgt || (!src && !(mflags & MS_PROPAGATION))) {
- if (!mnt_context_fstab_applied(cxt))
+ case -MNT_ERR_NOFSTAB:
warnx(_("can't find %s in %s"), src ? src : tgt,
mnt_get_fstab_path());
- else if (mflags & MS_REMOUNT)
- warnx(_("%s not mounted"), src ? src : tgt);
-
return MOUNT_EX_USAGE;
- }
-
- if (!mnt_context_get_fstype(cxt)) {
+ case -MNT_ERR_NOFSTYPE:
if (restricted)
warnx(_("I could not determine the filesystem type, "
"and none was specified"));
else
warnx(_("you must specify the filesystem type"));
return MOUNT_EX_USAGE;
- }
+ case -MNT_ERR_NOSOURCE:
+ if (src)
+ warnx(_("can't find %s"), src);
+ else
+ warnx(_("mount source not defined"));
+ return MOUNT_EX_USAGE;
+
+ default:
return handle_generic_errors(rc, _("%s: mount failed"),
tgt ? tgt : src);
-
+ }
} else if (mnt_context_get_syscall_errno(cxt) == 0) {
/*
* mount(2) syscall success, but something else failed

View File

@ -1,8 +1,8 @@
Index: util-linux-2.20/libmount/src/Makefile.am Index: util-linux-2.21.2/libmount/src/Makefile.am
=================================================================== ===================================================================
--- util-linux-2.20.orig/libmount/src/Makefile.am --- util-linux-2.21.2.orig/libmount/src/Makefile.am
+++ util-linux-2.20/libmount/src/Makefile.am +++ util-linux-2.21.2/libmount/src/Makefile.am
@@ -29,7 +29,7 @@ nodist_libmount_la_SOURCES = mountP.h @@ -30,7 +30,7 @@ nodist_libmount_la_SOURCES = mountP.h
libmount_la_LIBADD = $(ul_libblkid_la) $(SELINUX_LIBS) libmount_la_LIBADD = $(ul_libblkid_la) $(SELINUX_LIBS)

View File

@ -1,3 +1,22 @@
-------------------------------------------------------------------
Fri Jun 15 12:57:06 UTC 2012 - puzel@suse.com
- improve error messages from new mount (bnc#767208)
- backport patches from upstream git:
- mount-new-add-loopdev-specific-error-message.patch
- mount-new-use-MNT_ERR-for-error-messages.patch
- libmount-add-special-MNT_ERR-codes.patch
- mount-new-improve-error-messages.patch
- libmount-add-MNT_ERR_LOOPDEV.patch
-------------------------------------------------------------------
Thu Jun 14 13:04:40 UTC 2012 - puzel@suse.com
- fix automount with quota (rh#825836)
- mount-new-allow-sloppy-for-non-root.patch
- fix wrong mount options for CIFS mounts (bnc#766157)
- libmount-don-t-use-nosuid-noexec-nodev-for-cifs-user.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Thu May 31 10:04:23 UTC 2012 - sweet_f_a@gmx.de Thu May 31 10:04:23 UTC 2012 - sweet_f_a@gmx.de

View File

@ -88,6 +88,16 @@ Source51: blkid.conf
Patch1: util-linux-2.12r-fdisk_remove_bogus_warnings.patch Patch1: util-linux-2.12r-fdisk_remove_bogus_warnings.patch
Patch2: util-linux-2.20-libmount-deps.patch Patch2: util-linux-2.20-libmount-deps.patch
Patch3: fdisk-tinfo.patch Patch3: fdisk-tinfo.patch
Patch4: mount-new-allow-sloppy-for-non-root.patch
Patch5: libmount-don-t-use-nosuid-noexec-nodev-for-cifs-user.patch
# Patches 6-10: bcn#767208 (taken from upstream
Patch6: mount-new-improve-error-messages.patch
Patch7: libmount-add-special-MNT_ERR-codes.patch
Patch8: mount-new-use-MNT_ERR-for-error-messages.patch
Patch9: libmount-add-MNT_ERR_LOOPDEV.patch
Patch10: mount-new-add-loopdev-specific-error-message.patch
#####
## ##
## adjtimex ## adjtimex
@ -190,6 +200,13 @@ Files to develop applications using the libmount library.
%patch1 -p1 %patch1 -p1
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
# #
cd adjtimex-* cd adjtimex-*