Add fresh device trust, installer recovery and scoped patch runtime
This commit is contained in:
@@ -50,6 +50,33 @@ def on_server(options):
|
||||
inputs = ['--artifacts', str(build), '--build-receipt', str(build / options['receipt'])]
|
||||
subprocess.run(['python3', '-I', str(tool), 'prepare', *inputs, '--state', str(state), '--gateway', options['gateway'],
|
||||
'--service-uid','10001','--sequence',str(options['sequence']),'--version',options['version']],check=True)
|
||||
if options['label'].startswith('windows'):
|
||||
import re
|
||||
import uuid
|
||||
public = Path('/etc/rmm-time-source/time-public-key.json')
|
||||
if public.exists():
|
||||
contents = json.loads(public.read_bytes())
|
||||
if (set(contents) != {'schema_version','algorithm','server_instance','key_id','key_generation','public_key_hex'}
|
||||
or contents['algorithm'] != 'Ed25519' or contents['schema_version'] != 1 or uuid.UUID(contents['server_instance']).int == 0
|
||||
or not re.fullmatch('[A-Za-z0-9_-]{1,64}', contents['key_id']) or not re.fullmatch('[0-9a-f]{64}', contents['public_key_hex'])
|
||||
or type(contents['key_generation']) is not int or contents['key_generation'] <= 0):
|
||||
raise ValueError('time broker public key information invalid')
|
||||
expected = {'server_instance':contents['server_instance'],'key_generation':contents['key_generation'],
|
||||
'public_keys_hex':{contents['key_id']:contents['public_key_hex']}}
|
||||
path = state/'config/windows-time-trust.json'
|
||||
if not path.exists():
|
||||
with tempfile.NamedTemporaryFile(mode='w', dir=path.parent,delete=False) as tmp:
|
||||
json.dump(expected,tmp,separators=(',',':'))
|
||||
os.fchmod(tmp.fileno(),0o600)
|
||||
os.fchown(tmp.fileno(),10001,10001)
|
||||
tmp.flush()
|
||||
os.fsync(tmp.fileno())
|
||||
try:
|
||||
os.link(tmp.name,path)
|
||||
finally:
|
||||
os.unlink(tmp.name)
|
||||
if json.loads(path.read_bytes()) != expected:
|
||||
raise ValueError('time trust changed; verify rotation before new publication')
|
||||
if options['prepare_only']:
|
||||
return
|
||||
# Use the ordinary development catalog permission and CSRF-protected API.
|
||||
@@ -67,7 +94,7 @@ def on_server(options):
|
||||
subprocess.run(['python3','-I',str(tool),'publish',*inputs,'--tenant',options['tenant'],
|
||||
'--envelope',str(state/'prepared'/options['label']/str(options['sequence'])/'envelope.json'),
|
||||
'--origin','https://localhost:18443','--ca','/opt/rust-discovery/devstate/api-pki/ca.pem',
|
||||
'--dev-login-file',auth.name],check=True)
|
||||
'--dev-login-file',auth.name,'--bootstrap-worker',str(state/'bootstrap-workers'/options['label'])],check=True)
|
||||
|
||||
def main():
|
||||
import inspect
|
||||
|
||||
Reference in New Issue
Block a user