From 94f6e7d4a69b3016a6faa318736fd61c6d115064 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Mon, 26 Dec 2022 02:01:48 +0400 Subject: [PATCH 1/2] Reinstate selfupdate tag to make builds without self-update work Revert what seems to be a typo introduced as part of the fix for #2041 in 2018 7d0f2eaf24cffe6f45d7980a39791a08f5ba4d8e. `xbuild` does not look like a go build/tag keyword to me, I failed to find documentation for it and using `go install -tags '!selfupdate' ...` has no effect, i.e. self-update code is still compiled. `+build` however works; updating the OpenBSD port/binary package security/restic to apply this PR works as expected: ``` $ restic help | grep self $ restic self-update unknown command "self-update" for "restic" ``` (Using `go:build` now as per restic's style and gofmt.) Previously, using `restic-0.14.0p1` on OpenBSD/amd64 7.2-current would check for a newer version and probably attempt replacing the system wide root-owned executable (on a read-only filesystem) as unprivileged user: ``` $ restic version restic 0.14.0 compiled with go1.19.2 on openbsd/amd64 $ restic help | grep self self-update Update the restic binary $ restic self-update writing restic to /usr/local/bin/restic find latest release of restic at GitHub restic is up to date ``` (It never tried to actually write besaid path; doing so would fail, so the current message can be considered misleading.) --- cmd/restic/cmd_self_update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/restic/cmd_self_update.go b/cmd/restic/cmd_self_update.go index 23345a97c..4b86c416f 100644 --- a/cmd/restic/cmd_self_update.go +++ b/cmd/restic/cmd_self_update.go @@ -1,4 +1,4 @@ -// xbuild selfupdate +//go:build selfupdate package main From 61e738638453939dca671f2a119b1165dd942fff Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Mon, 26 Dec 2022 02:48:11 +0400 Subject: [PATCH 2/2] Bugfix: Make distribution package builds without self-update work --- changelog/unreleased/pull-4100 | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 changelog/unreleased/pull-4100 diff --git a/changelog/unreleased/pull-4100 b/changelog/unreleased/pull-4100 new file mode 100644 index 000000000..33582d72d --- /dev/null +++ b/changelog/unreleased/pull-4100 @@ -0,0 +1,9 @@ +Bugfix: Restore self-update to disabled-by-default + +Due to a typo, the `self-update` feature was always compiled, even if the +`selfupdate` tag was not explicitly enabled. + +As intended, it is now disabled by default. +Official builds using `build.go` continue to explicitly enable it. + +https://github.com/restic/restic/pull/4100