Files
UmbraAudio/infra/remote_credential_broker/askpass_helper.py
2026-10-18 19:01:04 -07:00

33 lines
861 B
Python
Executable File

#!/usr/bin/env python3
# Copyright 2026 Umbra Tools (umbratools.com)
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import os
import socket
import sys
def main() -> int:
socket_path = os.environ.get("UMBRA_BROKER_ASKPASS_SOCKET", "")
if not socket_path:
print("credential broker: askpass socket is not configured", file=sys.stderr)
return 2
try:
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as channel:
channel.connect(socket_path)
secret = channel.recv(4096)
except OSError as exc:
print(f"credential broker: askpass channel failed: {exc}", file=sys.stderr)
return 1
if not secret:
return 1
sys.stdout.buffer.write(secret)
sys.stdout.buffer.flush()
return 0
if __name__ == "__main__":
raise SystemExit(main())