@@ -1453,6 +1453,7 @@ fileout() {
14531453
14541454
14551455json_header() {
1456+ local fname_date="$1"
14561457 local fname_prefix
14571458 local filename_provided=false
14581459
@@ -1481,9 +1482,9 @@ json_header() {
14811482 fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
14821483 fi
14831484 if [[ -z "$JSONFILE" ]]; then
1484- JSONFILE="$fname_prefix-$(date +"%Y%m%d-%H%M" .json) "
1485+ JSONFILE="$fname_prefix-${fname_date} .json"
14851486 elif [[ -d "$JSONFILE" ]]; then
1486- JSONFILE="$JSONFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M" .json) "
1487+ JSONFILE="$JSONFILE/${fname_prefix}-${fname_date} .json"
14871488 fi
14881489 # Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
14891490 if "$APPEND" && [[ ! -s "$JSONFILE" ]]; then
@@ -1504,6 +1505,7 @@ json_header() {
15041505
15051506
15061507csv_header() {
1508+ local fname_date="$1"
15071509 local fname_prefix
15081510 local filename_provided=false
15091511
@@ -1529,9 +1531,9 @@ csv_header() {
15291531 fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
15301532 fi
15311533 if [[ -z "$CSVFILE" ]]; then
1532- CSVFILE="${fname_prefix}-$(date +"%Y%m%d-%H%M" .csv) "
1534+ CSVFILE="${fname_prefix}-${fname_date} .csv"
15331535 elif [[ -d "$CSVFILE" ]]; then
1534- CSVFILE="$CSVFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M" .csv) "
1536+ CSVFILE="$CSVFILE/${fname_prefix}-${fname_date} .csv"
15351537 fi
15361538 # Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
15371539 if "$APPEND" && [[ ! -s "$CSVFILE" ]]; then
@@ -1558,6 +1560,7 @@ csv_header() {
15581560################# END JSON file functions. START HTML functions ####################
15591561
15601562html_header() {
1563+ local fname_date="$1"
15611564 local fname_prefix
15621565 local filename_provided=false
15631566
@@ -1586,9 +1589,9 @@ html_header() {
15861589 fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
15871590 fi
15881591 if [[ -z "$HTMLFILE" ]]; then
1589- HTMLFILE="$fname_prefix-$(date +"%Y%m%d-%H%M" .html) "
1592+ HTMLFILE="$fname_prefix-${fname_date} .html"
15901593 elif [[ -d "$HTMLFILE" ]]; then
1591- HTMLFILE="$HTMLFILE/$fname_prefix-$(date +"%Y%m%d-%H%M" .html) "
1594+ HTMLFILE="$HTMLFILE/$fname_prefix-${fname_date} .html"
15921595 fi
15931596 # Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
15941597 if "$APPEND" && [[ ! -s "$HTMLFILE" ]]; then
@@ -1636,8 +1639,9 @@ html_footer() {
16361639################# END HTML file functions ####################
16371640
16381641prepare_logging() {
1639- # arg1: for testing mx records name we put a name of logfile in here, otherwise we get strange file names
1640- local fname_prefix="$1"
1642+ local fname_date="$1"
1643+ # arg2: for testing mx records name we put a name of logfile in here, otherwise we get strange file names
1644+ local fname_prefix="$2"
16411645 local filename_provided=false
16421646
16431647 if [[ -n "$PARENT_LOGFILE" ]]; then
@@ -1654,10 +1658,10 @@ prepare_logging() {
16541658 [[ -z "$fname_prefix" ]] && fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
16551659
16561660 if [[ -z "$LOGFILE" ]]; then
1657- LOGFILE="$fname_prefix-$(date +"%Y%m%d-%H%M" .log) "
1661+ LOGFILE="$fname_prefix-${fname_date} .log"
16581662 elif [[ -d "$LOGFILE" ]]; then
16591663 # actually we were instructed to place all files in a DIR instead of the current working dir
1660- LOGFILE="$LOGFILE/$fname_prefix-$(date +"%Y%m%d-%H%M" .log) "
1664+ LOGFILE="$LOGFILE/$fname_prefix-${fname_date} .log"
16611665 else
16621666 : # just for clarity: a log file was specified, no need to do anything else
16631667 fi
@@ -23416,25 +23420,26 @@ draw_line() {
2341623420
2341723421
2341823422run_mx_all_ips() {
23423+ local fname_date="$1"
2341923424 local mxs mx
2342023425 local mxport
2342123426 local -i ret=0
2342223427 local word=""
2342323428
2342423429 STARTTLS_PROTOCOL="smtp"
2342523430 # test first higher priority servers
23426- mxs=$(get_mx_record "$1 " | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
23431+ mxs=$(get_mx_record "$2 " | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
2342723432 if [[ $CMDLINE_IP == one ]]; then
2342823433 word="as instructed one" # with highest priority
2342923434 mxs=${mxs%% *}
2343023435 else
2343123436 word="the only"
2343223437 fi
23433- mxport=${2 :-25}
23438+ mxport=${3 :-25}
2343423439 if [[ -n "$LOGFILE" ]] || [[ -n "$PARENT_LOGFILE" ]]; then
23435- prepare_logging
23440+ prepare_logging "${fname_date}"
2343623441 else
23437- prepare_logging "${FNAME_PREFIX}mx-$1"
23442+ prepare_logging "${fname_date}" "${ FNAME_PREFIX}mx-$1"
2343823443 fi
2343923444 if [[ -n "$mxs" ]] && [[ "$mxs" != ' ' ]]; then
2344023445 [[ $(count_words "$mxs") -gt 1 ]] && MULTIPLE_CHECKS=true
@@ -25325,22 +25330,23 @@ lets_roll() {
2532525330################# main #################
2532625331
2532725332
25328- RET=0 # this is a global as we can have a function main(), see #705. Should we toss then all local $ret?
25329- ip =""
25333+ RET=0 # this is a global as a function main() is problematic , see #705. Should we toss then all local $ret?
25334+ IP ="" # global used only here
2533025335 stopwatch start
25336+ FNAME_DATE="$(date +"%Y%m%d-%H%M")" # a global var, and a definition via local doesn't work here. Omitting definition above
2533125337
2533225338 lets_roll init
2533325339 initialize_globals
25334- check_base_requirements # needs to come after $do_html is defined
25340+ check_base_requirements # needs to come after $do_html is defined
2533525341 parse_cmd_line "$@"
2533625342 # CMDLINE_PARSED has been set now. Don't put a function immediately after this which calls fatal().
2533725343 # Rather put it after csv_header below.
2533825344 # html_header() needs to be called early! Otherwise if html_out() is called before html_header() and the
2533925345 # command line contains --htmlfile <htmlfile> or --html, it'll make problems with html output, see #692.
2534025346 # json_header and csv_header could be called later but for context reasons we'll leave it here
25341- html_header
25342- json_header
25343- csv_header
25347+ html_header "${FNAME_DATE}"
25348+ json_header "${FNAME_DATE}"
25349+ csv_header "${FNAME_DATE}"
2534425350 get_install_dir
2534525351 # see #705, we need to source TLS_DATA_FILE here instead of in get_install_dir(), see #705
2534625352 [[ -r "$TLS_DATA_FILE" ]] && . "$TLS_DATA_FILE"
@@ -25365,7 +25371,7 @@ lets_roll() {
2536525371 fileout_banner
2536625372
2536725373 if "$do_mass_testing"; then
25368- prepare_logging
25374+ prepare_logging "${FNAME_DATE}"
2536925375 if [[ "$MASS_TESTING_MODE" == parallel ]]; then
2537025376 run_mass_testing_parallel
2537125377 else
@@ -25380,12 +25386,12 @@ lets_roll() {
2538025386 #FIXME: do we need this really here?
2538125387 count_do_variables # if we have just 1x "do_*" --> we do a standard run -- otherwise just the one specified
2538225388 [[ $? -eq 1 ]] && set_scanning_defaults
25383- run_mx_all_ips "${URI}" $PORT # we should reduce run_mx_all_ips to what's necessary as below we have similar code
25389+ run_mx_all_ips "${FNAME_DATE}" "${ URI}" $PORT # we should reduce run_mx_all_ips to what's necessary as below we have similar code
2538425390 exit $?
2538525391 fi
2538625392
2538725393 [[ -z "$NODE" ]] && parse_hn_port "${URI}" # NODE, URL_PATH, PORT, IPADDRs2CHECK and IPADDRs2SHOW is set now
25388- prepare_logging
25394+ prepare_logging "${FNAME_DATE}"
2538925395
2539025396 if [[ -n "$PROXY" ]] && $DNS_VIA_PROXY; then
2539125397 NODEIP="$NODE"
@@ -25404,10 +25410,10 @@ lets_roll() {
2540425410 pr_bold "Testing all IP addresses (port $PORT): "
2540525411 fi
2540625412 outln "$IPADDRs2CHECK"
25407- for ip in $IPADDRs2CHECK; do
25413+ for IP in $IPADDRs2CHECK; do
2540825414 draw_line "-" $((TERM_WIDTH * 2 / 3))
2540925415 outln
25410- NODEIP="$ip "
25416+ NODEIP="$IP "
2541125417 lets_roll "${STARTTLS_PROTOCOL}"
2541225418 RET=$((RET + $?)) # RET value per IP address
2541325419 done
0 commit comments