summaryrefslogtreecommitdiff
path: root/lib/chef/resource/windows_service.rb
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@getchef.com>2014-10-21 14:09:04 -0700
committerChris Doherty <cdoherty@getchef.com>2014-12-19 16:24:03 -0800
commitbe28ba90bde1fe0240f313151e3d564ce57e8b29 (patch)
treeae83d0079f55c07452dba11982d1e73f76638368 /lib/chef/resource/windows_service.rb
parent3569079f9831b5e14e8e46b51840f3b6a069d9eb (diff)
downloadchef-be28ba90bde1fe0240f313151e3d564ce57e8b29.tar.gz
Enable Windows services to run as a different user (CHEF-4921). This adds :run_as_user andcdoherty-enhance-win-service
:run_as_password attributes to the windows_service resource. If a logon user is specified, the resource will (on every run) grant the logon-as-service privilege to that user, using secedit.exe.
Diffstat (limited to 'lib/chef/resource/windows_service.rb')
-rw-r--r--lib/chef/resource/windows_service.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index 2aec4d6304..8090adceb0 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -37,6 +37,8 @@ class Chef
@resource_name = :windows_service
@allowed_actions.push(:configure_startup)
@startup_type = :automatic
+ @run_as_user = ""
+ @run_as_password = ""
end
def startup_type(arg=nil)
@@ -48,6 +50,22 @@ class Chef
:equal_to => [ :automatic, :manual, :disabled ]
)
end
+
+ def run_as_user(arg=nil)
+ set_or_return(
+ :run_as_user,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def run_as_password(arg=nil)
+ set_or_return(
+ :run_as_password,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
end
end
end