0

Mac's sudo behaviour is unlike everywhere else, of which just like observed in Passing PATH through sudo, sudo would flush PATH every time.

However, I found in Mac, my PATH setting is carried into sudo, which is causing me trouble. Take a look:

$ sudo /bin/sh -x /usr/libexec/locate.updatedb
++ id -u
+ '[' 0 = 0 ']'
+ rc=0
++ sudo -u nobody mktemp -t updatedb
mktemp: too few X's in template ‘updatedb’
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • export FCODES=
  • FCODES=
  • chown nobody

chown: missing operand after ‘nobody’ . . .

$ type mktemp mktemp is /opt/local/libexec/gnubin/mktemp

What's happening is that, I've put GNU tools in PATH before the native ones, for myself only, but that setting get leaked into sudo and the different behaviour of GNU's mktemp breaks the Mac's native locate script.

Can anyone confirm, and
what's the fix please?

xpt
  • 8,651

0 Answers0