Commit Graph
2804 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek b4e7d7555e man: describe capability checks on the bus
A description of SD_BUS_VTABLE_CAPABILITY is added, and the discussion
on SD_BUS_VTABLE_UNPRIVILEGED in expanded. I think it would be nice
to add longer description of how access is checked (maybe in sd-bus(3)),
but I'm leaving that for later. I think the text that was added here
describes everything, even if tersely.

Fixes #21882.
2022-03-04 15:43:18 +01:00
Zbigniew Jędrzejewski-Szmek f05a288135 Merge pull request #22644 from keszybz/meson-no-split
Use normal lists in meson instead of splitting on whitespace
2022-03-03 23:10:14 +01:00
Tobias Stoeckmann 1a823cdeb9 core: check size before mmap
The data type off_t can be 64 on 32 bit systems if they have large
file support. Since mmap expects a size_t with 32 bits as second
argument truncation could occur. At worst these huge files could
lead to mmaps smaller than the previous check for small files.

This in turn shouldn't have a lot of impact because mmap allocates
at page size boundaries. This also made the PAGE_ALIGN call in
open_mmap unneeded. In fact it was neither in sync with other mmap
calls nor with its own munmap counterpart in error path.

If such large files are encountered, which is very unlikely in these
code paths, treat them with the same error as if they are too small.
2022-03-03 22:48:43 +01:00
Zbigniew Jędrzejewski-Szmek 2f492a739c meson: move files' closing brace to separate line 2022-03-03 12:14:13 +01:00
Zbigniew Jędrzejewski-Szmek f1b98127ff meson: do not use split() in file lists
The approach to use '''…'''.split() instead of a list of strings was initially
used when converting from automake because it allowed identical blocks of lines
to be used for both, making the conversion easier.

But over the years we have been using normal lists more and more, especially
when there were just a few filenames listed. This converts the rest.

No functional change.
2022-03-02 14:49:32 +01:00
Zbigniew Jędrzejewski-Szmek 0b6c0b8083 Merge pull request #22605 from yuwata/test-journal-send-fd-leaks
test-journal-send: fix fd leaks
2022-02-23 09:15:41 +01:00
Zbigniew Jędrzejewski-Szmek f2acaf39c1 Merge pull request #22600 from poettering/timestamp_is_set-more
make more use of timestamp_is_set()
2022-02-23 08:59:49 +01:00
Yu Watanabe eb9752d2be journal-send: close fd on exit when running with valgrind
Fixes an issue reported in #22576.
2022-02-23 07:38:43 +09:00
Yu Watanabe 9048a6ccf3 test-journal-send: close fd opend by syslog()
Fixes an issue reported in #22576.
2022-02-23 07:38:39 +09:00
Lennart Poettering 0da36375eb tree-wide: use timestamp_is_set() more 2022-02-22 22:49:40 +01:00
Yu Watanabe 62d4b3b36e test: fix file descriptor leak in test-catalog
Fixes an issue reported in #22576.
2022-02-22 21:50:29 +09:00
Yu Watanabe 65022cd7ab network,udev/net: add Kind= settings in [Match] section
This may be useful for writing .network or .link files matching with
virtual interfaces.

Closes #22541.
2022-02-17 23:10:26 +09:00
Lennart Poettering 96ca229517 coccinelle: automatically switch some uses of memcpy() → mempcpy()
Inspired by #22520, let's add a coccinelle script that converts this
automatically.
2022-02-16 17:26:26 +01:00
Yu Watanabe 88586e5d32 Merge pull request #22508 from poettering/stat-ino-compare
stat-util: add new stat_inode_same() helper
2022-02-15 04:45:31 +09:00
Yu Watanabe d1e7fa02ca Merge pull request #22507 from poettering/id128-compare-tweaks
sd-id128: comparison tweaks
2022-02-15 04:40:53 +09:00
Lennart Poettering d6b218e742 sd-daemon: use path_join() instead of manual path concat 2022-02-14 17:27:24 +01:00
Lennart Poettering a9dac7a6dd tree-wide: port various places over to new stat_inode_same() helper 2022-02-14 17:27:14 +01:00
Luca Boccassi d74da762a3 Merge pull request #22506 from poettering/devnum-zero-btrfs-block-dev
gpt-auto: some (primarily cosmetic) fixes to backing block device detection in gpt-auto-generator/sd-device
2022-02-14 16:17:04 +00:00
Lennart Poettering 75a505c600 id128-util: add new helper id128_equal_string()
Quite often we compare uuids/id128 formatted as strings with specific
values. So far we usually used streq() for that. let's add a new
explicit helper for this in id128_equal_string() that compares a string
with an sd_id128_t and is more robust than a simple string comparison.
Moreover, we can mroe easily reuse the various defines we have for
specific UUIDs, for example those from gpt.h.
2022-02-14 15:14:03 +01:00
Lennart Poettering b74163607b sd128: export sd_id128_to_uuid_string()
We expose various other forms of UUID helpers already, i.e.
SD_ID128_UUID_FORMAT_STR and SD_ID128_MAKE_UUID_STR(), and we parse
UUIDs, hence add a high-level helper for formatting UUIDs too.

This doesn't add any new code, it just moves some helpers
id128-util.[ch] → sd-id128.[ch], to make them public.
2022-02-14 15:13:23 +01:00
Yu Watanabe 42672c80dc test: check if running in container earlier 2022-02-14 13:46:17 +00:00
Lennart Poettering f1ad2c9238 sd-device: refuse opening device mit major/minor of zero early
device nodes with 0 dev_t are not real (and for that reason such inodes
are used as whiteouts in overlayfs, for example), hence refuse them
early. It seems wrong going to sysfs for something we know can't exist
anyway.
2022-02-14 13:40:56 +01:00
Yu Watanabe e8b8b3eacb sd-netlink: allow to dump qdisc and tclass 2022-02-09 14:43:19 +09:00
Yu Watanabe 27e93a4b66 sd-netlink: make traffic control related message can be monitored 2022-02-09 14:43:19 +09:00
Yu Watanabe 1f38b6f9c6 sd-netlink: introduce sd_rtnl_message_traffic_control_get_{ifindex,parent,handle}() 2022-02-09 14:38:23 +09:00
Yu Watanabe f50b93fed7 sd-netlink: unify sd_rtnl_message_new_qdisc() and sd_rtnl_message_new_tclass()
As the netlink message header types for both qdisc and tclass are
equivalent.
2022-02-09 14:35:25 +09:00
Daan De Meyer 952d1e784a journal: Improve handling of corruption during upwards entry iteration
If we're going upwards in the journal file during entry iteration and we
can't reach the current entry due to corruption, start iterating upwards
from the last reachable entry array. This is equivalent to skipping
all entries in the array that can't be reached anymore.

Fixes #22431
2022-02-07 20:40:30 +00:00
Daan De Meyer aa00163d79 journal: Fix upwards iteration of entry items in case of corruption
8d801e35cb didn't take into account
upwards iteration of entry items when we're working on a corrupted
journal file. Instead of moving to the previous entry array, we'd
always move to the next array, regardless of the iteration direction.

To fix this, we introduce bump_entry_array() that moves to the next
or previous entry array depending on the given direction. Since the
entry array chains are singly linked lists, we have to start iterating
from the front to find the previous array. We only reach this logic
if we're working on a corrupted journal file so being slow here shouldn't
matter too much.
2022-02-07 20:40:28 +00:00
Luca Boccassi 5c10b98350 Merge pull request #22358 from yuwata/udevadm-test-support-dev-path-or-device-unit
udevadm: test,test-builtin: support /dev path or device unit
2022-02-02 15:32:20 +00:00
Yu Watanabe 4900ae14a5 sd-device: drop device_new_from_synthetic_event() from libsystemd
It is used by only test-udev.c.
2022-02-02 20:34:38 +09:00
Yu Watanabe 2079898088 sd-device: make device_set_action() take sd_device_action_t 2022-02-02 20:34:38 +09:00
Yu Watanabe 7f2e3eea28 sd-device: move device_read_uevent_file() to device-private.h
Then, it can be used by our tools or daemons.
2022-02-02 20:34:38 +09:00
Lennart Poettering e6d4a1106c journal-file: don't use pread() when determining where to append, use mmap as before
This partially undoes the effect of
ab6e257b3e.

Originally, we always used the mmap logic to determine the current end
of the file. ab6e257b3e changed this so
that we always used pread().

With this change we'll use pread() from the synchronization thread and
mmap otherwise.
2022-02-02 11:21:44 +09:00
Lennart Poettering e5d8473335 journal: various fixes to journal_file_read_object()
This fixes a bunch of issues:

pread() returns ssize_t, and returns errors in 'errno', handle that
correctly.

More importantly: it might incompletely read data in case we hit
EOF. Check for that, and handle it.

Finally, rename the function to journal_file_read_object_header(), since
it really doesn't read full objects, but only their headers.

Follow-up for: 117e21121e
2022-02-01 18:45:23 +01:00
Yu Watanabe 29fafedd39 sd-device: suppress too many debugging log when enumerating devices
Follow-up for d7cb60daf6.
2022-01-28 10:58:15 +09:00
Daan De Meyer 8bad545354 journal: Stop comparing hash values from entry items against data objects
These checks don't achieve anything of value. Assuming they were added to
check for corruption, they don't actually achieve this goal since other parts
of the data object can still get corrupted and we wouldn't notice unless we'd
recalculate the hash every time.

In theory, we could use the entry item hash to avoid a random access lookup
for the data object hash in the journal file in the future to speed up searching,
but for finding all entry objects containing a specific data objects, we already
have entry arrays per data object to get fast access to this information.

This means that duplicating the hashes in the entry item doesn't result in any
added value. In this commit, we remove the checks so that in future commits we
can remove the hashes from the journal file format in the new compact mode.
2022-01-26 20:16:00 +00:00
Daan De Meyer c710944c83 journal: Inline loop variable 2022-01-26 20:16:00 +00:00
Daan De Meyer 578cd1855b journal: Invert verify entry <=> data consistency checks
Previously, for each entry in a data object's entry array, we'd check
if one of that entry's entry items referred to the data object.

Instead, when verifying the main entry array, let's check if for each
entry item found by iterating the main entry array, the corresponding
data object's entry array refers to that entry.

This enables us to re-use more code from journal-file and turns out to
be roughly 10s faster when verifying my 4G laptop journal.

When verifying data objects, we still check if every entry in the data
object's entry array also exists in the main entry array so that we ensure
we're not missing any entries when iterating the main entry array.
2022-01-26 20:16:00 +00:00
Daan De Meyer df53536435 journal: Fail gracefully when linking a new entry
Let's always try to link all entry items even if linking one fails
due to not being able to allocate a new entry array. Other entry
items might still be successfully linked if the entry array of the
corresponding data object isn't full yet.
2022-01-26 20:16:00 +00:00
Daan De Meyer 910eb3c063 journal: Use ret_offset everywhere in journal-file.h 2022-01-26 20:16:00 +00:00
Daan De Meyer ded10e3a5f journal: Only move to objects when necessary
Let's make sure we only move to objects when it's required. If "ret"
is NULL, the caller isn't interested in the actual object and the
function being called shouldn't move to it unless it has to
inspect/modify the object itself.
2022-01-26 20:16:00 +00:00
Daan De Meyer ec50313d4e journal: Pass data objects to journal_file_move_to_entry_..._for_data() functions
This reduces the number of calls to journal_file_move_to_object() which are heavy.
All call sites have easy access to the data object so this change doesn't end up
complicating things.
2022-01-26 20:16:00 +00:00
Daan De Meyer 57e97246cd journal: Log error when keyed hash env variable cannot be parsed 2022-01-26 20:16:00 +00:00
Daan De Meyer 3a8099a871 journal: Use offsetof(Object, ...) to retrieve object field offsets
We currently use both offsetof(Object, ...) and offsetof(DataObject, ...).
This makes it harder to grep for usages as we have to make sure we grep for
both usages. Let's unify these all to use offsetof(Object, ...) to make it
easier to grep for usages.
2022-01-26 20:16:00 +00:00
Thomas Haller 2091c77931 sd-event: workaround maybe-uninitalized warning in sd_event_add_inotify()
With LTO, the compiler might think that the variable is uninitialized
(from NetworkManager's fork, with gcc-11.2.1-1.fc35):

    src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c: In function 'sd_event_add_inotify':
    src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c:2120: error: 's' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2120 |                 *ret = s;
          |
    src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c:2102: note: 's' was declared here
     2102 |         sd_event_source *s;
          |
    lto1: all warnings being treated as errors

In particular, that would happen for codepaths where event_add_inotify_fd_internal()
returns `-errno`, and the compiler cannot be sure that the returned value will
be negative. Technically, the compiler is right, but we rely on libc functions
to set errno correctly, so this only happens in code paths, where something
bad already happend.

While LTO is prone to such false warnings, we are largely able to build systemd
without warnings. So it is feasible and we should make the effort of working
around warnings as they appear.
2022-01-23 13:10:31 +09:00
Yu Watanabe 61dc4b9ea9 network-util: introduce network_link_get_operational_state() 2022-01-21 06:22:21 +09:00
Jan Janssen acac88340a bus: Use OrderedSet for introspection
Otherwise, the generated xml files are not reproducible.
2022-01-19 23:07:59 +00:00
Yu Watanabe d7cb60daf6 sd-device: add more debugging logs in device_set_syspath()
On failure, the function previously sometimes logs in debug level, but
sometimes does not. Let's always log the error cause.
2022-01-19 20:48:36 +09:00
Zbigniew Jędrzejewski-Szmek e47a3af44e sd-device: drop unnecessary parenthesis 2022-01-15 13:38:49 +01:00
Zbigniew Jędrzejewski-Szmek 376ee2c312 sd-device: silence gcc warning with newest gcc 2022-01-15 13:38:30 +01:00