nikstur / userborn

Declaratively bear (manage) Linux users and groups
MIT License
47 stars 1 forks source link
declarative groups linux nix nixos users

Userborn

Declaratively bear (manage) Linux users and groups.

Features

Where does it run?

It is undeniable that Userborn finds it's origin in NixOS. However, Userborn has been designed to work on any distro. It is effectively distro-agnostic. It will run on any Linux.

Getting Started

NixOS

Userborn is available in Nixpkgs (nixos-unstable). To enable it:

services.userborn.enable = true;

Nondestructivity

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:

Limitations to Nondestructivity

Configuration

You can configure Userborn during runtime via the provided config file and via environment variables.

Environment Variables

Building Userborn

Runtime dependencies:

Build-Time Parameters

You can configure Userborn via compile-time environment variables:

Comparison With Other Tools for Declarative User Management

systemd-sysusers

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:

  1. Does not only create system users (UID < 1000) but also normal users. In the systemd world, "normal" users wouldn't have an entry in /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.
  2. Takes full ownership of the password database and thus also (destructively) changes user entries. For example, it can change passwords, home directories, default shell, etc. Please see the Idempotence section for details of what Userborn can change and what it will never change.

NixOS update-users-groups.pl

Userborn:

  1. Doesn't use perl.
  2. Runs as a systemd service, not as an activation script.
  3. Doesn't rely on a hidden database to track state over the lifetime of a system.
  4. Supports mounting /etc via an (immutable, read-only) overlay.

Limitations