summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnson <jeff@jeffs-tech.com>2021-03-09 11:26:56 -0800
committerJeff Johnson <jeff@jeffs-tech.com>2021-03-09 11:26:56 -0800
commit9fc122d4ee60fa0f3c16f3b72169634c9aa5cbef (patch)
tree4306fc59349fa7014ba122a7a7bfc2ceb87d6025
parentd17e4f2ffbb9d152d8f4d30c2abd2d1356dcac56 (diff)
downloadchef-9fc122d4ee60fa0f3c16f3b72169634c9aa5cbef.tar.gz
use full path for launchctl calls
Signed-off-by: Jeff Johnson <jeff@jeffs-tech.com>
-rw-r--r--lib/chef/provider/service/macosx.rb6
-rw-r--r--lib/chef/resource/chef_client_launchd.rb2
-rw-r--r--spec/unit/provider/service/macosx_spec.rb6
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)