I'm hoping there exists something like sudo for AppArmor, so I can run something in a context like:
aado -hat my-hat command arg arg arg
Does this exist?
I think this can be done by creating hardlinks to e.g. /bin/bash. You then create a profile for /bin/bash-my-hat and start your command:
/bin/bash-my-hat -c command '$0' arg1 arg2
The aa-exec
command can run a command with a specific named profile (or unconfined). For example:
aa-exec -p my-profile -- command arg arg arg
aa-exec -p unconfined -- command arg arg arg