Bug 1190877

Summary: Options incorrectly parsed
Product: [Community] GlusterFS Reporter: mark <mdl123>
Component: fuseAssignee: Csaba Henk <csaba>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: low    
Version: mainlineCC: atumball, bugs, nbalacha, ndevos, simon.fayer05, vbellur
Target Milestone: ---Keywords: EasyFix, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: glusterfs-6.x Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-19 03:11:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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>
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/)