Voucher
A voucher.
class Voucher
Overview
A voucher is a kernel object that can be attached to a message using the Darwin/mach_msg_header_t/voucherPort
property in the message header. A voucher is created from an array of command recipes. The commands are executed in sequence on an empty voucher to result in the desired voucher. Other subsequent commands can then be executed on the voucher.
Attributes
Vouchers contain attributes that are each managed in the kernel by an attribute manager. These attributes managers provide the functionality for initial recipe commands, as well as any subsequent commands executed on the voucher.
There are six attributes managers that are “well-known” to the kernel:
Attribute Manager | Recipe Commands | Subsequent Commands |
---|---|---|
atm | VoucherATMAttributeRecipeCommand | VoucherATMAction |
importance | VoucherImportanceAttributeRecipeCommand | VoucherImportanceAction |
bank | VoucherBankAttributeRecipeCommand | VoucherBankAction |
pthreadPriority | VoucherPthreadPriorityAttributeRecipeCommand | Not Supported |
userData | VoucherUserDataAttributeRecipeCommand | Not Supported |
test | Same as userData | Same as userData |
Creating Vouchers
init(recipes: consuming [Mach.VoucherAttributeRecipe]
) throws Creates a new voucher with the given recipes.
Representing No Voucher
class var Nil: `Self`
A voucher that represents no voucher.
Getting The Recipes In A Voucher
var recipes: [Mach.VoucherAttributeRecipe]
The recipes in the voucher.
func recipe(forKey: Mach.VoucherAttributeKey
) throws -> mach_voucher_attr_recipe_t Gets a recipe from the voucher.
Operating On A Voucher
func executeCommand(key: Mach.VoucherAttributeKey, command: any Mach.VoucherAttributeCommand, input: BitwiseCopyable?
) throws -> Data? Executes a command on the voucher.