Declaratively bear (manage) Linux users and groups.
/etc/subuid and /etc/subgid for rootless containers.Userborn is available in Nixpkgs. To enable it:
services.userborn.enable = true;
While Userborn finds its origin in NixOS, it has been designed to work on any distro. However, there are currently no ready-to-use integrations for other distros. If you're interested in adding one, please reach out to me!
/etc/sub{u,g}id for an
owner that no longer requests one, so the range cannot be reassigned to a
different owner./etc/{group,passwd,shadow} files is
never changed. If the files already exist before Userborn runs for the first
time it will retain these values.This prohibits UID/GID re-use which is a security issue. The danger of UID/GID re-use is best illustrated by an example. Imagine the following scenario:
Userborn support mutable users. This feature allows you to manage some users
via Userborn and manage other users imperatively with tools like useradd,
usermod, etc.
When the mutable user feature is enabled by setting USERBORN_MUTABLE_USERS = true, only users and groups that were already in the previous config are
disabled and drained. All other users/groups remain enabled.
Userborn will still "re-take" control of users/groups that were imperatively created and later added to the Userborn config. For example:
useradd called normalo.normalo to your Userborn config setting a
different password.normalo and take full ownership of the entire user.Userborn writes /etc/subuid and /etc/subgid so that tools like
newuidmap/newgidmap (used by rootless Podman, Docker, and similar) work
out of the box.
Per user you can either:
subUidRanges / subGidRanges, which are written
verbatim, orautoSubIdRange: true to have Userborn allocate a single 65536-wide
range at or above 100000 that does not overlap any other owner's ranges.Auto-allocated ranges are stable: once written they are read back from
/etc/sub{u,g}id on subsequent runs and never moved, even if other ranges
change around them. As with UIDs, entries for owners that disappear from the
config are kept so the range cannot be reused by a different owner.
If the resulting set of ranges overlaps across distinct owners (which can
only happen via explicit configuration or pre-existing on-disk state),
Userborn refuses to write /etc/sub{u,g}id and exits with an error. The
other databases (passwd, group, shadow) are still written.
You can configure Userborn during runtime via the provided config file and via environment variables.
The config file is specified in a provided JSON schema which you can use to see available options and to validate your config.
USERBORN_MUTABLE_USERS: Set this to the string true if you want to enable
mutable users.USERBORN_PREVIOUS_CONFIG: Set this to the path of the previous Userborn
config. This is necessary when you enable mutable users. Otherwise, this
variable is ignored. It is your responsibility to update this on each change
of the Userborn config.Runtime dependencies:
libxcryptYou can configure Userborn via compile-time environment variables:
USERBORN_NO_LOGIN_DEFAULT_PATH: Set this to the default path of the
nologin binary in your distro or system. If this is not set, the value
/run/current-system/sw/bin/nologin is used which will only make sense on
NixOS.Userborn follows the same spirit as systemd-sysusers and indeed can be viewed as an adaptation of sysusers to a more specialized system where the service takes full ownership of the user database (i.e. also changes certain fields of entries).
Userborn has two key differences from systemd-sysusers:
/etc/{group,passwd,shadow}. Userborn, however affords them one of these
entries, not because the systemd way is wrong or bad but because this way is
easier and fully backwards compatible.update-users-groups.plUserborn:
/etc via an (immutable, read-only) overlay./etc/gshadow).Rust
94.6%
Nix
5.4%
Declaratively bear (manage) Linux users and groups.
/etc/subuid and /etc/subgid for rootless containers.Userborn is available in Nixpkgs. To enable it:
services.userborn.enable = true;
While Userborn finds its origin in NixOS, it has been designed to work on any distro. However, there are currently no ready-to-use integrations for other distros. If you're interested in adding one, please reach out to me!
/etc/sub{u,g}id for an
owner that no longer requests one, so the range cannot be reassigned to a
different owner./etc/{group,passwd,shadow} files is
never changed. If the files already exist before Userborn runs for the first
time it will retain these values.This prohibits UID/GID re-use which is a security issue. The danger of UID/GID re-use is best illustrated by an example. Imagine the following scenario:
Userborn support mutable users. This feature allows you to manage some users
via Userborn and manage other users imperatively with tools like useradd,
usermod, etc.
When the mutable user feature is enabled by setting USERBORN_MUTABLE_USERS = true, only users and groups that were already in the previous config are
disabled and drained. All other users/groups remain enabled.
Userborn will still "re-take" control of users/groups that were imperatively created and later added to the Userborn config. For example:
useradd called normalo.normalo to your Userborn config setting a
different password.normalo and take full ownership of the entire user.Userborn writes /etc/subuid and /etc/subgid so that tools like
newuidmap/newgidmap (used by rootless Podman, Docker, and similar) work
out of the box.
Per user you can either:
subUidRanges / subGidRanges, which are written
verbatim, orautoSubIdRange: true to have Userborn allocate a single 65536-wide
range at or above 100000 that does not overlap any other owner's ranges.Auto-allocated ranges are stable: once written they are read back from
/etc/sub{u,g}id on subsequent runs and never moved, even if other ranges
change around them. As with UIDs, entries for owners that disappear from the
config are kept so the range cannot be reused by a different owner.
If the resulting set of ranges overlaps across distinct owners (which can
only happen via explicit configuration or pre-existing on-disk state),
Userborn refuses to write /etc/sub{u,g}id and exits with an error. The
other databases (passwd, group, shadow) are still written.
You can configure Userborn during runtime via the provided config file and via environment variables.
The config file is specified in a provided JSON schema which you can use to see available options and to validate your config.
USERBORN_MUTABLE_USERS: Set this to the string true if you want to enable
mutable users.USERBORN_PREVIOUS_CONFIG: Set this to the path of the previous Userborn
config. This is necessary when you enable mutable users. Otherwise, this
variable is ignored. It is your responsibility to update this on each change
of the Userborn config.Runtime dependencies:
libxcryptYou can configure Userborn via compile-time environment variables:
USERBORN_NO_LOGIN_DEFAULT_PATH: Set this to the default path of the
nologin binary in your distro or system. If this is not set, the value
/run/current-system/sw/bin/nologin is used which will only make sense on
NixOS.Userborn follows the same spirit as systemd-sysusers and indeed can be viewed as an adaptation of sysusers to a more specialized system where the service takes full ownership of the user database (i.e. also changes certain fields of entries).
Userborn has two key differences from systemd-sysusers:
/etc/{group,passwd,shadow}. Userborn, however affords them one of these
entries, not because the systemd way is wrong or bad but because this way is
easier and fully backwards compatible.update-users-groups.plUserborn:
/etc via an (immutable, read-only) overlay./etc/gshadow).Rust
94.6%
Nix
5.4%