diff options
author | Tim Smith <tsmith@chef.io> | 2021-03-09 15:20:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-09 15:20:42 -0800 |
commit | 128a75e5f4d47ee0a6c51376c954a7324c8fd2ed (patch) | |
tree | b8c9985ee6b72cb07f1318c8557d60ac1205ff49 | |
parent | b68978ee348c376ca70610068b20eafc3e19ae1f (diff) | |
parent | 9fc122d4ee60fa0f3c16f3b72169634c9aa5cbef (diff) | |
download | chef-128a75e5f4d47ee0a6c51376c954a7324c8fd2ed.tar.gz |
Merge pull request #11154 from krackajak/launchctl_full_path
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/provider/service/macosx.rb | 6 | ||||
-rw-r--r-- | lib/chef/resource/chef_client_launchd.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/service/macosx_spec.rb | 6 |
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index ce05dd54f0..fd8610a0f9 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -169,12 +169,12 @@ class Chef def load_service session = @session_type ? "-S #{@session_type} " : "" - cmd = "launchctl load -w " + session + @plist + cmd = "/bin/launchctl load -w " + session + @plist shell_out_as_user(cmd) end def unload_service - cmd = "launchctl unload -w " + @plist + cmd = "/bin/launchctl unload -w " + @plist shell_out_as_user(cmd) end @@ -190,7 +190,7 @@ class Chef def set_service_status return if @plist.nil? || @service_label.to_s.empty? - cmd = "launchctl list #{@service_label}" + cmd = "/bin/launchctl list #{@service_label}" res = shell_out_as_user(cmd) if res.exitstatus == 0 diff --git a/lib/chef/resource/chef_client_launchd.rb b/lib/chef/resource/chef_client_launchd.rb index 04b88aa550..65c561a2a2 100644 --- a/lib/chef/resource/chef_client_launchd.rb +++ b/lib/chef/resource/chef_client_launchd.rb @@ -134,7 +134,7 @@ class Chef standard_error_path ::File.join(new_resource.log_directory, new_resource.log_file_name) program_arguments ["/bin/bash", "-c", - "echo; echo #{ChefUtils::Dist::Infra::PRODUCT} launchd daemon config has been updated. Manually unloading and reloading the daemon; echo Now unloading the daemon; launchctl unload /Library/LaunchDaemons/com.#{ChefUtils::Dist::Infra::SHORT}.#{ChefUtils::Dist::Infra::CLIENT}.plist; sleep 2; echo Now loading the daemon; launchctl load /Library/LaunchDaemons/com.#{ChefUtils::Dist::Infra::SHORT}.#{ChefUtils::Dist::Infra::CLIENT}.plist"] + "echo; echo #{ChefUtils::Dist::Infra::PRODUCT} launchd daemon config has been updated. Manually unloading and reloading the daemon; echo Now unloading the daemon; /bin/launchctl unload /Library/LaunchDaemons/com.#{ChefUtils::Dist::Infra::SHORT}.#{ChefUtils::Dist::Infra::CLIENT}.plist; sleep 2; echo Now loading the daemon; /bin/launchctl load /Library/LaunchDaemons/com.#{ChefUtils::Dist::Infra::SHORT}.#{ChefUtils::Dist::Infra::CLIENT}.plist"] action :enable # enable creates the plist & triggers service restarts on change end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index adf1192165..eafc857cf1 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -78,7 +78,7 @@ describe Chef::Provider::Service::Macosx do @getpwuid = double("Etc::Passwd", { name: "mikedodge04" }) allow(Etc).to receive(:getpwuid).and_return(@getpwuid) allow(node).to receive(:[]).with("platform_version").and_return("10.11.1") - cmd = "launchctl list #{service_label}" + cmd = "/bin/launchctl list #{service_label}" allow(provider).to receive(:shell_out) .with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false) .and_return(double("Status", @@ -265,7 +265,7 @@ describe Chef::Provider::Service::Macosx do end it "starts service via launchctl if service found" do - cmd = "launchctl load -w " + session + plist + cmd = "/bin/launchctl load -w " + session + plist expect(provider).to receive(:shell_out) .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false) .and_return(0) @@ -297,7 +297,7 @@ describe Chef::Provider::Service::Macosx do end it "stops the service via launchctl if service found" do - cmd = "launchctl unload -w " + plist + cmd = "/bin/launchctl unload -w " + plist expect(provider).to receive(:shell_out) .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false) .and_return(0) |