diff options
author | Thom May <thom@chef.io> | 2015-05-05 17:52:13 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2015-05-05 17:52:13 +0100 |
commit | 7f56dbd49e32149a98f7e1a3873a65b94d8e627c (patch) | |
tree | 05096a5ecdd241aa18ea0e5d1485e983570c6570 | |
parent | f74c9a16ed3a9d14bc1dfb6e9d34601c6afbd6a9 (diff) | |
parent | d52e13ea77589ba0209ba48454b78c60674a7e79 (diff) | |
download | chef-7f56dbd49e32149a98f7e1a3873a65b94d8e627c.tar.gz |
Merge branch 'minshallj-minshallj/keep_suid_bit'
-rw-r--r-- | lib/chef/file_access_control/unix.rb | 5 | ||||
-rw-r--r-- | spec/support/shared/functional/securable_resource.rb | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/chef/file_access_control/unix.rb b/lib/chef/file_access_control/unix.rb index 472f30b752..c53d832414 100644 --- a/lib/chef/file_access_control/unix.rb +++ b/lib/chef/file_access_control/unix.rb @@ -197,6 +197,8 @@ class Chef # the user has specified a permission, and it does not match the file, so fix the permission Chef::Log.debug("found target_mode != current_mode, updating mode") return true + elsif suid_bit_set? and (should_update_group? or should_update_owner?) + return true else Chef::Log.debug("found target_mode == current_mode, not updating mode") # the user has specified a permission, but it matches the file, so behave idempotently @@ -280,6 +282,9 @@ class Chef return nil end + def suid_bit_set? + return target_mode & 04000 > 0 + end end end end diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb index e016bb685d..cd8c2a166b 100644 --- a/spec/support/shared/functional/securable_resource.rb +++ b/spec/support/shared/functional/securable_resource.rb @@ -231,6 +231,24 @@ shared_examples_for "a securable resource with existing target" do expect(resource.updated_by_last_action?).to eq(expect_updated?) end end + + describe "when setting the suid bit", :requires_root do + before do + @suid_mode = 04776 + resource.mode @suid_mode + resource.run_action(:create) + end + + it "should set the suid bit" do + expect(File.lstat(path).mode & 007777).to eq(@suid_mode & 007777) + end + + it "should retain the suid bit when updating the user" do + resource.user 1338 + resource.run_action(:create) + expect(File.lstat(path).mode & 007777).to eq(@suid_mode & 007777) + end + end end context "on Windows", :windows_only do |