Skip to main content
Question

pushing scripts as user rather than root?


Forum|alt.badge.img+6
  • Contributor
  • 63 replies

Does anyone have a way to run a script on a remote computer via casper as the logged-in user?
I'm trying to quit the Junos Pulse tray in the menu bar so that the connection URL can be updated. Although locally I have no problem using LAUNCHCTL UNLOAD ... to unload it to make it quit, if I use the same command in a policy, it doesn't work because that plist isn't active under the root user.
I'v also run into other situations where it would be good to run a script as the logged in user rather than root before as well.

is there way?

3 replies

Forum|alt.badge.img+13

the pulse client includes a method for importing a config file. if you do this, you shouldn't need to kill the menu bar app.

for instance, if you drop the config file under /etc, you can do this:

/Applications/Junos Pulse.app/Contents/Plugins/JamUI/jamCommand -importFile /private/etc/configfile.jnprpreconfig

that will update the connection url.


Forum|alt.badge.img+12
  • Contributor
  • 417 replies
  • July 2, 2012

Casper can run scripts in the user context by using the su $3 command. su for switch user, $3 is the username of the current console user.

Careful though, unless you are running a POLICY, the UID of the casper admin will not be 0, and you will be prompted for a password when invoking su. Only root can su to any other user account with no password.

Use the -c option to run only a single command as a particular user


Forum|alt.badge.img+12
  • Contributor
  • 529 replies
  • July 3, 2012

You need to tell launchctl what the user PID is of the current loginwindow console, so you'll need something like:

userPID=`ps -ef | grep "loginwindow console" | grep -v grep | awk '{print $2}'`
launchctl bsexec $userPID su $3 -c 'launchctl unload [the thing you want to unload]'

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings