1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00
Commit Graph

49285 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
cd621954ed rpm: order sysctl/sysusers/tmpfiles execution before package scriptlets
P>1000000 is *before* "normal" scriptlets, P<1000000 is *after*. I think it
makes sense to do stuff like execution of sysctl/sysusers/tmpfiles configuration
before package scriptlets. I think that was the intent, but a single digit got
dropped ;(

Also, let's reorder the scriptlets in the file to match execution order, to
make it easier to see what is going on.

Most of those may happen in any order, but there are some exceptions:
tmpfiles should be after sysusers,
udevadm --reload should be after hwdb.
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
b492db99d6 rpm: simplify daemon-reload trigger
The trigger was initially written to use %transfiletriggerun instead
of %transfiletriggerpostun because the latter would not fire. It turned
out to a buffer overread in rpm that since has been long fixed:
https://bugzilla.redhat.com/show_bug.cgi?id=1284645
f6521c50f6
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
addf2c0ecd rpm: sync the shell version of triggers.systemd with the lua version
Note that this goes both ways: in particular the lua version had udev
scriptlets in the wrong package, fixed in
3c9433d7cf.

Add missing "|| :" so the scriptlets never fail.
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
8e5658010d rpm: pull in the alternative trigger implementation in sh
From https://src.fedoraproject.org/rpms/systemd/blob/master/f/triggers.systemd.

In 12dde791d5 scriptlets were converted to lua.
This is not only faster and cleaner, but also avoids a nasty dependency loop:
rpm implements the lua scripting internally, so we don't need a working shell
for the scriplets. This is nice and all, but unfortunately ostree wants to
capture scriptlets and execute them at a later time and does not support lua.
So in Fedora we ended up with a revert back to a shell-based implementation
[1]. At the time I hoped this would only be a temporary workaround, but three
years later I think it's fair to assume that this will not happen any time
soon. But carrying the upstream lua version and the downstream sh version is
error prone. So let's import the other version into our tree too so that they
can be kept in sync.

[1] 8e6b39457b
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
2a9b4bbe3e Move rpm stuff into a separate src/rpm/ directory
It is only of interest to rpm-based distros, we can move it out of src/core/
which is pretty busy.
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
c9615f7352 systemctl: add "reload-or-restart --marked"
This is almost equivalent to 'busctl call-method org.freedesktop.systemd1
/org/freedesktop/systemd1 org.freedesktop.systemd1.Manager EnqueueMarkedJobs',
but waits for the jobs to finish.
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
deaf4b863b systemctl: reduce scope of iterator variables 2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
cb31470f40 core: wrap long lines 2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
70666e28a1 core: add EnqueueMarkedJobs method to reload/restart marked units
We support two return types for methods that start jobs. EnqueueJob support the
full-monty mode with affected jobs. I didn't do this here, since it seems
unlikely to be used. In the common case there'd be a huge list of jobs and
affected jobs. EnqueueMarkedJobs() just returns a list of jobs that we can wait
upon.

The name of the method is generic in case we decide to add something other than
just reload/restart later on.

When errors occur, resource errors are treated as fatal, but for other error
types we queue up other jobs, and only return an error at the end. The
assumption is that the caller will ignore the result error anyway, so it's
better to try to reload/restart as much as possible.
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
0dd3c0907f core: allow Markers to be set using set-property 2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
95d1e21e90 core/dbus-unit: reduce scope of iterator variables 2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
ff68472a20 core: add Unit.Markers property
The property is never set by systemd, only reset after a stop or restart or
reload. It may externally be set to mark the unit for a later restart/reload.

I wasn't sure whether to configure the property only for the types where this
makes sense (Service, Swap, etc). But Restart() method is defined on the unit,
and also having this always under the same property name is more convenient.
2021-02-15 20:49:14 +01:00
Zbigniew Jędrzejewski-Szmek
8c2524c7fd core: pahole optimization of struct Unit
We had a lone 'bool job_running_timeout_set:1', which generated a hole. Let's
move things around a bit. The structure is a tiny bit smaller and has less
holes:
        /* size: 1192, cachelines: 19, members: 149 */
        /* sum members: 1175, holes: 3, sum holes: 11 */
        /* sum bitfield members: 27 bits, bit holes: 1, sum bit holes: 7 bits */
        /* bit_padding: 14 bits */
        /* last cacheline: 40 bytes */

        /* size: 1184, cachelines: 19, members: 149 */
        /* sum members: 1175, holes: 1, sum holes: 4 */
        /* sum bitfield members: 27 bits (3 bytes) */
        /* bit_padding: 13 bits */
        /* last cacheline: 32 bytes */
2021-02-12 11:59:59 +01:00
Zbigniew Jędrzejewski-Szmek
ef3fc326b9 manager: remove unnecessary conditional 2021-02-12 11:59:59 +01:00
Zbigniew Jędrzejewski-Szmek
9466ec13a5 core: add helper macros for deserialization
A helper function would seem more natural, but there are two reasons why a
macro is needed:
- many bool fields are bitfields, so we can't take a pointer, and using a macro
  allows us to avoid taking a pointer.
- we have a few diffent types (bool, uint64_t, FreezerState), and we can have
  type safety without specifying the type by using the macro.

This also makes the error messages more informative: they print the exact field
identifier that failed, which is more useful for debugging than a description.
2021-02-12 11:59:41 +01:00
Zbigniew Jędrzejewski-Szmek
2d3b784dfb core: split out a few funcs into unit-serialize.[ch]
Just a straightforward move and resulting include file adjustments.
2021-02-12 11:36:24 +01:00
Zbigniew Jędrzejewski-Szmek
41b88bb8ad sd-bus: standarize on NULL for empty signature in method calls
We would use sometimes "" and sometimes NULL. They are equivalent, so let's use
NULL everywhere, except for a two places in tests.
2021-02-12 11:36:24 +01:00
Zbigniew Jędrzejewski-Szmek
63ab06c4d2 sd-bus: extend sd_bus_message_read_strv() to paths and signatures
It's rather convenient to be able to read all three types with this function.
Strictly speaking this change is not fully compatible, in case someone was
relying on sd_bus_message_read_strv() returning an error for anything except
"as", but I hope nobody was doing that.
2021-02-12 11:36:24 +01:00
Yu Watanabe
fa7924db0b
Merge pull request #11484 from keszybz/udevadm-error-logs
Use real return codes in _from_string() functions
2021-02-11 03:17:47 +09:00
Frantisek Sumsal
2de908aead test: count call instructions as well
Binaries on the latest Arch Linux use `call` instructions instead of
`callq`, which breaks the ASan detection and eventually the image
building process (due to insufficient space).
2021-02-10 20:20:31 +03:00
Weblate (bot)
2c7bd14280
Translations update from Weblate (#18537)
Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
2021-02-11 00:55:41 +09:00
Frantisek Sumsal
58bc1735fe ci: build on Fedora ELN as well
ELN builds with a slightly different content set and RHEL-like options,
which should, theoretically, help a bit with RHEL stuff.
2021-02-10 16:34:22 +01:00
Yu Watanabe
9a67c080b0
Merge pull request #18506 from keszybz/fuzz-systemctl-parse-argv
Fuzzer for systemctl argline parsing
2021-02-11 00:29:22 +09:00
Lennart Poettering
bbe05f94f1
Merge pull request #18521 from poettering/coredumpctl-table
coredumpctl improvements (mostly about table formatting)
2021-02-10 15:58:56 +01:00
Zbigniew Jędrzejewski-Szmek
23ece765cc test-string-util: add missing comma
Coverity CID#1446368.
2021-02-10 14:47:00 +01:00
Zbigniew Jędrzejewski-Szmek
419076978c resolved: rework a few functions to return early on error
The implementation is a bit ugly because we set the output variable
twice. But we were already doing this on error, so this is not
significantly worse. Doing this allows us to avoid goto's, and the
compiler should be able to figure this out and only set once.
2021-02-10 14:47:00 +01:00
Zbigniew Jędrzejewski-Szmek
c706a52ac5 machinectl: write arg_* only after verifying the value 2021-02-10 14:47:00 +01:00
Zbigniew Jędrzejewski-Szmek
7211c853c2 tree-wide: propagate error code from _from_string() functions
Now that we know we have something useful, no need to make an answer up.
2021-02-10 14:46:59 +01:00
Zbigniew Jędrzejewski-Szmek
751db3b4cd Return -EINVAL from _from_string() functions
We'd return -1 (-EPERM), even though we have a general rule to use real errno
values. The particular case that caught my attention was:

$ sudo udevadm control -l asdf
Failed to parse log priority 'asdf': Operation not permitted

... but "git grep 'r =.*_from_string' src/" return 110 hits. Confusingly, some
of the _from_string functions already return a proper errno value, so not all
of those are broken, but probably quite a few.
2021-02-10 14:46:59 +01:00
Zbigniew Jędrzejewski-Szmek
2d93c20e5f tree-wide: use -EINVAL for enum invalid values
As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617.

This does not touch anything exposed in src/systemd. Changing the defines there
would be a compatibility break.

Note that tests are broken after this commit. They will be fixed in the next one.
2021-02-10 14:46:59 +01:00
Zbigniew Jędrzejewski-Szmek
71c163c9fa udev: make sure UdevBuiltinCommand is properly converted 2021-02-10 14:46:59 +01:00
Zbigniew Jędrzejewski-Szmek
38d1e12063 sd-bus: drop some bitfields in sd_bus_slot
A hole was/is present after the booleans, so changing them to be one byte each
doesn't change the structure size (122 bits on amd64). If we add more stuff
later, it might make sense to turn some of those into bitfields again. For now,
let's take the easy route. EINVAL fits into type now.

Code size it minimally reduced:
-rwxrwxr-x 1 zbyszek zbyszek 4109792 Feb 10 14:00 build/libsystemd.so.0.30.0
-rwxrwxr-x 1 zbyszek zbyszek 4109712 Feb 10 14:01 build/libsystemd.so.0.30.0
2021-02-10 14:46:59 +01:00
Lennart Poettering
8dfc2beb57 github: expressly ask for logs in github issue template
Apparently it's not obvious that logs are a good thing to provide, hence
let's explicitly ask for them.
2021-02-10 14:43:16 +01:00
Zbigniew Jędrzejewski-Szmek
399f74c79d sd-netlink: pahole optimization of sd_netlink_slot
By rearranging the fields, we can avoid one of the holes (on amd64).
By adding more space for .type, -EINVAL can be used as a value later on.
The structure is reduced from 96 to 88 bytes (on amd64).

Text size is also smaller:
-rwxrwxr-x 1 zbyszek zbyszek 4109832 Feb  9 19:50 build/libsystemd.so.0.30.0
-rwxrwxr-x 1 zbyszek zbyszek 4109792 Feb  9 19:51 build/libsystemd.so.0.30.0
2021-02-10 14:43:10 +01:00
Zbigniew Jędrzejewski-Szmek
4d24463211 shared/json: make JsonVariant.type field wider
pahole shows that this doesn't make a difference, but we can fit -EINVAL
into .type without warnings.
2021-02-10 14:43:10 +01:00
Zbigniew Jędrzejewski-Szmek
755c6d5923 sd-event: drop one bitfield from sd_event_source
pahole analysis confirms that the structure size does not change (there
was/is a hole after the sequence of bitfields anyway).
2021-02-10 14:43:10 +01:00
Zbigniew Jędrzejewski-Szmek
ec08f27069 core: drop bitfields in Manager object
Every bitfield may make the object a little smaller, but requires additional
code when accessing the field. So it only makes sense in objects that are
created in many many copies. The Manager is pretty much a singleton.

-rwxrwxr-x 1 zbyszek zbyszek 4443840 Feb  9 16:14 build/systemd
-rwxrwxr-x 1 zbyszek zbyszek 4442552 Feb  9 16:42 build/systemd

We save 1288 bytes of code by "wasting" a few bytes on storage. (The speed
advantages are probably more important, but harder to measure…)
2021-02-10 14:43:10 +01:00
Zbigniew Jędrzejewski-Szmek
61b315de9b Add comma in structured initialization in a few places
It just looks nicer…
2021-02-10 14:43:10 +01:00
Zbigniew Jędrzejewski-Szmek
170d40260b core: do not initialize variable which is unconditionally set below 2021-02-10 14:43:10 +01:00
Zbigniew Jędrzejewski-Szmek
3c3cd61e75 test-tables: make the assert more readable
Doing it all in one line and with negation in front seemed like a good
idea at some point, but I think it is vastly easier to understand when
it is split out a bit.
2021-02-10 14:43:10 +01:00
Zbigniew Jędrzejewski-Szmek
b357fe57b2 test-tables: fix warning about NULL used in printf
With the simplified asserts, newer gcc is able to (correctly) figure
out that NULL was being passed.
2021-02-10 14:43:10 +01:00
Lennart Poettering
505061bb4f clock-util: modernize settimeofday() timezone calls
Let's use structured initialization, and avoid the weird `tv_null`
indirection.

No changes in behaviour, just some clean-ups.
2021-02-10 14:14:37 +01:00
Luca Boccassi
8aa35d09d3 Fix coverity warning in test-string-util.c
CID 1446368:  Incorrect expression  (MISSING_COMMA)
2021-02-10 13:22:06 +01:00
Lennart Poettering
4016281c4f coredumpctl: include coredump size in output
This improves the output of the "list" and "info" verbs and adds
coredump size information to the output.

For doing that a common helper function is added that analyzes the
coredump file on disk.
2021-02-10 12:22:21 +01:00
Lennart Poettering
bbd86b72f1 man: document new coredumpctl features 2021-02-10 12:22:03 +01:00
Lennart Poettering
0689cfdb83 coredumpctl: modernize table output
Let's use our table formatter for generating the coredump table. Bring
support up to our current standards, with a bit of color, JSON output
and so on.

Also adds supports for setting a max for the number of lines to
generate. (with the new -n switch)

The existing -1 switch now becomes a synonym for "-n 1 --reverse"

Fixes: #3271
2021-02-10 12:21:59 +01:00
Lennart Poettering
56909de015 format-table: when generating json, synthesize "null" for invalid ifindex
This matches what we do for other cell types that have an invalid value.
2021-02-10 12:21:56 +01:00
Lennart Poettering
a7273eaf32 format-table: make UID/GID/PID fields first class citizens + add signal cell type
This way we can display invalid UIDs/GIDs/PIDs as n/a while still
storing them as is.

Also, let's add a new cell type for unix signal, that is stored as
integer, but displayed as signal name string.
2021-02-10 12:21:17 +01:00
Lennart Poettering
77552b9520 analyze: slightly reword PrivatTmp= message
Apparently there way confusion about "does not apply". Let's say "is not
appropriate".

Fixes: #13095
2021-02-10 12:14:29 +01:00
Lennart Poettering
228f5ed3a4
Merge pull request #18518 from poettering/inhibit-limit-columns
put a width limit on the "systemd-inhibit --list" table
2021-02-09 17:14:25 +01:00