General script question - which "rm" is used by Jamf script?

mucgyver-old
New Contributor III

Hi all.
I would like to implement saferm (https://launchpad.net/safe-rm) to prevent accidental deletion of user homes and mounted network drives, just to name a few, via jamf script.
However, if I crackbrainly and accidentally run a jamf script with " rm -rf / " in it, which rm would be actually called by this?
/usr/local/bin/rm?
/usr/bin/rm?
The first mentioned in the /etc/paths file (should be by default /usr/local/bin/rm)?
Any other I do not think about?
I get different results running this command locally and remotely via jamf (after installation of saferm in /usr/local/bin/rm), even if I give the complete path in the script /usr/local/bin/rm).
Any ideas?
Best regards
Christian

2 REPLIES 2

ryan_ball
Valued Contributor

@cbednarzwirecard In your scripts, just use the full path of the binary that you intend to be called, don't just specify rm.

talkingmoose
Moderator
Moderator

Ryan's answer is best. Rather than assuming you know the shell and its paths that another account will use, prepending the command with its full path in your scripts lets you call the binary you expect.

To find the path to any binary that comes with a Mac, use which followed by the command in Terminal:

$ which rm
/bin/rm