Skip to content

Commit

Permalink
(PUP-1133) Reset permission on Windows test files
Browse files Browse the repository at this point in the history
 - Previously some security tests manipulated file permissions in
   a way that made it impossible for the top-level spec temp file
   cleanup to be performed.  This patch resets the files after runs.
  • Loading branch information
Iristyle committed Dec 20, 2013
1 parent ba09bfe commit 776767c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/integration/type/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,19 @@ def expects_at_least_one_inherited_system_ace_grants_full_access(path)
catalog.add_resource @directory
end

def grant_everyone_full_access(path)
sd = Puppet::Util::Windows::Security.get_security_descriptor(path)
sd.dacl.allow(
'S-1-1-0', #everyone
Windows::File::FILE_ALL_ACCESS,
Windows::File::OBJECT_INHERIT_ACE | Windows::File::CONTAINER_INHERIT_ACE)
Puppet::Util::Windows::Security.set_security_descriptor(path, sd)
end

after :each do
grant_everyone_full_access(dir)
end

describe "when source permissions are ignored" do
before :each do
@directory[:source_permissions] = :ignore
Expand Down
18 changes: 18 additions & 0 deletions spec/integration/util/windows/security_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def set_group_depending_on_current_user(path)
end
end

def grant_everyone_full_access(path)
sd = winsec.get_security_descriptor(path)
everyone = 'S-1-1-0'
inherit = WindowsSecurityTester::OBJECT_INHERIT_ACE | WindowsSecurityTester::CONTAINER_INHERIT_ACE
sd.dacl.allow(everyone, Windows::File::FILE_ALL_ACCESS, inherit)
winsec.set_security_descriptor(path, sd)
end

shared_examples_for "only child owner" do
it "should allow child owner" do
winsec.set_owner(sids[:guest], parent)
Expand Down Expand Up @@ -616,6 +624,11 @@ def set_group_depending_on_current_user(path)
path
end

after :each do
# allow temp files to be cleaned up
grant_everyone_full_access(parent)
end

it_behaves_like "a securable object" do
def check_access(mode, path)
if (mode & WindowsSecurityTester::S_IRUSR).nonzero?
Expand Down Expand Up @@ -682,6 +695,11 @@ def check_delete(path)
path
end

after :each do
# allow temp files to be cleaned up
grant_everyone_full_access(parent)
end

it_behaves_like "a securable object" do
def check_access(mode, path)
if (mode & WindowsSecurityTester::S_IRUSR).nonzero?
Expand Down

0 comments on commit 776767c

Please sign in to comment.