mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
The desktop feature (assets/features/desktop.sh, not chosen until you choose it, about 370 MB) installs Xfce and TigerVNC's Xvnc from base's package snapshot, and devvm-desktop, which starts Xvnc on display :1 on a socket of the VM user's own (/run/devvm-desktop/vnc.sock, 0600 in a 0700 folder), with no TCP port (-rfbport -1, -nolisten tcp) and no password of its own, the clipboard on or off as asked (vncconfig on a running one), then an Xfce session in a D-Bus session of its own. Nothing starts it at boot: devvm desktop does, on every backend. devvm desktop gets the VM ready as devvm ssh does, refuses a VM without the feature (desktop_no_feature), starts its desktop (desktop_start_failed), and serves it on 127.0.0.1 alone until Ctrl+C or the VM stops (desktop_vm_stopped), on the VM's own port (desktop_port, among netpolicy.UsedPorts, so no forwarder or new VM takes it), showing the address and password (desktop_ready) and opening vnc://127.0.0.1:PORT in Screen Sharing on macOS (--no-open; desktop_open_failed). --clipboard shares the clipboard both ways for that run. internal/desktop's Relay is the guarantee, not the VM's server: it speaks RFB 3.3/3.7/3.8 as a server, offers VNC authentication alone, checks the answer against the VM's password (8 characters of 31, about 40 bits, crypto/rand, kept in the VM's state as desktop_password, never sent to the VM) one check at a time with a second's wait after a wrong one, and only then opens an ssh -W channel to the VM's socket through devvm's ssh config (pinned host key, no session, agent or forwarding), closed by its input first so the VM's sshd ends its side. Without --clipboard it drops every ClientCutText (extended ones too) and ends a connection on a message type it can't size. At most 8 connections. Also: vm.Desktop (Open, serve, listener, dial), vm.ready (devvm ssh's launch without the Include prompt), Env.OpenURL; build's chosen features leave desktop out until it's chosen; messages desktop_failed, desktop_no_feature, desktop_start_failed, desktop_ready, desktop_open_failed, desktop_vm_stopped, with doc links. Tests: internal/desktop (passwords, Response, wrong passwords refused with no dial, 3.3/3.7/3.8, not a viewer, the clipboard dropped or carried, an unknown message ending the connection, a VM server asking for a password), internal/vm (the password kept and remade, the listener's port kept and replaced, ssh's arguments), internal/build (desktop off until chosen), testdata/script/desktop.txtar (no VM, no feature, a stopped VM started, the forward asked for with the clipboard off and on, the same port and password, Screen Sharing opened or failing, the VM stopping, the start failing), setup.txtar, docgen; tests/e2e.sh's desktop section (Lima, with network policy) and checks in the smolvm and Docker sections; TestE2EDesktop. Docs: using/desktop.md (new), customizing.md's features, commands.md, internals/desktop.md (new), design.md's note on the desktop, contributing/testing.md's manual Screen Sharing check, the CLI reference. Review (security-audit skill, guidance mode, local IPC and loopback listener classes), against the review's list: - another local user or process reaching the port: 127.0.0.1 alone, without address reuse; VNC authentication checked on the host before any ssh, constant-time, about 1 guess a second globally (thousands of years); the password in the VM's state (0600 file, 0700 folder), shown only on stdout with the address, never in open's arguments or the run log (e2e: no run log, no host process's arguments); - never in an image or the VM: the VM's server has no password; e2e greps the VM's files for it (found the first time only in the VM's journal, from the check's own sudo command line, now fed on its input); - the server on no address but loopback on each backend, even if root changes it: Xvnc has no TCP listener (e2e on each backend), the relay is the only way in and lives on the host; root's own server without a password (e2e, Lima) still gets no viewer without devvm's password; - clipboard off really off: the relay drops the viewer's clipboard whatever the server accepts (e2e: root's server records a key event but never the clipboard); the VM's clipboard to the viewer can't be filtered without decoding screen updates, documented, Screen Sharing's setting; - nothing from the VM toward the host: a local ssh -W channel, which ssh's client asks for; the VM reaches neither the relay's port nor anything new (e2e: with network policy, no direct connection out, nor to the port); a VM that reaches host loopback (no policy, Docker Desktop) meets the password like anyone; - network policy unchanged: no policy file or allowlist changes; the self-check passes with the desktop running (e2e). Left as documented residuals: the VM's clipboard sent by a changed server; a local process or VM keeping the relay's 8 slots busy or failing checks (availability only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
109 lines
3.5 KiB
Plaintext
109 lines
3.5 KiB
Plaintext
# setup: the default backend, base's features and new VMs' size (all
|
|
# asked in a terminal, which Go tests cover; without one, the backend and
|
|
# size aren't asked and the features are kept, or every one until they're
|
|
# chosen; --backend, --features, --cpus and --memory without asking). A new choice of features says base
|
|
# rebuilds, and once images are built that devvm gc deletes the old ones.
|
|
env DEVVM_MESSAGES=names
|
|
env CHOSEN=$XDG_CONFIG_HOME/devvm/base-features
|
|
|
|
# Kept: none chosen; no backend or size asked.
|
|
exec devvm setup
|
|
stdout '^==> base_features_none$'
|
|
! stdout base_will_rebuild
|
|
! stdout default_backend
|
|
! stdout 'size_question|size_defaults'
|
|
! exists $XDG_CONFIG_HOME/devvm/backend
|
|
! exists $XDG_CONFIG_HOME/devvm/size
|
|
! stderr .
|
|
! stub_calls
|
|
|
|
# Unchosen: every feature.
|
|
rm $CHOSEN
|
|
exec devvm setup
|
|
stdout '^==> base_features features=cli-tools fzf omb$'
|
|
! stdout base_will_rebuild
|
|
|
|
# --features, in the order features run; nothing built yet.
|
|
exec devvm setup --features omb,fzf
|
|
stdout '^==> base_features features=fzf omb$'
|
|
stdout '^==> base_will_rebuild$'
|
|
! stdout gc_old_hint
|
|
! stdout default_backend
|
|
cmp $CHOSEN fzf-omb
|
|
exec devvm setup --features fzf,omb
|
|
! stdout base_will_rebuild
|
|
|
|
# Built: a new choice rebuilds base, and gc deletes the old one.
|
|
exec devvm build base
|
|
exec devvm setup --features ''
|
|
stdout '^==> base_features_none$'
|
|
stdout '^==> base_will_rebuild$'
|
|
stdout '^gc_old_hint$'
|
|
exec devvm build base
|
|
stdout '^==> building_image image=base key='
|
|
exec devvm gc
|
|
stdout '^gc_image image=base key='
|
|
|
|
# A name that isn't a feature changes nothing.
|
|
! exec devvm setup --features fzf,nope
|
|
stderr '^devvm: no_feature feature=nope features=cli-tools desktop fzf omb$'
|
|
! stdout base_features
|
|
exec devvm setup
|
|
stdout '^==> base_features_none$'
|
|
|
|
# The default backend: only it, unless --features is given too.
|
|
exec devvm setup --backend lima
|
|
stdout '^==> default_backend backend=lima$'
|
|
! stdout base_features
|
|
cmp $XDG_CONFIG_HOME/devvm/backend lima.txt
|
|
exec devvm setup --backend lima --features fzf
|
|
stdout '^==> default_backend backend=lima$'
|
|
stdout '^==> base_features features=fzf$'
|
|
! exec devvm setup --backend nope
|
|
stderr '^devvm: backend_unknown backends=docker, lima, smolvm name=nope$'
|
|
cmp $XDG_CONFIG_HOME/devvm/backend lima.txt
|
|
|
|
# New VMs' size: --cpus and --memory, checked, without asking; with only
|
|
# them the backend and features stay, and a saved disk is kept.
|
|
exec sh -c 'echo disk=120 > "$XDG_CONFIG_HOME/devvm/size"'
|
|
exec devvm setup --cpus 2 --memory 4GiB
|
|
stdout '^==> size_defaults size=cpus=2 memory=4GiB disk=120GiB$'
|
|
! stdout 'base_features|default_backend|size_question'
|
|
cmp $XDG_CONFIG_HOME/devvm/size size.txt
|
|
exec devvm setup --memory 3
|
|
stdout '^==> size_defaults size=cpus=2 memory=3GiB disk=120GiB$'
|
|
cmp $XDG_CONFIG_HOME/devvm/size size3.txt
|
|
! exec devvm setup --cpus 9999
|
|
stderr '^devvm: too_many_cpus have=8 want=9999$'
|
|
! exec devvm setup --memory 99999
|
|
stderr '^devvm: too_much_memory have=16 max=14 want=99999$'
|
|
! exec devvm setup --cpus 1.5
|
|
stderr '^devvm: cpus_not_number value="1\.5"$'
|
|
cmp $XDG_CONFIG_HOME/devvm/size size3.txt
|
|
exec devvm setup --backend lima --cpus 4
|
|
stdout '^==> default_backend backend=lima$'
|
|
stdout '^==> size_defaults size=cpus=4 memory=3GiB disk=120GiB$'
|
|
! stdout base_features
|
|
|
|
# An unreadable choice stays for you to fix.
|
|
cp bad $CHOSEN
|
|
! exec devvm setup
|
|
stderr '^devvm: setup_failed reason=.*base-features'
|
|
cmp $CHOSEN bad
|
|
|
|
-- fzf-omb --
|
|
fzf
|
|
omb
|
|
-- lima.txt --
|
|
lima
|
|
-- size.txt --
|
|
cpus=2
|
|
memory=4
|
|
disk=120
|
|
-- size3.txt --
|
|
cpus=2
|
|
memory=3
|
|
disk=120
|
|
-- bad --
|
|
Not_A_Feature
|