How to create installable app with setuid bit set owned by root
I have inherited a codebase that needs updating, but I don't have the build scripts that created the final pkg file.
The code needs to access a connected USB device (treated as a drive) to read and write bits to, and so it needs escalated privelidges. Due to the non technical nature of the end users, they need to be able to click on the app, and can't be expected to run it from the command line with sudo.
The current installer installs to /Applications/myapp.app, with myapp.app/Contents/MacOS/myapp being set to -rwsr-xr-x root:staff permissions. When installed, this app runs just fine without complaint.
I managed to make a similar pkg file using pkgbuild, and it creates a similar folder in /Applications, with the same permissions, newapp.app/Contents/MacOS/newapp -rwsr-xr-x root:staff. But if I try to run the app without sudo, then I get "The application with bundle ID newapp is running setugid(), which is not allowed."
The mac I have is running macos 10.13.6 The app is python that have been packaged into a binary.
How am I supposed to package this code so it runs as root after it's been installed?
This is just the task suite to a shell script to be packaged with your installer package.
Just package all your files as you do and then review this script only package. Since there are no files, all the steps in this guide will show you how to craft the post install script.
- https://derflounder.wordpress.com/2012/08/15/creating-payload-free-packages-with-pkgbuild/
- http://macinstallers.blogspot.com/2012/07/scripting-in-installer-packages.html
- Configure the OS X Server from .pkg postinstall script
The first guide is the densest, so read it and then hit up the next links, then return to the first for when you’re ready to use pkgbuild
tool to install and script.