diff --git a/net/ddns-scripts/Makefile b/net/ddns-scripts/Makefile index 6505b0b100..1c2d33cee8 100644 --- a/net/ddns-scripts/Makefile +++ b/net/ddns-scripts/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ddns-scripts PKG_VERSION:=2.8.4 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-2.0 diff --git a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh index 0f4c5d6716..a8ba663ec2 100644 --- a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh +++ b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh @@ -121,7 +121,11 @@ ddns_loglines=$((ddns_loglines + 1)) # correct sed handling # format to show date information in log and luci-app-ddns default ISO 8601 format ddns_dateformat=$(uci -q get ddns.global.ddns_dateformat) || ddns_dateformat="%F %R" -DATE_PROG="date +'$ddns_dateformat'" + +# Print the current date using the configured format. +# Do not turn this into a command string that is run through "eval": the format +# is read from UCI and a single quote inside it would start a new shell word. +date_prog() { date +"$ddns_dateformat"; } # USE_CURL if GNU Wget and cURL installed normally Wget is used by do_transfer() # to change this use global option use_curl '1' @@ -1121,17 +1125,17 @@ trap_handler() { case $1 in 0) if [ $__ERR -eq 0 ]; then - write_log 5 "PID '$$' exit normal at $(eval $DATE_PROG)${N}" + write_log 5 "PID '$$' exit normal at $(date_prog)${N}" else - write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(eval $DATE_PROG)${N}" + write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(date_prog)${N}" fi ;; - 1) write_log 6 "PID '$$' received 'SIGHUP' at $(eval $DATE_PROG)" + 1) write_log 6 "PID '$$' received 'SIGHUP' at $(date_prog)" # reload config via starting the script again /usr/lib/ddns/dynamic_dns_updater.sh -v "0" -S "$__SECTIONID" -- start || true exit 0 ;; # and leave this one - 2) write_log 5 "PID '$$' terminated by 'SIGINT' at $(eval $DATE_PROG)${N}";; - 3) write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(eval $DATE_PROG)${N}";; - 15) write_log 5 "PID '$$' terminated by 'SIGTERM' at $(eval $DATE_PROG)${N}";; + 2) write_log 5 "PID '$$' terminated by 'SIGINT' at $(date_prog)${N}";; + 3) write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(date_prog)${N}";; + 15) write_log 5 "PID '$$' terminated by 'SIGTERM' at $(date_prog)${N}";; *) write_log 13 "Unhandled signal '$1' in 'trap_handler()'";; esac diff --git a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh index b01697c6d0..0d61feca1d 100644 --- a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh +++ b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh @@ -174,14 +174,14 @@ ERR_LAST=$? # save return code - equal 0 if SECTION_ID found [ $VERBOSE -le 1 ] && VERBOSE=2 # force console out and logfile output [ -f $LOGFILE ] && rm -f $LOGFILE # clear logfile before first entry write_log 7 "************ ************** ************** **************" - write_log 5 "PID '$$' started at $(eval $DATE_PROG)" + write_log 5 "PID '$$' started at $(date_prog)" write_log 7 "ddns version : $VERSION" write_log 7 "uci configuration:${N}$(uci -q show ddns | grep '=service' | sort)" write_log 14 "Service section '$SECTION_ID' not defined" } write_log 7 "************ ************** ************** **************" -write_log 5 "PID '$$' started at $(eval $DATE_PROG)" +write_log 5 "PID '$$' started at $(date_prog)" write_log 7 "ddns version : $VERSION" write_log 7 "uci configuration:${N}$(uci -q show ddns.$SECTION_ID | sort)" # write_log 7 "ddns version : $(opkg list-installed ddns-scripts | cut -d ' ' -f 3)" @@ -285,8 +285,7 @@ if [ $LAST_TIME -eq 0 ]; then write_log 7 "last update: never" else EPOCH_TIME=$(( $(date +%s) - $CURR_TIME + $LAST_TIME )) - EPOCH_TIME="date -d @$EPOCH_TIME +'$ddns_dateformat'" - write_log 7 "last update: $(eval $EPOCH_TIME)" + write_log 7 "last update: $(date -d @$EPOCH_TIME +"$ddns_dateformat")" fi # verify Proxy server and set environment @@ -309,7 +308,7 @@ ERR_LAST=$? [ $use_ipv6 -eq 1 ] && expand_ipv6 "$REGISTERED_IP" REGISTERED_IP # loop endlessly, checking ip every check_interval and forcing an updating once every force_interval -write_log 6 "Starting main loop at $(eval $DATE_PROG)" +write_log 6 "Starting main loop at $(date_prog)" while : ; do get_current_ip CURRENT_IP # read current IP @@ -396,7 +395,7 @@ while : ; do [ $FORCE_SECONDS -eq 0 ] && write_log 6 "Configured to run once" [ $VERBOSE -gt 1 -o $FORCE_SECONDS -eq 0 ] && exit 0 - write_log 6 "Rerun IP check at $(eval $DATE_PROG)" + write_log 6 "Rerun IP check at $(date_prog)" done # we should never come here there must be a programming error write_log 12 "Error in 'dynamic_dns_updater.sh - program coding error"