Ignore:
Timestamp:
Dec 19, 1999, 1:25:55 PM (26 years ago)
Author:
sandervl
Message:

Forward SID apis to NTDLL & move some sid apis from advapi32 to ntdll

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/NTDLL/sec.cpp

    r2122 r2134  
    1 /* $Id: sec.cpp,v 1.4 1999-12-18 20:01:14 sandervl Exp $ */
     1/* $Id: sec.cpp,v 1.5 1999-12-19 12:25:55 sandervl Exp $ */
    22
    33/*
     
    2121#include <os2win.h>
    2222#include "ntdll.h"
    23 
    24 /*
    25 #include "windef.h"
    26 #include "winbase.h"
    27 #include "winuser.h"
    28 #include "wine/winestring.h"
    29 #include "heap.h"
    30 #include "winnls.h"
    31 #include "winuser.h"
    32 #include "winerror.h"
    33 #include "stackframe.h"
    34 
    35 #include "winreg.h"
    36 */
    3723
    3824/*
     
    7763  (*pSid)->Revision          = SID_REVISION;
    7864  (*pSid)->SubAuthorityCount = nSubAuthorityCount;
    79   (*pSid)->SubAuthority[0]   = nSubAuthority0;
    80   (*pSid)->SubAuthority[1]   = nSubAuthority1;
    81   (*pSid)->SubAuthority[2]   = nSubAuthority2;
    82   (*pSid)->SubAuthority[3]   = nSubAuthority3;
    83   (*pSid)->SubAuthority[4]   = nSubAuthority4;
    84   (*pSid)->SubAuthority[5]   = nSubAuthority5;
    85   (*pSid)->SubAuthority[6]   = nSubAuthority6;
    86   (*pSid)->SubAuthority[7]   = nSubAuthority7;
    87   memcpy((PVOID)&(*pSid)->IdentifierAuthority, (PVOID)pIdentifierAuthority, sizeof(SID_IDENTIFIER_AUTHORITY));
     65
     66  if (nSubAuthorityCount > 0)
     67        (*pSid)->SubAuthority[0] = nSubAuthority0;
     68  if (nSubAuthorityCount > 1)
     69        (*pSid)->SubAuthority[1] = nSubAuthority1;
     70  if (nSubAuthorityCount > 2)
     71        (*pSid)->SubAuthority[2] = nSubAuthority2;
     72  if (nSubAuthorityCount > 3)
     73        (*pSid)->SubAuthority[3] = nSubAuthority3;
     74  if (nSubAuthorityCount > 4)
     75        (*pSid)->SubAuthority[4] = nSubAuthority4;
     76  if (nSubAuthorityCount > 5)
     77        (*pSid)->SubAuthority[5] = nSubAuthority5;
     78  if (nSubAuthorityCount > 6)
     79        (*pSid)->SubAuthority[6] = nSubAuthority6;
     80  if (nSubAuthorityCount > 7)
     81        (*pSid)->SubAuthority[7] = nSubAuthority7;
     82
     83  if(pIdentifierAuthority)
     84        memcpy((PVOID)&(*pSid)->IdentifierAuthority, (PVOID)pIdentifierAuthority, sizeof(SID_IDENTIFIER_AUTHORITY));
    8885  return TRUE;
    8986}
     
    9693BOOL WINAPI RtlEqualSid(PSID pSid1, PSID pSid2)
    9794{
    98   dprintf(("NTDLL: RtlEqualSid(%08x, %08x) not implemented.\n",
    99            pSid1,
    100            pSid2));
    101 
    102   return TRUE;
    103 }
    104 
     95   dprintf(("NTDLL: RtlEqualSid(%08x, %08x)",
     96            pSid1,
     97            pSid2));
     98
     99   if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
     100        return FALSE;
     101
     102   if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
     103        return FALSE;
     104
     105   if (memcmp(pSid1, pSid2, RtlLengthSid(pSid1)) != 0)
     106        return FALSE;
     107
     108   return TRUE;
     109}
     110
     111
     112/******************************************************************************
     113 * RtlEqualPrefixSid [NTDLL.351]
     114 */
     115BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2)
     116{
     117    if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
     118        return FALSE;
     119
     120    if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
     121        return FALSE;
     122
     123    if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(pSid1->SubAuthorityCount - 1)) != 0)
     124        return FALSE;
     125
     126    return TRUE;
     127}
    105128
    106129/******************************************************************************
     
    109132VOID* WINAPI RtlFreeSid(PSID pSid)
    110133{
    111   dprintf(("NTDLL: RtlFreeSid(%08xh) not implemented.\n",
    112            pSid));
     134  dprintf(("NTDLL: RtlFreeSid(%08xh)", pSid));
    113135
    114136  Heap_Free(pSid);
    115   return (VOID*)TRUE; //??????
     137  return NULL;
    116138}
    117139
     
    171193
    172194
     195/******************************************************************************
     196 * RtlIdentifierAuthoritySid [NTDLL.395]
     197 *
     198 * PARAMS
     199 *   pSid []
     200 */
     201PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
     202{
     203    return &pSid->IdentifierAuthority;
     204}
     205
    173206/**************************************************************************
    174207 *                 RtlSubAuthoritySid          [NTDLL.497]
     
    191224LPBYTE WINAPI RtlSubAuthorityCountSid(PSID psid)
    192225{
    193   dprintf(("NTDLL: RtlSubAUthorityCountSid(%08xh)\n",
    194            psid));
     226  dprintf2(("NTDLL: RtlSubAUthorityCountSid(%08xh)\n",
     227            psid));
    195228
    196229  return ((LPBYTE)psid)+1;
     
    201234 *                 RtlCopySid                     [NTDLL.302]
    202235 */
    203 DWORD WINAPI RtlCopySid(DWORD len,
    204                         PSID  to,
    205                         PSID  from)
     236DWORD WINAPI RtlCopySid(DWORD nDestinationSidLength,
     237                        PSID  pDestinationSid,
     238                        PSID  pSourceSid)
    206239{
    207240  dprintf(("NTDLL: RtlCopySid(%08xh,%08xh,%08xh)\n",
    208            len,
    209            to,
    210            from));
    211 
    212   if (!from)
    213     return 0;
    214 
    215   if (len<(from->SubAuthorityCount*4+8))
    216      return STATUS_BUFFER_TOO_SMALL;
    217 
    218   memmove(to,
    219           from,
    220           from->SubAuthorityCount*4+8);
    221 
    222   return STATUS_SUCCESS;
    223 }
    224 
     241           nDestinationSidLength,
     242           pDestinationSid,
     243           pSourceSid));
     244
     245  if (!RtlValidSid(pSourceSid))
     246        return STATUS_INVALID_PARAMETER;
     247
     248  if (nDestinationSidLength < RtlLengthSid(pSourceSid))
     249        return STATUS_BUFFER_TOO_SMALL;
     250
     251  memcpy(pDestinationSid, pSourceSid, RtlLengthSid(pSourceSid));
     252
     253  return STATUS_SUCCESS;
     254}
     255
     256
     257/******************************************************************************
     258 * RtlValidSid [NTDLL.523]
     259 *
     260 * PARAMS
     261 *   pSid []
     262 */
     263BOOL WINAPI RtlValidSid( PSID pSid )
     264{
     265    if (IsBadReadPtr(pSid, 4))
     266    {
     267        return FALSE;
     268    }
     269
     270    if (pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
     271        return FALSE;
     272
     273    if (!pSid || pSid->Revision != SID_REVISION)
     274        return FALSE;
     275
     276    return TRUE;
     277}
    225278
    226279/*
Note: See TracChangeset for help on using the changeset viewer.