From 1ce599d2ae68285426e251031cb98a87cb530ff6 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 9 Jul 2023 14:15:23 +0200 Subject: [PATCH 1/3] Fix handling of empty cacert environment variable This resulted in a "empty filename for root certificate supplied" error. --- cmd/restic/global.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/restic/global.go b/cmd/restic/global.go index 487fa9673..07412925e 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -151,7 +151,9 @@ func init() { globalOptions.PasswordFile = os.Getenv("RESTIC_PASSWORD_FILE") globalOptions.KeyHint = os.Getenv("RESTIC_KEY_HINT") globalOptions.PasswordCommand = os.Getenv("RESTIC_PASSWORD_COMMAND") - globalOptions.RootCertFilenames = strings.Split(os.Getenv("RESTIC_CACERT"), ",") + if os.Getenv("RESTIC_CACERT") != "" { + globalOptions.RootCertFilenames = strings.Split(os.Getenv("RESTIC_CACERT"), ",") + } globalOptions.TLSClientCertKeyFilename = os.Getenv("RESTIC_TLS_CLIENT_CERT") comp := os.Getenv("RESTIC_COMPRESSION") if comp != "" { From 89fbd39e59f4febb75575af227c8c12eee5c72b9 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 9 Jul 2023 14:17:43 +0200 Subject: [PATCH 2/3] Don't print stacktrace on invalid cacert option --- cmd/restic/global.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/restic/global.go b/cmd/restic/global.go index 07412925e..31d5aac16 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -584,7 +584,7 @@ func open(ctx context.Context, s string, gopts GlobalOptions, opts options.Optio rt, err := backend.Transport(globalOptions.TransportOptions) if err != nil { - return nil, err + return nil, errors.Fatal(err.Error()) } // wrap the transport so that the throughput via HTTP is limited @@ -640,7 +640,7 @@ func create(ctx context.Context, s string, gopts GlobalOptions, opts options.Opt rt, err := backend.Transport(globalOptions.TransportOptions) if err != nil { - return nil, err + return nil, errors.Fatal(err.Error()) } factory := gopts.backends.Lookup(loc.Scheme) From c158741e2ea08997f37b71db025bd5f595298475 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 9 Jul 2023 14:29:43 +0200 Subject: [PATCH 3/3] CI: add minimal CLI test Just create a repository and run a minimal backup. --- .github/workflows/tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0ec8c072c..bb9945891 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -141,6 +141,14 @@ jobs: run: | go run build.go + - name: Minimal test + run: | + ./restic init + ./restic backup . + env: + RESTIC_REPOSITORY: ../testrepo + RESTIC_PASSWORD: password + - name: Run local Tests env: RESTIC_TEST_FUSE: ${{ matrix.test_fuse }}