ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

sec.c
Go to the documentation of this file.
00001 /* $Id: sec.c 56451 2012-04-29 21:39:32Z ekohl $
00002  *
00003  * COPYRIGHT:       See COPYING in the top level directory
00004  * PROJECT:         ReactOS system libraries
00005  * FILE:            lib/advapi32/sec/sec.c
00006  * PURPOSE:         Security descriptor functions
00007  * PROGRAMMER:      Ariadne ( ariadne@xs4all.nl)
00008  *                  Steven Edwards ( Steven_Ed4153@yahoo.com )
00009  *                  Andrew Greenwood ( silverblade_uk@hotmail.com )
00010  * UPDATE HISTORY:
00011  *                  Created 01/11/98
00012  */
00013 
00014 #include <advapi32.h>
00015 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
00016 
00017 /*
00018  * @implemented
00019  */
00020 BOOL
00021 WINAPI
00022 GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00023                              PSECURITY_DESCRIPTOR_CONTROL pControl,
00024                              LPDWORD lpdwRevision)
00025 {
00026     NTSTATUS Status;
00027 
00028     Status = RtlGetControlSecurityDescriptor(pSecurityDescriptor,
00029                                              pControl,
00030                                              (PULONG)lpdwRevision);
00031     if (!NT_SUCCESS(Status))
00032     {
00033         SetLastError(RtlNtStatusToDosError(Status));
00034         return FALSE;
00035     }
00036 
00037     return TRUE;
00038 }
00039 
00040 
00041 /*
00042  * @implemented
00043  */
00044 BOOL
00045 WINAPI
00046 GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00047                           LPBOOL lpbDaclPresent,
00048                           PACL *pDacl,
00049                           LPBOOL lpbDaclDefaulted)
00050 {
00051     BOOLEAN DaclPresent;
00052     BOOLEAN DaclDefaulted;
00053     NTSTATUS Status;
00054 
00055     Status = RtlGetDaclSecurityDescriptor(pSecurityDescriptor,
00056                                           &DaclPresent,
00057                                           pDacl,
00058                                           &DaclDefaulted);
00059     *lpbDaclPresent = (BOOL)DaclPresent;
00060     *lpbDaclDefaulted = (BOOL)DaclDefaulted;
00061 
00062     if (!NT_SUCCESS(Status))
00063     {
00064         SetLastError(RtlNtStatusToDosError(Status));
00065         return FALSE;
00066     }
00067 
00068     return TRUE;
00069 }
00070 
00071 
00072 /*
00073  * @implemented
00074  */
00075 BOOL
00076 WINAPI
00077 GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00078                            PSID *pGroup,
00079                            LPBOOL lpbGroupDefaulted)
00080 {
00081     BOOLEAN GroupDefaulted;
00082     NTSTATUS Status;
00083 
00084     Status = RtlGetGroupSecurityDescriptor(pSecurityDescriptor,
00085                                            pGroup,
00086                                            &GroupDefaulted);
00087     *lpbGroupDefaulted = (BOOL)GroupDefaulted;
00088 
00089     if (!NT_SUCCESS(Status))
00090     {
00091         SetLastError(RtlNtStatusToDosError(Status));
00092         return FALSE;
00093     }
00094 
00095     return TRUE;
00096 }
00097 
00098 
00099 /*
00100  * @implemented
00101  */
00102 BOOL
00103 WINAPI
00104 GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00105                            PSID *pOwner,
00106                            LPBOOL lpbOwnerDefaulted)
00107 {
00108     BOOLEAN OwnerDefaulted;
00109     NTSTATUS Status;
00110 
00111     Status = RtlGetOwnerSecurityDescriptor(pSecurityDescriptor,
00112                                            pOwner,
00113                                            &OwnerDefaulted);
00114     *lpbOwnerDefaulted = (BOOL)OwnerDefaulted;
00115 
00116     if (!NT_SUCCESS(Status))
00117     {
00118         SetLastError(RtlNtStatusToDosError(Status));
00119         return FALSE;
00120     }
00121 
00122     return TRUE;
00123 }
00124 
00125 
00126 /*
00127  * @implemented
00128  */
00129 DWORD
00130 WINAPI
00131 GetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor,
00132                                PUCHAR RMControl)
00133 {
00134     if (!RtlGetSecurityDescriptorRMControl(SecurityDescriptor,
00135                                            RMControl))
00136         return ERROR_INVALID_DATA;
00137 
00138     return ERROR_SUCCESS;
00139 }
00140 
00141 
00142 /*
00143  * @implemented
00144  */
00145 BOOL
00146 WINAPI
00147 GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00148                           LPBOOL lpbSaclPresent,
00149                           PACL *pSacl,
00150                           LPBOOL lpbSaclDefaulted)
00151 {
00152     BOOLEAN SaclPresent;
00153     BOOLEAN SaclDefaulted;
00154     NTSTATUS Status;
00155 
00156     Status = RtlGetSaclSecurityDescriptor(pSecurityDescriptor,
00157                                           &SaclPresent,
00158                                           pSacl,
00159                                           &SaclDefaulted);
00160     *lpbSaclPresent = (BOOL)SaclPresent;
00161     *lpbSaclDefaulted = (BOOL)SaclDefaulted;
00162 
00163     if (!NT_SUCCESS(Status))
00164     {
00165         SetLastError(RtlNtStatusToDosError(Status));
00166         return FALSE;
00167     }
00168 
00169     return TRUE;
00170 }
00171 
00172 
00173 /*
00174  * @implemented
00175  */
00176 BOOL
00177 WINAPI
00178 InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00179                              DWORD dwRevision)
00180 {
00181     NTSTATUS Status;
00182 
00183     Status = RtlCreateSecurityDescriptor(pSecurityDescriptor,
00184                                          dwRevision);
00185     if (!NT_SUCCESS(Status))
00186     {
00187         SetLastError(RtlNtStatusToDosError(Status));
00188         return FALSE;
00189     }
00190 
00191     return TRUE;
00192 }
00193 
00194 
00195 /*
00196  * @implemented
00197  */
00198 BOOL
00199 WINAPI
00200 IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor)
00201 {
00202     BOOLEAN Result;
00203 
00204     Result = RtlValidSecurityDescriptor (pSecurityDescriptor);
00205     if (Result == FALSE)
00206         SetLastError(RtlNtStatusToDosError(STATUS_INVALID_SECURITY_DESCR));
00207 
00208     return (BOOL)Result;
00209 }
00210 
00211 
00212 /*
00213  * @implemented
00214  */
00215 BOOL
00216 WINAPI
00217 MakeAbsoluteSD(PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
00218                PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
00219                LPDWORD lpdwAbsoluteSecurityDescriptorSize,
00220                PACL pDacl,
00221                LPDWORD lpdwDaclSize,
00222                PACL pSacl,
00223                LPDWORD lpdwSaclSize,
00224                PSID pOwner,
00225                LPDWORD lpdwOwnerSize,
00226                PSID pPrimaryGroup,
00227                LPDWORD lpdwPrimaryGroupSize)
00228 {
00229     NTSTATUS Status;
00230 
00231     Status = RtlSelfRelativeToAbsoluteSD(pSelfRelativeSecurityDescriptor,
00232                                          pAbsoluteSecurityDescriptor,
00233                                          lpdwAbsoluteSecurityDescriptorSize,
00234                                          pDacl,
00235                                          lpdwDaclSize,
00236                                          pSacl,
00237                                          lpdwSaclSize,
00238                                          pOwner,
00239                                          lpdwOwnerSize,
00240                                          pPrimaryGroup,
00241                                          lpdwPrimaryGroupSize);
00242     if (!NT_SUCCESS(Status))
00243     {
00244         SetLastError(RtlNtStatusToDosError(Status));
00245         return FALSE;
00246     }
00247 
00248     return TRUE;
00249 }
00250 
00251 
00252 /*
00253  * @implemented
00254  */
00255 BOOL
00256 WINAPI
00257 MakeAbsoluteSD2(IN OUT PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
00258                 OUT LPDWORD lpdwBufferSize)
00259 {
00260     NTSTATUS Status;
00261 
00262     Status = RtlSelfRelativeToAbsoluteSD2(pSelfRelativeSecurityDescriptor,
00263                                           lpdwBufferSize);
00264     if (!NT_SUCCESS(Status))
00265     {
00266         SetLastError(RtlNtStatusToDosError(Status));
00267         return FALSE;
00268     }
00269 
00270     return TRUE;
00271 }
00272 
00273 
00274 /*
00275  * @implemented
00276  */
00277 BOOL
00278 WINAPI
00279 MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
00280                    PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
00281                    LPDWORD lpdwBufferLength)
00282 {
00283     NTSTATUS Status;
00284 
00285     Status = RtlAbsoluteToSelfRelativeSD(pAbsoluteSecurityDescriptor,
00286                                          pSelfRelativeSecurityDescriptor,
00287                                          (PULONG)lpdwBufferLength);
00288     if (!NT_SUCCESS(Status))
00289     {
00290         SetLastError(RtlNtStatusToDosError(Status));
00291         return FALSE;
00292     }
00293 
00294     return TRUE;
00295 }
00296 
00297 
00298 /*
00299  * @implemented
00300  */
00301 BOOL
00302 WINAPI
00303 SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00304                              SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
00305                              SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet)
00306 {
00307     NTSTATUS Status;
00308     
00309     Status = RtlSetControlSecurityDescriptor(pSecurityDescriptor,
00310                                              ControlBitsOfInterest,
00311                                              ControlBitsToSet);
00312     if (!NT_SUCCESS(Status))
00313     {
00314         SetLastError(RtlNtStatusToDosError(Status));
00315         return FALSE;
00316     }
00317 
00318     return TRUE;
00319 }
00320 
00321 
00322 /*
00323  * @implemented
00324  */
00325 BOOL
00326 WINAPI
00327 SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00328                           BOOL bDaclPresent,
00329                           PACL pDacl,
00330                           BOOL bDaclDefaulted)
00331 {
00332     NTSTATUS Status;
00333 
00334     Status = RtlSetDaclSecurityDescriptor(pSecurityDescriptor,
00335                                           bDaclPresent,
00336                                           pDacl,
00337                                           bDaclDefaulted);
00338     if (!NT_SUCCESS(Status))
00339     {
00340         SetLastError(RtlNtStatusToDosError(Status));
00341         return FALSE;
00342     }
00343 
00344     return TRUE;
00345 }
00346 
00347 
00348 /*
00349  * @implemented
00350  */
00351 BOOL
00352 WINAPI
00353 SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00354                            PSID pGroup,
00355                            BOOL bGroupDefaulted)
00356 {
00357     NTSTATUS Status;
00358 
00359     Status = RtlSetGroupSecurityDescriptor(pSecurityDescriptor,
00360                                            pGroup,
00361                                            bGroupDefaulted);
00362     if (!NT_SUCCESS(Status))
00363     {
00364         SetLastError(RtlNtStatusToDosError(Status));
00365         return FALSE;
00366     }
00367 
00368     return TRUE;
00369 }
00370 
00371 
00372 /*
00373  * @implemented
00374  */
00375 BOOL
00376 WINAPI
00377 SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00378                            PSID pOwner,
00379                            BOOL bOwnerDefaulted)
00380 {
00381     NTSTATUS Status;
00382 
00383     Status = RtlSetOwnerSecurityDescriptor(pSecurityDescriptor,
00384                                            pOwner,
00385                                            bOwnerDefaulted);
00386     if (!NT_SUCCESS(Status))
00387     {
00388         SetLastError(RtlNtStatusToDosError(Status));
00389         return FALSE;
00390     }
00391 
00392     return TRUE;
00393 }
00394 
00395 
00396 /*
00397  * @implemented
00398  */
00399 DWORD
00400 WINAPI
00401 SetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor,
00402                                PUCHAR RMControl)
00403 {
00404     RtlSetSecurityDescriptorRMControl(SecurityDescriptor,
00405                                       RMControl);
00406 
00407     return ERROR_SUCCESS;
00408 }
00409 
00410 
00411 /*
00412  * @implemented
00413  */
00414 BOOL
00415 WINAPI
00416 SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
00417                           BOOL bSaclPresent,
00418                           PACL pSacl,
00419                           BOOL bSaclDefaulted)
00420 {
00421     NTSTATUS Status;
00422 
00423     Status = RtlSetSaclSecurityDescriptor(pSecurityDescriptor,
00424                                           bSaclPresent,
00425                                           pSacl,
00426                                           bSaclDefaulted);
00427     if (!NT_SUCCESS(Status))
00428     {
00429         SetLastError(RtlNtStatusToDosError(Status));
00430         return FALSE;
00431     }
00432 
00433     return TRUE;
00434 }
00435 
00436 
00437 /*
00438  * @implemented
00439  */
00440 VOID
00441 WINAPI
00442 QuerySecurityAccessMask(IN SECURITY_INFORMATION SecurityInformation,
00443                         OUT LPDWORD DesiredAccess)
00444 {
00445     *DesiredAccess = 0;
00446 
00447     if (SecurityInformation & (OWNER_SECURITY_INFORMATION |
00448                                GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION))
00449     {
00450         *DesiredAccess |= READ_CONTROL;
00451     }
00452 
00453     if (SecurityInformation & SACL_SECURITY_INFORMATION)
00454         *DesiredAccess |= ACCESS_SYSTEM_SECURITY;
00455 }
00456 
00457 
00458 /*
00459  * @implemented
00460  */
00461 VOID
00462 WINAPI
00463 SetSecurityAccessMask(IN SECURITY_INFORMATION SecurityInformation,
00464                       OUT LPDWORD DesiredAccess)
00465 {
00466     *DesiredAccess = 0;
00467 
00468     if (SecurityInformation & (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION))
00469         *DesiredAccess |= WRITE_OWNER;
00470 
00471     if (SecurityInformation & DACL_SECURITY_INFORMATION)
00472         *DesiredAccess |= WRITE_DAC;
00473 
00474     if (SecurityInformation & SACL_SECURITY_INFORMATION)
00475         *DesiredAccess |= ACCESS_SYSTEM_SECURITY;
00476 }
00477 
00478 
00479 /*
00480  * @unimplemented
00481  */
00482 BOOL
00483 WINAPI
00484 ConvertToAutoInheritPrivateObjectSecurity(IN PSECURITY_DESCRIPTOR ParentDescriptor,
00485                                           IN PSECURITY_DESCRIPTOR CurrentSecurityDescriptor,
00486                                           OUT PSECURITY_DESCRIPTOR* NewSecurityDescriptor,
00487                                           IN GUID* ObjectType,
00488                                           IN BOOLEAN IsDirectoryObject,
00489                                           IN PGENERIC_MAPPING GenericMapping)
00490 {
00491     UNIMPLEMENTED;
00492     return FALSE;
00493 }
00494 
00495 
00496 /*
00497  * @unimplemented
00498  */
00499 DWORD
00500 WINAPI
00501 BuildSecurityDescriptorW(IN PTRUSTEE_W pOwner  OPTIONAL,
00502                          IN PTRUSTEE_W pGroup  OPTIONAL,
00503                          IN ULONG cCountOfAccessEntries,
00504                          IN PEXPLICIT_ACCESS_W pListOfAccessEntries  OPTIONAL,
00505                          IN ULONG cCountOfAuditEntries,
00506                          IN PEXPLICIT_ACCESS_W pListOfAuditEntries  OPTIONAL,
00507                          IN PSECURITY_DESCRIPTOR pOldSD  OPTIONAL,
00508                          OUT PULONG pSizeNewSD,
00509                          OUT PSECURITY_DESCRIPTOR* pNewSD)
00510 {
00511     UNIMPLEMENTED;
00512     return FALSE;
00513 }
00514 
00515 
00516 /*
00517  * @unimplemented
00518  */
00519 DWORD
00520 WINAPI
00521 BuildSecurityDescriptorA(IN PTRUSTEE_A pOwner  OPTIONAL,
00522                          IN PTRUSTEE_A pGroup  OPTIONAL,
00523                          IN ULONG cCountOfAccessEntries,
00524                          IN PEXPLICIT_ACCESS_A pListOfAccessEntries  OPTIONAL,
00525                          IN ULONG cCountOfAuditEntries,
00526                          IN PEXPLICIT_ACCESS_A pListOfAuditEntries  OPTIONAL,
00527                          IN PSECURITY_DESCRIPTOR pOldSD  OPTIONAL,
00528                          OUT PULONG pSizeNewSD,
00529                          OUT PSECURITY_DESCRIPTOR* pNewSD)
00530 {
00531     UNIMPLEMENTED;
00532     return FALSE;
00533 }
00534 
00535 /* EOF */

Generated on Sun May 27 2012 04:22:44 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.