Build and Publish HeiniRemote Agent Flatpak / build (push) Successful in 7m16s
flatpak-spawn --host does not forward the caller's environment; the host login shell started without TERM (tput errors, integer test on empty LINES/COLUMNS in the profile scripts). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jkHZhr7ZzHGGuE2bJQmGa
30 lines
1.5 KiB
Bash
Executable File
30 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# Host-shell bridge for the agent's PTY console.
|
|
#
|
|
# The wrapper sets SHELL=/app/bin/host-shell, so the agent's PTY console
|
|
# spawns this instead of a sandboxed shell. flatpak-spawn --host (requires
|
|
# --talk-name=org.freedesktop.Flatpak) runs the command on the host with the
|
|
# PTY fds forwarded, giving the remote console a real host login shell.
|
|
#
|
|
# The inner resolution runs ON THE HOST: flatpak-spawn forwards the sandbox
|
|
# environment, so $SHELL would still point at this script — resolve the user's
|
|
# real login shell from passwd instead and fix up $SHELL before exec'ing it.
|
|
#
|
|
# The PTY itself was allocated inside the sandbox (its own devpts instance),
|
|
# so on the host the forwarded fd cannot be named (`tty` fails, no
|
|
# controlling terminal, tools that open /dev/tty break). script(1) allocates a
|
|
# second, host-side PTY for the shell and relays through the forwarded one;
|
|
# util-linux >= 2.35 also passes window-size changes along.
|
|
# flatpak-spawn --host does not forward the caller's environment: without
|
|
# --env the host shell starts with no TERM at all (login scripts then fail
|
|
# in tput and in integer tests on the empty LINES/COLUMNS).
|
|
exec flatpak-spawn --host --env=TERM="${TERM:-xterm-256color}" --env=COLORTERM=truecolor /bin/sh -c '
|
|
shell="$(getent passwd "$(id -un)" | cut -d: -f7)"
|
|
[ -x "$shell" ] || shell=/bin/sh
|
|
export SHELL="$shell"
|
|
if command -v script >/dev/null 2>&1; then
|
|
exec script -q -e -c "exec \"$shell\" -l" /dev/null
|
|
fi
|
|
exec "$shell" -l
|
|
'
|