]> git.ipfire.org Git - thirdparty/systemd.git/blame - docs/PORTABILITY_AND_STABILITY.md
po: Translated using Weblate (Swedish)
[thirdparty/systemd.git] / docs / PORTABILITY_AND_STABILITY.md
CommitLineData
02c789f9 1---
e4893c63 2title: Interface Portability and Stability
02c789f9
ZJS
3category: Interfaces
4layout: default
0aff7b75 5SPDX-License-Identifier: LGPL-2.1-or-later
02c789f9
ZJS
6---
7
8eabc083 8# Interface Portability and Stability Promise
e4893c63 9
d7d0eb49 10systemd provides various interfaces developers and programs might rely on.
11Starting with version 26 (the first version released with Fedora 15) we promise to keep a number of them stable and compatible for the future.
e4893c63
ZJS
12
13The stable interfaces are:
14
d7d0eb49 15* **The unit configuration file format**. Unit files written now will stay compatible with future versions of systemd.
16 Extensions to the file format will happen in a way that existing files remain compatible.
f8349d2f 17
d7d0eb49 18* **The command line interface** of `systemd`, `systemctl`, `loginctl`, `journalctl`, and all other command line utilities installed in `$PATH` and documented in a man page.
19 We will make sure that scripts invoking these commands will continue to work with future versions of systemd.
20 Note however that the output generated by these commands is generally not included in the promise, unless it is documented in the man page.
21 Example: the output of `systemctl status` is not stable, but that of `systemctl show` is, because the former is intended to be human readable and the latter computer readable, and this is documented in the man page.
f8349d2f 22
383917ac
LB
23* **The protocol spoken on the socket referred to by `$NOTIFY_SOCKET`**, as documented in
24 [sd_notify(3)](https://www.freedesktop.org/software/systemd/man/sd_notify.html). Note that, although using
25 libsystemd is a good choice, this protocol can also be reimplemented without external dependencies, as
26 demonstrated in the example listed in
485bb19d 27 [sd_notify(3)](https://www.freedesktop.org/software/systemd/man/devel/sd_notify.html#Notes)
f8349d2f 28
d7d0eb49 29* Some of the **"special" unit names** and their semantics.
30 To be precise the ones that are necessary for normal services, and not those required only for early boot and late shutdown, with very few exceptions.
31 To list them here: `basic.target`, `shutdown.target`, `sockets.target`, `network.target`, `getty.target`, `graphical.target`, `multi-user.target`, `rescue.target`, `emergency.target`, `poweroff.target`, `reboot.target`, `halt.target`, `runlevel[1-5].target`.
f8349d2f 32
d7d0eb49 33* **The D-Bus interfaces of the main service daemon and other daemons**. We try to always preserve backwards compatibility, and intentional breakage is never introduced.
34 Nevertheless, when we find bugs that mean that the existing interface was not useful, or when the implementation did something different than stated by the documentation and the implemented behaviour is not useful, we will fix the implementation and thus introduce a change in behaviour.
35 But the API (parameter counts and types) is never changed, and existing attributes and methods will not be removed.
f8349d2f 36
e4893c63
ZJS
37* For a more comprehensive and authoritative list, consult the chart below.
38
d7d0eb49 39The following interfaces will not necessarily be kept stable for now, but we will eventually make a stability promise for these interfaces too.
40In the meantime we will however try to keep breakage of these interfaces at a minimum:
e4893c63 41
e4893c63 42* **The set of states of the various state machines used in systemd**, e.g. the high-level unit states inactive, active, deactivating, and so on, as well (and in particular) the low-level per-unit states.
f8349d2f 43
e4893c63
ZJS
44* **All "special" units that aren't listed above**.
45
46The following interfaces are considered private to systemd, and are not and will not be covered by any stability promise:
47
b2eea3dc 48* **Undocumented switches** to `systemd`, `systemctl` and otherwise.
f8349d2f 49
e4893c63
ZJS
50* **The internal protocols** used on the various sockets such as the sockets `/run/systemd/shutdown`, `/run/systemd/private`.
51
d7d0eb49 52One of the main goals of systemd is to unify basic Linux configurations and service behaviors across all distributions.
53Systemd project does not contain any distribution-specific parts.
54Distributions are expected to convert over time their individual configurations to the systemd format, or they will need to carry and maintain patches in their package if they still decide to stay different.
e4893c63 55
d7d0eb49 56What does this mean for you? When developing with systemd, don't use any of the latter interfaces, or we will tell your mom, and she won't love you anymore.
57You are welcome to use the other interfaces listed here, but if you use any of the second kind (i.e. those where we don't yet make a stability promise), then make sure to subscribe to our mailing list, where we will announce API changes, and be prepared to update your program eventually.
e4893c63 58
d7d0eb49 59Note that this is a promise, not an eternal guarantee.
60These are our intentions, but if in the future there are very good reasons to change or get rid of an interface we have listed above as stable, then we might take the liberty to do so, despite this promise.
61However, if we do this, then we'll do our best to provide a smooth and reasonably long transition phase.
e4893c63
ZJS
62
63
8eabc083 64## Interface Portability And Stability Chart
02c789f9 65
d7d0eb49 66systemd provides a number of APIs to applications.
67Below you'll find a table detailing which APIs are considered stable and how portable they are.
02c789f9 68
b8b73097 69This list is intended to be useful for distribution and OS developers who are interested in maintaining a certain level of compatibility with the new interfaces systemd introduced, without relying on systemd itself.
02c789f9 70
d7d0eb49 71In general it is our intention to cooperate through interfaces and not code with other distributions and OSes.
72That means that the interfaces where this applies are best reimplemented in a compatible fashion on those other operating systems.
73To make this easy we provide detailed interface documentation where necessary.
74That said, it's all Open Source, hence you have the option to a) fork our code and maintain portable versions of the parts you are interested in independently for your OS, or b) build systemd for your distro, but leave out all components except the ones you are interested in and run them without the core of systemd involved.
75We will try not to make this any more difficult than necessary.
76Patches to allow systemd code to be more portable will be accepted on case-by-case basis (essentially, patches to follow well-established standards instead of e.g. glibc or linux extensions have a very high chance of being accepted, while patches which make the code ugly or exist solely to work around bugs in other projects have a low chance of being accepted).
02c789f9 77
d7d0eb49 78Many of these interfaces are already being used by applications and 3rd party code.
79If you are interested in compatibility with these applications, please consider supporting these interfaces in your distribution, where possible.
02c789f9
ZJS
80
81
82## General Portability of systemd and its Components
83
d7d0eb49 84**Portability to OSes:** systemd is not portable to non-Linux systems.
85It makes use of a large number of Linux-specific interfaces, including many that are used by its very core.
86We do not consider it feasible to port systemd to other Unixes (let alone non-Unix operating systems) and will not accept patches for systemd core implementing any such portability (but hey, it's git, so it's as easy as it can get to maintain your own fork...).
87APIs that are supposed to be used as library code are exempted from this: it is important to us that these compile nicely on non-Linux and even non-Unix platforms, even if they might just become NOPs.
02c789f9 88
d7d0eb49 89**Portability to Architectures:** It is important to us that systemd is portable to little endian as well as big endian systems.
90We will make sure to provide portability with all important architectures and hardware Linux runs on and are happy to accept patches for this.
02c789f9 91
d7d0eb49 92**Portability to Distributions:** It is important to us that systemd is portable to all Linux distributions.
93However, the goal is to unify many of the needless differences between the distributions, and hence will not accept patches for certain distribution-specific work-arounds.
94Compatibility with the distribution's legacy should be maintained in the distribution's packaging, and not in the systemd source tree.
02c789f9 95
d7d0eb49 96**Compatibility with Specific Versions of Other packages:** We generally avoid adding compatibility kludges to systemd that work around bugs in certain versions of other software systemd interfaces with. We strongly encourage fixing bugs where they are, and if that's not systemd we rather not try to fix it there.
97(There are very few exceptions to this rule possible, and you need an exceptionally strong case for it).
02c789f9
ZJS
98
99
100## General Portability of systemd's APIs
101
d7d0eb49 102systemd's APIs are available everywhere where systemd is available.
103Some of the APIs we have defined are supposed to be generic enough to be implementable independently of systemd, thus allowing compatibility with systems systemd itself is not compatible with, i.e. other OSes, and distributions that are unwilling to fully adopt systemd.
02c789f9 104
d7d0eb49 105A number of systemd's APIs expose Linux or systemd-specific features that cannot sensibly be implemented elsewhere.
106Please consult the table below for information about which ones these are.
02c789f9 107
d7d0eb49 108Note that not all of these interfaces are our invention (but most), we just adopted them in systemd to make them more prominently implemented.
109For example, we adopted many Debian facilities in systemd to push it into the other distributions as well.
02c789f9
ZJS
110
111
02c789f9
ZJS
112---
113
114
02c789f9 115And now, here's the list of (hopefully) all APIs that we have introduced with systemd:
e4893c63
ZJS
116
117| API | Type | Covered by Interface Stability Promise | Fully documented | Known External Consumers | Reimplementable Independently | Known Other Implementations | systemd Implementation portable to other OSes or non-systemd distributions |
118| --- | ---- | ----------------------------------------------------------------------------------------- | ---------------- | ------------------------ | ----------------------------- | --------------------------- | -------------------------------------------------------------------------- |
92897d76
BF
119| [hostnamed](https://www.freedesktop.org/software/systemd/man/org.freedesktop.hostname1.html) | D-Bus | yes | yes | GNOME | yes | [Ubuntu](https://launchpad.net/ubuntu/+source/ubuntu-system-service), [Gentoo](http://www.gentoo.org/proj/en/desktop/gnome/openrc-settingsd.xml), [BSD](http://uglyman.kremlin.cc/gitweb/gitweb.cgi?p=systembsd.git;a=summary) | partially |
120| [localed](https://www.freedesktop.org/software/systemd/man/org.freedesktop.locale1.html) | D-Bus | yes | yes | GNOME | yes | [Ubuntu](https://launchpad.net/ubuntu/+source/ubuntu-system-service), [Gentoo](http://www.gentoo.org/proj/en/desktop/gnome/openrc-settingsd.xml), [BSD](http://uglyman.kremlin.cc/gitweb/gitweb.cgi?p=systembsd.git;a=summary) | partially |
121| [timedated](https://www.freedesktop.org/software/systemd/man/org.freedesktop.timedate1.html) | D-Bus | yes | yes | GNOME | yes | [Gentoo](http://www.gentoo.org/proj/en/desktop/gnome/openrc-settingsd.xml), [BSD](http://uglyman.kremlin.cc/gitweb/gitweb.cgi?p=systembsd.git;a=summary) | partially |
0d592a5e
FS
122| [initrd interface](/INITRD_INTERFACE) | Environment, flag files | yes | yes | mkosi, dracut, ArchLinux | yes | ArchLinux | no |
123| [Container interface](/CONTAINER_INTERFACE) | Environment, Mounts | yes | yes | libvirt/LXC | yes | - | no |
124| [Boot Loader interface](/BOOT_LOADER_INTERFACE) | EFI variables | yes | yes | gummiboot | yes | - | no |
92897d76
BF
125| [Service bus API](https://www.freedesktop.org/software/systemd/man/org.freedesktop.systemd1.html) | D-Bus | yes | yes | system-config-services | no | - | no |
126| [logind](https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html) | D-Bus | yes | yes | GNOME | no | - | no |
7ecce0e5 127| [sd-bus.h API](https://www.freedesktop.org/software/systemd/man/sd-bus.html) | C Library | yes | yes | - | maybe | - | maybe |
e4893c63 128| [sd-daemon.h API](https://www.freedesktop.org/software/systemd/man/sd-daemon.html) | C Library or Drop-in | yes | yes | numerous | yes | - | yes |
7ecce0e5
ZJS
129| [sd-device.h API](https://www.freedesktop.org/software/systemd/man/sd-device.html) | C Library | yes | no | numerous | yes | - | yes |
130| [sd-event.h API](https://www.freedesktop.org/software/systemd/man/sd-event.html) | C Library | yes | yes | - | maybe | - | maybe |
131| [sd-gpt.h API](https://www.freedesktop.org/software/systemd/man/sd-gpt.html) | Header Library | yes | no | - | yes | - | yes |
132| [sd-hwdb.h API](https://www.freedesktop.org/software/systemd/man/sd-hwdb.html) | C Library | yes | yes | - | maybe | - | yes |
133| [sd-id128.h API](https://www.freedesktop.org/software/systemd/man/sd-id128.html) | C Library | yes | yes | - | yes | - | yes |
e4893c63 134| [sd-journal.h API](https://www.freedesktop.org/software/systemd/man/sd-journal.html) | C Library | yes | yes | - | maybe | - | no |
7ecce0e5
ZJS
135| [sd-login.h API](https://www.freedesktop.org/software/systemd/man/sd-login.html) | C Library | yes | yes | GNOME, polkit, ... | no | - | no |
136| [sd-messages.h API](https://www.freedesktop.org/software/systemd/man/sd-messages.html) | Header Library | yes | yes | - | yes | python-systemd | yes |
137| [sd-path.h API](https://www.freedesktop.org/software/systemd/man/sd-path.html) | C Library | yes | no | - | maybe | - | maybe |
e4893c63
ZJS
138| [$XDG_RUNTIME_DIR](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) | Environment | yes | yes | glib, GNOME | yes | - | no |
139| [$LISTEN_FDS $LISTEN_PID FD Passing](https://www.freedesktop.org/software/systemd/man/sd_listen_fds.html) | Environment | yes | yes | numerous (via sd-daemon.h) | yes | - | no |
140| [$NOTIFY_SOCKET Daemon Notifications](https://www.freedesktop.org/software/systemd/man/sd_notify.html) | Environment | yes | yes | a few, including udev | yes | - | no |
0d592a5e 141| [argv[0][0]='@' Logic](/ROOT_STORAGE_DAEMONS) | `/proc` marking | yes | yes | mdadm | yes | - | no |
e4893c63 142| [Unit file format](https://www.freedesktop.org/software/systemd/man/systemd.unit.html) | File format | yes | yes | numerous | no | - | no |
870d38dc
ZJS
143| [Network](https://www.freedesktop.org/software/systemd/man/systemd.network.html) & [Netdev file format](https://www.freedesktop.org/software/systemd/man/systemd.netdev.html) | File format | yes | yes | no | no | - | no |
144| [Link file format](https://www.freedesktop.org/software/systemd/man/systemd.link.html) | File format | yes | yes | no | no | - | no |
0d592a5e 145| [Journal File Format](/JOURNAL_FILE_FORMAT) | File format | yes | yes | - | maybe | - | no |
b058563a 146| [Journal Export Format](JOURNAL_EXPORT_FORMATS#journal-export-format) | File format | yes | yes | - | yes | - | no |
147| [Journal JSON Format](JOURNAL_EXPORT_FORMATS#journal-json-format) | File format | yes | yes | - | yes | - | no |
0d592a5e
FS
148| [Cooperation in cgroup tree](/PAX_CONTROL_GROUPS) | Treaty | yes | yes | libvirt | yes | libvirt | no |
149| [Password Agents](/PASSWORD_AGENTS) | Socket+Files | yes | yes | - | yes | - | no |
515736d0 150| [udev multi-seat properties](https://www.freedesktop.org/software/systemd/man/sd-login.html) | udev Property | yes | yes | X11, gdm | no | - | no |
e4893c63
ZJS
151| udev session switch ACL properties | udev Property | no | no | - | no | - | no |
152| [CLI of systemctl,...](https://www.freedesktop.org/software/systemd/man/systemctl.html) | CLI | yes | yes | numerous | no | - | no |
f8349d2f 153| [tmpfiles.d](https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html) | File format | yes | yes | numerous | yes | ArchLinux | partially |
e4893c63
ZJS
154| [sysusers.d](https://www.freedesktop.org/software/systemd/man/sysusers.d.html) | File format | yes | yes | unknown | yes | | partially |
155| [/etc/machine-id](https://www.freedesktop.org/software/systemd/man/machine-id.html) | File format | yes | yes | D-Bus | yes | - | no |
156| [binfmt.d](https://www.freedesktop.org/software/systemd/man/binfmt.d.html) | File format | yes | yes | numerous | yes | - | partially |
f8349d2f
LP
157| [/etc/hostname](https://www.freedesktop.org/software/systemd/man/hostname.html) | File format | yes | yes | numerous (it's a Debian thing) | yes | Debian, ArchLinux | no |
158| [/etc/locale.conf](https://www.freedesktop.org/software/systemd/man/locale.conf.html) | File format | yes | yes | - | yes | ArchLinux | partially |
e4893c63
ZJS
159| [/etc/machine-info](https://www.freedesktop.org/software/systemd/man/machine-info.html) | File format | yes | yes | - | yes | - | partially |
160| [modules-load.d](https://www.freedesktop.org/software/systemd/man/modules-load.d.html) | File format | yes | yes | numerous | yes | - | partially |
f8349d2f
LP
161| [/usr/lib/os-release](https://www.freedesktop.org/software/systemd/man/os-release.html) | File format | yes | yes | some | yes | Fedora, OpenSUSE, ArchLinux, Angstrom, Frugalware, others... | no |
162| [sysctl.d](https://www.freedesktop.org/software/systemd/man/sysctl.d.html) | File format | yes | yes | some (it's a Debian thing) | yes | procps/Debian, ArchLinux | partially |
e4893c63 163| [/etc/timezone](https://www.freedesktop.org/software/systemd/man/timezone.html) | File format | yes | yes | numerous (it's a Debian thing) | yes | Debian | partially |
f8349d2f
LP
164| [/etc/vconsole.conf](https://www.freedesktop.org/software/systemd/man/vconsole.conf.html) | File format | yes | yes | - | yes | ArchLinux | partially |
165| `/run` | File hierarchy change | yes | yes | numerous | yes | OpenSUSE, Debian, ArchLinux | no |
e4893c63
ZJS
166| [Generators](https://www.freedesktop.org/software/systemd/man/systemd.generator.html) | Subprocess | yes | yes | - | no | - | no |
167| [System Updates](https://www.freedesktop.org/software/systemd/man/systemd.offline-updates.html) | System Mode | yes | yes | - | no | - | no |
7e215af7 168| [Presets](https://www.freedesktop.org/software/systemd/man/systemd.preset.html) | File format | yes | yes | - | no | - | no |
e4893c63 169| Udev rules | File format | yes | yes | numerous | no | no | partially |
02c789f9
ZJS
170
171
172### Explanations
173
d7d0eb49 174Items for which "systemd implementation portable to other OSes" is "partially" means that it is possible to run the respective tools that are included in the systemd tarball outside of systemd.
175Note however that this is not officially supported, so you are more or less on your own if you do this.
176If you are opting for this solution simply build systemd as you normally would but drop all files except those which you are interested in.
02c789f9 177
d7d0eb49 178Of course, it is our intention to eventually document all interfaces we defined.
179If we haven't documented them for now, this is usually because we want the flexibility to still change things, or don't want 3rd party applications to make use of these interfaces already.
180That said, our sources are quite readable and open source, so feel free to spelunk around in the sources if you want to know more.
02c789f9
ZJS
181
182If you decide to reimplement one of the APIs for which "Reimplementable independently" is "no", then we won't stop you, but you are on your own.
183
d7d0eb49 184This is not an attempt to comprehensively list all users of these APIs.
185We are just listing the most obvious/prominent ones which come to our mind.
02c789f9 186
d7d0eb49 187Of course, one last thing I can't make myself not ask you before we finish here, and before you start reimplementing these APIs in your distribution:
188are you sure it's time well spent if you work on reimplementing all this code instead of just spending it on adopting systemd on your distro as well?
d89cde09 189
1e1f4f44 190## Independent Operation of systemd Programs
d89cde09 191
d3e5639e 192Some programs in the systemd suite are intended to operate independently of the
d89cde09
ZJS
193running init process (or even without an init process, for example when
194creating system installation chroots). They can be safely called on systems with
195a different init process or for example in package installation scriptlets.
196
197The following programs currently and in the future will support operation
198without communicating with the `systemd` process:
199`systemd-escape`,
200`systemd-id128`,
201`systemd-path`,
202`systemd-tmpfiles`,
203`systemd-sysctl`,
204`systemd-sysusers`.
205
206Many other programs support operation without the system manager except when
5c7a4f21 207the specific functionality requires such communication. For example,
d89cde09 208`journalctl` operates almost independently, but will query the boot id when
0a5a8f13
ZJS
209`--boot` option is used; it also requires `systemd-journald` (and thus
210`systemd`) to be running for options like `--flush` and `--sync`.
211`systemd-journal-remote`, `systemd-journal-upload`, `systemd-journal-gatewayd`,
212`coredumpctl`, `busctl`, `systemctl --root` also fall into this category of
213mostly-independent programs.