Journal Entry

Object
Created
2026-08-11 20:36
Created by
YoSiJo
Kind
Info

Tags

No tags assigned

Comments

/usr/lib/cgi-bin/build-main.sh repariert.

#! /bin/bash
# Lies den raw body von stdin und speichere ihn
BODY=$(cat)

# Setze dein wirkliches Webhook-Secret (das du in Codeberg eingetragen hast)
SECRET="…"

# Berechne HMAC-SHA256 über den Body
HASH="sha256=$(echo -n "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | awk '{print $NF}')"

# Vergleiche mit dem Header (ohne "sha256=" Präfix oder mit - je nach Format)
EXPECTED_SIG="${HTTP_X_GITEA_SIGNATURE:-${HTTP_X_FORGEJO_SIGNATURE}}"

if [ "$HASH" = "sha256=$EXPECTED_SIG" ] || [ "${HASH#sha256=}" = "$EXPECTED_SIG" ]; then
  echo "Content-Type: text/plain"
  echo ""
  echo "signature valid"

  sudo -u buildbot /var/lib/buildbot/buildjob-main.sh 2>&1
else
  echo "Status: 401"
  echo "Content-Type: text/plain"
  echo ""
  echo "signature invalid"
  echo "DEBUG: hash=$HASH" >&2
  echo "DEBUG: expected=$EXPECTED_SIG" >&2
  exit 1
fi