diff options
author | Christian Hesse <mail@eworm.de> | 2023-08-30 08:59:04 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-08-30 09:30:25 +0200 |
commit | f099c2c9ea0a09e7802246b726f6abbc95c2f8ed (patch) | |
tree | e3addce9535b4afb3451be6413c1256e79b3f13f | |
parent | 1e247542a51749175bcd73bb0ea07513848c6442 (diff) |
backup-upload: check configuration size before writing file
-rw-r--r-- | backup-upload.rsc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/backup-upload.rsc b/backup-upload.rsc index 29bdfff..ec76385 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -101,11 +101,12 @@ $WaitFullyConnected; # global-config-overlay :if ($BackupSendGlobalConfig = true) do={ :local Config [ /system/script/get global-config-overlay source ]; - /file/add name=($FilePath . ".conf") contents=$Config; - $WaitForFile ($FilePath . ".conf"); - :local Size [ :len $Config ]; - :if ([ /file/get ($FilePath . ".conf") size ] = $Size) do={ + + :if ($Size <= 4095) { + /file/add name=($FilePath . ".conf") contents=$Config; + $WaitForFile ($FilePath . ".conf"); + :do { /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \ user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf"); @@ -115,13 +116,14 @@ $WaitFullyConnected; :set ConfigFile "failed"; :set Failed 1; } + + /file/remove ($FilePath . ".conf"); } else={ - $LogPrintExit2 warning $0 ("Creating config file failed. Size should be " . $Size . " bytes, but is not.") false; + $LogPrintExit2 warning $0 ("Creating config file not possible. Limit is 4kB, configuration has " . \ + $Size . " bytes.") false; :set ConfigFile "failed"; :set Failed 1; } - - /file/remove ($FilePath . ".conf"); } $SendNotification2 ({ origin=$0; \ |