Skip to content

vmlab.sh: use a lab directory only if it is private to the user - #108

Merged
margani merged 1 commit into
mainfrom
fix/105-vmlab-private-dir
Nov 2, 2026
Merged

margani merged 1 commit into
mainfrom
fix/105-vmlab-private-dir

Conversation

@margani

@margani margani commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Closes #105.

What changed

  • lab_private refuses --dir when it is a symlink or not a directory, not owned by the caller, or writable by group or others. It runs for every command except help, and again in create right after mkdir -p -m 0755, because mkdir -p is satisfied by a directory created in the meantime.
  • The default stays /var/tmp/vmlab, so existing labs keep working with no migration; qemu still needs to read it (0755).
  • README notes the refusal.

Why

/var/tmp/vmlab is a fixed name in a world-writable directory. Another local user could create it first, and vmlab.sh would then use their base.img as every VM's backing image and write into their directory.

Verification

  • New suite vmlab/tests/vmlab_test.sh: a 0777 directory is refused (status and create), a symlink is refused, an own 0755 directory passes, and --help always works. On the old code: FAIL: accepted a 0777 lab directory; new code: PASS.
  • ./run-tests (now with the vmlab suite): all 11 passed, 3 skipped.

Not verified

  • The "owned by another user" branch: it needs a second uid. It uses bash's -O test.
  • A real libvirt run.

The default --dir is a fixed name in world-writable /var/tmp, and mkdir -p
accepted a directory another local user had created, with their base.img in
it. vmlab.sh now refuses a lab directory that is a symlink, not owned by the
caller, or writable by group or others, checked again after create's mkdir.

Closes #105
@margani
margani merged commit b1d76fc into main Nov 2, 2026
4 checks passed
@margani
margani deleted the fix/105-vmlab-private-dir branch November 2, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vmlab.sh: default lab directory must be private to the user

1 participant