Skip to content

fix(upgrade.sh): use HTTPS for GPG key import and restore SELinux context after upgrade#36930

Merged
lunny merged 3 commits into
go-gitea:mainfrom
xijiang:fix/upgrade-sh-gpg-selinux
Mar 19, 2026
Merged

fix(upgrade.sh): use HTTPS for GPG key import and restore SELinux context after upgrade#36930
lunny merged 3 commits into
go-gitea:mainfrom
xijiang:fix/upgrade-sh-gpg-selinux

Conversation

@xijiang
Copy link
Copy Markdown
Contributor

@xijiang xijiang commented Mar 19, 2026

Summary

Two bug fixes for contrib/upgrade.sh found during a real-world upgrade from 1.24.3 to 1.25.5 on Fedora.


Fix 1: GPG key import fails when HKP port 11371 is blocked (closes #36928)

Before:

gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2

This uses HKP port 11371, which is blocked by many firewalls. The upgrade aborts with:

gpg: keyserver receive failed: Connection timed out

After:

curl -fsSL --connect-timeout 10 \
  "https://keys.openpgp.org/vks/v1/by-fingerprint/7C9E68152594688862D62AF62D9AE806EC1592E2" \
  | gpg --import \
  || gpg --keyserver keyserver.ubuntu.com --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 \
  || gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2

Same keys.openpgp.org server, same key — but fetched over HTTPS port 443 which is universally accessible. Keyservers remain as fallbacks.


Fix 2: Gitea fails to start after upgrade on SELinux systems (closes #36929)

Problem: After mv-ing the binary from $giteahome to /usr/local/bin/gitea, the file retains the SELinux context of the source directory. Systemd refuses to execute it, exiting with status=203/EXEC.

Fix: Add a restorecon call guarded by command -v so it is a no-op on non-SELinux systems:

command -v restorecon &>/dev/null && restorecon -v "$giteabin" || true

Verified: restorecon -v /usr/local/bin/gitea immediately restored service on the affected machine.

…text

Two fixes for contrib/upgrade.sh:

1. GPG key import now uses the keys.openpgp.org HTTPS REST API
   (port 443) instead of the HKP protocol (port 11371), which is
   frequently blocked by firewalls. Keyservers remain as fallbacks.
   Closes go-gitea#36928

2. After moving the binary to $giteabin, run restorecon to fix the
   SELinux security context on RHEL/Fedora systems. Without this,
   systemd exits with status 203/EXEC. Guarded with command -v so
   it is a no-op on non-SELinux systems.
   Closes go-gitea#36929
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 19, 2026
Comment thread contrib/upgrade.sh
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Comment thread contrib/upgrade.sh Outdated
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 19, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 19, 2026
@lunny lunny merged commit 068d7a5 into go-gitea:main Mar 19, 2026
26 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Mar 19, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 23, 2026
* giteaofficial/main:
  Add user badges (go-gitea#36752)
  Apply as maintainer (go-gitea#36947)
  Refactor storage content-type handling of ServeDirectURL (go-gitea#36804)
  Add summary to action runs view (go-gitea#36883)
  feat: Add configurable permissions for Actions automatic tokens (go-gitea#36173)
  Feature: Add button to re-run failed jobs in Actions (go-gitea#36924)
  Support dark/light theme images in markdown (go-gitea#36922)
  fix go-gitea#36463: preserve sort order of exclusive labels from template repo (go-gitea#36931)
  fix(upgrade.sh): use HTTPS for GPG key import and restore SELinux context after upgrade (go-gitea#36930)
  [skip ci] Updated translations via Crowdin
  Make container registry support Apple Container (basic auth) (go-gitea#36920)
  Fix various trivial problems (go-gitea#36921)
silverwind added a commit to silverwind/gitea that referenced this pull request Mar 23, 2026
* origin/main:
  Update to eslint 10 (go-gitea#36925)
  Add user badges (go-gitea#36752)
  Apply as maintainer (go-gitea#36947)
  Refactor storage content-type handling of ServeDirectURL (go-gitea#36804)
  Add summary to action runs view (go-gitea#36883)
  feat: Add configurable permissions for Actions automatic tokens (go-gitea#36173)
  Feature: Add button to re-run failed jobs in Actions (go-gitea#36924)
  Support dark/light theme images in markdown (go-gitea#36922)
  fix go-gitea#36463: preserve sort order of exclusive labels from template repo (go-gitea#36931)
  fix(upgrade.sh): use HTTPS for GPG key import and restore SELinux context after upgrade (go-gitea#36930)
  [skip ci] Updated translations via Crowdin
  Make container registry support Apple Container (basic auth) (go-gitea#36920)
  Fix various trivial problems (go-gitea#36921)
  [skip ci] Updated translations via Crowdin

# Conflicts:
#	package.json
#	pnpm-lock.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore.

Projects

None yet

5 participants