From dd1528c829ea97faa04157e030270b27ae8d8246 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Fri, 21 Aug 2015 22:24:45 -0400 Subject: [PATCH] [test suite] set sudo path on the fwknopd command line --- server/config_init.c | 6 ++++-- test/test-fwknop.pl | 5 +++++ test/tests/basic_operations.pl | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/config_init.c b/server/config_init.c index fcf5d197..d7b50440 100644 --- a/server/config_init.c +++ b/server/config_init.c @@ -1262,7 +1262,7 @@ config_init(fko_srv_options_t *opts, int argc, char **argv) else { log_msg(LOG_ERR, - "[*] gpg path '%s' could not stat()/does not exist?", + "[*] gpg path '%s' could not stat()/not executable?", optarg); clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE); } @@ -1330,7 +1330,7 @@ config_init(fko_srv_options_t *opts, int argc, char **argv) else { log_msg(LOG_ERR, - "[*] gpg path '%s' could not stat()/does not exist?", + "[*] sudo path '%s' could not stat()/not executable?", optarg); clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE); } @@ -1448,6 +1448,8 @@ usage(void) " done in the access.conf file).\n" " --gpg-exe - Specify the path to GPG (this is normally done in\n" " the access.conf file).\n" + " --sudo-exe - Specify the path to sudo (the default path is\n" + " /usr/bin/sudo).\n" " --no-firewd-check-support\n" " - Disable test for 'firewall-cmd ... -C' support.\n" " --no-ipt-check-support - Disable test for 'iptables -C' support.\n" diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index 1c8402e7..a3252c24 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -4735,6 +4735,11 @@ sub spa_cmd_exec_cycle() { ### we need to write the access.conf file based on sudo ### requirements &write_sudo_access_conf($test_hr); + + ### make sure the path to sudo is set properly + if ($test_hr->{'fwknopd_cmdline'}) { + $test_hr->{'fwknopd_cmdline'} .= " --sudo-exe $sudo_path"; + } } if (-e $cmd_exec_test_file) { diff --git a/test/tests/basic_operations.pl b/test/tests/basic_operations.pl index 0a1f8415..2cad54df 100644 --- a/test/tests/basic_operations.pl +++ b/test/tests/basic_operations.pl @@ -435,6 +435,22 @@ 'exec_err' => $YES, 'cmdline' => "$fwknopdCmd $default_server_conf_args --gpg-exe /invalid/path" }, + { + 'category' => 'basic operations', + 'subcategory' => 'server', + 'detail' => 'sudo invalid binary path (1)', + 'function' => \&generic_exec, + 'exec_err' => $YES, + 'cmdline' => "$fwknopdCmd $default_server_conf_args --sudo-exe /invalid/path" + }, + { + 'category' => 'basic operations', + 'subcategory' => 'server', + 'detail' => 'sudo invalid binary path (2)', + 'function' => \&generic_exec, + 'exec_err' => $YES, + 'cmdline' => "$fwknopdCmd $default_server_conf_args --sudo-exe /etc/hosts" + }, { 'category' => 'basic operations',