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

Forward SID apis to NTDLL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/advapi32/security.cpp

    r1894 r2133  
    1 /* $Id: security.cpp,v 1.1 1999-11-30 19:41:45 sandervl Exp $ */
     1/* $Id: security.cpp,v 1.2 1999-12-19 12:24:52 sandervl Exp $ */
    22/*
    33 * Win32 security API functions for OS/2
     
    145145
    146146/******************************************************************************
    147  * AllocateAndInitializeSid [ADVAPI32.11]
    148  *
    149  * PARAMS
    150  *   pIdentifierAuthority []
    151  *   nSubAuthorityCount   []
    152  *   nSubAuthority0       []
    153  *   nSubAuthority1       []
    154  *   nSubAuthority2       []
    155  *   nSubAuthority3       []
    156  *   nSubAuthority4       []
    157  *   nSubAuthority5       []
    158  *   nSubAuthority6       []
    159  *   nSubAuthority7       []
    160  *   pSid                 []
    161  */
    162 BOOL WINAPI
    163 AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
    164                           BYTE nSubAuthorityCount,
    165                           DWORD nSubAuthority0, DWORD nSubAuthority1,
    166                           DWORD nSubAuthority2, DWORD nSubAuthority3,
    167                           DWORD nSubAuthority4, DWORD nSubAuthority5,
    168                           DWORD nSubAuthority6, DWORD nSubAuthority7,
    169                           PSID *pSid )
    170 {
    171     if (!(*pSid = (PSID)HeapAlloc(GetProcessHeap(), 0,
    172                                   GetSidLengthRequired(nSubAuthorityCount))))
    173         return FALSE;
    174 
    175     (*pSid)->Revision = SID_REVISION;
    176     if (pIdentifierAuthority)
    177         memcpy(&(*pSid)->IdentifierAuthority, pIdentifierAuthority,
    178                sizeof (SID_IDENTIFIER_AUTHORITY));
    179     *GetSidSubAuthorityCount(*pSid) = nSubAuthorityCount;
    180 
    181     if (nSubAuthorityCount > 0)
    182         *GetSidSubAuthority(*pSid, 0) = nSubAuthority0;
    183     if (nSubAuthorityCount > 1)
    184         *GetSidSubAuthority(*pSid, 1) = nSubAuthority1;
    185     if (nSubAuthorityCount > 2)
    186         *GetSidSubAuthority(*pSid, 2) = nSubAuthority2;
    187     if (nSubAuthorityCount > 3)
    188         *GetSidSubAuthority(*pSid, 3) = nSubAuthority3;
    189     if (nSubAuthorityCount > 4)
    190         *GetSidSubAuthority(*pSid, 4) = nSubAuthority4;
    191     if (nSubAuthorityCount > 5)
    192         *GetSidSubAuthority(*pSid, 5) = nSubAuthority5;
    193     if (nSubAuthorityCount > 6)
    194         *GetSidSubAuthority(*pSid, 6) = nSubAuthority6;
    195     if (nSubAuthorityCount > 7)
    196         *GetSidSubAuthority(*pSid, 7) = nSubAuthority7;
    197 
    198     return TRUE;
    199 }
    200 
    201 /******************************************************************************
    202  * FreeSid [ADVAPI32.42]
    203  *
    204  * PARAMS
    205  *   pSid []
    206  */
    207 PVOID WINAPI
    208 FreeSid( PSID pSid )
    209 {
    210     HeapFree( GetProcessHeap(), 0, pSid );
    211     return NULL;
    212 }
    213 
    214 /******************************************************************************
    215147 * CopySid [ADVAPI32.24]
    216148 *
     
    223155CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
    224156{
    225 
    226     if (!IsValidSid(pSourceSid))
    227         return FALSE;
    228 
    229     if (nDestinationSidLength < GetLengthSid(pSourceSid))
    230         return FALSE;
    231 
    232     memcpy(pDestinationSid, pSourceSid, GetLengthSid(pSourceSid));
    233 
    234     return TRUE;
     157        CallWin32ToNt (RtlCopySid( nDestinationSidLength, pDestinationSid, pSourceSid));
    235158}
    236159
     
    244167IsValidSid( PSID pSid )
    245168{
    246     if (IsBadReadPtr(pSid, 4))
    247     {
    248         WARN_(security)("(%p): invalid pointer!", pSid);
    249         return FALSE;
    250     }
    251 
    252     if (pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
    253         return FALSE;
    254 
    255     if (!pSid || pSid->Revision != SID_REVISION)
    256         return FALSE;
    257 
    258     return TRUE;
     169        CallWin32ToNt (RtlValidSid( pSid));
    259170}
    260171
     
    269180EqualSid( PSID pSid1, PSID pSid2 )
    270181{
    271     if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
    272         return FALSE;
    273 
    274     if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
    275         return FALSE;
    276 
    277     if (memcmp(pSid1, pSid2, GetLengthSid(pSid1)) != 0)
    278         return FALSE;
    279 
    280     return TRUE;
     182        CallWin32ToNt (RtlEqualSid( pSid1, pSid2));
    281183}
    282184
     
    284186 * EqualPrefixSid [ADVAPI32.39]
    285187 */
    286 BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2) {
    287     if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
    288         return FALSE;
    289 
    290     if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
    291         return FALSE;
    292 
    293     if (memcmp(pSid1, pSid2, GetSidLengthRequired(pSid1->SubAuthorityCount - 1))
    294  != 0)
    295         return FALSE;
    296 
    297     return TRUE;
    298 }
    299 
    300 /******************************************************************************
    301  * GetSidLengthRequired [ADVAPI32.63]
    302  *
    303  * PARAMS
    304  *   nSubAuthorityCount []
    305  */
    306 DWORD WINAPI
    307 GetSidLengthRequired( BYTE nSubAuthorityCount )
    308 {
    309     return sizeof (SID) + (nSubAuthorityCount - 1) * sizeof (DWORD);
     188BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
     189{
     190        CallWin32ToNt (RtlEqualPrefixSid( pSid1, pSid2));
    310191}
    311192
     
    320201                    BYTE nSubAuthorityCount)
    321202{
    322     int i;
    323 
    324     pSid->Revision = SID_REVISION;
    325     if (pIdentifierAuthority)
    326         memcpy(&pSid->IdentifierAuthority, pIdentifierAuthority,
    327                sizeof (SID_IDENTIFIER_AUTHORITY));
    328     *GetSidSubAuthorityCount(pSid) = nSubAuthorityCount;
    329 
    330     for (i = 0; i < nSubAuthorityCount; i++)
    331         *GetSidSubAuthority(pSid, i) = 0;
    332 
    333     return TRUE;
    334 }
    335 
    336 /******************************************************************************
    337  * GetSidIdentifierAuthority [ADVAPI32.62]
    338  *
    339  * PARAMS
    340  *   pSid []
    341  */
    342 PSID_IDENTIFIER_AUTHORITY WINAPI
    343 GetSidIdentifierAuthority( PSID pSid )
    344 {
    345     return &pSid->IdentifierAuthority;
    346 }
    347 
    348 /******************************************************************************
    349  * GetSidSubAuthority [ADVAPI32.64]
    350  *
    351  * PARAMS
    352  *   pSid          []
    353  *   nSubAuthority []
    354  */
    355 PDWORD WINAPI
    356 GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
    357 {
    358     return &pSid->SubAuthority[nSubAuthority];
    359 }
    360 
    361 /******************************************************************************
    362  * GetSidSubAuthorityCount [ADVAPI32.65]
    363  *
    364  * PARAMS
    365  *   pSid []
    366  */
    367 PUCHAR WINAPI
    368 GetSidSubAuthorityCount (PSID pSid)
    369 {
    370     return &pSid->SubAuthorityCount;
    371 }
    372 
    373 /******************************************************************************
    374  * GetLengthSid [ADVAPI32.48]
    375  *
    376  * PARAMS
    377  *   pSid []
    378  */
    379 DWORD WINAPI
    380 GetLengthSid (PSID pSid)
    381 {
    382     return GetSidLengthRequired( * GetSidSubAuthorityCount(pSid) );
     203        CallWin32ToNt (RtlInitializeSid( pSid, pIdentifierAuthority, nSubAuthorityCount));
    383204}
    384205
Note: See TracChangeset for help on using the changeset viewer.