Bug 616393 - tmpfs mount fails with 'user' option.
tmpfs mount fails with 'user' option.
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: util-linux-ng (Show other bugs)
6.1
All Linux
low Severity medium
: rc
: ---
Assigned To: Karel Zak
qe-baseos-daemons
:
Depends On: 615719
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-20 06:55 EDT by Karel Zak
Modified: 2011-05-19 10:05 EDT (History)
7 users (show)

See Also:
Fixed In Version: util-linux-ng-2.17.2-9.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 615719
Environment:
Last Closed: 2011-05-19 10:05:48 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0699 normal SHIPPED_LIVE util-linux-ng bug fix and enhancement update 2011-05-18 14:10:13 EDT

  None (edit)
Description Karel Zak 2010-07-20 06:55:23 EDT
+++ This bug was initially created as a clone of Bug #615719 +++

Description of problem:
Mount of tmpfs where fstab contains "user" option still requires root privilege.

Version-Release number of selected component (if applicable):
util-linux-ng-2.17.2-5.fc13.i686
Problem appears present at least back to Fedora12.

How reproducible:
100%

Steps to Reproduce:
1. Add fstab entry like
tmpfs  /mnt/ramdisk tmpfs user,noauto		0 0	
2. Create mountpoint
mkdir /mnt/ramdisk
3. Attempt to mount from non-root account:
mount /mnt/ramdisk

  
Actual results:
[stevea@nidula mount]$ tail -1 /etc/fstab
tmpfs			/mnt/ramdisk		tmpfs	user,noauto,ro		0 0	
[stevea@nidula mount]$ ls -ld /mnt/ramdisk/
drwxrwxrwt 2 root root 40 Jul 18 04:03 /mnt/ramdisk/
[stevea@nidula mount]$ mount /mnt/ramdisk
mount: only root can do that
[stevea@nidula mount]$ 

Expected results:
tmpfs should mount at /mnt/ramdisk WITHOUT requiring root privilege.

Additional info:
This problem results from the correction to bug 476964
https://bugzilla.redhat.com/show_bug.cgi?id=476964
The script /sbin/mount.tmpfs is called from mount, and in turn  exec's "mount -i-t tmpfs -o user,...".   For obvious reasons the mount command cannot accept the "-o user" option from the command line.  The script solution to 476964 does not correctly preserve mount functionality.


--- Additional comment from kzak@redhat.com on 2010-07-20 03:30:33 EDT ---

Proposed patch:

--- mount.tmpfs	12 Apr 2010 13:19:23 -0000	1.5
+++ mount.tmpfs	20 Jul 2010 07:28:09 -0000
@@ -18,6 +18,24 @@
       ;;
 esac
 
+restricted=1
+ruid=$(id --user --real)
+euid=$(id --user)
+
+if [ $ruid -eq 0 ] && [ $ruid -eq $euid ]; then
+  restricted=0
+fi
+
+# mount(8) in restricted mode (for non-root users) does not allow to use any
+# mount options, types or so on command line. We have to call mount(8) with
+# mountpoint only.  All necessary options have to be defined in /etc/fstab.
+#
+# https://bugzilla.redhat.com/show_bug.cgi?id=615719
+#
+if [ $restricted -eq 1 ]; then
+  exec /bin/mount -i "$2"
+fi
+
 # Remount with context mount options is unsupported
 # http://bugzilla.redhat.com/show_bug.cgi?id=563267
 #
Comment 5 errata-xmlrpc 2011-05-19 10:05:48 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0699.html

Note You need to log in before you can comment on or make changes to this bug.