Node 0 MemTotal: 7863292 kB Node 0 MemFree: 586648 kB Node 0 MemUsed: 7276644 kB Node 0 SwapCached: 12076 kB Node 0 Active: 2999372 kB Node 0 Inactive: 3131824 kB Node 0 Active(anon): 1531252 kB Node 0 Inactive(anon): 228892 kB Node 0 Active(file): 1468120 kB Node 0 Inactive(file): 2902932 kB Node 0 Unevictable: 4000 kB Node 0 Mlocked: 0 kB Node 0 Dirty: 632 kB Node 0 Writeback: 0 kB Node 0 FilePages: 4480752 kB Node 0 Mapped: 242516 kB Node 0 AnonPages: 1605952 kB Node 0 Shmem: 97604 kB Node 0 KernelStack: 8848 kB Node 0 PageTables: 13136 kB Node 0 SecPageTables: 0 kB Node 0 NFS_Unstable: 0 kB Node 0 Bounce: 0 kB Node 0 WritebackTmp: 0 kB Node 0 KReclaimable: 903740 kB Node 0 Slab: 1004500 kB Node 0 SReclaimable: 903740 kB Node 0 SUnreclaim: 100760 kB Node 0 AnonHugePages: 823296 kB Node 0 ShmemHugePages: 0 kB Node 0 ShmemPmdMapped: 0 kB Node 0 FileHugePages: 0 kB Node 0 FilePmdMapped: 0 kB Node 0 Unaccepted: 0 kB Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 ; ˆl–ßi~” jn-jqA àAq·Tţ „]Áa–ß=¿JJj"Tâ‚fà]¸ÐTÅ£Ç?÷ # # Copyright (C) 2022 Red Hat, Inc. # SPDX-License-Identifier: GPL-3.0-or-later import argparse import asyncio import base64 import importlib.resources import logging import os import re import shlex import tempfile import time from pathlib import Path from typing import Dict, Literal, Optional, Sequence from cockpit import polyfills from cockpit._vendor import ferny from cockpit._vendor.bei import bootloader from cockpit.beipack import BridgeBeibootHelper from cockpit.bridge import parse_os_release, setup_logging from cockpit.channel import ChannelRoutingRule from cockpit.channels.packages import PackagesChannel from cockpit.jsonutil import JsonObject, get_str from cockpit.osinfo import supported_oses from cockpit.packages import Packages, PackagesLoader, patch_libexecdir from cockpit.peer import Peer from cockpit.protocol import CockpitProblem, CockpitProtocolError from cockpit.router import Router, RoutingRule from cockpit.transports import StdioTransport logger = logging.getLogger('cockpit.beiboot') def ensure_ferny_askpass() -> Path: """Create askpass executable We need this for the flatpak: ssh and thus the askpass program run on the host (via flatpak-spawn), not the flatpak. Thus we cannot use the shipped cockpit-askpass program. """ src_path = importlib.resources.files(ferny.__name__) / 'interaction_client.py' src_data = src_path.read_bytes() # Create the file in $XDG_CACHE_HOME, one of the few locations that a flatpak can write to xdg_cache_home = os.environ.get('XDG_CACHE_HOME') if xdg_cache_home is None: xdg_cache_home = os.path.expanduser('~/.cache') os.makedirs(xdg_cache_home, exist_ok=True) dest_path = Path(xdg_cache_home, 'cockpit-client-askpass') logger.debug("Checking if %s exists...", dest_path) # Check first to see if we already wrote the current version try: if dest_path.read_bytes() != src_data: logger.debug(" ... it exists but is not the same version...") raise ValueError if not dest_path.stat().st_mode & 0o100: logger.debug(" ... it has the correct contents, but is not executable...") raise ValueError except (FileNotFoundError, ValueError): logger.debug(" ... writing contents.") dest_path.write_bytes(src_data) dest_path.chmod(0o700) return dest_path class ProxyPackagesLoader(PackagesLoader): file_status: Dict[str, bool] def __init__(self, file_status: Dict[str, bool]): self.file_status = file_status def path_exists(self, path: str) -> bool: return self.file_status.get(path, False) BEIBOOT_GADGETS = { "report_exists": r""" import os def report_exists(f