From 2e61af2c8316e28a7387a1de40e1700feefa3991 Mon Sep 17 00:00:00 2001 From: igophper <34326532+igophper@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:09:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#5578)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #5573 --- backend/app/service/cronjob_helper.go | 4 ++-- backend/app/service/snapshot.go | 2 +- backend/app/service/snapshot_create.go | 2 +- backend/utils/files/tar_gz.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go index b6947e604..412fce462 100644 --- a/backend/app/service/cronjob_helper.go +++ b/backend/app/service/cronjob_helper.go @@ -161,7 +161,7 @@ func handleTar(sourceDir, targetDir, name, exclusionRules string, secret string) commands := "" if len(secret) != 0 { - extraCmd := "| openssl enc -aes-256-cbc -salt -k " + secret + " -out" + extraCmd := "| openssl enc -aes-256-cbc -salt -k '" + secret + "' -out" commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read -zcf %s %s %s %s", " -"+excludeRules, path, extraCmd, targetDir+"/"+name) global.LOG.Debug(strings.ReplaceAll(commands, fmt.Sprintf(" %s ", secret), "******")) } else { @@ -186,7 +186,7 @@ func handleUnTar(sourceFile, targetDir string, secret string) error { } commands := "" if len(secret) != 0 { - extraCmd := "openssl enc -d -aes-256-cbc -k " + secret + " -in " + sourceFile + " | " + extraCmd := "openssl enc -d -aes-256-cbc -k '" + secret + "' -in " + sourceFile + " | " commands = fmt.Sprintf("%s tar -zxvf - -C %s", extraCmd, targetDir+" > /dev/null 2>&1") global.LOG.Debug(strings.ReplaceAll(commands, fmt.Sprintf(" %s ", secret), "******")) } else { diff --git a/backend/app/service/snapshot.go b/backend/app/service/snapshot.go index 79168da7e..463b703ce 100644 --- a/backend/app/service/snapshot.go +++ b/backend/app/service/snapshot.go @@ -389,7 +389,7 @@ func (u *SnapshotService) handleUnTar(sourceDir, targetDir string, secret string } commands := "" if len(secret) != 0 { - extraCmd := "openssl enc -d -aes-256-cbc -k " + secret + " -in " + sourceDir + " | " + extraCmd := "openssl enc -d -aes-256-cbc -k '" + secret + "' -in " + sourceDir + " | " commands = fmt.Sprintf("%s tar -zxvf - -C %s", extraCmd, targetDir+" > /dev/null 2>&1") global.LOG.Debug(strings.ReplaceAll(commands, fmt.Sprintf(" %s ", secret), "******")) } else { diff --git a/backend/app/service/snapshot_create.go b/backend/app/service/snapshot_create.go index 56d8f2a16..9649326c0 100644 --- a/backend/app/service/snapshot_create.go +++ b/backend/app/service/snapshot_create.go @@ -256,7 +256,7 @@ func handleSnapTar(sourceDir, targetDir, name, exclusionRules string, secret str } commands := "" if len(secret) != 0 { - extraCmd := "| openssl enc -aes-256-cbc -salt -k " + secret + " -out" + extraCmd := "| openssl enc -aes-256-cbc -salt -k '" + secret + "' -out" commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read -zcf %s %s %s %s", " -"+exStr, path, extraCmd, targetDir+"/"+name) global.LOG.Debug(strings.ReplaceAll(commands, fmt.Sprintf(" %s ", secret), "******")) } else { diff --git a/backend/utils/files/tar_gz.go b/backend/utils/files/tar_gz.go index bf11a3976..8a1691abf 100644 --- a/backend/utils/files/tar_gz.go +++ b/backend/utils/files/tar_gz.go @@ -20,7 +20,7 @@ func (t TarGzArchiver) Extract(filePath, dstDir string, secret string) error { var err error commands := "" if len(secret) != 0 { - extraCmd := "openssl enc -d -aes-256-cbc -k " + secret + " -in " + filePath + " | " + extraCmd := "openssl enc -d -aes-256-cbc -k '" + secret + "' -in " + filePath + " | " commands = fmt.Sprintf("%s tar -zxvf - -C %s", extraCmd, dstDir+" > /dev/null 2>&1") global.LOG.Debug(strings.ReplaceAll(commands, fmt.Sprintf(" %s ", secret), "******")) } else { @@ -47,7 +47,7 @@ func (t TarGzArchiver) Compress(sourcePaths []string, dstFile string, secret str path += fmt.Sprintf("- -C %s %s", aheadDir, itemDir) commands := "" if len(secret) != 0 { - extraCmd := "| openssl enc -aes-256-cbc -salt -k " + secret + " -out" + extraCmd := "| openssl enc -aes-256-cbc -salt -k '" + secret + "' -out" commands = fmt.Sprintf("tar -zcf %s %s %s", path, extraCmd, dstFile) global.LOG.Debug(strings.ReplaceAll(commands, fmt.Sprintf(" %s ", secret), "******")) } else {