SecTask.h
1 /* 2 * Copyright (c) 2008,2012-2016 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24 #ifndef _SECURITY_SECTASK_H_ 25 #define _SECURITY_SECTASK_H_ 26 27 #include <Security/SecBase.h> 28 29 #include <CoreFoundation/CoreFoundation.h> 30 #include <mach/message.h> 31 32 #include <sys/cdefs.h> 33 34 #if SEC_OS_OSX 35 #include <Security/SecCode.h> 36 #endif /* SEC_OS_OSX */ 37 38 __BEGIN_DECLS 39 40 CF_ASSUME_NONNULL_BEGIN 41 CF_IMPLICIT_BRIDGING_ENABLED 42 43 /*! 44 @typedef SecTaskRef 45 @abstract CFType used for representing a task 46 */ 47 typedef struct CF_BRIDGED_TYPE(id) __SecTask *SecTaskRef; 48 49 /*! 50 @function SecTaskGetTypeID 51 @abstract Returns the type ID for CF instances of SecTask. 52 @result A CFTypeID for SecTask 53 */ 54 CFTypeID SecTaskGetTypeID(void); 55 56 /*! 57 @function SecTaskCreateWithAuditToken 58 @abstract Create a SecTask object for the task that sent the mach message 59 represented by the audit token. 60 @param token The audit token of a mach message 61 @result The newly created SecTask object or NULL on error. The caller must 62 CFRelease the returned object. 63 */ 64 __nullable 65 SecTaskRef SecTaskCreateWithAuditToken(CFAllocatorRef __nullable allocator, audit_token_t token); 66 67 /*! 68 @function SecTaskCreateFromSelf 69 @abstract Create a SecTask object for the current task. 70 @result The newly created SecTask object or NULL on error. The caller must 71 CFRelease the returned object. 72 #ifndef LEFT 73 */ 74 __nullable 75 SecTaskRef SecTaskCreateFromSelf(CFAllocatorRef __nullable allocator); 76 77 /*! 78 @function SecTaskCopyValueForEntitlement 79 @abstract Returns the value of a single entitlement for the represented 80 task. 81 @param task A previously created SecTask object 82 @param entitlement The name of the entitlement to be fetched 83 @param error On a NULL return, this may be contain a CFError describing 84 the problem. This argument may be NULL if the caller is not interested in 85 detailed errors. 86 @result The value of the specified entitlement for the process or NULL if 87 the entitlement value could not be retrieved. The type of the returned 88 value will depend on the entitlement specified. The caller must release 89 the returned object. 90 @discussion A NULL return may indicate an error, or it may indicate that 91 the entitlement is simply not present. In the latter case, no CFError is 92 returned. 93 */ 94 __nullable 95 CFTypeRef SecTaskCopyValueForEntitlement(SecTaskRef task, CFStringRef entitlement, CFErrorRef *error); 96 97 /*! 98 @function SecTaskCopyValuesForEntitlements 99 @abstract Returns the values of multiple entitlements for the represented 100 task. 101 @param task A previously created SecTask object 102 @param entitlements An array of entitlement names to be fetched 103 @param error On a NULL return, this will contain a CFError describing 104 the problem. This argument may be NULL if the caller is not interested in 105 detailed errors. If a requested entitlement is not present for the 106 returned dictionary, the entitlement is not set on the task. The caller 107 must CFRelease the returned value 108 */ 109 __nullable 110 CFDictionaryRef SecTaskCopyValuesForEntitlements(SecTaskRef task, CFArrayRef entitlements, CFErrorRef *error); 111 112 /*! 113 @function SecTaskCopySigningIdentifier 114 @abstract Return the value of the codesigning identifier. 115 @param task A previously created SecTask object 116 @param error On a NULL return, this will contain a CFError describing 117 the problem. This argument may be NULL if the caller is not interested in 118 detailed errors. The caller must CFRelease the returned value 119 */ 120 __nullable 121 CFStringRef SecTaskCopySigningIdentifier(SecTaskRef task, CFErrorRef *error); 122 123 /*! 124 @function SecTaskGetCodeSignStatus 125 @abstract Return the code sign status flags 126 @param task A previously created SecTask object 127 */ 128 129 uint32_t SecTaskGetCodeSignStatus(SecTaskRef task) 130 API_AVAILABLE(ios(10.0), watchos(3.0), tvos(10.0), macCatalyst(11.0)) SPI_AVAILABLE(macos(10.5)); 131 132 133 CF_IMPLICIT_BRIDGING_DISABLED 134 CF_ASSUME_NONNULL_END 135 136 __END_DECLS 137 138 #endif /* !_SECURITY_SECTASK_H_ */