· about 35 minutes · runs on ubuntu-26.04-devops · unrated
An unrated lab. It runs on your machine with no account and no network, and everything about it — the faults, the checks, the hints and the reference solution — is in the repository. An attempt on it is recorded on your profile and never moves a rating: only rated labs do. Rated and unrated labs.
netprobe is the team's small connectivity checker. It reads a list of host:port targets and says
which ones accept connections:
$ netprobe check --config /etc/netprobe/targets.yaml
[{"target": "127.0.0.1:22", "open": true}, ...]
A colleague installed version 1.4.0 on this machine before leaving on holiday, into the virtual
environment /opt/netprobe/venv, from the checkout in their working copy. It works for them as root.
Everyone else gets command not found, and when they call the venv's program by its full path they
get Permission denied or ModuleNotFoundError.
What is expected, and graded — the grader runs netprobe as your own, unprivileged account:
netprobe --version works for every user, from the normal PATH, and prints netprobe 1.4.0.netprobe check --config /etc/netprobe/targets.yaml works for every user and reports that
127.0.0.1:22 is open./opt/netprobe/venv: it keeps working if the
working copy it was installed from is deleted or changes.Nothing can be downloaded: the machine has no internet access. The wheels the project needs are in
/opt/wheels. You have root through sudo. Everything must still hold after a reboot.
The machine is checked, rebooted, and checked again. A check passes only if it passes both times.
| Check | Objective |
|---|---|
| 01_every_user_can_run_it | Install a Python application into its own virtual environment for every user of the machine |
| 02_checks_targets_as_a_user | Install a Python application into its own virtual environment for every user of the machine |
| 03_installed_copy_stands_alone | Tell an editable development install from a real one, and know what each depends on |
Where the lab's hints send you, level by level, as you ask for them (h, then l opens a journal section in the TUI).
4 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Three of them, to answer here:
What does this print?
import subprocess, sys, tempfile, os
venv = os.path.join(tempfile.mkdtemp(), "v")
subprocess.run([sys.executable, "-m", "venv", "--without-pip", venv], check=True)
out = subprocess.run([f"{venv}/bin/python", "-c", "import sys; print(sys.prefix == sys.base_prefix)"],
capture_output=True, text=True).stdout.strip()
print(out, os.path.exists(f"{venv}/pyvenv.cfg"))
False True
Running the venv's interpreter directly, without activating anything, already puts Python in the environment: sys.prefix points at the venv while sys.base_prefix is the system Python. pyvenv.cfg next to bin/ is what tells the interpreter so.
https://docs.python.org/3/library/venv.html#how-venvs-work · executed in a sandbox
What does this print?
import os, subprocess, sys, tempfile
site = tempfile.mkdtemp(); src = tempfile.mkdtemp()
os.makedirs(f"{src}/pkgdemo"); open(f"{src}/pkgdemo/__init__.py", "w").close()
open(f"{site}/demo.pth", "w").write(src + "\n")
code = f"import site; site.addsitedir({site!r}); import pkgdemo; print(pkgdemo.__file__.startswith({src!r}))"
print(subprocess.run([sys.executable, "-c", code], capture_output=True, text=True).stdout.strip())
True
A .pth file in a site directory adds each of its lines to sys.path when that directory is processed. That is how an editable install works: the package is imported from the source tree the line names, not from site-packages — and it disappears for anyone who cannot read that tree.
https://docs.python.org/3/library/site.html · executed in a sandbox
An ordinary user runs /opt/tool/venv/bin/tool and gets exit status 126, "Permission denied". The file is mode 755. What is the most likely cause?
A directory on the way, such as the venv itself, lacks search (x) permission for that user
Executing a file requires search permission on every directory in its path. A missing package would start the interpreter and raise ModuleNotFoundError; a PATH problem gives 127 "command not found"; activation is never required to run a venv's program by its full path.
man 7 path_resolution