summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-08-07 12:09:32 +0530
committerVivek Singh <vivek.singh@msystechnologies.com>2019-08-07 12:09:32 +0530
commit104f68b71ba523b7fa4e8a6c28a45449a2a67751 (patch)
tree5546330ce9188826b350f841a0da14547026091f
parentb595d89891d429606b37e2d6ad9bf99cabd473ec (diff)
downloadchef-104f68b71ba523b7fa4e8a6c28a45449a2a67751.tar.gz
Fix chown: Operation not permitted
- Added sudo chown to fix permission denied error. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r--lib/chef/knife/bootstrap/train_connector.rb2
-rw-r--r--spec/unit/knife/bootstrap/train_connector_spec.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/knife/bootstrap/train_connector.rb b/lib/chef/knife/bootstrap/train_connector.rb
index 4290e4593d..a3611470d1 100644
--- a/lib/chef/knife/bootstrap/train_connector.rb
+++ b/lib/chef/knife/bootstrap/train_connector.rb
@@ -128,7 +128,7 @@ class Chef
# running with sudo right now - so this directory would be owned by root.
# File upload is performed over SCP as the current logged-in user,
# so we'll set ownership to ensure that works.
- cmd += " && chown #{config[:user]} '#{dir}'"
+ cmd += " && sudo chown #{config[:user]} '#{dir}'"
run_command!(cmd)
dir
end
diff --git a/spec/unit/knife/bootstrap/train_connector_spec.rb b/spec/unit/knife/bootstrap/train_connector_spec.rb
index ff6dfca5b1..a2b7a571b0 100644
--- a/spec/unit/knife/bootstrap/train_connector_spec.rb
+++ b/spec/unit/knife/bootstrap/train_connector_spec.rb
@@ -163,7 +163,7 @@ describe Chef::Knife::Bootstrap::TrainConnector do
end
it "uses the *nix command to create the temp dir and sets ownership to logged-in user" do
- expected_command = "mkdir -p #{dir} && chown user1 '#{dir}'"
+ expected_command = "mkdir -p #{dir} && sudo chown user1 '#{dir}'"
expect(subject).to receive(:run_command!).with(expected_command)
.and_return double("result", stdout: "\r\n")
expect(subject.temp_dir).to eq(dir)
@@ -171,7 +171,7 @@ describe Chef::Knife::Bootstrap::TrainConnector do
context "with noise in stderr" do
it "uses the *nix command to create the temp dir and sets ownership to logged-in user" do
- expected_command = "mkdir -p #{dir} && chown user1 '#{dir}'"
+ expected_command = "mkdir -p #{dir} && sudo chown user1 '#{dir}'"
expect(subject).to receive(:run_command!).with(expected_command)
.and_return double("result", stdout: "sudo: unable to resolve host hostname.localhost\r\n" + "#{dir}\r\n")
expect(subject.temp_dir).to eq(dir)