| Age | Commit message (Collapse) | Author |
|
This is the first PR in a fresh branch that refactors `dbx` to a
new agentic development paradigm. The idea is to create a single
development container for each project, and provision it with a
working agent harness.
The development flow is changed to fetching Git refs from the
development box for review and signing on the host. It is meant as
a hardened alternative compared to the previous version (where we
would typically expose a GPG/SSH socket over an `ssh` connection
to the guest, and rely on `pinentry` and `askpass` configuration
to enforce user presence or verification tests for each
authenticated operation.
It is still in the early stages of "ideating" how the final project
would look like, but I already have some idea on how I want it.
|
|
Move back to using plain containers, as they have stronger security
guarantees (`container machine` forwards SSH socket for example).
|
|
TSI has some known limitations (such as mapping `:0` ports on the
guest incorrectly). For this to work, some additional `passt`
configuration was needed:
- Enable `passt` in the `krun` configuration
- `passt` cannot bind to service ports, so an additional sysctl in
the container to remove all ports from the service port range.
This does not affect the user in the guest
- Additional `pasta` flags to make connections from the guest to
the host not look like local ones on loopback (doesn't prevent
access to the host over the network, but makes it look like
another system on the local network).
In general network isolation is still lacking and needs to be
generally improved (but I lack understanding to make it work).
|
|
The `XDG_RUNTIME_DIR` is a Linux-only thing, and there is no
established equivalent on macOS, so just don't create the
directory.
Also cleaned up some "if unset" expansions in the script.
|
|
|
|
Two options weren't actually needed but still hanging around:
- the KRUN_INIT_PID1 caused more issues than it solved, as it
prevented the proper reporting of exit codes (among other things)
to `crun`. Now that we have an `/sbin/stop` script, and the init
script correctly forces `tini` to be a subreaper, this is no
longer needed.
- the `network` flag, specifically adding the `--map-guest-addr none`
flags wasn't actually doing anything for security.
|
|
Similar to how we added an "RC" system to the init script, we
now have a custom tear-down script (which can do things like
unmount loop devices).
Furthermore, we make sure that an `$XDG_RUNTIME_DIR/dbx` exists
for things like SSH control sockets (so they can go somewhere
where an application has R/W access to, while only keeping RO
access to the configurations).
|
|
We added a basic RC system (that runs executable scripts from a
directory in the container) for greater customization. Additionally,
the post-installation script now runs as root (as it alwasy should
have) to allow for additional customization of the enviroment before
dropping to the user.
This allows for some more complicated devbox provisioning such as:
- Making /dev/net/tun accessible to the developement user for pasta
- Support setting up XDG runtime dirs if required
In particular, this supports a case for running `podman` within the
`krun` container: `podman`'s overlay storage driver does not work
on `virtiofs` file systems, this allows you to create a loop-mount
for `podman` storage to work around this issue.
```sh
truncate -s 32G /var/lib/user.img
mkfs.ext4 /var/lib/user.img
mkdir -p /var/lib/user
USER="$1"
UID="$(id -u "$USER")"
GID="$(id -g "$USER")"
cat <<EOF >/etc/dbx/rc.d/user-dirs.sh
mountpoint -q /var/lib/user || mount -o loop /var/lib/user.img /var/lib/user
install -d -m 0755 -o '$UID' -g '$GID' '/var/lib/user/$UID'
install -d -m 0700 -o '$UID' -g '$GID' '/run/user/$UID'
EOF
```
For obvious reasons, you do not want the 32GB image to be included
in the devbox image. This allows ths user to use
`/var/lib/user/1000/...` as `podman` graphroot storage:
```toml
[storage]
driver = "overlay"
graphroot = "/var/lib/user/1000/containers/storage"
```
|
|
While `User=%u` does work in practice, it has some negative side
effects. In paricular, `Match` configurations in the user-supplied
`.config/dbx/$NAME.ssh_config` use the literal %u instead of the
expanded value.
Get the user name manually with `id -un` and use that instead of
relying on %u expansion.
|
|
|
|
We now support a `skel` directory, and **no longer specify the
host bind port**. This has a nice side-effect that we don't have
to worry about devbox port collisions manually - the `ssh_config`
gets updated automatically with the same machinery used for
updating the IP address that was used by the `container` engine
runtime.
Some additional fixes were also added.
|
|
We also did a general "hardening" pass on the setup:
- Use `printf` for no weird behaviour with `-` prefixed user-text
- More defensive validation of user-specified parameters
- No more root access in the `devbox`, but instead a -R flag
- Stricter SSH configuration
|
|
First of all, we just use Bash instead of POSIX `sh` - there are some
goodies that make it more robust (like `pipefail` and array expansion).
This also allows us to make a few more checks on the parameters (such
as denying invalid host specifies for `scp`).
Added an option for regenerating the SSH configuration
|
|
|
|
|
|
I ended up fighting with C for no benefit. We are back to a Shell
script, but this time we use (mostly) POSIX shell (we use `local`
because it is so convenient, although it is technically not POSIX).
Additionally, this time we create a monolithic script, and already
add hooks to allow for multiple contianer engines to work with the
script (for now, just `container` is implemented and `podman krun`
is stubbed).
|
|
We stopped in the middle, as I realized that I am spending WAY to
much time just to do basic things in C instead of actually focusing
on implementing the tool.
|
|
|
|
We take a slightly different API approach where we return an error
number and other values are "returned" through pointers that are
passed into the function.
Other functions will be adapted to use this pattern going forward.
|
|
We are now able to create devboxes :tada:. It supports the post
install script, and added support for custom SSH configuration
options (through `~/.config/dbx/$NAME.ssh_config` file).
|
|
We setup a single-use SSH key and can generate an SSH
configuration. Additionally, we support user SSH settings in
`~/.config/dbx/$NAME.ssh_config`.
This still doesn't quite work (there are some left-over TODOs).
In particular:
1. We need to get the generated SSH public key to the authorized
keys list on the devbox
2. We need to SCP and run the optional post-installation script
|
|
We now search `PATH` for the engine executable (`container` or `podman`)
and use non-`p` variands of `posix_spawn` and `execv`.
This allows us to implement engine initialization as "find the path to
the engine command, and fail if you cannot find it". It also avoids
searching the path on each engine invocation.
|
|
|
|
|
|
|
|
Previously, the devbox user would default to the `POSIX` locale
which meant that a lot of minor things around UTF-8 would not
work.
We now update the locale to use one with UTF-8 support; note that
we just use the minimal C locale instead of building one. Users
can (if they chose) use something like `dpkg-reconfigure locales`
and `update-locale` in order to modify their default locale if
they want something else specific.
Additionally, get rid of the annoying known hosts warning, by
keeping a devbox specific known hosts file.
|
|
With `container` v1, a new `machine` subcommand was introduced in
order to support long-lived machines.
Port the `dbx` utility to use `container machine` instead of using
regular containers. The main motivation for this is:
- `container machine`s are more elastic; when they are stopped
their containers are removed entirely (which is different to a
container that is stopped, but not removed)
- `container machine`s can modify settings (such as CPU and memory
limits) after creation, allowing for the machine to change over
time as needed
Overall, the structure stays largely the same as before; the main
difference being how initialization is done (since `container
machine` has built-in support for initializing a user with
passwordless `sudo`). Note we explicitly set `--home-mount=none`
in order to keep the same filesystem isolation guarantees that
existed before (files can be copied with `scp`; there is no
`container cp` analogy for machines).
One notable difference is network management. `container machine`s
are assigned their own virtual network device and get a completely
separate IP to the host (which is different than before where
container ports were being published to the host). I do not know
which one is more secure...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
License code for publishing under GPL, and cleanup a bit (in
particular, add a `Makefile` for building the Go `dbx-proxy`
executable).
|
|
Improve DX by adding a utility to create linked executables that run
in a devbox (for example, editors can natively run LSP servers) and
proxy container TCP connections to the host.
The proxying works over stdin and stdout, so it does not require the
container to publish ports (and know what ports need to be published
beforehand). It was written in Go (since writing this in Bash was too
unruly).
I want to port the whole project to OCaml once I have time :)
|
|
In order to correctly handle signals.
|
|
You can now enter and run commands in a devbox.
|
|
We can now create and initialize a `dbx` container!
|