Revision 8a6e87dc
Added by Greg Sutcliffe almost 11 years ago
lib/puppet/parser/functions/cache_data.rb | ||
---|---|---|
require 'fileutils'
|
||
require 'yaml'
|
||
require 'etc'
|
||
|
||
# Retrieves data from a cache file, or creates it with supplied data if the file doesn't exist
|
||
#
|
||
... | ... | |
File.open(cache, 'w', 0600) do |c|
|
||
c.write(YAML.dump(initial_data))
|
||
end
|
||
# Chown to puppet to prevent later cache-read errors when this is run as root
|
||
if Etc.getpwuid.name == 'root'
|
||
uid = Etc.getpwnam('puppet').uid
|
||
File.chown(uid, nil, cache)
|
||
File.chown(uid, nil, cache_dir)
|
||
end
|
||
initial_data
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #2689 - chown cache data to puppet