Commit Graph
8191 Commits
Author SHA1 Message Date
David Tardon ca46756cd8 varlink: add generic impl. of io.systemd.varlink.Ping() 2023-10-31 12:49:17 +01:00
David Tardon 4ffe0aedf9 varlink: define interface io.systemd.service 2023-10-31 12:49:16 +01:00
Yu Watanabe 758a3aeb4c dissect: reenable automatic removal before trying again
The device node may be different from we want to activate, and we may
try to activate different device in the subsequent loop. In such case,
we should enable the automatic removal for the unexpected device.
Otherwise, it will not be removed even when not necessary anymore.
2023-10-31 10:30:30 +00:00
Yu Watanabeandcunshunxia 0e7a7cd4e9 locale,firstboot: add headers to vconsole.conf
Closes #29717.
Replaces #29760.

Co-authored-by: cunshunxia <cunshunxia@tencent.com>
2023-10-31 17:15:21 +09:00
Yu Watanabe f155cb6d75 env-util: make write_env_file() optionally take headers
This also makes write_env_file() and write_env_file_label() optionally
take dir_fd, and drop write_env_file_at().

Preparation for later commits.
2023-10-31 17:15:21 +09:00
Yu Watanabe 678fbf7eef tests: make log_tests_skipped() and friend accept format string 2023-10-31 14:46:38 +09:00
Mike Yuan 77bd39385e sleep-config: allow setting empty HibernateMode= (use kernel default)
Both sleep_mode_supported and write_mode support this,
but parse_sleep_config currently prohibits this - it always
uses our default value if user specifies HibernateMode=<empty>.
2023-10-30 11:34:21 +00:00
Mike Yuan 6d468648b9 Merge pull request #29740 from YHNdnzj/sleep-round-four
sleep: make sure we clear HibernateLocation on all error paths
2023-10-28 17:53:54 +08:00
Anton Lundin 5629d4e29f tpm2: fix build failure without openssl 2023-10-27 13:54:10 +01:00
Mike Yuan e024cdd270 sleep: introduce sleep_operation_is_hibernation 2023-10-27 17:57:03 +08:00
Lennart Poettering 7113640493 fd-uitl: rename PIPE_EBADF → EBADF_PAIR, and add EBADF_TRIPLET
We use it for more than just pipe() arrays. For example also for
socketpair(). Hence let's give it a generic name.

Also add EBADF_TRIPLET to mirror this for things like
stdin/stdout/stderr arrays, which we use a bunch of times.
2023-10-26 22:30:42 +02:00
Daan De Meyer 7b794ba019 mkfs-util: Use actual UID/GID in protofile instead of root 2023-10-26 19:10:31 +01:00
Luca Boccassi c895d047e3 Merge pull request #29720 from poettering/cgls-fix-delegate
cgls: fix display of delegation flag
2023-10-26 14:28:28 +01:00
Lennart Poettering 34931384ac varlink: make sure 'incomplete' bool is nullable
This field is optional, it only makes sense for user records that
actually have a privileged part to set.
2023-10-26 11:52:07 +01:00
Lennart Poettering 001feb125b cgroup-show: rework cgroup tree display to operate by fd only
This restores display of the "delegate" flag of a cgroup. Previously we
erroneously passed a full fs path where a cgroup path was expected (the
difference being the /sys/fs/cgroup/ prefix), which meant we never read
the xattr properly. Let's fix that by simply operating by fd on the
cgroup and using it for all operations.
2023-10-26 09:28:29 +02:00
Yu Watanabe b9541abdb9 dissect: insert missing space 2023-10-26 12:16:12 +09:00
Luca Boccassi 4c46ece4c8 Merge pull request #29698 from poettering/tpm2-no-best-pcr
tpm2: minor tweaks
2023-10-25 13:18:03 +01:00
Luca Boccassi 7470e161cf Merge pull request #29553 from keszybz/analyze-cat-config-tldr
analyze/cat-config: add switch to print only "interesting" parts of conffiles
2023-10-25 09:53:19 +01:00
Lennart Poettering 980a5aeffa tpm2-util: add line breaks in compound struct init, like we usually do 2023-10-25 10:33:29 +02:00
Lennart Poettering 4af7f27aeb tpm2-util: add line breaks in compound struct init, like we usually do 2023-10-25 09:29:20 +02:00
Lennart Poettering 3ee5e9d5f3 tpm2-util: dont't find best PCR bank if no PCRs are selected whatsoever
This will otherwise just yield weird log message, complaining that PCRs
were not initialized. But which PCRs if we have none selected?
2023-10-25 09:29:20 +02:00
Lennart Poettering 83d5bbaf1b mount-util: add one more const 2023-10-25 15:53:10 +09:00
Luca Boccassi 648fbfe621 Merge pull request #29677 from keszybz/rewinddir-alternative-fix
Rewind dir fd before using it for cleanup
2023-10-24 19:41:02 +01:00
Mike Yuan 828ad30470 sleep-config: make hybrid sleep always use 'suspend' disk mode
If user requests hybrid sleep, we should always use 'suspend'
disk mode. If that's not supported, let's correctly report it
so they can choose plain hibernation instead. HybridSleepMode=
serves no purpose in this case and should be removed.

Addresses https://github.com/systemd/systemd/pull/29681#discussion_r1369812785
2023-10-24 19:07:03 +02:00
Zbigniew Jędrzejewski-Szmek c04cec128f shared/pretty-print: skip redundant section headers with --tldr
If the same section appears consecutively in a given file, subsequent
occurenced are not printed.

[Slice]
Foo=bar
[Slice]   # this is not printed
Bar=bar

Requested in
https://github.com/systemd/systemd/pull/29553#pullrequestreview-1677310352.
2023-10-24 18:32:18 +02:00
Zbigniew Jędrzejewski-Szmek 1be6a5db21 tmpfiles: add --tldr
This is like --cat-config, but omits the comments and empty lines.
The name is incoungrous with --cat-config, but I don't see a nice way to
call it that wouldn't be annoyingly long.

pager_open() is moved to cat_config() to remove some lines from run().
2023-10-24 18:32:17 +02:00
Zbigniew Jędrzejewski-Szmek a9e6803582 shared/pretty-print: add highlighting 2023-10-24 18:24:12 +02:00
Zbigniew Jędrzejewski-Szmek 063c838206 analyze/cat-config: add switch to print only "interesting" parts of config files
When looking at configuration, often a user wants to suppress the comments and
just look at the parts that actually configure something, roughly equivalent to
  systemd-analyze cat-config … | rg -v '^(#|;|$)
This switch implements this natively, skipping lines that start with a comment
character or only contain whitespace.

For formats that have section headers, section headers are skipped, if only
followed by stuff that would be skipped. (The last section header is printed
when we're about to print some actual output.)

Note that the caller doesn't know if the format has headers or not. We do format
type detection in pretty-print.c. So the caller only specifies tldr=true|false, and
conf_files_cat() figures out if the format has headers and whether those should
be handled specially.

The comments that show the file name are always printed, even if all of the file
is suppressed.

This is a partial answer to the discussions in
https://github.com/systemd/systemd/pull/28919,
https://github.com/systemd/systemd/pull/29248. If the default config is shown in
config files, the user can conveniently use '--tldr' to show the relevant parts.
2023-10-24 15:59:34 +02:00
Zbigniew Jędrzejewski-Szmek e3b84b105e shared/copy: rewind dir fd before using it for cleanup
This seems to be the only place where rm_rf_children() is called with a
possibly used fd, which is then passed through to rm_rf_children_impl().

This also fixes #29606.
(Tested on Fedora rawhide with kernel 6.5.6-300.fc39.x86_64.)
2023-10-24 13:37:10 +02:00
Luca Boccassi e5cd8bc060 Merge pull request #29601 from yuwata/mmap-check-overflow
mmap: check offset and size more carefully
2023-10-24 12:20:04 +01:00
Mike Yuan fefddffa53 sleep-config: check sleep mode only when hibernation
With the previous change, this should only be used when
doing hibernation.
2023-10-23 23:12:27 +08:00
Mike Yuan 1f82c21dce sleep-config: remove HibernateState= & HybridSleepState=, restrict
SuspendState= not to include "disk"

I don't know why these existed in the first place, but as I
justified in the comments, it's simply not sensible to allow
HibernateState= or HybridSleepState= to take values other than
'disk'. So let's just remove those options. Also, SuspendState=
should not contain 'disk'.
2023-10-23 23:12:27 +08:00
Mike Yuan 080105d77a hibernate-util: add missing assertion 2023-10-23 23:12:27 +08:00
Zbigniew Jędrzejewski-Szmek 59ccbad65e Revert "rm-rf: Make sure we rewinddir() before readdir()"
This reverts commit 6bbb893b90.

Let's try a different approach where we make sure that all callers only pass in
a fd that is "clean", i.e. at offset 0. The majority of callers of this function
(both direct and indirect) pass a freshly-opened fd, so the rewind call is not
needed.
2023-10-23 13:56:38 +02:00
Luca Boccassi f04333210b Merge pull request #29674 from poettering/unexport-marshal-blob
tpm2-util: make tpm2_marshal_blob()/tpm2_unmarshal_blob() static
2023-10-23 11:43:15 +01:00
Lennart Poettering 4cdef9f08c pcrextend: split out word to measure code into shared helper file
Let's split out the logic that actually generates the word to measure to
PCRs into a new helper file pcrextend-util.[ch].

This we can later reuse to calculate PCR measurement predictions ahead
of time.
2023-10-23 11:24:18 +01:00
Lennart Poettering 10cb55eef1 efi-api: export UUID converter calls
(while exporting, do some minor simplifications)
2023-10-23 11:23:56 +01:00
Lennart Poettering add8091c97 tpm2-util: make tpm2_read_public() static, as we use it only internally in tpm2-util.c 2023-10-23 10:36:22 +02:00
Lennart Poettering 9122edf907 tpm2-util: make tpm2_marshal_blob()/tpm2_unmarshal_blob() static
These are not used outside of tpm2-util.[ch], and the way they merge
public/private key pair into one blob is kinda specific to our
implementation, hence better should be hidden away, and not used for new
code anyway.
2023-10-23 10:36:22 +02:00
Julien Malka f64b9a1897 creds-utils: fix read_full_file_full call in read_credential_with_decryption
data was passed as a null pointer when an address was expected.
As a result, the assert was always tripped.
2023-10-23 09:36:04 +02:00
Lennart Poettering b98c4f1d48 tpm2-util: rename tpm2_calculate_name() → tpm2_calculate_pubkey_name()
We'll soon have a function for determining the name of an NV index,
hence let's rename the existing function for the same of a public key to
make clear it's about public keys only.
2023-10-21 19:34:55 +01:00
Luca Boccassi 242b4bebcd Merge pull request #29382 from YHNdnzj/sleep-round-two
shared/sleep-config,hibernate-util: cleanup round two
2023-10-21 11:51:09 +01:00
Mike Yuan 0f095d0b8f shared/mount-util: log correct errno
Follow-up for 5f48198af8
2023-10-21 06:25:36 +08:00
Mike Yuan 805deec039 hibernate-util: introduce hibernation_is_safe
After 7470b80763, we refuse
to hibernate if we fail to write HibernateLocation EFI
variable and resume= is not set. Let's teach sleep_supported
to follow the practice too.
2023-10-20 23:22:54 +08:00
Mike Yuan 596873c10c hibernate-util: rework find_hibernate_location
* "HibernateLocation" struct is renamed to HibernationDevice
  to avoid ambiguity with the EFI variable. Also, it no longer
  takes the reference to a SwapEntry object, since it's really
  unnecessary (only SwapEntry.path is used), but increases complexity.
* SwapEntry is no longer used externally.
* find_hibernate_location is split into read_swap_entries and
  find_suitable_hibernation_device. The former reads all swap entries
  into SwapEntries object for later use.
* Make use of btrfs_get_file_physical_offset_fd

Closes #25130
2023-10-20 23:22:54 +08:00
Mike Yuan 2abc3c6d48 hibernate-util: read_fiemap: add missing asserts 2023-10-20 23:22:28 +08:00
Mike Yuan a0f6d74ec8 sleep-config: introduce sleep_supported_full that returns a reason
Preparation for later commits.

Also some other cleanups:
* Add assertions
* Use FOREACH_ARRAY
2023-10-20 23:22:28 +08:00
Mike Yuan 23577f4462 sleep-config: minor cleanup for can_sleep_{state,disk}
* Rename to sleep_{state,mode}_supported
* Treat unreadable/unwriable sysfs files as error
2023-10-20 23:22:28 +08:00
Malte PollandPaul Meyer b2942c76ad mkfs-util: set timezone to UTC when copying files into fat partition
mcopy will set the modification time of created directories to the mtime
of the source directories but converts it to the timezone of the host.
This behavior is identical to Windows / DOS:

>  The FAT file system stores time values based on the local time of the computer.

-- https://learn.microsoft.com/en-us/windows/win32/sysinfo/file-times

To achieve reproducible builds, mcopy should be invoked with TZ=UTC.

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2023-10-20 16:15:52 +01:00
Lennart Poettering 4c4de97db8 sort-utils: add generic uint16_t comparison call 2023-10-20 15:57:58 +01:00