Commit Graph
2645 Commits
Author SHA1 Message Date
Luca Boccassi ec4afb4606 libsystemd/sd-id128: use only internal hmac, remove khash/OpenSSL support
Using OpenSSL brings in an additional dependency for all users of
libsystemd.so even though it's just one API that makes use of it.

The khash implementation is awkward as it requires context switches and
computation inside the kernel, thus leaving the process.

Remove both from libsystemd.so, and use exclusively the internal hmac fallback.
While this is not optimized, the sd-id128 API is not used in
performance-critical contexts where hardware acceleration would make a
noticeable difference.
2021-10-08 13:11:00 +01:00
Lennart Poettering c53e07e249 xattr-util: merge various getxattr()/listxattr() helpers into getxattr_at_malloc() + listxattr_at_malloc()
Unfortunately fgetxattr() and flistxattr() don't work via O_PATH fds.
Let's thus add fallbacks to go via /proc/self/fd/ in these cases.

Also, let's merge all the various flavours we have here into singular
implementations that can do everything we need:

1. malloc() loop handling
2. by fd, by path, or combination (i.e. a proper openat() like API)
3. work on O_PATH
2021-10-07 11:49:22 +02:00
Lennart Poettering f435195925 basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch] 2021-10-05 16:14:37 +02:00
Lennart Poettering 9e5fd71799 basic: split out inotify-related calls from fs-util.h → inotify-util.h 2021-10-05 16:14:37 +02:00
Lennart Poettering d8e32c471f basic: split out glyph/emoji related calls from locale-util.[ch] into glyph-util.[ch]
These functions are used pretty much independently of locale, i.e. the
only info relevant is whether th locale is UTF-8 or not. Hence let's
give this its own pair of .c/.h files.
2021-10-05 16:14:37 +02:00
Lennart Poettering bf819d3ac2 basic: split out sync() family of calls from fs-util.[ch] into new c/h file
No changes in code, just some splitting out.
2021-10-05 15:47:32 +02:00
Yu Watanabe 8e310690b0 sd-netlink: add several attributes for nl80211 2021-09-29 15:38:59 +09:00
Yu Watanabe f3e235ffb2 sd-netlink, wifi-util: fix attribute type of NL80211_ATTR_SSID 2021-09-29 15:38:59 +09:00
Yu Watanabe a1d2ae065b sd-netlink: introduce sd_netlink_message_read_data_suffix0() 2021-09-29 15:38:59 +09:00
Yu Watanabe 84f7bd7698 sd-netlink: make sd_genl_message_new() or friends return -EOPNOTSUPP if a module is not supported by the kernel 2021-09-29 15:38:55 +09:00
Yu Watanabe 4d4d898a4b sd-netlink: also check multicast group to find suitable match callback 2021-09-29 15:36:42 +09:00
Yu Watanabe ec44d3f407 sd-netlink: allow to set dump flag for genl or netfilter messages 2021-09-29 15:35:08 +09:00
Yu Watanabe dbc35fe3aa sd-netlink: add type safe macro for sd_genl_add_match() 2021-09-29 15:33:50 +09:00
Yu Watanabe 52888279df sd-netlink: minor coding style fixes 2021-09-29 15:33:50 +09:00
Yu Watanabe 01afd0f7f5 tree-wide: make format_ifname() or friends return negative errno on failure
Also,
- drop unnecessary +1 from buffer size, as IF_NAMESIZE or IFNAMSIZ
  includes the nul at the end.
- format_ifname() does not update buffer on failure,
- introduces format_ifname_alloc(), FORMAT_IFNAME(), and their friends.
2021-09-29 03:37:06 +09:00
Yu Watanabe 73bf0f2ace Merge pull request #20738 from mrc0mmand/ci-llvm-13
ci: build with clang-13
2021-09-16 09:32:21 +09:00
Daan De Meyer adbd80f510 sd-journal: Ignore data threshold if set to zero in sd_journal_enumerate_fields()
According to the documentation, Setting the data threshold to zero disables the
data threshold alltogether. Let's make sure we actually implement this behaviour
in sd_journal_enumerate_fields() by only applying the data threshold if it exceeds
zero.
2021-09-16 00:12:25 +09:00
Frantisek Sumsal d7ac09520b tree-wide: mark set-but-not-used variables as unused to make LLVM happy
LLVM 13 introduced `-Wunused-but-set-variable` diagnostic flag, which
trips over some intentionally set-but-not-used variables or variables
attached to cleanup handlers with side effects (`_cleanup_umask_`,
`_cleanup_(notify_on_cleanup)`, `_cleanup_(restore_sigsetp)`, etc.):

```
../src/basic/process-util.c:1257:46: error: variable 'saved_ssp' set but not used [-Werror,-Wunused-but-set-variable]
        _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL;
                                                     ^
                                                     1 error generated.
```
2021-09-15 13:09:45 +02:00
Daan De Meyer 27bf0ab76e sd-journal: Don't compare hashes from different journal files
In sd_journal_enumerate_fields(), we check if we've already handled
a field by checking if we can find it in any of the already processed
journal files. We do this by calling
journal_file_find_field_object_with_hash(), which compares the size,
payload and hash of the given field against all fields in a journal file,
trying to find a match. However, since we now use per file hash functions,
hashes for the same fields will differ between different journal files,
meaning we'll never find an actual match.

To fix the issue(), let's use journal_file_find_field_object() when one
or more of the files we're comparing is using per file keyed hashes.
journal_file_find_field_object() only takes the field payload and size
as arguments and calculates the hash itself using the hash function from
the journal file we're searching in.
2021-09-15 11:00:49 +09:00
Yu Watanabe 20ec7d9ed5 sd-device: do not recreate the same symlinks which store watch handle 2021-09-13 11:54:56 +09:00
Michal Sekletar 9f6ef46781 sd-event: take ref on event loop object before dispatching event sources
Idea is that all public APIs should take reference on objects that get
exposed to user-provided callbacks. We take the reference as a
protection from callbacks dropping it. We used to do this also here in
sd_event_loop(). However, in cleanup portion of f814c871e6 this was
accidentally dropped.
2021-09-09 01:15:57 +09:00
Yu Watanabe 05403363ca tree-wide: fix typo 2021-09-05 09:09:13 +02:00
Yu Watanabe b2cdc2c05e Merge pull request #20603 from yuwata/udev-node-cleanups
udev: cleanups for creating/removing device node symlinks
2021-09-03 05:33:06 +09:00
Vito Caputo a4121e965f sd-journal: use FILE streams to buffer write_uint64()
journal_file_verify() uses a set of tmpfs files to create lists
of object positions by type.

The existing code used a bare write() call for every object
position written, incurring a syscall per listed object.

This commit encapsulates the bare file descriptors in FILE *'s
and replaces the bare write with fwrite, buffering the writes so
there's less syscalls.

Cached `journalctl --verify` tests showed a ~8% faster runtime
with this change on a release build, verifying 1.3GiB of
production journals across 16 files.
2021-09-02 11:29:23 +02:00
Yu Watanabe b881ce16b9 sd-device: introduce device_has_devlink() 2021-09-02 08:30:51 +09:00
Lennart Poettering 50dbb118c9 Merge pull request #20575 from vcaputo/verify_field_object_hash
sd-journal: verify field object hash
2021-09-01 15:56:05 +02:00
Yu Watanabe 416e84192a sd-netlink: introduce sd_netlink_message_get_max_attribute() 2021-08-31 21:18:34 +09:00
Yu Watanabe e0df8e9993 sd-netlink: specify appropriate netlink attribute type 2021-08-31 21:12:20 +09:00
Yu Watanabe 38d3bcde5d sd-netlink: support more rtnl attributes 2021-08-31 21:12:20 +09:00
Luca Boccassi 1f08acf406 Merge pull request #20257 from bluca/seqno
Use new diskseq block device property
2021-08-31 09:06:33 +01:00
Vito Caputo 921fcd5d9e sd-journal: verify field object hashes
journal_file_verify() doesn't actually verify field object hashes
against their contents, despite journald storing a hash with the
payload.  This commit adds that verification.
2021-08-29 22:26:54 -07:00
Vito Caputo d18e868ec0 sd-journal: move payload hashing to helper function
Preparatory commit for adding field object hash verification to
journal_file_verify() / `journalctl --verify`
2021-08-29 22:15:39 -07:00
Yu Watanabe 98be429243 sd-netlink: make type_system_get_*() and friends return value directly 2021-08-29 18:10:47 +09:00
Yu Watanabe e1578f608b sd-netlink: introduce sd_genl_add_match()
By using this, we can listen multicast messages for generic netlink.
2021-08-29 18:10:47 +09:00
Yu Watanabe 3f60e4488c sd-netlink: split sd_netlink_add_match() into two parts
This also makes netlink_slot_disconnect() correctly unref multicast
groups.
2021-08-29 18:10:47 +09:00
Yu Watanabe ef90beb1c5 sd-netlink: introduce sd_genl_message_get_command() 2021-08-29 18:10:47 +09:00
Yu Watanabe 44f1072a9d sd-netlink: determine header size of genl message by using CTRL_ATTR_HDRSIZE attribute
Fortunately, all genl families we currently use do not require additional
header size.
2021-08-29 18:10:47 +09:00
Yu Watanabe 52313394ba sd-netlink: read protocol version of each genl family 2021-08-29 18:10:47 +09:00
Yu Watanabe 56fdc16da8 sd-netlink: drop sd_genl_family_t and introduce GenericNetlinkFamily
Kernel manages each genl family by its name, e.g. "nlctrl" or WG_GENL_NAME,
and its ID (used for nlmsg_type) is determined dynamically when the
corresponding module is loaded.

This commit makes sd-netlink follow the same way; now, sd_genl_family_t
is dropped, and sd_genl_message_new() takes a genl family name. Each
genl family is resolved when it is used first time, and its information
is stored in GenericNetlinkFamily.
2021-08-29 18:10:43 +09:00
Yu Watanabe 1cedca05e4 sd-netlink: split message_new() into two parts and introduces message_new_full() 2021-08-29 18:01:26 +09:00
Yu Watanabe 699c3708df sd-netlink: introduce several macros to define type system 2021-08-29 18:01:26 +09:00
Yu Watanabe e6dd298935 sd-netlink: drop redundant string table lookup functions to handle type system union 2021-08-29 18:01:26 +09:00
Yu Watanabe fae9ee25a4 sd-netlink: split type system for nfnl
This makes the root type system for nfnl indexed by subsystem, and
itroduces a next level type system for each subsystem. The second
level type systems are indexed by message types correspond to each
subsystem.
2021-08-29 18:01:26 +09:00
Yu Watanabe 07acd0d90b sd-netlink: drop 'flags' argument from sd_nfnl_nft_message_new_table() 2021-08-29 18:01:26 +09:00
Yu Watanabe c08ab4a013 sd-netlink: wrap long function declarations 2021-08-29 18:01:26 +09:00
Yu Watanabe 9a9c8f3fcc sd-netlink: add several missing attributes 2021-08-29 18:01:26 +09:00
Yu Watanabe aee6309b97 sd-netlink: introduce basic_type_system
Preparation for later commits.
2021-08-29 18:01:26 +09:00
Yu Watanabe d757e6bdf0 sd-netlink: unify two spurious type system root for genl 2021-08-29 18:01:26 +09:00
Yu Watanabe 9270ec60bc sd-netlink: drop genl type system indexed by command
All type systems of currently supported genl families do not depend on
commands. Hence, at least tentatively, let's drop the tables.

Note that type system for genl ethtool depends on commands. Let's
reintroduce a mechanism to support the deps when we support ethtool on
netlink.
2021-08-29 18:01:26 +09:00
Yu Watanabe e6d58c2f71 sd-netlink: rename several type systems for generic netlink 2021-08-29 18:01:26 +09:00