Getting Yaptest to work with Sudo
When you first install yaptest and try to use sudo you might get the following error:
$ sudo yaptest-nmap-udp.pl
ERROR: Environment variable YAPTEST_DBNAME is not set
at /usr/local/lib/site_perl/yaptest.pm line 126
yaptest::new('yaptest') called at /usr/local/bin/yaptest-hosts.pl line 8
(in cleanup) Can't call method "disconnect" on an undefined value at /usr/local/lib/site_perl/yaptest.pm line 3247.
This is because sudo has (very sensibly) unset the environment variable YAPTEST_CONFIG_FILE which in turn prevents YAPTEST_DBNAME getting set. The yaptest scripts no longer know which test they’re supposed to be working on.
The solution is simple. Add an entry like the following into /etc/sudoers:
# Allow users in group users to export specific variables
Defaults:youruser env_keep="DISPLAY YAPTEST_CONFIG_FILE"
This prevents sudo from unsetting the YAPTEST_CONFIG_FILE (and also DISPLAY because that can be a pain too).
Leave a Reply
You must be logged in to post a comment.