diff --git a/tools/collector/scripts/collect b/tools/collector/scripts/collect index c35b7a6b..fddb4e43 100755 --- a/tools/collector/scripts/collect +++ b/tools/collector/scripts/collect @@ -1086,6 +1086,38 @@ pw=${pw/$/\\$} # replace '$' with '\$' pw=${pw/\"/\\\"} # replace '"' with '\"' +function password_test() +{ + local dir=${1} + +/usr/bin/expect << EOF + log_user ${USER_LOG_MODE} + spawn bash -i + set timeout 10 + expect -re $ + send "sudo cat /usr/local/sbin/expect_done\n" + expect { + "assword:" { + send "${pw}\r" + expect { + "${cmd_done_sig}" { exit ${PASS} } + "${pw_error}" { exit ${FAIL_PASSWORD} } + timeout { exit ${FAIL_TIMEOUT1} } + } + } + "${pw_error}" { exit ${FAIL_PASSWORD} } + timeout { exit ${FAIL_TIMEOUT} } + } +EOF + local rc=${?} + if [ ${rc} -ne ${PASS} ] ; then + report_error "Timeout waiting for password prompt. Passwordless sudo may be enabled. Please disable and retry." ${rc} + collect_exit ${rc} + fi +} + +password_test + ########################################################################### # # Name : check_host_reachable