Bug 1190877 - Options incorrectly parsed
Summary: Options incorrectly parsed
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: fuse
Version: mainline
Hardware: x86_64
OS: Linux
low
unspecified
Target Milestone: ---
Assignee: Csaba Henk
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-02-09 20:38 UTC by mark
Modified: 2019-06-19 03:11 UTC (History)
6 users (show)

Fixed In Version: glusterfs-6.x
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-19 03:11:57 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:


Attachments (Terms of Use)

Description mark 2015-02-09 20:38:01 UTC
Description of problem:
mount.glusterfs fails to correctly parse autofs mount options

Version-Release number of selected component (if applicable):
v3.6.2

How reproducible:
Invoke mount.glusterfs with -n -o $mountoptions
e.g.  mount $host:volume /mnt/volume -n -o acl

Steps to Reproduce:
1.
2.
3.

Actual results:
volume is mounted without acls enabled (depending upon $mountoptions, the mount may fail silently instead).

Expected results:
Mount with acls enabled


Additional info:
The issue is in mount.glusterfs parsing the line using getopts: under the -n and -o cases, there are "shift" statements. These confuse getopts as getopts expects the argument list unchanged unless $OPTIND is also chagned - after parsing "-n", $OPTIND = 2, $1='-n', $2='-o', $3='acl', but the shift removes $1, causing $1='-o' and $2='acl'. The next call to getopts returns garbage as getopts tries to parse 'acl', not '-o'. The patch below fixes the issue:

commit ede617d738c38a0c45275dadcfefa414574dfac0
Author: Mark Levedahl <mark.levedahl@mdnt.com>
Date:   Mon Feb 9 13:15:50 2015 -0500

    mount.glusterfs - remove "shift" statements
    
    getopts takes care of the command line arguments, adding "shift"
    in the loop causes getopt to skip when it should not.

diff --git a/xlators/mount/fuse/utils/mount.glusterfs.in b/xlators/mount/fuse/utils/mount.glusterfs.in
index 68d452c..924b98f 100755
--- a/xlators/mount/fuse/utils/mount.glusterfs.in
+++ b/xlators/mount/fuse/utils/mount.glusterfs.in
@@ -556,10 +556,8 @@ main ()
         case "${opt}" in
             o)
                 parse_options ${OPTARG};
-       shift 2;
                 ;;
             n)
-       shift 1;
                 ;;
             V)
                 ${cmd_line} -V;
@@ -575,6 +573,10 @@ main ()
                 ;;
         esac
     done
+    if test $OPTIND -gt 1
+    then
+        shift $((OPTIND - 1))
+    fi
 
     if [ "x${uname_s}" = "xNetBSD" ] ; then
         volfile_loc=$1

Comment 1 Amar Tumballi 2019-06-19 03:11:57 UTC
This is fixed in latest releases. (https://review.gluster.org/#/c/glusterfs/+/21295/)


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