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)
|
||||
}
|
||||
defer parents.Close()
|
||||
security, err := newOwnerOnlySecurityDescriptor()
|
||||
if err != nil {
|
||||
t.Fatalf("newOwnerOnlySecurityDescriptor() error = %T %v", err, err)
|
||||
}
|
||||
defer security.Close()
|
||||
handle, err := openWindowsRelativeObject(
|
||||
value, err := createWindowsPrivateRegularAtWithAccess(
|
||||
parents.handles[len(parents.handles)-1],
|
||||
target,
|
||||
windows.FILE_GENERIC_READ|windows.FILE_GENERIC_WRITE|windows.DELETE,
|
||||
windows.FILE_CREATE,
|
||||
windows.FILE_NON_DIRECTORY_FILE|windows.FILE_SYNCHRONOUS_IO_NONALERT|windows.FILE_OPEN_REPARSE_POINT,
|
||||
security,
|
||||
windows.GENERIC_WRITE,
|
||||
)
|
||||
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 := windows.GetFileInformationByHandle(handle, new(windows.ByHandleFileInformation)); err != nil {
|
||||
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)
|
||||
if err := value.Close(); err != nil {
|
||||
t.Fatalf("close private regular after write-only create = %T %v", err, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user