Permalink
Browse files

Spike out ability to change defaults as a given user.

  • Loading branch information...
1 parent 06e5f33 commit 8ee56324de208544f10c17c13c3f0373be702984 @wfarr committed Jun 2, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/puppet/provider/defaults/osx.rb
@@ -12,12 +12,19 @@ def create
defaults(:write, resource[:domain], resource[:key], type_and_val)
end
+ def defaults(command)
+ if resource[:user]
+ asuser(resource[:user]) { super }
+ end
+ end
+
def destroy
defaults(:delete, resource[:domain], resource[:key])
end
def exists?
- `/usr/bin/defaults read #{resource[:domain]} | grep '#{resource[:key]}'`
+ su_str = "su - #{resource[:user]}" if resource[:user]
+ `#{su_str} /usr/bin/defaults read #{resource[:domain]} | grep '#{resource[:key]}'`
if $? == 0
defaults(:read, resource[:domain], resource[:key]).split(' ')[1] == resource[:value].to_s
else

0 comments on commit 8ee5632

Please sign in to comment.