Skip to content

Linux support for the CLI and daemon #48

Closed
Closed

Description

@sineld

What's missing

Flock runs on macOS and Windows only. On Linux the CLI builds, but flock install, the DNS setup, the CA trust and the background daemon have no Linux implementation, so a Linux machine can't serve *.test sites.

Approach

The daemon and the web server are already portable. What needs adding is the per-OS setup, in internal/cli/install_linux.go and internal/dns.

  • The CLI is named flock-php on Linux. util-linux ships flock(1) on every distribution, and scripts rely on it.
  • The daemon:
    • It runs as a systemd user unit, falling back to a detached process without a user manager.
    • setcap cap_net_bind_service lets it bind ports 80 and 443 without root.
  • DNS:
    • A small root unit, flock-dns.service, creates a dummy link flock0 and routes ~test to Flock's DNS server through systemd-resolved (resolvectl dns/domain). It doesn't use a global resolved.conf drop-in, which breaks when the user has DNS= servers.
    • A NetworkManager drop-in keeps NetworkManager off flock0.
    • The daemon reports when the link drifts.
  • Trust: the CA goes into the system store (update-ca-certificates / update-ca-trust) and into NSS databases (Chrome, Firefox).
  • Packages: the Linux builds of PHP and the services are in feat: Linux packages: PHP for x64 and arm64, and the mirrored services binaries#24–ci: let pull requests that change only docs/ through without an issue, and label them #28.

Status

The implementation is ready as #12. I opened it before the issue rule existed and will add Fixes #<this> to it once this is approved.

Activity

  1. Nejcc commented on Oct 21, 2026

    @Nejcc

    Confirming: I ran the #22 harness against #12's current head on Arch, Ubuntu 24.04 and Fedora (real systemd + NetworkManager), with 0 failures. Once this is approved I'll add Refs #48 to #16 and #22, and re-run the harness after #12 is rebased onto develop.

  2. Nejcc commented on Oct 21, 2026

    @Nejcc

    Here is my own run of the harness from #22, as promised.

    Result: 116 checks passed, 0 failed (arch 0 failed, ubuntu 0 failed, fedora 0 failed), exit 0.

    Full output
    building the archives…
    ######## arch
    PASS  install this tree
    PASS  user unit active
    PASS  flock-php installed, no bin/flock
    PASS  util-linux flock first in a new shell
    PASS  flock-php on PATH in a new shell
    PASS  flock-dns.service active and enabled
    PASS  flock0 routes ~test
    PASS  no drop-in in the global scope
    PASS  NetworkManager drop-in is zz-flock.conf (no 90-flock.conf)
    PASS  setcap, listening on 80 and 443
    PASS  CA in Chrome's NSS database
    PASS  installed: hello.test (resolvectl, getent)
    PASS  installed: example.com, then hello.test again
    PASS  installed: HTTPS to hello.test (system trust)
    == drift
    PASS  status clean
    PASS  status reports a flushed flock0 within 70 s
          *.test while it's reported: fails
    PASS  restarting flock-dns.service clears it within 70 s
    PASS  repaired: hello.test (resolvectl, getent)
    PASS  repaired: example.com, then hello.test again
    PASS  repaired: HTTPS to hello.test (system trust)
    == resolved restart, reboot
    PASS  resolved restarted: hello.test (resolvectl, getent)
    PASS  resolved restarted: example.com, then hello.test again
    PASS  resolved restarted: HTTPS to hello.test (system trust)
    PASS  after reboot: flock-dns.service and the user unit active
    PASS  rebooted: hello.test (resolvectl, getent)
    PASS  rebooted: example.com, then hello.test again
    PASS  rebooted: HTTPS to hello.test (system trust)
    == uninstall --purge
    PASS  flock-dns.service and flock0 gone
    PASS  NetworkManager drop-in gone
    PASS  CA gone from the system and NSS
    PASS  PATH line, user unit and ~/.config/Flock gone
    PASS  hello.test gone, example.com resolves
    == arch: 0 failed
    ######## ubuntu
    PASS  install this tree
    PASS  user unit active
    PASS  flock-php installed, no bin/flock
    PASS  util-linux flock first in a new shell
    PASS  flock-php on PATH in a new shell
    PASS  flock-dns.service active and enabled
    PASS  flock0 routes ~test
    PASS  no drop-in in the global scope
    PASS  NetworkManager drop-in is zz-flock.conf (no 90-flock.conf)
    PASS  setcap, listening on 80 and 443
    PASS  CA in Chrome's NSS database
    PASS  installed: hello.test (resolvectl, getent)
    PASS  installed: example.com, then hello.test again
    PASS  installed: HTTPS to hello.test (system trust)
    == NetworkManager
    PASS  flock0 unmanaged
    PASS  networking off/on + resolved restart: flock0 keeps its address
    PASS  networking off/on + resolved restart: hello.test (resolvectl, getent)
    PASS  networking off/on + resolved restart: example.com, then hello.test again
    PASS  networking off/on + resolved restart: HTTPS to hello.test (system trust)
    PASS  managed yes doesn't take flock0
    PASS  a drop-in after Flock's: status reports NetworkManager managing flock0 within 70 s
    PASS  drop-in removed: flock0 unmanaged again
    PASS  status clean again
    == drift
    PASS  status clean
    PASS  status reports a flushed flock0 within 70 s
          *.test while it's reported: still resolves
    PASS  restarting flock-dns.service clears it within 70 s
    PASS  repaired: hello.test (resolvectl, getent)
    PASS  repaired: example.com, then hello.test again
    PASS  repaired: HTTPS to hello.test (system trust)
    == resolved restart, reboot
    PASS  resolved restarted: hello.test (resolvectl, getent)
    PASS  resolved restarted: example.com, then hello.test again
    PASS  resolved restarted: HTTPS to hello.test (system trust)
    PASS  after reboot: flock-dns.service and the user unit active
    PASS  rebooted: hello.test (resolvectl, getent)
    PASS  rebooted: example.com, then hello.test again
    PASS  rebooted: HTTPS to hello.test (system trust)
    == uninstall --purge
    PASS  flock-dns.service and flock0 gone
    PASS  NetworkManager drop-in gone
    PASS  other NetworkManager drop-ins kept
    PASS  CA gone from the system and NSS
    PASS  PATH line, user unit and ~/.config/Flock gone
    PASS  hello.test gone, example.com resolves
    == ubuntu: 0 failed
    ######## fedora
    PASS  install this tree
    PASS  user unit active
    PASS  flock-php installed, no bin/flock
    PASS  util-linux flock first in a new shell
    PASS  flock-php on PATH in a new shell
    PASS  flock-dns.service active and enabled
    PASS  flock0 routes ~test
    PASS  no drop-in in the global scope
    PASS  NetworkManager drop-in is zz-flock.conf (no 90-flock.conf)
    PASS  setcap, listening on 80 and 443
    PASS  CA in Chrome's NSS database
    PASS  installed: hello.test (resolvectl, getent)
    PASS  installed: example.com, then hello.test again
    PASS  installed: HTTPS to hello.test (system trust)
    == NetworkManager
    PASS  flock0 unmanaged
    PASS  networking off/on + resolved restart: flock0 keeps its address
    PASS  networking off/on + resolved restart: hello.test (resolvectl, getent)
    PASS  networking off/on + resolved restart: example.com, then hello.test again
    PASS  networking off/on + resolved restart: HTTPS to hello.test (system trust)
    PASS  managed yes doesn't take flock0
    PASS  a drop-in after Flock's: status reports NetworkManager managing flock0 within 70 s
    PASS  drop-in removed: flock0 unmanaged again
    PASS  status clean again
    == drift
    PASS  status clean
    PASS  status reports a flushed flock0 within 70 s
          *.test while it's reported: still resolves
    PASS  restarting flock-dns.service clears it within 70 s
    PASS  repaired: hello.test (resolvectl, getent)
    PASS  repaired: example.com, then hello.test again
    PASS  repaired: HTTPS to hello.test (system trust)
    == resolved restart, reboot
    PASS  resolved restarted: hello.test (resolvectl, getent)
    PASS  resolved restarted: example.com, then hello.test again
    PASS  resolved restarted: HTTPS to hello.test (system trust)
    PASS  after reboot: flock-dns.service and the user unit active
    PASS  rebooted: hello.test (resolvectl, getent)
    PASS  rebooted: example.com, then hello.test again
    PASS  rebooted: HTTPS to hello.test (system trust)
    == uninstall --purge
    PASS  flock-dns.service and flock0 gone
    PASS  NetworkManager drop-in gone
    PASS  other NetworkManager drop-ins kept
    PASS  CA gone from the system and NSS
    PASS  PATH line, user unit and ~/.config/Flock gone
    PASS  hello.test gone, example.com resolves
    == fedora: 0 failed
    == 0 failed in all
    
  3. lukas-frey commented on Oct 26, 2026

    @lukas-frey
    Member

    I replied inside the PR.

  4. added this to the v1.0.0 milestone on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions