webui-desktop: redirect browser stdout/stderr to a log file#1252
webui-desktop: redirect browser stdout/stderr to a log file#1252rvykydal merged 1 commit intorhinstaller:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the webui-desktop script to redirect standard output and error to /dev/null when launching the browser, preventing potential pipe blocking issues. Review feedback highlights that the HOME environment variable is currently lost because pkexec clears the environment; suggestions were made to explicitly pass HOME within the command execution to ensure the browser correctly uses the isolated temporary directory.
| pkexec --user "$INSTALLER_USER" env XDG_CURRENT_DESKTOP=GNOME "${user_environment[@]}" "${BROWSER[@]}" "$WEBUI_URL" \ | ||
| >/dev/null 2>&1 & |
There was a problem hiding this comment.
While the redirection to /dev/null correctly addresses the pipe blocking issue, there is a pre-existing bug in how the environment is passed to pkexec. pkexec clears the environment and sets HOME to the target user's default home directory, which means the isolation intended by the temporary directory created at line 214 is lost. To ensure the browser uses the correct home directory, HOME="$BROWSER_HOME" should be explicitly passed as an argument to the env command. Note that it should be placed after "${user_environment[@]}" to avoid being overwritten if that array contains a HOME entry.
| pkexec --user "$INSTALLER_USER" env XDG_CURRENT_DESKTOP=GNOME "${user_environment[@]}" "${BROWSER[@]}" "$WEBUI_URL" \ | |
| >/dev/null 2>&1 & | |
| pkexec --user "$INSTALLER_USER" env XDG_CURRENT_DESKTOP=GNOME "${user_environment[@]}" HOME="$BROWSER_HOME" "${BROWSER[@]}" "$WEBUI_URL" \ | |
| >/dev/null 2>&1 & |
| dbus-run-session -- "${BROWSER[@]}" "$WEBUI_URL" \ | ||
| >/dev/null 2>&1 & |
There was a problem hiding this comment.
Similar to the graphical session case, the HOME variable should be explicitly passed to the browser via the env command. Since pkexec clears the environment, the HOME="$BROWSER_HOME" assignment at line 238 does not reach the browser process, defeating the isolation provided by the temporary home directory.
| dbus-run-session -- "${BROWSER[@]}" "$WEBUI_URL" \ | |
| >/dev/null 2>&1 & | |
| HOME="$BROWSER_HOME" \ | |
| dbus-run-session -- "${BROWSER[@]}" "$WEBUI_URL" \ | |
| >/dev/null 2>&1 & |
adamkankovsky
left a comment
There was a problem hiding this comment.
I'm just wondering if it might be better to redirect these logs to some other log file rather than discarding them entirely, for example, for future debugging.
KKoukiou
left a comment
There was a problem hiding this comment.
If it's tested and it works it looks reasonable.
Yes, tested to be working. |
The browser process inherits the stdout pipe from webui-desktop back to anaconda's proc.communicate(). When exitGui() kills webui-desktop, the cleanup trap kills the browser, but Firefox may survive (it forks into its own process group). While Firefox is alive it holds the pipe open, so proc.communicate() never returns, anaconda never exits, and the atexit handler that calls systemctl reboot is never reached. Redirect the browser's stdout/stderr to webui-browser.log file so that even if Firefox outlives webui-desktop, it cannot block anaconda's pipe. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5160945 to
5c02074
Compare
Good point, updated. |
|
I updated the PR actually limiting the redirection to the boot.iso case (the Live ISO is not using proc.communicate code path) |
adamkankovsky
left a comment
There was a problem hiding this comment.
Now it looks great, and if it works, I have no objection to it
|
Yes, it works. FYI The contents of the webui-browser.log from my test run: |
The browser process inherits the stdout pipe from webui-desktop back
to anaconda's proc.communicate(). When exitGui() kills webui-desktop,
the cleanup trap kills the browser, but Firefox may survive (it forks
into its own process group). While Firefox is alive it holds the pipe
open, so proc.communicate() never returns, anaconda never exits, and
the atexit handler that calls systemctl reboot is never reached.
Redirect the browser's stdout/stderr to webui-browser.log file so that
even if Firefox outlives webui-desktop, it cannot block anaconda's pipe.