[
https://issues.apache.org/jira/browse/TS-3245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15285537#comment-15285537
]
ASF GitHub Bot commented on TS-3245:
------------------------------------
Github user pbchou commented on the pull request:
https://github.com/apache/trafficserver/pull/571#issuecomment-219565721
When there is an issue, typically the second plugin in the list will have
corrupted values for its arguments as returned by getopt_long(). For example,
it might return text from the first plugin's argument list.
One interesting thing is that all plugins are using getopt_long() and not
getopt(). I think getopt_long() is itself a GNU extension according to the man
page. So does this mean optind = 0 will always be safe (since implies GNU
library) or have other non GNU libraries implemented getopt_long also?
Additional Notes:
+ There are 16 plugins making use of getopt_long(). There are 0 plugins
using plain getopt(). The 15 mentioned in a prior comment was incorrect (-1 due
to a local plugin, +2 due to two plugins not setting optind at all).
+ 10 plugins are using optind = 0.
+ 4 plugins are using optind = 1.
+ 2 plugins are using getopt_long but not setting optind at all. [epic,
ssl_cert_loader]
> getopt doesn't work correctly when used in plugin chaining
> ----------------------------------------------------------
>
> Key: TS-3245
> URL: https://issues.apache.org/jira/browse/TS-3245
> Project: Traffic Server
> Issue Type: Improvement
> Components: Plugins
> Affects Versions: 5.1.1
> Reporter: Sudheer Vinukonda
> Priority: Minor
> Labels: newbie
> Fix For: sometime
>
>
> When multiple plugins that use getopt are chained, it doesn't work correctly
> for the subsequent plugins after the first plugin. [[email protected]] and
> [~zwoop] suggested that the getopt globals need to be reset (example,
> {{optind = opterr = optopt = 0}}) before using it and would be better to do
> it in the core during plugin loading to keep it simple/transparent from
> plugin development.
> Note that, if a plugin itself uses getopt multiple times on different argv's,
> it would have to reset the globals between them.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)