Use a non-root fixture operator in root CI containers

This commit is contained in:
Mark Gregory
2026-11-28 10:07:28 +00:00
parent eac09534c7
commit 11b56adcef
2 changed files with 11 additions and 4 deletions
+2 -2
View File
@@ -1,10 +1,10 @@
"""Local operator identity and scoped migration approval policy."""
import hmac
import os
from dataclasses import dataclass
from datetime import datetime
from os import geteuid
from core.approval import (
ApprovalError,
@@ -46,7 +46,7 @@ class OperatorApprovalPolicy:
self._key = sealing_key
def authorise(self, approval, operation, now):
uid = os.geteuid()
uid = geteuid()
principal = approval["approver"]
validate_approver(principal)
context = approval["context"]
+9 -2
View File
@@ -82,9 +82,16 @@ class ApprovalStoreTests(unittest.TestCase):
self.identifier = self.approval["approval_id"]
self.uid = os.geteuid()
if self.uid == 0:
self.uid = 1000
identity = patch("core.operator_approval.geteuid", return_value=self.uid)
identity.start()
self.addCleanup(identity.stop)
self.key = os.urandom(32)
self.grants = [
OperatorGrant(os.geteuid(), "operator", operation, self.base["site"],
OperatorGrant(self.uid, "operator", operation, self.base["site"],
self.base["revision"], self.now + timedelta(days=2))
for operation in ("issue", "execute")
]
@@ -481,7 +488,7 @@ class ApprovalStoreTests(unittest.TestCase):
self.assertFalse(self.store.approval_path(self.identifier).exists())
def test_unrecognised_os_identity_denies_issuance(self):
other_account = [replace(grant, uid=os.geteuid() + 1) for grant in self.grants]
other_account = [replace(grant, uid=self.uid + 1) for grant in self.grants]
self.store.operator_policy = OperatorApprovalPolicy(other_account, sealing_key=self.key)
with self.assertRaisesRegex(ApprovalStoreError, "not authorised"):
self.save()