Repository navigation
Clipboard: host image bridge for SELinux and SSH, fix text copy/paste regression - #93
Merged
Merged
Conversation
…display socket With SELinux enforcing, a confined container is denied any connection to the Wayland compositor or X server: the mounted display socket is dead. Since PR #92 exports WAYLAND_DISPLAY even from shells that lacked it, harnesses switched from the terminal clipboard (OSC 52) to wl-copy/wl-paste, which fail: image pasting still did not work, and text select/copy and middle-click paste broke. - add_clipboard_mounts() no longer mounts the display socket or exports WAYLAND_DISPLAY/DISPLAY when SELinux is enforcing (selinux_enforcing): text goes through the terminal again. Permissive and non-SELinux hosts keep the direct socket. - Clipboard image bridge (clipboard_bridge_*): a host helper started by the launcher answers requests from a wl-paste shim mounted in the container, through a FIFO and files in a per-session directory under $XDG_RUNTIME_DIR. Image types only; the container gets no display access. - The helper asks an SSH-forwarded clipboard socket first ($XDG_RUNTIME_DIR/codebox-clipboard-ssh.sock), then the host's own wl-paste/xclip, chosen per paste, so sessions used over SSH paste the images of the machine the user is typing on. integrations/clipboard-ssh/ holds the server for that machine (script + systemd user socket units). - tests: clipboard-wayland / clipboard-selinux golden scenarios, and tests/clipboard-bridge-test.sh (shim -> helper -> socket -> server against stub clipboards), run in CI. - docs: usage.md Clipboard Support, new "Pasting Images over SSH" section; AGENTS.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Select + middle-click paste did not work through the bridge. In fullscreen mode Claude Code handles the middle click itself by running `wl-paste --primary`, and publishes its own selection with `wl-copy` / `wl-copy --primary` when WAYLAND_DISPLAY is set; none of that could reach the host, and the shim refused it. - The shim is now also mounted as /usr/local/bin/wl-copy, and WAYLAND_DISPLAY is set to a name that is not a socket so harnesses use the two commands. - New requests: "copy clipboard|primary" (text selected in the harness, written to the host selections and kept as the session's last selection) and "primary" (host primary selection, else that last selection). - The text to copy is read with O_NOFOLLOW: a link planted by the container would otherwise let it read a host file back through the primary selection. - Reading the regular clipboard as text is still refused. Selection text never uses the SSH-forwarded socket (images only). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #92, which did not make image pasting work and broke text select/copy and middle-click paste in containers.
wl-paste/wl-copyfail withPermission denied. On a permissive host the same connection is only logged, which is why it worked there.WAYLAND_DISPLAYeven from shells that lacked it (Herdr, SSH). Claude Code switches from the terminal clipboard (OSC 52) towl-copy/wl-pasteas soon as that variable is set, and those fail.Changes
/usr/local/bin/wl-pasteand/usr/local/bin/wl-copyasks it through a FIFO and files in a per-session directory ($XDG_RUNTIME_DIR/codebox-clipboard/<container>, removed with the session). The container gets no display access;WAYLAND_DISPLAYis set to a name that is not a socket, only so harnesses use the two commands. It carries:wl-paste --primary);O_NOFOLLOW).wl-paste/xclip. The source is chosen per paste.integrations/clipboard-ssh/holds the server for the local machine (script + systemd user socket-activated units).docs/usage.mdClipboard Support updated, new "Pasting Images over SSH" section (server install,RemoteForward,StreamLocalBindUnlink);AGENTS.md.Tests
clipboard-waylandandclipboard-selinux; existing goldens unchanged.tests/clipboard-bridge-test.sh: shim → helper → forwarded socket → server against stub clipboards, selection copy and primary read, clipboard-text refusal, malformed requests, planted symlinks, fallback after disconnect. Added to CI along with shellcheck for the new scripts.Verification
Verified by hand on an SELinux-enforcing Wayland laptop, local session inside Herdr: select + middle-click paste, and CTRL+V of an image.
Not verified yet: the SSH path end to end (forwarded socket,
RemoteForwardhonoured by the terminal's SSH connections). It is only covered by the stub-based test.Host requirements:
wl-clipboard(orxclip) for the local source,python3for the SSH source. No image rebuild is needed.🤖 Generated with Claude Code