Issue #8255 has been updated by tgeeky -.
Category set to installation
Status changed from Unreviewed to Ready For Checkin
Assignee set to tgeeky -
% Done changed from 90 to 100
OK. The original fix as proposed in the above pastie are not the best possible
fix. I will use pastie links here, instead of typing the code in, because of
syntax highlighting and whatnot.
This bug is really two problems. The first is the series of entries (somewhat
poorly formatted) by Luke Caines. He introduced defaults that, in general,
looked like this:
:yamldir => {:default => "$vardir/yaml",
:owner => "service",
:group => "service",
:mode => "750",
:desc => "The directory in which YAML data is stored, usually in a
subdirectory."},
The problem line is:
<blockquote>
<b>:mode => "750"</b>
</blockquote>
When using strings for :mode-lines, this is decimal.
The output with --genmanifest is:
file { '/var/lib/puppet/yaml':
ensure => 'directory',
backup => 'false',
group => 'puppet',
links => 'follow',
loglevel => 'debug',
mode => '1356',
owner => 'puppet',
}
This isn't a problem that stops puppet, because 1356 does not contain any
non-octal digits. This is not the intended mode, obviously.
So, I wrote this
[[patch]](https://github.com/technogeeky/puppet/commit/2c340292d8f08398f98a9b157471ed99ec35969c#L0R459)
which converts the defaults introduced in
[[bug#1138]](http://projects.puppetlabs.com/issues/1138) to the format used for
the rest of the file. These are ****bare**** ruby numbers, all in octal
(starting with 0).
[[The result (pastie)]](http://www.pastie.org/2174464) is either good or bad,
depending on your viewpoint. On the one hand, there are plenty of invalid
modelines which were already there. On the other hand, they are consistently
incorrect!
On advice from ****richardc****, I tried (instead of implementing the sprintf
'hack') making all modelines strings. I even did this twice - once with
singlequote strings, once with doublequote:
*
[[singlequote]](https://github.com/technogeeky/puppet/commit/0baa89f265c5ec09040de7d4db9585cab8bedbe2)
*
[[doublequote]](https://github.com/technogeeky/puppet/commit/30655a4502eda1dbf70f51a4401d91df18d71b34)
Happily, these produce correct modelines:
* [[Using doublequotes]](http://www.pastie.org/pastes/2174495)
And they are identical:
diff genmanifest-strings.pp genmanifest-doublequotes.pp
< nothing! >
Now, [[running these manifests]](http://www.pastie.org/2174518) results in a
correct-looking configuration.
Huzzah!
Now for the tounge-in-cheek part. Since we aren't using a language like Haskell
with strong typing, perhaps it would be best to pick a standard (from my
investigation I assume only storing modelines as strings will do) - and to warn
in other cases - ****especially**** because this can get through puppet and
appear to work, but fail by setting permissions incorrectly.
----------------------------------------
Bug #8255: inconsistent handling of octal in file { mode => 'nnnn' }
https://projects.puppetlabs.com/issues/8255
Author: tgeeky -
Status: Ready For Checkin
Priority: Normal
Assignee: tgeeky -
Category: installation
Target version:
Affected Puppet version: 2.7.1
Keywords: octal, permissions, genmanifest, defaults
Branch:
****I just noticed this is a repeat of bug
[[1756]](http://projects.puppetlabs.com/issues/1756)****. But for serveral
reasons (including the much different version of puppet), I'm posting it
separately.
I believe this merits priority ****High**** because it represents a major
stumbling block for people using puppet for the first time, and a tool which
doesn't properly generate its own configuration (though it claims to in docs)
represents a serious slight against the stability of the software in question.
****However****, since this problem may only be restricted to the scope of
--genmanifest (I suspect there is more inconsistent handling of octal in
puppet), I leave it at ****Normal**** for now.
In an out ****of-of-the-box**** configuration, the following command will
produce incorrect output:
puppet --genmanifest > /etc/puppet/manifests/site.pp
The resulting output contains decimal file modes like this one:
file { '/etc/puppet/ssl/private':
ensure => 'directory',
backup => 'false',
links => 'follow',
loglevel => 'debug',
mode => '488',
owner => 'puppet',
}
Trying to run with this autogenerated manifest:
puppet agent --server puppet --verbose --test --debug trace
Fails:
...
err: Could not run Puppet configuration client: Parameter mode failed: File
modes can only be octal numbers, not "488"
A one-liner fix was suggested by richardc, and tested by me (and it works,
insfoar as the output is parseable now):
diff --git a/lib/puppet/util/settings/file_setting.rb
b/lib/puppet/util/settings/file_setting.rb
index 776398e..c765a4b 100644
--- a/lib/puppet/util/settings/file_setting.rb
+++ b/lib/puppet/util/settings/file_setting.rb
@@ -91,7 +91,7 @@ class Puppet::Util::Settings::FileSetting <
Puppet::Util::Settings::Setting
resource = Puppet::Resource.new(:file, path)
if Puppet[:manage_internal_file_permissions]
- resource[:mode] = self.mode if self.mode
+ resource[:mode] = sprintf("%o", self.mode) if self.mode
if Puppet.features.root?
resource[:owner] = self.owner if self.owner
Much more detail is available in this
[[pastie]](http://www.pastie.org/pastes/2173089).
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.