mirror of
https://github.com/systemd/systemd
synced 2026-03-30 03:34:49 +02:00
Compare commits
No commits in common. "2e5f717545e2664ce2ed6b2dd84744b3789156b1" and "72cbc28347bc1541cb3fb32207cf25f8d39fed6b" have entirely different histories.
2e5f717545
...
72cbc28347
2
.github/labeler.yml
vendored
2
.github/labeler.yml
vendored
@ -226,7 +226,7 @@ sd-resolve:
|
|||||||
selinux:
|
selinux:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: '**/*selinux*'
|
- any-glob-to-any-file: '**/*selinux*'
|
||||||
shell completion:
|
shell-completion:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: 'shell-completion/**'
|
- any-glob-to-any-file: 'shell-completion/**'
|
||||||
shell profile:
|
shell profile:
|
||||||
|
|||||||
@ -39,7 +39,7 @@ jobs:
|
|||||||
trigger: pull_request
|
trigger: pull_request
|
||||||
fmf_url: https://src.fedoraproject.org/rpms/systemd
|
fmf_url: https://src.fedoraproject.org/rpms/systemd
|
||||||
# This is automatically updated by tools/fetch-distro.py --update fedora
|
# This is automatically updated by tools/fetch-distro.py --update fedora
|
||||||
fmf_ref: 12f95f807fef5075a8842dd107f83b4c41d5ac26
|
fmf_ref: 8e2833a5b64f7e2ce62ea0a2d0ec9e393e718dfa
|
||||||
targets:
|
targets:
|
||||||
- fedora-rawhide-x86_64
|
- fedora-rawhide-x86_64
|
||||||
# testing-farm in the Fedora repository is explicitly configured to use testing-farm bare metal runners as
|
# testing-farm in the Fedora repository is explicitly configured to use testing-farm bare metal runners as
|
||||||
|
|||||||
@ -7,72 +7,51 @@ SPDX-License-Identifier: LGPL-2.1-or-later
|
|||||||
|
|
||||||
# Mount Point Availability Requirements
|
# Mount Point Availability Requirements
|
||||||
|
|
||||||
This document describes the requirements placed by systemd
|
systemd makes various requirements on the time during boot where various parts
|
||||||
on the time when various parts of the file system hierarchy
|
of the Linux file system hierarchy must be available and must be mounted. If
|
||||||
must be available and mounted during boot.
|
the file systems backing these mounts are located on external or remote media,
|
||||||
This document should be read in conjunction with
|
that require special drivers, infrastructure or networking to be set up, then
|
||||||
[Linux File System Hierarchy](https://uapi-group.org/specifications/specs/linux_file_system_hierarchy/),
|
this implies that this functionality must be started and running at that point
|
||||||
which describes the role of the mount points discussed here.
|
already.
|
||||||
|
|
||||||
If the file system backing a mount point is located on external or remote media
|
Generally, there are three categories of requirements:
|
||||||
that require special drivers, infrastructure or networking to be set up,
|
|
||||||
then this implies that this functionality must be started and running
|
|
||||||
at the point in the boot sequence when that mount point is required.
|
|
||||||
|
|
||||||
There are three general categories of mount points:
|
|
||||||
|
|
||||||
1. 🌥️ *initrd*: File system mounts that must be established before the OS
|
1. 🌥️ *initrd*: File system mounts that must be established before the OS
|
||||||
transitions into the root file system. (I.e., must be mounted in
|
transitions into the root file system. (i.e. that must be stablished from
|
||||||
the initrd before the initrd→host transition takes place.)
|
the initrd before the initrd→host transition takes place.)
|
||||||
|
|
||||||
2. 🌤️ *early*: File system mounts that must be established
|
2. 🌤️ *early*: File system mounts that must be established during early boot,
|
||||||
before the end of "early boot", i.e. before `local-fs.target` is reached.
|
after the initrd→host transition took place, but before regular services are
|
||||||
All services that do not explicitly opt-out of the dependency
|
started. (i.e. before `local-fs.target` is reached.)
|
||||||
are ordered after that point.
|
|
||||||
|
|
||||||
3. ☀️ *regular*: File system mounts that can be mounted later.
|
3. ☀️ *regular*: File system mounts that can be mounted at any time during the
|
||||||
Individual services might pull in specific mount points and be ordered after them.
|
boot process – but which specific, individual services might require to be
|
||||||
Mount points that require network to be available
|
established at the point they are started. (i.e. these mounts are typically
|
||||||
are typically ordered before `remote-fs.target`.
|
ordered before `remote-fs.target`.)
|
||||||
Those mount points may be established as automount points.
|
|
||||||
|
|
||||||
Mounts in the later categories may be established earlier,
|
Of course, mounts that fall into category 3 can also be mounted during the
|
||||||
i.e. mounts that fall into category 2/early may also be mounted in the initrd,
|
initrd or in early boot. And those from category 2 can also be mounted already
|
||||||
and mounts in category 3/regular may also be mounted in the initrd or early boot.
|
from the initrd.
|
||||||
Since mount points that are lower in the hierarchy are mounted later,
|
|
||||||
if a mount point is *not* split out,
|
|
||||||
but a given subtree is part of the parent mount,
|
|
||||||
the requirements for that subtree are trivially satisfied by the parent.
|
|
||||||
|
|
||||||
A "mount point" in this document means the whole subtree of the hierachy,
|
|
||||||
until a mountpoint lower in the hierarchy which is conceptually separate.
|
|
||||||
For example, on a system with a custom mount point located below `/var/spool/`,
|
|
||||||
most of `/var/` would be in category 2/early,
|
|
||||||
but the additional mount would be in category 3/regular.
|
|
||||||
Conversly, if some part of `/usr/` that is normally part of that subtree
|
|
||||||
was split out to a separate mount,
|
|
||||||
this mount point would fall into category 1/initrd
|
|
||||||
and configuration would need to be provided for it to be mounted in the initrd.
|
|
||||||
|
|
||||||
Here's a table with relevant mounts and to which category they belong:
|
Here's a table with relevant mounts and to which category they belong:
|
||||||
|
|
||||||
| *Mount* | *Category* |
|
| *Mount* | *Category* |
|
||||||
|---------------|------------|
|
|---------------|------------|
|
||||||
| `/` (root fs) | 1/initrd |
|
| `/` (root fs) | 1 |
|
||||||
| `/usr/` | 1/initrd |
|
| `/usr/` | 1 |
|
||||||
| `/etc/` | 1/initrd |
|
| `/etc/` | 1 |
|
||||||
| `/var/` | 2/early |
|
| `/var/` | 2 |
|
||||||
| `/var/tmp/` | 2/early |
|
| `/var/tmp/` | 2 |
|
||||||
| `/tmp/` | 2/early |
|
| `/tmp/` | 2 |
|
||||||
| `/home/` | 3/regular |
|
| `/home/` | 3 |
|
||||||
| `/srv/` | 3/regular |
|
| `/srv/` | 3 |
|
||||||
| XBOOTLDR | 3/regular |
|
| XBOOTLDR | 3 |
|
||||||
| ESP | 3/regular |
|
| ESP | 3 |
|
||||||
|
|
||||||
Or in other words: the root file system (obviously…), `/usr/` and `/etc/` (if
|
Or in other words: the root file system (obviously…), `/usr/` and `/etc/` (if
|
||||||
these are split off) must be mounted at the moment the initrd transitions into
|
these are split off) must be mounted at the moment the initrd transitions into
|
||||||
the host. Then, `/var/` (with `/var/tmp/`) and `/tmp/` (if split off) must be
|
the host. Then, `/var/` (with `/var/tmp/`) and `/tmp/` (if split off) must be
|
||||||
mounted before the host reaches `local-fs.target` (and then `basic.target`),
|
mounted, before the host reaches `local-fs.target` (and then `basic.target`),
|
||||||
after which any remaining mounts may be established.
|
after which any remaining mounts may be established.
|
||||||
|
|
||||||
If mounts such as `/var/` are not mounted during early boot (or from the
|
If mounts such as `/var/` are not mounted during early boot (or from the
|
||||||
@ -84,19 +63,18 @@ Also note that the whole of `/var/` (including `/var/tmp/`), and `/tmp/` must
|
|||||||
be *writable* at the moment indicated above. It's OK if they are mounted
|
be *writable* at the moment indicated above. It's OK if they are mounted
|
||||||
read-only at an earlier time as long as they are remounted writable by the
|
read-only at an earlier time as long as they are remounted writable by the
|
||||||
indicated point in time. Systems where these three hierarchies remain read-only
|
indicated point in time. Systems where these three hierarchies remain read-only
|
||||||
during regular operation are not supported by `systemd`.
|
during regular operation are not supported by `systemd`. (Note that for
|
||||||
|
stateless systems it is absolutely OK and supported to mount an empty `tmpfs`
|
||||||
An exception to the rules described above are ephemeral systems,
|
there at boot, `systemd` will know how to populate the tree as necessary.)
|
||||||
where the root file system is initially an empty `tmpfs` mount point
|
|
||||||
and parts of the file system hierarchy are populated by systemd during early boot.
|
|
||||||
|
|
||||||
If you intend to use network-backed mounts (NFS, SMB, iSCSI, NVME-TCP and
|
If you intend to use network-backed mounts (NFS, SMB, iSCSI, NVME-TCP and
|
||||||
similar, including anything you add the `_netdev` pseudo mount option to) for
|
similar, including anything you add the `_netdev` pseudo mount option to) for
|
||||||
any of the mounts from category 1/initrd or 2/early,
|
any of the mounts from category 1 or 2, make sure to use a network managing
|
||||||
make sure to use a network manager that is capable of running in the initrd or early boot.
|
implementation that is capable of running from the initrd/during early
|
||||||
[`systemd-networkd(8)`](https://www.freedesktop.org/software/systemd/man/latest/systemd-networkd.html)
|
boot. [`systemd-networkd(8)`](https://www.freedesktop.org/software/systemd/man/latest/systemd-networkd.html)
|
||||||
for example works well in such scenarios.
|
for example works well in such scenarios.
|
||||||
|
|
||||||
|
Note that
|
||||||
[`systemd-homed.service(8)`](https://www.freedesktop.org/software/systemd/man/latest/systemd-homed.html)
|
[`systemd-homed.service(8)`](https://www.freedesktop.org/software/systemd/man/latest/systemd-homed.html)
|
||||||
is an example of a regular service from category 3/regular.
|
(which is a regular service, i.e. runs after `basic.target`) requires `/home/`
|
||||||
It runs after `basic.target` and requires `/home/` to be mounted.
|
to be mounted.
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>file-hierarchy</refname>
|
<refname>file-hierarchy</refname>
|
||||||
<refpurpose>systemd file system hierarchy requirements</refpurpose>
|
<refpurpose>File system hierarchy overview</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
@ -25,12 +25,20 @@
|
|||||||
|
|
||||||
<para>Operating systems using the
|
<para>Operating systems using the
|
||||||
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> system and
|
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> system and
|
||||||
service manager are organized based on a file system hierarchy inspired by UNIX,
|
service manager are organized based on a file system hierarchy inspired by UNIX, more specifically the
|
||||||
as described in <ulink url="https://uapi-group.org/specifications/specs/linux_file_system_hierarchy/">
|
hierarchy described in the <ulink url="http://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html">File
|
||||||
Linux File System Hierarchy</ulink>.
|
System Hierarchy</ulink> specification and <citerefentry
|
||||||
Additional requirements on <emphasis>when</emphasis> given parts of the hierarchy
|
project='man-pages'><refentrytitle>hier</refentrytitle><manvolnum>7</manvolnum></citerefentry>, with
|
||||||
must be available during boot are listed in
|
various extensions, partially documented in the <ulink
|
||||||
<ulink url="https://systemd.io/MOUNT_REQUIREMENTS/">Mount Requirements</ulink>.</para>
|
url="https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory
|
||||||
|
Specification</ulink> and <ulink url="https://www.freedesktop.org/wiki/Software/xdg-user-dirs">XDG User
|
||||||
|
Directories</ulink>. This manual page describes a more generalized, though minimal and modernized subset
|
||||||
|
of these specifications that defines more strictly the suggestions and restrictions systemd makes on the
|
||||||
|
file system hierarchy. Note that this document makes no attempt to define the directory structure
|
||||||
|
comprehensively, it only documents a skeleton of a directory tree, that downstreams can extend. Because
|
||||||
|
of that traditional directories such as <filename>/usr/include/</filename> or
|
||||||
|
<filename>/var/spool/</filename> are not covered, even though it might (or might not) make a lot of sense
|
||||||
|
to include them in the structure of an actually deployed OS.</para>
|
||||||
|
|
||||||
<para>Many of the paths described here can be queried
|
<para>Many of the paths described here can be queried
|
||||||
with the
|
with the
|
||||||
@ -38,13 +46,720 @@
|
|||||||
tool.</para>
|
tool.</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>General Structure</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/</filename></term>
|
||||||
|
<listitem><para>The file system root. Usually writable, but this is not required. Possibly a
|
||||||
|
temporary file system (<literal>tmpfs</literal>). Not shared with other hosts (unless
|
||||||
|
read-only).</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/boot/</filename></term>
|
||||||
|
<listitem><para>The boot partition used for bringing up the system. On EFI systems, this is possibly
|
||||||
|
the EFI System Partition (ESP), also see
|
||||||
|
<citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
|
||||||
|
This directory is usually strictly local to the host, and should be considered read-only, except when
|
||||||
|
a new kernel or boot loader is installed. This directory only exists on systems that run on physical
|
||||||
|
or emulated hardware that requires boot loaders.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/efi/</filename></term>
|
||||||
|
<listitem><para>If the boot partition <filename>/boot/</filename> is maintained separately from the
|
||||||
|
EFI System Partition (ESP), the latter is mounted here. Tools that need to operate on the EFI system
|
||||||
|
partition should look for it at this mount point first, and fall back to <filename>/boot/</filename>
|
||||||
|
— if the former does not qualify (for example if it is not a mount point or does not have the correct
|
||||||
|
file system type <constant>MSDOS_SUPER_MAGIC</constant>).</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/etc/</filename></term>
|
||||||
|
<listitem><para>System-specific configuration. This directory may or may not be
|
||||||
|
read-only. Frequently, this directory is pre-populated with vendor-supplied configuration files, but
|
||||||
|
applications should not make assumptions about this directory being fully populated or populated at
|
||||||
|
all, and should fall back to defaults if configuration is missing.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/home/</filename></term>
|
||||||
|
<listitem><para>The location for normal user's home directories. Possibly shared with other systems,
|
||||||
|
and never read-only. This directory should only be used for normal users, never for system
|
||||||
|
users. This directory and possibly the directories contained within it might only become available or
|
||||||
|
writable in late boot or even only after user authentication. This directory might be placed on
|
||||||
|
limited-functionality network file systems, hence applications should not assume the full set of file
|
||||||
|
API is available on this directory. Applications should generally not reference this directory
|
||||||
|
directly, but via the per-user <varname>$HOME</varname> environment variable, or via the home
|
||||||
|
directory field of the user database.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/root/</filename></term>
|
||||||
|
<listitem><para>The home directory of the root user. The root user's home directory is located
|
||||||
|
outside of <filename>/home/</filename> in order to make sure the root user may log in even without
|
||||||
|
<filename>/home/</filename> being available and mounted.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/srv/</filename></term>
|
||||||
|
<listitem><para>The place to store general server payload, managed by the administrator. No
|
||||||
|
restrictions are made how this directory is organized internally. Generally writable, and possibly
|
||||||
|
shared among systems. This directory might become available or writable only very late during
|
||||||
|
boot.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/tmp/</filename></term>
|
||||||
|
<listitem><para>The place for small temporary files. This directory is usually mounted as a
|
||||||
|
<literal>tmpfs</literal> instance, and should hence not be used for larger files. (Use
|
||||||
|
<filename>/var/tmp/</filename> for larger files.) This directory is usually flushed at boot-up. Also,
|
||||||
|
files that are not accessed within a certain time may be automatically deleted.</para>
|
||||||
|
|
||||||
|
<para>If applications find the environment variable <varname>$TMPDIR</varname> set, they should use
|
||||||
|
the directory specified in it instead of <filename>/tmp/</filename> (see <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> and
|
||||||
|
<ulink url="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">IEEE
|
||||||
|
Std 1003.1</ulink> for details).</para>
|
||||||
|
|
||||||
|
<para>Since <filename>/tmp/</filename> is accessible to other users of the system, it is essential
|
||||||
|
that files and subdirectories under this directory are only created with <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>mkstemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
|
<citerefentry
|
||||||
|
project='man-pages'><refentrytitle>mkdtemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
|
and similar calls. For more details, see <ulink url="https://systemd.io/TEMPORARY_DIRECTORIES">Using
|
||||||
|
/tmp/ and /var/tmp/ Safely</ulink>.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Runtime Data</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/run/</filename></term>
|
||||||
|
<listitem><para>A <literal>tmpfs</literal> file system for system packages to place runtime data,
|
||||||
|
socket files, and similar. This directory is flushed on boot, and generally writable for privileged
|
||||||
|
programs only. Always writable.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/run/log/</filename></term>
|
||||||
|
<listitem><para>Runtime system logs. System components may place private logs in this
|
||||||
|
directory. Always writable, even when <filename>/var/log/</filename> might not be accessible
|
||||||
|
yet.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/run/user/</filename></term>
|
||||||
|
<listitem><para>Contains per-user runtime directories, each usually individually mounted
|
||||||
|
<literal>tmpfs</literal> instances. Always writable, flushed at each reboot and when the user logs
|
||||||
|
out. User code should not reference this directory directly, but via the
|
||||||
|
<varname>$XDG_RUNTIME_DIR</varname> environment variable, as documented in the <ulink
|
||||||
|
url="https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory
|
||||||
|
Specification</ulink>.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Vendor-supplied Operating System Resources</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/</filename></term>
|
||||||
|
<listitem><para>Vendor-supplied operating system resources. Usually read-only, but this is not
|
||||||
|
required. Possibly shared between multiple hosts. This directory should not be modified by the
|
||||||
|
administrator, except when installing or removing vendor-supplied packages.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/bin/</filename></term>
|
||||||
|
<listitem><para>Binaries and executables for user commands that shall appear in the
|
||||||
|
<varname>$PATH</varname> search path. It is recommended not to place binaries in this directory that
|
||||||
|
are not useful for invocation from a shell (such as daemon binaries); these should be placed in a
|
||||||
|
subdirectory of <filename>/usr/lib/</filename> instead.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/lib/</filename></term>
|
||||||
|
<listitem><para>Static, private vendor data that is compatible with all architectures (though not
|
||||||
|
necessarily architecture-independent). Note that this includes internal executables or other binaries
|
||||||
|
that are not regularly invoked from a shell. Such binaries may be for any architecture supported by
|
||||||
|
the system. Do not place public libraries in this directory, use <varname>$libdir</varname> (see
|
||||||
|
below), instead.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/lib/<replaceable>arch-id</replaceable>/</filename></term>
|
||||||
|
<listitem><para>Location for placing dynamic libraries into, also called
|
||||||
|
<varname>$libdir</varname>. The architecture identifier to use is defined on <ulink
|
||||||
|
url="https://wiki.debian.org/Multiarch/Tuples">Multiarch Architecture Specifiers (Tuples)</ulink>
|
||||||
|
list. Legacy locations of <varname>$libdir</varname> are <filename>/usr/lib/</filename>,
|
||||||
|
<filename>/usr/lib64/</filename>. This directory should not be used for package-specific data, unless
|
||||||
|
this data is architecture-dependent, too.</para>
|
||||||
|
|
||||||
|
<para>To query <varname>$libdir</varname> for the primary architecture of the system, invoke:
|
||||||
|
<programlisting>systemd-path system-library-arch</programlisting></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/share/</filename></term>
|
||||||
|
<listitem><para>Resources shared between multiple packages, such as documentation, man pages, time
|
||||||
|
zone information, fonts and other resources. Usually, the precise location and format of files stored
|
||||||
|
below this directory is subject to specifications that ensure interoperability.</para>
|
||||||
|
|
||||||
|
<para>Note that resources placed in this directory typically are under shared ownership,
|
||||||
|
i.e. multiple different packages have provided and consumed these resources, on equal footing, without
|
||||||
|
any obvious primary owner. This makes things systematically different from
|
||||||
|
<filename>/usr/lib/</filename>, where ownership is generally not shared.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/share/doc/</filename></term>
|
||||||
|
<listitem><para>Documentation for the operating system or system packages.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/share/factory/etc/</filename></term>
|
||||||
|
<listitem><para>Repository for vendor-supplied default configuration files. This directory should be
|
||||||
|
populated with pristine vendor versions of all configuration files that may be placed in
|
||||||
|
<filename>/etc/</filename>. This is useful to compare the local configuration of a system with vendor
|
||||||
|
defaults and to populate the local configuration with defaults. Software should not read configuration
|
||||||
|
settings directly from <filename>/usr/share/factory/</filename>. Those files will be copied to
|
||||||
|
other locations if appropriate, and should only be read from there.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/usr/share/factory/var/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Similar to
|
||||||
|
<filename>/usr/share/factory/etc/</filename>, but for vendor
|
||||||
|
versions of files in the variable, persistent data directory
|
||||||
|
<filename>/var/</filename>. The same recommendations as for
|
||||||
|
<filename>/usr/share/factory/etc/</filename> apply here.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Persistent Variable System Data</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/var/</filename></term>
|
||||||
|
<listitem><para>Persistent, variable system data. Writable during normal system operation. This
|
||||||
|
directory might be pre-populated with vendor-supplied data, but applications should be able to
|
||||||
|
reconstruct necessary files and directories in this subhierarchy should they be missing, as the
|
||||||
|
system might start up without this directory being populated. Persistency is recommended, but
|
||||||
|
optional, to support ephemeral systems. This directory might become available or writable only very
|
||||||
|
late during boot. Components that are required to operate during early boot hence shall not
|
||||||
|
unconditionally rely on this directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/var/cache/</filename></term>
|
||||||
|
<listitem><para>Persistent system cache data. System components may place non-essential data in this
|
||||||
|
directory. Flushing this directory should have no effect on operation of programs, except for
|
||||||
|
increased runtimes necessary to rebuild these caches.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/var/lib/</filename></term>
|
||||||
|
<listitem><para>Persistent system data. System components may place private data in this
|
||||||
|
directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/var/log/</filename></term>
|
||||||
|
<listitem><para>Persistent system logs. System components may place private logs in this directory,
|
||||||
|
though it is recommended to do most logging via the <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
|
||||||
|
<citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||||
|
calls.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/var/tmp/</filename></term>
|
||||||
|
<listitem><para>The place for larger and persistent temporary files. In contrast to
|
||||||
|
<filename>/tmp/</filename>, this directory is usually mounted from a persistent physical file system
|
||||||
|
and can thus accept larger files. (Use <filename>/tmp/</filename> for small ephemeral files.) This
|
||||||
|
directory is generally not flushed at boot-up, but time-based cleanup of files that have not been
|
||||||
|
accessed for a certain time is applied.</para>
|
||||||
|
|
||||||
|
<para>If applications find the environment variable <varname>$TMPDIR</varname> set, they should use
|
||||||
|
the directory specified in it instead of <filename>/var/tmp/</filename> (see <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
|
||||||
|
details).</para>
|
||||||
|
|
||||||
|
<para>The same security restrictions as with <filename>/tmp/</filename> apply: <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>mkstemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
|
<citerefentry
|
||||||
|
project='man-pages'><refentrytitle>mkdtemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
|
and similar calls should be used. For further details about this directory, see <ulink
|
||||||
|
url="https://systemd.io/TEMPORARY_DIRECTORIES">Using /tmp/ and /var/tmp/
|
||||||
|
Safely</ulink>.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Virtual Kernel and API File Systems</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/dev/</filename></term>
|
||||||
|
<listitem><para>The root directory for device nodes. Usually, this directory is mounted as a
|
||||||
|
<literal>devtmpfs</literal> instance, but might be of a different type in sandboxed/containerized
|
||||||
|
setups. This directory is managed jointly by the kernel and
|
||||||
|
<citerefentry><refentrytitle>systemd-udevd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
||||||
|
and should not be written to by other components. A number of special purpose virtual file systems
|
||||||
|
might be mounted below this directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/dev/shm/</filename></term>
|
||||||
|
<listitem><para>Place for POSIX shared memory segments, as created via <citerefentry
|
||||||
|
project='die-net'><refentrytitle>shm_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
|
||||||
|
This directory is flushed on boot, and is a <literal>tmpfs</literal> file system. Since all users
|
||||||
|
have write access to this directory, special care should be taken to avoid name clashes and
|
||||||
|
vulnerabilities. For normal users, shared memory segments in this directory are usually deleted when
|
||||||
|
the user logs out. Usually, it is a better idea to use memory mapped files in
|
||||||
|
<filename>/run/</filename> (for system programs) or <varname>$XDG_RUNTIME_DIR</varname> (for user
|
||||||
|
programs) instead of POSIX shared memory segments, since these directories are not world-writable and
|
||||||
|
hence not vulnerable to security-sensitive name clashes.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/proc/</filename></term>
|
||||||
|
<listitem><para>A virtual kernel file system exposing the process list and other functionality. This
|
||||||
|
file system is mostly an API to interface with the kernel and not a place where normal files may be
|
||||||
|
stored. For details, see <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>. A
|
||||||
|
number of special purpose virtual file systems might be mounted below this
|
||||||
|
directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/proc/sys/</filename></term>
|
||||||
|
<listitem><para>A hierarchy below <filename>/proc/</filename> that exposes a number of kernel
|
||||||
|
tunables. The primary way to configure the settings in this API file tree is via
|
||||||
|
<citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||||
|
files. In sandboxed/containerized setups, this directory is generally mounted
|
||||||
|
read-only.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/sys/</filename></term>
|
||||||
|
<listitem><para>A virtual kernel file system exposing discovered devices and other
|
||||||
|
functionality. This file system is mostly an API to interface with the kernel and not a place where
|
||||||
|
normal files may be stored. In sandboxed/containerized setups, this directory is generally mounted
|
||||||
|
read-only. A number of special purpose virtual file systems might be mounted below this
|
||||||
|
directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/sys/fs/cgroup/</filename></term>
|
||||||
|
<listitem><para>A virtual kernel file system exposing process control groups (cgroups). This file
|
||||||
|
system is an API to interface with the kernel and not a place where normal files may be stored. On
|
||||||
|
current systems running in the default "unified" mode, this directory serves as the mount point for
|
||||||
|
the <literal>cgroup2</literal> filesystem, which provides a unified cgroup hierarchy for all resource
|
||||||
|
controllers. On systems with non-default configurations, this directory may instead be a tmpfs
|
||||||
|
filesystem containing mount points for various <literal>cgroup</literal> (v1) resource controllers;
|
||||||
|
in such configurations, if <literal>cgroup2</literal> is mounted it will be mounted on
|
||||||
|
<filename>/sys/fs/cgroup/unified/</filename>, but cgroup2 will not have resource controllers
|
||||||
|
attached. In sandboxed/containerized setups, this directory may either not exist or may include a
|
||||||
|
subset of functionality.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Compatibility Symlinks</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/bin/</filename></term>
|
||||||
|
<term><filename>/sbin/</filename></term>
|
||||||
|
<term><filename>/usr/sbin/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>These compatibility symlinks point to <filename>/usr/bin/</filename>, ensuring that
|
||||||
|
scripts and binaries referencing these legacy paths correctly find their binaries.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/lib/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>This compatibility symlink points to <filename>/usr/lib/</filename>, ensuring that
|
||||||
|
programs referencing this legacy path correctly find their resources.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/lib64/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>On some architecture ABIs, this compatibility symlink points to
|
||||||
|
<varname>$libdir</varname>, ensuring that binaries referencing this legacy path correctly find their
|
||||||
|
dynamic loader. This symlink only exists on architectures whose ABI places the dynamic loader in this
|
||||||
|
path.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>/var/run/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>This compatibility symlink points to <filename>/run/</filename>, ensuring that
|
||||||
|
programs referencing this legacy path correctly find their runtime data.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Home Directory</title>
|
||||||
|
|
||||||
|
<para>User applications may want to place files and directories in
|
||||||
|
the user's home directory. They should follow the following basic
|
||||||
|
structure. Note that some of these directories are also
|
||||||
|
standardized (though more weakly) by the <ulink
|
||||||
|
url="https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG
|
||||||
|
Base Directory Specification</ulink>. Additional locations for
|
||||||
|
high-level user resources are defined by <ulink
|
||||||
|
url="https://www.freedesktop.org/wiki/Software/xdg-user-dirs">xdg-user-dirs</ulink>.</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>~/.cache/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Persistent user cache data. User programs may place non-essential data in this
|
||||||
|
directory. Flushing this directory should have no effect on operation of programs, except for
|
||||||
|
increased runtimes necessary to rebuild these caches. If an application finds
|
||||||
|
<varname>$XDG_CACHE_HOME</varname> set, it should use the directory specified in it instead of this
|
||||||
|
directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>~/.config/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Application configuration. When a new user is created, this directory will be empty
|
||||||
|
or not exist at all. Applications should fall back to defaults should their configuration in this
|
||||||
|
directory be missing. If an application finds <varname>$XDG_CONFIG_HOME</varname> set, it should use
|
||||||
|
the directory specified in it instead of this directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>~/.local/bin/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Executables that shall appear in the user's <varname>$PATH</varname> search path. It
|
||||||
|
is recommended not to place executables in this directory that are not useful for invocation from a
|
||||||
|
shell; these should be placed in a subdirectory of <filename>~/.local/lib/</filename> instead. Care
|
||||||
|
should be taken when placing architecture-dependent binaries in this place, which might be
|
||||||
|
problematic if the home directory is shared between multiple hosts with different
|
||||||
|
architectures.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>~/.local/lib/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Static, private vendor data that is compatible with all
|
||||||
|
architectures.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>~/.local/lib/<replaceable>arch-id</replaceable>/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Location for placing public dynamic libraries. The architecture identifier to use is
|
||||||
|
defined on <ulink url="https://wiki.debian.org/Multiarch/Tuples">Multiarch Architecture Specifiers
|
||||||
|
(Tuples)</ulink> list.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>~/.local/share/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Resources shared between multiple packages, such as fonts or artwork. Usually, the
|
||||||
|
precise location and format of files stored below this directory is subject to specifications that
|
||||||
|
ensure interoperability. If an application finds <varname>$XDG_DATA_HOME</varname> set, it should use
|
||||||
|
the directory specified in it instead of this directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><filename>~/.local/state/</filename></term>
|
||||||
|
|
||||||
|
<listitem><para>Application state. When a new user is created, this directory will be empty or not
|
||||||
|
exist at all. Applications should fall back to defaults should their state in this directory be
|
||||||
|
missing. If an application finds <varname>$XDG_STATE_HOME</varname> set, it should use the directory
|
||||||
|
specified in it instead of this directory.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Write Access</title>
|
||||||
|
|
||||||
|
<refsect2>
|
||||||
|
<title>Unprivileged Write Access</title>
|
||||||
|
|
||||||
|
<para>Unprivileged processes generally lack write access to most of the hierarchy.</para>
|
||||||
|
|
||||||
|
<para>The exceptions for normal users are
|
||||||
|
<filename>/tmp/</filename>,
|
||||||
|
<filename>/var/tmp/</filename>,
|
||||||
|
<filename>/dev/shm/</filename>, as well as the home directory
|
||||||
|
<varname>$HOME</varname> (usually found below
|
||||||
|
<filename>/home/</filename>) and the runtime directory
|
||||||
|
<varname>$XDG_RUNTIME_DIR</varname> (found below
|
||||||
|
<filename>/run/user/</filename>) of the user, which are all
|
||||||
|
writable.</para>
|
||||||
|
|
||||||
|
<para>For unprivileged system processes, only
|
||||||
|
<filename>/tmp/</filename>,
|
||||||
|
<filename>/var/tmp/</filename> and
|
||||||
|
<filename>/dev/shm/</filename> are writable. If an
|
||||||
|
unprivileged system process needs a private writable directory in
|
||||||
|
<filename>/var/</filename> or <filename>/run/</filename>, it is
|
||||||
|
recommended to either create it before dropping privileges in the
|
||||||
|
daemon code, to create it via
|
||||||
|
<citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||||
|
fragments during boot, or via the
|
||||||
|
<varname>StateDirectory=</varname> and <varname>RuntimeDirectory=</varname>
|
||||||
|
directives of service units (see
|
||||||
|
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||||
|
for details).</para>
|
||||||
|
|
||||||
|
<para><filename>/tmp/</filename>, <filename>/var/tmp/</filename> and <filename>/dev/shm/</filename>
|
||||||
|
should be mounted <option>nosuid</option> and <option>nodev</option>, which means that set-user-id mode
|
||||||
|
and character or block special devices are not interpreted on those file systems. In general it is not
|
||||||
|
possible to mount them <option>noexec</option>, because various programs use those directories for
|
||||||
|
dynamically generated or optimized code, and with that flag those use cases would break. Using this
|
||||||
|
flag is OK on special-purpose installations or systems where all software that may be installed is
|
||||||
|
known and does not require such functionality. See the discussion of
|
||||||
|
<option>nosuid</option>/<option>nodev</option>/<option>noexec</option> in <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> and
|
||||||
|
<constant>PROT_EXEC</constant> in <citerefentry
|
||||||
|
project='man-pages'><refentrytitle>mmap</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
|
||||||
|
</para>
|
||||||
|
</refsect2>
|
||||||
|
|
||||||
|
<refsect2>
|
||||||
|
<title>Lack of Write Access on Read-Only Systems and during System Recovery</title>
|
||||||
|
|
||||||
|
<para>As noted above, some systems operate with the <filename>/usr</filename> and
|
||||||
|
<filename>/etc</filename> hierarchies mounted read-only, possibly only allowing write access during
|
||||||
|
package upgrades. Other part of the hierarchy are generally mounted read-write (in particular
|
||||||
|
<filename>/var</filename> and <filename>/var/tmp</filename>), but may be read-only when the kernel
|
||||||
|
remounts the file system read-only in response to errors, or when the system is booted read-only for
|
||||||
|
recovery purposes. To the extent reasonable, applications should be prepared to execute without write
|
||||||
|
access, so that for example, failure to save non-essential data to <filename>/var/cache/</filename> or
|
||||||
|
failure to create a custom log file under <filename>/var/log</filename> does not prevent the
|
||||||
|
application from running.</para>
|
||||||
|
|
||||||
|
<para>The <filename>/run/</filename> directory is available since the earliest boot and is always
|
||||||
|
writable. It should be used for any runtime data and sockets, so that write access to e.g.
|
||||||
|
<filename>/etc</filename> or <filename>/var</filename> is not needed.</para>
|
||||||
|
</refsect2>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Node Types</title>
|
||||||
|
|
||||||
|
<para>Unix file systems support different types of file nodes,
|
||||||
|
including regular files, directories, symlinks, character and
|
||||||
|
block device nodes, sockets and FIFOs.</para>
|
||||||
|
|
||||||
|
<para>It is strongly recommended that <filename>/dev/</filename> is
|
||||||
|
the only location below which device nodes shall be placed.
|
||||||
|
Similarly, <filename>/run/</filename> shall be the only location to
|
||||||
|
place sockets and FIFOs. Regular files, directories and symlinks
|
||||||
|
may be used in all directories.</para>
|
||||||
|
|
||||||
|
<para>Applications should expect that a security policy might be enforced on a system that enforces these
|
||||||
|
rules.</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>System Packages</title>
|
||||||
|
|
||||||
|
<para>Developers of system packages should follow strict rules when placing their files in the file
|
||||||
|
system. The following table lists recommended locations for specific types of files supplied by the
|
||||||
|
vendor.</para>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<title>System package vendor files locations</title>
|
||||||
|
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
||||||
|
<colspec colname="directory" />
|
||||||
|
<colspec colname="purpose" />
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>Directory</entry>
|
||||||
|
<entry>Purpose</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/usr/bin/</filename></entry>
|
||||||
|
<entry>Package executables that shall appear in the <varname>$PATH</varname> executable search path, compiled for any of the supported architectures compatible with the operating system. It is not recommended to place internal binaries or binaries that are not commonly invoked from the shell in this directory, such as daemon binaries. As this directory is shared with most other packages of the system, special care should be taken to pick unique names for files placed here, that are unlikely to clash with other package's files.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/usr/lib/<replaceable>arch-id</replaceable>/</filename></entry>
|
||||||
|
<entry>Public shared libraries of the package. As above, be careful with using too generic names, and pick unique names for your libraries to place here to avoid name clashes.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/usr/lib/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Private static vendor resources of the package, including private binaries and libraries, or any other kind of read-only vendor data.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/usr/lib/<replaceable>arch-id</replaceable>/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Private other vendor resources of the package that are architecture-specific and cannot be shared between architectures. Note that this generally does not include private executables since binaries of a specific architecture may be freely invoked from any other supported system architecture.</entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<para>Additional static vendor files with shared ownership may be installed in the
|
||||||
|
<filename>/usr/share/</filename> hierarchy to the locations defined by the various relevant
|
||||||
|
specifications.</para>
|
||||||
|
|
||||||
|
<para>The following directories shall be used by the package for local configuration and files created
|
||||||
|
during runtime:</para>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<title>System package variable files locations</title>
|
||||||
|
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
||||||
|
<colspec colname="directory" />
|
||||||
|
<colspec colname="purpose" />
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>Directory</entry>
|
||||||
|
<entry>Purpose</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/etc/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>System-specific configuration for the package. It is recommended to default to safe fallbacks if this configuration is missing, if this is possible. Alternatively, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment may be used to copy or symlink the necessary files and directories from <filename>/usr/share/factory/</filename> during boot, via the <literal>L</literal> or <literal>C</literal> directives.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/run/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Runtime data for the package. Packages must be able to create the necessary subdirectories in this tree on their own, since the directory is flushed automatically on boot. Alternatively, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment may be used to create the necessary directories during boot, or the <varname>RuntimeDirectory=</varname> directive of service units may be used to create them at service startup (see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details).</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/run/log/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Runtime log data for the package. As above, the package needs to make sure to create this directory if necessary, as it will be flushed on every boot.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/var/cache/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Persistent cache data of the package. If this directory is flushed, the application should work correctly on next invocation, though possibly slowed down due to the need to rebuild any local cache files. The application must be capable of recreating this directory should it be missing and necessary. To create an empty directory, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment or the <varname>CacheDirectory=</varname> directive of service units (see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>) may be used.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/var/lib/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Persistent private data of the package. This is the primary place to put persistent data that does not fall into the other categories listed. Packages should be able to create the necessary subdirectories in this tree on their own, since the directory might be missing on boot. To create an empty directory, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment or the <varname>StateDirectory=</varname> directive of service units (see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>) may be used.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>/var/log/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Persistent log data of the package. As above, the package should make sure to create this directory if necessary, possibly using <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> or <varname>LogsDirectory=</varname> (see <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>), as it might be missing.</entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>User Packages</title>
|
||||||
|
|
||||||
|
<para>Programs running in user context should follow strict rules when placing their own files in the
|
||||||
|
user's home directory. The following table lists recommended locations in the home directory for specific
|
||||||
|
types of files supplied by the vendor if the application is installed in the home directory. (User
|
||||||
|
applications installed system-wide are covered by the rules outlined above for vendor files.)</para>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<title>Vendor package file locations under the home directory of the user</title>
|
||||||
|
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
||||||
|
<colspec colname="directory" />
|
||||||
|
<colspec colname="purpose" />
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>Directory</entry>
|
||||||
|
<entry>Purpose</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><filename>~/.local/bin/</filename></entry>
|
||||||
|
<entry>Package executables that shall appear in the <varname>$PATH</varname> executable search path. It is not recommended to place internal executables or executables that are not commonly invoked from the shell in this directory, such as daemon executables. As this directory is shared with most other packages of the user, special care should be taken to pick unique names for files placed here, that are unlikely to clash with other package's files.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>~/.local/lib/<replaceable>arch-id</replaceable>/</filename></entry>
|
||||||
|
<entry>Public shared libraries of the package. As above, be careful with using overly generic names, and pick unique names for your libraries to place here to avoid name clashes.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>~/.local/lib/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Private, static vendor resources of the package, compatible with any architecture, or any other kind of read-only vendor data.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>~/.local/lib/<replaceable>arch-id</replaceable>/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Private other vendor resources of the package that are architecture-specific and cannot be shared between architectures.</entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<para>Additional static vendor files with shared ownership may be installed in the
|
||||||
|
<filename>~/.local/share/</filename> hierarchy, mirroring the subdirectories specified in the section
|
||||||
|
"Vendor-supplied operating system resources" above.</para>
|
||||||
|
|
||||||
|
<para>The following directories shall be used by the package for per-user local configuration and files
|
||||||
|
created during runtime:</para>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<title>User package variable file locations</title>
|
||||||
|
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
||||||
|
<colspec colname="directory" />
|
||||||
|
<colspec colname="purpose" />
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>Directory</entry>
|
||||||
|
<entry>Purpose</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><filename>~/.config/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>User-specific configuration for the package. It is required to default to safe fallbacks if this configuration is missing.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename><varname>$XDG_RUNTIME_DIR</varname>/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>User runtime data for the package.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>~/.cache/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Persistent cache data of the package. If this directory is flushed, the application should work correctly on next invocation, though possibly slowed down due to the need to rebuild any local cache files. The application must be capable of recreating this directory should it be missing and necessary.</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><filename>~/.local/state/<replaceable>package</replaceable>/</filename></entry>
|
||||||
|
<entry>Persistent state data of the package.</entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>See Also</title>
|
<title>See Also</title>
|
||||||
<para><simplelist>
|
<para><simplelist type="inline">
|
||||||
|
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
||||||
<member><citerefentry project='man-pages'><refentrytitle>hier</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
|
<member><citerefentry project='man-pages'><refentrytitle>hier</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
|
||||||
<member><ulink url="http://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html">File System Hierarchy</ulink></member>
|
<member><citerefentry><refentrytitle>systemd-path</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
||||||
<member><ulink url="https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory Specification</ulink></member>
|
<member><citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
|
||||||
<member><ulink url="https://www.freedesktop.org/wiki/Software/xdg-user-dirs">XDG User Directories</ulink></member>
|
<member><citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
|
||||||
|
<member><citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
|
||||||
|
<member><citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
||||||
|
<member><citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
|
||||||
</simplelist></para>
|
</simplelist></para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
|||||||
@ -721,10 +721,9 @@
|
|||||||
<term><varname>BindsTo=</varname></term>
|
<term><varname>BindsTo=</varname></term>
|
||||||
|
|
||||||
<listitem><para>Configures requirement dependencies, very similar in style to
|
<listitem><para>Configures requirement dependencies, very similar in style to
|
||||||
<varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effects of
|
<varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effect of
|
||||||
<varname>Requires=</varname>, which already stops (or restarts) the configuring unit when a listed unit is
|
<varname>Requires=</varname> it declares that if the unit bound to is stopped, this unit will be stopped
|
||||||
explicitly stopped (or restarted), it also does so when a listed unit stops unexpectedly (which includes when it
|
too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too.
|
||||||
fails).
|
|
||||||
Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit
|
Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit
|
||||||
might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of
|
might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of
|
||||||
a mount unit might be unmounted without involvement of the system and service manager.</para>
|
a mount unit might be unmounted without involvement of the system and service manager.</para>
|
||||||
|
|||||||
@ -4,5 +4,5 @@
|
|||||||
Environment=
|
Environment=
|
||||||
GIT_URL=https://src.fedoraproject.org/rpms/systemd.git
|
GIT_URL=https://src.fedoraproject.org/rpms/systemd.git
|
||||||
GIT_BRANCH=rawhide
|
GIT_BRANCH=rawhide
|
||||||
GIT_COMMIT=12f95f807fef5075a8842dd107f83b4c41d5ac26
|
GIT_COMMIT=8e2833a5b64f7e2ce62ea0a2d0ec9e393e718dfa
|
||||||
PKG_SUBDIR=fedora
|
PKG_SUBDIR=fedora
|
||||||
|
|||||||
@ -6,4 +6,3 @@ Packages=
|
|||||||
gdb
|
gdb
|
||||||
llvm
|
llvm
|
||||||
meson # Also needed in the NO_BUILD case so we list it explicitly.
|
meson # Also needed in the NO_BUILD case so we list it explicitly.
|
||||||
valgrind
|
|
||||||
|
|||||||
@ -394,7 +394,6 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
|
|||||||
if (v->base == TIMER_CALENDAR) {
|
if (v->base == TIMER_CALENDAR) {
|
||||||
bool rebase_after_boot_time = false;
|
bool rebase_after_boot_time = false;
|
||||||
usec_t b, random_offset = 0;
|
usec_t b, random_offset = 0;
|
||||||
usec_t boot_monotonic = UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic;
|
|
||||||
|
|
||||||
if (t->random_offset_usec != 0)
|
if (t->random_offset_usec != 0)
|
||||||
random_offset = timer_get_fixed_delay_hash(t) % t->random_offset_usec;
|
random_offset = timer_get_fixed_delay_hash(t) % t->random_offset_usec;
|
||||||
@ -415,16 +414,9 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
|
|||||||
t->last_trigger.realtime);
|
t->last_trigger.realtime);
|
||||||
else
|
else
|
||||||
b = trigger->inactive_enter_timestamp.realtime;
|
b = trigger->inactive_enter_timestamp.realtime;
|
||||||
} else if (dual_timestamp_is_set(&t->last_trigger)) {
|
} else if (dual_timestamp_is_set(&t->last_trigger))
|
||||||
b = t->last_trigger.realtime;
|
b = t->last_trigger.realtime;
|
||||||
|
else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
|
||||||
/* Check if the last_trigger timestamp is older than the current machine
|
|
||||||
* boot. If so, this means the timestamp came from a stamp file of a
|
|
||||||
* persistent timer and we need to rebase it to make RandomizedDelaySec=
|
|
||||||
* work (see below). */
|
|
||||||
if (t->last_trigger.monotonic < boot_monotonic)
|
|
||||||
rebase_after_boot_time = true;
|
|
||||||
} else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
|
|
||||||
b = UNIT(t)->inactive_exit_timestamp.realtime - random_offset;
|
b = UNIT(t)->inactive_exit_timestamp.realtime - random_offset;
|
||||||
else {
|
else {
|
||||||
b = ts.realtime - random_offset;
|
b = ts.realtime - random_offset;
|
||||||
@ -442,7 +434,8 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
|
|||||||
* time has already passed, set the time when systemd first started as the scheduled
|
* time has already passed, set the time when systemd first started as the scheduled
|
||||||
* time. Note that we base this on the monotonic timestamp of the boot, not the
|
* time. Note that we base this on the monotonic timestamp of the boot, not the
|
||||||
* realtime one, since the wallclock might have been off during boot. */
|
* realtime one, since the wallclock might have been off during boot. */
|
||||||
usec_t rebased = map_clock_usec(boot_monotonic, CLOCK_MONOTONIC, CLOCK_REALTIME);
|
usec_t rebased = map_clock_usec(UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic,
|
||||||
|
CLOCK_MONOTONIC, CLOCK_REALTIME);
|
||||||
if (v->next_elapse < rebased)
|
if (v->next_elapse < rebased)
|
||||||
v->next_elapse = rebased;
|
v->next_elapse = rebased;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1599,7 +1599,7 @@ static int setup_environment(
|
|||||||
return setup_runtime_directory(handle, ur, runtime_directory, area);
|
return setup_runtime_directory(handle, ur, runtime_directory, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int open_osc_context(pam_handle_t *handle, const char *session_type, UserRecord *ur, bool debug) {
|
static int open_osc_context(pam_handle_t *handle, const char *session_type, UserRecord *ur) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(handle);
|
assert(handle);
|
||||||
@ -1628,7 +1628,7 @@ static int open_osc_context(pam_handle_t *handle, const char *session_type, User
|
|||||||
* so that we don't delay tty hang-up. */
|
* so that we don't delay tty hang-up. */
|
||||||
_cleanup_close_ int tty_opath_fd = fd_reopen(STDOUT_FILENO, O_PATH|O_CLOEXEC);
|
_cleanup_close_ int tty_opath_fd = fd_reopen(STDOUT_FILENO, O_PATH|O_CLOEXEC);
|
||||||
if (tty_opath_fd < 0)
|
if (tty_opath_fd < 0)
|
||||||
pam_debug_syslog_errno(handle, debug, tty_opath_fd, "Failed to pin TTY, ignoring: %m");
|
pam_syslog_errno(handle, LOG_DEBUG, tty_opath_fd, "Failed to pin TTY, ignoring: %m");
|
||||||
else
|
else
|
||||||
tty_opath_fd = fd_move_above_stdio(tty_opath_fd);
|
tty_opath_fd = fd_move_above_stdio(tty_opath_fd);
|
||||||
|
|
||||||
@ -1670,7 +1670,7 @@ static int open_osc_context(pam_handle_t *handle, const char *session_type, User
|
|||||||
return PAM_SUCCESS;
|
return PAM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int close_osc_context(pam_handle_t *handle, bool debug) {
|
static int close_osc_context(pam_handle_t *handle) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(handle);
|
assert(handle);
|
||||||
@ -1695,7 +1695,7 @@ static int close_osc_context(pam_handle_t *handle, bool debug) {
|
|||||||
/* Now open the original TTY again, so that we can write on it */
|
/* Now open the original TTY again, so that we can write on it */
|
||||||
_cleanup_close_ int fd = fd_reopen(tty_opath_fd, O_WRONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
_cleanup_close_ int fd = fd_reopen(tty_opath_fd, O_WRONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
pam_debug_syslog_errno(handle, debug, fd, "Failed to reopen TTY, ignoring: %m");
|
pam_syslog_errno(handle, LOG_DEBUG, fd, "Failed to reopen TTY, ignoring: %m");
|
||||||
return PAM_SUCCESS;
|
return PAM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1715,7 +1715,7 @@ static int close_osc_context(pam_handle_t *handle, bool debug) {
|
|||||||
/* When we are closing things, the TTY might not take our writes anymore. Accept that gracefully. */
|
/* When we are closing things, the TTY might not take our writes anymore. Accept that gracefully. */
|
||||||
r = loop_write(fd, osc, SIZE_MAX);
|
r = loop_write(fd, osc, SIZE_MAX);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
pam_debug_syslog_errno(handle, debug, r, "Failed to write OSC sequence to TTY, ignoring: %m");
|
pam_syslog_errno(handle, LOG_DEBUG, r, "Failed to write OSC sequence to TTY, ignoring: %m");
|
||||||
|
|
||||||
return PAM_SUCCESS;
|
return PAM_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1807,7 +1807,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
|
|||||||
if (r != PAM_SUCCESS)
|
if (r != PAM_SUCCESS)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
return open_osc_context(handle, c.type, ur, debug);
|
return open_osc_context(handle, c.type, ur);
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ PAM_EXTERN int pam_sm_close_session(
|
_public_ PAM_EXTERN int pam_sm_close_session(
|
||||||
@ -1844,7 +1844,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
|
|||||||
return pam_syslog_pam_error(handle, LOG_ERR, r,
|
return pam_syslog_pam_error(handle, LOG_ERR, r,
|
||||||
"Failed to get PAM systemd.existing data: @PAMERR@");
|
"Failed to get PAM systemd.existing data: @PAMERR@");
|
||||||
|
|
||||||
(void) close_osc_context(handle, debug);
|
(void) close_osc_context(handle);
|
||||||
|
|
||||||
id = pam_getenv(handle, "XDG_SESSION_ID");
|
id = pam_getenv(handle, "XDG_SESSION_ID");
|
||||||
if (id && !existing) {
|
if (id && !existing) {
|
||||||
|
|||||||
@ -75,7 +75,7 @@ int pam_syslog_errno(pam_handle_t *handle, int level, int error, const char *for
|
|||||||
LOCAL_ERRNO(error);
|
LOCAL_ERRNO(error);
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
sym_pam_vsyslog(handle, level, format, ap);
|
sym_pam_vsyslog(handle, LOG_ERR, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return error == -ENOMEM ? PAM_BUF_ERR : PAM_SERVICE_ERR;
|
return error == -ENOMEM ? PAM_BUF_ERR : PAM_SERVICE_ERR;
|
||||||
|
|||||||
@ -35,20 +35,13 @@ int pam_syslog_errno(pam_handle_t *handle, int level, int error, const char *for
|
|||||||
|
|
||||||
int pam_syslog_pam_error(pam_handle_t *handle, int level, int error, const char *format, ...) _printf_(4,5);
|
int pam_syslog_pam_error(pam_handle_t *handle, int level, int error, const char *format, ...) _printf_(4,5);
|
||||||
|
|
||||||
/* Call sym_pam_syslog if debug is enabled */
|
/* Call pam_vsyslog if debug is enabled */
|
||||||
#define pam_debug_syslog(handle, debug, fmt, ...) \
|
#define pam_debug_syslog(handle, debug, fmt, ...) \
|
||||||
({ \
|
({ \
|
||||||
if (debug) \
|
if (debug) \
|
||||||
sym_pam_syslog(handle, LOG_DEBUG, fmt, ## __VA_ARGS__); \
|
sym_pam_syslog(handle, LOG_DEBUG, fmt, ## __VA_ARGS__); \
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Call pam_syslog_errno if debug is enabled */
|
|
||||||
#define pam_debug_syslog_errno(handle, debug, error, fmt, ...) \
|
|
||||||
({ \
|
|
||||||
if (debug) \
|
|
||||||
pam_syslog_errno(handle, LOG_DEBUG, error, fmt, ## __VA_ARGS__); \
|
|
||||||
})
|
|
||||||
|
|
||||||
static inline int pam_log_oom(pam_handle_t *handle) {
|
static inline int pam_log_oom(pam_handle_t *handle) {
|
||||||
/* This is like log_oom(), but uses PAM logging */
|
/* This is like log_oom(), but uses PAM logging */
|
||||||
return pam_syslog_errno(handle, LOG_ERR, ENOMEM, "Out of memory.");
|
return pam_syslog_errno(handle, LOG_ERR, ENOMEM, "Out of memory.");
|
||||||
|
|||||||
@ -1,67 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
||||||
#
|
|
||||||
# Persistent timers (i.e. timers with Persitent=yes) save their last trigger timestamp to a persistent
|
|
||||||
# storage (a stamp file), which is loaded during subsequent boots. As mentioned in the man page, such timers
|
|
||||||
# should be still affected by RandomizedDelaySec= during boot even if they already elapsed and would be then
|
|
||||||
# triggered immediately.
|
|
||||||
#
|
|
||||||
# This behavior was, however, broken by [0], which stopped rebasing the to-be next elapse timestamps
|
|
||||||
# unconditionally and left that only for timers that have neither last trigger nor inactive exit timestamps
|
|
||||||
# set, since rebasing is needed only during boot. This holds for regular timers during boot, but not for
|
|
||||||
# persistent ones, since the last trigger timestamp is loaded from a persistent storage.
|
|
||||||
#
|
|
||||||
# Provides coverage for:
|
|
||||||
# - https://github.com/systemd/systemd/issues/39739
|
|
||||||
#
|
|
||||||
# [0] bdb8e584f4509de0daebbe2357d23156160c3a90
|
|
||||||
#
|
|
||||||
set -eux
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
# shellcheck source=test/units/test-control.sh
|
|
||||||
. "$(dirname "$0")"/util.sh
|
|
||||||
|
|
||||||
UNIT_NAME="timer-RandomizedDelaySec-persistent-$RANDOM"
|
|
||||||
STAMP_FILE="/var/lib/systemd/timers/stamp-$UNIT_NAME.timer"
|
|
||||||
|
|
||||||
# Setup
|
|
||||||
cat >"/run/systemd/system/$UNIT_NAME.timer" <<EOF
|
|
||||||
[Timer]
|
|
||||||
OnCalendar=daily
|
|
||||||
Persistent=true
|
|
||||||
RandomizedDelaySec=12h
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat >"/run/systemd/system/$UNIT_NAME.service" <<\EOF
|
|
||||||
[Service]
|
|
||||||
ExecStart=echo "Service ran at $(date)"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
systemctl daemon-reload
|
|
||||||
|
|
||||||
# Create timer's state file with an old-enough timestamp (~2 days ago), so it'd definitely elapse if the next
|
|
||||||
# elapse timestamp wouldn't get rebased
|
|
||||||
mkdir -p "$(dirname "$STAMP_FILE")"
|
|
||||||
touch -d "2 days ago" "$STAMP_FILE"
|
|
||||||
stat "$STAMP_FILE"
|
|
||||||
SAVED_LAST_TRIGGER_S="$(stat --format="%Y" "$STAMP_FILE")"
|
|
||||||
|
|
||||||
# Start the timer and verify that its last trigger timestamp didn't change
|
|
||||||
#
|
|
||||||
# The last trigger timestamp should get rebased before it gets used as a base for the next elapse timestamp
|
|
||||||
# (since it pre-dates the machine boot time). This should then add a RandomizedDelaySec= to the rebased
|
|
||||||
# timestamp and the timer unit should not get triggered immediately after starting.
|
|
||||||
systemctl start "$UNIT_NAME.timer"
|
|
||||||
systemctl status "$UNIT_NAME.timer"
|
|
||||||
|
|
||||||
TIMER_LAST_TRIGGER="$(systemctl show --property=LastTriggerUSec --value "$UNIT_NAME.timer")"
|
|
||||||
TIMER_LAST_TRIGGER_S="$(date --date="$TIMER_LAST_TRIGGER" "+%s")"
|
|
||||||
: "The timer should not be triggered immediately, hence the last trigger timestamp should not change"
|
|
||||||
assert_eq "$SAVED_LAST_TRIGGER_S" "$TIMER_LAST_TRIGGER_S"
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
systemctl stop "$UNIT_NAME".{timer,service}
|
|
||||||
systemctl clean --what=state "$UNIT_NAME.timer"
|
|
||||||
rm -f "/run/systemd/system/$UNIT_NAME".{timer,service}
|
|
||||||
systemctl daemon-reload
|
|
||||||
Loading…
x
Reference in New Issue
Block a user