summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/util/selinux.rb2
-rw-r--r--spec/unit/util/selinux_spec.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/util/selinux.rb b/lib/chef/util/selinux.rb
index 1da3e88913..92d5756552 100644
--- a/lib/chef/util/selinux.rb
+++ b/lib/chef/util/selinux.rb
@@ -47,7 +47,7 @@ class Chef
def restore_security_context(file_path, recursive = false)
if restorecon_path
restorecon_command = recursive ? "#{restorecon_path} -R -r" : "#{restorecon_path} -R"
- restorecon_command += " #{file_path}"
+ restorecon_command += " \"#{file_path}\""
Chef::Log.debug("Restoring selinux security content with #{restorecon_command}")
shell_out!(restorecon_command)
else
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index d87cebf95c..53faba3db3 100644
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -114,7 +114,7 @@ describe Chef::Util::Selinux do
end
describe "when restorecon binary exists on the system" do
- let (:path) { "/path/to/awesome" }
+ let (:path) { "/path/to/awesome directory" }
before do
@restorecon_enabled_path = File.join("/sbin", "restorecon")
@@ -125,7 +125,7 @@ describe Chef::Util::Selinux do
end
it "should call restorecon non-recursive by default" do
- restorecon_command = "#{@restorecon_enabled_path} -R #{path}"
+ restorecon_command = "#{@restorecon_enabled_path} -R \"#{path}\""
@test_instance.should_receive(:shell_out!).twice.with(restorecon_command)
@test_instance.restore_security_context(path)
File.should_not_receive(:executable?)
@@ -133,7 +133,7 @@ describe Chef::Util::Selinux do
end
it "should call restorecon recursive when recursive is set" do
- restorecon_command = "#{@restorecon_enabled_path} -R -r #{path}"
+ restorecon_command = "#{@restorecon_enabled_path} -R -r \"#{path}\""
@test_instance.should_receive(:shell_out!).twice.with(restorecon_command)
@test_instance.restore_security_context(path, true)
File.should_not_receive(:executable?)
@@ -141,7 +141,7 @@ describe Chef::Util::Selinux do
end
it "should call restorecon non-recursive when recursive is not set" do
- restorecon_command = "#{@restorecon_enabled_path} -R #{path}"
+ restorecon_command = "#{@restorecon_enabled_path} -R \"#{path}\""
@test_instance.should_receive(:shell_out!).twice.with(restorecon_command)
@test_instance.restore_security_context(path)
File.should_not_receive(:executable?)