Commit graph

2291 commits

Author SHA1 Message Date
Yu Watanabe 9e5b649655 tree-wide: use setsockopt_int() more 2018-10-19 05:52:42 +09:00
Lennart Poettering b33fa02b2d util: drop const_int_one/const_int_zero again
There's only a single user remaining now that we have setsockopt_int(),
let's define those variables locally.

This more or less reverts 6d5e65f645.
2018-10-18 19:50:29 +02:00
Lennart Poettering 2ff48e981e tree-wide: introduce setsockopt_int() helper and make use of it everywhere
As suggested by @heftig:

6d5e65f645 (commitcomment-30938667)
2018-10-18 19:50:29 +02:00
Lennart Poettering 085f3d6416 json: add an assert_cc() check that validates _JSON_VARIANT_MAGIC_MAX 2018-10-18 16:44:51 +02:00
Lennart Poettering 7e61bd0f67 macro.h: include assert.h so that static_assert can be properly checked for
For the definition of assert_cc() we try to use static_assert and check
for it with "#ifdef". But that can only work if assert.h is imported
before. Hence let's do so.
2018-10-18 16:44:51 +02:00
Lennart Poettering d520d519f0 json: add support for using static const strings directly as JsonVariant objects
This is a nice little optimization when using static const strings: we
can now use them directly as JsonVariant objecs, without any additional
allocation.
2018-10-18 16:44:51 +02:00
Lennart Poettering 4fcb507a90 json: minor optimization
instead of comparing the magic JsonVariants one by one, let's simply
compare that they lie within a specific range.
2018-10-18 16:44:51 +02:00
Lennart Poettering d77e781fd0 json: when creating an object, insist that every second item is a string
After all, those are the keys, which have to be keys.
2018-10-18 16:44:51 +02:00
Lennart Poettering b2fa0d4fca json: enforce a maximum nesting depth for json variants
Simply as a safety precaution so that json objects we read are not
arbitrary amounts deep, so that code that processes json objects
recursively can't be easily exploited (by hitting stack limits).

Follow-up for oss-fuzz#10908

(Nice is that we can accomodate for this counter without increasing the
size of the JsonVariant object.)
2018-10-18 16:44:51 +02:00
Lennart Poettering a7efb03039 json: slightly reorder JsonVariant
Let's move things around a bit, so that the trailing unused whitespace
within the structure due to padding is placed together, so that it is
easier to use for new fields. (Found with pahole)
2018-10-18 16:44:51 +02:00
Lennart Poettering 4ae7e4e5d8 json: avoid stack allocation of long strings in a recursive function
Fixes: oss-fuzz#10908

https://oss-fuzz.com/v2/testcase-detail/5639441482252288
2018-10-18 16:44:51 +02:00
Lennart Poettering 92853e9bbe json: return a double when we shall return a double 2018-10-18 16:44:51 +02:00
Lennart Poettering a1559e3f53 json: use structured initialization all the way 2018-10-18 16:44:51 +02:00
Lennart Poettering 8f7329ac27 exec-util: errors are reported by non-zero, not negative by putenv() 2018-10-18 16:40:12 +02:00
Lennart Poettering 8d2b9d14c4 time-util: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 7e7a16a00e process-util: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering f5af75eaec mount-util: FOREACH_LINE() excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering d2b39cb606 cgroup-util: FOREACH_LINE() excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering d3f9790c81 terminal-util: use fgetc() carefully instead of fread() 2018-10-18 13:32:34 +02:00
Lennart Poettering 715bcf361d terminal-util: excorcise fgets() 2018-10-18 13:32:05 +02:00
Lennart Poettering 6d3db278fe clock-util: excorcise fgets() 2018-10-18 13:30:20 +02:00
Yu Watanabe 103341f9f8
Merge pull request #10438 from poettering/path-is-valid
be a bit more carful when processing transient socket paths via the bus
2018-10-18 06:20:41 +09:00
Lennart Poettering 67f5d31b45
Merge pull request #10440 from poettering/fflush-and-check-some-more
use fflush_and_check() and free_and_replace() where we can
2018-10-17 22:54:34 +02:00
Lennart Poettering a42984dbc7
Merge pull request #10428 from keszybz/failure-actions
Implement manager status changes using SuccessAction=
2018-10-17 21:29:10 +02:00
Lennart Poettering c93d527f46 exec-util: use fflush_and_check() where appropriate 2018-10-17 21:23:34 +02:00
Lennart Poettering 656552ebb3 path-util: add new path_is_valid() helper 2018-10-17 21:13:02 +02:00
Lennart Poettering 3088305166 list: fix double avaluation in LIST_APPEND() 2018-10-17 21:13:02 +02:00
Lennart Poettering d3e66e684f env-util: drop ARG_MAX define
It's not a constant, hence don't pretend it was.
2018-10-17 20:51:14 +02:00
Lennart Poettering fcbb657460 env-util: modernize strv_env_set() a bit 2018-10-17 20:51:14 +02:00
Lennart Poettering 04effffd84 env-util: modernize strv_env_replace() 2018-10-17 20:51:14 +02:00
Lennart Poettering 2d3ff1decb env-util: rework strv_env_merge()
Let's clean up the failure codepaths, by using _cleanup_.

This relies on the new behaviour of env_append() introduced in the
previous commit that guarantess the list always remains properly NULL
terminated
2018-10-17 20:51:14 +02:00
Lennart Poettering 2a13184a43 env-util: rework env_append()
Let's make sure the strv we are putting together always remains valid
(i.e. is NULL terminated). Also document the parameters to pass in
correctly.
2018-10-17 20:51:14 +02:00
Lennart Poettering 68ac147e8d env-util: use strv_contains() where appropriate 2018-10-17 20:51:14 +02:00
Lennart Poettering 8aeb1d3176
Merge pull request #10244 from poettering/nofile-bump
bump RLIMIT_NOFILE
2018-10-17 17:59:36 +02:00
Zbigniew Jędrzejewski-Szmek 1bcf3fc6c5 core: return true from cg_is_empty* on ENOENT 2018-10-17 17:49:57 +02:00
Zbigniew Jędrzejewski-Szmek c02b6ee496 meson: define @HIGH_RLIMIT_NOFILE@ and use it everywhere 2018-10-17 14:54:48 +02:00
Lennart Poettering c8884aceef main: introduce a define HIGH_RLIMIT_MEMLOCK similar to HIGH_RLIMIT_NOFILE 2018-10-17 14:40:44 +02:00
Lennart Poettering 5450a37e3c
Merge pull request #10419 from yuwata/fix-prioq
Fix segfault in prioq_remove() with empty Prioq object
2018-10-16 19:56:04 +02:00
Yu Watanabe 90c88092e6 tree-wide: use CMP() macro where applicable
Follow-up for 6dd91b3682.
2018-10-16 19:55:38 +02:00
Yu Watanabe 8da2f9e807
Merge pull request #10412 from poettering/sockaddr-sun-path
various fixes related to struct sockaddr_un handling
2018-10-17 01:25:58 +09:00
Yu Watanabe 0cb3b295ec prioq: use structrued initializer 2018-10-17 01:09:41 +09:00
Yu Watanabe e6e637a11a prioq: fix index range check 2018-10-17 01:09:41 +09:00
Yu Watanabe 9f934223b2 prioq: add one more assertion 2018-10-17 01:08:51 +09:00
Lennart Poettering 6dd91b3682 tree-wide: CMP()ify all the things
Let's employ coccinelle to fix everything up automatically for us.
2018-10-16 17:45:53 +02:00
Lennart Poettering 0bbee2c226 rlimit-util: don't call setrlimit() needlessly if it wouldn't change anything
Just a tiny tweak to avoid generating an error if there's no need to.
2018-10-16 16:33:55 +02:00
Lennart Poettering 99ab6fdf8c core: add a new call for bumping RLIMIT_NOFILE to "high" values
Following discussions with some kernel folks at All Systems Go! it
appears that file descriptors are not really as expensive as they used
to be (both memory and performance-wise) and it should thus be OK to allow
programs (including unprivileged ones) to have more of them without ill
effects.

Unfortunately we can't just raise the RLIMIT_NOFILE soft limit
globally for all processes, as select() and friends can't handle fds
>= 1024, and thus unexpecting programs might fail if they accidently get
an fd outside of that range. We can however raise the hard limit, so
that programs that need a lot of fds can opt-in into getting fds beyond
the 1024 boundary, simply by bumping the soft limit to the now higher
hard limit.

This is useful for all our client code that accesses the journal, as the
journal merging logic might need a lot of fds. Let's add a unified
function for bumping the limit in a robust way.
2018-10-16 16:33:55 +02:00
Lennart Poettering d6e069f412 def: add a "high" limit for RLIMIT_NOFILE
This simply adds a new constant we can use for bumping RLIMIT_NOFILE to
a "high" value. It default to 256K for now, which is pretty high, but
smaller than the kernel built-in limit of 1M.

Previously, some tools that needed a higher RLIMIT_NOFILE bumped it to
16K. This new define goes substantially higher than this, following the
discussion with the kernel folks.
2018-10-16 16:33:55 +02:00
Lennart Poettering a53f90ca24 siphash24: add helper for calculating the hash value for a string
Let's shorten some code.
2018-10-16 16:27:15 +02:00
Yu Watanabe cd86deefa1 util: fix segfault in prioq_remove() with empty Prioq object 2018-10-16 22:27:30 +09:00
Yu Watanabe d13b5f5a85 util,test: introduce cleanup function prioq_freep()
This also simplifies test-prioq.c.
2018-10-16 22:17:08 +09:00
Lennart Poettering 2011149a3c
Merge pull request #10327 from yuwata/test-sd-device-enumerator-subsystem
sd-device-enumerator: dedup enumerated devices and add test for subsystem filtering
2018-10-16 12:48:01 +02:00
Lennart Poettering 6d5e65f645 tree-wide: add a single version of "static const int one = 1"
All over the place we define local variables for the various sockopts
that take a bool-like "int" value. Sometimes they are const, sometimes
static, sometimes both, sometimes neither.

Let's clean this up, introduce a common const variable "const_int_one"
(as well as one matching "const_int_zero") and use it everywhere, all
acorss the codebase.
2018-10-15 19:40:51 +02:00
Lennart Poettering 8e8132c6b8 socket-util: tighten socket_address_verify() checks a bit 2018-10-15 19:40:51 +02:00
Lennart Poettering 48e6a2dc84 socket-util: tweak commenting in socket_address_get_path()
Let's make clear explicitly that there's always a NUL byte following the
path, and how.
2018-10-15 19:40:51 +02:00
Lennart Poettering 69995bffb7 socket-util: include trailing NUL byte in SOCKADDR_UN_LEN() count for fs sockets
This is what unix(7) recommends, hence do so.
2018-10-15 19:40:51 +02:00
Lennart Poettering 5cf91ea9c8 socket-util: add sockaddr_un_set_path() helper
Properly initializing sun_path from foreign data is not easy, given the
size constraints, and NUL confusion. Let's add a helper function for
this.
2018-10-15 19:35:00 +02:00
Lennart Poettering 686192048a strxcpyx: minor coding style updates 2018-10-15 19:35:00 +02:00
Lennart Poettering 057e85805c socket-address: document socket address parsing size restrictions in a comment 2018-10-15 19:35:00 +02:00
Lennart Poettering 9ec30b2769 socket-util: use structured initialization 2018-10-15 19:35:00 +02:00
Lennart Poettering 9f20fc28f0 socket-util: add new sockaddr_un_unlink() helper
The helper is supposed to properly handle cases where .sun_path does not
contain a NUL byte, and thus copies out the path suffix a NUL as
necessary.

This also reworks the more specific socket_address_unlink() to be a
wrapper around the more generic sockaddr_un_unlink()
2018-10-15 19:35:00 +02:00
Lennart Poettering 242c41b850 alloc-util: add alloca() counterparts for memdup() and memdup_suffix0() 2018-10-15 19:35:00 +02:00
Yu Watanabe 7ef670c34a hashmap: introduce hashmap_first_key_and_value() and friends 2018-10-13 21:45:50 +09:00
Lennart Poettering ee7b9f1dfc format-table: don't use unsigned when there's no point in it
CID 1394372
2018-10-13 12:37:13 +02:00
Lennart Poettering fcadf032c0 json: fix memleak on OOM
CID 1396083
2018-10-13 12:37:13 +02:00
Yu Watanabe fd8879498d Revert "alloc-util: return NULL if 0-sized allocation is requested"
This reverts commit c05107767b.
2018-10-13 12:34:32 +02:00
Yu Watanabe b4b3649a94
Merge pull request #10366 from poettering/in-set-fixes
IN_SET() compile time check fixes
2018-10-13 17:25:36 +09:00
Lennart Poettering a6ee956610
Merge pull request #10356 from dtardon/covscan
assorted coverity/clang fixes
2018-10-12 18:43:04 +02:00
David Tardon c05107767b alloc-util: return NULL if 0-sized allocation is requested
That would almost certainly be an error (e.g., an overflow in computing
_need_), so it's better to fail.
2018-10-12 14:51:35 +02:00
Lennart Poettering 8e2b687957 macro: rework IN_SET a bit
This makes use of assert_cc() to guard against missing CASE macros,
instead of a manual implementation that might result in a static
variable to be allocated.

More importantly though this changes the base type for the array used to
determine the number of arguments for the compile time check from "int"
to "long double". This is done in order to avoid warnings from "ubsan"
that possibly large constants are assigned to small types. "long double"
hopefully isn't vulnerable to that.

Fixes: #10332
2018-10-11 22:07:14 +02:00
Lennart Poettering 696c0b890e macro: drop -Wdeclaration-after-statement exclusion magic, we dropped that warning anyway from our build 2018-10-11 22:05:55 +02:00
Lennart Poettering 960d4b29d7
Merge pull request #10334 from keszybz/nomempool
Use mempool only in progs linked to libsystemd-shared.so
2018-10-11 13:44:34 +02:00
Zbigniew Jędrzejewski-Szmek a5d8835c78 mempool: only enable mempool use when linked to libsystemd-shared.so
Mempool use is enabled or disabled based on the mempool_use_allowed symbol that
is linked in.

Should fix assert crashes in external programs caused by #9792.
Replaces #10286.

v2:
- use two different source files instead of a gcc constructor
2018-10-11 11:10:37 +02:00
Zbigniew Jędrzejewski-Szmek 7c48ea0280 Move use_pool() to mempool.c and rename to mempool_enabled()
The only user is in hashmap.c, but it's a mempool thing.
2018-10-11 10:55:41 +02:00
Zbigniew Jędrzejewski-Szmek 2a56a88f46
Merge pull request #10316 from poettering/json-api
just the json stuff from #9762
2018-10-10 14:21:18 +02:00
Zbigniew Jędrzejewski-Szmek 98359a012a
Merge pull request #10349 from poettering/bus-creds-shift-overflow
sd-bus creds bitshift overflow fix
2018-10-10 12:04:33 +02:00
Lennart Poettering 65f95765d0 tree-wide: various ubsan zero size memory fixes
Fixes: #10346
2018-10-10 12:00:56 +02:00
Lennart Poettering 5f00c5684f capability: introduce CAP_TO_MASK_CORRECTED() macro replacing CAP_TO_MASK()
linux/capability.h's CAP_TO_MASK potentially shifts a signed int "1"
(i.e. 32bit wide) left by 31 which means it becomes negative. That's
just weird, and ubsan complains about it. Let's introduce our own macro
CAP_TO_MASK_CORRECTED which doesn't fall into this trap, and make use of
it.

Fixes: #10347
2018-10-10 11:11:48 +02:00
Lennart Poettering cd0b6c5390 json: add a nice JSON parser
As preparation for OCI support in nspawn, let's add a JSON parser.

The json.h file contains an explanation why this is new code instead of
just us linking against an existing JSON library.
2018-10-10 10:13:30 +02:00
Roman Gushchin 084c700780 core: support cgroup v2 device controller
Cgroup v2 provides the eBPF-based device controller, which isn't currently
supported by systemd. This commit aims to provide such support.

There are no user-visible changes, just the device policy and whitelist
start working if cgroup v2 is used.
2018-10-09 09:47:51 -07:00
Roman Gushchin 17f149556a core: refactor bpf firewall support into a pseudo-controller
The idea is to introduce a concept of bpf-based pseudo-controllers
to make adding new bpf-based features easier.
2018-10-09 09:46:08 -07:00
Lennart Poettering d09a71356e terminal-util: extra safety checks when parsing $COLUMNS or $LINES (#10314)
Let's make sure the integers we parse out are not larger than USHRT_MAX.
This is a good idea as the kernel's TIOCSWINSZ ioctl for sizing
terminals can't take larger values, and we shouldn't risk an overflow.
2018-10-09 16:49:04 +09:00
Lennart Poettering db9a42545a chattr: optionally, return the old flags when updating them 2018-10-08 21:40:44 +02:00
Lennart Poettering 1634ebb54a
Merge pull request #10262 from keszybz/hibres-disable
Switches to disable hibernation and/or resuming
2018-10-08 21:39:54 +02:00
Lennart Poettering 3ccf61268f mount-util: show mount source in failure log message (#10312) 2018-10-08 11:59:11 -07:00
Zbigniew Jędrzejewski-Szmek 9a135c084a basic/proc-cmdline: allow parsing of cmdline from a string
Comes with tests.

Also add direct test for $SYSTEMD_PROC_CMDLINE.

In test-proc-cmdline, "true" was masquerading as PROC_CMDLINE_STRIP_RD_PREFIX,
fix that. Also, reorder functions to match call order.
2018-10-08 17:05:19 +02:00
Zbigniew Jędrzejewski-Szmek 1af294fc82 Drop empty lines in proc-cmdline.c 2018-10-08 17:05:18 +02:00
Zbigniew Jędrzejewski-Szmek 0307ea49c7 Add $SYSTEMD_IN_INITRD=yes|no override for debugging 2018-10-08 16:04:51 +02:00
Thomas Haller afbae3e9f2 path-util: fix path_simplify() with kill_dots and "."
Previously, together with kill_dots true, patch like
".", "./.", ".//.//" would all return an empty string.

That is wrong. There must be one "." left to reference
the current directory.

Also, the comment with examples was wrong.
2018-10-05 21:41:33 +02:00
Yu Watanabe c250bf671b core/dbus-execute: fix parsing CPUScheduling* and Nice for transient services
Fixes #10290.
2018-10-05 21:41:05 +02:00
Frank Schaefer 14ee72b7d8 * hack around deficiencies in prctl() PR_SET_MM_* 2018-10-05 21:40:41 +02:00
Lennart Poettering ad191df836
Merge pull request #10134 from keszybz/test-runner
Some test-related fixed and a test runner for installed tests
2018-10-05 20:35:30 +02:00
Lennart Poettering 083d27b654
Merge pull request #10152 from yuwata/udev-use-extract
udev: small cleanups
2018-10-05 17:11:43 +02:00
Zbigniew Jędrzejewski-Szmek 9a21d8b9fd
Merge pull request #10251 from poettering/renameat-racy
rename_noreplace() fallback for file systems where neither RENAME_REPLACE nor link()/unlinkat() is available
2018-10-03 13:37:53 +02:00
Lennart Poettering eb74d3b97a
Merge pull request #10249 from keszybz/lgtm-fixes
Fixes for issues found by LGTM
2018-10-02 17:42:55 +02:00
Lennart Poettering 2f15b6253a fs-util: add racy RENAME_NOREPLACE fallback using access()
Apparently FAT on some recent kernels can't do RENAME_NOREPLACE, and of
course cannot do linkat()/unlinkat() either (as the hard link concept
does not exist on FAT). Add a fallback using an explicit beforehand
faccessat() check. This sucks, but what we can do if the safe operations
are not available?

Fixes: #10063
2018-10-02 16:11:10 +02:00
Lennart Poettering eaa680c09e fileio: fix error propagation in link_tmpfile() 2018-10-02 16:11:10 +02:00
Zbigniew Jędrzejewski-Szmek 3d6c184474 basic/hexdecoct: check for overflow
LGTM was complaining:
> Multiplication result may overflow 'int' before it is converted to 'long'.
Fix this by changing all types to ssize_t and add a check for overflow
while at it.
2018-10-02 12:54:00 +02:00
Zbigniew Jędrzejewski-Szmek 7f546026ab Introduce free_and_strndup and use it in bus-message.c
v2: fix error in free_and_strndup()

When the orignal and copied message were the same, but shorter than specified
length l, memory read past the end of the buffer would be performed. A test
case is included: a string that had an embedded NUL ("q\0") is used to replace
"q".

v3: Fix one more bug in free_and_strndup and add tests.

v4: Some style fixed based on review, one more use of free_and_replace, and
make the tests more comprehensive.
2018-10-02 11:42:45 +02:00
Thomas Haller f21f31b24b trivial: fix spelling in code comments
Based-on-patch-by: Rafael Fontenelle <rafaelff@gnome.org>
2018-09-30 21:32:33 +02:00
Lennart Poettering 2f3db9c907 uft8: add comment, requested by @keszybz 2018-09-27 17:21:18 +02:00
Zbigniew Jędrzejewski-Szmek b6de93096e
Merge pull request #10173 from poettering/sd-boot-utf
the utf8.c changes from PR #9437 (i.e. the boot counting PR)
2018-09-27 08:21:20 +02:00
Anita Zhang c87700a133 Make Watchdog Signal Configurable
Allows configuring the watchdog signal (with a default of SIGABRT).
This allows an alternative to SIGABRT when coredumps are not desirable.

Appropriate references to SIGABRT or aborting were renamed to reflect
more liberal watchdog signals.

Closes #8658
2018-09-26 16:14:29 +02:00
Yu Watanabe 8059aa9c92 strv: introduce 'relax' mode to strv_split_full()
If SPLIT_RELAX is specified, then it accepts unfinished quotes or
missing separator after right quote.
2018-09-26 22:48:17 +09:00
Yu Watanabe 2c3a11d86e strv: allow to set separator NULL in strv_split() or strv_split_full() 2018-09-26 19:20:43 +09:00
Yu Watanabe af0b60b37c strv: introduce strv_split_full() which optionally handle quotes 2018-09-26 19:17:51 +09:00
Zbigniew Jędrzejewski-Szmek 97c7469bbe
Merge pull request #10169 from poettering/putenv-error-handling
add missing putenv() error handling
2018-09-25 19:50:49 +02:00
Lennart Poettering 80b0a59729 utf8: add utf8_to_utf16() helper 2018-09-25 15:57:47 +02:00
Lennart Poettering 2ac2ff3fc1 utf8: let's update utf16_to_utf8() a bit
Let's change utf16_to_utf8() prototype to refer to utf16 chars with char16_t rather than void

Let's not cast away a "const" needlessly.

Let's add a few comments.

Let's fix the calculations of the buffer size to allocate, and how long
to run the loop in case of uneven byte numbers
2018-09-25 15:57:47 +02:00
Lennart Poettering 7c42185784 utf8: change return type of utf8_encoded_expected_len() to size_t
After all it returns a lengths of a string in chars, and hence should
return size_t, exactly like strlen().
2018-09-25 15:57:47 +02:00
Lennart Poettering 07667be733 utf8: modernize utf16 inline calls a bit
Let's fix an indentation issue.

Let's avoid yoda comparisons.

Let's drop unnecessary ().

Let's make sure we convert 16bit values to 32bit before shifting them by
10bit to the left, to avoid overflows.

Let's avoid comparisons between signed literals and unsigned variables,
in particular if the literals are outside of the minimum range C
requires for "int".
2018-09-25 15:57:47 +02:00
Lennart Poettering e71fb4b302 utf8: update utf8_is_valid() a bit
Let's avoid a few casts in the function. Also, let's drop the "const"
when returning the string, for similar reasons as strchr() and friends
drop it: so that we don't add a const if the user passes in a non-const
string.
2018-09-25 15:57:47 +02:00
Lennart Poettering 7c428bb5d5
Merge pull request #10059 from yuwata/env-exec-directory
core: introduce $RUNTIME_DIRECTORY= or friends
2018-09-25 12:34:30 +02:00
Lennart Poettering 653d469519 exec-util: add missing logging call
This function logs about all errors, but one case was forgotten. Fix
that.
2018-09-25 12:04:14 +02:00
Lennart Poettering ed689f7894 exec-util: handle putenv() errors
Just paranoia, as putenv() can fail and we should catch it, like we
catch all other errors.

Follow-up for #10073
2018-09-25 12:04:14 +02:00
Zbigniew Jędrzejewski-Szmek 3318fd9c24
Merge pull request #10073 from xnox/execve
Execute generators with manager's environment exported
2018-09-25 10:07:23 +02:00
Lennart Poettering de89949a71 btrfs: fix loopback resizing code
This corrects the block device to use, to the right path, as it was
before 553e15f21b.

Replaces: #10153
2018-09-24 19:44:06 +02:00
Yu Watanabe 6c9c51e5e2 fs-util: make symlink_idempotent() optionally create relative link 2018-09-24 18:52:53 +03:00
Zbigniew Jędrzejewski-Szmek c745d2bfa0 basic/mount-util: reword debug message
"because blacklisted" is not grammatical, it should be something like
"becuase it is blacklisted", which in turn in too verbose. Let's use
a shorter form.
2018-09-24 15:42:50 +02:00
Dimitri John Ledkov 78ec1bb436 exec-util: in execute_directories, support initial exec environment 2018-09-24 13:40:10 +01:00
Yu Watanabe bc861c2e09 tree-wide: use typesafe_bsearch() or typesafe_bsearch_r() 2018-09-19 08:08:03 +09:00
Yu Watanabe f0f6d791fe util: introduce typesafe_bsearch() and typesafe_bsearch_r() 2018-09-19 08:06:57 +09:00
Yu Watanabe ba0a7bfb98 tree-wide: use typesafe_qsort_r() 2018-09-19 08:05:13 +09:00
Yu Watanabe 5532395be7 util: introduce typesafe_qsort_r() 2018-09-19 08:04:40 +09:00
Yu Watanabe 93bab28895 tree-wide: use typesafe_qsort() 2018-09-19 08:02:52 +09:00
Zbigniew Jędrzejewski-Szmek 6058516a14 detect-virt: do not try to read all of /proc/cpuinfo
Quoting https://github.com/systemd/systemd/issues/10074:
> detect_vm_uml() reads /proc/cpuinfo with read_full_file()
> read_full_file() has a file max limit size of READ_FULL_BYTES_MAX=(4U*1024U*1024U)
> Unfortunately, the size of my /proc/cpuinfo is bigger, approximately:
> echo $(( 4* $(cat /proc/cpuinfo | wc -c)))
> 9918072
> This causes read_full_file() to fail and the Condition test fallout.

Let's just read line by line until we find an intersting line. This also
helps if not running under UML, because we avoid reading as much data.
2018-09-18 16:53:36 +02:00
Yu Watanabe 010d436e02 verbs: reset optind (#10116)
optind may be used in each verb, e.g., udevadm. So, let's initialize
optind before calling verbs.

Without this, e.g., udevadm -d hwdb --update causes error in parsing arguments.
2018-09-18 16:24:58 +02:00
Zbigniew Jędrzejewski-Szmek 32397af3d4
Merge pull request #9928 from yuwata/libudev-cleanups
libudev: coding style updates
2018-09-15 22:36:38 +02:00
Franck Bui 10ce2e0681 socket-util: attempt SO_RCVBUFFORCE/SO_SNDBUFFORCE only if SO_RCVBUF/SO_SNDBUF fails
Both SO_SNDBUFFORCE and SO_RCVBUFFORCE requires capability 'net_admin'.

If this capability is not granted to the service the first attempt to increase
the recv/snd buffers (via sd_notify()) with SO_RCVBUFFORCE/SO_SNDBUFFORCE will
fail, even if the requested size is lower than the limit enforced by the
kernel.

If apparmor is used, the DENIED logs for net_admin will show up. These log
entries are seen as red warning light, because they could indicate that a
program has been hacked and tries to compromise the system.

It would be nicer if they can be avoided without giving services (relying on
sd_notify) net_admin capability or dropping DENIED logs for all such services
via their apparmor profile.

I'm not sure if sd_notify really needs to forcibly increase the buffer sizes,
but at least if the requested size is below the kernel limit, the capability
(hence the log entries) should be avoided.

Hence let's first ask politely for increasing the buffers and only if it fails
then ignore the kernel limit if we have sufficient privileges.
2018-09-14 13:00:38 +02:00
Yu Watanabe 2b9a7d2e96 strv: introduce strv_join_prefix() 2018-09-13 17:02:58 +09:00
Yu Watanabe be1791ad6a libudev-monitor: rename udev_has_devtmpfs() and move it to mount-util.c
As the function itself is quite generic.
2018-09-11 12:45:21 +09:00
Yu Watanabe f73fc95ea5 strbuf: accept NULL for strbuf_cleanup() 2018-09-10 18:27:36 +09:00
Dongsu Park 21224070e8 importd, basic/string-util: use case-insensitive comparison for HTTP headers
According to RFC2616[1], HTTP header names are case-insensitive. So
it's totally valid to have a header starting with either `Date:` or
`date:`.

However, when systemd-importd pulls an image from an HTTP server, it
parses HTTP headers by comparing header names as-is, without any
conversion. That causes failures when some HTTP servers return headers
with different combinations of upper-/lower-cases.

An example:
https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_developer_container.bin.bz2 returns `Etag: "pe89so9oir60"`,
while https://alpha.release.core-os.net/amd64-usr/current/coreos_developer_container.bin.bz2
returns `ETag: "f03372edea9a1e7232e282c346099857"`.
Since systemd-importd expects to see `ETag`, the etag for the Container Linux image
is correctly interpreted as a part of the hidden file name.
However, it cannot parse etag for Flatcar Linux, so the etag the Flatcar Linux image
is not appended to the hidden file name.

```
$ sudo ls -al /var/lib/machines/
-r--r--r--  1 root root 3303014400 Aug 21 20:07 '.raw-https:\x2f\x2falpha\x2erelease\x2ecore-os\x2enet\x2famd64-usr\x2fcurrent\x2fcoreos_developer_container\x2ebin\x2ebz2.\x22f03372edea9a1e7232e282c346099857\x22.raw'
-r--r--r--  1 root root 3303014400 Aug 17 06:15 '.raw-https:\x2f\x2falpha\x2erelease\x2eflatcar-linux\x2enet\x2famd64-usr\x2fcurrent\x2fflatcar_developer_container\x2ebin\x2ebz2.raw'
```

As a result, when the Flatcar image is removed and downloaded again,
systemd-importd is not able to determine if the file has been already
downloaded, so it always download it again. Then it fails to rename it
to an expected name, because there's already a hidden file.

To fix this issue, let's introduce a new helper function
`memory_startswith_no_case()`, which compares memory regions in a
case-insensitive way. Use this function in `curl_header_strdup()`.

See also https://github.com/kinvolk/kube-spawn/issues/304

[1]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
2018-09-03 22:59:27 +02:00
Yu Watanabe 7a3c343cb8 tree-wide: use '#pragma once' for header guard
Follow-up for a2b635eb39 (#9959).
2018-08-30 06:10:43 +03:00
Sjoerd Simons 9e2acd1d24 fd-util: accept that kcmp might fail with EPERM/EACCES
In a container the kcmp call might well be blocked; Accept that and fall
back to fstat in that case.
2018-08-29 17:53:00 +02:00
Yu Watanabe 22ac37aa00 string-table: do not ignore 'scope' argument 2018-08-28 12:40:25 +09:00
Yu Watanabe 1d3044e275 refcnt: introduce DEFINE_ATOMIC_REF_UNREF_FUNC() macro and friends 2018-08-28 05:09:40 +09:00
Yu Watanabe 8301aa0bf1 tree-wide: use DEFINE_TRIVIAL_REF_UNREF_FUNC() macro or friends where applicable 2018-08-27 14:01:46 +09:00
Yu Watanabe a6a08596ef macro: introduce DEFINE_TRIVIAL_REF_UNREF_FUNC() macro and friends 2018-08-27 14:01:27 +09:00
Susant Sahani 53cb501a13 networkd and sd-netlink: add support for Generic netlink And FooOverUDP to IPIP tunnel
This work add support to generic netlink to sd-netlink.
See https://lwn.net/Articles/208755/

networkd: add support FooOverUDP support to IPIP tunnel netdev
https://lwn.net/Articles/614348/

Example conf:

/lib/systemd/network/1-fou-tunnel.netdev
```
[NetDev]
Name=fou-tun
Kind=fou

[FooOverUDP]
Port=5555
Protocol=4

```

/lib/systemd/network/ipip-tunnel.netdev
```
[NetDev]
Name=ipip-tun
Kind=ipip

[Tunnel]
Independent=true
Local=10.65.208.212
Remote=10.65.208.211
FooOverUDP=true
FOUDestinationPort=5555
```

$ ip -d link show ipip-tun
```
5: ipip-tun@NONE: <POINTOPOINT,NOARP> mtu 1472 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ipip 10.65.208.212 peer 10.65.208.211 promiscuity 0
    ipip remote 10.65.208.211 local 10.65.208.212 ttl inherit pmtudisc encap fou encap-sport auto encap-dport 5555 noencap-csum noencap-csum6 noencap-remcsum numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
```
2018-08-23 11:30:37 +02:00
Yu Watanabe 71d1700afa selinux-util: drop unused variables
Follow-up for 7e531a5265.
2018-08-22 16:32:35 +02:00
Yu Watanabe 8d30fcb9b5 util: do not use stack frame for parsing arbitrary inputs
This replaces strndupa() by strndup() in socket_address_parse(),
as input string may be too long.

Fixes issue 10007 by ClusterFuzz-External:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10007
2018-08-22 15:46:32 +09:00
Lennart Poettering 97fa202a61 random-util: use RDRAND for randomness if the kernel doesn't want to give us any
Pretty much all intel cpus have had RDRAND in a long time. While
CPU-internal RNG are widely not trusted, for seeding hash tables it's
perfectly OK to use: we don't high quality entropy in that case, hence
let's use it.

This is only hooked up with 'high_quality_required' is false. If we
require high quality entropy the kernel is the only source we should
use.
2018-08-21 20:13:32 +02:00
Zbigniew Jędrzejewski-Szmek 0566668016
Merge pull request #9712 from filbranden/socket1
socket-util: Introduce send_one_fd_iov() and receive_one_fd_iov()
2018-08-21 19:45:44 +02:00
Zbigniew Jędrzejewski-Szmek 7692fed98b
Merge pull request #9783 from poettering/get-user-creds-flags
beef up get_user_creds() a bit and other improvements
2018-08-21 10:09:33 +02:00
Zbigniew Jędrzejewski-Szmek 43ad3ad7ea Rename USER_CREDS_SYNTHESIZE_FALLBACK to …_PREFER_NSS 2018-08-20 16:06:41 +02:00
Lennart Poettering fafff8f1ff user-util: rework get_user_creds()
Let's fold get_user_creds_clean() into get_user_creds(), and introduce a
flags argument for it to select "clean" behaviour. This flags parameter
also learns to other new flags:

- USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for
  root/nobody are only synthesized as fallback. Normally, the synthesized
  records take precedence over what is in the user database.  With this
  flag set this is reversed, and the user database takes precedence, and
  the synthesized records are only used if they are missing there. This
  flag should be set in cases where doing NSS is deemed safe, and where
  there's interest in knowing the correct shell, for example if the
  admin changed root's shell to zsh or suchlike.

- USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by
  numeric value, and there's no user/group record for it accept it
  anyway. This allows us to fix #9767

This then also ports all users to set the most appropriate flags.

Fixes: #9767

[zj: remove one isempty() call]
2018-08-20 15:58:21 +02:00
Zbigniew Jędrzejewski-Szmek 5664144bd3
Merge pull request #9809 from poettering/tmpfiles-cleanup
various tmpfiles fixes
2018-08-20 12:51:57 +02:00
Lennart Poettering 37ec0fdd34 tree-wide: add clickable man page link to all --help texts
This is a bit like the info link in most of GNU's --help texts, but we
don't do info but man pages, and we make them properly clickable on
terminal supporting that, because awesome.

I think it's generally advisable to link up our (brief) --help texts and
our (more comprehensive) man pages a bit, so this should be an easy and
straight-forward way to do it.
2018-08-20 11:33:04 +02:00
Yu Watanabe 53c442ef63 util: improve comments why we ignore EACCES and EPERM
Follow-up for ef454fd193 (#9848).
2018-08-20 10:16:09 +02:00
Yu Watanabe ef454fd193 util: bind_remount_recursive_with_mountinfo(): ignore submounts which cannot be accessed
Fixes #9844.
2018-08-10 14:30:55 +09:00
Lennart Poettering 2e6e616887 btrfs-util: unfuck tmpfiles' subvol creation
tmpfiles now passes an O_PATH fd to btrfs_subvol_make_fd() under the
assumption it will accept it like mkdirat() does. So far this assumption
was wrong, let's correct that.

Without that tmpfiles' on btrfs file systems failed systematically...
2018-08-08 11:59:39 +02:00
Yu Watanabe a5ee33b951 syslog: fix segfault in syslog_parse_priority() 2018-08-08 18:27:15 +09:00
Yu Watanabe f30faf854b util: introduce memcmp_safe() 2018-08-08 17:11:50 +09:00
Filipe Brandenburger a0edd02e43 tree-wide: Convert compare_func's to use CMP() macro wherever possible.
Looked for definitions of functions using the *_compare_func() suffix.

Tested:
- Unit tests passed (ninja -C build/ test)
- Installed this build and booted with it.
2018-08-06 19:26:35 -07:00
Filipe Brandenburger 84fb2131d0 macros: add CMP(a, b) macro.
Macro returns -1, 0, 1 depending on whether a < b, a == b or a > b.

It's safe to use on unsigned types.

Add tests to confirm corner cases are properly covered.
2018-08-06 19:19:05 -07:00
Filipe Brandenburger 117efe065a macro: drop __extension__, reformat and reindent
Drop __extension__, since we don't use gcc -Wpedantic or -ansi.

Reformat code for spacing. Add spaces after commas almost everywhere.
Reindent code blocks in macro definitions, for consistency.
2018-08-06 19:15:02 -07:00
Franck Bui 0ec113366d smack-util: use 'path' paremeter as is if it's already absolute in mac_smack_fix_at() 2018-08-06 20:25:56 +02:00
Zbigniew Jędrzejewski-Szmek 7735d9397b
Merge pull request #9792 from poettering/hashmap-mempool
minor hashmap fixes
2018-08-06 14:13:30 +02:00
Yu Watanabe 68c597e9e4 resolve: treat some icmp errors as disconnected
Fixes #9773.
2018-08-06 09:57:00 +02:00
Lennart Poettering 685499007f
Merge pull request #8822 from fbuihuu/rfc-tmpfiles-safe-upstream
Make tmpfiles safe
2018-08-03 18:11:36 +02:00
Lennart Poettering 205c085bc3 hashmap: add an explicit assert() for detecting when objects migrated between threads
When clients don't follow protocol and use the same object from
different threads, then we previously would silently corrupt memory.
With this assert we'll fail with an assert(). This doesn't fix anything
but certainly makes mis-uses easier to detect and debug.

Triggered by https://bugzilla.redhat.com/show_bug.cgi?id=1609349
2018-08-03 17:36:11 +02:00
Lennart Poettering b4f607433c hashmap: add an environment variable to turn off the memory pool used by hashmaps
Triggered by https://bugzilla.redhat.com/show_bug.cgi?id=1609349
2018-08-03 17:36:11 +02:00
Filipe Brandenburger d34673ecb8 socket-util: Introduce send_one_fd_iov() and receive_one_fd_iov()
These take a struct iovec to send data together with the passed FD.

The receive function returns the FD through an output argument. In case data is
received, but no FD is passed, the receive function will set the output
argument to -1 explicitly.

Update code in dynamic-user to use the new helpers.
2018-08-02 09:25:04 -07:00
Yu Watanabe 2357724699 basic: use FAMILY_ADDRESS_SIZE() macro in hash_ops for in_addr_data 2018-08-02 17:07:25 +09:00
Yu Watanabe 6c39e02609 basic: introduce in_addr_data_hash_ops 2018-07-31 15:45:38 +09:00
Franck Bui 7f6240fab1 path-util: make use of path_join() in path_make_absolute_cwd() 2018-07-30 16:06:02 +02:00
Franck Bui 1f56e4ce77 fs-util: add new CHASE_NOFOLLOW flag to chase_symlinks()
This flag mimics what "O_NOFOLLOW|O_PATH" does for open(2) that is
chase_symlinks() will not resolve the final pathname component if it's a
symlink and instead will return a file descriptor referring to the symlink
itself.

Note: if CHASE_SAFE is also passed, no safety checking is performed on the
transition done if the symlink would have been followed.
2018-07-30 15:54:03 +02:00
Franck Bui 4fe3828c58 fs-util: introduce mkfifoat_atomic() helper 2018-07-30 15:54:03 +02:00
Franck Bui 43231f00c2 fileio: make tempfn_random_child() accept empty string as path
In this case it simply returns the random generated filename with anything
prefixed.
2018-07-30 15:54:03 +02:00
Franck Bui a12e4ade1b basic/stat-util: introduce is_dir_fd() 2018-07-30 15:54:03 +02:00
Franck Bui 62f9666ae0 btrfs-util: introduce btrfs_subvol_make_fd() 2018-07-30 15:54:03 +02:00
Franck Bui 1e9126316f basic/label: introduce mkdirat_label()/mkdirat_errno_wrapper() helpers 2018-07-30 15:54:03 +02:00
Franck Bui 7e531a5265 selinux: introduce mac_selinux_create_file_prepare_at() 2018-07-30 15:54:03 +02:00
Franck Bui 2c3d5adde0 smack: introduce mac_smack_fix_at() 2018-07-30 15:54:03 +02:00
Daniel 1595b257df void call of page_size guarantees that sysconf is not called from signal handler 2018-07-26 15:39:12 +02:00
Zbigniew Jędrzejewski-Szmek 54fe2ce1b9
Merge pull request #9504 from poettering/nss-deadlock
some nss deadlock love
2018-07-26 10:16:25 +02:00
Zbigniew Jędrzejewski-Szmek cf6e28f3cb
Merge pull request #9484 from poettering/permille-everywhere
Permille everywhere
2018-07-26 10:13:56 +02:00
Lennart Poettering 1e5057b904 sd-bus: allow connecting to the pseudo-container ".host"
machined exposes the pseudo-container ".host" as a reference to the host
system, and this means "machinectl login .host" and "machinectl shell
.host" get your a login/shell on the host. systemd-run currently doesn't
allow that. Let's fix that, and make sd-bus understand ".host" as an
alias for connecting to the host system.
2018-07-25 22:48:11 +02:00
Lennart Poettering 8cbc92d597 parse-util: in parse_permille() check negative earlier
If 'v' is negative, it's wrong to add the decimal to it, as we'd
actually need to subtract it in this case. But given that we don't want
to allow negative vaues anyway, simply check earlier whether what we
have parsed so far was negative, and react to that before adding the
decimal to it.
2018-07-25 16:14:45 +02:00
Lennart Poettering f7b8b5c4fb pam_systemd: move socket_from_display() from util.[ch] to pam_systemd.c
It's highly specific, kinda legacy (X11…) and only used at one place,
let's move this out of the common code, and into pam_systemd.c where it
is used.
2018-07-25 16:09:33 +02:00
Zbigniew Jędrzejewski-Szmek 17086a40c1
Merge pull request #9668 from poettering/open-parent
introduce open_parent() helper
2018-07-25 12:58:45 +02:00
Lennart Poettering 1d2d351319
Merge pull request #9658 from LukeShu/to-upstream/misc-cleanup
nspawn: Miscellaneous touch-up
2018-07-23 17:44:56 +02:00
Lennart Poettering 0c462ea4ef tree-wide: port various bits over to open_parent() 2018-07-23 13:38:18 +02:00
Lennart Poettering ef8becfac5 fs-util: introduce open_parent() helper
We often open the parent directory of a path. Let's add a common helper
for that, that shortens our code a bit and adds some extra safety
checks, for example it will fail if used on the root directory (which
doesn't really have a parent).

The helper is actually generalized from a function in btrfs-util.[ch]
which already existed for this purpose.
2018-07-23 13:38:18 +02:00
Lennart Poettering 09942654d3 fileio: add additional safety checks
Let's protect against attempts to create temporary files above the root
dir, as that makes little sense.

Let's better be safe than sorry.
2018-07-23 13:38:18 +02:00
Luke Shumaker f09e86bcaa cgroup-util: cg_kernel_controllers(): Fix comment about including "name="
Remove "arbitrary named hierarchies" from the list of things that
cg_kernel_controllers() might return, and clarify that "name="
pseudo-controllers are not included in the returned list.

/proc/cgroups does not contain "name=" pseudo-controllers, and
cg_kernel_controllers() makes no effort to enumerate them via a different
mechanism.
2018-07-20 12:12:02 -04:00
Lennart Poettering 6b228852bc path-util: avoid name clashes
One of those days we should rework this to use the UNIQ macros, but for
now, an underscore should be enough.
2018-07-20 16:57:35 +02:00
Lennart Poettering ccfc19c960 env-util: make env-util.h self contained
The header file references strlen(), hence it should include string.h
2018-07-20 16:57:35 +02:00
Lennart Poettering 496a6ba40e
Merge pull request #9516 from keszybz/module-load-unification
Module load unification
2018-07-20 13:55:56 +02:00
Lennart Poettering 9638adaf21
Merge pull request #9614 from poettering/negative-sec
parse-util: make sure "-0.-0s" is not considered a valid time specifi…
2018-07-20 13:22:01 +02:00
Filipe Brandenburger 279f52a1d3 parse-util: make sure "3.+1s" or "3. 1s" are not considered valid time specification
Indeed, strtoll() is super-hard to use properly! :-(

Also added more tests for those cases and copied the tests to parse_nsec as well.
2018-07-19 22:09:54 -07:00
Filipe Brandenburger d9fb7afb48 coverity: Add custom assertion macros for Coverity
These custom macros make the expression go through a function, in order
to prevent ASSERT_SIDE_EFFECT false positives on our macros such as
assert_se() and assert_return() that cannot be disabled and will always
evaluate their expressions.

This technique has been described and recommended in:
https://community.synopsys.com/s/question/0D534000046Yuzb/suppressing-assertsideeffect-for-functions-that-allow-for-sideeffects

Tested by doing a local cov-build and uploading the resulting tarball to
scan.coverity.com, confirmed that the ASSERT_SIDE_EFFECT false positives
were gone.
2018-07-19 09:07:25 +02:00
Zbigniew Jędrzejewski-Szmek 1d7aedf11a meson: remove false check for key_serial_t
key_serial_t is defined in keyutil.h, which wasn't included in the header list
in the test, so the test always failed. We were always compiling stuff with
!HAVE_KEY_SERIAL_T.

We could try to add keyutil.h to the test, but then we'd have to first check if
it is available, which just doesn't seem worth the trouble.

key_serial_t should always be defined as int32_t. Let's keep the uncoditional
define, since repeated compatible typedefs are not a problem, and it allows us
to compile even if the header file is missing. If there's ever a change in the
definition, we'll have to adjust the code for the different type anyway, and
our compiler will tell us.
2018-07-18 17:46:33 +02:00
Zbigniew Jędrzejewski-Szmek 9c869d08d8 meson: unify linux/stat.h check with other checks and use _GNU_SOURCE
Using _GNU_SOURCE is better because that's how we include the headers in the
actual build, and some headers define different stuff when it is defined.
sys/stat.h for example defines 'struct statx' conditionally.
2018-07-18 17:40:41 +02:00
Lennart Poettering 5a9fb35843 parse-util: make sure "-0.-0s" is not considered a valid time specification
Did I mention that strtoll() is super-hard to use properly?
2018-07-17 13:01:46 +02:00
Yu Watanabe 2bb8d8d9b2 process-util: do not hide global variable
Suggested by LGTM.
2018-07-17 03:06:45 +09:00
Yu Watanabe 460d7ac3a2
Merge pull request #9550 from nosada/fix-9549
format-table: make all widths be set properly
2018-07-16 23:02:32 +09:00
Zbigniew Jędrzejewski-Szmek 3cb9b42af3 Move module-util.h to src/shared/ and load_module() to libshared
Unfortunately this needs libshared to link to libkmod. Before it was linked
into systemd-udevd, udevadm, and systemd each seperately. On most systems this
doesn't make much difference, because at least systemd would be installed, but
it might not be in small chroots. It is a small library, so I hope this is not
a big issue.
2018-07-16 13:08:40 +02:00
Filipe Brandenburger 75720bff62 build-sys: Detect whether struct statx is defined in sys/stat.h
Starting with glibc 2.27.9000-36.fc29, include file sys/stat.h will have a
definition for struct statx, in which case include file linux/stat.h should be
avoided, in order to prevent a duplicate definition.

    In file included from ../src/basic/missing.h:18,
		     from ../src/basic/util.h:28,
		     from ../src/basic/hashmap.h:10,
		     from ../src/shared/bus-util.h:12,
		     from ../src/libsystemd/sd-bus/bus-creds.c:11:
    /usr/include/linux/stat.h:99:8: error: redefinition of ‘struct statx’
     struct statx {
	    ^~~~~
    In file included from /usr/include/sys/stat.h:446,
		     from ../src/basic/util.h:19,
		     from ../src/basic/hashmap.h:10,
		     from ../src/shared/bus-util.h:12,
		     from ../src/libsystemd/sd-bus/bus-creds.c:11:
    /usr/include/bits/statx.h:36:8: note: originally defined here
     struct statx
	    ^~~~~

Extend our meson.build to look for struct statx when only sys/stat.h is
included and, in that case, do not include linux/stat.h anymore.

Tested that systemd builds correctly when using a glibc version that includes a
definition for struct statx.

glibc Fedora RPM update:
28cb5d31fc

glibc upstream commit:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fd70af45528d59a00eb3190ef6706cb299488fcd
2018-07-16 11:14:29 +02:00
Yu Watanabe 475d8599b0 format-table: fix typo in comment 2018-07-15 17:07:38 +09:00