Commit Graph
4632 Commits
Author SHA1 Message Date
Lennart Poettering 2c032478fc fileio: fix error propagation 2022-05-13 21:48:27 +09:00
Lennart Poettering 28fe6a8072 fileio: propagate original error if we notice AF_UNIX connect() is not going to work
let's not make up new errors in these checks that validate if connect()
work at all. After all, we don't really know if the ENXIO we saw earlier
actually is really caused by the inode being an AF_UNIX socket, we just
have the suspicion...
2022-05-13 21:48:17 +09:00
Lennart Poettering dfa2b389a6 socket-util: change sockaddr_un_set_path() to return recognizable error on 108ch limit
This way we can implement nice fallbacks later on.

While we are at it, provide a test for this (one that is a bit over the
top, but then again, we can never have enough tests).
2022-05-13 21:47:58 +09:00
Yu Watanabe 0ffffade03 Merge pull request #23361 from keszybz/resolved-helpers
Add some ref-unref helpers for resolved
2022-05-13 02:33:29 +09:00
Zbigniew Jędrzejewski-Szmek 8b0c43475a Add saturate_add() that generalizes size_add() 2022-05-12 17:15:51 +02:00
Zbigniew Jędrzejewski-Szmek cd0cade1ad Merge pull request #23289 from yuwata/resolve-answer-add-rrsig
resolve: place RRSIG after the corresponding entries
2022-05-12 16:15:12 +02:00
Yu Watanabe 34f6ae24c5 Merge pull request #23351 from keszybz/logind-message
logind: fix crash in logind on bad message string
2022-05-12 05:25:21 +09:00
Zbigniew Jędrzejewski-Szmek 011a03a3fa meson: turn on log-message-verification by default in developer builds
I'm not _quite_ convinced that this a good idea… I'm at least keeping
it separate to make it easy to revert ;)
2022-05-11 18:18:59 +02:00
Zbigniew Jędrzejewski-Szmek 1ec7c15613 Do LOG_MESSAGE_VERIFICATION in coverity runs
This should be enough to get reports if we screw up anywhere, coverity does
analysis of printf format strings.
2022-05-11 16:47:40 +02:00
Zbigniew Jędrzejewski-Szmek b9ce5cf9ca Optionally call printf on LOG_MESSAGE() arguments
With an intentional mistake:

../src/login/logind-dbus.c: In function ‘bus_manager_log_shutdown’:
../src/login/logind-dbus.c:1542:39: error: format ‘%s’ expects a matching ‘char *’ argument [-Werror=format=]
 1542 |                           LOG_MESSAGE("%s %s", message),
      |                                       ^~~~~~~
2022-05-11 16:47:40 +02:00
Zbigniew Jędrzejewski-Szmek 92663a5e5b tree-wide: use LOG_MESSAGE() where possible
Also break some long lines for more uniform formatting. No functional change.

I went over all log_struct, log_struct_errno, log_unit_struct,
log_unit_struct_errno calls, and they seem fine.
2022-05-11 16:47:40 +02:00
Yu Watanabe 97cda6e10f Merge pull request #23335 from keszybz/fuzz-json-more-coverage
More coverage in fuzz-json
2022-05-11 02:12:57 +09:00
Zbigniew Jędrzejewski-Szmek 96d651a22b basic/alloc-util: remove unnecessary parens
Those symbols are not macros anymore, so we can drop parens.
2022-05-10 17:08:37 +02:00
Zbigniew Jędrzejewski-Szmek 8b105ec831 shared/calendarspec: wrap long comments and reduce scope of one var 2022-05-10 13:06:32 +02:00
Lennart Poettering b501e42e71 socket-util: don't reference field by macro parameter name
Let's avoid ambigituies here. (Interesting that the current users
compiled at all, in fact)
2022-05-09 13:55:28 +02:00
Zbigniew Jędrzejewski-Szmek a9d178d28b basic/virt: use STRV_FOREACH instead of iteration with ELEMENTSOF
I think it's a bit simpler, we don't have two indexes.
2022-05-08 22:47:50 +02:00
Yu Watanabe 0bb7324c11 ordered-set: introduce ordered_set_reserve() 2022-05-07 15:14:41 +09:00
Zbigniew Jędrzejewski-Szmek b38a9d2d77 basic/strv: fix splitting of strings with escape characters
Plain strv_split() should not care if the strings contains backslashes
or quote characters. But extract_first_word() interprets backslashes
unless EXTRACT_RETAIN_ESCAPE is given.

I wonder how it's possible that nobody noticed this before. I think this
code was introduced in 0645b83a40.
2022-05-06 18:26:30 +02:00
Zbigniew Jędrzejewski-Szmek 34c2d32cf9 shared/terminal-util: don't use $COLORTERM to force colors
Fixup for a5efbf468c: if $COLORTERM was set, we'd
unconditionally turn on colors, which is unexpected and wrong. It even breaks
our own tests when executed in gnome-terminal.
2022-05-06 18:26:26 +02:00
Andreas Rammhold 66c38cd053 core: handle lookup paths being symlinks
With a recent change paths leaving the statically known lookup paths would be
treated differently then those that remained within those. That was done
(AFAIK) to consistently handle alias names. Unfortunately that means that on
some distributions, especially those where /etc/ consists mostly of symlinks,
would trigger that new detection for every single unit in /etc/systemd/system.
The reason for that is that the units directory itself is already a symlink.

Rebased-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2022-05-05 14:46:52 +02:00
Sonali Srivastava a5efbf468c terminal-util: get_color_mode checks COLORTERM 2022-05-05 09:18:51 +02:00
Daan De Meyer 746ea80b77 basic: Add some missing headers to compress.h 2022-05-04 22:47:58 +01:00
Lennart Poettering 0af6ce9ab3 stat-util: drop dir_is_populated() which is apparently not used 2022-05-04 13:29:14 +02:00
Lennart Poettering db55bbf29b stat-util: fix dir_is_empty() with hidden/backup files
This is a follow-up for f470cb6d13 which in
turn is a follow-up for a068aceafb.

The latter started to honour hidden files when deciding whether a
directory is empty. The former reverted to the old behaviour to fix
issue #23220.

It introduced a bug though: when a directory contains a larger number of
hidden entries the getdents64() buffer will not suffice to read them,
since we just allocate three entries for it (which is definitely enough
if we just ignore the . + .. entries, but not ig we ignore more).

I think it's a bit confusing that dir_is_empty() can return true even if
rmdir() on the dir would return ENOTEMPTY. Hence, let's rework the
function to make it optional whether hidden files are ignored or not.
After all, I looking at the users of this function I am pretty sure in
more cases we want to honour hidden files.
2022-05-04 13:29:14 +02:00
Luca Boccassi f470cb6d13 stat-util: ignore hidden_or_backup_file when checking if dir is empty
Commit https://github.com/systemd/systemd/commit/a068aceafbf
changed dir_is_emtpy_at to use FOREACH_DIRENT_IN_BUFFER instead of
FOREACH_DIRENT, but used dot_or_dotdot which just checks if the name
is literally '.' or '..' which is not enough, previous behaviour was
to ignore all hidden files, so restore that and add a test case.

Fixes https://github.com/systemd/systemd/issues/23220
2022-05-01 11:41:43 +09:00
Zbigniew Jędrzejewski-Szmek 4d5713bb7e Merge pull request #23119 from yuwata/test-sd-device-exclude-bdi
test: exclude "bdi" subsystem
2022-04-27 16:56:53 +02:00
Yu Watanabe d25d4f189c set: introduce set_fnmatch() 2022-04-27 16:32:15 +09:00
Lennart Poettering 4d698d12de compress: make Compression a regular non-sparse enum
Given we have two different types for the journal object flags and the
Compression enum, let's make the latter a regular non-sparse enum, and
thus remove some surprises. We have to convert anyway between the two,
and already do via COMPRESSION_FROM_OBJECT().
2022-04-26 21:55:49 +02:00
Lennart Poettering acc50c92eb basic: move compress.[ch] → src/basic/
The compression helpers are used both in journal code and in coredump
code, and there's a good chance we'll use them later for other stuff.

Let's hence move them into src/basic/, to make them a proper internal
API we can use from everywhere where that's desirable. (pstore might be
a candidate, for example)

No real code changes, just some moving around, build system
rearrangements, and stripping of journal-def.h inclusion.
2022-04-26 21:45:03 +02:00
Jan Janssen d5a99b7c9c tree-wide: Simplify variable declarations behind #ifdef 2022-04-24 01:31:05 +09:00
Lennart Poettering 7d3e856e82 macro: upgrade ref counting overflow check assert() → assert_se()
The overflow check for ref counting should not be subject to NDEBUG,
hence upgrade assert() → assert_se(). (The check for zero is an
immediate bug in our code, and should be impossible to trigger, hence
it's fine if the check is optimized away if people are crazy enough to
set NDEBUG, so that can stay assert())

https://github.com/systemd/systemd/pull/23099#discussion_r854341850
2022-04-21 08:56:32 +09:00
Lennart Poettering 947914cb44 Merge pull request #23099 from yuwata/sd-bus-track-fixlets
sd-bus: fix counter
2022-04-20 18:23:05 +02:00
Daan De Meyer b9b156ea3c Merge pull request #23124 from yuwata/fixes-for-post-merge-review
Fixes for post merge review
2022-04-20 17:15:40 +02:00
w30023233 01d9fbccdd virt: detect OpenStack Nova instance 2022-04-20 02:32:33 +09:00
Yu Watanabe 146f4482b2 string-util: introduce strspn_from_end() 2022-04-20 02:15:01 +09:00
Yu Watanabe 072f5f9b18 string-util: introduce string_replace_char() 2022-04-20 02:14:35 +09:00
Yu Watanabe bb60956b39 path-util: make readlink_value() refuse O_DIRECTORY returned from path_extract_filename()
The function is now only used by sd-device.c and pam_systemd.c, and they
expects the result are not directory. Hence, it is safe to change the
behavior.

Addresses https://github.com/systemd/systemd/pull/23089#discussion_r853006017.
2022-04-20 01:40:39 +09:00
Yu Watanabe c8431e9e35 macro: check over flow in reference counter 2022-04-19 17:58:02 +09:00
Yu Watanabe ce8394f9c7 fs-util: use path_extract_filename() at one more place 2022-04-16 00:50:01 +09:00
Lennart Poettering 1fde09b3b4 Merge pull request #22759 from msekletar/issue-18077-long-sysfs-paths-hashing
Create "hashed" unit names from long paths
2022-04-13 22:21:38 +02:00
Yu Watanabe bd1f75d5fb Merge pull request #23070 from poettering/devnum-split
basic: some devnum handling tweaks and refactorings
2022-04-14 03:45:39 +09:00
Lennart Poettering 02b9047edf devnum-util: catch potential stack overruns early 2022-04-13 16:26:31 +02:00
Lennart Poettering ec61371fe6 devnum-util: define helper macros for formatting devnum major/minor pairs
And port some parts over.
2022-04-13 16:26:31 +02:00
Lennart Poettering 7176f06c9e basic: split out dev_t related calls into new devno-util.[ch]
No actual code changes, just splitting out of some dev_t handling
related calls from stat-util.[ch], they are quite a number already, and
deserve their own module now I think.

Also, try to settle on the name "devnum" as the name for the concept,
instead of "devno" or "dev" or "devid". "devnum" is the name exported in
udev APIs, hence probably best to stick to that. (this just renames a
few symbols to "devum", local variables are left untouched, to make the
patch not too invasive)

No actual code changes.
2022-04-13 16:26:31 +02:00
Lennart Poettering 9117d94b9a udevadm: add new --tree mode to "udevadm info"
sysfs is a tree, hence let's a mode that allows showing it as such.
2022-04-13 14:41:05 +02:00
Lennart Poettering 57f9ca3aa0 chase-symlinks: prefer path_extract_directory() over dirname() 2022-04-12 17:10:50 +02:00
Lennart Poettering 860f4c6aa6 chase-symlinks: add comment for opaque argument 2022-04-12 17:10:06 +02:00
Lennart Poettering 0ac6cdd6ae chase-symlinks: add missing OOM check 2022-04-12 17:09:21 +02:00
Lennart Poettering 69cf392f8e chase-symlinks: use empty_to_root() where appropriate 2022-04-12 17:08:33 +02:00
Lennart Poettering 7b9be862c7 chase-symlinks: avoid using stack allocation for potentially huge paths
let's better be safe and use heap allocation for paths which might be
unbounded.

In particular as previously we copied the stack memory to heap anyway,
via a noop path_make_absolute_cwd() call.
2022-04-12 17:07:49 +02:00