[sudo-users] Test for -E support

Todd C. Miller Todd.Miller at sudo.ws
Sat Mar 28 13:54:03 MDT 2020

On Sat, 28 Mar 2020 14:17:23 -0400, Jeffrey Walton wrote:

> Some of the older machines in my testing environment does not support
> -E. The first thing I need is, detect the problem. Preferably the test
> would not use a password. It just tests for the -E option.

You must be running a very old version of sudo on those machines,
the -E flag was introduced 15 years ago in sudo 1.6.8p12.

> So I'm thinking I can check for -E with:
>     NO_E_OPT=`sudo -E -h 2>&1 | grep -i -c illegal`
> And then:
>     # PowerMac
>     $ NO_E_OPT=`sudo -E -h 2>&1 | grep -i -c illegal`; echo $NO_E_OPT
>     1
>     # Ubuntu
>     $ NO_E_OPT=`sudo -E -h 2>&1 | grep -i -c illegal`; echo $NO_E_OPT
>     0
> Does that look about right? Or is there a better way to do this?

What you have should work just fine.  Sudo 1.6.x displays "illegal
option" for unrecognized options where 1.7.0 and higher uses "unknown
option".  This is not an issue, however, as the -E option is supported
by all sudo 1.7.x (and 1.8.x) versions anyway.

All that being said, you might want to consider building a newer
version of sudo on those machines if possible.

 - todd

More information about the sudo-users mailing list