Commit Graph

45200 Commits

Author SHA1 Message Date
Mike Yuan
d708bb7c02 systemctl-enable: warn if disabled/masked units has active triggering units
Closes #311
2023-09-28 05:24:51 +08:00
Mike Yuan
0b675f97d6 systemctl-start: suppress the triggering unit warning when --no-warn 2023-09-28 05:24:51 +08:00
Mike Yuan
002db03f54 systemctl: clean up check_triggering_units
Preparation for #311
2023-09-28 05:24:51 +08:00
Mike Yuan
6ea32f61f3 systemctl: make unit_is_masked always query manager 2023-09-28 05:24:51 +08:00
Mike Yuan
c36c81e467 systemctl: don't duplicate string needlessly 2023-09-28 05:14:42 +08:00
Mike Yuan
1f998158a9 systemctl: reflect that statically enabled units can be in .upholds/
Follow-up for 38f901791f
2023-09-28 05:14:42 +08:00
Luca Boccassi
89e7b9652b Merge pull request #29353 from YHNdnzj/nft-followup
man/org.freedesktop.systemd1: add version info for NFTSet
2023-09-27 21:02:43 +01:00
Mike Yuan
05ae788d28 Merge pull request #29265 from YHNdnzj/sleep-util-refactor
sleep-util: split into three and first round of cleanups
2023-09-28 03:06:48 +08:00
Mike Yuan
95f7492875 core/unit: use RET_GATHER in one more function 2023-09-28 03:00:13 +08:00
Topi Miettinen
3bb48b19bd core: add user and group to NFTSet=
The benefit of using this setting is that user and group IDs, especially dynamic and random
IDs used by DynamicUser=, can be used in firewall configuration easily.

Example:

```
[Service]
NFTSet=user:inet:filter:serviceuser
```

Corresponding NFT rules:

```
table inet filter {
        set serviceuser {
                typeof meta skuid
        }
        chain service_output {
                meta skuid @serviceuser accept
                drop
        }
}
```

```
$ cat /etc/systemd/system/dunft.service
[Service]
DynamicUser=yes
NFTSet=user:inet:filter:serviceuser
ExecStart=/bin/sleep 1000

[Install]
WantedBy=multi-user.target
$ sudo nft list set inet filter serviceuser
table inet filter {
        set serviceuser {
                typeof meta skuid
                elements = { 64864 }
        }
}
$ ps -n --format user,group,pid,command -p `systemctl show dunft.service -P MainPID`
    USER    GROUP     PID COMMAND
   64864    64864   55158 /bin/sleep 1000
```
2023-09-27 18:10:11 +00:00
Topi Miettinen
dc7d69b3c1 core: firewall integration of cgroups with NFTSet=
New directive `NFTSet=` provides a method for integrating dynamic cgroup IDs
into firewall rules with NFT sets. The benefit of using this setting is to be
able to use control group as a selector in firewall rules easily and this in
turn allows more fine grained filtering. Also, NFT rules for cgroup matching
use numeric cgroup IDs, which change every time a service is restarted, making
them hard to use in systemd environment.

This option expects a whitespace separated list of NFT set definitions. Each
definition consists of a colon-separated tuple of source type (only "cgroup"),
NFT address family (one of "arp", "bridge", "inet", "ip", "ip6", or "netdev"),
table name and set name. The names of tables and sets must conform to lexical
restrictions of NFT table names. The type of the element used in the NFT filter
must be "cgroupsv2". When a control group for a unit is realized, the cgroup ID
will be appended to the NFT sets and it will be be removed when the control
group is removed.  systemd only inserts elements to (or removes from) the sets,
so the related NFT rules, tables and sets must be prepared elsewhere in
advance.  Failures to manage the sets will be ignored.

If the firewall rules are reinstalled so that the contents of NFT sets are
destroyed, command systemctl daemon-reload can be used to refill the sets.

Example:

```
table inet filter {
...
        set timesyncd {
                type cgroupsv2
        }

        chain ntp_output {
                socket cgroupv2 != @timesyncd counter drop
                accept
        }
...
}
```

/etc/systemd/system/systemd-timesyncd.service.d/override.conf
```
[Service]
NFTSet=cgroup:inet:filter:timesyncd
```

```
$ sudo nft list set inet filter timesyncd
table inet filter {
        set timesyncd {
                type cgroupsv2
                elements = { "system.slice/systemd-timesyncd.service" }
        }
}
```
2023-09-27 18:10:11 +00:00
Lennart Poettering
174e8e9897 Merge pull request #29345 from poettering/measured-uki-condition
pid1: introduce ConditionSecurity=measured-uki
2023-09-27 16:39:46 +02:00
Mike Yuan
563ef8f950 sleep-config: add explanatory comment on "modes" 2023-09-27 21:48:40 +08:00
Mike Yuan
087a25d2ca sleep-config: several cleanups
* Rename free_sleep_config to sleep_config_free
* Rearrange functions
* Make SleepConfig.modes and .states only contain
  operations that needs configuration
* Add missing assert
2023-09-27 21:48:39 +08:00
Mike Yuan
f3afe9dc20 sleep/battery-capacity: rearrange functions 2023-09-27 21:48:39 +08:00
Mike Yuan
7f88eee935 sleep/battery-capacity: drop unused error-handling 2023-09-27 21:48:39 +08:00
Mike Yuan
fbc1dbf296 sleep/battery-capacity: don't report we have trip alarm if no battery is found 2023-09-27 21:48:39 +08:00
Mike Yuan
54d7fcc6a3 sleep-util: split into sleep-config and hibernate-util 2023-09-27 21:48:39 +08:00
Mike Yuan
7d769198e0 sleep-util: split battery-capacity into sleep/
This is only used by sleep.c. Let's start shrinking down
the "mixed" sleep-util.
2023-09-27 21:48:39 +08:00
Mike Yuan
43309f14d9 sleep: rebreak lines in check_wakeup_type 2023-09-27 21:48:39 +08:00
Mike Yuan
1482feda01 sleep-util: move check_wakeup_type to sleep/sleep 2023-09-27 21:48:39 +08:00
Luca Boccassi
93bd6e3714 Merge pull request #29134 from nabijaczleweli/short-iso-timestamp
journalctl -o short-iso[-precise]: timezone as +02:00 instead of +0200
2023-09-27 14:42:27 +01:00
Zbigniew Jędrzejewski-Szmek
e071384dc5 Merge pull request #29296 from yuwata/sd-journal-several-cleanups-for-boot-id 2023-09-27 14:56:48 +02:00
Luca Boccassi
578840bdf9 Merge pull request #29296 from keszybz/make-cryptsetup-offical-and-add-docs
Make cryptsetup offical and add docs
2023-09-27 13:31:11 +01:00
Lennart Poettering
c24f9f5371 efi-loader: add caching to efi_measured_uki()
EFI variable access is slow, hence let's avoid it if there's no need.
Let's cache the result of efi_measured_uki() so that we don't have to go
to the EFI variables each time.

This only caches in the yes/no case. If we encounter an error we don't
cache, so that we go to disk again.

This should optimize things a bit given we now have a bunch of services
which are conditioned with this at boot.
2023-09-27 12:14:56 +02:00
Lennart Poettering
340d979af3 condition: add ConditionSecurity=measured-uki
We have various services that should only run in a measured UKI
environment. Let's add an explicit high-level check for that.
2023-09-27 12:10:46 +02:00
Lennart Poettering
be8f478c0f efi-loader: rename efi_stub_measured() → efi_measured_uki()
Let's say "uki" rather than "stub", since that is just too generic, and
we shouldn't limit us to our own stub anyway, but generally define a
concept of a "measured UKI", which is a UKI that measures its part to
PCR 11.

This is mostly preparation for exposing this check to the user via
ConditionSecurity=.
2023-09-27 11:51:13 +02:00
Susant Sahani
0ba8374bb8 ndisc: Also set link hoplimit
The per route hop limit does not place the hop limit in the IPv6 header.
https://github.com/systemd/systemd/issues/28437#issuecomment-1711055181
2023-09-27 11:05:15 +02:00
Daan De Meyer
3bd337a084 network: Rename json_append_one() and move to json.h 2023-09-26 19:01:34 +01:00
Daan De Meyer
418a498777 journal: Stop trying to open runtime journal once flushed
Once we've flushed the runtime journal to /var, stop trying to open
it since that will just fail with ENOENT all the time.
2023-09-26 19:01:07 +01:00
Jan Janssen
90461ef56f meson: Fix version script handling
Build targets should have a link dependency on the version scripts they
use. This also uses absolute paths in anticipation for meson 1.3
needlessly deprecating file to string conversions.
2023-09-26 19:41:53 +02:00
huyubiao
b53a80966e systemd-hwdb: fix unsigned and signed comparison problem
...
uint8_t c;
struct trie_node *child;

for (p = 0; (c = trie->strings->buf[node->prefix_off + p]); p++) {
        _cleanup_free_ struct trie_node *new_child = NULL;
        _cleanup_free_ char *s = NULL;
        ssize_t off;
if (c == search[i + p])
        continue;
...
When '®' is present in search, c is 194, search[i + p] is -62, c is not equal to search[i + p], but c should be equal to search[i + p].
2023-09-26 17:38:16 +01:00
Zbigniew Jędrzejewski-Szmek
a1ca52c2da meson: add comments to compat symlinks 2023-09-26 17:03:26 +02:00
Zbigniew Jędrzejewski-Szmek
fb8d67cd34 meson: move systemd-cryptsetup to /usr/bin
This was requested, though I think an issue was never filed. If people are
supposed to invoke it, even for testing, then it's reasonable to make it
"public".
2023-09-26 17:03:26 +02:00
Zbigniew Jędrzejewski-Szmek
5bae80bd44 cryptsetup: fail with error if extraneous arguments are specified
So far the program would silently ignore those… I think it's better to fail.
2023-09-26 16:21:31 +02:00
Zbigniew Jędrzejewski-Szmek
166015faf5 cryptsetup: add parse_argv() and implement --version
All public programs are expected to have that. The --help output is adjusted to
follow the usual style (highlighting, listing of options). The OPTIONS
positional argument is renamed to "CONFIG", because we now also have "OPTIONS…"
to describe the non-positional options.
2023-09-26 16:20:29 +02:00
Zbigniew Jędrzejewski-Szmek
4cc8e81db5 cryptenroll: align tables 2023-09-26 15:35:06 +02:00
наб
0693e6b246 journalctl -o short-iso[-precise]: timezone as +02:00 instead of +0200 2023-09-26 15:24:13 +02:00
Lennart Poettering
1617424ce7 udev: raise RLIMIT_NOFILE as high as we can
We might need a lot of fds on large systems, hence raise RLIMIT_NOFILE
to what the service manager allows us, which is quite a lot these days.

udev already sets FORK_RLIMIT_NOFILE_SAFE when forking of chilren, thus
ensuring that forked off processes get their RLIMIT_NOFILE soft limit
reset to 1K for compat with crappy old select().

Replaces: #29298
Fixes: #28583
2023-09-26 13:01:02 +02:00
Lennart Poettering
7af33700e6 varlink: remove duplicate varlink_clear_current() 2023-09-26 12:59:24 +02:00
Mike Yuan
fe3d33c140 core/service: log the next restart usec only when we're arming timer
service_restart_usec_next() is also called when querying
'RestartUSecNext' dbus property. Let's avoid the redundant
logging triggered every time user does a 'systemctl status'.
2023-09-26 12:59:15 +08:00
Yu Watanabe
bb83c7c633 test: add test case that journal file with unreferenced _BOOT_ID data
For issue #29275.
2023-09-26 13:26:22 +09:00
Yu Watanabe
304cb08f84 sd-journal: always fallback to find entry by realtime
Consider the following situation:
- There are two journal files (x and y), that contains entries for two boots (X and Y).
- The journal file x contains entries of the boot X, and y contains
  entries of Y.
- Nevertheless x does not contains entries of boot Y, it contains
  the _BOOT_ID= data object of boot Y. Of course, the data object is not
  referenced by any entries in the journal file x.

In such situation, when the current location of sd_journal is the head
of journal y, that is, the first entry of the boot Y,
sd_journal_previous() failed without this change, and
'journalctl --boot -NUM' for boot X failed.

Fixes #29275.
2023-09-26 13:26:22 +09:00
Yu Watanabe
7c1784db83 test: add tests for journal_find_boot_by_offset() and friends 2023-09-26 13:26:22 +09:00
Yu Watanabe
0141b2143d logs-show: use sd_journal_step_one() 2023-09-26 13:26:22 +09:00
Yu Watanabe
8081939d1d logs-show: move journal_find_boot_by_offset() and friends from journalctl.c 2023-09-26 13:26:22 +09:00
Yu Watanabe
f5257facb9 journalctl: several cleanups for find_boot_by_offset()/_by_id()
- their names are prefixed with "journal_",
- make them not directly use global variables,
- simplifies the loop counter in find_boot_by_offset().
2023-09-26 13:26:22 +09:00
Yu Watanabe
1eede15851 sd-journal: refuse to write entry without boot ID
To make journal entries always contain valid boot ID.
2023-09-26 13:26:22 +09:00
Yu Watanabe
b761ae0fca sd-journal: boot_id is always non-NULL
The two callers of journal_file_append_entry_internal() always pass
non-NULL boot ID.
2023-09-26 13:26:22 +09:00
Yu Watanabe
6ea51363c8 sd-journal: also verify tail_entry_boot_id and friends in journal_file_verify_header()
Then, we can drop the redundant check in journal_file_read_tail_timestamp().
2023-09-26 13:26:22 +09:00