Commit Graph

3803 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
eb406c4e19 Merge pull request #18955 from keszybz/fstab-escaping
Fix handling of escaped characters in fstab
2021-03-11 14:45:11 +01:00
Zbigniew Jędrzejewski-Szmek
e4645ca599 basic/group-util: optimize alloca use
Follow-up for 0fa7b50053.
2021-03-11 14:43:16 +01:00
Zbigniew Jędrzejewski-Szmek
3141089f53 basic/extract-word: rename flag
The flag enables "relaxed mode" for all kinds of unescaping, not just c-unescaping.
2021-03-11 09:21:07 +01:00
Zbigniew Jędrzejewski-Szmek
76c4e48ee6 basic/extract-word: allow escape character to be escaped
With EXTRACT_UNESCAPE_SEPARATORS, backslash is used to escape the separator.
But it wasn't possible to insert the backslash itself. Let's allow this and
add test.
2021-03-11 09:21:07 +01:00
Zbigniew Jędrzejewski-Szmek
8723c716c7 basic/extract_word: try to explain what the various options do
A test for stripping of escaped backslashes without any flags was explicitly
added back in 4034a06ddb. So it seems to be on
purpose, though I would say that this is at least surprising and hence deserves
a comment.

In test-extract-word, add tests for standalone EXTRACT_UNESCAPE_SEPARATORS.
Only behaviour combined with EXTRACT_CUNESCAPE was tested.
2021-03-11 09:21:04 +01:00
Lennart Poettering
48f813c4aa coredumpctl: fflush() stdout before invoking gdb
Fixes: #18936
2021-03-11 08:55:20 +01:00
Zbigniew Jędrzejewski-Szmek
749c4c8ed1 Merge pull request #18553 from Werkov/cgroup-user-instance-controllers
Make (user) instance aware of delegated cgroup controllers
2021-03-10 09:41:40 +01:00
Lennart Poettering
e5f8ce13bb socket-util: refuse ifnames with embedded '%' as invalid
So Linux has this (insane — in my opinion) "feature" that if you name a
network interface "foo%d" then it will automatically look for the
interface starting with "foo…" with the lowest number that is not used
yet and allocates that.

We should never clash with this "magic" handling of ifnames, hence
refuse this, since otherwise we never know what the name is we end up
with.

We should probably switch things from a deny list to an allow list
sooner or later and be much stricter. Since the kernel directly enforces
only very few rules on the names, we'd need to do some research what is
safe and what is not first, though.
2021-03-10 11:11:52 +09:00
Lennart Poettering
9813d8354c fs-util: port symlink_idempotent() to path_extract_directory() 2021-03-09 14:37:23 +00:00
Lennart Poettering
445714569d mountpoint-util: replace our last use of FILENAME_MAX by PATH_MAX 2021-03-08 22:47:55 +01:00
Lennart Poettering
db22003233 fs-util: replace use of FILENAME_MAX by PATH_MAX in readlinkat_malloc()
While we are at it, let's also add an overflow check and do other
modernizations.
2021-03-08 22:47:51 +01:00
Lennart Poettering
8ca94009f8 basic: tighten two filename length checks
This fixes two checks where we compare string sizes when validating with
FILENAME_MAX. In both cases the check apparently wants to check if the
name fits in a filename, but that's not actually what FILENAME_MAX can
be used for, as it — in contrast to what the name suggests — actually
encodes the maximum length of a path.

In both cases the stricter change doesn't actually change much, but the
use of FILENAME_MAX is still misleading and typically wrong.
2021-03-08 22:47:14 +01:00
Zbigniew Jędrzejewski-Szmek
1d73ffeae1 missing-syscalls: do not generate trailing empty line
The generated .h file was already like this, but what the generator generated
did not match. So we only need to update the generator.
2021-03-08 12:39:50 +01:00
Zbigniew Jędrzejewski-Szmek
36fd31f525 syscalls: update tables
bfin_spinlock and cache_sync are dropped from the table, but didn't have
numbers assigned.

mount_setattr was added in v5.11-rc4-35-g2a1867219c.
2021-03-08 12:31:46 +01:00
Zbigniew Jędrzejewski-Szmek
6bc352af1f basic/namespae-util: avoid one allocation 2021-03-07 12:22:28 +01:00
Zbigniew Jędrzejewski-Szmek
9e8a392a9a basic/os-util: adjust indentation 2021-03-07 12:15:42 +01:00
Yu Watanabe
f96f5d54b8 socket-util: initialize variable with cleanup attribute
Follow-up for 83e03c4fc2.

Fixes CID#1448460.
2021-03-07 10:32:36 +09:00
Lennart Poettering
47f9f84ca9 Merge pull request #18891 from keszybz/size_t-cast-removal
size_t cast removal
2021-03-06 14:32:46 +01:00
Yu Watanabe
c2cbe05708 Merge pull request #18896 from poettering/no-localhost-ipv6
if ipv6 is turned off, don't synthesize localhost as ::1 ever
2021-03-06 11:28:38 +09:00
Lennart Poettering
07a7441a1c socket-util: refuse "all" and "default" as valid ifnames
Let's avoid collisions with special sysctls.
2021-03-06 11:26:18 +09:00
Luca Boccassi
5d5b6442a2 Merge pull request #18875 from keszybz/localed-error
localed: return error when setting a non-installed keymap
2021-03-05 22:50:41 +00:00
Lennart Poettering
83e03c4fc2 socket-util: add helper for checking if IPv6 is enabled 2021-03-05 20:51:43 +01:00
Lennart Poettering
571ec995fe socket-util: cache result of socket_ipv6_is_supported()
And while we are at it, log about unexpected errors.
2021-03-05 20:51:43 +01:00
Lennart Poettering
b0ffd2760c basic: move shared/sysctl-util.[ch] → basic/
This is self-contained ans allows us later to use the provided APIs from
other code in src/basic/
2021-03-05 20:41:07 +01:00
Zbigniew Jędrzejewski-Szmek
fd4e991dfd Drop parens from around already-parenthesized defines 2021-03-05 19:27:23 +01:00
Zbigniew Jędrzejewski-Szmek
63dc82d378 Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
tree-wide: use UINT64_MAX or friends
2021-03-05 17:51:34 +01:00
Yu Watanabe
f385c44787 strv: introduce strv_split_newlines_full() 2021-03-05 09:29:57 +09:00
Lennart Poettering
bb72c43485 copy: move sync_rights() to copy.c and rename copy_rights()
It's so similar to copy_access(), hence let's move it over and rename it
in similar style to the rest of the functions.

No change in behaviour, just moving things over.
2021-03-04 22:35:52 +00:00
Lennart Poettering
e1aec57dd1 copy: simplify error paths when creating temporary files 2021-03-05 07:12:51 +09:00
Yu Watanabe
f5fbe71d95 tree-wide: use UINT64_MAX or friends 2021-03-05 07:10:13 +09:00
Yu Watanabe
496db33004 tree-wide: use usec_add() and usec_sub_unsigned() 2021-03-05 07:10:08 +09:00
Lennart Poettering
4d930e87ee rm-rf: fix up chmod in the _cleanup_ rm_rf() destructors
REMOVE_CHMOD is necessary to remove files/dirs that are owned by us but
have an access mode that would not allow us to remove them. In generic
destructor calls for use with `_cleanup_` that are "fire-and-forget"
style we should make use of that, to maximize the chance we can actually
remove the files/dirs.

(Also, add in REMOVE_MISSING_OK. Just because prettier, we ignore the
return codes anyway, but it' a bit nicer to ignore a bit fewer errors.)
2021-03-04 20:50:07 +00:00
Lennart Poettering
a60d064748 fileio: minor read_full_stream_full() optimization
If we shall read as much of a file/stream as we can, then it makes sense
to use the full malloc()ed memory, not just the part we asked for.
2021-03-04 18:55:02 +01:00
Lennart Poettering
407234203b Merge pull request #18615 from xry111/private-ipc-1
New directives PrivateIPC and IPCNamespacePath
2021-03-04 18:04:28 +01:00
Lennart Poettering
9706d27cbe Merge pull request #18840 from yuwata/libudev-monitor-tiny-cleanup
io-util: introduce ppoll_usec()
2021-03-04 17:23:17 +01:00
Zbigniew Jędrzejewski-Szmek
315edc2c11 Move basic/kbd-util to shared/
It is (or should be used) in localectl, localed, and a few other places,
no reason to keep it in basic/.
2021-03-04 09:39:29 +01:00
Yu Watanabe
6ce8eda8a1 Merge pull request #18864 from poettering/fsync-tweaks
make sure fsync_directory_of_file() + fsync_full() work on more inode types reasonably
2021-03-04 14:51:10 +09:00
Lennart Poettering
1b55621dab rm-rf: fstatat() might fail if containing dir has limited access mode, patch that too 2021-03-04 14:50:50 +09:00
Lennart Poettering
1071c195f7 fs-util: when opening arbitrary inodes, better use O_NONBLOCK
In case this is a device node where opening might block.
2021-03-04 14:50:38 +09:00
Lennart Poettering
30cdcd628b fs-util: port open_parent() to path_extract_directory() 2021-03-03 22:00:24 +01:00
Yu Watanabe
c4febde9d0 io-util: introduce ppoll_usec() helper function 2021-03-04 05:06:43 +09:00
Lennart Poettering
ed4a653c09 fs-util: handle gracefully if fsync_full() is called on block devices and such 2021-03-03 18:31:23 +01:00
Lennart Poettering
9041e36d07 fs-util: allow fsync_directory_of_file() on directories too
(in which case the parent dir is synced)
2021-03-03 18:31:20 +01:00
Xℹ Ruoyao
54c2459d56 Refactor network namespace specific functions in generic helpers 2021-03-04 00:04:36 +08:00
Lennart Poettering
ab05bee1dd time-util: simplify overflow check
And don't rely on 2s complement.
2021-03-03 12:16:21 +09:00
Luca Boccassi
294f1b40ab Merge pull request #18834 from poettering/path-extract
Beef up path_extract_filename() a bit, and introduce path_extract_directory()
2021-03-02 19:22:53 +00:00
Lennart Poettering
312dff1760 util: add helpers for generating colored check mark glyphs from bools 2021-03-03 03:08:31 +09:00
Lennart Poettering
62a88d7a3e tmpfile: port tempfn_*() to path_extract_*() 2021-03-02 15:07:52 +01:00
Lennart Poettering
ee277c6bc7 path-util: return O_DIRECTORY from path_extract_filename() when path ends in slash
Let's fine-tune the path_extract_filename() interface: on succes return
O_DIRECTORY as indicator that the input path was slash-suffixed, and
regular 0 otherwise. This is useful since in many cases it is useful to
filter out paths that must refer to dirs early on.

I opted for O_DIRECTORY instead of the following other ideas:

1. return -EISDIR: I think the function should return an extracted
   filename even when referring to an obvious dir, so this is not an
   option.

2. S_ISDIR, this was a strong contender, but I think O_DIRECTORY is a
   tiny bit nicer since quite likely we will go on and open the thing,
   maybe with openat(), and hence it's quite nice to be able to OR in
   the return value into the flags argument of openat().

3. A new enum defined with two values "dont-know" and
   "definitely-directory". But I figured this was unnecessary, given we
   have other options too, that reuse existing definitions for very
   similar purposes.
2021-03-02 15:07:44 +01:00
Lennart Poettering
8dcb891c19 path-util: add path_extract_directory(), to match path_extract_filename()
These two together are a lot like dirname() + basename() but have the
benefit that they return clear errors when one passes a special case
path to them where the extraction doesn't make sense, i.e. "", "/",
"foo", "foo/" and so on.

Sooner or later we should probably port all our uses of
dirname()/basename() over to this, to catch these special cases more
safely.
2021-03-02 15:07:11 +01:00