]> git.ipfire.org Git - people/mfischer/ipfire-2.x.git/commitdiff
backup.pl: Fixes bug13734 - tar treats colon in filename as remote location
authorAdolf Belka <adolf.belka@ipfire.org>
Wed, 7 Aug 2024 14:02:20 +0000 (16:02 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Aug 2024 18:09:46 +0000 (18:09 +0000)
- When a user tries to restore on the console from a backup on IPFire that has a colon in
   the filename the tar treats this as meaning that everything after the colon is
   information about a remote location to do the extraction to. This results in a filename
   that cannot be found, and a remote location that is not correct and the tar operation
   fails.
- This has been confirmed by myself.
- If the user tries a restore from a file downloaded to another computer then for most, if
   not all browsers, the colon will have been replaced by an underscore or other character.
   Firefox, Chromium and Vivaldi do this.
- So any backup file that is selected to be restored using the WUI will no longer have a
   colon in the filename.
- This patch adds --force-local to the tar command, which means that tar will treat the
   colon as a character in the filename. This will ensure that if a user has any backup
   files stored on their IPFire system, with a colon in the filename then doing a restore
   from this file will not cause tar to fail.
- The NOW variable is also changed to replace the colon by a dash and to separate the date
   and time by an underscore. This filename will be accepted by browsers, without doing
   any replacements. Tested out with Firefox, Chromium & Vivaldi.
- The above ensures that both the new and old filename versions will work for doing a
   restore.

Fixes: bug13734
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Tested-by: Bernhard Bitsch <bbitsch@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/backup/backup.pl

index d848084e944e68225a7d52f51ddc5635b862cde5..7b2f953040d523ff84dfb7bd8c5f1fd452876454 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2022  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2024  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -21,7 +21,7 @@
 
 shopt -s nullglob
 
-NOW="$(date "+%Y-%m-%d-%H:%M")"
+NOW="$(date "+%Y-%m-%d_%H-%M")"
 
 list_addons() {
        local file
@@ -82,7 +82,8 @@ restore_backup() {
        # Extract backup
        if ! tar xvzpf "${filename}" -C / \
                        --exclude-from="/var/ipfire/backup/exclude" \
-                       --exclude-from="/var/ipfire/backup/exclude.user"; then
+                       --exclude-from="/var/ipfire/backup/exclude.user" \
+                       --force-local; then
                echo "Could not extract backup" >&2
                return 1
        fi