How to add entitlements to a command line program written in C

Viewed 216

I'm creating a command line program written in the C language in the usual way — compiling with gcc on the command line etc. I want my program to be able to use Hypervisor.framework. In order to do this it needs the com.apple.security.hypervisor entitlement. How can I add this entitlement to my compiled binary in order to allow it to run?

1 Answers

You'll need something like this (although with a different <key> for your entitlement): https://glyph.twistedmatrix.com/2018/01/shipping-pygame-mac-app.html

Pasted here:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
</dict>
</plist>

Save in entitleme.plist, and then run:

codesign --sign - \
    --entitlements entitleme.plist \
    --deep <your-binary> \
    --force

other reference to homebrew issue on codesigning in general: https://github.com/Homebrew/brew/issues/9082

Related