Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Spike out ability to change defaults as a given user.

  • Loading branch information...
commit 8ee56324de208544f10c17c13c3f0373be702984 1 parent 06e5f33
@wfarr authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/puppet/provider/defaults/osx.rb
View
9 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
Please sign in to comment.
Something went wrong with that request. Please try again.