Skip to content

Commit

Permalink
Clean up Security methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lundman committed Mar 6, 2019
1 parent 56ca0bb commit bd9184e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ZFSin/zfs/module/zfs/zfs_vnops_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -4798,9 +4798,13 @@ NTSTATUS query_security(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATIO
&sd);
VN_RELE(vp);

Irp->IoStatus.Information = buflen;
if (Status == STATUS_BUFFER_TOO_SMALL) {
Status = STATUS_BUFFER_OVERFLOW;
Irp->IoStatus.Information = buflen;
} else if (NT_SUCCESS(Status)) {
Irp->IoStatus.Information = IrpSp->Parameters.QuerySecurity.Length;
} else {
Irp->IoStatus.Information = 0;
}

return Status;
Expand Down Expand Up @@ -4833,16 +4837,14 @@ NTSTATUS set_security(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION
Status = SeSetSecurityDescriptorInfo(NULL,
&IrpSp->Parameters.SetSecurity.SecurityInformation,
IrpSp->Parameters.SetSecurity.SecurityDescriptor,
(void**)&oldsd,
(void **)&vp->security_descriptor,
PagedPool,
IoGetFileObjectGenericMapping());

if (!NT_SUCCESS(Status))
goto err;

// Here, 'oldsd' is now ptr to new sd, and vnode_security() one needs to be freed
ExFreePool(vnode_security(vp));
vnode_setsecurity(vp, oldsd);
ExFreePool(oldsd);

// Now, we might need to update ZFS ondisk information
vattr_t vattr;
Expand Down Expand Up @@ -4876,6 +4878,9 @@ NTSTATUS set_security(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION
}

Irp->IoStatus.Information = 0;
zfs_send_notify(zfsvfs, zp->z_name_cache, zp->z_name_offset,
FILE_NOTIFY_CHANGE_SECURITY,
FILE_ACTION_MODIFIED);

err:
VN_RELE(vp);
Expand Down

0 comments on commit bd9184e

Please sign in to comment.