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 sounds a mess and not the way to do it. An app can't be run as root. You need to make the app call a command line script that has permissions or the app itself uses the macOS dialog to ask for the admin user and password. ALso why are yoiu using an installer?
    – mmmmmm
    Commented Jun 20, 2019 at 22:19
  • Nah, pkgbuild can make this or drop the app and then run a script to set things up.
    – bmike
    Commented Jun 21, 2019 at 0:52

1 Answer 1


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.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .