summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-10-31 11:19:37 -0700
committerGitHub <noreply@github.com>2018-10-31 11:19:37 -0700
commit461d7e5b5db9e562e13d191ef3751306758ff1e3 (patch)
tree2280ee0940f0d336e5f35ffcb5db3b610c3a28b5
parentc4ed115bed739bec87654b040bf426ba8943fea7 (diff)
parente53c21db3ec1ff031d701d65818e738d66b8a17d (diff)
downloadchef-461d7e5b5db9e562e13d191ef3751306758ff1e3.tar.gz
Merge pull request #7814 from MsysTechnologiesllc/nimesh/MSYS-915_InteractiveEnabledFixes
Handle `interactive_enabled` property in windows_task resource
-rw-r--r--lib/chef/provider/windows_task.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index cd8e07e24c..20709fa527 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -135,10 +135,10 @@ class Chef
converge_by("#{new_resource} task created") do
task = TaskScheduler.new
if new_resource.frequency == :none
- task.new_work_item(new_resource.task_name, {}, { user: new_resource.user, password: new_resource.password })
+ task.new_work_item(new_resource.task_name, {}, { user: new_resource.user, password: new_resource.password, interactive: new_resource.interactive_enabled })
task.activate(new_resource.task_name)
else
- task.new_work_item(new_resource.task_name, trigger, { user: new_resource.user, password: new_resource.password })
+ task.new_work_item(new_resource.task_name, trigger, { user: new_resource.user, password: new_resource.password, interactive: new_resource.interactive_enabled })
end
task.application_name = new_resource.command
task.parameters = new_resource.command_arguments if new_resource.command_arguments
@@ -349,7 +349,7 @@ class Chef
current_task_trigger[:type] != new_task_trigger[:type] ||
current_task_trigger[:random_minutes_interval].to_i != new_task_trigger[:random_minutes_interval].to_i ||
current_task_trigger[:minutes_interval].to_i != new_task_trigger[:minutes_interval].to_i ||
- task.account_information != new_resource.user ||
+ task.account_information.to_s.casecmp(new_resource.user.to_s) != 0 ||
task.application_name != new_resource.command ||
task.parameters != new_resource.command_arguments.to_s ||
task.working_directory != new_resource.cwd.to_s ||
@@ -570,13 +570,18 @@ class Chef
def logon_type
# Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383566(v=vs.85).aspx
# if nothing is passed as logon_type the TASK_LOGON_SERVICE_ACCOUNT is getting set as default so using that for comparision.
- user_id = new_resource.user
+ user_id = new_resource.user.to_s
+ password = new_resource.password.to_s
if Chef::ReservedNames::Win32::Security::SID.service_account_user?(user_id)
TaskScheduler::TASK_LOGON_SERVICE_ACCOUNT
elsif Chef::ReservedNames::Win32::Security::SID.group_user?(user_id)
TaskScheduler::TASK_LOGON_GROUP
- elsif !new_resource.password.to_s.empty? # password is present
- TaskScheduler::TASK_LOGON_PASSWORD
+ elsif !user_id.empty? && !password.empty?
+ if new_resource.interactive_enabled
+ TaskScheduler::TASK_LOGON_INTERACTIVE_TOKEN
+ else
+ TaskScheduler::TASK_LOGON_PASSWORD
+ end
else
TaskScheduler::TASK_LOGON_INTERACTIVE_TOKEN
end