diff options
author | Tim Smith <tsmith@chef.io> | 2021-04-02 09:34:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 09:34:00 -0700 |
commit | 62d44e8647bbe7cb0642293d771a8889aafd98db (patch) | |
tree | 6c3045676047f0670271980e1d3e599ad555dad0 | |
parent | d699e3c8de549a0f9c6d925c0a1461160a8ea317 (diff) | |
parent | ec09e63ec43f7a9674ee657ab7a1707f0e139c73 (diff) | |
download | chef-62d44e8647bbe7cb0642293d771a8889aafd98db.tar.gz |
Merge pull request #11282 from chef/htop_16
use full path for launchctl calls
-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 2152789a6e..206c67e277 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 0e173050d0..9450c760a0 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 6cc0f88725..6b86265a04 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) |