Posted on 02-06-2023 07:54 AM
I have a script that is running a lot of commands starting with
su "$currentuser" -c
When the policy is run locally or via Self Service the script runs as expected. When I let it run via check-in, all the lines that start with the above command do not run. Any ideas?
Solved! Go to Solution.
Posted on 02-06-2023 08:51 AM
There is a difference between the natural Jamf check-in that gets started via the LaunchDaemon, versus a manual check-in or policy execution (Self Service, doing sudo jamf policy, etc.) The former gets executed entirely in a root context, whereas the latter ones typically run as the user with elevated rights.
All this is to say, I've seen this type of problem before. What typically has worked for me is to use the launchctl asuser syntax you can find here:
https://scriptingosx.com/2020/08/running-a-command-as-another-user/
Posted on 02-06-2023 08:40 AM
Are you sure that there is always a currentuser during checkin?
Posted on 02-06-2023 08:51 AM
There is a difference between the natural Jamf check-in that gets started via the LaunchDaemon, versus a manual check-in or policy execution (Self Service, doing sudo jamf policy, etc.) The former gets executed entirely in a root context, whereas the latter ones typically run as the user with elevated rights.
All this is to say, I've seen this type of problem before. What typically has worked for me is to use the launchctl asuser syntax you can find here:
https://scriptingosx.com/2020/08/running-a-command-as-another-user/
Posted on 02-08-2023 04:24 AM
If you echo currentuser you might notice that it's root.