[ros-diffs] [gbrunmar] 29837: Added RtlCopySecurityDescriptor

gbrunmar at svn.reactos.org gbrunmar at svn.reactos.org
Tue Oct 23 23:42:04 CEST 2007


Author: gbrunmar
Date: Wed Oct 24 01:42:03 2007
New Revision: 29837

URL: http://svn.reactos.org/svn/reactos?rev=29837&view=rev
Log:
Added RtlCopySecurityDescriptor

Modified:
    trunk/reactos/dll/ntdll/def/ntdll.def
    trunk/reactos/include/ndk/rtlfuncs.h
    trunk/reactos/lib/rtl/sd.c

Modified: trunk/reactos/dll/ntdll/def/ntdll.def
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.def?rev=29837&r1=29836&r2=29837&view=diff
==============================================================================
--- trunk/reactos/dll/ntdll/def/ntdll.def (original)
+++ trunk/reactos/dll/ntdll/def/ntdll.def Wed Oct 24 01:42:03 2007
@@ -361,7 +361,7 @@
 RtlCopyLuid at 8
 RtlCopyLuidAndAttributesArray at 12
 RtlCopyRangeList at 8
-;RtlCopySecurityDescriptor
+RtlCopySecurityDescriptor at 8
 RtlCopySid at 12
 RtlCopySidAndAttributesArray at 28
 RtlCopyString at 8

Modified: trunk/reactos/include/ndk/rtlfuncs.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev=29837&r1=29836&r2=29837&view=diff
==============================================================================
--- trunk/reactos/include/ndk/rtlfuncs.h (original)
+++ trunk/reactos/include/ndk/rtlfuncs.h Wed Oct 24 01:42:03 2007
@@ -911,6 +911,14 @@
 NTSYSAPI
 NTSTATUS
 NTAPI
+RtlCopySecurityDescriptor(
+    IN PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
+    OUT PSECURITY_DESCRIPTOR pDestinationSecurityDescriptor
+);
+
+NTSYSAPI
+NTSTATUS
+NTAPI
 RtlDeleteAce(
     PACL Acl,
     ULONG AceIndex

Modified: trunk/reactos/lib/rtl/sd.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/sd.c?rev=29837&r1=29836&r2=29837&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/sd.c (original)
+++ trunk/reactos/lib/rtl/sd.c Wed Oct 24 01:42:03 2007
@@ -129,6 +129,93 @@
    pSD->Dacl = NULL;
 
    return STATUS_SUCCESS;
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS NTAPI
+RtlCopySecurityDescriptor(IN PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
+                          OUT PSECURITY_DESCRIPTOR pDestinationSecurityDescriptor)
+{
+  PSID Owner, Group;
+  PACL Dacl, Sacl;
+  BOOLEAN Defaulted, Present;
+  DWORD OwnerLength, GroupLength;
+  PSECURITY_DESCRIPTOR srcSD = pSourceSecurityDescriptor;
+  PSECURITY_DESCRIPTOR destSD = pDestinationSecurityDescriptor;
+     
+  if (srcSD->Revision != SECURITY_DESCRIPTOR_REVISION)
+    return STATUS_UNKNOWN_REVISION;
+ 
+  /* Copy non relative dependent data */
+  destSD->Revision = srcSD->Revision;
+  destSD->Sbz1 = srcSD->Sbz1;
+  destSD->Control = srcSD->Control;
+
+  /* Read relative data */
+  RtlGetOwnerSecurityDescriptor(srcSD, &Owner, &Defaulted);
+  OwnerLength = RtlLengthSid(Owner);
+  RtlGetGroupSecurityDescriptor(srcSD, &Group, &Defaulted);
+  GroupLength = RtlLengthSid(Group);
+  RtlGetDaclSecurityDescriptor(srcSD, &Present, &Dacl, &Defaulted);
+  RtlGetSaclSecurityDescriptor(srcSD, &Present, &Sacl, &Defaulted);
+
+  if (srcSD->Control & SE_SELF_RELATIVE)
+  {
+    destSD->Owner = srcSD->Owner;
+    RtlCopySid(OwnerLength, (LPBYTE)destSD + (DWORD_PTR)destSD->Owner, Owner);
+
+    destSD->Group = srcSD->Group;
+    RtlCopySid(GroupLength, (LPBYTE)destSD + (DWORD_PTR)destSD->Group, Group);
+
+	if (srcSD->Control & SE_DACL_PRESENT)
+    {
+	  destSD->Dacl = srcSD->Dacl;
+
+      if(srcSD->Dacl != NULL && RtlValidAcl(srcSD->Dacl))
+	  {
+        RtlCopyMemory(((LPBYTE)destSD + (DWORD_PTR)destSD->Dacl), Dacl, Dacl->AclSize);
+	  }
+    }
+
+	if (srcSD->Control & SE_SACL_PRESENT)
+    {
+      destSD->Sacl = srcSD->Sacl;
+
+      if(srcSD->Sacl != NULL && RtlValidAcl(srcSD->Sacl))
+	  {
+        RtlCopyMemory(((LPBYTE)destSD + (DWORD_PTR)destSD->Sacl), Sacl, Sacl->AclSize);
+	  }
+	}
+  }
+  else
+  {
+    RtlCopySid(OwnerLength, destSD->Owner, Owner);
+    RtlCopySid(GroupLength, destSD->Group, Group);
+
+    if (srcSD->Control & SE_DACL_PRESENT)
+    {
+      destSD->Dacl = RtlAllocateHeap(RtlGetProcessHeap(), 0, Dacl->AclSize);
+
+      if(srcSD->Dacl != NULL && RtlValidAcl(srcSD->Dacl))
+	  {
+        RtlCopyMemory(destSD->Dacl, Dacl, Dacl->AclSize);
+	  }
+	}
+
+    if (srcSD->Control & SE_SACL_PRESENT)
+    {
+      destSD->Sacl = RtlAllocateHeap(RtlGetProcessHeap(), 0, Sacl->AclSize);
+
+      if(srcSD->Sacl != NULL && RtlValidAcl(srcSD->Sacl))
+	  {
+        RtlCopyMemory(destSD->Sacl, Sacl, Sacl->AclSize);
+	  }
+	}
+  }
+
+  return STATUS_SUCCESS;
 }
 
 




More information about the Ros-diffs mailing list