S6-SYSTEMD-UNIT-CONVERSION(7)

๐Ÿ“ฆ version 2.15.1.0, in nixpkgs unstable

๐Ÿ’… s6-systemd-unit-conv(7) โ€” Miscellaneous Information Manual ๐ŸŽ€

ok so this is s6-systemd-unit-conv(7), and it lives in the Miscellaneous Information Manual, and it's literally all about how to convert systemd unit files to an s6 installation. buckle up bestie ๐Ÿ’–


โœจ NAME โœจ

s6-systemd-unit-conversion โ€” how to convert systemd unit files to an s6 installation. that's it, that's the name, slay ๐Ÿ’…


๐ŸŒธ DESCRIPTION ๐ŸŒธ

okay so the question of "how do i convert a whole set of services managed by systemd[1] into a set of services managed by s6" comes up constantly on our support channels. and lowkey, an automated conversion tool that parses a bunch of systemd.unit(5) files and spits out a bunch of directories (cf. s6-service-directory(7)) or s6-rc service definition directories (cf. s6-rc-compile(8)) would be genuinely so useful for people who wanna migrate to s6 but already have a whole existing base of services running under systemd. ๐Ÿซถ

unfortunately ๐Ÿ˜ญ automating that conversion is extremely difficult. the main reason is that systemd and s6 are architectured in very different ways: how they view a set of services, how they modelize a machine, what kind of solution they bring to a given problem, and the extent of what they're supposed to manage โ€” there are like, few similarities between how systemd and s6 operate. ngl, it's giving two entirely different species. as a consequence, the way systemd maps a set of services into unit files is not isomorphic to the way s6 does, so translating a setup between systemd and s6 requires intelligence. it is not possible to write an automated tool that converts a set of services accurately and idiomatically without doing a full, deep system analysis โ€” and writing such a tool would be a huge undertaking. ๐Ÿ’€

fortunately tho (plot twist โœจ), in practice, most unit files only use a small subset of all the theoretically supported directives. most services that run under systemd can be converted to run under s6 without too much trouble. so, depending on the exact nature of the set of services, it may be possible to write a reasonable converter that is limited in what it supports but does not require a full understanding of systemd (or even s6). ๐Ÿฆ‹

this document targets people who think about writing a tool to automatically convert a set of unit files to a set of s6 services and are trying to assess its feasability and difficulty. we analyze all the directives that may appear in a unit file for their services, and rate the difficulty of translating the directive โ€” i.e. the amount of complexity that would need to go into the converter tool if that directive were to be supported. ๐Ÿ’–

we rate difficulty on a scale from 0 to 10. bestie, here's the vibe check on the numbers:

  • 0 โ€” the directive is irrelevant to s6 and can just be ignored. bye ๐Ÿ‘‹
  • 1 โ€” there is a straightforward, one-for-one way of translating the systemd directive into s6 parlance. easy ate. ๐Ÿ’…
  • 10 โ€” the directive is so systemd-specific that it is impossible to express it on an s6 system and the unit file cannot be converted as is. rip ๐Ÿ™ˆ
  • 9 โ€” it is theoretically possible to convert, given infinite time and manpower to write a tool that analyzes the systemd-managed system holistically and outputs an equivalent system managed by s6, but in practice nobody's ever going to write such a tool. not me writing that. never. ๐Ÿ˜ญ

we only address directives that can appear in service units, which are the ones that can reasonably be expected to translate to s6 or s6-rc services. we do not address directives that can only appear in other kinds of unit files such as slices, timers, sockets, etc. ๐ŸŽ€


๐Ÿงš Difficulty by directive ๐Ÿงš

use this section to answer the question: "I have this directive in my unit file, how hard would it be to write a converter tool that processes this file?" ๐Ÿ’ญ

๐Ÿ”ฅ Directives documented in systemd.unit(5) ๐Ÿ”ฅ

[Unit] section

  • Description โ€” 0.
  • Documentation โ€” 0.
  • Wants โ€” 3. Dependencies between services are implemented via s6-rc[1]; in order to implement Wants the converter needs to target s6-rc, which is a reasonable requirement for a complete set of services. However, Wants expresses weak dependencies, which are not supported by the current version of s6-rc, so the exact nature of the dependency needs to be checked by hand. ๐Ÿ‘€
  • Requires โ€” 2. The converter needs to target s6-rc, but Requires dependencies map well to the s6-rc dependency model. slay.
  • Requisite โ€” 3. systemd supports a lot of weird types of dependencies that the current version of s6-rc does not (by design). ๐Ÿ’€
  • BindsTo โ€” 3. Same.
  • PartOf โ€” 3. Same.
  • Upholds โ€” 0. In s6, services are upheld by the supervisor, not by other services. main character energy tbh ๐Ÿ‘‘
  • Conflicts โ€” 5. There are no negative dependencies in the s6 world, and a converter tool would have to implement it on top of the existing system.
  • Before โ€” 2. systemd loves to have a zillion keywords to express slightly different kinds of dependencies, and only a small subset of all the possible combinations are useful. ๐Ÿ™ˆ
  • After โ€” 2.
  • OnFailure โ€” 5. Permanent failure is a very exceptional state in s6, there are no hooks to do something when permanent failure occurs; so a converter would need to add scripting around that.
  • OnSuccess โ€” 2. These are oneshot dependencies.
  • PropagatesReloadTo โ€” 0. Under s6-rc you can either reload a single service or the whole dependency chain that starts at the service. Other configurations just make no sense. periodt.
  • ReloadPropagatedFrom โ€” 0. Same.
  • PropagatesStopTo โ€” 0. Same with stopping a single service or a dependency chain of services.
  • StopPropagatedFrom โ€” 0. Same.
  • JoinsNamespaceOf โ€” 8. There are no native s6 tools to manage namespaces.
  • RequiresMountsFor โ€” 4. Mounts are not handled in a special way in s6, the converter would have to know what service mounts what filesystem. ๐Ÿ—‚๏ธ
  • OnFailureJobMode โ€” 6. This is what happens when you mix layers.
  • IgnoreOnIsolate โ€” 0.
  • StopWhenUnneeded โ€” 0.
  • RefuseManualStart โ€” 4. Would need some scripting around. There's no reason to ever use that directive though.
  • RefuseManualStop โ€” 1.
  • AllowIsolate โ€” 0.
  • DefaultDependencies โ€” 2.
  • CollectMode โ€” 0.
  • FailureAction โ€” 3. Anything involving permanent failure need to be scripted around, because s6 considers that it is an extreme state that requires administrator attention and will stop making automatic decisions. โš ๏ธ
  • SuccessAction โ€” 3. That's a oneshot dependency, but systemd doesn't realize that.
  • FailureActionExitStatus โ€” 1.
  • SuccessActionExitStatus โ€” 1.
  • JobTimeoutSec โ€” 9. s6 has no concept of jobs.
  • JobRunningTimeoutSec โ€” 9. Same.
  • JobTimeoutAction โ€” 9. Same.
  • JobTimeoutRebootArgument โ€” 9. Same.
  • StartLimitIntervalSec โ€” 3. s6 does not limit start rate. It can stop a service that has a high death rate: that's the configuration knob that makes sense. That directive can be converted to check death interval instead.
  • StartLimitBurst โ€” 3. Same.
  • StartLimitAction โ€” 3. Same.
  • RebootArgument โ€” 5. Any "system mode" action such as a reboot has no place in an s6 set of services anyway; systemd obviously likes to mix unrelated layers. In the s6 world, the only place where a reboot should occur is s6-linux-init[2], and the related scripting in rc.init files. ๐Ÿ”ฅ
  • SourcePath โ€” 0.
  • Conditions and Asserts โ€” 9. Most of these are tied to the global machine state and absolutely not local to a given set of services. And even for those that are not, what they do is change the whole service manager's behaviour depending on some external dynamic state such as the existence of a file in the filesystem โ€” and that is entirely contrary to the s6 philosophy of making services predictable and reproducible. big yikes. ๐Ÿ’€

[Install] section

any directive under Install can be ignored, since it has no meaning on the run-time behaviour of the service. so the difficulty is 0. ๐ŸŽ‰

however, an automatic converter would need to analyze the whole installed service configuration, e.g. the links in /etc/systemd/system/multi-user.target.wants/, in order to understand the dependencies between services. systemd targets can typically be converted into s6-rc bundles. ๐Ÿซถ

๐Ÿ’œ Directives documented in systemd.service(5) ๐Ÿ’œ

[Service] section

  • Type โ€” depending on its type, a systemd "service" can translate to wildly different things under s6. ๐Ÿ‘€
    • simple โ€” 1.
    • exec โ€” 1.
    • forking โ€” 2. This type is strongly discouraged. ๐Ÿšฉ
    • oneshot โ€” 1.
    • dbus โ€” 5. This type requires implementing dbus management programs for s6.
    • notify โ€” 7. This type requires an implementation of a compatibility server for sd_notify(3), which is heavily tied to the monolithic systemd architecture and is difficult to support in a modular system such as s6. It is much easier to modify the services themselves so they use the s6-notifywhenup(7) s6 readiness notification mechanism instead of sd_notify. ๐Ÿ’ก
    • idle โ€” 0. This type is meaningless under s6 and should be treated like simple.
  • ExitType โ€” again, it depends on the value.
    • main โ€” 1.
    • cgroup โ€” 3. This requires implementing, or having access to, command-line cgroup tools.
  • RemainAfterExit โ€” 0.
  • GuessMainPid โ€” 0. But don't use forking if you can avoid it. ๐Ÿ™
  • PIDFile โ€” 2. Same, no notes. ๐ŸŽ€
  • BusName โ€” 5. Avoid type dbus if you possibly can, bestie. ๐Ÿ™ˆ
  • ExecStart โ€” 2, but with caveats, and the caveats are doing a lot of heavy lifting here. This is the bread and butter of service definitions โ€” every one of your services is gonna have one of these, and the contents of ExecStart typically go straight into a run script (for longruns) or an up file (for oneshots). โœจ But since systemd hates simplicity with a burning passion, there are a whole bunch of transformations that have to happen to the command line before it's usable in a script, especially if the command has a special executable prefix. Implementing those has its own difficulty ratings, because of course it does:
    • @ โ€” 1.
    • - โ€” 1.
    • : โ€” 2.
    • + โ€” 5.
    • ! โ€” 3.
    • !! โ€” 3.
  • ExecStartPre โ€” 2. To get strict semantic equivalence with their systemd version, ExecStartPre lines have to be implemented as s6-rc oneshots, and the whole unit file has to be implemented as a bundle. That's the price of exactness. ๐Ÿ’…
  • ExecStartPost โ€” 2. Same. ๐Ÿซถ
  • ExecCondition โ€” 2.
  • ExecReload โ€” 0. Literally zero! A reloading command that doesn't involve restarting the service does not need the service manager as a third-party. systemd cannot help inserting itself where it does not belong โ€” it's giving main character syndrome. ๐Ÿ˜ญ
  • ExecStop โ€” 5. s6 only supports terminating services via signals, so if a service needs a specific command to stop it, the converter has to target an interface layer on top of s6 with a repository of stop commands; such a layer would likely need to be on top of s6-rc as well, and a lot of complexity would ensue. ๐Ÿ’€ Fortunately, a huge majority of services support termination via signals, and it's often easy to avoid relying on ExecStop.
  • ExecStopPost โ€” 2. These are the down scripts of the ExecStartPre oneshots. ๐Ÿ“
  • RestartSec โ€” 2. s6 has no setting for that, because it aims for maximum uptime; but there are still ways to implement that bad idea. ๐Ÿ‘€
  • TimeoutStartSec โ€” 1.
  • TimeoutStopSec โ€” 1.
  • TimeoutAbortSec โ€” 7. This would need a watchdog implementation, in the server implementation of sd_notify(3). ๐Ÿ˜ฎโ€๐Ÿ’จ
  • TimeoutSec โ€” 1.
  • TimeoutStartFailureMode โ€” 0 for terminate and kill, 7 for abort.
  • TimeoutStopFailureMode โ€” 0 for terminate and kill, 7 for abort.
  • RuntimeMaxSec โ€” 4. This is the exact opposite of what you need a process supervisor for, so s6 does not implement it. Run such a thing (a process, not a service) outside of any kind of supervision framework, bestie. ๐ŸŒธ
  • RuntimeRandomizedExtraSec โ€” 4. Same.
  • WatchdogSec โ€” 7. Requires a watchdog implementation in the very specific systemd way. ๐Ÿ•
  • Restart โ€” depends on the value, so buckle up:
    • no โ€” 2, but why use a process supervisor in the first place? ๐Ÿคจ
    • on-success โ€” 2.
    • on-failure โ€” 2.
    • on-abnormal โ€” 2.
    • on-watchdog โ€” 7. Again, this requires a watchdog implementation.
    • on-abort โ€” 2.
    • always โ€” 1.
  • SuccessExitStatus โ€” 3. This can be easily scripted, but supporting all the systemd formats is annoying. ๐Ÿ™„
  • RestartPreventExitStatus โ€” 1. This is exactly what s6-permafailon(8) is for. Slay.
  • RestartForceExitStatus โ€” 2.
  • RootDirectoryStartOnly โ€” 2.
  • NonBlocking โ€” 5. This requires an emulation of systemd's socket activation. s6 provides the useful parts of it, like an s6-fdholder-daemon(8) process to hold file descriptors, but the systemd-specific API around socket activation, sd_listen_fds(3), still needs to be implemented. ๐Ÿ”ฅ
  • NotifyAccess โ€” 1 if none, 7 otherwise, because it needs an implementation of sd_notify(3).
  • Sockets โ€” 5. Requires an implementation of systemd's socket activation.
  • FileDescriptorStoreMax โ€” 7. Requires an implementation of sd_notify(3); the fd store itself is native to s6, so that part's already iconic. ๐Ÿ‘‘
  • USBFunctionDescriptors โ€” 9. This is low-level machine management, not service management. Not our department. ๐Ÿ’…
  • USBFunctionStrings โ€” 9. Same.
  • OOMPolicy โ€” 9. Same.

โœจ Directives documented in systemd.exec(5) โœจ

๐Ÿ›ค๏ธ Paths

  • ExecSearchPath โ€” 1.
  • WorkingDirectory โ€” 2.
  • RootDirectory โ€” 1.
  • RootImage โ€” 6. I am discovering these options in real time and shaking my head โ€” systemd still manages to baffle me with the amount of gratuitous ad-hoc that went into it. ๐Ÿ˜ญ Still, this is regular low-level programming for Linux, so it's less difficult to implement than systemd-specific stuff โ€” that's why it only gets a 6.
  • RootImageOptions โ€” 6. Same.
  • RootHash โ€” 9. Please. ๐Ÿ™
  • RootHashSignature โ€” 9.
  • RootVerity โ€” 9.
  • MountAPIVFS โ€” 6.
  • ProtectProc โ€” 6.
  • ProcSubset โ€” 6.
  • BindPaths โ€” 6.
  • BindReadOnlyPaths โ€” 6.
  • MountImages โ€” 6.
  • ExtensionImages โ€” 6.
  • ExtensionDirectories โ€” 6. It's a full low-level userspace implementation at this point. It's not very complex โ€” the 6 feels accurate โ€” but it's a whole lot of work. ๐Ÿ’€ This is how systemd maintains its hegemony: not because it does incredible, awe-inspiring magic, but because it substitutes its monolithic self for a whole ecosystem, imposes its own API, and locks users in. People who want to smoothly transition away from systemd need to implement the whole shtick, which is obviously a huge undertaking โ€” as the author of uselessd[4] can confirm. ๐Ÿซ 

๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘ User/group identity

  • User โ€” 3. Looks very simple, but it is treacherous, because User is a mash-up of two very different features: setting users statically (via numeric ID, which don't change meanings between two invocations) and setting users dynamically (via user name, which needs to be interpreted by getpwnam(3) on every invocation of the service). s6 supports both, but since these are two different things, the way to do them in s6 is different โ€” statically setting the UID and GID variables and calling s6-applyuidgid -U, or calling s6-setuidgid(8). ๐ŸŽ€ This is the exact kind of small detail that makes writing an automatic converter more difficult than it should be: the systemd unit file syntax is rife with semantic pitfalls, and navigating your way across it requires very close attention. No cap.
  • Group โ€” 3. Same.
  • DynamicUser โ€” 5. Of course this flag has an entirely different meaning from setting users statically or dynamically โ€” otherwise it would be too easy to understand. ๐Ÿ™„ No, this flag is about allocating temporary new users, which is a prime example of overengineering.
  • SupplementaryGroups โ€” 1. Same.
  • PAMName โ€” 4. Requires PAM command-line utilities.

โšก Capabilities

  • CapabilityBoundingSet โ€” 4. This requires command-line tools implementing capabilities.
  • AmbientCapabilities โ€” 4. Same.

๐Ÿ”’ Security

  • NoNewPrivileges โ€” 4. Similar to capabilities, this requires a command-line tool controlling the Linux-specific prctl(2) system call.
  • SecureBits โ€” 4. Same.

๐Ÿ›ก๏ธ Mandatory access control

  • SELinuxContext โ€” 5. This requires command-line tools managing SELinux.
  • AppArmorProfile โ€” 5. Same, with AppArmor.
  • SmackProcessLabel โ€” 5. Same, with SMACK. systemd needs to know and understand all the Linux security modules in order to interact with them. s6 does not โ€” it expects a service's run script to perform all the needed process state changes and controls before executing into the daemon. ๐Ÿ’… That's the whole vibe.

๐Ÿงฌ Process properties

  • LimitCPU โ€” 1.
  • LimitFSIZE โ€” 1.
  • LimitDATA โ€” 1.
  • LimitSTACK โ€” 1.
  • LimitCORE โ€” 1.
  • LimitRSS โ€” 1.
  • LimitNOFILE โ€” 1.
  • LimitAS โ€” 1.
  • LimitNPROC โ€” 1.
  • LimitMEMLOCK โ€” 1.
  • LimitLOCKS โ€” 2. This resource limit isn't natively supported by s6-softlimit 8, but it could appear in a future s6 version โ€” and it's easy to add in any case. โœจ
  • LimitSIGPENDING โ€” 2. Same.
  • LimitMSGQUEUE โ€” 2. Same.
  • LimitNICE โ€” 2. Same.
  • LimitRTPRIO โ€” 2. Same.
  • LimitRTTIME โ€” 2. Same.
  • UMask โ€” 1.
  • CoredumpFilter โ€” 4. Requires a command-line tool around prctl(2).
  • KeyringMode โ€” 5. Requires interaction with PAM and an understanding of keyrings. Fortunately, practically nothing will need that. ๐Ÿ™ˆ
  • OOMScoreAdjust โ€” 2.
  • TimerSlackNSec โ€” 4. Requires a command-line tool around prctl(2).

๐Ÿซถ Personality

  • Personality โ€” difficulty 3. It's giving "needs a whole command-line tool wrapping personality(2)", so yeah, not a one-liner bestie.
  • IgnoreSIGPIPE โ€” difficulty 2.

๐ŸŒธ Scheduling

  • Nice โ€” difficulty 1. Baby steps, we love to see it.
  • CPUSchedulingPolicy โ€” difficulty 3. You're gonna need a command-line tool wrapping sched_setscheduler(2) for this one.
  • CPUSchedulingPriority โ€” difficulty 3. Same deal, same wrapper energy.
  • CPUSchedulingResetOnFork โ€” difficulty 3. Also same.
  • CPUAffinity โ€” difficulty 3. Requires a command-line tool around sched_setaffinity(2), no cap.
  • NUMAPolicy โ€” difficulty 3. Needs a tool around set_mempolicy(2).
  • NUMAMask โ€” difficulty 3. Same.
  • IOSchedulingClass โ€” difficulty 3. Needs a tool around ioprio_set(2).
  • IOSchedulingPriority โ€” difficulty 3. Same, literally.

๐Ÿ’… Sandboxing

Okay so here's the tea, and it's honestly kind of iconic: systemd gracefully turns off the sandboxing options on systems that don't have the necessary functionality. Which means all of these options can be ignored (difficulty 0) and your services will still work. Slay.

But โ€” and this is the highkey important part โ€” if you actually want the sandboxing to do something, you have to pair s6 with command-line tools that perform the required process state changes, by interfacing with namespaces, cgroups, seccomp, or any other relevant feature of the Linux kernel. So for all of these directives, the difficulty is somewhere between 2 (if the tool already exists, cute, we love a shortcut) and 8 (if it requires writing a full container implementation from scratch ๐Ÿ˜ญ). The devs are like, "the following numbers are only a rough guess", so take them as vibes, not gospel.

  • ProtectSystem โ€” difficulty 6.
  • ProtectHome โ€” difficulty 6.
  • RuntimeDirectory โ€” difficulty 1.
  • StateDirectory โ€” difficulty 1.
  • CacheDirectory โ€” difficulty 1.
  • LogsDirectory โ€” difficulty 1.
  • ConfigurationDirectory โ€” difficulty 1.
  • RuntimeDirectoryMode โ€” difficulty 1.
  • StateDirectoryMode โ€” difficulty 1.
  • CacheDirectoryMode โ€” difficulty 1.
  • LogsDirectoryMode โ€” difficulty 1.
  • ConfigurationDirectoryMode โ€” difficulty 1.
  • RuntimeDirectoryPreserve โ€” difficulty 3.
  • TimeoutCleanSec โ€” difficulty 3.
  • ReadWritePaths โ€” difficulty 5.
  • ReadOnlyPaths โ€” difficulty 5.
  • InaccessiblePaths โ€” difficulty 5.
  • ExecPaths โ€” difficulty 5.
  • NoExecPaths โ€” difficulty 5.
  • TemporaryFileSystem โ€” difficulty 5.
  • PrivateTmp โ€” difficulty 5.
  • PrivateDevices โ€” difficulty 5.
  • PrivateNetwork โ€” difficulty 8.
  • NetworkNamespacePath โ€” difficulty 8.
  • PrivateIPC โ€” difficulty 5.
  • IPCNamespacePath โ€” difficulty 5.
  • PrivateUsers โ€” difficulty 5.
  • ProtectHostname โ€” difficulty 5.
  • ProtectClock โ€” difficulty 7.
  • ProtectKernelTunables โ€” difficulty 7.
  • ProtectKernelModules โ€” difficulty 7.
  • ProtectKernelLogs โ€” difficulty 7.
  • ProtectControlGroups โ€” difficulty 7.
  • RestrictAddressFamilies โ€” difficulty 7.
  • RestrictFilesystems โ€” difficulty 7.
  • RestrictNamespaces โ€” difficulty 7.
  • LockPersonality โ€” difficulty 7.
  • MemoryDenyWriteExecute โ€” difficulty 7.
  • RestrictRealtime โ€” difficulty 7.
  • RestrictSUIDSGID โ€” difficulty 7.
  • RemoveIPC โ€” difficulty 5.
  • PrivateMounts โ€” difficulty 5.

๐Ÿงš System call filtering

  • SystemCallFilter โ€” difficulty 8.
  • SystemCallErrorNumber โ€” difficulty 8.
  • SystemCallArchitectures โ€” difficulty 8.
  • SystemCallLog โ€” difficulty 8.

๐Ÿฆ‹ Environment

  • Environment โ€” difficulty 1.
  • EnvironmentFile โ€” difficulty 1.
  • PassEnvironment โ€” difficulty 1.
  • UnsetEnvironment โ€” difficulty 1.

๐ŸŽ€ Logging and standard input/output

  • StandardInput โ€” difficulty 1.
  • StandardOutput โ€” difficulty 1, except for journal, which cannot be supported (10). Yeah, that one's just not happening.
  • StandardError โ€” Same.
  • StandardInputText โ€” difficulty 2.
  • StandardInputData โ€” difficulty 2.
  • LogLevelMax โ€” difficulty 3.
  • LogExtraFields โ€” difficulty 10.
  • LogRateLimitIntervalSec โ€” difficulty 10.
  • LogRateLimitBurst โ€” difficulty 10.
  • LogFilterPatterns โ€” difficulty 4.
  • LogNamespace โ€” difficulty 10.
  • SyslogIdentifier โ€” difficulty 2.
  • SyslogFacility โ€” difficulty 2.
  • SyslogLevel โ€” difficulty 2.
  • SyslogLevelPrefix โ€” difficulty 4.
  • TTYPath โ€” difficulty 1.
  • TTYReset โ€” difficulty 3.
  • TTYVHangup โ€” difficulty 3.
  • TTYRows โ€” difficulty 3.
  • TTYColumns โ€” difficulty 3.
  • TTYDisallocate โ€” difficulty 3.

๐Ÿ”ฅ Credentials

Not gonna lie, this one's a whole mood. systemd implements its own credentials store mechanism, like, for no obvious benefit ๐Ÿ™ˆ. The whole credentials system needs to be reimplemented outside of systemd in order for credentials-related directives to be supported by s6. Consequently, all these directives are rated 6.

๐ŸŒˆ System V compatibility

Bestie, the utmp directives can be made significantly easier to implement if the target system is using utmps[5], because the directives then become a single call to utmps-write[6] with the relevant options. Iconic behavior honestly. If utmps cannot be used, though, then the utmp calls need to be reimplemented. F in the chat.

  • UtmpIdentifier โ€” difficulty 4.
  • UtmpMode โ€” difficulty 4.

๐Ÿ’€ Directives documented in systemd.kill(5)

  • KillMode โ€” depends on the kill mode, bestie. control-group and mixed are 3, because they require cgroup control commands (that can be implemented in shell โ€” yes, in shell, we love a low-effort queen). process is 1. none is 2.
  • KillSignal โ€” difficulty 1.
  • RestartKillSignal โ€” difficulty 5. s6 doesn't use a different signal for restarting, so implementing this requires an outer layer. (The page says, and I quote: this is overengineering.)
  • SendSIGHUP โ€” difficulty 5. Same.
  • SendSIGKILL โ€” difficulty 1.
  • FinalKillSignal โ€” difficulty 5. (This one is absolute overengineering ๐Ÿ’€.)
  • WatchdogSignal โ€” difficulty 7. Only meaningful with an implementation of systemd's watchdog system.

โญ Directives documented in systemd.resource-control(5)

Okay so all of these directives relate to cgroups, which means implementing them requires having access to at least some cgroups commands (difficulty at least 3). Others are even more involved, requiring tight service integration with the system โ€” like, main-character-complex levels of involved.

๐Ÿšจ Real talk: generally, seeing these directives in your unit files is a bad sign. Despite some of them only having 3 or 4 listed, we do not recommend implementing systemd.resource-control(5) without having a full holistic view of the system. Please don't come for us.
  • CPUAccounting โ€” difficulty 3.
  • CPUWeight โ€” difficulty 4.
  • StartupCPUWeight โ€” difficulty 9. Involves startup and shutdown.
  • CPUQuota โ€” difficulty 4.
  • CPUQuotaPeriodSec โ€” difficulty 4.
  • AllowedCPUs โ€” difficulty 3.
  • StartupAllowedCPUs โ€” difficulty 9. Involves startup and shutdown.
  • AllowedMemoryNodes โ€” difficulty 3.
  • StartupAllowedMemoryNodes โ€” difficulty 9. Involves startup and shutdown.
  • MemoryAccounting โ€” difficulty 3.
  • MemoryMin โ€” difficulty 3.
  • MemoryLow โ€” difficulty 3.
  • MemoryHigh โ€” difficulty 3.
  • MemoryMax โ€” difficulty 3.
  • MemorySwapMax โ€” difficulty 3.
  • MemoryZSwapMax โ€” difficulty 3.
  • TasksAccounting โ€” difficulty 3.
  • TasksMax โ€” difficulty 3.
  • IOAccounting โ€” difficulty 3.
  • IOWeight โ€” difficulty 3.
  • StartupIOWeight โ€” difficulty 9. Involves startup and shutdown.
  • IODeviceWeight โ€” difficulty 5.
  • IOReadBandwidthMax โ€” difficulty 5.
  • IOWriteBandwidthMax โ€” difficulty 5.
  • IOReadIOPSMax โ€” difficulty 5.
  • IOWriteIOPSMax โ€” difficulty 5.
  • IODeviceLatencyTargetSec โ€” difficulty 4.
  • IPAccounting โ€” difficulty 7.
  • IPAddressAllow โ€” difficulty 7.
  • IPAddressDeny โ€” difficulty 7.
  • IPIngressFilterPath โ€” difficulty 8.
  • IPEgressFilterPath โ€” difficulty 8.
  • BPFProgram โ€” difficulty 8.
  • SocketBindAllow โ€” difficulty 6.
  • SocketBindDeny โ€” difficulty 6.
  • RestrictNetworkInterfaces โ€” difficulty 4.
  • DeviceAllow โ€” difficulty 6.
  • DevicePolicy โ€” difficulty 6.
  • Slice โ€” difficulty 9. Slices are a systemd concept, and fully implementing them requires a holistic system analysis. Like, the whole system. Good luck babes.
  • Delegate โ€” difficulty 4.
  • DisableControllers โ€” difficulty 3.
  • ManagedOOMSwap โ€” difficulty 8. Out-of-memory management is an entire systemd subsystem. Instead of implementing that, we recommend provisioning your machines correctly, and freeing up more resources for your applications by using s6. That's the tip, periodt.
  • ManagedOOMMemoryPressure โ€” difficulty 8.
  • ManagedOOMMemoryPressureLimit โ€” difficulty 8.
  • ManagedOOMPreference โ€” difficulty 8.

๐Ÿ‘‘ Directives rated by difficulty

Use this section to answer the question: โ€œIf I were to write a converter tool from systemd to s6, what subset of the unit file syntax should I focus on first?โ€

Take this classification with a grain of salt, bestie: for instance, it does not make sense to implement an easy directive if it's only used in the context of a larger subsystem that's much harder to implement โ€” typically, most cgroups-related resource control directives. So like, don't get cocky just 'cause something's a 1, iykyk.

โœจ Difficulty: 0 โ€” directives that can be ignored

  • Description
  • Documentation
  • Upholds
  • PropagatesReloadTo
  • PropagatesStopTo
  • StopPropagatedFrom
  • IgnoreOnIsolate
  • StopWhenUnneeded
  • AllowIsolate
  • CollectMode
  • SourcePath
  • Type=idle
  • RemainAfterExit
  • GuessMainPid
  • ExecReload
  • TimeoutStartFailureMode
  • TimeoutStopFailureMode

๐Ÿ’– Difficulty: 1 โ€” direct functionality mapping

  • RefuseManualStop
  • FailureActionExitStatus
  • SuccessActionExitStatus
  • Type=simple|exec|oneshot
  • ExitType=main
  • TimeoutStartSec
  • TimeoutStopSec
  • TimeoutSec
  • Restart=always
  • RestartPreventExitStatus
  • NotifyAccess=none
  • ExecSearchPath
  • RootDirectory
  • SupplementaryGroups
  • LimitCPU
  • LimitFSIZE
  • LimitDATA
  • LimitSTACK
  • LimitCORE
  • LimitRSS
  • LimitNOFILE
  • LimitAS
  • LimitNPROC
  • LimitMEMLOCK
  • UMask
  • Nice
  • RuntimeDirectory
  • StateDirectory
  • CacheDirectory
  • LogsDirectory
  • ConfigurationDirectory
  • RuntimeDirectoryMode
  • StateDirectoryMode
  • CacheDirectoryMode
  • LogsDirectoryMode
  • ConfigurationDirectoryMode
  • Environment
  • EnvironmentFile
  • PassEnvironment
  • UnsetEnvironment
  • StandardInput
  • StandardOutput (except journal)
  • StandardError (except journal)
  • TTYPath
  • KillMode=process
  • KillSignal
  • SendSIGKILL

๐ŸŽ€ Difficulty: 2 โ€” straightforward implementation

okay bestie, difficulty two is basically "yeah you got this, it's a chill afternoon project" ๐Ÿ’… no cap, these are the ones you can knock out without a whole character arc:

  • Requires
  • Before
  • After
  • OnSuccess
  • DefaultDependencies
  • Type=forking
  • PIDFile
  • ExecStart (omitting some prefixes)
  • ExecStartPre
  • ExecStartPost
  • ExecCondition
  • ExecStopPost
  • RestartSec
  • Restart except on-watchdog
  • RestartForceExitStatus
  • RootDirectoryStartOnly
  • WorkingDirectory
  • LimitLOCKS
  • LimitSIGPENDING
  • LimitMSGQUEUE
  • LimitNICE
  • LimitRTPRIO
  • LimitRTTIME
  • OOMScoreAdjust
  • IgnoreSIGPIPE
  • StandardInputText
  • StandardInputData
  • SyslogIdentifier
  • SyslogFacility
  • SyslogLevel
  • KillMode=none

โœจ Difficulty: 3 โ€” requires easy additional programming

so like, this tier is where you gotta actually write a lil bit of code, but it's giving "one weekend, two iced coffees, done" ๐Ÿ“ fr fr:

  • Wants
  • Requisite
  • BindsTo
  • PartOf
  • FailureAction
  • SuccessAction
  • StartLimitIntervalSec
  • StartLimitBurst
  • StartLimitAction
  • ExitType=cgroup
  • SuccessExitStatus
  • User
  • Group
  • Personality
  • CPUSchedulingPolicy
  • CPUSchedulingPriority
  • CPUSchedulingResetOnFork
  • CPUAffinity
  • NUMAPolicy
  • NUMAMask
  • IOSchedulingClass
  • IOSchedulingPriority
  • RuntimeDirectoryPreserve
  • TimeoutCleanSec
  • LoglevelMax
  • TTYReset
  • TTYVHangup
  • TTYRows
  • TTYColumns
  • TTYDisallocate
  • KillMode=control-group|mixed
  • CPUAccounting
  • AllowedCPUs
  • AllowedMemoryNodes
  • MemoryAccounting
  • MemoryMin
  • MemoryLow
  • MemoryHigh
  • MemoryMax
  • MemorySwapMax
  • MemoryZSwapMax
  • TasksAccounting
  • TasksMax
  • IOAccounting
  • IOWeight
  • DisableControllers

๐Ÿฆ‹ Difficulty: 4 โ€” requires medium additional programming

medium programming, medium vibes, medium "omg why is this taking me three evenings" energy ๐Ÿ˜ญ but you'll slay it:

  • RuntimeMaxSec
  • RuntimeRandomizedExtraSec
  • RequiresMountsFor
  • RefuseManualStart
  • PAMName
  • CapabilityBoundingSet
  • AmbientCapabilities
  • NoNewPrivileges
  • SecureBits
  • CoredumpFilter
  • TimerSlackNSec
  • LogFilterPatterns
  • SyslogLevelPrefix
  • UtmpIdentifier
  • UtmpMode
  • CPUWeight
  • CPUQuota
  • CPUQuotaPeriodSec
  • IODeviceLatencyTargetSec
  • RestrictNetworkInterfaces
  • Delegate

๐Ÿ”ฅ Difficulty: 5 โ€” requires complex additional programming

okay now we're in complex territory, bestie โ€” this is the "clear your calendar and tell your friends you're busy" tier ๐Ÿ‘‘:

  • Conflicts
  • OnFailure
  • RebootArgument
  • Type=dbus
  • BusName
  • ExecStop
  • NonBlocking
  • Sockets
  • DynamicUser
  • SELinuxContext
  • AppArmorProfile
  • SmackProcessLabel
  • KeyringMode
  • ReadWritePaths
  • ReadOnlyPaths
  • InaccessiblePaths
  • ExecPaths
  • NoExecPaths
  • TemporaryFilesystem
  • PrivateTmp
  • PrivateDevices
  • PrivateIPC
  • IPCNamespacePath
  • PrivateUsers
  • ProtectHostname
  • RemoveIPC
  • PrivateMounts
  • RestartKillSignal
  • SendSIGHUP
  • FinalKillSignal
  • IODeviceWeight
  • IOReadBandwidthMax
  • IOWriteBandwidthMax
  • IOReadIOPSMax
  • IOWriteIOPSMax

๐Ÿ’€ Difficulty: 6 โ€” requires a full independent implementation of a Linux subsystem and/or a part of the systemd architecture

yeah so at this point you're not "adding a feature", you're literally reimplementing a whole Linux subsystem and/or a chunk of the systemd architecture. it's giving icon behaviour but also it's giving suffering ๐Ÿซถ:

  • OnFailureJobMode
  • RootImage
  • RootImageOptions
  • MountAPIVFS
  • ProtectProc
  • ProcSubset
  • BindPaths
  • BindReadOnlyPaths
  • MountImages
  • ExtensionImages
  • ExtensionDirectories
  • ProtectSystem
  • ProtectHome
  • All credentials-related[7] directives
  • SocketBindAllow
  • SocketBindDeny
  • DeviceAllow
  • DevicePolicy

๐ŸŒˆ Difficulty: 7 โ€” requires a full independent implementation of a complex Linux subsystem and/or a significant part of the systemd architecture

"complex Linux subsystem" AND "a significant part of the systemd architecture"?? bestie that's not a task, that's a whole personality change ๐Ÿ’… good luck, genuinely:

  • Type=notify
  • TimeoutAbortSec
  • TimeoutStartFailureMode=abort
  • TimeoutStopFailureMode=abort
  • WatchdogSec
  • Restart=on-watchdog
  • NotifyAccess
  • FileDescriptorStoreMax
  • ProtectClock
  • ProtectKernelTunables
  • ProtectKernelModules
  • ProtectKernelLogs
  • ProtectControlGroups
  • RestrictAddressFamilies
  • RestrictFilesystems
  • RestrictNamespaces
  • LockPersonality
  • MemoryDenyWriteExecute
  • RestrictRealtime
  • RestrictSUIDSGID
  • WatchdogSignal
  • IPAccounting
  • IPAddressAllow
  • IPAddressDeny

๐Ÿงš Difficulty: 8 โ€” requires a complete implementation of complex Linux-specific tooling

"complete implementation of complex Linux-specific tooling" โ€” no notes, that's just the whole sentence, and it ate ๐Ÿ”ฅ:

  • JoinsNamespaceOf
  • PrivateNetwork
  • NetworkNamespacePath
  • SystemCallFilter
  • SystemCallErrorNumber
  • SystemCallArchitectures
  • SystemCallLog
  • IPIngressFilterPath
  • IPEgressFilterPath
  • BPFProgram
  • ManagedOOMSwap
  • ManagedOOMMemoryPressure
  • ManagedOOMMemoryPressureLimit
  • ManagedOOMPreference

โญ Difficulty: 9 โ€” requires a full system analysis and remodelization

full system analysis AND remodelization?? that's not a port, that's a glow-up of your entire architecture. main character energy only ๐Ÿ‘‘:

  • JobTimeoutSec
  • JobRunningTimeoutSec
  • JobTimeoutAction
  • JobTimeoutRebootArgument
  • Conditions and Asserts
  • USBFunctionDescriptors
  • USBFunctionStrings
  • OOMPolicy
  • RootHash
  • RootHashSignature
  • RootVerity
  • StartupCPUWeight
  • StartupAllowedCPUs
  • StartupAllowedMemoryNodes
  • StartupIOWeight
  • Slice

๐ŸŒธ Difficulty: 10 โ€” implementing this basically means reimplementing systemd

and here it is. the final boss. the manpage itself says it: implementing these basically means reimplementing systemd ๐Ÿ’€ like, the whole thing. literally just build systemd again at this point, bestie. iconic of the doc to warn us tbh ๐Ÿ™ˆ:

  • StandardOutput=journal
  • StandardError=journal
  • LogExtraFields
  • LogRateLimitIntervalSec
  • LogRateLimitBurst
  • LogNamespace

๐Ÿฆ‹ SEE ALSO

go read these, bestie โ€” they're the whole friend group:

and the link drop, all seven of them, exactly as given ๐ŸŽ€:

This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6/unit-conversion.html โ€” so if you want the original-original, that's where it lives ๐Ÿ’–

๐Ÿ’œ AUTHORS

  • Laurent Bercot
  • Alexis <flexibeat@gmail.com> (man page port)

okay that's the whole page, bestie โ€” you made it to the end ๐Ÿฅณ this lil port shipped with Debian on November 11, 2023, and honestly? reading all ten difficulty tiers in one sitting is a flex. go drink some water, you've earned it ๐Ÿ’…๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from