- fix #577947 - need --no-canonicalize option for mount

This commit is contained in:
kzak 2010-04-12 18:56:01 +00:00
commit ec700b7502
2 changed files with 155 additions and 2 deletions

View file

@ -0,0 +1,148 @@
diff -up util-linux-ng-2.16.2/mount/mount.8.kzak util-linux-ng-2.16.2/mount/mount.8
--- util-linux-ng-2.16.2/mount/mount.8.kzak 2009-11-30 15:54:35.000000000 +0100
+++ util-linux-ng-2.16.2/mount/mount.8 2010-04-12 17:32:22.000000000 +0200
@@ -439,6 +439,14 @@ This is necessary for example when
.I /etc
is on a read-only filesystem.
.TP
+.B \-\-no\-canonicalize
+Don't canonicalize paths. The mount command canonicalizes all paths
+(from command line or fstab) and stores canonicalized paths to the
+.IR /etc/mtab
+file. This option can be used together with the
+.B \-f
+flag for already canonicalized absolut paths.
+.TP
.BI \-p " num"
In case of a loop mount with encryption, read the passphrase from
file descriptor
diff -up util-linux-ng-2.16.2/mount/mount.c.kzak util-linux-ng-2.16.2/mount/mount.c
--- util-linux-ng-2.16.2/mount/mount.c.kzak 2010-04-12 17:40:39.000000000 +0200
+++ util-linux-ng-2.16.2/mount/mount.c 2010-04-12 17:34:34.000000000 +0200
@@ -1878,6 +1878,7 @@ static struct option longopts[] = {
{ "make-rslave", 0, 0, 141 },
{ "make-rprivate", 0, 0, 142 },
{ "make-runbindable", 0, 0, 143 },
+ { "no-canonicalize", 0, 0, 144 },
{ "internal-only", 0, 0, 'i' },
{ NULL, 0, 0, 0 }
};
@@ -2170,7 +2171,9 @@ main(int argc, char *argv[]) {
case 143:
mounttype = (MS_UNBINDABLE | MS_REC);
break;
-
+ case 144:
+ nocanonicalize = 1;
+ break;
case '?':
default:
usage (stderr, EX_USAGE);
@@ -2209,7 +2212,8 @@ main(int argc, char *argv[]) {
if (restricted &&
(types || options || readwrite || nomtab || mount_all ||
- fake || mounttype || (argc + specseen) != 1)) {
+ nocanonicalize || fake || mounttype || (argc + specseen) != 1)) {
+
die (EX_USAGE, _("mount: only root can do that"));
}
diff -up util-linux-ng-2.16.2/mount/sundries.c.kzak util-linux-ng-2.16.2/mount/sundries.c
--- util-linux-ng-2.16.2/mount/sundries.c.kzak 2009-11-30 15:42:33.000000000 +0100
+++ util-linux-ng-2.16.2/mount/sundries.c 2010-04-12 17:29:49.000000000 +0200
@@ -21,6 +21,7 @@
int mount_quiet;
int verbose;
+int nocanonicalize;
char *progname;
char *
@@ -270,9 +271,9 @@ canonicalize_spec (const char *path)
{
char *res;
- if (path == NULL)
+ if (!path)
return NULL;
- if (is_pseudo_fs(path))
+ if (nocanonicalize || is_pseudo_fs(path))
return xstrdup(path);
res = canonicalize_path(path);
@@ -283,8 +284,14 @@ canonicalize_spec (const char *path)
char *canonicalize (const char *path)
{
- char *res = canonicalize_path(path);
+ char *res;
+ if (!path)
+ return NULL;
+ else if (nocanonicalize)
+ return xstrdup(path);
+
+ res = canonicalize_path(path);
if (!res)
die(EX_SYSERR, _("not enough memory"));
return res;
diff -up util-linux-ng-2.16.2/mount/sundries.h.kzak util-linux-ng-2.16.2/mount/sundries.h
--- util-linux-ng-2.16.2/mount/sundries.h.kzak 2009-10-16 22:50:03.000000000 +0200
+++ util-linux-ng-2.16.2/mount/sundries.h 2010-04-12 17:29:49.000000000 +0200
@@ -16,6 +16,7 @@
/* global mount, umount, and losetup variables */
extern int mount_quiet;
extern int verbose;
+extern int nocanonicalize;
extern char *progname;
#define streq(s, t) (strcmp ((s), (t)) == 0)
diff -up util-linux-ng-2.16.2/mount/umount.8.kzak util-linux-ng-2.16.2/mount/umount.8
--- util-linux-ng-2.16.2/mount/umount.8.kzak 2009-10-16 22:50:03.000000000 +0200
+++ util-linux-ng-2.16.2/mount/umount.8 2010-04-12 17:34:44.000000000 +0200
@@ -119,6 +119,10 @@ Lazy unmount. Detach the filesystem from
and cleanup all references to the filesystem as soon as it is not busy
anymore.
(Requires kernel 2.4.11 or later.)
+.IP "\fB\-\-no\-canonicalize\fP"
+Don't canonicalize paths. For more details about this option see the
+.B mount(8)
+man page.
.SH "THE LOOP DEVICE"
The
diff -up util-linux-ng-2.16.2/mount/umount.c.kzak util-linux-ng-2.16.2/mount/umount.c
--- util-linux-ng-2.16.2/mount/umount.c.kzak 2009-10-16 22:50:03.000000000 +0200
+++ util-linux-ng-2.16.2/mount/umount.c 2010-04-12 17:34:44.000000000 +0200
@@ -388,6 +388,8 @@ static struct option longopts[] =
{ "version", 0, 0, 'V' },
{ "read-only", 0, 0, 'r' },
{ "types", 1, 0, 't' },
+
+ { "no-canonicalize", 0, 0, 144 },
{ NULL, 0, 0, 0 }
};
@@ -672,7 +674,10 @@ main (int argc, char *argv[]) {
types = optarg;
break;
case 'i':
- external_allowed = 0;
+ external_allowed = 0;
+ break;
+ case 144:
+ nocanonicalize = 1;
break;
case 0:
break;
@@ -691,7 +696,8 @@ main (int argc, char *argv[]) {
}
}
- if (restricted && (all || types || nomtab || force || remount)) {
+ if (restricted &&
+ (all || types || nomtab || force || remount || nocanonicalize)) {
die (2, _("umount: only root can do that"));
}

View file

@ -2,7 +2,7 @@
Summary: A collection of basic system utilities
Name: util-linux-ng
Version: 2.16.2
Release: 8%{?dist}
Release: 9%{?dist}
License: GPLv2 and GPLv2+ and BSD with advertising and Public Domain
Group: System Environment/Base
URL: ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng
@ -118,7 +118,8 @@ Patch11: util-linux-ng-2.16-blkid-ataraid.patch
Patch12: util-linux-ng-2.16-blkid-minix.patch
# 494070 - Anaconda tries to mount zfs filesystem as EXT3 and install fails
Patch13: util-linux-ng-2.16-blkid-zfs.patch
# 577947 - need --no-canonicalize option for mount
Patch14: util-linux-ng-2.16-mount-nocanonicalize.patch
%description
The util-linux-ng package contains a large variety of low-level system
@ -218,6 +219,7 @@ cp %{SOURCE8} %{SOURCE9} .
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%build
unset LINGUAS || :
@ -728,6 +730,9 @@ fi
%changelog
* Mon Apr 12 2010 Karel Zak <kzak@redhat.com> 2.16.2-9
- fix #577947 - need --no-canonicalize option for mount
* Mon Apr 12 2010 Karel Zak <kzak@redhat.com> 2.16.2-8
- fix #581252 - remounting tmpfs fails because of hidden rootcontext=