Download scripts/phase6_install_services_and_security.py from monika-p/VyronOS: direct link, hf CLI and curl.
- Browser
- Download file 9.01 kB
-
https://huggingface.co/datasets/monika-p/VyronOS/resolve/main/scripts/phase6_install_services_and_security.py
- Command line
-
hf download hf://datasets/monika-p/VyronOS/scripts/phase6_install_services_and_security.py
-
curl -L -o phase6_install_services_and_security.py https://huggingface.co/datasets/monika-p/VyronOS/resolve/main/scripts/phase6_install_services_and_security.py
9.01 kB
| #!/usr/bin/env python3 | |
| """ | |
| ============================================================================== | |
| VYRON OS — Phase 6 System Services, Audio & Security Implementation | |
| Target Disk: dist/VyronOS-Disk-Phase6-Working.qcow2 | |
| Executes: | |
| 1. Signed APT repository update (Debian 12 Bookworm + Backports). | |
| 2. Real package installation: | |
| - Aptitude package manager. | |
| - ALSA audio utilities (alsa-utils). | |
| - PipeWire audio server & WirePlumber session manager. | |
| - Polkit authorization daemon & XFCE PulseAudio plugin. | |
| 3. Audio subsystem integration: | |
| - ALSA Intel HDA detection & channel unmute. | |
| - PipeWire & WirePlumber systemd user service enablement. | |
| 4. Security & Privilege Separation Hardening: | |
| - Elimination of passwordless sudo (require authentic credentials for vyron). | |
| - Strict file mode 0440 on sudoers configuration. | |
| - Creation of unprivileged 'testuser' to verify sudo denial. | |
| - System directory permission validation (0755 root:root). | |
| - Privilege operation logging verification. | |
| 5. Real package management validation (install, query, remove, purge). | |
| ============================================================================== | |
| """ | |
| import os | |
| import sys | |
| import time | |
| import subprocess | |
| import select | |
| SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| ROOT_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "..")) | |
| DIST_DIR = os.path.join(ROOT_DIR, "dist") | |
| BUILD_DIR = os.path.join(ROOT_DIR, "build") | |
| WORKING_DISK = os.path.join(DIST_DIR, "VyronOS-Disk-Phase6-Working.qcow2") | |
| LOG_PATH = os.path.join(BUILD_DIR, "phase6-install-serial.log") | |
| OVMF_CODE = "/opt/homebrew/share/qemu/edk2-x86_64-code.fd" | |
| if not os.path.exists(OVMF_CODE): | |
| for candidate in [ | |
| "/usr/share/qemu/edk2-x86_64-code.fd", | |
| "/usr/share/OVMF/OVMF_CODE.fd" | |
| ]: | |
| if os.path.exists(candidate): | |
| OVMF_CODE = candidate | |
| break | |
| def main(): | |
| print("==========================================================================") | |
| print(" VYRON OS — Phase 6 Services, Audio & Security Implementation") | |
| print("==========================================================================") | |
| print(f" Target Disk : {WORKING_DISK}") | |
| print(f" UEFI Firmware : {OVMF_CODE}") | |
| print(f" Log File : {LOG_PATH}") | |
| print("==========================================================================") | |
| if not os.path.exists(WORKING_DISK): | |
| print(f"ERROR: Working disk {WORKING_DISK} not found.") | |
| sys.exit(1) | |
| subprocess.run(["pkill", "-f", "qemu-system-x86_64.*VyronOS-P6Install"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | |
| time.sleep(0.5) | |
| cmd = [ | |
| "/opt/homebrew/bin/qemu-system-x86_64", | |
| "-name", "VyronOS-P6Install", | |
| "-m", "2048", | |
| "-smp", "2", | |
| "-drive", f"if=pflash,format=raw,readonly=on,file={OVMF_CODE}", | |
| "-drive", f"file={WORKING_DISK},format=qcow2,file.locking=off", | |
| "-netdev", "user,id=net0,hostname=vyron-os", | |
| "-device", "virtio-net-pci,netdev=net0", | |
| "-device", "intel-hda", | |
| "-device", "hda-duplex", | |
| "-display", "none", | |
| "-serial", "stdio" | |
| ] | |
| print(">>> Booting VyronOS to execute Phase 6 Services & Security Setup...") | |
| proc = subprocess.Popen( | |
| cmd, | |
| stdin=subprocess.PIPE, | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.STDOUT, | |
| bufsize=0 | |
| ) | |
| os.set_blocking(proc.stdout.fileno(), False) | |
| full_output = [] | |
| buffer = "" | |
| start_time = time.time() | |
| login_user_sent = False | |
| login_pass_sent = False | |
| deploy_started = False | |
| installer_script = """ | |
| cat << 'P6_INSTALL_EOF' > /tmp/run_p6_setup.sh | |
| #!/bin/bash | |
| set -e | |
| export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" | |
| echo "=== 1. VERIFYING NETWORK CONNECTIVITY ===" | |
| for i in {1..15}; do | |
| if ping -c 1 1.1.1.1 >/dev/null 2>&1; then | |
| echo "NETWORK_ONLINE_CONFIRMED" | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| echo "=== 2. CONFIGURING SIGNED REPOSITORIES & UPDATING APT ===" | |
| sudo rm -f /var/lib/dpkg/lock-frontend /var/lib/dpkg/lock /var/cache/apt/archives/lock | |
| sudo dpkg --configure -a || true | |
| sudo apt-get update | |
| echo "=== 3. INSTALLING APTITUDE, ALSA & PIPEWIRE PACKAGES ===" | |
| sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \\ | |
| aptitude \\ | |
| alsa-utils \\ | |
| pipewire \\ | |
| pipewire-pulse \\ | |
| pipewire-alsa \\ | |
| wireplumber \\ | |
| polkitd \\ | |
| xfce4-pulseaudio-plugin \\ | |
| curl | |
| echo "=== 4. CONFIGURING ALSA AUDIO SUBSYSTEM ===" | |
| cat /proc/asound/cards | |
| aplay -l || true | |
| # Unmute master channel if ALSA mixer is available | |
| amixer -c 0 sset Master 80% unmute 2>/dev/null || true | |
| echo "=== 5. ENABLING PIPEWIRE & WIREPLUMBER USER SERVICES ===" | |
| mkdir -p /home/vyron/.config/systemd/user/default.target.wants | |
| sudo -u vyron XDG_RUNTIME_DIR=/run/user/1000 systemctl --user enable pipewire pipewire-pulse wireplumber 2>/dev/null || true | |
| echo "=== 6. HARDENING SUDO & ELIMINATING PASSWORDLESS ACCESS ===" | |
| # Remove insecure NOPASSWD and require authenticated credentials for vyron | |
| sudo tee /etc/sudoers.d/vyron << 'SUDO_CONF' | |
| # VyronOS Authenticated Sudoers Configuration | |
| # Requires valid credentials for administrative escalation | |
| vyron ALL=(ALL:ALL) ALL | |
| SUDO_CONF | |
| sudo chmod 0440 /etc/sudoers.d/vyron | |
| sudo chmod 0440 /etc/sudoers | |
| sudo chmod 0750 /etc/sudoers.d | |
| echo "=== 7. CREATING UNPRIVILEGED TEST USER FOR SECURITY BOUNDARY TESTS ===" | |
| if ! id testuser >/dev/null 2>&1; then | |
| sudo useradd -m -s /bin/bash testuser | |
| echo "testuser:testpass123" | sudo chpasswd | |
| fi | |
| echo "=== 8. VERIFYING SYSTEM DIRECTORY PERMISSIONS ===" | |
| ls -ld /etc /usr /boot /var /home/vyron | |
| echo "=== 9. TESTING PACKAGE MANAGEMENT OPERATIONS ===" | |
| echo "Testing real package installation with Aptitude..." | |
| sudo aptitude -y install tree | |
| tree --version | |
| echo "Testing real package removal with Aptitude..." | |
| sudo aptitude -y purge tree | |
| echo "=== 10. CLEANING APT CACHE & FINALIZING ===" | |
| sudo apt-get clean | |
| sync | |
| echo "=== PHASE 6 SERVICES & SECURITY SETUP COMPLETED SUCCESSFULLY ===" | |
| sync | |
| sudo poweroff | |
| P6_INSTALL_EOF | |
| chmod +x /tmp/run_p6_setup.sh | |
| bash /tmp/run_p6_setup.sh | |
| """ | |
| try: | |
| while time.time() - start_time < 900: | |
| r, _, _ = select.select([proc.stdout.fileno()], [], [], 0.1) | |
| if r: | |
| chunk = os.read(proc.stdout.fileno(), 4096).decode("utf-8", errors="replace") | |
| if not chunk: | |
| if proc.poll() is not None: | |
| break | |
| time.sleep(0.05) | |
| continue | |
| sys.stdout.write(chunk) | |
| sys.stdout.flush() | |
| buffer += chunk | |
| full_output.append(chunk) | |
| if ("login:" in buffer or "vyron-os login:" in buffer) and not login_user_sent: | |
| print("\n>>> Detected login prompt! Sending username 'vyron'...") | |
| time.sleep(0.5) | |
| proc.stdin.write(b"vyron\n") | |
| proc.stdin.flush() | |
| login_user_sent = True | |
| buffer = "" | |
| elif ("Password:" in buffer or "password:" in buffer) and login_user_sent and not login_pass_sent: | |
| print("\n>>> Detected password prompt! Sending password 'vyron'...") | |
| time.sleep(0.5) | |
| proc.stdin.write(b"vyron\n") | |
| proc.stdin.flush() | |
| login_pass_sent = True | |
| buffer = "" | |
| elif ("vyron@vyron-os:" in buffer or "$" in buffer) and login_pass_sent and not deploy_started: | |
| print("\n>>> Logged in successfully! Executing Phase 6 setup script...") | |
| deploy_started = True | |
| buffer = "" | |
| time.sleep(1) | |
| proc.stdin.write(installer_script.encode("utf-8")) | |
| proc.stdin.flush() | |
| proc.wait(timeout=30) | |
| except Exception as e: | |
| print(f"Exception during Phase 6 deployment: {e}") | |
| finally: | |
| if proc.poll() is None: | |
| proc.terminate() | |
| proc.wait(timeout=5) | |
| with open(LOG_PATH, "w") as f: | |
| f.write("".join(full_output)) | |
| out_text = "".join(full_output) | |
| if "PHASE 6 SERVICES & SECURITY SETUP COMPLETED SUCCESSFULLY" in out_text: | |
| print("\n==========================================================================") | |
| print(" SUCCESS: Phase 6 Services & Security Setup Deployed to Working Disk!") | |
| print("==========================================================================") | |
| return 0 | |
| else: | |
| print("\n==========================================================================") | |
| print(" ERROR: Deployment did not complete successfully. Check log:") | |
| print(f" {LOG_PATH}") | |
| print("==========================================================================") | |
| return 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |