Skip to content

Commit

Permalink
Try to redirect everything that could be spamming TTY1
Browse files Browse the repository at this point in the history
So far unsuccessfully. :P
  • Loading branch information
M4rtinK committed Aug 20, 2024
1 parent 83c6d10 commit 55d5b9f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
3 changes: 2 additions & 1 deletion data/systemd/anaconda-tmux@.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ WorkingDirectory=/root
Environment=LANG=en_US.UTF-8
ExecStart=/usr/bin/tmux -u attach -t anaconda
StandardInput=tty
StandardOutput=tty
StandardOutput=journal
StandardError=journal
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
Expand Down
35 changes: 33 additions & 2 deletions pyanaconda/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#
# Author(s): Martin Kolman <mkolman@redhat.com>
#
GNOME_KIOSK_LOG_FILE = "/tmp/gnome-kiosk.log"
USER_SYSTEMD_LOG_FILE = "/tmp/user-systemd.log"

import os
import time
import textwrap
Expand Down Expand Up @@ -72,7 +75,10 @@ def start_user_systemd():

# Start the user instance of systemd. This call will also cause the launch of
# dbus-broker and start a session bus at XDG_RUNTIME_DIR/bus.
childproc = util.startProgram(["/usr/lib/systemd/systemd", "--user"])
childproc = util.startProgram(["/usr/lib/systemd/systemd", "--user"],
stdout=_open_user_systemd_log_file(),
stderr=_open_user_systemd_log_file(),
)
WatchProcesses.watch_process(childproc, "systemd")

# Set up the session bus address. Some services started by Anaconda might call
Expand Down Expand Up @@ -200,6 +206,28 @@ def check_rd_can_be_started(anaconda):
return rd_startup_possible, error_messages


def _open_gnome_kiosk_log_file():
# FIXME: redirect to journal ?
try:
fd = os.open(GNOME_KIOSK_LOG_FILE, os.O_RDWR | os.O_CREAT)
except OSError as e:
sys.stderr.write("error opening %s: %s\n", (GNOME_KIOSK_LOG_FILE, e))
fd = None

return fd


def _open_user_systemd_log_file():
# FIXME: redirect to journal ?
try:
fd = os.open(USER_SYSTEMD_LOG_FILE, os.O_RDWR | os.O_CREAT)
except OSError as e:
sys.stderr.write("error opening %s: %s\n", (USER_SYSTEMD_LOG_FILE, e))
fd = None

return fd


def do_startup_wl_actions(timeout, headless=False, headless_resolution=None):
"""Start the Wayland compositor.
Expand Down Expand Up @@ -250,7 +278,10 @@ def wl_preexec():
argv.extend(["--headless"])

childproc = util.startProgram(argv, env_add={'XDG_DATA_DIRS': xdg_data_dirs},
preexec_fn=wl_preexec)
preexec_fn=wl_preexec,
stdout=_open_gnome_kiosk_log_file(),
stderr=_open_gnome_kiosk_log_file(),
)
WatchProcesses.watch_process(childproc, argv[0])

for _i in range(0, int(timeout / 0.1)):
Expand Down
1 change: 1 addition & 0 deletions pyanaconda/gnome_remote_destop.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def _start_grd_process(self):
global grd_process
grd_process = startProgram([GRD_BINARY_PATH, "--headless"],
stdout=self._open_grd_log_file(),
stderr=self._open_grd_log_file(),
env_add={"HOME": "/root"})
self.log.info("GNOME remote desktop is now running.")
except OSError:
Expand Down
7 changes: 5 additions & 2 deletions scripts/run-in-new-session
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ def run_program_in_new_session(arguments, pam_environment, user, service,
print(f"Could not wait for VT {vt} to change: {e}", file=old_tty_output)

try:
new_session_log = open("/tmp/new_session.log", "wt")
os.dup2(tty_input.fileno(), 0)
os.dup2(tty_output.fileno(), 1)
os.dup2(tty_output.fileno(), 2)
# os.dup2(tty_output.fileno(), 1)
# os.dup2(tty_output.fileno(), 2)
os.dup2(new_session_log.fileno(), 1)
os.dup2(new_session_log.fileno(), 2)
except OSError as e:
print(f"Could not set up standard i/o: {e}", file=old_tty_output)

Expand Down

0 comments on commit 55d5b9f

Please sign in to comment.