Compare commits

...

17 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek a79be2f807 hwdb: update for v246
As usual, it seems that there are mostly additions with a smaller amount
of corrections, no big removals.
2020-06-26 05:20:50 +09:00
Zbigniew Jędrzejewski-Szmek 3f11426f52
Merge pull request #16275 from yuwata/network-deprecate-netdevsim
network: deprecate netdevsim support
2020-06-25 18:41:49 +02:00
Łukasz Stelmach fdf3e48c44 udev: split attribute assignment for MMC cards
Some cards have names consisting only of whitespace characters which
prevents the original rule from matching and assigning ID_SERIAL
properly. With the split rules ID_SERIAL and ID_NAME are assigned
independently and the symlink is created only if both are available the
same way it has worked for partitions.
2020-06-25 18:40:45 +02:00
Luca Boccassi 6d88513e6b portabled: create temp file for unit, not directory
open_tmpfile_linkable is used to create a temporary file in the same
directory as the target, but portabled uses the name of the parent
directory instead of the file it intends to create.
In other words, it creats a tmp for /etc/systemd/system.attached instead
of /etc/systemd/system.attached/foo.service.
It still works because it's later moved in the right place.
But as a side effect, it tries the create the file in the parent directory
which is /etc/systemd, and it case of read-only filesystems it fails.
2020-06-25 18:40:19 +02:00
Christian Göttsche 823e917f13 selinux: check mac_selinux_init() in tests
Since bc8d57f290 mac_selinux_init() is checked and considered fatal
tree-wide.

Coverity complains about it not being checked in the test code.

Follow-up of: #16223
Fixes: CID 1429975
2020-06-25 18:39:42 +02:00
Zbigniew Jędrzejewski-Szmek 0986bb9b95
Merge pull request #16278 from keszybz/fix-man-links
Fix html links
2020-06-25 18:38:37 +02:00
Zbigniew Jędrzejewski-Szmek 66ed28d332
Merge pull request #15624 from poettering/hostnamed-instant
hostnamed: stop caching so much
2020-06-25 18:36:56 +02:00
Zbigniew Jędrzejewski-Szmek 98506a41fe
Merge pull request #15697 from OhNoMoreGit/fix-path-units
Recheck PathExists=, PathExistsGlob=, DirectoryNotEmpty= when triggered unit terminates
2020-06-25 18:23:47 +02:00
Zbigniew Jędrzejewski-Szmek 4a5a01ccdd man: reword awkward sentence 2020-06-25 14:41:44 +02:00
Zbigniew Jędrzejewski-Szmek 55cf7779f2 man: fix various internal references
Found with linkchecker.
2020-06-25 14:41:44 +02:00
Zbigniew Jędrzejewski-Szmek b7a4734551 man: fix links to various external man pages
In cases where we used both die-net and man-pages for the same reference,
I switched to use man-pages everywhere.
2020-06-25 14:41:44 +02:00
Lennart Poettering d7f4ad203a hostnamed: minimize caching of /etc/hostname, /etc/os-release and /etc/machine-info
Instead of reading these files at startup and never again, let's read
them when we need them. As an optimization (in particular as some of
these files contain the data for many fields at once) let's cache the
results as long as the stat data (i.e. mtime) remains stable.

Also, while we are at it, if we can't read any of these props, let's not
fail everything, but continue without the data.
2020-06-25 13:49:11 +02:00
Lennart Poettering aa994368c9 hostnamed: don't cache local hostname either
Querying the current hostname is cheap, hence let's not cache it. That
way it is much less likely we'll return out-of-date data.
2020-06-25 13:49:07 +02:00
Yu Watanabe 440988666c test-network: remove unused config 2020-06-25 17:30:19 +09:00
Yu Watanabe 59a9ef1022 network: deprecate netdevsim support in .netdev config
Since kernel 5.2, netdevsim creation/destruction via netlink is removed.
So, let's remove the netdevsim support from our documents.

See below commit for more details.
e05b2d141f
2020-06-25 17:26:40 +09:00
Michael Chapman 708961c701 core/path: recheck path specs when triggered unit changes state
As documented in systemd.path(5):

    When a service unit triggered by a path unit terminates (regardless
    whether it exited successfully or failed), monitored paths are
    checked immediately again, and the service accordingly restarted
    instantly.

This commit implements this behaviour for PathExists=, PathExistsGlob=,
and DirectoryNotEmpty=. These predicates are essentially
"level-triggered": the service should be activated whenever the
predicate is true. PathChanged= and PathModified=, on the other hand,
are "edge-triggered": the service should only be activated when the
predicate *becomes* true.

The behaviour has been broken since at least as far back as commit
8fca6944c2 ("path: stop watching path specs once we triggered the target
unit"). This commit had systemd stop monitoring inotify whenever the
triggered unit was activated. Unfortunately this meant it never updated
the ->inotify_triggered flag, so it never rechecked the path specs when
the triggered unit deactivated.

With this commit, systemd rechecks all paths specs whenever the
triggered unit deactivates. If any PathExists=, PathExistsGlob= or
DirectoryNotEmpty= predicate passes, the triggered unit is reactivated.

If the target unit is activated by something outside of the path unit,
the path unit immediately transitions to a running state. This ensures
the path unit stops monitoring inotify in this situation.

With this change in place, commit d7cf8c24d4 ("core/path: fix spurious
triggering of PathExists= on restart/reload") is no longer necessary.
The path unit (and its triggered unit) is now always active whenever
the PathExists= predicate passes, so there is no spurious restart when
systemd is reloaded or restarted.
2020-05-05 13:56:02 +10:00
Michael Chapman f285f07752 core/path: use escaped path in serialization 2020-05-05 13:56:02 +10:00
59 changed files with 23001 additions and 1991 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
--- 20-acpi-vendor.hwdb.base 2020-03-06 12:40:11.417307950 +0100
+++ 20-acpi-vendor.hwdb 2020-03-06 12:40:11.433308177 +0100
--- 20-acpi-vendor.hwdb.base 2020-06-25 15:39:12.679783537 +0200
+++ 20-acpi-vendor.hwdb 2020-06-25 15:39:12.697783719 +0200
@@ -3,6 +3,8 @@
# Data imported from:
# https://uefi.org/uefi-pnp-export

View File

@ -470,6 +470,9 @@ pci:v*d*sv*sd*bc0Csc03i20*
pci:v*d*sv*sd*bc0Csc03i30*
ID_PCI_INTERFACE_FROM_DATABASE=XHCI
pci:v*d*sv*sd*bc0Csc03i40*
ID_PCI_INTERFACE_FROM_DATABASE=USB4 Host Interface
pci:v*d*sv*sd*bc0Csc03i80*
ID_PCI_INTERFACE_FROM_DATABASE=Unspecified

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
of firmware, this firmware may also load the kernel directly.</para>
<para>The kernel (optionally) mounts an in-memory file system, often generated by
<citerefentry project='die-net'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
which looks for the root file system. Nowadays this is usually implemented as an initramfs — a compressed
archive which is extracted when the kernel boots up into a lightweight in-memory file system based on
tmpfs, but in the past normal file systems using an in-memory block device (ramdisk) were used, and the
@ -349,7 +349,7 @@ systemd-reboot.service systemd-poweroff.service systemd-halt.service syste
<citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-halt.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry project='die-net'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -134,7 +134,7 @@
<listitem><para>Invoke a debugger on the last core dump
matching specified characteristics. By default,
<citerefentry><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>
will be used. This may be changed using the <option>--debugger=</option>
option or the <varname>$SYSTEMD_DEBUGGER</varname> environment
variable.</para></listitem>
@ -213,7 +213,7 @@
<listitem><para>Use the given debugger for the <command>debug</command>
command. If not given and <varname>$SYSTEMD_DEBUGGER</varname> is unset, then
<citerefentry><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>
will be used. </para></listitem>
</varlistentry>

View File

@ -621,7 +621,7 @@
<listitem><para>Filter output to entries where the <varname>MESSAGE=</varname>
field matches the specified regular expression. PERL-compatible regular expressions
are used, see
<citerefentry><refentrytitle>pcre2pattern</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry project='url'><refentrytitle url='http://pcre.org/current/doc/html/pcre2pattern.html'>pcre2pattern</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for a detailed description of the syntax.</para>
<para>If the pattern is all lowercase, matching is case insensitive.

View File

@ -109,7 +109,7 @@
<para>During early boot, the generation of core dump files is disabled until a core dump handler (if any)
takes over. This parameter allows specifying an absolute path where core dump files should be stored until
a handler is installed. The path should be absolute and may contain specifiers, see
<citerefentry><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details.</para>
<citerefentry project='man-pages'><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details.</para>
</listitem>
</varlistentry>

View File

@ -80,7 +80,7 @@
</para></listitem>
<listitem><para><filename>50-depmod.install</filename> runs
<citerefentry><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum></citerefentry> for the
<citerefentry project='man-pages'><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum></citerefentry> for the
<replaceable>KERNEL-VERSION</replaceable>.</para></listitem>
<listitem><para><filename>90-loaderentry.install</filename> copies <replaceable>KERNEL-IMAGE</replaceable>
@ -231,7 +231,7 @@
<para>
<citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<ulink url="https://systemd.io/BOOT_LOADER_SPECIFICATION">Boot Loader Specification</ulink>
</para>

View File

@ -233,7 +233,7 @@ s - Service VLAN, m - Two-port MAC Relay (TPMR)
<listitem><para>Show numerical address labels that can be used for address selection.
This is the same information that
<citerefentry><refentrytitle>ip-addrlabel</refentrytitle><manvolnum>8</manvolnum></citerefentry>
<citerefentry project='die-net'><refentrytitle>ip-addrlabel</refentrytitle><manvolnum>8</manvolnum></citerefentry>
shows. See <ulink url="https://tools.ietf.org/html/rfc3484">RFC 3484</ulink>
for a discussion of address labels.</para>

View File

@ -75,7 +75,7 @@ node /org/freedesktop/LogControl1 {
<title>Properties</title>
<para><varname>LogLevel</varname> describes the
<citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>-style
<citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>-style
log-level, and should be one of <literal>emerg</literal>, <literal>alert</literal>,
<literal>crit</literal>, <literal>err</literal>, <literal>warning</literal>, <literal>notice</literal>,
<literal>info</literal>, <literal>debug</literal>, in order of increasing verbosity.</para>
@ -86,14 +86,14 @@ node /org/freedesktop/LogControl1 {
<literal>journal</literal> (log the the journal natively, see
<citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>),
<literal>syslog</literal> (log using the
<citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> call).
<citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> call).
</para>
<para>Those two properties are writable, so they may be set by sufficiently privileged users.</para>
<para><varname>SyslogIdentifier</varname> is a read-only property that shows the "syslog identifier".
It is a short string that identifies the program that is the source of log messages that is passed to
the <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> call.
the <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> call.
</para>
<para>Note: <command>journalctl</command> option <option>-p</option>/<option>--priority=</option> may

View File

@ -165,7 +165,7 @@ node /org/freedesktop/home1 {
<para><function>GetHomeByName()</function> returns basic user information (a minimal subset of the full
user record), provided a user name. The information supplied more or less matches what
<citerefentry><refentrytitle>getpwnam</refentrytitle><manvolnum>3</manvolnum></citerefentry> returns:
<citerefentry project='man-pages'><refentrytitle>getpwnam</refentrytitle><manvolnum>3</manvolnum></citerefentry> returns:
the numeric UID and GID, the real name, home directory and shell. In addition it returns a state
identifier describing the state the user's home directory is in, as well as a bus path referring to the
bus object encapsulating the user record and home directory. This object implements the

View File

@ -37,7 +37,7 @@
is mostly a small companion service for
<citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
Many operations to manipulate local container and VM images are hence available via the <command>systemd-machined</command> D-Bus API, c.f.
<citerefentry><refentrytitle>org.freedesktop.machine1.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
<citerefentry><refentrytitle>org.freedesktop.machine1</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
</refsect1>

View File

@ -567,7 +567,7 @@ node /org/freedesktop/login1 {
<para><function>SetWallMessage()</function> sets the wall message (the message that will be sent out to
all terminals and stored in a
<citerefentry><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry> record) for a
<citerefentry project='man-pages'><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry> record) for a
subsequent scheduled shutdown operation. The parameter <varname>wall_message</varname> specifies the
shutdown reason (and may be empty) which will be included in the shutdown message. The parameter
<varname>enable</varname> specifies whether to print a wall message on shutdown.</para>

View File

@ -368,7 +368,8 @@ node /org/freedesktop/machine1 {
<para><function>OpenMachinePTY()</function> allocates a pseudo TTY in the container and returns a file
descriptor and its path. This is equivalent to transitioning into the container and invoking
<citerefentry><refentrytitle>posix_openpt</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
<citerefentry project='man-pages'><refentrytitle>posix_openpt</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
<para><function>OpenMachineLogin()</function> allocates a pseudo TTY in the container and ensures that
a getty login prompt of the container is running on the other end. It returns the file descriptor of

View File

@ -1312,7 +1312,7 @@ node /org/freedesktop/systemd1 {
<para><function>SetUnitProperties()</function> may be used to modify certain unit properties at
runtime. Not all properties may be changed at runtime, but many resource management settings (primarily
those listed in
<citerefentry><refentrytitle>systemd.cgroup</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
may. The changes are applied instantly and stored on disk for future boots, unless
<varname>runtime</varname> is true, in which case the settings only apply until the next
reboot. <varname>name</varname> is the name of the unit to modify. <varname>properties</varname> are
@ -8278,16 +8278,16 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
<para>Most of the properties map directly to the corresponding settings in swap unit files. As mount
units invoke the
<citerefentry><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> command,
<citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> command,
their bus objects include implicit <varname>ExecActivate</varname> (and similar) fields which contain
information about processes to execute. They also share most of the fields related to the execution
context that Service objects expose (see above). In addition to these properties there are the
following:</para>
<para><varname>ControlPID</varname> contains the PID of the currently running
<citerefentry><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> or
<citerefentry><refentrytitle>swapoff</refentrytitle><manvolnum>8</manvolnum></citerefentry> command if
there is one running, otherwise 0.</para>
<citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> or
<citerefentry project='man-pages'><refentrytitle>swapoff</refentrytitle><manvolnum>8</manvolnum></citerefentry>
command if there is one running, otherwise 0.</para>
<para><varname>Result</varname> contains a value explaining why a mount unit failed if it failed. It
can take the values <literal>success</literal>, <literal>resources</literal>,

View File

@ -253,7 +253,7 @@
<para> See
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information about the resources.
Also, see <citerefentry><refentrytitle>pam_set_data</refentrytitle><manvolnum>3</manvolnum></citerefentry> for additional information about how to set
Also, see <citerefentry project='man-pages'><refentrytitle>pam_set_data</refentrytitle><manvolnum>3</manvolnum></citerefentry> for additional information about how to set
the context objects.
</para>

View File

@ -316,11 +316,11 @@
<term><option>-a</option></term>
<listitem><para>Registers per-interface DNS configuration data with
<command>systemd-resolved</command>. Expects a network interface name as only command line argument. Reads
<citerefentry><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> compatible DNS
configuration data from its standard input. Relevant fields are <literal>nameserver</literal> and
<citerefentry project='man-pages'><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>-compatible
DNS configuration data from its standard input. Relevant fields are <literal>nameserver</literal> and
<literal>domain</literal>/<literal>search</literal>. This command is mostly identical to invoking
<command>resolvectl</command> with a combination of <option>dns</option> and
<option>domain</option> commands.</para></listitem>
<command>resolvectl</command> with a combination of <option>dns</option> and <option>domain</option>
commands.</para></listitem>
</varlistentry>
<varlistentry>

View File

@ -86,6 +86,10 @@
<citerefentry><refentrytitle>sd_bus_get_name_machine_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_name_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_owner_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_property</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_property_trivial</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_property_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_property_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_scope</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_tid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_unique_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
@ -111,10 +115,6 @@
<citerefentry><refentrytitle>sd_bus_message_get_errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_property</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_property_trivial</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_property_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_property_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_signature</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_type</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

View File

@ -91,7 +91,7 @@
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -83,11 +83,11 @@
<constant>SD_BUS_MESSAGE_METHOD_RETURN</constant>, <constant>SD_BUS_MESSAGE_METHOD_ERROR</constant>,
<constant>SD_BUS_MESSAGE_SIGNAL</constant>. This type is either specified as a parameter when the message
is created using
<citerefentry><refentrytitle>sd_bus_set_message_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
or is set automatically when the message is created using
<citerefentry><refentrytitle>sd_bus_set_message_new_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_message_new_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
and similar functions.</para>
<para><function>sd_bus_message_get_error()</function> returns the error stored in the message
@ -108,20 +108,20 @@
signal message. If <parameter>interface</parameter> is non-null, it also checks if the message has the
same interface set. If <parameter>member</parameter> is non-null, it also checks if the message has the
same member set. Also see
<citerefentry><refentrytitle>sd_bus_set_message_new_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
<citerefentry><refentrytitle>sd_bus_message_new_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
It returns true when all checks pass.</para>
<para><function>sd_bus_message_is_method_call()</function> checks if message <parameter>m</parameter>
is a method call message. If <parameter>interface</parameter> is non-null, it also checks if the message
has the same interface set. If <parameter>member</parameter> is non-null, it also checks if the message
has the same member set. Also see
<citerefentry><refentrytitle>sd_bus_set_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
It returns true when all checks pass.</para>
<para><function>sd_bus_message_is_method_error()</function> checks if message <parameter>m</parameter>
is an error reply message. If <parameter>name</parameter> is non-null, it also checks if the message has
the same error identifier set. Also see
<citerefentry><refentrytitle>sd_bus_set_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
<citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
It returns true when all checks pass.</para>
</refsect1>

View File

@ -98,7 +98,7 @@
an error reply similarly to
<function>sd_bus_message_new_method_error()</function>, but in addition to the
error structure <parameter>p</parameter>, it takes an
<citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
error value in parameter <parameter>error</parameter>. If the error
<parameter>p</parameter> is set (see
<citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>),
@ -111,7 +111,7 @@
<para>The <function>sd_bus_message_new_method_errnof()</function> function
creates an error reply similarly to
<function>sd_bus_message_new_method_error()</function>. It takes an
<citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
error value in parameter <parameter>error</parameter>, plus a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
format string <parameter>format</parameter> and corresponding arguments.

View File

@ -45,7 +45,7 @@
parameter. The signal will be sent to path <parameter>path</parameter>, on the interface
<parameter>interface</parameter>, member <parameter>member</parameter>. When this message is
sent, no reply is expected. See
<citerefentry><refentrytitle>sd_bus_message_new_call</refentrytitle><manvolnum>1</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>1</manvolnum></citerefentry>
for a short description of the meaning of the <parameter>path</parameter>,
<parameter>interface</parameter>, and <parameter>member</parameter> parameters.
</para>

View File

@ -152,7 +152,7 @@
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_seqnum</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

View File

@ -84,7 +84,7 @@
<para>The <function>sd_bus_reply_method_error()</function> function sends an error reply to the
<parameter>call</parameter> message. The error structure <parameter>e</parameter> specifies the
error to send, and is used as described in
<citerefentry><refentrytitle>sd_bus_message_new_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
<citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
If no reply is expected to <parameter>call</parameter>, this function succeeds without sending a
reply.</para>

View File

@ -48,7 +48,7 @@
socket binding for a bus connection object. If the <parameter>b</parameter> is true, the feature is enabled,
otherwise disabled (which is the default). When enabled, and the selected bus address refers to an
<filename>AF_UNIX</filename> socket in the file system which does not exist while the connection attempt is made an
<citerefentry><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry> watch is installed on
<citerefentry project='man-pages'><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry> watch is installed on
it, waiting for the socket to appear. As soon as the socket appears the connection is made. This functionality is
useful in particular in early-boot programs that need to run before the system bus is available, but want to
connect to it the instant it may be connected to.</para>
@ -56,18 +56,18 @@
<para><function>sd_bus_get_watch_bind()</function> may be used to query the current setting of this feature. It
returns zero when the feature is disabled, and positive if enabled.</para>
<para>Note that no timeout is applied while it is waited for the socket to appear. This means that any synchronous
remote operation (such as
<para>Note that no timeout is applied while we wait for the socket to appear. This means that any
synchronous remote operation (such as
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry> or
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>), that is
used on a connection with this feature enabled that is not established yet might block unbounded if the socket is
never created. However, asynchronous remote operations (such as
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>),
that is used on a connection with this feature enabled that hasn't been established yet, might block
forever if the socket is never created. However, asynchronous remote operations (such as
<citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_add_match_async</refentrytitle><manvolnum>3</manvolnum></citerefentry> or
<citerefentry><refentrytitle>sd_bus_request_match_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>) do
not block in this case, and safely enqueue the requested operations to be dispatched the instant the connection is
set up.</para>
<citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_add_match_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
do not block in this case, and safely enqueue the requested operations to be dispatched the instant the
connection is set up.</para>
<para>Use <citerefentry><refentrytitle>sd_bus_is_ready</refentrytitle><manvolnum>3</manvolnum></citerefentry> to
determine whether the connection is fully established, i.e. whether the peer socket has been bound, connected to
@ -106,7 +106,7 @@
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

View File

@ -148,7 +148,7 @@
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-udev.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>

View File

@ -112,7 +112,7 @@
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-udev.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>

View File

@ -63,7 +63,7 @@ key.pattern.overridden.with.glob = custom
<literal>net.ipv4.conf.enp3s0/200.forwarding</literal> or
<literal>net/ipv4/conf/enp3s0.200/forwarding</literal> may be used to refer to
<filename>/proc/sys/net/ipv4/conf/enp3s0.200/forwarding</filename>. A glob
<citerefentry><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry> pattern may be
<citerefentry project='man-pages'><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry> pattern may be
used to write the same value to all matching keys. Keys for which an explicit pattern exists will be
excluded from any glob matching. In addition, a key may be explicitly excluded from being set by any
matching glob patterns by specifying the key name prefixed with a <literal>-</literal> character and not

View File

@ -669,7 +669,7 @@ Service b@0.service not loaded, b.socket cannot be started.
<command>dot</command> command (see above), this selects which
relationships are shown in the dependency graph. Both options
require a
<citerefentry project='die-net'><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>
pattern as an argument, which will be matched against the
left-hand and the right-hand, respectively, nodes of a
relationship.</para>

View File

@ -106,18 +106,19 @@ systemd-tmpfiles --create --prefix /var/log/journal</programlisting>
errors. In order to react gracefully in this case it is recommended that programs logging to standard output/error
ignore such errors. If the <constant>SIGPIPE</constant> UNIX signal handler is not blocked or turned off, such
write attempts will also result in such process signals being generated, see
<citerefentry><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>. To mitigate this issue,
systemd service manager explicitly turns off the <constant>SIGPIPE</constant> signal for all invoked processes by
default (this may be changed for each unit individually via the <varname>IgnoreSIGPIPE=</varname> option, see
<citerefentry project='man-pages'><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
To mitigate this issue, systemd service manager explicitly turns off the <constant>SIGPIPE</constant>
signal for all invoked processes by default (this may be changed for each unit individually via the
<varname>IgnoreSIGPIPE=</varname> option, see
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
details). After the standard output/standard error streams have been terminated they may not be recovered until the
services they are associated with are restarted. Note that during normal operation,
<filename>systemd-journald.service</filename> stores copies of the file descriptors for those streams in the
service manager. If <filename>systemd-journald.service</filename> is restarted using <command>systemctl
restart</command> or equivalent operation instead of a pair of separate <command>systemctl stop</command> and
<command>systemctl start</command> commands (or equivalent operations), these stream connections are not terminated
and survive the restart. It is thus safe to restart <filename>systemd-journald.service</filename>, but stopping it
is not recommended.</para>
details). After the standard output/standard error streams have been terminated they may not be recovered
until the services they are associated with are restarted. Note that during normal operation,
<filename>systemd-journald.service</filename> stores copies of the file descriptors for those streams in
the service manager. If <filename>systemd-journald.service</filename> is restarted using
<command>systemctl restart</command> or equivalent operation instead of a pair of separate
<command>systemctl stop</command> and <command>systemctl start</command> commands (or equivalent
operations), these stream connections are not terminated and survive the restart. It is thus safe to
restart <filename>systemd-journald.service</filename>, but stopping it is not recommended.</para>
<para>Note that the log record metadata for records transferred via such standard output/error streams reflect the
metadata of the peer the stream was originally created for. If the stream connection is passed on to other

View File

@ -76,7 +76,7 @@
<listitem><para>The
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry> library
exposes the
<citerefentry><refentrytitle>sd_bus_open_system_container</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_open_system_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call to connect to the system bus of any registered container.</para></listitem>
<listitem><para>The

View File

@ -96,7 +96,7 @@
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-networkd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -92,7 +92,7 @@
<citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-networkd-wait-online.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-networkd-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -732,9 +732,9 @@ CapabilityBoundingSet=~CAP_B CAP_C</programlisting>
kernel default of <literal><constant>private-anonymous</constant>
<constant>shared-anonymous</constant> <constant>elf-headers</constant>
<constant>private-huge</constant></literal>). See
<citerefentry><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry> for the
meaning of the mapping types. When specified multiple times, all specified masks are ORed. When not
set, or if the empty value is assigned, the inherited value is not changed.</para>
<citerefentry project='man-pages'><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for the meaning of the mapping types. When specified multiple times, all specified masks are
ORed. When not set, or if the empty value is assigned, the inherited value is not changed.</para>
<example>
<title>Add DAX pages to the dump filter</title>
@ -880,7 +880,7 @@ CapabilityBoundingSet=~CAP_B CAP_C</programlisting>
in <varname>NUMAMask=</varname>. For more details on each policy please see,
<citerefentry><refentrytitle>set_mempolicy</refentrytitle><manvolnum>2</manvolnum></citerefentry>. For overall
overview of NUMA support in Linux see,
<citerefentry><refentrytitle>numa</refentrytitle><manvolnum>7</manvolnum></citerefentry>
<citerefentry project='man-pages'><refentrytitle>numa</refentrytitle><manvolnum>7</manvolnum></citerefentry>
</para></listitem>
</varlistentry>

View File

@ -27,7 +27,7 @@
<title>Description</title>
<para>A plain ini-style text file that encodes configuration for matching network devices, used by
<citerefentry><refentrytitle>systemd-udev</refentrytitle><manvolnum>8</manvolnum></citerefentry> and in
<citerefentry><refentrytitle>systemd-udevd</refentrytitle><manvolnum>8</manvolnum></citerefentry> and in
particular its <command>net_setup_link</command> builtin. See
<citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a
general description of the syntax.</para>

View File

@ -171,9 +171,6 @@
<row><entry><varname>wireguard</varname></entry>
<entry>WireGuard Secure Network Tunnel.</entry></row>
<row><entry><varname>netdevsim</varname></entry>
<entry>A simulator. This simulated networking device is used for testing various networking APIs and at this time is particularly focused on testing hardware offloading related interfaces.</entry></row>
<row><entry><varname>nlmon</varname></entry>
<entry>A Netlink monitor device. Use an nlmon device when you want to monitor system Netlink messages.</entry></row>

View File

@ -1078,8 +1078,8 @@
manager. If set to <constant>kill</constant> and one of the service's processes is killed by the OOM
killer the kernel is instructed to kill all remaining processes of the service, too. Defaults to the
setting <varname>DefaultOOMPolicy=</varname> in
<citerefentry><refentrytitle>system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> is
set to, except for services where <varname>Delegate=</varname> is turned on, where it defaults to
<citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
is set to, except for services where <varname>Delegate=</varname> is turned on, where it defaults to
<constant>continue</constant>.</para>
<para>Use the <varname>OOMScoreAdjust=</varname> setting to configure whether processes of the unit

View File

@ -76,8 +76,9 @@ KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394
KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n"
# MMC
KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", \
ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}"
KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ENV{ID_NAME}="$attr{name}"
KERNEL=="mmcblk[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
KERNEL=="mmcblk[0-9]p[0-9]*", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
# UBI-MTD

View File

@ -174,15 +174,13 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
return r;
}
static bool path_spec_check_good(PathSpec *s, bool initial) {
static bool path_spec_check_good(PathSpec *s, bool initial, bool from_trigger_notify) {
bool b, good = false;
switch (s->type) {
case PATH_EXISTS:
b = access(s->path, F_OK) >= 0;
good = b && !s->previous_exists;
s->previous_exists = b;
good = access(s->path, F_OK) >= 0;
break;
case PATH_EXISTS_GLOB:
@ -200,7 +198,7 @@ static bool path_spec_check_good(PathSpec *s, bool initial) {
case PATH_CHANGED:
case PATH_MODIFIED:
b = access(s->path, F_OK) >= 0;
good = !initial && b != s->previous_exists;
good = !initial && !from_trigger_notify && b != s->previous_exists;
s->previous_exists = b;
break;
@ -425,8 +423,7 @@ static void path_set_state(Path *p, PathState state) {
old_state = p->state;
p->state = state;
if (state != PATH_WAITING &&
(state != PATH_RUNNING || p->inotify_triggered))
if (!IN_SET(state, PATH_WAITING, PATH_RUNNING))
path_unwatch(p);
if (state != old_state)
@ -435,7 +432,7 @@ static void path_set_state(Path *p, PathState state) {
unit_notify(UNIT(p), state_translation_table[old_state], state_translation_table[state], 0);
}
static void path_enter_waiting(Path *p, bool initial, bool recheck);
static void path_enter_waiting(Path *p, bool initial, bool from_trigger_notify);
static int path_coldplug(Unit *u) {
Path *p = PATH(u);
@ -446,7 +443,7 @@ static int path_coldplug(Unit *u) {
if (p->deserialized_state != p->state) {
if (IN_SET(p->deserialized_state, PATH_WAITING, PATH_RUNNING))
path_enter_waiting(p, true, true);
path_enter_waiting(p, true, false);
else
path_set_state(p, p->deserialized_state);
}
@ -486,8 +483,6 @@ static void path_enter_running(Path *p) {
if (r < 0)
goto fail;
p->inotify_triggered = false;
path_set_state(p, PATH_RUNNING);
path_unwatch(p);
@ -498,27 +493,35 @@ fail:
path_enter_dead(p, PATH_FAILURE_RESOURCES);
}
static bool path_check_good(Path *p, bool initial) {
static bool path_check_good(Path *p, bool initial, bool from_trigger_notify) {
PathSpec *s;
assert(p);
LIST_FOREACH(spec, s, p->specs)
if (path_spec_check_good(s, initial))
if (path_spec_check_good(s, initial, from_trigger_notify))
return true;
return false;
}
static void path_enter_waiting(Path *p, bool initial, bool recheck) {
static void path_enter_waiting(Path *p, bool initial, bool from_trigger_notify) {
Unit *trigger;
int r;
if (recheck)
if (path_check_good(p, initial)) {
log_unit_debug(UNIT(p), "Got triggered.");
path_enter_running(p);
return;
}
/* If the triggered unit is already running, so are we */
trigger = UNIT_TRIGGER(UNIT(p));
if (trigger && !UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(trigger))) {
path_set_state(p, PATH_RUNNING);
path_unwatch(p);
return;
}
if (path_check_good(p, initial, from_trigger_notify)) {
log_unit_debug(UNIT(p), "Got triggered.");
path_enter_running(p);
return;
}
r = path_watch(p);
if (r < 0)
@ -528,12 +531,11 @@ static void path_enter_waiting(Path *p, bool initial, bool recheck) {
* might have appeared/been removed by now, so we must
* recheck */
if (recheck)
if (path_check_good(p, false)) {
log_unit_debug(UNIT(p), "Got triggered.");
path_enter_running(p);
return;
}
if (path_check_good(p, false, from_trigger_notify)) {
log_unit_debug(UNIT(p), "Got triggered.");
path_enter_running(p);
return;
}
path_set_state(p, PATH_WAITING);
return;
@ -579,7 +581,7 @@ static int path_start(Unit *u) {
path_mkdir(p);
p->result = PATH_SUCCESS;
path_enter_waiting(p, true, true);
path_enter_waiting(p, true, false);
return 1;
}
@ -617,7 +619,7 @@ static int path_serialize(Unit *u, FILE *f, FDSet *fds) {
(void) serialize_item_format(f, "path-spec", "%s %i %s",
type,
s->previous_exists,
s->path);
escaped);
}
return 0;
@ -728,15 +730,10 @@ static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, v
if (changed < 0)
goto fail;
/* If we are already running, then remember that one event was
* dispatched so that we restart the service only if something
* actually changed on disk */
p->inotify_triggered = true;
if (changed)
path_enter_running(p);
else
path_enter_waiting(p, false, true);
path_enter_waiting(p, false, false);
return 0;
@ -760,11 +757,11 @@ static void path_trigger_notify(Unit *u, Unit *other) {
if (p->state == PATH_RUNNING &&
UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
log_unit_debug(UNIT(p), "Got notified about unit deactivation.");
/* Hmm, so inotify was triggered since the
* last activation, so I guess we need to
* recheck what is going on. */
path_enter_waiting(p, false, p->inotify_triggered);
path_enter_waiting(p, false, true);
} else if (p->state == PATH_WAITING &&
!UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
log_unit_debug(UNIT(p), "Got notified about unit activation.");
path_enter_waiting(p, false, true);
}
}

View File

@ -56,8 +56,6 @@ struct Path {
PathState state, deserialized_state;
bool inotify_triggered;
bool make_directory;
mode_t directory_mode;

View File

@ -28,6 +28,7 @@
#include "selinux-util.h"
#include "service-util.h"
#include "signal-util.h"
#include "stat-util.h"
#include "strv.h"
#include "user-util.h"
#include "util.h"
@ -36,54 +37,89 @@
#define VALID_DEPLOYMENT_CHARS (DIGITS LETTERS "-.:")
enum {
PROP_HOSTNAME,
/* Read from /etc/hostname */
PROP_STATIC_HOSTNAME,
/* Read from /etc/machine-info */
PROP_PRETTY_HOSTNAME,
PROP_ICON_NAME,
PROP_CHASSIS,
PROP_DEPLOYMENT,
PROP_LOCATION,
/* Read from /etc/os-release (or /usr/lib/os-release) */
PROP_OS_PRETTY_NAME,
PROP_OS_CPE_NAME,
PROP_HOME_URL,
_PROP_MAX
PROP_OS_HOME_URL,
_PROP_MAX,
_PROP_INVALID = -1,
};
typedef struct Context {
char *data[_PROP_MAX];
struct stat etc_hostname_stat;
struct stat etc_os_release_stat;
struct stat etc_machine_info_stat;
Hashmap *polkit_registry;
} Context;
static void context_reset(Context *c) {
static void context_reset(Context *c, uint64_t mask) {
int p;
assert(c);
for (p = 0; p < _PROP_MAX; p++)
for (p = 0; p < _PROP_MAX; p++) {
if (!FLAGS_SET(mask, UINT64_C(1) << p))
continue;
c->data[p] = mfree(c->data[p]);
}
}
static void context_destroy(Context *c) {
assert(c);
context_reset(c);
context_reset(c, UINT64_MAX);
bus_verify_polkit_async_registry_free(c->polkit_registry);
}
static int context_read_data(Context *c) {
static void context_read_etc_hostname(Context *c) {
struct stat current_stat = {};
int r;
assert(c);
context_reset(c);
if (stat("/etc/hostname", &current_stat) >= 0 &&
stat_inode_unmodified(&c->etc_hostname_stat, &current_stat))
return;
c->data[PROP_HOSTNAME] = gethostname_malloc();
if (!c->data[PROP_HOSTNAME])
return -ENOMEM;
context_reset(c, UINT64_C(1) << PROP_STATIC_HOSTNAME);
r = read_etc_hostname(NULL, &c->data[PROP_STATIC_HOSTNAME]);
if (r < 0 && r != -ENOENT)
return r;
log_warning_errno(r, "Failed to read /etc/hostname, ignoring: %m");
c->etc_hostname_stat = current_stat;
}
static void context_read_machine_info(Context *c) {
struct stat current_stat = {};
int r;
assert(c);
if (stat("/etc/machine-info", &current_stat) >= 0 &&
stat_inode_unmodified(&c->etc_machine_info_stat, &current_stat))
return;
context_reset(c,
(UINT64_C(1) << PROP_PRETTY_HOSTNAME) |
(UINT64_C(1) << PROP_ICON_NAME) |
(UINT64_C(1) << PROP_CHASSIS) |
(UINT64_C(1) << PROP_DEPLOYMENT) |
(UINT64_C(1) << PROP_LOCATION));
r = parse_env_file(NULL, "/etc/machine-info",
"PRETTY_HOSTNAME", &c->data[PROP_PRETTY_HOSTNAME],
@ -92,17 +128,36 @@ static int context_read_data(Context *c) {
"DEPLOYMENT", &c->data[PROP_DEPLOYMENT],
"LOCATION", &c->data[PROP_LOCATION]);
if (r < 0 && r != -ENOENT)
return r;
log_warning_errno(r, "Failed to read /etc/machine-info, ignoring: %m");
c->etc_machine_info_stat = current_stat;
}
static void context_read_os_release(Context *c) {
struct stat current_stat = {};
int r;
assert(c);
if ((stat("/etc/os-release", &current_stat) >= 0 ||
stat("/usr/lib/os-release", &current_stat) >= 0) &&
stat_inode_unmodified(&c->etc_os_release_stat, &current_stat))
return;
context_reset(c,
(UINT64_C(1) << PROP_OS_PRETTY_NAME) |
(UINT64_C(1) << PROP_OS_CPE_NAME) |
(UINT64_C(1) << PROP_OS_HOME_URL));
r = parse_os_release(NULL,
"PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
"CPE_NAME", &c->data[PROP_OS_CPE_NAME],
"HOME_URL", &c->data[PROP_HOME_URL],
"HOME_URL", &c->data[PROP_OS_HOME_URL],
NULL);
if (r < 0 && r != -ENOENT)
return r;
log_warning_errno(r, "Failed to read os-release file, ignoring: %m");
return 0;
c->etc_os_release_stat = current_stat;
}
static bool valid_chassis(const char *chassis) {
@ -244,12 +299,22 @@ static bool hostname_is_useful(const char *hn) {
return !isempty(hn) && !is_localhost(hn);
}
static int context_update_kernel_hostname(Context *c) {
const char *static_hn;
const char *hn;
static int context_update_kernel_hostname(
Context *c,
const char *transient_hn) {
const char *static_hn, *hn;
struct utsname u;
assert(c);
if (!transient_hn) {
/* If no transient hostname is passed in, then let's check what is currently set. */
assert_se(uname(&u) >= 0);
transient_hn =
isempty(u.nodename) || streq(u.nodename, "(none)") ? NULL : u.nodename;
}
static_hn = c->data[PROP_STATIC_HOSTNAME];
/* /etc/hostname with something other than "localhost"
@ -258,8 +323,8 @@ static int context_update_kernel_hostname(Context *c) {
hn = static_hn;
/* ... the transient hostname, (ie: DHCP) comes next ... */
else if (!isempty(c->data[PROP_HOSTNAME]))
hn = c->data[PROP_HOSTNAME];
else if (!isempty(transient_hn))
hn = transient_hn;
/* ... fallback to static "localhost.*" ignored above ... */
else if (!isempty(static_hn))
@ -278,7 +343,6 @@ static int context_update_kernel_hostname(Context *c) {
}
static int context_write_data_static_hostname(Context *c) {
assert(c);
if (isempty(c->data[PROP_STATIC_HOSTNAME])) {
@ -342,6 +406,94 @@ static int context_write_data_machine_info(Context *c) {
return write_env_file_label("/etc/machine-info", l);
}
static int property_get_hostname(
sd_bus *bus,
const char *path,
const char *interface,
const char *property,
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
_cleanup_free_ char *current = NULL;
int r;
r = gethostname_strict(&current);
if (r == -ENXIO)
return sd_bus_message_append(reply, "s", FALLBACK_HOSTNAME);
if (r < 0)
return r;
return sd_bus_message_append(reply, "s", current);
}
static int property_get_static_hostname(
sd_bus *bus,
const char *path,
const char *interface,
const char *property,
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
Context *c = userdata;
assert(c);
context_read_etc_hostname(c);
return sd_bus_message_append(reply, "s", c->data[PROP_STATIC_HOSTNAME]);
}
static int property_get_machine_info_field(
sd_bus *bus,
const char *path,
const char *interface,
const char *property,
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
sd_bus_slot *slot;
Context *c;
/* Acquire the context object without this property's userdata offset added. Explanation: we want
* access to two pointers here: a) the main context object we cache all properties in, and b) the
* pointer to the property field inside the context object that we are supposed to update and
* use. The latter (b) we get in the 'userdata' function parameter, and sd-bus calculates that for us
* from the 'userdata' pointer we supplied when the vtable was registered, with the offset we
* specified in the vtable added on top. To get the former (a) we need the 'userdata' pointer from
* the vtable registration directly, without the offset added. Hence we ask sd-bus what the slot
* object is (which encapsulates the vtable registration), and then query the 'userdata' field
* directly off it. */
assert_se(slot = sd_bus_get_current_slot(bus));
assert_se(c = sd_bus_slot_get_userdata(slot));
context_read_machine_info(c);
return sd_bus_message_append(reply, "s", *(char**) userdata);
}
static int property_get_os_release_field(
sd_bus *bus,
const char *path,
const char *interface,
const char *property,
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
sd_bus_slot *slot;
Context *c;
/* As above, acquire the current context without this property's userdata offset added. */
assert_se(slot = sd_bus_get_current_slot(bus));
assert_se(c = sd_bus_slot_get_userdata(slot));
context_read_os_release(c);
return sd_bus_message_append(reply, "s", *(char**) userdata);
}
static int property_get_icon_name(
sd_bus *bus,
const char *path,
@ -355,6 +507,8 @@ static int property_get_icon_name(
Context *c = userdata;
const char *name;
context_read_machine_info(c);
if (isempty(c->data[PROP_ICON_NAME]))
name = n = context_fallback_icon_name(c);
else
@ -378,6 +532,8 @@ static int property_get_chassis(
Context *c = userdata;
const char *name;
context_read_machine_info(c);
if (isempty(c->data[PROP_CHASSIS]))
name = fallback_chassis();
else
@ -405,8 +561,8 @@ static int property_get_uname_field(
static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *error) {
Context *c = userdata;
const char *name;
int interactive;
int r;
int interactive, r;
struct utsname u;
assert(m);
assert(c);
@ -415,6 +571,8 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *
if (r < 0)
return r;
context_read_etc_hostname(c);
if (isempty(name))
name = c->data[PROP_STATIC_HOSTNAME];
@ -424,7 +582,8 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *
if (!hostname_is_valid(name, false))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", name);
if (streq_ptr(name, c->data[PROP_HOSTNAME]))
assert_se(uname(&u) >= 0);
if (streq_ptr(name, u.nodename))
return sd_bus_reply_method_return(m, NULL);
r = bus_verify_polkit_async(
@ -441,17 +600,13 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *
if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
r = free_and_strdup(&c->data[PROP_HOSTNAME], name);
if (r < 0)
return r;
r = context_update_kernel_hostname(c);
r = context_update_kernel_hostname(c, name);
if (r < 0) {
log_error_errno(r, "Failed to set hostname: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %m");
}
log_info("Changed hostname to '%s'", strna(c->data[PROP_HOSTNAME]));
log_info("Changed hostname to '%s'", name);
(void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), "/org/freedesktop/hostname1", "org.freedesktop.hostname1", "Hostname", NULL);
@ -473,6 +628,8 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
name = empty_to_null(name);
context_read_etc_hostname(c);
if (streq_ptr(name, c->data[PROP_STATIC_HOSTNAME]))
return sd_bus_reply_method_return(m, NULL);
@ -497,7 +654,7 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
if (r < 0)
return r;
r = context_update_kernel_hostname(c);
r = context_update_kernel_hostname(c, NULL);
if (r < 0) {
log_error_errno(r, "Failed to set hostname: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %m");
@ -530,6 +687,8 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
name = empty_to_null(name);
context_read_machine_info(c);
if (streq_ptr(name, c->data[prop]))
return sd_bus_reply_method_return(m, NULL);
@ -671,19 +830,19 @@ static int method_get_product_uuid(sd_bus_message *m, void *userdata, sd_bus_err
static const sd_bus_vtable hostname_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("Hostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("StaticHostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_STATIC_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("PrettyHostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_PRETTY_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Hostname", "s", property_get_hostname, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("StaticHostname", "s", property_get_static_hostname, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("PrettyHostname", "s", property_get_machine_info_field, offsetof(Context, data) + sizeof(char*) * PROP_PRETTY_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("IconName", "s", property_get_icon_name, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Chassis", "s", property_get_chassis, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Deployment", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_DEPLOYMENT, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Location", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_LOCATION, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Deployment", "s", property_get_machine_info_field, offsetof(Context, data) + sizeof(char*) * PROP_DEPLOYMENT, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Location", "s", property_get_machine_info_field, offsetof(Context, data) + sizeof(char*) * PROP_LOCATION, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("KernelName", "s", property_get_uname_field, offsetof(struct utsname, sysname), SD_BUS_VTABLE_ABSOLUTE_OFFSET|SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("KernelRelease", "s", property_get_uname_field, offsetof(struct utsname, release), SD_BUS_VTABLE_ABSOLUTE_OFFSET|SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("KernelVersion", "s", property_get_uname_field, offsetof(struct utsname, version), SD_BUS_VTABLE_ABSOLUTE_OFFSET|SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("OperatingSystemPrettyName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_PRETTY_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("OperatingSystemCPEName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_CPE_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HomeURL", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_HOME_URL, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("OperatingSystemPrettyName", "s", property_get_os_release_field, offsetof(Context, data) + sizeof(char*) * PROP_OS_PRETTY_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("OperatingSystemCPEName", "s", property_get_os_release_field, offsetof(Context, data) + sizeof(char*) * PROP_OS_CPE_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HomeURL", "s", property_get_os_release_field, offsetof(Context, data) + sizeof(char*) * PROP_OS_HOME_URL, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_METHOD_WITH_NAMES("SetHostname",
"sb",
@ -826,10 +985,6 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return r;
r = context_read_data(&context);
if (r < 0)
return log_error_errno(r, "Failed to read hostname and machine information: %m");
r = bus_event_loop_with_idle(event, bus, "org.freedesktop.hostname1", DEFAULT_EXIT_USEC, NULL, NULL);
if (r < 0)
return log_error_errno(r, "Failed to run event loop: %m");

View File

@ -877,7 +877,7 @@ static int attach_unit_file(
_cleanup_(unlink_and_freep) char *tmp = NULL;
_cleanup_close_ int fd = -1;
fd = open_tmpfile_linkable(where, O_WRONLY|O_CLOEXEC, &tmp);
fd = open_tmpfile_linkable(path, O_WRONLY|O_CLOEXEC, &tmp);
if (fd < 0)
return log_debug_errno(fd, "Failed to create unit file '%s': %m", path);

View File

@ -61,28 +61,34 @@ static void shutdown_test(Manager *m) {
manager_free(m);
}
static void check_stop_unlink(Manager *m, Unit *unit, const char *test_path, const char *service_name) {
static Service *service_for_path(Manager *m, Path *path, const char *service_name) {
_cleanup_free_ char *tmp = NULL;
Unit *service_unit = NULL;
Service *service = NULL;
usec_t ts;
usec_t timeout = 2 * USEC_PER_SEC;
assert_se(m);
assert_se(unit);
assert_se(test_path);
assert_se(path);
if (!service_name) {
assert_se(tmp = strreplace(unit->id, ".path", ".service"));
assert_se(tmp = strreplace(UNIT(path)->id, ".path", ".service"));
service_unit = manager_get_unit(m, tmp);
} else
service_unit = manager_get_unit(m, service_name);
assert_se(service_unit);
service = SERVICE(service_unit);
return SERVICE(service_unit);
}
static void check_states(Manager *m, Path *path, Service *service, PathState path_state, ServiceState service_state) {
usec_t ts;
usec_t timeout = 2 * USEC_PER_SEC;
assert_se(m);
assert_se(service);
ts = now(CLOCK_MONOTONIC);
/* We process events until the service related to the path has been successfully started */
while (service->result != SERVICE_SUCCESS || service->state != SERVICE_START) {
while (path->result != PATH_SUCCESS || service->result != SERVICE_SUCCESS ||
path->state != path_state || service->state != service_state) {
usec_t n;
int r;
@ -90,119 +96,216 @@ static void check_stop_unlink(Manager *m, Unit *unit, const char *test_path, con
assert_se(r >= 0);
printf("%s: state = %s; result = %s \n",
service_unit->id,
UNIT(path)->id,
path_state_to_string(path->state),
path_result_to_string(path->result));
printf("%s: state = %s; result = %s \n",
UNIT(service)->id,
service_state_to_string(service->state),
service_result_to_string(service->result));
/* But we timeout if the service has not been started in the allocated time */
n = now(CLOCK_MONOTONIC);
if (ts + timeout < n) {
log_error("Test timeout when testing %s", unit->id);
log_error("Test timeout when testing %s", UNIT(path)->id);
exit(EXIT_FAILURE);
}
}
assert_se(unit_stop(unit) >= 0);
(void) rm_rf(test_path, REMOVE_ROOT|REMOVE_PHYSICAL);
}
static void test_path_exists(Manager *m) {
const char *test_path = "/tmp/test-path_exists";
Unit *unit = NULL;
Path *path = NULL;
Service *service = NULL;
assert_se(m);
assert_se(manager_load_startable_unit_or_warn(m, "path-exists.path", NULL, &unit) >= 0);
path = PATH(unit);
service = service_for_path(m, path, NULL);
assert_se(unit_start(unit) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(touch(test_path) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
check_stop_unlink(m, unit, test_path, NULL);
/* Service restarts if file still exists */
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
assert_se(rm_rf(test_path, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(unit_stop(unit) >= 0);
}
static void test_path_existsglob(Manager *m) {
const char *test_path = "/tmp/test-path_existsglobFOOBAR";
Unit *unit = NULL;
Path *path = NULL;
Service *service = NULL;
assert_se(m);
assert_se(manager_load_startable_unit_or_warn(m, "path-existsglob.path", NULL, &unit) >= 0);
path = PATH(unit);
service = service_for_path(m, path, NULL);
assert_se(unit_start(unit) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(touch(test_path) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
check_stop_unlink(m, unit, test_path, NULL);
/* Service restarts if file still exists */
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
assert_se(rm_rf(test_path, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(unit_stop(unit) >= 0);
}
static void test_path_changed(Manager *m) {
const char *test_path = "/tmp/test-path_changed";
FILE *f;
Unit *unit = NULL;
Path *path = NULL;
Service *service = NULL;
assert_se(m);
assert_se(touch(test_path) >= 0);
assert_se(manager_load_startable_unit_or_warn(m, "path-changed.path", NULL, &unit) >= 0);
path = PATH(unit);
service = service_for_path(m, path, NULL);
assert_se(unit_start(unit) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(touch(test_path) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
/* Service does not restart if file still exists */
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
f = fopen(test_path, "w");
assert_se(f);
fclose(f);
check_stop_unlink(m, unit, test_path, NULL);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
(void) rm_rf(test_path, REMOVE_ROOT|REMOVE_PHYSICAL);
assert_se(unit_stop(unit) >= 0);
}
static void test_path_modified(Manager *m) {
_cleanup_fclose_ FILE *f = NULL;
const char *test_path = "/tmp/test-path_modified";
Unit *unit = NULL;
Path *path = NULL;
Service *service = NULL;
assert_se(m);
assert_se(touch(test_path) >= 0);
assert_se(manager_load_startable_unit_or_warn(m, "path-modified.path", NULL, &unit) >= 0);
path = PATH(unit);
service = service_for_path(m, path, NULL);
assert_se(unit_start(unit) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(touch(test_path) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
/* Service does not restart if file still exists */
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
f = fopen(test_path, "w");
assert_se(f);
fputs("test", f);
check_stop_unlink(m, unit, test_path, NULL);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
(void) rm_rf(test_path, REMOVE_ROOT|REMOVE_PHYSICAL);
assert_se(unit_stop(unit) >= 0);
}
static void test_path_unit(Manager *m) {
const char *test_path = "/tmp/test-path_unit";
Unit *unit = NULL;
Path *path = NULL;
Service *service = NULL;
assert_se(m);
assert_se(manager_load_startable_unit_or_warn(m, "path-unit.path", NULL, &unit) >= 0);
path = PATH(unit);
service = service_for_path(m, path, "path-mycustomunit.service");
assert_se(unit_start(unit) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(touch(test_path) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
check_stop_unlink(m, unit, test_path, "path-mycustomunit.service");
assert_se(rm_rf(test_path, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(unit_stop(unit) >= 0);
}
static void test_path_directorynotempty(Manager *m) {
const char *test_path = "/tmp/test-path_directorynotempty/";
Unit *unit = NULL;
Path *path = NULL;
Service *service = NULL;
assert_se(m);
assert_se(manager_load_startable_unit_or_warn(m, "path-directorynotempty.path", NULL, &unit) >= 0);
path = PATH(unit);
service = service_for_path(m, path, NULL);
assert_se(access(test_path, F_OK) < 0);
assert_se(manager_load_startable_unit_or_warn(m, "path-directorynotempty.path", NULL, &unit) >= 0);
assert_se(unit_start(unit) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
/* MakeDirectory default to no */
assert_se(access(test_path, F_OK) < 0);
assert_se(mkdir_p(test_path, 0755) >= 0);
assert_se(touch(strjoina(test_path, "test_file")) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
check_stop_unlink(m, unit, test_path, NULL);
/* Service restarts if directory is still not empty */
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_RUNNING, SERVICE_RUNNING);
assert_se(rm_rf(test_path, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
assert_se(unit_stop(UNIT(service)) >= 0);
check_states(m, path, service, PATH_WAITING, SERVICE_DEAD);
assert_se(unit_stop(unit) >= 0);
}
static void test_path_makedirectory_directorymode(Manager *m) {
@ -212,9 +315,10 @@ static void test_path_makedirectory_directorymode(Manager *m) {
assert_se(m);
assert_se(manager_load_startable_unit_or_warn(m, "path-makedirectory.path", NULL, &unit) >= 0);
assert_se(access(test_path, F_OK) < 0);
assert_se(manager_load_startable_unit_or_warn(m, "path-makedirectory.path", NULL, &unit) >= 0);
assert_se(unit_start(unit) >= 0);
/* Check if the directory has been created */

View File

@ -82,7 +82,10 @@ static int run(int argc, char *argv[]) {
}
log_debug("version %s", GIT_VERSION);
mac_selinux_init();
r = mac_selinux_init();
if (r < 0)
return r;
action = argv[1];
devpath = argv[2];

View File

@ -1,3 +0,0 @@
[NetDev]
Kind=netdevsim
Name=netdevsim99

View File

@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
Type=oneshot
Type=simple
RemainAfterExit=true

View File

@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
Type=oneshot
Type=simple
RemainAfterExit=true

View File

@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
Type=oneshot
Type=simple
RemainAfterExit=true

View File

@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
Type=oneshot
Type=simple
RemainAfterExit=true

View File

@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
Type=oneshot
Type=simple
RemainAfterExit=true

View File

@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
Type=oneshot
Type=simple
RemainAfterExit=true

View File

@ -1,6 +1,7 @@
[Unit]
Description=Service Test Path Unit=
Description=Service Test Path Unit
[Service]
ExecStart=/bin/true
Type=oneshot
Type=simple
RemainAfterExit=true