Группа :: Разработка/Ruby
Пакет: gem-puppet
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: fix_yaml.patch
Скачать
Скачать
commit b78617411ccd9c5d1491e8dc5c0ed5d1cf20f329
Author: Pavel Skrylev <majioa@altlinux.org>
Date: Mon Dec 28 17:26:33 2020 +0300
(maint) Fix owner for the facts folder
When retrieving facts and string them to the facts fils as yaml, the
folder is created as of root, so changing them to puppet defaults.
diff --git a/lib/puppet/file_system/file_impl.rb b/lib/puppet/file_system/file_impl.rb
index c4e8500243..beba1ea54d 100644
--- lib/puppet/file_system/file_impl.rb
+++ lib/puppet/file_system/file_impl.rb
@@ -160,8 +160,8 @@ class Puppet::FileSystem::FileImpl
def replace_file(path, mode = nil)
begin
stat = lstat(path)
- gid = stat.gid
- uid = stat.uid
+ gid = Puppet::Type.type(:group).new(name: Puppet[:group]).exists? ? Puppet[:group] : stat.gid
+ uid = Puppet::Type.type(:user).new(name: Puppet[:user]).exists? ? Puppet[:user] : stat.uid
mode ||= stat.mode & 07777
rescue Errno::ENOENT
mode ||= 0640
diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index e6df83801c..301e937376 100644
--- lib/puppet/indirector/yaml.rb
+++ lib/puppet/indirector/yaml.rb
@@ -23,8 +23,9 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
basedir = File.dirname(file)
- # This is quite likely a bad idea, since we're not managing ownership or modes.
- Dir.mkdir(basedir) unless Puppet::FileSystem.exist?(basedir)
+ if !Puppet::FileSystem.exist?(basedir)
+ touch_dir(basedir)
+ end
begin
Puppet::Util::Yaml.dump(request.instance, file)
@@ -56,6 +57,14 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
end
protected
+ def touch_dir dir
+ Dir.mkdir(dir)
+
+ user = Puppet::Type.type(:user).new(name: Puppet[:user]).exists? ? Puppet[:user] : nil
+ group = Puppet::Type.type(:group).new(name: Puppet[:group]).exists? ? Puppet[:group] : nil
+ Puppet.debug("Fixing perms for #{user}:#{group} on #{dir}")
+ FileUtils.chown(user, group, dir) if user || group
+ end
def load_file(file)
Puppet::Util::Yaml.safe_load_file(file, [model, Symbol])