1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fixed bugs with flipped protection attribute

This commit is contained in:
Hans-Joachim Kliemeck 2015-10-22 14:22:50 +02:00 committed by Matt Clay
parent 632df80276
commit 867b7a9649

View file

@ -38,20 +38,14 @@ Try {
$inheritanceEnabled = !$objACL.AreAccessRulesProtected $inheritanceEnabled = !$objACL.AreAccessRulesProtected
If (($state -eq "present") -And !$inheritanceEnabled) { If (($state -eq "present") -And !$inheritanceEnabled) {
If ($reorganize) {
$objACL.SetAccessRuleProtection($True, $True)
} Else {
$objACL.SetAccessRuleProtection($True, $False)
}
Set-ACL $path $objACL
Set-Attr $result "changed" $true;
}
Elseif (($state -eq "absent") -And $inheritanceEnabled) {
# second parameter is ignored if first=$False # second parameter is ignored if first=$False
$objACL.SetAccessRuleProtection($False, $False) $objACL.SetAccessRuleProtection($False, $False)
If ($reorganize) { If ($reorganize) {
# it wont work without intermediate save, state would be the same
Set-ACL $path $objACL
$objACL = Get-ACL $path
# convert explicit ACE to inherited ACE # convert explicit ACE to inherited ACE
ForEach($inheritedRule in $objACL.Access) { ForEach($inheritedRule in $objACL.Access) {
If (!$inheritedRule.IsInherited) { If (!$inheritedRule.IsInherited) {
@ -59,7 +53,7 @@ Try {
} }
ForEach($explicitRrule in $objACL.Access) { ForEach($explicitRrule in $objACL.Access) {
If ($inheritedRule.IsInherited) { If ($explicitRrule.IsInherited) {
Continue Continue
} }
@ -70,6 +64,16 @@ Try {
} }
} }
Set-ACL $path $objACL
Set-Attr $result "changed" $true;
}
Elseif (($state -eq "absent") -And $inheritanceEnabled) {
If ($reorganize) {
$objACL.SetAccessRuleProtection($True, $True)
} Else {
$objACL.SetAccessRuleProtection($True, $False)
}
Set-ACL $path $objACL Set-ACL $path $objACL
Set-Attr $result "changed" $true; Set-Attr $result "changed" $true;
} }