[QUARTZ_WINETEST]
[reactos.git] / reactos / drivers / filesystems / npfs_new / seinfo.c
1 /*
2 * PROJECT: ReactOS Named Pipe FileSystem
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/filesystems/npfs/seinfo.c
5 * PURPOSE: Pipes Security Information
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "npfs.h"
12
13 // File ID number for NPFS bugchecking support
14 #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_SEINFO)
15
16 /* FUNCTIONS ******************************************************************/
17
18 NTSTATUS
19 NTAPI
20 NpCommonQuerySecurityInfo(IN PDEVICE_OBJECT DeviceObject,
21 IN PIRP Irp)
22 {
23 NODE_TYPE_CODE NodeTypeCode;
24 PIO_STACK_LOCATION IoStack;
25 NTSTATUS Status;
26 PNP_FCB Fcb;
27 PNP_CCB Ccb;
28 ULONG NamedPipeEnd;
29 PAGED_CODE();
30
31 IoStack = IoGetCurrentIrpStackLocation(Irp);
32
33 NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
34 (PVOID*)&Fcb,
35 &Ccb,
36 &NamedPipeEnd);
37 if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
38 if (NodeTypeCode != NPFS_NTC_CCB) return STATUS_INVALID_PARAMETER;
39
40 Status = SeQuerySecurityDescriptorInfo(&IoStack->Parameters.QuerySecurity.SecurityInformation,
41 Irp->UserBuffer,
42 &IoStack->Parameters.QuerySecurity.Length,
43 &Fcb->SecurityDescriptor);
44 if (Status == STATUS_BUFFER_TOO_SMALL)
45 {
46 Irp->IoStatus.Information = IoStack->Parameters.QuerySecurity.Length;
47 Status = STATUS_BUFFER_OVERFLOW;
48 }
49
50 return Status;
51 }
52
53 NTSTATUS
54 NTAPI
55 NpCommonSetSecurityInfo(IN PDEVICE_OBJECT DeviceObject,
56 IN PIRP Irp)
57 {
58 NODE_TYPE_CODE NodeTypeCode;
59 PIO_STACK_LOCATION IoStack;
60 NTSTATUS Status;
61 PNP_FCB Fcb;
62 PNP_CCB Ccb;
63 ULONG NamedPipeEnd;
64 PVOID CachedSecurityDescriptor, SecurityDescriptor;
65 PAGED_CODE();
66
67 IoStack = IoGetCurrentIrpStackLocation(Irp);
68
69 NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
70 (PVOID*)&Fcb,
71 &Ccb,
72 &NamedPipeEnd);
73 if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
74 if (NodeTypeCode != NPFS_NTC_CCB) return STATUS_INVALID_PARAMETER;
75
76 Status = SeSetSecurityDescriptorInfo(NULL,
77 &IoStack->Parameters.SetSecurity.SecurityInformation,
78 IoStack->Parameters.SetSecurity.SecurityDescriptor,
79 &SecurityDescriptor,
80 TRUE,
81 IoGetFileObjectGenericMapping());
82 if (!NT_SUCCESS(Status)) return Status;
83
84 Status = ObLogSecurityDescriptor(SecurityDescriptor, &CachedSecurityDescriptor, TRUE);
85 ExFreePool(SecurityDescriptor);
86
87 if (!NT_SUCCESS(Status)) return Status;
88
89 Fcb->SecurityDescriptor = CachedSecurityDescriptor;
90 ObDereferenceSecurityDescriptor(SecurityDescriptor, 1);
91 return Status;
92 }
93
94 NTSTATUS
95 NTAPI
96 NpFsdQuerySecurityInfo(IN PDEVICE_OBJECT DeviceObject,
97 IN PIRP Irp)
98 {
99 NTSTATUS Status;
100 PAGED_CODE();
101
102 FsRtlEnterFileSystem();
103 NpAcquireExclusiveVcb();
104
105 Status = NpCommonQuerySecurityInfo(DeviceObject, Irp);
106
107 NpReleaseVcb();
108 FsRtlExitFileSystem();
109
110 if (Status != STATUS_PENDING)
111 {
112 Irp->IoStatus.Status = Status;
113 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
114 }
115
116 return Status;
117 }
118
119 NTSTATUS
120 NTAPI
121 NpFsdSetSecurityInfo(IN PDEVICE_OBJECT DeviceObject,
122 IN PIRP Irp)
123 {
124 NTSTATUS Status;
125 PAGED_CODE();
126
127 FsRtlEnterFileSystem();
128 NpAcquireExclusiveVcb();
129
130 Status = NpCommonQuerySecurityInfo(DeviceObject, Irp);
131
132 NpReleaseVcb();
133 FsRtlExitFileSystem();
134
135 if (Status != STATUS_PENDING)
136 {
137 Irp->IoStatus.Status = Status;
138 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
139 }
140
141 return Status;
142 }
143
144 /* EOF */