#!/usr/bin/env python3 """Bounded root log acceptance for the one harmless cloud test unit.""" import datetime as dt import hashlib import json import os import subprocess import sys import uuid import cloud_apt_retry as apt import cloud_root_policy cloud=apt.cloud def open_policy(payload): import datetime as dt p=Path('/opt/rust-discovery/devstate/root-policy/policy.json') require(not p.is_symlink() and p.stat().st_uid==10001 and p.stat().st_mode&0o777==0o600,'safe existing policy') old=p.read_bytes() require(hashlib.sha256(old).hexdigest()==payload['previous_sha256'] and dt.datetime.fromisoformat(json.loads(old)['expires_at'])