branch update for HEAD-2003091401
[reactos.git] / lib / ntdll / rtl / sd.c
index 05f3471..1511d00 100644 (file)
@@ -37,6 +37,9 @@ RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
   return(STATUS_SUCCESS);
 }
 
+/*
+ * @implemented
+ */
 ULONG STDCALL
 RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
 {
@@ -97,6 +100,9 @@ RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                             PBOOLEAN DaclPresent,
@@ -141,6 +147,9 @@ RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                             BOOLEAN DaclPresent,
@@ -171,6 +180,9 @@ RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN STDCALL
 RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
 {
@@ -240,6 +252,9 @@ RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                              PSID Owner,
@@ -262,6 +277,9 @@ RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
    return(STATUS_SUCCESS);
 }
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                              PSID* Owner,
@@ -298,6 +316,9 @@ RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
    return(STATUS_SUCCESS);
 }
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlSetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                              PSID Group,
@@ -320,6 +341,9 @@ RtlSetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
    return(STATUS_SUCCESS);
 }
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlGetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                              PSID* Group,
@@ -456,6 +480,9 @@ RtlpQuerySecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlMakeSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
                      PSECURITY_DESCRIPTOR RelSD,
@@ -536,6 +563,9 @@ RtlMakeSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlAbsoluteToSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
                            PSECURITY_DESCRIPTOR RelSD,
@@ -551,6 +581,9 @@ RtlAbsoluteToSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlGetControlSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                                PSECURITY_DESCRIPTOR_CONTROL Control,
@@ -569,6 +602,9 @@ RtlGetControlSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                             PBOOLEAN SaclPresent,
@@ -612,6 +648,9 @@ RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
    return(STATUS_SUCCESS);
 }
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlSetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
                             BOOLEAN SaclPresent,
@@ -641,6 +680,10 @@ RtlSetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
    return(STATUS_SUCCESS);
 }
 
+
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlSelfRelativeToAbsoluteSD(PSECURITY_DESCRIPTOR RelSD,
                            PSECURITY_DESCRIPTOR AbsSD,
@@ -654,7 +697,53 @@ RtlSelfRelativeToAbsoluteSD(PSECURITY_DESCRIPTOR RelSD,
                            PSID Group,
                            PDWORD GroupSize)
 {
-   UNIMPLEMENTED;
+  ULONG OwnerLength;
+  ULONG GroupLength;
+  ULONG DaclLength;
+  ULONG SaclLength;
+  PSID pOwner;
+  PSID pGroup;
+  PACL pDacl;
+  PACL pSacl;
+
+  if (!(RelSD->Control & SE_SELF_RELATIVE))
+    return STATUS_BAD_DESCRIPTOR_FORMAT;
+
+  RtlpQuerySecurityDescriptor (RelSD,
+                              &pOwner,
+                              &OwnerLength,
+                              &pGroup,
+                              &GroupLength,
+                              &pDacl,
+                              &DaclLength,
+                              &pSacl,
+                              &SaclLength);
+
+  if (OwnerLength > *OwnerSize ||
+      GroupLength > *GroupSize ||
+      DaclLength > *DaclSize ||
+      SaclLength > *SaclSize)
+    return STATUS_BUFFER_TOO_SMALL;
+
+  memmove (Owner, pOwner, OwnerLength);
+  memmove (Group, pGroup, GroupLength);
+  memmove (Dacl, pDacl, DaclLength);
+  memmove (Sacl, pSacl, SaclLength);
+
+  memmove (AbsSD, RelSD, sizeof (SECURITY_DESCRIPTOR));
+
+  AbsSD->Control &= ~SE_SELF_RELATIVE;
+  AbsSD->Owner = Owner;
+  AbsSD->Group = Group;
+  AbsSD->Dacl = Dacl;
+  AbsSD->Sacl = Sacl;
+
+  *OwnerSize = OwnerLength;
+  *GroupSize = GroupLength;
+  *DaclSize = DaclLength;
+  *SaclSize = SaclLength;
+
+  return STATUS_SUCCESS;
 }
 
 /* EOF */