luci-app-statistics: harden sysupgrade_backup
authorJohn Kohl <jtk.git@bostonpog.org>
Sat, 11 Nov 2023 16:19:58 +0000 (11:19 -0500)
committerHannu Nyman <hannu.nyman@iki.fi>
Sat, 11 Nov 2023 16:55:47 +0000 (18:55 +0200)
Remove sysupgrade_backup from help.  Also have it check parameters.

Signed-off-by: John Kohl <jtk.git@bostonpog.org>
applications/luci-app-statistics/root/etc/init.d/luci_statistics

index d36534cce4fa65cf4f9eecc5923e2b2d490307c8..20acf70019ed2232c90e00a22714cb359ffb587b 100755 (executable)
@@ -13,9 +13,7 @@ SYSUPGRADE_BACKUP_TWIN_A="${BACKUP_DIR}/sysupgrade.trustme.txt"
 SYSUPGRADE_BACKUP_TWIN_B="${BACKUP_DIR}/sysupgrade.dont.trustme.txt"
 EXTRA_COMMANDS="backup sysupgrade_backup"
 EXTRA_HELP="\
-       backup          Backup current rrd database if configured to do so\n\
-        sysupgrade_backup  Take a special backup for sysupgrade/configuration saving"
-
+       backup          Backup current rrd database if configured to do so"
 TRACE=0
 
 doing_backups() {
@@ -150,6 +148,10 @@ copy_backup_for_sysupgrade() {
 
 sysupgrade_backup() {
        local filelist="$1"
+       [ -z "$filelist" -o ! -f "$filelist" ] && {
+           echo sysupgrade_backup requires an existing filename argument 1>&2
+           exit 1
+       }
        [ ${TRACE} -gt 0 ] && logger -t ${0##*/} -- luci_statistics sysupgrade_backup CONF_BACKUP_LIST=${CONF_BACKUP_LIST}
        doing_backups && {
                ### CONF_BACKUP_LIST=1 means we are generating the