New upstream version 248.1

This commit is contained in:
Michael Biebl 2021-05-07 00:35:20 +02:00
parent 3a6ce6777f
commit 5b5a102a31
196 changed files with 1478 additions and 841 deletions

View File

@ -42,6 +42,7 @@ BuildPackages=
python python
python-lxml python-lxml
qrencode qrencode
rsync
xz xz
zstd zstd

View File

@ -130,7 +130,7 @@ names for them in UIs.
discovered Windows installation might have the identifier `auto-windows` or discovered Windows installation might have the identifier `auto-windows` or
`auto-windows-10` or so.). `auto-windows-10` or so.).
4. Similar, boot menu entries referring to Apple MacOS X installations should 4. Similar, boot menu entries referring to Apple macOS installations should
use the identifier `osx` or one that is prefixed with `osx-`. If such an use the identifier `osx` or one that is prefixed with `osx-`. If such an
entry is automatically discovered by the boot loader use `auto-osx` as entry is automatically discovered by the boot loader use `auto-osx` as
identifier, or `auto-osx-` as prefix for the identifier, see above. identifier, or `auto-osx-` as prefix for the identifier, see above.

View File

@ -208,7 +208,7 @@ On EFI, any such images shall be added to the list of valid boot entries.
Note that these configurations snippets do not need to be the only configuration source for a boot loader. It may extend this list of entries with additional items from other configuration files (for example its own native configuration files) or automatically detected other entries without explicit configuration. Note that these configurations snippets do not need to be the only configuration source for a boot loader. It may extend this list of entries with additional items from other configuration files (for example its own native configuration files) or automatically detected other entries without explicit configuration.
To make this explicitly clear: this specification is designed with "free" operating systems in mind, starting Windows or MacOS is out of focus with these configuration snippets, use boot-loader specific solutions for that. In the text above, if we say "OS" we hence imply "free", i.e. primarily Linux (though this could be easily be extended to the BSDs and whatnot). To make this explicitly clear: this specification is designed with "free" operating systems in mind, starting Windows or macOS is out of focus with these configuration snippets, use boot-loader specific solutions for that. In the text above, if we say "OS" we hence imply "free", i.e. primarily Linux (though this could be easily be extended to the BSDs and whatnot).
Note that all paths used in the configuration snippets use a Unix-style "/" as path separator. This needs to be converted to an EFI-style "\" separator in EFI boot loaders. Note that all paths used in the configuration snippets use a Unix-style "/" as path separator. This needs to be converted to an EFI-style "\" separator in EFI boot loaders.

View File

@ -35,7 +35,7 @@
<citerefentry><refentrytitle>systemd-coredump</refentrytitle><manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>systemd-coredump</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
a handler for core dumps invoked by the kernel. Whether <command>systemd-coredump</command> is used a handler for core dumps invoked by the kernel. Whether <command>systemd-coredump</command> is used
is determined by the kernel's is determined by the kernel's
<varname>kernel.core_pattern</varname> <citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry> <varname>kernel.core_pattern</varname> <citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>
setting. See setting. See
<citerefentry><refentrytitle>systemd-coredump</refentrytitle><manvolnum>8</manvolnum></citerefentry> <citerefentry><refentrytitle>systemd-coredump</refentrytitle><manvolnum>8</manvolnum></citerefentry>
and and
@ -86,7 +86,9 @@
<listitem><para>The maximum size in bytes of a core <listitem><para>The maximum size in bytes of a core
which will be processed. Core dumps exceeding this size which will be processed. Core dumps exceeding this size
may be stored, but the backtrace will not be generated. may be stored, but the backtrace will not be generated.
</para> Like other sizes in this same config file, the usual
suffixes to the base of 1024 are allowed (B, K, M,
G, T, P, and E.)</para>
<para>Setting <varname>Storage=none</varname> and <varname>ProcessSizeMax=0</varname> <para>Setting <varname>Storage=none</varname> and <varname>ProcessSizeMax=0</varname>
disables all coredump handling except for a log entry.</para> disables all coredump handling except for a log entry.</para>
@ -98,15 +100,18 @@
<term><varname>JournalSizeMax=</varname></term> <term><varname>JournalSizeMax=</varname></term>
<listitem><para>The maximum (uncompressed) size in bytes of a <listitem><para>The maximum (uncompressed) size in bytes of a
core to be saved.</para></listitem> core to be saved. Unit suffixes are allowed just as in
<option>ProcessSizeMax=</option></para></listitem>.
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>MaxUse=</varname></term> <term><varname>MaxUse=</varname></term>
<term><varname>KeepFree=</varname></term> <term><varname>KeepFree=</varname></term>
<listitem><para>Enforce limits on the disk space taken up by <listitem><para>Enforce limits on the disk space, specified
externally stored core dumps. <option>MaxUse=</option> makes in bytes, taken up by externally stored core dumps.
Unit suffixes are allowed just as in <option>ProcessSizeMax=</option>.
<option>MaxUse=</option> makes
sure that old core dumps are removed as soon as the total disk sure that old core dumps are removed as soon as the total disk
space taken up by core dumps grows beyond this limit (defaults space taken up by core dumps grows beyond this limit (defaults
to 10% of the total disk size). <option>KeepFree=</option> to 10% of the total disk size). <option>KeepFree=</option>

View File

@ -846,6 +846,10 @@
<title>Exit status</title> <title>Exit status</title>
<para>On success, 0 is returned, a non-zero failure code otherwise.</para> <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
<para>When a command is invoked with <command>with</command>, the exit status of the child is
propagated. Effectively, <command>homectl</command> will exit without error if the command is
successfully invoked <emphasis>and</emphasis> finishes successfully.</para>
</refsect1> </refsect1>
<xi:include href="common-variables.xml" /> <xi:include href="common-variables.xml" />

View File

@ -184,17 +184,20 @@ html = custom_target(
depends : html_pages, depends : html_pages,
command : ['echo']) command : ['echo'])
run_target( rsync = find_program('rsync', required : false)
'doc-sync', if rsync.found()
depends : man_pages + html_pages, run_target(
command : ['rsync', '-rlv', 'doc-sync',
'--delete-excluded', depends : man_pages + html_pages,
'--include=man', command : [rsync, '-rlv',
'--include=*.html', '--delete-excluded',
'--exclude=*', '--include=man',
'--omit-dir-times', '--include=*.html',
meson.current_build_dir(), '--exclude=*',
get_option('www-target')]) '--omit-dir-times',
meson.current_build_dir(),
get_option('www-target')])
endif
############################################################ ############################################################

View File

@ -40,7 +40,7 @@ node /org/freedesktop/portable1 {
methods: methods:
GetImage(in s image, GetImage(in s image,
out o object); out o object);
ListImages(out a(ssbtttso) UNNAMED); ListImages(out a(ssbtttso) images);
GetImageOSRelease(in s image, GetImageOSRelease(in s image,
out a{ss} os_release); out a{ss} os_release);
GetImageMetadata(in s image, GetImageMetadata(in s image,
@ -249,12 +249,12 @@ node /org/freedesktop/portable1 {
node /org/freedesktop/portable1 { node /org/freedesktop/portable1 {
interface org.freedesktop.portable1.Image { interface org.freedesktop.portable1.Image {
methods: methods:
GetOSRelease(out a{ss} UNNAMED); GetOSRelease(out a{ss} os_release);
GetMetadata(in as matches, GetMetadata(in as matches,
out s image, out s image,
out ay os_release, out ay os_release,
out a{say} units); out a{say} units);
GetState(out s UNNAMED); GetState(out s state);
Attach(in as matches, Attach(in as matches,
in s profile, in s profile,
in b runtime, in b runtime,

View File

@ -65,8 +65,8 @@
union type:</para> union type:</para>
<programlisting>typedef union sd_id128 { <programlisting>typedef union sd_id128 {
uint8_t bytes[16]; uint8_t bytes[16];
uint64_t qwords[2]; uint64_t qwords[2];
} sd_id128_t;</programlisting> } sd_id128_t;</programlisting>
<para>This union type allows accessing the 128-bit ID as 16 <para>This union type allows accessing the 128-bit ID as 16
@ -95,7 +95,7 @@
#define SD_MESSAGE_COREDUMP_STR SD_ID128_MAKE_STR(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1) #define SD_MESSAGE_COREDUMP_STR SD_ID128_MAKE_STR(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)
int main(int argc, char **argv) { int main(int argc, char **argv) {
puts("Match for coredumps: MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR); puts("Match for coredumps: MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR);
} }
</programlisting> </programlisting>
@ -104,7 +104,7 @@ int main(int argc, char **argv) {
following example code will output the string following example code will output the string
"fc2e22bc6ee647b6b90729ab34a250b1":</para> "fc2e22bc6ee647b6b90729ab34a250b1":</para>
<programlisting>int main(int argc, char *argv[]) { <programlisting>int main(int argc, char *argv[]) {
puts("Match for coredumps: %s", SD_ID128_CONST_STR(SD_MESSAGE_COREDUMP)); puts("Match for coredumps: %s", SD_ID128_CONST_STR(SD_MESSAGE_COREDUMP));
}</programlisting> }</programlisting>
<para><constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> may <para><constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> may
@ -113,10 +113,10 @@ int main(int argc, char **argv) {
format string, as shown in the following example:</para> format string, as shown in the following example:</para>
<programlisting>int main(int argc, char *argv[]) { <programlisting>int main(int argc, char *argv[]) {
sd_id128_t id; sd_id128_t id;
id = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07); id = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07);
printf("The ID encoded in this C file is " SD_ID128_FORMAT_STR ".\n", SD_ID128_FORMAT_VAL(id)); printf("The ID encoded in this C file is " SD_ID128_FORMAT_STR ".\n", SD_ID128_FORMAT_VAL(id));
return 0; return 0;
}</programlisting> }</programlisting>
<para><constant>SD_ID128_UUID_FORMAT_STR</constant> is similar to <para><constant>SD_ID128_UUID_FORMAT_STR</constant> is similar to
@ -127,20 +127,20 @@ int main(int argc, char **argv) {
<para>Use <function>sd_id128_equal()</function> to compare two 128-bit IDs:</para> <para>Use <function>sd_id128_equal()</function> to compare two 128-bit IDs:</para>
<programlisting>int main(int argc, char *argv[]) { <programlisting>int main(int argc, char *argv[]) {
sd_id128_t a, b, c; sd_id128_t a, b, c;
a = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07); a = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07);
b = SD_ID128_MAKE(f2,28,88,9c,5f,09,44,15,9d,d7,04,77,58,cb,e7,3e); b = SD_ID128_MAKE(f2,28,88,9c,5f,09,44,15,9d,d7,04,77,58,cb,e7,3e);
c = a; c = a;
assert(sd_id128_equal(a, c)); assert(sd_id128_equal(a, c));
assert(!sd_id128_equal(a, b)); assert(!sd_id128_equal(a, b));
return 0; return 0;
}</programlisting> }</programlisting>
<para>Use <function>sd_id128_is_null()</function> to check if an 128bit ID consists of only <para>Use <function>sd_id128_is_null()</function> to check if an 128bit ID consists of only
<constant>NUL</constant> bytes:</para> <constant>NUL</constant> bytes:</para>
<programlisting>int main(int argc, char *argv[]) { <programlisting>int main(int argc, char *argv[]) {
assert(sd_id128_is_null(SD_ID128_NULL)); assert(sd_id128_is_null(SD_ID128_NULL));
}</programlisting> }</programlisting>
<para>Note that new, randomized IDs may be generated with <para>Note that new, randomized IDs may be generated with

View File

@ -115,7 +115,7 @@
__attribute__((cleanup(sd_login_monitor_unrefp))) sd_login_monitor *m = NULL; __attribute__((cleanup(sd_login_monitor_unrefp))) sd_login_monitor *m = NULL;
int r; int r;
r = sd_login_monitor_default(&amp;m); r = sd_login_monitor_new(NULL, &amp;m);
if (r &lt; 0) if (r &lt; 0)
fprintf(stderr, "Failed to allocate login monitor object: %s\n", strerror(-r)); fprintf(stderr, "Failed to allocate login monitor object: %s\n", strerror(-r));

View File

@ -51,7 +51,7 @@
<listitem><para>The Microsoft Windows EFI boot manager, if installed</para></listitem> <listitem><para>The Microsoft Windows EFI boot manager, if installed</para></listitem>
<listitem><para>The Apple MacOS X boot manager, if installed</para></listitem> <listitem><para>The Apple macOS boot manager, if installed</para></listitem>
<listitem><para>The EFI Shell binary, if installed</para></listitem> <listitem><para>The EFI Shell binary, if installed</para></listitem>
@ -193,7 +193,7 @@
<varlistentry> <varlistentry>
<term><keycap>a</keycap></term> <term><keycap>a</keycap></term>
<listitem><para>OS X</para></listitem> <listitem><para>macOS</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -215,7 +215,7 @@
<row> <row>
<entry>8</entry> <entry>8</entry>
<entry><citerefentry><refentrytitle>sd-boot</refentrytitle><manvolnum>8</manvolnum></citerefentry> measures the kernel command line in this PCR.</entry> <entry><citerefentry><refentrytitle>sd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry> measures the kernel command line in this PCR.</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>

View File

@ -17,22 +17,29 @@
<refnamediv> <refnamediv>
<refname>systemd-cryptsetup@.service</refname> <refname>systemd-cryptsetup@.service</refname>
<!-- <refname>system-systemd\x2dcryptsetup.slice</refname> — this causes meson to go haywire because it
thinks this is a (windows) path. Let's just not create the alias for this name, and only include it
in the synopsis. -->
<refname>systemd-cryptsetup</refname> <refname>systemd-cryptsetup</refname>
<refpurpose>Full disk decryption logic</refpurpose> <refpurpose>Full disk decryption logic</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<para><filename>systemd-cryptsetup@.service</filename></para> <para><filename>systemd-cryptsetup@.service</filename></para>
<para><filename>system-systemd\x2dcryptsetup.slice</filename></para>
<para><filename>/usr/lib/systemd/systemd-cryptsetup</filename></para> <para><filename>/usr/lib/systemd/systemd-cryptsetup</filename></para>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para><filename>systemd-cryptsetup@.service</filename> is a <para><filename>systemd-cryptsetup@.service</filename> is a service responsible for setting up encrypted
service responsible for setting up encrypted block devices. It is block devices. It is instantiated for each device that requires decryption for access.</para>
instantiated for each device that requires decryption for
access.</para> <para><filename>systemd-cryptsetup@.service</filename> instances are part of the
<filename>system-systemd\x2dcryptsetup.slice</filename> slice, which is destroyed only very late in the
shutdown procedure. This allows the encrypted devices to remain up until filesystems have been unmounted.
</para>
<para><filename>systemd-cryptsetup@.service</filename> will ask <para><filename>systemd-cryptsetup@.service</filename> will ask
for hard disk passwords via the <ulink for hard disk passwords via the <ulink

View File

@ -34,7 +34,7 @@
<citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, and provides the implementation for <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, and provides the implementation for
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
<command>pull-raw</command>, <command>pull-tar</command>, <command>import-raw</command>, <command>pull-raw</command>, <command>pull-tar</command>, <command>import-raw</command>,
<command>import-tar</command>, <command>export-raw</command>, and <command>export-tar</command> commands.</para> <command>import-tar</command>, <command>import-fs</command>, <command>export-raw</command>, and <command>export-tar</command> commands.</para>
<para>See <para>See
<citerefentry><refentrytitle>org.freedesktop.import1</refentrytitle><manvolnum>5</manvolnum></citerefentry> <citerefentry><refentrytitle>org.freedesktop.import1</refentrytitle><manvolnum>5</manvolnum></citerefentry>

View File

@ -48,10 +48,9 @@
<title>Setup Information</title> <title>Setup Information</title>
<para>The system must be running systemd with a full unified cgroup hierarchy for the expected cgroups-v2 features. <para>The system must be running systemd with a full unified cgroup hierarchy for the expected cgroups-v2 features.
Furthermore, resource accounting must be turned on for all units monitored by <command>systemd-oomd</command>. Furthermore, memory accounting must be turned on for all units monitored by <command>systemd-oomd</command>.
The easiest way to turn on resource accounting is by ensuring the values for <varname>DefaultCPUAccounting</varname>, The easiest way to turn on memory accounting is by ensuring the value for <varname>DefaultMemoryAccounting=</varname>
<varname>DefaultIOAccounting</varname>, <varname>DefaultMemoryAccounting</varname>, and is set to <constant>true</constant> in
<varname>DefaultTasksAccounting</varname> are set to <constant>true</constant> in
<citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
<para>You will need a kernel compiled with PSI support. This is available in Linux 4.20 and above.</para> <para>You will need a kernel compiled with PSI support. This is available in Linux 4.20 and above.</para>

View File

@ -263,16 +263,18 @@
<refsect1> <refsect1>
<title>Exit status</title> <title>Exit status</title>
<para>On success, 0 is returned. If the configuration was syntactically invalid (syntax errors, <para>On success, 0 is returned. If the configuration was syntactically invalid (syntax errors, missing
missing arguments, …), so some lines had to be ignored, but no other errors occurred, arguments, …), so some lines had to be ignored, but no other errors occurred, <constant>65</constant> is
<constant>65</constant> is returned (<constant>EX_DATAERR</constant> from returned (<constant>EX_DATAERR</constant> from <filename>/usr/include/sysexits.h</filename>). If the
<filename>/usr/include/sysexits.h</filename>). If the configuration was syntactically valid, but configuration was syntactically valid, but could not be executed (lack of permissions, creation of files
could not be executed (lack of permissions, creation of files in missing directories, invalid in missing directories, invalid contents when writing to <filename>/sys/</filename> values, …),
contents when writing to <filename>/sys/</filename> values, …), <constant>73</constant> is <constant>73</constant> is returned (<constant>EX_CANTCREAT</constant> from
returned (<constant>EX_CANTCREAT</constant> from <filename>/usr/include/sysexits.h</filename>). <filename>/usr/include/sysexits.h</filename>). Otherwise, <constant>1</constant> is returned
Otherwise, <constant>1</constant> is returned (<constant>EXIT_FAILURE</constant> from (<constant>EXIT_FAILURE</constant> from <filename>/usr/include/stdlib.h</filename>).</para>
<filename>/usr/include/stdlib.h</filename>).
</para> <para>Note: when creating items, if the target already exists, but is of the wrong type or otherwise does
not match the requested state, and forced operation has not been requested with <literal>+</literal>,
a message is emitted, but the failure is otherwise ignored.</para>
</refsect1> </refsect1>
<refsect1> <refsect1>

View File

@ -88,8 +88,8 @@
<term><option>-e</option></term> <term><option>-e</option></term>
<term><option>--exec-delay=</option></term> <term><option>--exec-delay=</option></term>
<listitem> <listitem>
<para>Delay the execution of <varname>RUN</varname> <para>Delay the execution of each <varname>RUN{<replaceable>program</replaceable>}</varname>
instructions by the given number of seconds. This option parameter by the given number of seconds. This option
might be useful when debugging system crashes during might be useful when debugging system crashes during
coldplug caused by loading non-working kernel coldplug caused by loading non-working kernel
modules.</para> modules.</para>
@ -160,7 +160,7 @@
<term><varname>udev.exec_delay=</varname></term> <term><varname>udev.exec_delay=</varname></term>
<term><varname>rd.udev.exec_delay=</varname></term> <term><varname>rd.udev.exec_delay=</varname></term>
<listitem> <listitem>
<para>Delay the execution of <varname>RUN</varname> instructions by the given <para>Delay the execution of each <varname>RUN{<replaceable>program</replaceable>}</varname> parameter by the given
number of seconds. This option might be useful when number of seconds. This option might be useful when
debugging system crashes during coldplug caused by loading debugging system crashes during coldplug caused by loading
non-working kernel modules.</para> non-working kernel modules.</para>

View File

@ -2651,7 +2651,8 @@ StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy
this option to configure the logging system to drop log messages of a specific service above the specified this option to configure the logging system to drop log messages of a specific service above the specified
level. For example, set <varname>LogLevelMax=</varname><option>info</option> in order to turn off debug logging level. For example, set <varname>LogLevelMax=</varname><option>info</option> in order to turn off debug logging
of a particularly chatty unit. Note that the configured level is applied to any log messages written by any of a particularly chatty unit. Note that the configured level is applied to any log messages written by any
of the processes belonging to this unit, sent via any supported logging protocol. The filtering is applied of the processes belonging to this unit, as well as any log messages written by the system manager process
(PID 1) in reference to this unit, sent via any supported logging protocol. The filtering is applied
early in the logging pipeline, before any kind of further processing is done. Moreover, messages which pass early in the logging pipeline, before any kind of further processing is done. Moreover, messages which pass
through this filter successfully might still be dropped by filters applied at a later stage in the logging through this filter successfully might still be dropped by filters applied at a later stage in the logging
subsystem. For example, <varname>MaxLevelStore=</varname> configured in subsystem. For example, <varname>MaxLevelStore=</varname> configured in

View File

@ -58,8 +58,8 @@ c+ /dev/char-device-to-[re]create mode user group - major
b /dev/block-device-to-create mode user group - major:minor b /dev/block-device-to-create mode user group - major:minor
b+ /dev/block-device-to-[re]create mode user group - major:minor b+ /dev/block-device-to-[re]create mode user group - major:minor
C /target/to/create - - - - /source/to/copy C /target/to/create - - - - /source/to/copy
x /path-or-glob/to/ignore - - - - - x /path-or-glob/to/ignore/recursively - - - - -
X /path-or-glob/to/ignore/recursively - - - - - X /path-or-glob/to/ignore - - - - -
r /empty/dir/to/remove - - - - - r /empty/dir/to/remove - - - - -
R /dir/to/remove/recursively - - - - - R /dir/to/remove/recursively - - - - -
z /path-or-glob/to/adjust/mode mode user group - - z /path-or-glob/to/adjust/mode mode user group - -

View File

@ -63,8 +63,8 @@
<term><varname>exec_delay=</varname></term> <term><varname>exec_delay=</varname></term>
<listitem> <listitem>
<para>An integer. Delay the execution of <varname>RUN</varname> <para>An integer. Delay the execution of each <varname>RUN{<replaceable>program</replaceable>}</varname>
instructions by the given number of seconds. This option parameter by the given number of seconds. This option
might be useful when debugging system crashes during might be useful when debugging system crashes during
coldplug caused by loading non-working kernel coldplug caused by loading non-working kernel
modules.</para> modules.</para>

View File

@ -710,7 +710,7 @@ if time_epoch == -1
if time_epoch == '' and git.found() and run_command('test', '-e', '.git').returncode() == 0 if time_epoch == '' and git.found() and run_command('test', '-e', '.git').returncode() == 0
# If we're in a git repository, use the creation time of the latest git tag. # If we're in a git repository, use the creation time of the latest git tag.
latest_tag = run_command('git', 'describe', '--abbrev=0', '--tags').stdout().strip() latest_tag = run_command('git', 'describe', '--abbrev=0', '--tags').stdout().strip()
time_epoch = run_command('git', 'log', '-1', '--format=%at', latest_tag).stdout() time_epoch = run_command('git', 'log', '--no-show-signature', '-1', '--format=%at', latest_tag).stdout()
endif endif
if time_epoch == '' if time_epoch == ''
NEWS = files('NEWS') NEWS = files('NEWS')
@ -797,7 +797,7 @@ if not meson.is_cross_build()
id = id_result.stdout().to_int() id = id_result.stdout().to_int()
if id != 65534 if id != 65534
warning('\n' + warning('\n' +
'The local group with the configured group name "@0@" of the nobody group does not have UID 65534 (it has @1@).\n'.format(nobody_group, id) + 'The local group with the configured group name "@0@" of the nobody group does not have GID 65534 (it has @1@).\n'.format(nobody_group, id) +
'Your build will result in an group table setup that is incompatible with the local system.') 'Your build will result in an group table setup that is incompatible with the local system.')
endif endif
endif endif

View File

@ -30,7 +30,7 @@ __get_machines() {
} }
_machinectl() { _machinectl() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local i verb comps local i verb comps
local -A OPTS=( local -A OPTS=(

View File

@ -30,7 +30,7 @@ __get_links() {
_networkctl() { _networkctl() {
local i verb comps local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local -A OPTS=( local -A OPTS=(
[STANDALONE]='-a --all -h --help --version --no-pager --no-legend -s --stats -l --full' [STANDALONE]='-a --all -h --help --version --no-pager --no-legend -s --stats -l --full'
[ARG]='-n --lines' [ARG]='-n --lines'

View File

@ -46,7 +46,7 @@ __get_syscall_sets() {
_systemd_analyze() { _systemd_analyze() {
local i verb comps mode local i verb comps mode
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local -A OPTS=( local -A OPTS=(
[STANDALONE]='-h --help --version --system --user --global --order --require --no-pager [STANDALONE]='-h --help --version --system --user --global --order --require --no-pager

View File

@ -25,7 +25,7 @@ __contains_word() {
} }
_systemd_cat() { _systemd_cat() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local i verb comps local i verb comps
local -A OPTS=( local -A OPTS=(

View File

@ -37,7 +37,7 @@ __get_units_have_cgroup() {
} }
_systemd_cgls() { _systemd_cgls() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local i verb comps local i verb comps
local -A OPTS=( local -A OPTS=(

View File

@ -29,7 +29,7 @@ __get_machines() {
} }
_systemd_cgtop() { _systemd_cgtop() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local comps local comps
local -A OPTS=( local -A OPTS=(

View File

@ -24,7 +24,7 @@ __contains_word() {
} }
_systemd-delta() { _systemd-delta() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local comps local comps
local -A OPTS=( local -A OPTS=(

View File

@ -24,7 +24,7 @@ __contains_word() {
} }
_systemd_detect_virt() { _systemd_detect_virt() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local i verb comps local i verb comps
local -A OPTS=( local -A OPTS=(

View File

@ -26,7 +26,7 @@ __contains_word () {
_systemd_id128() { _systemd_id128() {
local i verb comps local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local -A OPTS=( local -A OPTS=(
[STANDALONE]='-h --help --version -p --pretty' [STANDALONE]='-h --help --version -p --pretty'
[ARG]='-a --app-specific' [ARG]='-a --app-specific'

View File

@ -58,7 +58,7 @@ __get_rlimit() {
} }
_systemd_nspawn() { _systemd_nspawn() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local i verb comps local i verb comps
local -A OPTS=( local -A OPTS=(

View File

@ -30,7 +30,7 @@ __get_names() {
_systemd_path() { _systemd_path() {
local comps local comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local -A OPTS=( local -A OPTS=(
[STANDALONE]='-h --help --version' [STANDALONE]='-h --help --version'
[ARG]='--suffix' [ARG]='--suffix'

View File

@ -39,7 +39,7 @@ _localectl_set-x11-keymap() {
local -a _file _layout _model _variant _options local -a _file _layout _model _variant _options
local _xorg_lst local _xorg_lst
_xorg_lst=${"$($commands[pkg-config] xkeyboard-config --variable=xkb_base)"} _xorg_lst=${"$($commands[pkg-config] xkeyboard-config --variable=xkb_base)"}
_file=( ${(ps:\n\!:)"$(<$_xorg_lst/rules/xorg.lst)"} ) _file=( ${(ps:\n\!:)"$(<$_xorg_lst/rules/base.lst)"} )
_layout=( ${${${(M)${(f)_file[2]}:# *}# }%% *} ) _layout=( ${${${(M)${(f)_file[2]}:# *}# }%% *} )
_model=( ${${${(M)${(f)_file[1]}:# *}# }%% *} ) _model=( ${${${(M)${(f)_file[1]}:# *}# }%% *} )
_variant=( ${${${(M)${(f)_file[3]}:# *}# }%% *} ) _variant=( ${${${(M)${(f)_file[3]}:# *}# }%% *} )

View File

@ -151,7 +151,7 @@ static int exec_process(const char *name, char **argv, char **env, int start_fd,
envp[n_env++] = k; envp[n_env++] = k;
} else { } else {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
const char *n; const char *n;
p = strjoin(*s, "="); p = strjoin(*s, "=");
@ -421,7 +421,7 @@ static int parse_argv(int argc, char *argv[]) {
break; break;
case ARG_FDNAME: { case ARG_FDNAME: {
_cleanup_strv_free_ char **names; _cleanup_strv_free_ char **names = NULL;
char **s; char **s;
names = strv_split(optarg, ":"); names = strv_split(optarg, ":");
@ -430,7 +430,7 @@ static int parse_argv(int argc, char *argv[]) {
STRV_FOREACH(s, names) STRV_FOREACH(s, names)
if (!fdname_is_valid(*s)) { if (!fdname_is_valid(*s)) {
_cleanup_free_ char *esc; _cleanup_free_ char *esc = NULL;
esc = cescape(*s); esc = cescape(*s);
log_warning("File descriptor name \"%s\" is not valid.", esc); log_warning("File descriptor name \"%s\" is not valid.", esc);

View File

@ -350,7 +350,7 @@ int cache_efi_options_variable(void) {
* (NB: For testing purposes, we still check the $SYSTEMD_EFI_OPTIONS env var before accessing this * (NB: For testing purposes, we still check the $SYSTEMD_EFI_OPTIONS env var before accessing this
* cache, even when in SecureBoot mode.) */ * cache, even when in SecureBoot mode.) */
if (is_efi_secure_boot()) { if (is_efi_secure_boot()) {
_cleanup_free_ char *k; _cleanup_free_ char *k = NULL;
k = efi_variable_path(EFI_VENDOR_SYSTEMD, "SystemdOptions"); k = efi_variable_path(EFI_VENDOR_SYSTEMD, "SystemdOptions");
if (!k) if (!k)

View File

@ -57,7 +57,7 @@ int fdopen_unlocked(int fd, const char *options, FILE **ret) {
} }
int take_fdopen_unlocked(int *fd, const char *options, FILE **ret) { int take_fdopen_unlocked(int *fd, const char *options, FILE **ret) {
int r; int r;
assert(fd); assert(fd);
@ -1003,7 +1003,6 @@ int chase_symlinks_and_fopen_unlocked(
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
_cleanup_free_ char *final_path = NULL; _cleanup_free_ char *final_path = NULL;
int mode_flags, r; int mode_flags, r;
FILE *f;
assert(path); assert(path);
assert(open_flags); assert(open_flags);
@ -1017,12 +1016,10 @@ int chase_symlinks_and_fopen_unlocked(
if (fd < 0) if (fd < 0)
return fd; return fd;
r = fdopen_unlocked(fd, open_flags, &f); r = take_fdopen_unlocked(&fd, open_flags, ret_file);
if (r < 0) if (r < 0)
return r; return r;
TAKE_FD(fd);
*ret_file = f;
if (ret_path) if (ret_path)
*ret_path = TAKE_PTR(final_path); *ret_path = TAKE_PTR(final_path);
return 0; return 0;

View File

@ -24,6 +24,7 @@
#include "path-util.h" #include "path-util.h"
#include "process-util.h" #include "process-util.h"
#include "random-util.h" #include "random-util.h"
#include "ratelimit.h"
#include "stat-util.h" #include "stat-util.h"
#include "stdio-util.h" #include "stdio-util.h"
#include "string-util.h" #include "string-util.h"
@ -1715,3 +1716,23 @@ do_rename:
return 1; return 1;
} }
int posix_fallocate_loop(int fd, uint64_t offset, uint64_t size) {
RateLimit rl;
int r;
r = posix_fallocate(fd, offset, size); /* returns positive errnos on error */
if (r != EINTR)
return -r; /* Let's return negative errnos, like common in our codebase */
/* On EINTR try a couple of times more, but protect against busy looping
* (not more than 16 times per 10s) */
rl = (RateLimit) { 10 * USEC_PER_SEC, 16 };
while (ratelimit_below(&rl)) {
r = posix_fallocate(fd, offset, size);
if (r != EINTR)
return -r;
}
return -EINTR;
}

View File

@ -146,3 +146,5 @@ int conservative_renameat(int olddirfd, const char *oldpath, int newdirfd, const
static inline int conservative_rename(const char *oldpath, const char *newpath) { static inline int conservative_rename(const char *oldpath, const char *newpath) {
return conservative_renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath); return conservative_renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath);
} }
int posix_fallocate_loop(int fd, uint64_t offset, uint64_t size);

View File

@ -772,7 +772,7 @@ void lookup_paths_log(LookupPaths *p) {
log_debug("Ignoring unit files."); log_debug("Ignoring unit files.");
p->search_path = strv_free(p->search_path); p->search_path = strv_free(p->search_path);
} else { } else {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = strv_join(p->search_path, "\n\t"); t = strv_join(p->search_path, "\n\t");
log_debug("Looking for unit files in (higher priority first):\n\t%s", strna(t)); log_debug("Looking for unit files in (higher priority first):\n\t%s", strna(t));

View File

@ -47,7 +47,7 @@ static int proc_cmdline_extract_first(const char **p, char **ret_word, ProcCmdli
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL;
const char *c; const char *c;
r = extract_first_word(&q, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX); r = extract_first_word(&q, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX|EXTRACT_RETAIN_ESCAPE);
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) if (r == 0)

View File

@ -52,7 +52,7 @@ static volatile int cached_color_mode = _COLOR_INVALID;
static volatile int cached_underline_enabled = -1; static volatile int cached_underline_enabled = -1;
int chvt(int vt) { int chvt(int vt) {
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
/* Switch to the specified vt number. If the VT is specified <= 0 switch to the VT the kernel log messages go, /* Switch to the specified vt number. If the VT is specified <= 0 switch to the VT the kernel log messages go,
* if that's configured. */ * if that's configured. */
@ -514,7 +514,7 @@ int terminal_vhangup_fd(int fd) {
} }
int terminal_vhangup(const char *name) { int terminal_vhangup(const char *name) {
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK); fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0) if (fd < 0)

View File

@ -1547,7 +1547,7 @@ int time_change_fd(void) {
.it_value.tv_sec = TIME_T_MAX, .it_value.tv_sec = TIME_T_MAX,
}; };
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX)); assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX));

View File

@ -126,7 +126,7 @@ static int acquire_path(void) {
strv_free_and_replace(arg_path, a); strv_free_and_replace(arg_path, a);
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *j; _cleanup_free_ char *j = NULL;
j = strv_join(arg_path, ":"); j = strv_join(arg_path, ":");
log_debug("Using %s as boot loader drop-in search path.", j); log_debug("Using %s as boot loader drop-in search path.", j);

View File

@ -312,7 +312,7 @@ static int status_variables(void) {
} }
static int boot_entry_file_check(const char *root, const char *p) { static int boot_entry_file_check(const char *root, const char *p) {
_cleanup_free_ char *path; _cleanup_free_ char *path = NULL;
path = path_join(root, p); path = path_join(root, p);
if (!path) if (!path)

View File

@ -456,7 +456,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
device_path = DevicePathFromHandle(entry->device); device_path = DevicePathFromHandle(entry->device);
if (device_path) { if (device_path) {
_cleanup_freepool_ CHAR16 *str; _cleanup_freepool_ CHAR16 *str = NULL;
str = DevicePathToStr(device_path); str = DevicePathToStr(device_path);
Print(L"device handle '%s'\n", str); Print(L"device handle '%s'\n", str);

View File

@ -92,7 +92,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
* is non-NULL explicitly.) */ * is non-NULL explicitly.) */
if (efivar_get_raw(LOADER_GUID, L"LoaderImageIdentifier", NULL, NULL) != EFI_SUCCESS && if (efivar_get_raw(LOADER_GUID, L"LoaderImageIdentifier", NULL, NULL) != EFI_SUCCESS &&
loaded_image->FilePath) { loaded_image->FilePath) {
_cleanup_freepool_ CHAR16 *s; _cleanup_freepool_ CHAR16 *s = NULL;
s = DevicePathToStr(loaded_image->FilePath); s = DevicePathToStr(loaded_image->FilePath);
efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0); efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0);
@ -100,7 +100,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* if LoaderFirmwareInfo is not set, let's set it */ /* if LoaderFirmwareInfo is not set, let's set it */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) { if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s; _cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); s = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0);
@ -108,7 +108,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* ditto for LoaderFirmwareType */ /* ditto for LoaderFirmwareType */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) { if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s; _cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff); s = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0);

View File

@ -379,7 +379,7 @@ EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN s
return err; return err;
if (size == 0) { if (size == 0) {
_cleanup_freepool_ EFI_FILE_INFO *info; _cleanup_freepool_ EFI_FILE_INFO *info = NULL;
info = LibFileInfo(handle); info = LibFileInfo(handle);
if (!info) if (!info)

View File

@ -797,7 +797,7 @@ static Set* member_set_free(Set *s) {
DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, member_set_free); DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, member_set_free);
static int on_interface(const char *interface, uint64_t flags, void *userdata) { static int on_interface(const char *interface, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;
@ -828,7 +828,7 @@ static int on_interface(const char *interface, uint64_t flags, void *userdata) {
} }
static int on_method(const char *interface, const char *name, const char *signature, const char *result, uint64_t flags, void *userdata) { static int on_method(const char *interface, const char *name, const char *signature, const char *result, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;
@ -871,7 +871,7 @@ static int on_method(const char *interface, const char *name, const char *signat
} }
static int on_signal(const char *interface, const char *name, const char *signature, uint64_t flags, void *userdata) { static int on_signal(const char *interface, const char *name, const char *signature, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;
@ -910,7 +910,7 @@ static int on_signal(const char *interface, const char *name, const char *signat
} }
static int on_property(const char *interface, const char *name, const char *signature, bool writable, uint64_t flags, void *userdata) { static int on_property(const char *interface, const char *name, const char *signature, bool writable, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;

View File

@ -698,8 +698,7 @@ int bpf_firewall_install(Unit *u) {
if (r < 0) if (r < 0)
return log_unit_error_errno(u, r, "Failed to determine cgroup path: %m"); return log_unit_error_errno(u, r, "Failed to determine cgroup path: %m");
flags = (supported == BPF_FIREWALL_SUPPORTED_WITH_MULTI && flags = supported == BPF_FIREWALL_SUPPORTED_WITH_MULTI ? BPF_F_ALLOW_MULTI : 0;
(u->type == UNIT_SLICE || unit_cgroup_delegate(u))) ? BPF_F_ALLOW_MULTI : 0;
/* Unref the old BPF program (which will implicitly detach it) right before attaching the new program, to /* Unref the old BPF program (which will implicitly detach it) right before attaching the new program, to
* minimize the time window when we don't account for IP traffic. */ * minimize the time window when we don't account for IP traffic. */
@ -707,8 +706,7 @@ int bpf_firewall_install(Unit *u) {
u->ip_bpf_ingress_installed = bpf_program_unref(u->ip_bpf_ingress_installed); u->ip_bpf_ingress_installed = bpf_program_unref(u->ip_bpf_ingress_installed);
if (u->ip_bpf_egress) { if (u->ip_bpf_egress) {
r = bpf_program_cgroup_attach(u->ip_bpf_egress, BPF_CGROUP_INET_EGRESS, path, r = bpf_program_cgroup_attach(u->ip_bpf_egress, BPF_CGROUP_INET_EGRESS, path, flags);
flags | (set_isempty(u->ip_bpf_custom_egress) ? 0 : BPF_F_ALLOW_MULTI));
if (r < 0) if (r < 0)
return log_unit_error_errno(u, r, "Attaching egress BPF program to cgroup %s failed: %m", path); return log_unit_error_errno(u, r, "Attaching egress BPF program to cgroup %s failed: %m", path);
@ -717,8 +715,7 @@ int bpf_firewall_install(Unit *u) {
} }
if (u->ip_bpf_ingress) { if (u->ip_bpf_ingress) {
r = bpf_program_cgroup_attach(u->ip_bpf_ingress, BPF_CGROUP_INET_INGRESS, path, r = bpf_program_cgroup_attach(u->ip_bpf_ingress, BPF_CGROUP_INET_INGRESS, path, flags);
flags | (set_isempty(u->ip_bpf_custom_ingress) ? 0 : BPF_F_ALLOW_MULTI));
if (r < 0) if (r < 0)
return log_unit_error_errno(u, r, "Attaching ingress BPF program to cgroup %s failed: %m", path); return log_unit_error_errno(u, r, "Attaching ingress BPF program to cgroup %s failed: %m", path);

View File

@ -420,7 +420,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
"%sManagedOOMSwap: %s\n" "%sManagedOOMSwap: %s\n"
"%sManagedOOMMemoryPressure: %s\n" "%sManagedOOMMemoryPressure: %s\n"
"%sManagedOOMMemoryPressureLimit: " PERMYRIAD_AS_PERCENT_FORMAT_STR "\n" "%sManagedOOMMemoryPressureLimit: " PERMYRIAD_AS_PERCENT_FORMAT_STR "\n"
"%sManagedOOMPreference: %s%%\n", "%sManagedOOMPreference: %s\n",
prefix, yes_no(c->cpu_accounting), prefix, yes_no(c->cpu_accounting),
prefix, yes_no(c->io_accounting), prefix, yes_no(c->io_accounting),
prefix, yes_no(c->blockio_accounting), prefix, yes_no(c->blockio_accounting),
@ -2786,11 +2786,10 @@ int unit_check_oomd_kill(Unit *u) {
return 0; return 0;
if (n > 0) if (n > 0)
log_struct(LOG_NOTICE, log_unit_struct(u, LOG_NOTICE,
"MESSAGE_ID=" SD_MESSAGE_UNIT_OOMD_KILL_STR, "MESSAGE_ID=" SD_MESSAGE_UNIT_OOMD_KILL_STR,
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), LOG_UNIT_MESSAGE(u, "systemd-oomd killed %"PRIu64" process(es) in this unit.", n));
LOG_UNIT_MESSAGE(u, "systemd-oomd killed %"PRIu64" process(es) in this unit.", n));
return 1; return 1;
} }
@ -2818,11 +2817,10 @@ int unit_check_oom(Unit *u) {
if (!increased) if (!increased)
return 0; return 0;
log_struct(LOG_NOTICE, log_unit_struct(u, LOG_NOTICE,
"MESSAGE_ID=" SD_MESSAGE_UNIT_OUT_OF_MEMORY_STR, "MESSAGE_ID=" SD_MESSAGE_UNIT_OUT_OF_MEMORY_STR,
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), LOG_UNIT_MESSAGE(u, "A process of this unit has been killed by the OOM killer."));
LOG_UNIT_MESSAGE(u, "A process of this unit has been killed by the OOM killer."));
if (UNIT_VTABLE(u)->notify_cgroup_oom) if (UNIT_VTABLE(u)->notify_cgroup_oom)
UNIT_VTABLE(u)->notify_cgroup_oom(u); UNIT_VTABLE(u)->notify_cgroup_oom(u);

View File

@ -1626,7 +1626,7 @@ int bus_exec_context_set_transient_property(
unit_write_settingf(u, flags, name, "RootHash="); unit_write_settingf(u, flags, name, "RootHash=");
} else { } else {
_cleanup_free_ void *p; _cleanup_free_ void *p = NULL;
encoded = hexmem(roothash_decoded, roothash_decoded_size); encoded = hexmem(roothash_decoded, roothash_decoded_size);
if (!encoded) if (!encoded)
@ -1672,7 +1672,7 @@ int bus_exec_context_set_transient_property(
unit_write_settingf(u, flags, name, "RootHashSignature="); unit_write_settingf(u, flags, name, "RootHashSignature=");
} else { } else {
_cleanup_free_ void *p; _cleanup_free_ void *p = NULL;
ssize_t len; ssize_t len;
len = base64mem(roothash_sig_decoded, roothash_sig_decoded_size, &encoded); len = base64mem(roothash_sig_decoded, roothash_sig_decoded_size, &encoded);

View File

@ -96,7 +96,7 @@ static int bus_path_set_transient_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path in %s is not absolute: %s", type_name, path); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path in %s is not absolute: %s", type_name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *k; _cleanup_free_ char *k = NULL;
PathSpec *s; PathSpec *s;
k = strdup(path); k = strdup(path);

View File

@ -4309,24 +4309,23 @@ static int exec_child(
r = find_executable_full(command->path, false, &executable, &executable_fd); r = find_executable_full(command->path, false, &executable, &executable_fd);
if (r < 0) { if (r < 0) {
if (r != -ENOMEM && (command->flags & EXEC_COMMAND_IGNORE_FAILURE)) { if (r != -ENOMEM && (command->flags & EXEC_COMMAND_IGNORE_FAILURE)) {
log_struct_errno(LOG_INFO, r, log_unit_struct_errno(unit, LOG_INFO, r,
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR, "MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
LOG_UNIT_ID(unit), LOG_UNIT_INVOCATION_ID(unit),
LOG_UNIT_INVOCATION_ID(unit), LOG_UNIT_MESSAGE(unit, "Executable %s missing, skipping: %m",
LOG_UNIT_MESSAGE(unit, "Executable %s missing, skipping: %m", command->path),
command->path), "EXECUTABLE=%s", command->path);
"EXECUTABLE=%s", command->path);
return 0; return 0;
} }
*exit_status = EXIT_EXEC; *exit_status = EXIT_EXEC;
return log_struct_errno(LOG_INFO, r,
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR, return log_unit_struct_errno(unit, LOG_INFO, r,
LOG_UNIT_ID(unit), "MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
LOG_UNIT_INVOCATION_ID(unit), LOG_UNIT_INVOCATION_ID(unit),
LOG_UNIT_MESSAGE(unit, "Failed to locate executable %s: %m", LOG_UNIT_MESSAGE(unit, "Failed to locate executable %s: %m",
command->path), command->path),
"EXECUTABLE=%s", command->path); "EXECUTABLE=%s", command->path);
} }
r = add_shifted_fd(keep_fds, ELEMENTSOF(keep_fds), &n_keep_fds, executable_fd, &executable_fd); r = add_shifted_fd(keep_fds, ELEMENTSOF(keep_fds), &n_keep_fds, executable_fd, &executable_fd);
@ -4630,15 +4629,14 @@ static int exec_child(
final_argv = command->argv; final_argv = command->argv;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *line; _cleanup_free_ char *line = NULL;
line = exec_command_line(final_argv); line = exec_command_line(final_argv);
if (line) if (line)
log_struct(LOG_DEBUG, log_unit_struct(unit, LOG_DEBUG,
"EXECUTABLE=%s", executable, "EXECUTABLE=%s", executable,
LOG_UNIT_MESSAGE(unit, "Executing: %s", line), LOG_UNIT_MESSAGE(unit, "Executing: %s", line),
LOG_UNIT_ID(unit), LOG_UNIT_INVOCATION_ID(unit));
LOG_UNIT_INVOCATION_ID(unit));
} }
if (exec_fd >= 0) { if (exec_fd >= 0) {
@ -4730,14 +4728,13 @@ int exec_spawn(Unit *unit,
and, until the next SELinux policy changes, we save further reloads in future children. */ and, until the next SELinux policy changes, we save further reloads in future children. */
mac_selinux_maybe_reload(); mac_selinux_maybe_reload();
log_struct(LOG_DEBUG, log_unit_struct(unit, LOG_DEBUG,
LOG_UNIT_MESSAGE(unit, "About to execute %s", line), LOG_UNIT_MESSAGE(unit, "About to execute %s", line),
"EXECUTABLE=%s", command->path, /* We won't know the real executable path until we create "EXECUTABLE=%s", command->path, /* We won't know the real executable path until we create
the mount namespace in the child, but we want to log the mount namespace in the child, but we want to log
from the parent, so we need to use the (possibly from the parent, so we need to use the (possibly
inaccurate) path here. */ inaccurate) path here. */
LOG_UNIT_ID(unit), LOG_UNIT_INVOCATION_ID(unit));
LOG_UNIT_INVOCATION_ID(unit));
if (params->cgroup_path) { if (params->cgroup_path) {
r = exec_parameters_get_cgroup_path(params, &subcgroup_path); r = exec_parameters_get_cgroup_path(params, &subcgroup_path);
@ -4781,13 +4778,12 @@ int exec_spawn(Unit *unit,
exit_status_to_string(exit_status, exit_status_to_string(exit_status,
EXIT_STATUS_LIBC | EXIT_STATUS_SYSTEMD); EXIT_STATUS_LIBC | EXIT_STATUS_SYSTEMD);
log_struct_errno(LOG_ERR, r, log_unit_struct_errno(unit, LOG_ERR, r,
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR, "MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
LOG_UNIT_ID(unit), LOG_UNIT_INVOCATION_ID(unit),
LOG_UNIT_INVOCATION_ID(unit), LOG_UNIT_MESSAGE(unit, "Failed at step %s spawning %s: %m",
LOG_UNIT_MESSAGE(unit, "Failed at step %s spawning %s: %m", status, command->path),
status, command->path), "EXECUTABLE=%s", command->path);
"EXECUTABLE=%s", command->path);
} }
_exit(exit_status); _exit(exit_status);
@ -4907,6 +4903,7 @@ void exec_context_done(ExecContext *c) {
c->stdin_data_size = 0; c->stdin_data_size = 0;
c->network_namespace_path = mfree(c->network_namespace_path); c->network_namespace_path = mfree(c->network_namespace_path);
c->ipc_namespace_path = mfree(c->ipc_namespace_path);
c->log_namespace = mfree(c->log_namespace); c->log_namespace = mfree(c->log_namespace);
@ -4923,7 +4920,7 @@ int exec_context_destroy_runtime_directory(const ExecContext *c, const char *run
return 0; return 0;
STRV_FOREACH(i, c->directories[EXEC_DIRECTORY_RUNTIME].paths) { STRV_FOREACH(i, c->directories[EXEC_DIRECTORY_RUNTIME].paths) {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
if (exec_directory_is_private(c, EXEC_DIRECTORY_RUNTIME)) if (exec_directory_is_private(c, EXEC_DIRECTORY_RUNTIME))
p = path_join(runtime_prefix, "private", *i); p = path_join(runtime_prefix, "private", *i);

View File

@ -557,6 +557,9 @@ static void job_log_begin_status_message(Unit *u, uint32_t job_id, JobType t) {
if (!IN_SET(t, JOB_START, JOB_STOP, JOB_RELOAD)) if (!IN_SET(t, JOB_START, JOB_STOP, JOB_RELOAD))
return; return;
if (!unit_log_level_test(u, LOG_INFO))
return;
if (log_on_console()) /* Skip this if it would only go on the console anyway */ if (log_on_console()) /* Skip this if it would only go on the console anyway */
return; return;
@ -578,13 +581,12 @@ static void job_log_begin_status_message(Unit *u, uint32_t job_id, JobType t) {
* which is supposed the highest level, friendliest output * which is supposed the highest level, friendliest output
* possible, which means we should avoid the low-level unit * possible, which means we should avoid the low-level unit
* name. */ * name. */
log_struct(LOG_INFO, log_unit_struct(u, LOG_INFO,
LOG_MESSAGE("%s", buf), LOG_MESSAGE("%s", buf),
"JOB_ID=%" PRIu32, job_id, "JOB_ID=%" PRIu32, job_id,
"JOB_TYPE=%s", job_type_to_string(t), "JOB_TYPE=%s", job_type_to_string(t),
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), mid);
mid);
} }
static void job_emit_begin_status_message(Unit *u, uint32_t job_id, JobType t) { static void job_emit_begin_status_message(Unit *u, uint32_t job_id, JobType t) {
@ -844,7 +846,7 @@ static void job_print_done_status_message(Unit *u, JobType t, JobResult result)
REENABLE_WARNING; REENABLE_WARNING;
if (t == JOB_START && result == JOB_FAILED) { if (t == JOB_START && result == JOB_FAILED) {
_cleanup_free_ char *quoted; _cleanup_free_ char *quoted = NULL;
quoted = shell_maybe_quote(u->id, ESCAPE_BACKSLASH); quoted = shell_maybe_quote(u->id, ESCAPE_BACKSLASH);
manager_status_printf(u->manager, STATUS_TYPE_NORMAL, NULL, "See 'systemctl status %s' for details.", strna(quoted)); manager_status_printf(u->manager, STATUS_TYPE_NORMAL, NULL, "See 'systemctl status %s' for details.", strna(quoted));
@ -879,18 +881,20 @@ static void job_log_done_status_message(Unit *u, uint32_t job_id, JobType t, Job
/* Show condition check message if the job did not actually do anything due to failed condition. */ /* Show condition check message if the job did not actually do anything due to failed condition. */
if (t == JOB_START && result == JOB_DONE && !u->condition_result) { if (t == JOB_START && result == JOB_DONE && !u->condition_result) {
log_struct(LOG_INFO, log_unit_struct(u, LOG_INFO,
"MESSAGE=Condition check resulted in %s being skipped.", unit_status_string(u), "MESSAGE=Condition check resulted in %s being skipped.", unit_status_string(u),
"JOB_ID=%" PRIu32, job_id, "JOB_ID=%" PRIu32, job_id,
"JOB_TYPE=%s", job_type_to_string(t), "JOB_TYPE=%s", job_type_to_string(t),
"JOB_RESULT=%s", job_result_to_string(result), "JOB_RESULT=%s", job_result_to_string(result),
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), "MESSAGE_ID=" SD_MESSAGE_UNIT_STARTED_STR);
"MESSAGE_ID=" SD_MESSAGE_UNIT_STARTED_STR);
return; return;
} }
if (!unit_log_level_test(u, job_result_log_level[result]))
return;
format = job_get_done_status_message_format(u, t, result); format = job_get_done_status_message_format(u, t, result);
if (!format) if (!format)
return; return;
@ -922,24 +926,22 @@ static void job_log_done_status_message(Unit *u, uint32_t job_id, JobType t, Job
break; break;
default: default:
log_struct(job_result_log_level[result], log_unit_struct(u, job_result_log_level[result],
LOG_MESSAGE("%s", buf), LOG_MESSAGE("%s", buf),
"JOB_ID=%" PRIu32, job_id, "JOB_ID=%" PRIu32, job_id,
"JOB_TYPE=%s", job_type_to_string(t), "JOB_TYPE=%s", job_type_to_string(t),
"JOB_RESULT=%s", job_result_to_string(result), "JOB_RESULT=%s", job_result_to_string(result),
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u));
LOG_UNIT_INVOCATION_ID(u));
return; return;
} }
log_struct(job_result_log_level[result], log_unit_struct(u, job_result_log_level[result],
LOG_MESSAGE("%s", buf), LOG_MESSAGE("%s", buf),
"JOB_ID=%" PRIu32, job_id, "JOB_ID=%" PRIu32, job_id,
"JOB_TYPE=%s", job_type_to_string(t), "JOB_TYPE=%s", job_type_to_string(t),
"JOB_RESULT=%s", job_result_to_string(result), "JOB_RESULT=%s", job_result_to_string(result),
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), mid);
mid);
} }
static void job_emit_done_status_message(Unit *u, uint32_t job_id, JobType t, JobResult result) { static void job_emit_done_status_message(Unit *u, uint32_t job_id, JobType t, JobResult result) {
@ -1048,14 +1050,13 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr
* this context. And JOB_FAILURE is already handled by the * this context. And JOB_FAILURE is already handled by the
* unit itself. */ * unit itself. */
if (IN_SET(result, JOB_TIMEOUT, JOB_DEPENDENCY)) { if (IN_SET(result, JOB_TIMEOUT, JOB_DEPENDENCY)) {
log_struct(LOG_NOTICE, log_unit_struct(u, LOG_NOTICE,
"JOB_TYPE=%s", job_type_to_string(t), "JOB_TYPE=%s", job_type_to_string(t),
"JOB_RESULT=%s", job_result_to_string(result), "JOB_RESULT=%s", job_result_to_string(result),
LOG_UNIT_ID(u), LOG_UNIT_MESSAGE(u, "Job %s/%s failed with result '%s'.",
LOG_UNIT_MESSAGE(u, "Job %s/%s failed with result '%s'.", u->id,
u->id, job_type_to_string(t),
job_type_to_string(t), job_result_to_string(result)));
job_result_to_string(result)));
unit_start_on_failure(u); unit_start_on_failure(u);
} }

View File

@ -1695,6 +1695,8 @@ int config_parse_exec_cpu_affinity(
void *userdata) { void *userdata) {
ExecContext *c = data; ExecContext *c = data;
const Unit *u = userdata;
_cleanup_free_ char *k = NULL;
int r; int r;
assert(filename); assert(filename);
@ -1709,7 +1711,15 @@ int config_parse_exec_cpu_affinity(
return 0; return 0;
} }
r = parse_cpu_set_extend(rvalue, &c->cpu_set, true, unit, filename, line, lvalue); r = unit_full_printf(u, rvalue, &k);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to resolve unit specifiers in '%s', ignoring: %m",
rvalue);
return 0;
}
r = parse_cpu_set_extend(k, &c->cpu_set, true, unit, filename, line, lvalue);
if (r >= 0) if (r >= 0)
c->cpu_affinity_from_numa = false; c->cpu_affinity_from_numa = false;
@ -4592,7 +4602,7 @@ int config_parse_load_credential(
r = extract_first_word(&p, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS); r = extract_first_word(&p, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r <= 0) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -2036,7 +2036,7 @@ static void log_execution_mode(bool *ret_first_boot) {
} }
} else { } else {
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = uid_to_name(getuid()); t = uid_to_name(getuid());
log_debug("systemd " GIT_VERSION " running in %suser mode for user " UID_FMT "/%s. (%s)", log_debug("systemd " GIT_VERSION " running in %suser mode for user " UID_FMT "/%s. (%s)",

View File

@ -247,7 +247,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
} }
static int have_ask_password(void) { static int have_ask_password(void) {
_cleanup_closedir_ DIR *dir; _cleanup_closedir_ DIR *dir = NULL;
struct dirent *de; struct dirent *de;
dir = opendir("/run/systemd/ask-password"); dir = opendir("/run/systemd/ask-password");
@ -1280,7 +1280,6 @@ static unsigned manager_dispatch_stop_when_unneeded_queue(Manager *m) {
while ((u = m->stop_when_unneeded_queue)) { while ((u = m->stop_when_unneeded_queue)) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
assert(m->stop_when_unneeded_queue);
assert(u->in_stop_when_unneeded_queue); assert(u->in_stop_when_unneeded_queue);
LIST_REMOVE(stop_when_unneeded_queue, m->stop_when_unneeded_queue, u); LIST_REMOVE(stop_when_unneeded_queue, m->stop_when_unneeded_queue, u);

View File

@ -2088,7 +2088,7 @@ int setup_namespace(
} }
if (log_namespace) { if (log_namespace) {
_cleanup_free_ char *q; _cleanup_free_ char *q = NULL;
q = strjoin("/run/systemd/journal.", log_namespace); q = strjoin("/run/systemd/journal.", log_namespace);
if (!q) { if (!q) {
@ -2327,7 +2327,7 @@ int mount_image_add(MountImage **m, size_t *n, const MountImage *item) {
} }
LIST_FOREACH(mount_options, i, item->mount_options) { LIST_FOREACH(mount_options, i, item->mount_options) {
_cleanup_(mount_options_free_allp) MountOptions *o; _cleanup_(mount_options_free_allp) MountOptions *o = NULL;
o = new(MountOptions, 1); o = new(MountOptions, 1);
if (!o) if (!o)

View File

@ -2270,12 +2270,11 @@ static void service_enter_restart(Service *s) {
s->n_restarts ++; s->n_restarts ++;
s->flush_n_restarts = false; s->flush_n_restarts = false;
log_struct(LOG_INFO, log_unit_struct(UNIT(s), LOG_INFO,
"MESSAGE_ID=" SD_MESSAGE_UNIT_RESTART_SCHEDULED_STR, "MESSAGE_ID=" SD_MESSAGE_UNIT_RESTART_SCHEDULED_STR,
LOG_UNIT_ID(UNIT(s)), LOG_UNIT_INVOCATION_ID(UNIT(s)),
LOG_UNIT_INVOCATION_ID(UNIT(s)), LOG_UNIT_MESSAGE(UNIT(s), "Scheduled restart job, restart counter is at %u.", s->n_restarts),
LOG_UNIT_MESSAGE(UNIT(s), "Scheduled restart job, restart counter is at %u.", s->n_restarts), "N_RESTARTS=%u", s->n_restarts);
"N_RESTARTS=%u", s->n_restarts);
/* Notify clients about changed restart counter */ /* Notify clients about changed restart counter */
unit_add_to_dbus_queue(UNIT(s)); unit_add_to_dbus_queue(UNIT(s));
@ -2718,7 +2717,7 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
return 0; return 0;
} }
static int service_deserialize_exec_command( int service_deserialize_exec_command(
Unit *u, Unit *u,
const char *key, const char *key,
const char *value) { const char *value) {
@ -2776,9 +2775,6 @@ static int service_deserialize_exec_command(
case STATE_EXEC_COMMAND_PATH: case STATE_EXEC_COMMAND_PATH:
path = TAKE_PTR(arg); path = TAKE_PTR(arg);
state = STATE_EXEC_COMMAND_ARGS; state = STATE_EXEC_COMMAND_ARGS;
if (!path_is_absolute(path))
return -EINVAL;
break; break;
case STATE_EXEC_COMMAND_ARGS: case STATE_EXEC_COMMAND_ARGS:
r = strv_extend(&argv, arg); r = strv_extend(&argv, arg);
@ -2786,13 +2782,14 @@ static int service_deserialize_exec_command(
return -ENOMEM; return -ENOMEM;
break; break;
default: default:
assert_not_reached("Unknown error at deserialization of exec command"); assert_not_reached("Logic error in exec command deserialization");
break;
} }
} }
if (state != STATE_EXEC_COMMAND_ARGS) if (state != STATE_EXEC_COMMAND_ARGS)
return -EINVAL; return -EINVAL;
if (strv_isempty(argv))
return -EINVAL; /* At least argv[0] must be always present. */
/* Let's check whether exec command on given offset matches data that we just deserialized */ /* Let's check whether exec command on given offset matches data that we just deserialized */
for (command = s->exec_command[id], i = 0; command; command = command->command_next, i++) { for (command = s->exec_command[id], i = 0; command; command = command->command_next, i++) {
@ -3460,6 +3457,15 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
case SERVICE_START_POST: case SERVICE_START_POST:
case SERVICE_RELOAD: case SERVICE_RELOAD:
/* If neither main nor control processes are running then
* the current state can never exit cleanly, hence immediately
* terminate the service. */
if (control_pid_good(s) <= 0)
service_enter_stop(s, f);
/* Otherwise need to wait untill the operation is done. */
break;
case SERVICE_STOP: case SERVICE_STOP:
/* Need to wait until the operation is /* Need to wait until the operation is
* done */ * done */
@ -4255,7 +4261,7 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock, bool selinux_context
if (getpeername_pretty(fd, true, &peer) >= 0) { if (getpeername_pretty(fd, true, &peer) >= 0) {
if (UNIT(s)->description) { if (UNIT(s)->description) {
_cleanup_free_ char *a; _cleanup_free_ char *a = NULL;
a = strjoin(UNIT(s)->description, " (", peer, ")"); a = strjoin(UNIT(s)->description, " (", peer, ")");
if (!a) if (!a)

View File

@ -244,3 +244,6 @@ ServiceTimeoutFailureMode service_timeout_failure_mode_from_string(const char *s
DEFINE_CAST(SERVICE, Service); DEFINE_CAST(SERVICE, Service);
#define STATUS_TEXT_MAX (16U*1024U) #define STATUS_TEXT_MAX (16U*1024U)
/* Only exported for unit tests */
int service_deserialize_exec_command(Unit *u, const char *key, const char *value);

View File

@ -31,7 +31,6 @@
#NUMAMask= #NUMAMask=
#RuntimeWatchdogSec=0 #RuntimeWatchdogSec=0
#RebootWatchdogSec=10min #RebootWatchdogSec=10min
#ShutdownWatchdogSec=10min
#KExecWatchdogSec=0 #KExecWatchdogSec=0
#WatchdogDevice= #WatchdogDevice=
#CapabilityBoundingSet= #CapabilityBoundingSet=
@ -72,3 +71,4 @@
#DefaultLimitNICE= #DefaultLimitNICE=
#DefaultLimitRTPRIO= #DefaultLimitRTPRIO=
#DefaultLimitRTTIME= #DefaultLimitRTTIME=
#DefaultOOMPolicy=stop

View File

@ -556,7 +556,7 @@ static void unit_free_requires_mounts_for(Unit *u) {
assert(u); assert(u);
for (;;) { for (;;) {
_cleanup_free_ char *path; _cleanup_free_ char *path = NULL;
path = hashmap_steal_first_key(u->requires_mounts_for); path = hashmap_steal_first_key(u->requires_mounts_for);
if (!path) if (!path)
@ -1060,7 +1060,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
char **dp; char **dp;
STRV_FOREACH(dp, c->directories[dt].paths) { STRV_FOREACH(dp, c->directories[dt].paths) {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = path_join(u->manager->prefix[dt], *dp); p = path_join(u->manager->prefix[dt], *dp);
if (!p) if (!p)
@ -1449,6 +1449,9 @@ static int log_unit_internal(void *userdata, int level, int error, const char *f
va_list ap; va_list ap;
int r; int r;
if (u && !unit_log_level_test(u, level))
return -ERRNO_VALUE(error);
va_start(ap, format); va_start(ap, format);
if (u) if (u)
r = log_object_internalv(level, error, file, line, func, r = log_object_internalv(level, error, file, line, func,
@ -2152,6 +2155,13 @@ static int unit_log_resources(Unit *u) {
value > NOTICEWORTHY_IP_BYTES); value > NOTICEWORTHY_IP_BYTES);
} }
/* This check is here because it is the earliest point following all possible log_level assignments. If
* log_level is assigned anywhere after this point, move this check. */
if (!unit_log_level_test(u, log_level)) {
r = 0;
goto finish;
}
if (have_ip_accounting) { if (have_ip_accounting) {
if (any_traffic) { if (any_traffic) {
if (igress) if (igress)
@ -2181,7 +2191,7 @@ static int unit_log_resources(Unit *u) {
if (n_message_parts == 0) if (n_message_parts == 0)
t = strjoina("MESSAGE=", u->id, ": Completed."); t = strjoina("MESSAGE=", u->id, ": Completed.");
else { else {
_cleanup_free_ char *joined; _cleanup_free_ char *joined = NULL;
message_parts[n_message_parts] = NULL; message_parts[n_message_parts] = NULL;
@ -2206,7 +2216,7 @@ static int unit_log_resources(Unit *u) {
t = strjoina(u->manager->invocation_log_field, u->invocation_id_string); t = strjoina(u->manager->invocation_log_field, u->invocation_id_string);
iovec[n_iovec + 3] = IOVEC_MAKE_STRING(t); iovec[n_iovec + 3] = IOVEC_MAKE_STRING(t);
log_struct_iovec(log_level, iovec, n_iovec + 4); log_unit_struct_iovec(u, log_level, iovec, n_iovec + 4);
r = 0; r = 0;
finish: finish:
@ -3866,7 +3876,7 @@ int unit_patch_contexts(Unit *u) {
return 0; return 0;
} }
ExecContext *unit_get_exec_context(Unit *u) { ExecContext *unit_get_exec_context(const Unit *u) {
size_t offset; size_t offset;
assert(u); assert(u);
@ -4478,6 +4488,9 @@ void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
assert(u); assert(u);
assert(where); assert(where);
if (!unit_log_level_test(u, LOG_NOTICE))
return;
r = dir_is_empty(where); r = dir_is_empty(where);
if (r > 0 || r == -ENOTDIR) if (r > 0 || r == -ENOTDIR)
return; return;
@ -4486,12 +4499,11 @@ void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
return; return;
} }
log_struct(LOG_NOTICE, log_unit_struct(u, LOG_NOTICE,
"MESSAGE_ID=" SD_MESSAGE_OVERMOUNTING_STR, "MESSAGE_ID=" SD_MESSAGE_OVERMOUNTING_STR,
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), LOG_UNIT_MESSAGE(u, "Directory %s to mount over is not empty, mounting anyway.", where),
LOG_UNIT_MESSAGE(u, "Directory %s to mount over is not empty, mounting anyway.", where), "WHERE=%s", where);
"WHERE=%s", where);
} }
int unit_fail_if_noncanonical(Unit *u, const char* where) { int unit_fail_if_noncanonical(Unit *u, const char* where) {
@ -4512,12 +4524,11 @@ int unit_fail_if_noncanonical(Unit *u, const char* where) {
return 0; return 0;
/* No need to mention "." or "..", they would already have been rejected by unit_name_from_path() */ /* No need to mention "." or "..", they would already have been rejected by unit_name_from_path() */
log_struct(LOG_ERR, log_unit_struct(u, LOG_ERR,
"MESSAGE_ID=" SD_MESSAGE_OVERMOUNTING_STR, "MESSAGE_ID=" SD_MESSAGE_OVERMOUNTING_STR,
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), LOG_UNIT_MESSAGE(u, "Mount path %s is not canonical (contains a symlink).", where),
LOG_UNIT_MESSAGE(u, "Mount path %s is not canonical (contains a symlink).", where), "WHERE=%s", where);
"WHERE=%s", where);
return -ELOOP; return -ELOOP;
} }
@ -5296,35 +5307,32 @@ int unit_pid_attachable(Unit *u, pid_t pid, sd_bus_error *error) {
void unit_log_success(Unit *u) { void unit_log_success(Unit *u) {
assert(u); assert(u);
log_struct(LOG_INFO, log_unit_struct(u, LOG_INFO,
"MESSAGE_ID=" SD_MESSAGE_UNIT_SUCCESS_STR, "MESSAGE_ID=" SD_MESSAGE_UNIT_SUCCESS_STR,
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), LOG_UNIT_MESSAGE(u, "Deactivated successfully."));
LOG_UNIT_MESSAGE(u, "Deactivated successfully."));
} }
void unit_log_failure(Unit *u, const char *result) { void unit_log_failure(Unit *u, const char *result) {
assert(u); assert(u);
assert(result); assert(result);
log_struct(LOG_WARNING, log_unit_struct(u, LOG_WARNING,
"MESSAGE_ID=" SD_MESSAGE_UNIT_FAILURE_RESULT_STR, "MESSAGE_ID=" SD_MESSAGE_UNIT_FAILURE_RESULT_STR,
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), LOG_UNIT_MESSAGE(u, "Failed with result '%s'.", result),
LOG_UNIT_MESSAGE(u, "Failed with result '%s'.", result), "UNIT_RESULT=%s", result);
"UNIT_RESULT=%s", result);
} }
void unit_log_skip(Unit *u, const char *result) { void unit_log_skip(Unit *u, const char *result) {
assert(u); assert(u);
assert(result); assert(result);
log_struct(LOG_INFO, log_unit_struct(u, LOG_INFO,
"MESSAGE_ID=" SD_MESSAGE_UNIT_SKIPPED_STR, "MESSAGE_ID=" SD_MESSAGE_UNIT_SKIPPED_STR,
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u),
LOG_UNIT_INVOCATION_ID(u), LOG_UNIT_MESSAGE(u, "Skipped due to '%s'.", result),
LOG_UNIT_MESSAGE(u, "Skipped due to '%s'.", result), "UNIT_RESULT=%s", result);
"UNIT_RESULT=%s", result);
} }
void unit_log_process_exit( void unit_log_process_exit(
@ -5351,19 +5359,18 @@ void unit_log_process_exit(
else else
level = LOG_WARNING; level = LOG_WARNING;
log_struct(level, log_unit_struct(u, level,
"MESSAGE_ID=" SD_MESSAGE_UNIT_PROCESS_EXIT_STR, "MESSAGE_ID=" SD_MESSAGE_UNIT_PROCESS_EXIT_STR,
LOG_UNIT_MESSAGE(u, "%s exited, code=%s, status=%i/%s", LOG_UNIT_MESSAGE(u, "%s exited, code=%s, status=%i/%s",
kind, kind,
sigchld_code_to_string(code), status, sigchld_code_to_string(code), status,
strna(code == CLD_EXITED strna(code == CLD_EXITED
? exit_status_to_string(status, EXIT_STATUS_FULL) ? exit_status_to_string(status, EXIT_STATUS_FULL)
: signal_to_string(status))), : signal_to_string(status))),
"EXIT_CODE=%s", sigchld_code_to_string(code), "EXIT_CODE=%s", sigchld_code_to_string(code),
"EXIT_STATUS=%i", status, "EXIT_STATUS=%i", status,
"COMMAND=%s", strna(command), "COMMAND=%s", strna(command),
LOG_UNIT_ID(u), LOG_UNIT_INVOCATION_ID(u));
LOG_UNIT_INVOCATION_ID(u));
} }
int unit_exit_status(Unit *u) { int unit_exit_status(Unit *u) {

View File

@ -645,7 +645,7 @@ typedef struct UnitVTable {
extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX]; extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
static inline const UnitVTable* UNIT_VTABLE(Unit *u) { static inline const UnitVTable* UNIT_VTABLE(const Unit *u) {
return unit_vtable[u->type]; return unit_vtable[u->type];
} }
@ -808,7 +808,7 @@ void unit_ref_unset(UnitRef *ref);
int unit_patch_contexts(Unit *u); int unit_patch_contexts(Unit *u);
ExecContext *unit_get_exec_context(Unit *u) _pure_; ExecContext *unit_get_exec_context(const Unit *u) _pure_;
KillContext *unit_get_kill_context(Unit *u) _pure_; KillContext *unit_get_kill_context(Unit *u) _pure_;
CGroupContext *unit_get_cgroup_context(Unit *u) _pure_; CGroupContext *unit_get_cgroup_context(Unit *u) _pure_;
@ -879,6 +879,11 @@ static inline bool unit_has_job_type(Unit *u, JobType type) {
return u && u->job && u->job->type == type; return u && u->job && u->job->type == type;
} }
static inline bool unit_log_level_test(const Unit *u, int level) {
ExecContext *ec = unit_get_exec_context(u);
return !ec || ec->log_level_max < 0 || ec->log_level_max >= LOG_PRI(level);
}
/* unit_log_skip is for cases like ExecCondition= where a unit is considered "done" /* unit_log_skip is for cases like ExecCondition= where a unit is considered "done"
* after some execution, rather than succeeded or failed. */ * after some execution, rather than succeeded or failed. */
void unit_log_skip(Unit *u, const char *result); void unit_log_skip(Unit *u, const char *result);
@ -918,9 +923,10 @@ int unit_thaw_vtable_common(Unit *u);
#define log_unit_full_errno(unit, level, error, ...) \ #define log_unit_full_errno(unit, level, error, ...) \
({ \ ({ \
const Unit *_u = (unit); \ const Unit *_u = (unit); \
(log_get_max_level() < LOG_PRI(level)) ? -ERRNO_VALUE(error) : \ const int _l = (level); \
_u ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, _u->manager->unit_log_field, _u->id, _u->manager->invocation_log_field, _u->invocation_id_string, ##__VA_ARGS__) : \ (log_get_max_level() < LOG_PRI(_l) || (_u && !unit_log_level_test(_u, _l))) ? -ERRNO_VALUE(error) : \
log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \ _u ? log_object_internal(_l, error, PROJECT_FILE, __LINE__, __func__, _u->manager->unit_log_field, _u->id, _u->manager->invocation_log_field, _u->invocation_id_string, ##__VA_ARGS__) : \
log_internal(_l, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
}) })
#define log_unit_full(unit, level, ...) (void) log_unit_full_errno(unit, level, 0, __VA_ARGS__) #define log_unit_full(unit, level, ...) (void) log_unit_full_errno(unit, level, 0, __VA_ARGS__)
@ -937,6 +943,27 @@ int unit_thaw_vtable_common(Unit *u);
#define log_unit_warning_errno(unit, error, ...) log_unit_full_errno(unit, LOG_WARNING, error, __VA_ARGS__) #define log_unit_warning_errno(unit, error, ...) log_unit_full_errno(unit, LOG_WARNING, error, __VA_ARGS__)
#define log_unit_error_errno(unit, error, ...) log_unit_full_errno(unit, LOG_ERR, error, __VA_ARGS__) #define log_unit_error_errno(unit, error, ...) log_unit_full_errno(unit, LOG_ERR, error, __VA_ARGS__)
#define log_unit_struct_errno(unit, level, error, ...) \
({ \
const Unit *_u = (unit); \
const int _l = (level); \
unit_log_level_test(_u, _l) ? \
log_struct_errno(_l, error, __VA_ARGS__, LOG_UNIT_ID(_u)) : \
-ERRNO_VALUE(error); \
})
#define log_unit_struct(unit, level, ...) log_unit_struct_errno(unit, level, 0, __VA_ARGS__)
#define log_unit_struct_iovec_errno(unit, level, error, iovec, n_iovec) \
({ \
const int _l = (level); \
unit_log_level_test(unit, _l) ? \
log_struct_iovec_errno(_l, error, iovec, n_iovec) : \
-ERRNO_VALUE(error); \
})
#define log_unit_struct_iovec(unit, level, iovec, n_iovec) log_unit_struct_iovec_errno(unit, level, 0, iovec, n_iovec)
#define LOG_UNIT_MESSAGE(unit, fmt, ...) "MESSAGE=%s: " fmt, (unit)->id, ##__VA_ARGS__ #define LOG_UNIT_MESSAGE(unit, fmt, ...) "MESSAGE=%s: " fmt, (unit)->id, ##__VA_ARGS__
#define LOG_UNIT_ID(unit) (unit)->manager->unit_log_format_string, (unit)->id #define LOG_UNIT_ID(unit) (unit)->manager->unit_log_format_string, (unit)->id
#define LOG_UNIT_INVOCATION_ID(unit) (unit)->manager->invocation_log_format_string, (unit)->invocation_id_string #define LOG_UNIT_INVOCATION_ID(unit) (unit)->manager->invocation_log_format_string, (unit)->invocation_id_string

View File

@ -7,7 +7,7 @@
# #
# Entries in this file show the compile time defaults. Local configuration # Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in # should be created by either modifying this file, or by creating "drop-ins" in
# the system.conf.d/ subdirectory. The latter is generally recommended. # the user.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins. # Defaults can be restored by simply deleting this file and all drop-ins.
# #
# See systemd-user.conf(5) for details. # See systemd-user.conf(5) for details.

View File

@ -588,7 +588,7 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
static int get_process_ns(pid_t pid, const char *namespace, ino_t *ns) { static int get_process_ns(pid_t pid, const char *namespace, ino_t *ns) {
const char *p; const char *p;
struct stat stbuf; struct stat stbuf;
_cleanup_close_ int proc_ns_dir_fd; _cleanup_close_ int proc_ns_dir_fd = -1;
p = procfs_file_alloca(pid, "ns"); p = procfs_file_alloca(pid, "ns");

View File

@ -7,7 +7,7 @@
# #
# Entries in this file show the compile time defaults. Local configuration # Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in # should be created by either modifying this file, or by creating "drop-ins" in
# the system.conf.d/ subdirectory. The latter is generally recommended. # the coredump.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins. # Defaults can be restored by simply deleting this file and all drop-ins.
# #
# Use 'systemd-analyze cat-config systemd/coredump.conf' to display the full config. # Use 'systemd-analyze cat-config systemd/coredump.conf' to display the full config.

View File

@ -139,7 +139,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
return r; return r;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *filter; _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j); filter = journal_make_match_string(j);
log_debug("Journal filter: %s", filter); log_debug("Journal filter: %s", filter);
@ -944,7 +944,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
if (filename) { if (filename) {
#if HAVE_COMPRESSION #if HAVE_COMPRESSION
_cleanup_close_ int fdf; _cleanup_close_ int fdf = -1;
fdf = open(filename, O_RDONLY | O_CLOEXEC); fdf = open(filename, O_RDONLY | O_CLOEXEC);
if (fdf < 0) { if (fdf < 0) {

View File

@ -33,7 +33,7 @@ int find_key_file(
} }
STRV_FOREACH(i, search_path) { STRV_FOREACH(i, search_path) {
_cleanup_free_ char *joined; _cleanup_free_ char *joined = NULL;
joined = path_join(*i, key_file); joined = path_join(*i, key_file);
if (!joined) if (!joined)

View File

@ -29,7 +29,7 @@ static int environment_dirs(char ***ret) {
return r; return r;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = strv_join(dirs, "\n\t"); t = strv_join(dirs, "\n\t");
log_debug("Looking for environment.d files in (higher priority first):\n\t%s", strna(t)); log_debug("Looking for environment.d files in (higher priority first):\n\t%s", strna(t));

View File

@ -460,7 +460,7 @@ static int add_mount(
return r; return r;
if (!isempty(fstype) && !streq(fstype, "auto")) { if (!isempty(fstype) && !streq(fstype, "auto")) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = specifier_escape(fstype); t = specifier_escape(fstype);
if (!t) if (!t)

View File

@ -105,6 +105,7 @@ static int open_parent_block_device(dev_t devnum, int *ret_fd) {
} }
static int add_cryptsetup(const char *id, const char *what, bool rw, bool require, char **device) { static int add_cryptsetup(const char *id, const char *what, bool rw, bool require, char **device) {
#if HAVE_LIBCRYPTSETUP
_cleanup_free_ char *e = NULL, *n = NULL, *d = NULL; _cleanup_free_ char *e = NULL, *n = NULL, *d = NULL;
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
int r; int r;
@ -182,6 +183,9 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, bool requir
} }
return 0; return 0;
#else
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Partition is encrypted, but the project was compiled without libcryptsetup support");
#endif
} }
static int add_mount( static int add_mount(

View File

@ -3362,4 +3362,4 @@ static int run(int argc, char *argv[]) {
return dispatch_verb(argc, argv, verbs, NULL); return dispatch_verb(argc, argv, verbs, NULL);
} }
DEFINE_MAIN_FUNCTION(run); DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);

View File

@ -7,7 +7,7 @@
# #
# Entries in this file show the compile time defaults. Local configuration # Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in # should be created by either modifying this file, or by creating "drop-ins" in
# the system.conf.d/ subdirectory. The latter is generally recommended. # the homed.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins. # Defaults can be restored by simply deleting this file and all drop-ins.
# #
# Use 'systemd-analyze cat-config systemd/homed.conf' to display the full config. # Use 'systemd-analyze cat-config systemd/homed.conf' to display the full config.

View File

@ -155,17 +155,10 @@ static int print_status_info(StatusInfo *i) {
} }
if (!isempty(i->os_pretty_name)) { if (!isempty(i->os_pretty_name)) {
_cleanup_free_ char *formatted = NULL;
const char *t = i->os_pretty_name;
if (i->home_url) {
if (terminal_urlify(i->home_url, i->os_pretty_name, &formatted) >= 0)
t = formatted;
}
r = table_add_many(table, r = table_add_many(table,
TABLE_STRING, "Operating System:", TABLE_STRING, "Operating System:",
TABLE_STRING, t); TABLE_STRING, i->os_pretty_name,
TABLE_SET_URL, i->home_url);
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
} }

View File

@ -311,7 +311,7 @@ static int request_parse_range(
colon2 = strchr(colon + 1, ':'); colon2 = strchr(colon + 1, ':');
if (colon2) { if (colon2) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = strndup(colon + 1, colon2 - colon - 1); t = strndup(colon + 1, colon2 - colon - 1);
if (!t) if (!t)

View File

@ -40,7 +40,7 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
break; break;
case JOURNAL_WRITE_SPLIT_HOST: { case JOURNAL_WRITE_SPLIT_HOST: {
_cleanup_free_ char *name; _cleanup_free_ char *name = NULL;
assert(host); assert(host);

View File

@ -7,7 +7,7 @@
# #
# Entries in this file show the compile time defaults. Local configuration # Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in # should be created by either modifying this file, or by creating "drop-ins" in
# the system.conf.d/ subdirectory. The latter is generally recommended. # the journal-remote.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins. # Defaults can be restored by simply deleting this file and all drop-ins.
# #
# See journal-remote.conf(5) for details. # See journal-remote.conf(5) for details.

View File

@ -7,7 +7,7 @@
# #
# Entries in this file show the compile time defaults. Local configuration # Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in # should be created by either modifying this file, or by creating "drop-ins" in
# the system.conf.d/ subdirectory. The latter is generally recommended. # the journal-upload.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins. # Defaults can be restored by simply deleting this file and all drop-ins.
# #
# See journal-upload.conf(5) for details. # See journal-upload.conf(5) for details.

View File

@ -1158,7 +1158,7 @@ static int add_matches(sd_journal *j, char **args) {
if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) { if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) {
if (executable_is_script(p, &interpreter) > 0) { if (executable_is_script(p, &interpreter) > 0) {
_cleanup_free_ char *comm; _cleanup_free_ char *comm = NULL;
comm = strndup(basename(p), 15); comm = strndup(basename(p), 15);
if (!comm) if (!comm)
@ -1537,7 +1537,7 @@ static int get_possible_units(
char **patterns, char **patterns,
Set **units) { Set **units) {
_cleanup_set_free_free_ Set *found; _cleanup_set_free_free_ Set *found = NULL;
const char *field; const char *field;
int r; int r;
@ -2179,7 +2179,7 @@ int main(int argc, char *argv[]) {
case ACTION_LIST_CATALOG: case ACTION_LIST_CATALOG:
case ACTION_DUMP_CATALOG: case ACTION_DUMP_CATALOG:
case ACTION_UPDATE_CATALOG: { case ACTION_UPDATE_CATALOG: {
_cleanup_free_ char *database; _cleanup_free_ char *database = NULL;
database = path_join(arg_root, CATALOG_DATABASE); database = path_join(arg_root, CATALOG_DATABASE);
if (!database) { if (!database) {
@ -2433,7 +2433,7 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *filter; _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j); filter = journal_make_match_string(j);
if (!filter) if (!filter)

View File

@ -14,6 +14,7 @@
#include "escape.h" #include "escape.h"
#include "fd-util.h" #include "fd-util.h"
#include "format-util.h" #include "format-util.h"
#include "fs-util.h"
#include "io-util.h" #include "io-util.h"
#include "journald-kmsg.h" #include "journald-kmsg.h"
#include "journald-server.h" #include "journald-server.h"
@ -376,8 +377,8 @@ int server_open_dev_kmsg(Server *s) {
s->dev_kmsg_fd = open("/dev/kmsg", mode); s->dev_kmsg_fd = open("/dev/kmsg", mode);
if (s->dev_kmsg_fd < 0) { if (s->dev_kmsg_fd < 0) {
log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
"Failed to open /dev/kmsg, ignoring: %m"); errno, "Failed to open /dev/kmsg, ignoring: %m");
return 0; return 0;
} }
@ -436,8 +437,8 @@ int server_open_kernel_seqnum(Server *s) {
return 0; return 0;
} }
r = posix_fallocate(fd, 0, sizeof(uint64_t)); r = posix_fallocate_loop(fd, 0, sizeof(uint64_t));
if (r != 0) { if (r < 0) {
log_error_errno(r, "Failed to allocate sequential number file, ignoring: %m"); log_error_errno(r, "Failed to allocate sequential number file, ignoring: %m");
return 0; return 0;
} }

View File

@ -39,6 +39,12 @@
#define STDOUT_STREAMS_MAX 4096 #define STDOUT_STREAMS_MAX 4096
/* During the "setup" protocol phase of the stream logic let's define a different maximum line length than
* during the actual operational phase. We want to allow users to specify very short line lengths after all,
* but the unit name we embed in the setup protocol might be longer than that. Hence, during the setup phase
* let's enforce a line length matching the maximum unit name length (255) */
#define STDOUT_STREAM_SETUP_PROTOCOL_LINE_MAX (UNIT_NAME_MAX-1U)
typedef enum StdoutStreamState { typedef enum StdoutStreamState {
STDOUT_STREAM_IDENTIFIER, STDOUT_STREAM_IDENTIFIER,
STDOUT_STREAM_UNIT_ID, STDOUT_STREAM_UNIT_ID,
@ -47,7 +53,7 @@ typedef enum StdoutStreamState {
STDOUT_STREAM_FORWARD_TO_SYSLOG, STDOUT_STREAM_FORWARD_TO_SYSLOG,
STDOUT_STREAM_FORWARD_TO_KMSG, STDOUT_STREAM_FORWARD_TO_KMSG,
STDOUT_STREAM_FORWARD_TO_CONSOLE, STDOUT_STREAM_FORWARD_TO_CONSOLE,
STDOUT_STREAM_RUNNING STDOUT_STREAM_RUNNING,
} StdoutStreamState; } StdoutStreamState;
/* The different types of log record terminators: a real \n was read, a NUL character was read, the maximum line length /* The different types of log record terminators: a real \n was read, a NUL character was read, the maximum line length
@ -189,7 +195,7 @@ static int stdout_stream_save(StdoutStream *s) {
s->id_field + STRLEN("_STREAM_ID=")); s->id_field + STRLEN("_STREAM_ID="));
if (!isempty(s->identifier)) { if (!isempty(s->identifier)) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->identifier); escaped = cescape(s->identifier);
if (!escaped) { if (!escaped) {
@ -201,7 +207,7 @@ static int stdout_stream_save(StdoutStream *s) {
} }
if (!isempty(s->unit_id)) { if (!isempty(s->unit_id)) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->unit_id); escaped = cescape(s->unit_id);
if (!escaped) { if (!escaped) {
@ -468,6 +474,18 @@ static int stdout_stream_found(
return r; return r;
} }
static size_t stdout_stream_line_max(StdoutStream *s) {
assert(s);
/* During the "setup" phase of our protocol, let's ensure we use a line length where a full unit name
* can fit in */
if (s->state != STDOUT_STREAM_RUNNING)
return STDOUT_STREAM_SETUP_PROTOCOL_LINE_MAX;
/* After the protocol's "setup" phase is complete, let's use whatever the user configured */
return s->server->line_max;
}
static int stdout_stream_scan( static int stdout_stream_scan(
StdoutStream *s, StdoutStream *s,
char *p, char *p,
@ -475,19 +493,22 @@ static int stdout_stream_scan(
LineBreak force_flush, LineBreak force_flush,
size_t *ret_consumed) { size_t *ret_consumed) {
size_t consumed = 0; size_t consumed = 0, line_max;
int r; int r;
assert(s); assert(s);
assert(p); assert(p);
line_max = stdout_stream_line_max(s);
for (;;) { for (;;) {
LineBreak line_break; LineBreak line_break;
size_t skip, found; size_t skip, found;
char *end1, *end2; char *end1, *end2;
size_t tmp_remaining = MIN(remaining, line_max);
end1 = memchr(p, '\n', remaining); end1 = memchr(p, '\n', tmp_remaining);
end2 = memchr(p, 0, end1 ? (size_t) (end1 - p) : remaining); end2 = memchr(p, 0, end1 ? (size_t) (end1 - p) : tmp_remaining);
if (end2) { if (end2) {
/* We found a NUL terminator */ /* We found a NUL terminator */
@ -499,9 +520,9 @@ static int stdout_stream_scan(
found = end1 - p; found = end1 - p;
skip = found + 1; skip = found + 1;
line_break = LINE_BREAK_NEWLINE; line_break = LINE_BREAK_NEWLINE;
} else if (remaining >= s->server->line_max) { } else if (remaining >= line_max) {
/* Force a line break after the maximum line length */ /* Force a line break after the maximum line length */
found = skip = s->server->line_max; found = skip = line_max;
line_break = LINE_BREAK_LINE_MAX; line_break = LINE_BREAK_LINE_MAX;
} else } else
break; break;
@ -563,7 +584,7 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
/* Try to make use of the allocated buffer in full, but never read more than the configured line size. Also, /* Try to make use of the allocated buffer in full, but never read more than the configured line size. Also,
* always leave room for a terminating NUL we might need to add. */ * always leave room for a terminating NUL we might need to add. */
limit = MIN(s->allocated - 1, s->server->line_max); limit = MIN(s->allocated - 1, MAX(s->server->line_max, STDOUT_STREAM_SETUP_PROTOCOL_LINE_MAX));
assert(s->length <= limit); assert(s->length <= limit);
iovec = IOVEC_MAKE(s->buffer + s->length, limit - s->length); iovec = IOVEC_MAKE(s->buffer + s->length, limit - s->length);

View File

@ -7,7 +7,7 @@
# #
# Entries in this file show the compile time defaults. Local configuration # Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in # should be created by either modifying this file, or by creating "drop-ins" in
# the system.conf.d/ subdirectory. The latter is generally recommended. # the journald.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins. # Defaults can be restored by simply deleting this file and all drop-ins.
# #
# Use 'systemd-analyze cat-config systemd/journald.conf' to display the full config. # Use 'systemd-analyze cat-config systemd/journald.conf' to display the full config.

View File

@ -36,7 +36,11 @@ MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
BOOT_ROOT=${ENTRY_DIR_ABS%/$MACHINE_ID/$KERNEL_VERSION} BOOT_ROOT=${ENTRY_DIR_ABS%/$MACHINE_ID/$KERNEL_VERSION}
BOOT_MNT=$(stat -c %m $BOOT_ROOT) BOOT_MNT=$(stat -c %m $BOOT_ROOT)
ENTRY_DIR=${ENTRY_DIR_ABS#$BOOT_MNT} if [[ $BOOT_MNT == '/' ]]; then
ENTRY_DIR=$ENTRY_DIR_ABS
else
ENTRY_DIR=${ENTRY_DIR_ABS#$BOOT_MNT}
fi
if [[ $COMMAND == remove ]]; then if [[ $COMMAND == remove ]]; then
rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf" rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"

View File

@ -17,6 +17,7 @@
static int option_append(uint8_t options[], size_t size, size_t *offset, static int option_append(uint8_t options[], size_t size, size_t *offset,
uint8_t code, size_t optlen, const void *optval) { uint8_t code, size_t optlen, const void *optval) {
assert(options); assert(options);
assert(size > 0);
assert(offset); assert(offset);
if (code != SD_DHCP_OPTION_END) if (code != SD_DHCP_OPTION_END)
@ -165,7 +166,7 @@ int dhcp_option_append(DHCPMessage *message, size_t size, size_t *offset,
} else if (r == -ENOBUFS && use_sname) { } else if (r == -ENOBUFS && use_sname) {
/* did not fit, but we have more buffers to try /* did not fit, but we have more buffers to try
close the file array and move the offset to its end */ close the file array and move the offset to its end */
r = option_append(message->options, size, offset, SD_DHCP_OPTION_END, 0, NULL); r = option_append(message->file, sizeof(message->file), &file_offset, SD_DHCP_OPTION_END, 0, NULL);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -23,7 +23,7 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
} }
static void fuzz_client(const uint8_t *data, size_t size, bool is_information_request_enabled) { static void fuzz_client(const uint8_t *data, size_t size, bool is_information_request_enabled) {
_cleanup_(sd_event_unrefp) sd_event *e; _cleanup_(sd_event_unrefp) sd_event *e = NULL;
_cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL; _cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } }; struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };

View File

@ -307,6 +307,8 @@ tests += [
[['src/libsystemd/sd-device/test-sd-device.c']], [['src/libsystemd/sd-device/test-sd-device.c']],
[['src/libsystemd/sd-device/test-device-util.c']],
[['src/libsystemd/sd-device/test-sd-device-monitor.c']], [['src/libsystemd/sd-device/test-sd-device-monitor.c']],
] ]

View File

@ -69,7 +69,7 @@ struct sd_device {
char *id_filename; char *id_filename;
uint64_t usec_initialized; usec_t usec_initialized;
mode_t devmode; mode_t devmode;
uid_t devuid; uid_t devuid;

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once #pragma once
#include "sd-device.h"
#define FOREACH_DEVICE_PROPERTY(device, key, value) \ #define FOREACH_DEVICE_PROPERTY(device, key, value) \
for (key = sd_device_get_property_first(device, &(value)); \ for (key = sd_device_get_property_first(device, &(value)); \
key; \ key; \

View File

@ -178,13 +178,12 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
/* all 'devices' require an 'uevent' file */ /* all 'devices' require an 'uevent' file */
path = strjoina(syspath, "/uevent"); path = strjoina(syspath, "/uevent");
r = access(path, F_OK); if (access(path, F_OK) < 0) {
if (r < 0) {
if (errno == ENOENT) if (errno == ENOENT)
/* this is not a valid device */ /* this is not a valid device */
return -ENODEV; return -ENODEV;
return log_debug_errno(errno, "sd-device: %s does not have an uevent file: %m", syspath); return log_debug_errno(errno, "sd-device: cannot access uevent file for %s: %m", syspath);
} }
} else { } else {
/* everything else just needs to be a directory */ /* everything else just needs to be a directory */
@ -246,72 +245,69 @@ _public_ int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum)
} }
_public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname) { _public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname) {
char *name, *syspath; char syspath[PATH_MAX], *name;
size_t len = 0;
assert_return(ret, -EINVAL); assert_return(ret, -EINVAL);
assert_return(subsystem, -EINVAL); assert_return(subsystem, -EINVAL);
assert_return(sysname, -EINVAL); assert_return(sysname, -EINVAL);
assert_return(strlen(sysname) < PATH_MAX - strlen("/sys/bus/"), -ENAMETOOLONG);
if (streq(subsystem, "subsystem")) { if (streq(subsystem, "subsystem")) {
syspath = strjoina("/sys/subsystem/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/subsystem/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/bus/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/bus/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/class/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/class/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
} else if (streq(subsystem, "module")) { } else if (streq(subsystem, "module")) {
syspath = strjoina("/sys/module/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/module/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
} else if (streq(subsystem, "drivers")) { } else if (streq(subsystem, "drivers")) {
char subsys[PATH_MAX]; const char *subsys, *sep;
char *driver;
strscpy(subsys, sizeof(subsys), sysname); sep = strchr(sysname, ':');
driver = strchr(subsys, ':'); if (sep && sep[1] != '\0') { /* Require ":" and something non-empty after that. */
if (driver) { subsys = memdupa_suffix0(sysname, sep - sysname);
driver[0] = '\0';
driver++;
syspath = strjoina("/sys/subsystem/", subsys, "/drivers/", driver); if (snprintf_ok(syspath, sizeof syspath, "/sys/subsystem/%s/drivers/%s", subsys, sep + 1) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/bus/", subsys, "/drivers/", driver); if (snprintf_ok(syspath, sizeof syspath, "/sys/bus/%s/drivers/%s", subsys, sep + 1) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
} }
} }
/* translate sysname back to sysfs filename */ /* translate sysname back to sysfs filename */
name = strdupa(sysname); name = strdupa(sysname);
while (name[len] != '\0') {
if (name[len] == '/')
name[len] = '!';
len++; for (size_t i = 0; name[i]; i++)
} if (name[i] == '/')
name[i] = '!';
syspath = strjoina("/sys/subsystem/", subsystem, "/devices/", name); if (snprintf_ok(syspath, sizeof syspath, "/sys/subsystem/%s/devices/%s", subsystem, name) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/bus/", subsystem, "/devices/", name); if (snprintf_ok(syspath, sizeof syspath, "/sys/bus/%s/devices/%s", subsystem, name) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/class/", subsystem, "/", name); if (snprintf_ok(syspath, sizeof syspath, "/sys/class/%s/%s", subsystem, name) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/firmware/", subsystem, "/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/firmware/%s/%s", subsystem, sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
return -ENODEV; return -ENODEV;
@ -625,7 +621,7 @@ _public_ int sd_device_new_from_device_id(sd_device **ret, const char *id) {
struct ifreq ifr = {}; struct ifreq ifr = {};
int ifindex; int ifindex;
r = ifr.ifr_ifindex = parse_ifindex(&id[1]); r = ifr.ifr_ifindex = parse_ifindex(id + 1);
if (r < 0) if (r < 0)
return r; return r;
@ -654,18 +650,15 @@ _public_ int sd_device_new_from_device_id(sd_device **ret, const char *id) {
} }
case '+': { case '+': {
char subsys[PATH_MAX]; const char *subsys, *sep;
char *sysname;
(void) strscpy(subsys, sizeof(subsys), id + 1); sep = strchr(id + 1, ':');
sysname = strchr(subsys, ':'); if (!sep || sep - id - 1 > NAME_MAX)
if (!sysname)
return -EINVAL; return -EINVAL;
sysname[0] = '\0'; subsys = memdupa_suffix0(id + 1, sep - id - 1);
sysname++;
return sd_device_new_from_subsystem_sysname(ret, subsys, sysname); return sd_device_new_from_subsystem_sysname(ret, subsys, sep + 1);
} }
default: default:
@ -1444,10 +1437,10 @@ _public_ int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *u
if (!device->is_initialized) if (!device->is_initialized)
return -EBUSY; return -EBUSY;
if (!device->usec_initialized) if (device->usec_initialized == 0)
return -ENODATA; return -ENODATA;
now_ts = now(clock_boottime_or_monotonic()); now_ts = now(CLOCK_MONOTONIC);
if (now_ts < device->usec_initialized) if (now_ts < device->usec_initialized)
return -EIO; return -EIO;
@ -1895,10 +1888,11 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
return r; return r;
path = prefix_roota(syspath, sysattr); path = prefix_roota(syspath, sysattr);
r = lstat(path, &statbuf); if (lstat(path, &statbuf) < 0) {
if (r < 0) {
int k; int k;
r = -errno;
/* remember that we could not access the sysattr */ /* remember that we could not access the sysattr */
k = device_cache_sysattr_value(device, sysattr, NULL); k = device_cache_sysattr_value(device, sysattr, NULL);
if (k < 0) if (k < 0)

View File

@ -0,0 +1,30 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "device-util.h"
#include "tests.h"
static void test_log_device_full(void) {
int r;
log_info("/* %s */", __func__);
for (int level = LOG_ERR; level <= LOG_DEBUG; level++) {
log_device_full(NULL, level, "test level=%d: %m", level);
r = log_device_full_errno(NULL, level, EUCLEAN, "test level=%d errno=EUCLEAN: %m", level);
assert_se(r == -EUCLEAN);
r = log_device_full_errno(NULL, level, 0, "test level=%d errno=0: %m", level);
assert_se(r == 0);
r = log_device_full_errno(NULL, level, SYNTHETIC_ERRNO(ENODATA), "test level=%d errno=S(ENODATA): %m", level);
assert_se(r == -ENODATA);
}
}
int main(int argc, char **argv) {
test_setup_logging(LOG_INFO);
test_log_device_full();
return 0;
}

View File

@ -707,9 +707,9 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
/* Note that the glibc fallocate() fallback is very /* Note that the glibc fallocate() fallback is very
inefficient, hence we try to minimize the allocation area inefficient, hence we try to minimize the allocation area
as we can. */ as we can. */
r = posix_fallocate(f->fd, old_size, new_size - old_size); r = posix_fallocate_loop(f->fd, old_size, new_size - old_size);
if (r != 0) if (r < 0)
return -r; return r;
f->header->arena_size = htole64(new_size - old_header_size); f->header->arena_size = htole64(new_size - old_header_size);

View File

@ -88,7 +88,7 @@ static void patch_realtime(
} }
static int journal_file_empty(int dir_fd, const char *name) { static int journal_file_empty(int dir_fd, const char *name) {
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
struct stat st; struct stat st;
le64_t n_entries; le64_t n_entries;
ssize_t n; ssize_t n;

View File

@ -1860,7 +1860,7 @@ static int add_current_paths(sd_journal *j) {
* treat them as fatal. */ * treat them as fatal. */
ORDERED_HASHMAP_FOREACH(f, j->files) { ORDERED_HASHMAP_FOREACH(f, j->files) {
_cleanup_free_ char *dir; _cleanup_free_ char *dir = NULL;
int r; int r;
dir = dirname_malloc(f->path); dir = dirname_malloc(f->path);

View File

@ -775,7 +775,7 @@ _public_ int sd_get_sessions(char ***sessions) {
} }
_public_ int sd_get_uids(uid_t **users) { _public_ int sd_get_uids(uid_t **users) {
_cleanup_closedir_ DIR *d; _cleanup_closedir_ DIR *d = NULL;
struct dirent *de; struct dirent *de;
int r = 0; int r = 0;
unsigned n = 0; unsigned n = 0;

View File

@ -447,7 +447,7 @@ int sd_rtnl_message_new_neigh(sd_netlink *rtnl, sd_netlink_message **ret, uint16
return r; return r;
if (nlmsg_type == RTM_NEWNEIGH) if (nlmsg_type == RTM_NEWNEIGH)
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_APPEND; (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
ndm = NLMSG_DATA((*ret)->hdr); ndm = NLMSG_DATA((*ret)->hdr);

View File

@ -535,7 +535,7 @@ int vconsole_convert_to_x11(Context *c) {
int find_converted_keymap(const char *x11_layout, const char *x11_variant, char **new_keymap) { int find_converted_keymap(const char *x11_layout, const char *x11_variant, char **new_keymap) {
const char *dir; const char *dir;
_cleanup_free_ char *n; _cleanup_free_ char *n = NULL;
if (x11_variant) if (x11_variant)
n = strjoin(x11_layout, "-", x11_variant); n = strjoin(x11_layout, "-", x11_variant);

View File

@ -457,7 +457,7 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
(void) locale_update_system_manager(c, sd_bus_message_get_bus(m)); (void) locale_update_system_manager(c, sd_bus_message_get_bus(m));
if (settings) { if (settings) {
_cleanup_free_ char *line; _cleanup_free_ char *line = NULL;
line = strv_join(settings, ", "); line = strv_join(settings, ", ");
log_info("Changed locale to %s.", strnull(line)); log_info("Changed locale to %s.", strnull(line));

View File

@ -485,7 +485,7 @@ int config_parse_n_autovts(
static int vt_is_busy(unsigned vtnr) { static int vt_is_busy(unsigned vtnr) {
struct vt_stat vt_stat; struct vt_stat vt_stat;
int r; int r;
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
assert(vtnr >= 1); assert(vtnr >= 1);

View File

@ -1371,7 +1371,7 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
} }
static int flush_devices(Manager *m) { static int flush_devices(Manager *m) {
_cleanup_closedir_ DIR *d; _cleanup_closedir_ DIR *d = NULL;
assert(m); assert(m);
@ -2068,7 +2068,7 @@ static int update_schedule_file(Manager *m) {
m->scheduled_shutdown_type); m->scheduled_shutdown_type);
if (!isempty(m->wall_message)) { if (!isempty(m->wall_message)) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = cescape(m->wall_message); t = cescape(m->wall_message);
if (!t) { if (!t) {

View File

@ -266,7 +266,7 @@ int session_save(Session *s) {
fprintf(f, "DISPLAY=%s\n", s->display); fprintf(f, "DISPLAY=%s\n", s->display);
if (s->remote_host) { if (s->remote_host) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_host); escaped = cescape(s->remote_host);
if (!escaped) { if (!escaped) {
@ -278,7 +278,7 @@ int session_save(Session *s) {
} }
if (s->remote_user) { if (s->remote_user) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_user); escaped = cescape(s->remote_user);
if (!escaped) { if (!escaped) {
@ -290,7 +290,7 @@ int session_save(Session *s) {
} }
if (s->service) { if (s->service) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->service); escaped = cescape(s->service);
if (!escaped) { if (!escaped) {
@ -302,7 +302,7 @@ int session_save(Session *s) {
} }
if (s->desktop) { if (s->desktop) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->desktop); escaped = cescape(s->desktop);
if (!escaped) { if (!escaped) {

View File

@ -268,8 +268,8 @@ static int manager_enumerate_seats(Manager *m) {
s = hashmap_get(m->seats, de->d_name); s = hashmap_get(m->seats, de->d_name);
if (!s) { if (!s) {
if (unlinkat(dirfd(d), de->d_name, 0) < 0) if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning("Failed to remove /run/systemd/seats/%s: %m", log_warning_errno(errno, "Failed to remove /run/systemd/seats/%s: %m",
de->d_name); de->d_name);
continue; continue;
} }

Some files were not shown because too many files have changed in this diff Show More