fix(system): handle the DNS resolver step without root on system:install#205
Open
mawiswiss wants to merge 1 commit into
Open
fix(system): handle the DNS resolver step without root on system:install#205mawiswiss wants to merge 1 commit into
mawiswiss wants to merge 1 commit into
Conversation
`dde system:install` writes /etc/resolver/test, which requires root. Run as a
normal user the step failed with a cryptic Symfony rename exception ("Cannot
rename ... Permission denied").
Catch that and surface the exact command to run instead:
echo 'nameserver 127.0.0.1' | sudo tee /etc/resolver/test
The existing-file check now compares trimmed content, so a resolver file left
behind by dde v1 (which lacks a trailing newline) is recognised as already
configured — re-running system:install after a v1 upgrade no longer touches the
file or needs root at all.
Signed-off-by: Marc Wieland <marc@whatwedo.ch>
5f3e590 to
00ad9eb
Compare
Member
Author
|
@sbaerlocher Not sure if your PR (#142) already solves this issue. |
7 tasks
sbaerlocher
added a commit
to sbaerlocher/dde
that referenced
this pull request
Jun 30, 2026
`dde system:install` now configures DNS on Linux (systemd-resolved and NetworkManager) without a `sudo` prefix, and rejects `sudo dde` up-front so `$HOME/.dde/**` can no longer be poisoned with root-owned files. Two production failures from sbaerlocher/savvy PR whatwedo#102 motivated the change: Run 25183781831 (no sudo) failed at the DNS step with `mkdir(): Permission denied` on `/etc/systemd/resolved.conf.d/`; Run 25138709404 (with sudo) ran as root, then the next `dde project:up` as the unprivileged runner failed because `$HOME/.dde/data/dnsmasq/dnsmasq.conf` was owned by uid=0. PrivilegeEscalator implements an optimistic-then-sudo pattern: each write is attempted as the current user and only retried through sudo on a permission error, with the sudo TTY forwarded for interactive prompts. The bin/console guard runs before kernel boot and rejects the unique EUID-0-plus-SUDO_USER signature of `sudo dde`, while letting real-root sessions (containers, provisioning) pass through. DnsmasqService routes the two Linux /etc call sites through the escalator; ensureConfig() under $DDE_DATA_DIR deliberately stays on the bare Filesystem so user-data ownership is preserved. The macOS /etc/resolver/test path is left to whatwedo#205 and stays on the bare Filesystem. Signed-off-by: Simon Bärlocher <simon@whatwedo.ch> Signed-off-by: Simon Bärlocher <s.baerlocher@sbaerlocher.ch>
sbaerlocher
added a commit
to sbaerlocher/dde
that referenced
this pull request
Jun 30, 2026
End-to-end coverage for the no-sudo contract: the Linux happy path that configures DNS without sudo, the `sudo dde` rejection, $DDE_DATA_DIR staying owned by the invoking user, and a follow-up `project:up` still being able to write under $DDE_DATA_DIR. Each case owns its setUp/tearDown with an isolated config/data tree and best-effort cleanup of any /etc artefacts. The macOS resolver path is out of scope for this suite (handled by whatwedo#205). Signed-off-by: Simon Bärlocher <simon@whatwedo.ch> Signed-off-by: Simon Bärlocher <s.baerlocher@sbaerlocher.ch>
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
On macOS,
dde system:installfails the Configuring DNS resolver step:This shows up mainly when upgrading from dde v1: v1 left a
/etc/resolver/testcontainingnameserver 127.0.0.1without a trailing newline, while v2 expects the newline. The exact-match idempotency check therefore never short-circuits, so dde tries to rewrite the root-owned file as a normal user and dies with a raw Symfony rename exception.Fix (minimal)
Writing
/etc/resolver/testneeds root, and the people runningdde system:installare technical — so rather than build elevation into the installer, this just makes the failure mode sane:Tolerant idempotency — the existing-file check now compares trimmed content, so the v1 leftover file is recognised as already configured. Upgrading needs no root and no manual step at all.
Actionable error — when the file genuinely has to be created and dde can't (not root), it now prints the exact command instead of a cryptic rename exception:
That's the whole change: +21/−5 across
DnsmasqServiceand the CHANGELOG, no new classes.Testing
make qagreen — ECS, PHPStan L8, Rector, PHPUnit (1278 tests).Notes