Bug 1503983 - Wrong usage of getopt shell command in hook-scripts
Summary: Wrong usage of getopt shell command in hook-scripts
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: scripts
Version: mainline
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Anoop C S
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-19 08:34 UTC by Anoop C S
Modified: 2017-12-08 17:44 UTC (History)
1 user (show)

Fixed In Version: glusterfs-3.13.0
Clone Of:
Environment:
Last Closed: 2017-12-05 08:46:05 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

Description Anoop C S 2017-10-19 08:34:53 UTC
Description of problem:
getopt(1) shell command has the following optional argument defined in man page [1]

. . .
-n, --name progname
       The name that will be used by the getopt(3) routines when it reports
       errors. Note that errors of getopt(1) are still reported as coming from
       getopt.
. . .

The way getopt shell command is used inside almost every hook scripts results is generating wrong script name while reporting any errors during execution of `getopt`.


Version-Release number of selected component (if applicable):
mainline

[1] http://man7.org/linux/man-pages/man1/getopt.1.html

Comment 1 Worker Ant 2017-10-19 08:36:23 UTC
REVIEW: https://review.gluster.org/18548 (extras/hooks: Fix getopt usage) posted (#1) for review on master by Anoop C S (anoopcs)

Comment 2 Anoop C S 2017-10-25 07:07:57 UTC
We also have the following errors from hook scripts:

ame: unrecognized option '--first=no'
ame: unrecognized option '--version=1'
ame: unrecognized option '--volume-op=start'

Hook scripts fail to honour every command line arguments with which they are invoked.

Comment 3 Worker Ant 2017-10-25 07:11:19 UTC
REVIEW: https://review.gluster.org/18548 (extras/hooks: Fix getopt usage) posted (#2) for review on master by Anoop C S (anoopcs)

Comment 4 Worker Ant 2017-10-25 07:11:23 UTC
REVIEW: https://review.gluster.org/18569 (extras/hooks: Honour all input arguments to scripts) posted (#1) for review on master by Anoop C S (anoopcs)

Comment 5 Worker Ant 2017-10-25 07:29:28 UTC
REVIEW: https://review.gluster.org/18548 (extras/hooks: Fix getopt usage) posted (#3) for review on master by Anoop C S (anoopcs)

Comment 6 Worker Ant 2017-10-25 07:29:32 UTC
REVIEW: https://review.gluster.org/18569 (extras/hooks: Honour all input arguments to scripts) posted (#2) for review on master by Anoop C S (anoopcs)

Comment 7 Worker Ant 2017-10-30 15:49:34 UTC
COMMIT: https://review.gluster.org/18548 committed in master by  

------------- extras/hooks: Fix getopt usage

`getopt` does not have an optional argument as '-name'. It should
be either '-n' or '--name'(see man getopt(1)). This wrong usage
resulted in setting the script name as 'ame' instead of $PROGNAME
in most of the hook-scripts.

Additionally the following line from DESCRIPTION given for `getopt`
shell command expects short options for almost every kind of usage
mentioned in SYNOPSIS:

. . .
If  no  '-o'  or '--options' option is found in the first part, the
first parameter of the second part is used as the short options string.
. . .

Refer http://man7.org/linux/man-pages/man1/getopt.1.html for more
clarity on its usage.

Change-Id: I95baf5fa8c99025e66b2d83656dd838d4f6048ce
BUG: 1503983
Signed-off-by: Anoop C S <anoopcs>

Comment 8 Worker Ant 2017-10-31 12:24:43 UTC
COMMIT: https://review.gluster.org/18569 committed in master by  

------------- extras/hooks: Honour all input arguments to scripts

Some of the hook scripts were not honouring the arguments with which
they are invoked during various volume operations. So make sure that
we consider everything while parsing the command line arguments to
avoid following warnings:

. . .
ame: unrecognized option '--first=no'
ame: unrecognized option '--version=1'
ame: unrecognized option '--volume-op=start'
. . .

Change-Id: I5b08e5e7f32908c8509e97098a042096b507783e
BUG: 1503983
Signed-off-by: Anoop C S <anoopcs>

Comment 9 Shyamsundar 2017-12-08 17:44:30 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.13.0, please open a new bug report.

glusterfs-3.13.0 has been announced on the Gluster mailinglists [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://lists.gluster.org/pipermail/announce/2017-December/000087.html
[2] https://www.gluster.org/pipermail/gluster-users/


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