fix(safeio): accept Windows effective full-control ACL
This commit is contained in:
@@ -329,10 +329,11 @@ func validateOwnerOnlyDACL(handle windows.Handle) error {
|
|||||||
|
|
||||||
func isOwnerOnlyFullControlMask(mask uint32) bool {
|
func isOwnerOnlyFullControlMask(mask uint32) bool {
|
||||||
// Windows may persist GENERIC_ALL in the ACE or expand it to the file-object
|
// Windows may persist GENERIC_ALL in the ACE or expand it to the file-object
|
||||||
// full-control mask (including FILE_DELETE_CHILD). Both are the same semantic
|
// full-control mask. FILE_ALL_ACCESS is the standard-rights set, synchronize,
|
||||||
// authority; any additional bit remains unsafe.
|
// and all file-specific rights. Both are the same semantic authority; any
|
||||||
const fileDeleteChild = uint32(0x40)
|
// additional or missing bit remains unsafe.
|
||||||
effective := uint32(windows.FILE_GENERIC_READ|windows.FILE_GENERIC_WRITE|windows.FILE_GENERIC_EXECUTE|windows.DELETE) | fileDeleteChild
|
const fileSpecificAll = uint32(0x1ff)
|
||||||
|
effective := uint32(windows.STANDARD_RIGHTS_REQUIRED|windows.SYNCHRONIZE) | fileSpecificAll
|
||||||
return mask == uint32(windows.GENERIC_ALL) || mask == effective
|
return mask == uint32(windows.GENERIC_ALL) || mask == effective
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ func TestPrivateWindowsDACLRejectsPermissiveDirectoryAndRegularFile(t *testing.T
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOwnerOnlyDACLAcceptsWindowsFullControlMask(t *testing.T) {
|
func TestOwnerOnlyDACLAcceptsWindowsFullControlMask(t *testing.T) {
|
||||||
const fileDeleteChild = uint32(0x40)
|
const fileSpecificAll = uint32(0x1ff)
|
||||||
effectiveFullControl := uint32(windows.FILE_GENERIC_READ|windows.FILE_GENERIC_WRITE|windows.FILE_GENERIC_EXECUTE|windows.DELETE) | fileDeleteChild
|
effectiveFullControl := uint32(windows.STANDARD_RIGHTS_REQUIRED|windows.SYNCHRONIZE) | fileSpecificAll
|
||||||
if !isOwnerOnlyFullControlMask(effectiveFullControl) {
|
if !isOwnerOnlyFullControlMask(effectiveFullControl) {
|
||||||
t.Fatalf("effective Windows full-control mask %#x was rejected", effectiveFullControl)
|
t.Fatalf("effective Windows full-control mask %#x was rejected", effectiveFullControl)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user