summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Hain <elejia@gmail.com>2014-06-17 14:38:12 -0700
committerScott Hain <elejia@gmail.com>2014-06-17 14:38:12 -0700
commit4c4a5d8bb9ab59d392e867e4fb82eb7aefe57bc3 (patch)
treeaa2005e0287d126e0733f76acdf0adcb02df74ef
parent878d5453a48072a60e39257bda7145ffcb7ae520 (diff)
parentbe0e219e51b62aa50b10ad57c7233def9785183a (diff)
downloadchef-4c4a5d8bb9ab59d392e867e4fb82eb7aefe57bc3.tar.gz
Merge pull request #1500 from opscode/shain/spaces_in_selinux_path
Updated selinux path check to allow for directories that have a space in...
-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?)