test(safeio): cover write-only private create validation
This commit is contained in:
@@ -91,28 +91,16 @@ func TestOwnerOnlySecurityDescriptorNativeCreate(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer parents.Close()
|
defer parents.Close()
|
||||||
security, err := newOwnerOnlySecurityDescriptor()
|
value, err := createWindowsPrivateRegularAtWithAccess(
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("newOwnerOnlySecurityDescriptor() error = %T %v", err, err)
|
|
||||||
}
|
|
||||||
defer security.Close()
|
|
||||||
handle, err := openWindowsRelativeObject(
|
|
||||||
parents.handles[len(parents.handles)-1],
|
parents.handles[len(parents.handles)-1],
|
||||||
target,
|
target,
|
||||||
windows.FILE_GENERIC_READ|windows.FILE_GENERIC_WRITE|windows.DELETE,
|
windows.GENERIC_WRITE,
|
||||||
windows.FILE_CREATE,
|
|
||||||
windows.FILE_NON_DIRECTORY_FILE|windows.FILE_SYNCHRONOUS_IO_NONALERT|windows.FILE_OPEN_REPARSE_POINT,
|
|
||||||
security,
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NtCreateFile() private regular error = %T %v", err, err)
|
t.Fatalf("createWindowsPrivateRegularAtWithAccess() write-only error = %T %v", err, err)
|
||||||
}
|
}
|
||||||
defer windows.CloseHandle(handle)
|
if err := value.Close(); err != nil {
|
||||||
if err := windows.GetFileInformationByHandle(handle, new(windows.ByHandleFileInformation)); err != nil {
|
t.Fatalf("close private regular after write-only create = %T %v", err, err)
|
||||||
t.Fatalf("GetFileInformationByHandle() after private create = %T %v", err, err)
|
|
||||||
}
|
|
||||||
if err := validateOwnerOnlyDACL(handle); err != nil {
|
|
||||||
t.Fatalf("validateOwnerOnlyDACL() after private create = %T %v", err, err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user