[PUP-4429] Puppet command line tools accept partial matches for flags without altering behavior Created: 2015/04/16 Updated: 2019/04/04
|Affects Version/s:||PUP 3.7.5, PUP 4.0.0|
|Fix Version/s:||PUP 5.y|
|Remaining Estimate:||Not Specified|
|Time Spent:||Not Specified|
|Original Estimate:||Not Specified|
The Puppet command line tools will accept partial matches for flags, but do not use the values provided. This causes unexpected behavior when a command accepts a flag or type but doesn't actually act upon it.
Install Puppet 3.7.x or 4.0.x.
Execute config print commands with flags that affect settings, such as puppet agent --no-daemonize --configprint daemonize with various truncations of the --no-daemonize flag.
Partial matches are accepted, but don't alter the setting value:
The Puppet command line interface should treat partial flags the same way as missing flags and throw an 'invalid option' error:
|Comment by Charlie Sharpsteen [ 2015/04/16 ]|
Updated notes from Redmine ticket #19306:
Drilled the problem down a bit. A command line invocation, such as puppet agent --no-daemon, goes through two rounds of option parsing. This first round occurs in /util/command_line.rb and ends up triggering a block of code in settings.rb:
The important things to note is that this first round uses PuppetOptionParser which is a modified Trollop parser and that ignore_invalid_options is set to true because at this point Puppet doesn’t know which subcommand is being executed. Because of this, the unknown no-daemon flag slips through the first round of parsing without raising an error.
The second round of parsing occurs within the Application class in the parse_options method. This round of parsing uses the OptionParser class from the optparse module in the Ruby standard library. The OptionParser class is capable of autocorrecting no-daemon to no-daemonize and in fact always performs this correction—-there is no way to disable it. The command line arguments that match Puppet’s global settings are passed to the handlearg function which ignores them completely.
There are a few issues here:
|Comment by Kylo Ginsberg [ 2015/04/16 ]|
We should consider this ticket in any plans to work on the puppet CLI.