summaryrefslogtreecommitdiff
path: root/src/shared
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #25328 from poettering/vertical-tablesYu Watanabe2022-11-112-15/+151
|\ | | | | format-table: add concept of "vertical" table
| * format-table: add an explicit "vertical" modeLennart Poettering2022-11-102-15/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally, the table formatting code was written to display a number of records, one per line, and within each line multiple fields of the same record. The first line contains the column names. It was then started to be used in a "vertical" mode however, i.e. with field names on the left instead of the top. Let's support such a mode explicitly, so that we can provide systematic styling, and can properly convert this mode to JSON. A new constructor "table_new_vertical()" is added creating such "vertical" tables. Internally, this is a table with two columns: "key" and "value". When outputting this as JSON we'll output a single JSON object, with key/value as fields. (Which is different from the traditional output where we'd use the first line as JSON field names, and output an array of objects). A new cell type TABLE_FIELD is added for specifically marking the "field" cells, i.e. the cells in the first column. We'll automatically suffic ":" to these fields on output.
* | Merge pull request #25325 from yuwata/resolve-cap-per-link-setting-by-globalLuca Boccassi2022-11-101-1/+2
|\ \ | | | | | | resolve: provide effective mDNS or LLMNR settings
| * | resolve: introduce link_get_llmnr_support() and link_get_mdns_support()Yu Watanabe2022-11-101-1/+2
| |/
* | dissect: also parse out the top-level GPT table uuid and expose this as ↵Lennart Poettering2022-11-102-3/+24
| | | | | | | | | | | | | | | | image UUID systemd-repart generates this in a suitably stable fashion, hence let's actually use it as an identifier for the image. As a first step parse it, and show it.
* | json: add build helpers to insert id128 in uuid formatting into json objectLennart Poettering2022-11-103-4/+15
|/
* Merge pull request #24813 from DaanDeMeyer/at-all-the-thingsLuca Boccassi2022-11-103-6/+29
|\ | | | | Add more openat() style variants for existing stuff
| * rm-rf: Add rm_rf_physical_and_close()Daan De Meyer2022-11-091-0/+17
| | | | | | | | | | | | | | In tests it's useful to be able to delete temporary directories via a file descriptor to them, so let's add rm_rf_physical_and_close() which gets the file descriptor path via /proc and tries to remove it that way.
| * mkdir: Add mkdirat_parents()Daan De Meyer2022-11-092-3/+6
| |
| * mkdir: Add mkdirat_safe()Daan De Meyer2022-11-092-3/+6
| |
* | Merge pull request #25280 from keszybz/initrd-with-overlayfsFrantisek Sumsal2022-11-105-50/+60
|\ \ | | | | | | Initrd with overlayfs
| * | pid1: skip cleanup if root is not tmpfs/ramfsZbigniew Jędrzejewski-Szmek2022-11-091-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in_initrd() was really doing two things: checking if we're in the initrd, and also verifying that the initrd is set up correctly. But this second check is complicated, in particular it would return false for overlayfs, even with an upper tmpfs layer. It also doesn't support the use case of having an initial initrd with tmpfs, and then transitioning into an intermediate initrd that is e.g. a DDI, i.e. a filesystem possibly with verity arranged as a disk image. We don't need to check if we're in initrd in every program. Instead, concerns are separated: - in_initrd() just does a simple check for /etc/initrd-release. - When doing cleanup, pid1 checks if it's on a tmpfs before starting to wipe the old root. The only case where we want to remove the old root is when we're on a plain tempory filesystem. With an overlay, we'd be creating whiteout files, which is not very useful. (*) This should resolve https://bugzilla.redhat.com/show_bug.cgi?id=2137631 which is caused by systemd refusing to treat the system as an initrd because overlayfs is used. (*) I think the idea of keeping the initrd fs around for shutdown is outdated. We should just have a completely separate exitrd that is unpacked when we want to shut down. This way, we don't waste memory at runtime, and we also don't transition to a potentially older version of systemd. But we don't have support for this yet. This replaces 0fef5b0f0bd9ded1ae7bcb3e4e4b2893e36c51a6.
| * | shared: make libmount_parse() non-inlineZbigniew Jędrzejewski-Szmek2022-11-093-33/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | Back in e2857b3d87306d93f0fba526f3e79f4f6806fb02 I added this function as static inline in order to avoid linking libmount into libshared. Nevertheless, a dependency on libmount was added to libbasic in 9e7f941acb0d8fe7a31eec7826ff2c9c6af7044f, and later moved to libshared in 77c772f227d866331560a8d0487fba12dd128dd4. So the shenanigan with an inline function is not useful, let's make it a normal function.
| * | shared/mount-util: fix commentZbigniew Jędrzejewski-Szmek2022-11-091-7/+5
| | | | | | | | | | | | | | | Just typos and grammar. In the end didn't add a use of a function, but I read the comment carefully, and this commit is the result of that.
* | | Merge pull request #25321 from poettering/acpi-timing-fixLennart Poettering2022-11-092-12/+17
|\ \ \ | | | | | | | | acp-fpdt: minor tweaks/fixes
| * | | acpi-fpdt: make sure length/type fields are available in acpi_fpdt_headerLennart Poettering2022-11-091-1/+1
| | | | | | | | | | | | | | | | | | | | some extra safety: make sure the two fields we care about are actually properly present before the buffer is over.
| * | | acpi-fpdt: don't accidentally drop signedness of pread() returnLennart Poettering2022-11-091-5/+10
| | | |
| * | | acpi-fpdt: use our usual ret_xyz naming schemeLennart Poettering2022-11-092-6/+6
| |/ /
* | | dissect: officially support initrd DDIs (to implement 2nd stage initrds)Lennart Poettering2022-11-092-1/+14
|/ / | | | | | | | | Let's complete support for DDI discovery, and also support 2nd stage initrds.
* | Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-0810-10/+10
| | | | | | | | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* | basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-0818-18/+0
| | | | | | | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* | basic: move a bunch of cmdline-related funcs to new argv-util.c+hZbigniew Jędrzejewski-Szmek2022-11-082-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | I wanted to move saved_arg[cv] to process-util.c+h, but this causes problems: process-util.h includes format-util.h which includes net/if.h, which conflicts with linux/if.h. So we can't include process-util.h in some files. But process-util.c is very long anyway, so it seems nice to create a new file. rename_process(), invoked_as(), invoked_by_systemd(), and argv_looks_like_help() which lived in process-util.c refer to saved_argc and saved_argv, so it seems reasonable to move them to the new file too. util.c is now empty, so it is removed. util.h remains.
* | meson: add version.h as dependency to more targetsZbigniew Jędrzejewski-Szmek2022-11-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | version.h can be generated after compilation starts, creating a race condition between compilation of various .c files and creation of version.h. Let's add it as a dependency to more build targets that require version.h or build.h. So far we played whack'a'mole by adding versiondep whenever compilation failed. In principle any target which includes compilation (i.e. any that has .c sources directly), could require this. I don't understand why we didn't see more failures… But it seems reasonable to just add the dependency more widely.
* | basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| |
* | basic,shared: move disable_coredumps() to coredump-util.[ch]Zbigniew Jędrzejewski-Szmek2022-11-082-0/+14
| |
* | basic: move container_get_leader() to process-util.[ch]Zbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | | | | | | basic/util.[ch] is a grab-bag of unrelated functions. Let's move a few of the remaning functions to better locations.
* | basic: create new basic/initrd-util.[ch] for initrd-related functionsZbigniew Jędrzejewski-Szmek2022-11-085-3/+5
|/ | | | | | | | | I changed imports of util.h to initrd-util.h, or added an import of initrd-util.h, to keep compilation working. It turns out that many files didn't import util.h directly. When viewing the patch, don't be confused by git rename detection logic: a new .c file is added and two functions moved into it.
* Merge pull request #25266 from poettering/dissect-fsck-fixLennart Poettering2022-11-071-6/+10
|\ | | | | dissect: fix fsck invocation
| * dissect: fix fsckLennart Poettering2022-11-041-6/+10
| | | | | | | | | | | | | | | | | | | | Since f7725647bb41c3398a867f139efe526efe8aa1b3 when dissecting a disk image we operate with fds to the device nodes in question wherever we can. This includes when we fork off fsck, where we pass a /proc/self/fd/ path as argument. This only works if we keep that fd open however and disable O_CLOEXEC on the fd. Hence do so, and fix fsck this way. (Without this, all fsck will fail, since the fd path is invalid)
* | loop-util: open lock fd read-onlyChristian Göttsche2022-11-051-1/+1
|/ | | | | | | flock(2) works with file descriptors opened with O_RDONLY. This affects SELinux systems where access to block devices is quite restricted to avoid bypasses on filesystem objects.
* reboot-util: drop unnecessary castYu Watanabe2022-11-041-3/+3
| | | | Follow-up for ede5a78f50ed2d5f86dc7a117de2a51b397d52d4.
* reboot-util: drop redundant headersYu Watanabe2022-11-041-5/+0
| | | | Follow-up for ede5a78f50ed2d5f86dc7a117de2a51b397d52d4.
* meson: sort librariesYu Watanabe2022-11-041-2/+2
| | | | | | Except for 'threads'. Follow-up for ede5a78f50ed2d5f86dc7a117de2a51b397d52d4.
* shutdown: Add Xen kexec supportSamuel Thibault2022-11-023-1/+92
| | | | | | In the Xen case, it's the hypervisor which manages kexec. We thus have to ask it whether a kernel is loaded, instead of relying on /sys/kernel/kexec_loaded.
* condition: Check that subsystem is enabled in ConditionSecurity=tpm2Daan De Meyer2022-11-013-11/+15
| | | | | | | | | Instead of succeeding when either the firmware reports a TPM device or we find a TPM device, let's check that the firmware reports a TPM device and the TPM subsystem is enabled in the kernel. To check whether the subsystem enabled, we check if the relevant subdirectory in /sys exists at all.
* udev-builtin-net_id: support getting usb path off the hostCharles Hardin2022-10-312-0/+3
| | | | | | | | | | | To support predictable interface names in various embeeded systems add support for an additional naming scheming using the USB host interface. Several asics have usb controllers that are platform devices and not children of a pci interface. These embedded systems should be able to enumerate interfaces by udev path as well to support configurations and policies. Signed-off-by: Charles Hardin <charles.hardin@chargepoint.com>
* install: process all Wants= symlinks even if some of them failYu Watanabe2022-10-281-5/+11
| | | | | | Follow-up for 94e7298d309fef7710174def820e9d38e512a086. Fixes CID#1499992.
* btrfs-util: move btrfs_defrag_fd() from fd-util.[ch]Yu Watanabe2022-10-252-0/+13
| | | | | | After d71ece3f0b85c7a3decc50143b68ac07fc5831ae, the function is not used in libbasic or libsystemd anymore. Let's move it to more appropriate place.
* Merge pull request #25080 from keszybz/search-pathsYu Watanabe2022-10-252-97/+119
|\ | | | | Refusing linking files underneath our hierarchy, improve error messages
| * systemctl,manager: refuse linking unit files underneath the search pathsZbigniew Jędrzejewski-Szmek2022-10-241-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We treat symlinks to unit files outside of the search path differently from symlinks to unit files *in* the search path. The former are "linked" unit files, while the latter are enablement symlinks and such and will be removed when disabling the unit. The history of the check for in_search_path() is interesting: this condition was added already in the first version of the code in 830964834f330836b9d33752e83de09d4f38da87. Since the beginning, matching arguments would simply be ignored. I think this is dubious. The man page says: > Link a unit file that is *not* in the unit file search paths > into the unit file search path But for backwards-compat, let's continue to silently do nothing for files *in* the search path. The case of symlinks to unit files underneath the search path, but in some subdirectory, is less clear. We didn't check for this case, so it was implicitly allowed. But that's just an oversight, we don't want to allow people to create additional subhierarchies under our hierarchy. Let's check for this case and refuse. Closes #24605.
| * shared/install: check that install_changes_add() didn't fail on successZbigniew Jędrzejewski-Szmek2022-10-241-19/+41
| | | | | | | | | | | | | | This adds a check for an allocation error for the calls to install_changes_add() where we're plannig to return success from the call. In cases where we're returning failure, it doesn't matter as much: the operation will fail anyway, and if the allocation fails, we'll just get a less descriptive error message.
| * shared/install: add forgotten calls to install_changes_add()Zbigniew Jędrzejewski-Szmek2022-10-241-25/+24
| | | | | | | | | | | | | | | | | | The machinery to report a good error message only works if the error was registered with install_changes_add() and a file name. Otherwise we only get a generic "Op failed: %m" message. In some places -EINVAL is replaced by -EUCLEAN, so that we get the proper error message.
| * shared/install: make install_changes_add propagate passed-in errno valueZbigniew Jędrzejewski-Szmek2022-10-242-50/+32
| | | | | | | | | | | | | | | | | | | | | | The function was written to only return an error from internal allocation failures, because when using it to create a bus message, we want to distinguish a failed operation from an allocation error when sending the reply. But it turns out that the only caller that makes this distinction checks that the passed-in errno value ('type') is not negative beforehand. So we can make the function pass 'type' value through, which makes most of the callers nicer. No functional change.
| * Make comment about coordinating offline and online installation symmetricZbigniew Jędrzejewski-Szmek2022-10-201-0/+2
| | | | | | | | https://github.com/systemd/systemd/pull/24728#issuecomment-1260966910
* | tree-wide: inline declarations of sd_netlink_message iteratorsZbigniew Jędrzejewski-Szmek2022-10-201-2/+1
|/ | | | Most places were already converted, but a few weren't for some reason.
* Merge pull request #25059 from keszybz/fopen-reFrantisek Sumsal2022-10-191-6/+7
|\ | | | | Use "re" or "r" as appropriate for various calls
| * shared/tpm2-util: wrap commentsZbigniew Jędrzejewski-Szmek2022-10-191-6/+7
| |
* | Merge pull request #25055 from keszybz/coredump-deadlockLuca Boccassi2022-10-193-13/+41
|\ \ | | | | | | Fix coredump deadlock with overly long backtraces
| * | coredump: avoid deadlock when passing processed backtrace dataZbigniew Jędrzejewski-Szmek2022-10-191-6/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would deadlock when passing the data back from the forked-off process that was doing backtrace generation back to the coredump parent. This is because we fork the child and wait for it to exit. The child tries to write too much data to the output pipe, and and after the first 64k blocks on the parent because the pipe is full. The bug surfaced in Fedora because of a combination of four factors: - 87707784c70dc9894ec613df0a6e75e732a362a3 was backported to v251.5, which allowed coredump processing to be successful. - 1a0281a3ebf4f8c16d40aa9e63103f16cd23bb2a was NOT backported, so the output was very verbose. - Fedora has the ELF package metadata available, so a lot of output can be generated. Most other distros just don't have the information. - gnome-calendar crashes and has a bazillion modules and 69596 bytes of output are generated for it. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2135778. The code is changed to try to write data opportunistically. If we get partial information, that is still logged. In is generally better to log partial backtrace information than nothing at all.
| * | shared/json: use different return code for empty inputZbigniew Jędrzejewski-Szmek2022-10-192-3/+5
| | | | | | | | | | | | | | | It is useful to distinguish if json_parse_file() got no input or invalid input. Use different return codes for the two cases.