Project

General

Profile

Bug #19472

Smart Class Parameter adding \r to strings and issues with ""s

Added by James Perry over 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Parameters
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

In adding Smart Parameters to some classes for saz\sudo I found an interesting, and error causing, behaviors.

1. When entering into a smart parameter for a string it shows the double quotes in the string
"# Comment
Cmnd_Alias SOMERULE = /bin/false
testuser ALL NOPASSWD: SOMERULE"

If this is overriden to be

_"# Comment
Cmnd_Alias SOMERULE = /bin/false
testuser ALL NOPASSWD: SOMERULE
  1. Another Comment"_

The puppet run fails with syntax error messages for the lines where the smart parameter was overridden. A puppet catalog run against the host on the master shows:

"mysmartvar": "\"# Comment\r\nCmnd_Alias SOMERULE = /bin/false\r\ntestuser ALL NOPASSWD: SOMERULE\r\n# Another Comment*\"*\r\n"

This of course isn't valid syntax for sudoers which wants
  1. Comment
    Cmnd_Alias SOMERULE = /bin/false
    testusers ALL NOPASSWD: SOMERULE
  2. Another Comment

IF the comments are taken off, the rule is passed mostly correctly. Unfortunately that leads to second issue.

2. Smart Parameter Strings had \r\n appended to end of line instead of only \n.

Continuing with the above example:
When the smart parameter isn't overridden the parameter in the catalog is:

"mysmartvar": "# Comment\nCmnd_Alias SOMERULE = /bin/false\ntestuser ALL NOPASSWD: SOMERULE\n# Another Comment\n"

Just clicking override and removing the quotes, to work around #1 above, the string sent to the host becomes:

"mysmartvar": "# Comment\r\nCmnd_Alias SOMERULE = /bin/false\r\ntestuser ALL NOPASSWD: SOMERULE\r\n# Another Comment\r\n"

This results in the sudoers line become Windows/Dos formatted:

_# Comment*^M*
Cmnd_Alias SOMERULE = /bin/false*^M*
testuser ALL NOPASSWD: SOMERULE*$M*
  1. Another Comment*^M*
    _

To ensure this was not a browser / OS issue. I used Firefox from my Linux Master and Chrome from my Windows desktop. The ^M was added in both cases.

As a workaround I modified the sudo::conf.pp file block from content => $content_real, to content => dos2unix($content_real),.

Unfortunately that modification may not be viable for all Puppet versions / configurations.


Related issues

Related to Foreman - Bug #8997: ^M in multi line parameterNew2015-01-16

History

#1 Updated by Dominic Cleal over 3 years ago

  • Related to Bug #8997: ^M in multi line parameter added

Also available in: Atom PDF