Ignore:
Timestamp:
Feb 3, 2000, 10:39:40 PM (26 years ago)
Author:
sandervl
Message:

JW: Ported Wine security apis

File:
1 edited

Legend:

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

    r97 r2620  
    1 /* $Id: om.cpp,v 1.2 1999-06-10 17:06:46 phaller Exp $ */
     1/* $Id: om.cpp,v 1.3 2000-02-03 21:39:12 sandervl Exp $ */
    22
    33/*
     
    4646 *  NtQuerySecurityObject                [NTDLL]
    4747 */
    48 NTSTATUS WINAPI NtQuerySecurityObject(DWORD x1,
    49                                       DWORD x2,
    50                                       DWORD x3,
    51                                       DWORD x4,
    52                                       DWORD x5)
    53 {
    54   dprintf(("NTDLL: NtQuerySecurityObject(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
    55            x1,
    56            x2,
    57            x3,
    58            x4,
    59            x5));
    60 
    61   return 0;
     48NTSTATUS WINAPI NtQuerySecurityObject(
     49        IN HANDLE Object,
     50        IN SECURITY_INFORMATION RequestedInformation,
     51        OUT PSECURITY_DESCRIPTOR pSecurityDesriptor,
     52        IN ULONG Length,
     53        OUT PULONG ResultLength)
     54{
     55        static SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
     56        static SID_IDENTIFIER_AUTHORITY worldSidAuthority = {SECURITY_WORLD_SID_AUTHORITY};
     57        BYTE Buffer[256];
     58        PISECURITY_DESCRIPTOR_RELATIVE psd = (PISECURITY_DESCRIPTOR_RELATIVE)Buffer;
     59        UINT BufferIndex = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
     60       
     61        dprintf(("(0x%08x,0x%08lx,%p,0x%08lx,%p) stub!\n",
     62        Object, RequestedInformation, pSecurityDesriptor, Length, ResultLength));
     63
     64        RequestedInformation &= 0x0000000f;
     65
     66        if (RequestedInformation & SACL_SECURITY_INFORMATION) return STATUS_ACCESS_DENIED;
     67
     68        ZeroMemory(Buffer, 256);
     69        RtlCreateSecurityDescriptor((PSECURITY_DESCRIPTOR)psd, SECURITY_DESCRIPTOR_REVISION);
     70        psd->Control = SE_SELF_RELATIVE |
     71          ((RequestedInformation & DACL_SECURITY_INFORMATION) ? SE_DACL_PRESENT:0);
     72
     73        /* owner: administrator S-1-5-20-220*/
     74        if (OWNER_SECURITY_INFORMATION & RequestedInformation)
     75        {
     76          PSID psid = (PSID)&(Buffer[BufferIndex]);
     77
     78          psd->Owner = BufferIndex;
     79          BufferIndex += RtlLengthRequiredSid(2);
     80
     81          psid->Revision = SID_REVISION;
     82          psid->SubAuthorityCount = 2;
     83          psid->IdentifierAuthority = localSidAuthority;
     84          psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
     85          psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
     86        }
     87       
     88        /* group: built in domain S-1-5-12 */
     89        if (GROUP_SECURITY_INFORMATION & RequestedInformation)
     90        {
     91          PSID psid = (PSID) &(Buffer[BufferIndex]);
     92
     93          psd->Group = BufferIndex;
     94          BufferIndex += RtlLengthRequiredSid(1);
     95
     96          psid->Revision = SID_REVISION;
     97          psid->SubAuthorityCount = 1;
     98          psid->IdentifierAuthority = localSidAuthority;
     99          psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
     100        }
     101
     102        /* discretionary ACL */
     103        if (DACL_SECURITY_INFORMATION & RequestedInformation)
     104        {
     105          /* acl header */
     106          PACL pacl = (PACL)&(Buffer[BufferIndex]);
     107          PACCESS_ALLOWED_ACE pace;
     108          PSID psid;
     109                         
     110          psd->Dacl = BufferIndex;
     111
     112          pacl->AclRevision = MIN_ACL_REVISION;
     113          pacl->AceCount = 3;
     114          pacl->AclSize = BufferIndex; /* storing the start index temporary */
     115
     116          BufferIndex += sizeof(ACL);
     117         
     118          /* ACE System - full access */
     119          pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
     120          BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
     121
     122          pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
     123          pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
     124          pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
     125          pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER  | 0x3f;
     126          pace->SidStart = BufferIndex;
     127
     128          /* SID S-1-5-12 (System) */
     129          psid = (PSID)&(Buffer[BufferIndex]);
     130
     131          BufferIndex += RtlLengthRequiredSid(1);
     132
     133          psid->Revision = SID_REVISION;
     134          psid->SubAuthorityCount = 1;
     135          psid->IdentifierAuthority = localSidAuthority;
     136          psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
     137         
     138          /* ACE Administrators - full access*/
     139          pace = (PACCESS_ALLOWED_ACE) &(Buffer[BufferIndex]);
     140          BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
     141
     142          pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
     143          pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
     144          pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(2);
     145          pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER  | 0x3f;
     146          pace->SidStart = BufferIndex;
     147
     148          /* S-1-5-12 (Administrators) */
     149          psid = (PSID)&(Buffer[BufferIndex]);
     150
     151          BufferIndex += RtlLengthRequiredSid(2);
     152
     153          psid->Revision = SID_REVISION;
     154          psid->SubAuthorityCount = 2;
     155          psid->IdentifierAuthority = localSidAuthority;
     156          psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
     157          psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
     158         
     159          /* ACE Everyone - read access */
     160          pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
     161          BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
     162
     163          pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
     164          pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
     165          pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
     166          pace->Mask = READ_CONTROL| 0x19;
     167          pace->SidStart = BufferIndex;
     168
     169          /* SID S-1-1-0 (Everyone) */
     170          psid = (PSID)&(Buffer[BufferIndex]);
     171
     172          BufferIndex += RtlLengthRequiredSid(1);
     173
     174          psid->Revision = SID_REVISION;
     175          psid->SubAuthorityCount = 1;
     176          psid->IdentifierAuthority = worldSidAuthority;
     177          psid->SubAuthority[0] = 0;
     178
     179          /* calculate used bytes */
     180          pacl->AclSize = BufferIndex - pacl->AclSize;
     181        }
     182        *ResultLength = BufferIndex;
     183        dprintf(("len=%lu\n", *ResultLength));
     184        if (Length < *ResultLength) return STATUS_BUFFER_TOO_SMALL;
     185        memcpy(pSecurityDesriptor, Buffer, *ResultLength);
     186
     187        return STATUS_SUCCESS;
    62188}
    63189
     
    94220 * Handle   handle to close
    95221 */
    96 //NTSTATUS WINAPI NtClose(
    97 //   HANDLE Handle)
    98 //{
    99 //   FIXME(ntdll,"(0x%08x),stub!\n",Handle);
    100 //   return 1;
    101 //}
     222NTSTATUS WINAPI NtClose(
     223        HANDLE Handle)
     224{
     225        dprintf(("(0x%08x)\n",Handle));
     226        if (CloseHandle(Handle))
     227          return STATUS_SUCCESS;
     228        return STATUS_UNSUCCESSFUL; /*fixme*/
     229}
    102230
    103231
Note: See TracChangeset for help on using the changeset viewer.