[sudo-users] how to preserve functions in script for calling by sudo?

L. A. Walsh sudo at tlinx.org
Fri Jun 2 03:01:59 MDT 2017

I have a script where I need to perform a *few* things as root.

Most of the script doesn't need root, so I sudo as needed.

In order to provide more robust handling for the root
cases, I wrote functions to test various conditions (like
properties of directory I'm in and want to work with as root).

Unfortunately, it seems sudo is removing all of the
functions passed in the environment even though I have
!env_reset in my config file.

How do I allow root to run the functions in my script without having
to run as root all-the-time when the script is running.

Seems like requiring root to be used all the time rather than for
a few tightly controlled functions is considerably more risky.


More information about the sudo-users mailing list