summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-19 15:24:10 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-24 11:36:21 +1000
commit06fcece75ef52168a73013eba2b8bfc50cf71c97 (patch)
tree9f15442bc06aabece202187c602c216108b16537 /lib/puppet/util
parent4eb325a1839e7803e50f148b999952a0c5abd959 (diff)
downloadpuppet-06fcece75ef52168a73013eba2b8bfc50cf71c97.tar.gz
puppet-06fcece75ef52168a73013eba2b8bfc50cf71c97.tar.xz
puppet-06fcece75ef52168a73013eba2b8bfc50cf71c97.zip
Switching the owner/group settings to use symbolic values
We previously allowed the owner and group to be set to arbitrary values but we never actually used it -- we always just set them to '$user' or '$group'. This commit changes the model to allow 'root' or 'service', where 'service' is converted to the actual service user/group. This has the potential to have backward compatibility concerns, because users could have changed the owner/group in puppet.conf, but the chances of that are fantastically small. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/settings/file_setting.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb
index 08d8039f4..7ddc4697c 100644
--- a/lib/puppet/util/settings/file_setting.rb
+++ b/lib/puppet/util/settings/file_setting.rb
@@ -2,7 +2,11 @@ require 'puppet/util/settings/setting'
# A file.
class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
- attr_writer :owner, :group
+ AllowedOwners = %w{root service}
+ AllowedGroups = %w{service}
+
+ class SettingError < StandardError; end
+
attr_accessor :mode, :create
# Should we create files, rather than just directories?
@@ -10,20 +14,29 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
create
end
+ def group=(value)
+ unless AllowedGroups.include?(value)
+ raise SettingError, "Invalid group %s on setting %s. Valid groups are %s." % [value, name, AllowedGroups.join(', ')]
+ end
+ @group = value
+ end
+
def group
- if defined? @group
- return @settings.convert(@group)
- else
- return nil
+ return unless defined?(@group) && @group
+ @settings[:group]
+ end
+
+ def owner=(value)
+ unless AllowedOwners.include?(value)
+ raise SettingError, "Invalid owner %s on setting %s. Valid owners are %s." % [value, name, AllowedOwners.join(', ')]
end
+ @owner = value
end
def owner
- if defined? @owner
- return @settings.convert(@owner)
- else
- return nil
- end
+ return unless defined?(@owner) && @owner
+ return "root" if @owner == "root"
+ @settings[:user]
end
# Set the type appropriately. Yep, a hack. This supports either naming