Deploy package file by changing ownership from system to user.

slashnext
New Contributor II

Hello,
i have a package file which contains an .app binary with it, I need user level ownership for .app in order to perform some execution which is not possible without authorization with system ownership. Currently when i deploy the package jamf deploys it with system ownership. I have a post installation script in my package file which change the ownership from system to user but this script does not seems to work. I tried to run the package locally and in this case the script executes successfully. Is there any way to change ownership of the payload?
3e991cc6074644298d610615a0dabd47

5 REPLIES 5

Tribruin
Contributor III
Contributor III

How are you determining the user when changing ownership? Remember that Jamf installs run as root, not as the user.

You might want to post your post-install script (sanitized if necessary) so others can take a look.

slashnext
New Contributor II

@RBlount I am getting user in post script and adding ownership for this user. Attached is the script which i am using.
6e68cc6dbcab47f6a27d6a0f9913fdf7

mm2270
Legendary Contributor II

You can't use $USER in a Jamf Pro script, at least not for what you're trying to do. As @RBlount mentioned, this gets the user running the script, which would be root, not the logged in user account. Use something like this to get the logged in user

LoggedInUser=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ {print $3}')

slashnext
New Contributor II

@mm2270 do i need to install this utility "scutil" or is it available by default in all OSX?

mm2270
Legendary Contributor II

@slashnext It's there by default in all versions of macOS.