systemd rust banner

systemd, the init system and service manager that most mainstream Linux distributions use, has merged support for writing its programs in Rust. It landed on the main branch through a pull request of 19 commits.

The pull request replaces an earlier proposal and follows rules the maintainers agreed upon at a recent hackfest in Berlin.

The first program to use it is systemd-keyring-setup, and it adds X.509 certificates to kernel keyrings, such as the dm-verity and fs-verity ones, at boot before locking them down.

If you remember, we recently talked about Amutable launching a preview for their new offering. Anyhow, let’s see what they are up to now.

Rust, but on systemd’s terms

With the approach they are following, Rust stays optional, and systemd can still be built without it.

The Rust code’s scope is limited to new standalone programs that nothing else depends on, while everything builds with meson, excluding cargo from the equation. Only the core and libc crates are allowed, and that rules out the standard library and alloc.

Programs would use systemd’s own Box and Vec types, and a failed allocation would return an error instead of panicking. A Rust program must also behave like its C counterparts, with a test checking this for programs that declare the same command.

Building Rust programs involves having rustc 1.85, bindgen 0.71.1, and meson 1.4.0 or newer.

Distributions that build systemd with every feature enabled, such as Arch and openSUSE OBS, will have to install the Rust toolchain or turn Rust support off.

The shared library problem

The library that systemd’s programs share, libsystemd-shared, stays in C for now. Putting Rust in it would need proper shared library support from Rust itself, and the language still has no stable ABI.

Rust programs use that C library the same way C programs do, and putting Rust inside it would duplicate the same code across the library and many of systemd’s binaries.

Filesystem access is another hurdle, since systemd looks up paths through file descriptors to keep that step secure and does not accept Rust’s standard path handling for its sensitive components. It would like Rust to support that approach as well.

systemd still wants Rust in its core and says it is open to work with the Rust community to get there.

A wave of rust

systemd is not the only part of the Linux stack making room for Rust.

The memory-safe language entered the Linux kernel with 6.1 as an exploratory effort, with the kernel maintainers declaring late last year that the experiment was over.

Ubuntu has been taking the same route with its core tools since some time now, when sudo-rs and uutils coreutils became the default experiences.

All that strongly suggests that the adoption of Rust will only accelerate as we go into a very busy 2027.

Leave a Comment