Commit graph

2825 commits

Author SHA1 Message Date
Dan Streetman 9841802955 src/basic/missing_syscall: add comment lines for PR 13319 changes
Add a comment line explaining that the syscall defines might be
defined to invalid negative numbers, as libseccomp redefines them
to negative numbers if not defined by the kernel headers, which is
not obvious just from reading the code checking for defined && > 0
2019-08-15 19:36:50 +02:00
Dan Streetman 59b657296a src/basic/missing_syscall: change #ifndef to #if ! (defined && > 0)
The #ifndef check used to work for missing __NR_* syscall defines, but
unfortunately libseccomp now redefines missing syscall number to negative
numbers, in their public header file, e.g.:
https://github.com/seccomp/libseccomp/blob/master/include/seccomp.h.in#L801

When systemd is built, since it includes <seccomp.h>, it pulls in the
incorrect negative value for any __NR_* syscall define that's included in
the seccomp.h header (for those syscalls that the kernel headers don't
yet define, e.g. when built with older/stable-distro kernels).  This leads
to bugs like:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1821625

This changes the check so that it can override the negative number that
libseccomp defines, instead of trying to use the negative syscall number.
To avoid gcc warnings (which are failures with meson --werror), this checks
without generating a redefinition gcc warning.

I have no idea why libseccomp decided to define missing syscalls
to negative numbers inside their *public* header file, causing
problems like this.
2019-08-14 18:09:47 +02:00
Dan Streetman 4f6d0cf807 src/basic/missing_syscall: add s390 syscall number for __NR_pkey_mprotect
The syscall number for s390 was added to the kernel at:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b41c51c8e194c0bdfb4b1778a137aea8246c86cd
2019-08-13 15:40:29 -04:00
Miroslav Lichvar bca5a0eacc time-util: improve detection of synchronized clock
Instead of checking for the STA_UNSYNC flag in the timex status, check
the maximum error. It is updated by the kernel, increasing at a rate of
500 ppm. The maximum value is 16 seconds, which triggers the STA_UNSYNC
flag.

This follows timedatex and allows timedated to correctly detect a clock
synchronized by chronyd when configured to not synchronize the RTC.
2019-08-01 17:32:36 +02:00
Yu Watanabe 77372afbe0 time-util: introduce jiffies_to_usec() 2019-07-29 23:52:37 +09:00
Thomas Haller 6fd79cca68 errno-util: return const string from strerror_safe()
C's strerror() function does not return a "const char *" pointer
for the string. That has historic reasons and C99 even comments
that "[t]he array pointed to shall not be modified by the program".

Make the strerror_safe() wrapper correct this and be more strict
in this regard.
2019-07-26 18:42:49 +02:00
Lennart Poettering 17f8fd9cf7
Merge pull request #13194 from keszybz/chase-symlinks-testing
Chase symlinks testing
2019-07-26 18:42:31 +02:00
Zbigniew Jędrzejewski-Szmek 22f62b1274 fs-util: CHASE_NOFOLLOW is not limited to CHASE_OPEN
$ build/test-chase-symlinks /etc/os-release
/etc/os-release → /usr/lib/os-release

$ build/test-chase-symlinks --nofollow /etc/os-release /etc/../etc/os-release /etc/../etc/./././os-release
/etc/os-release → /etc/os-release
/etc/../etc/os-release → /etc/os-release
/etc/../etc/./././os-release → /etc/os-release
2019-07-26 15:29:11 +02:00
Lennart Poettering 3e155eba43 random-seed: move pool size determination to random-util.[ch]
That way we can reuse it elsewhere.
2019-07-25 18:16:46 +02:00
Lennart Poettering 5373172e80 xattr-util: document that we NUL suffix 2019-07-25 17:10:51 +02:00
Lennart Poettering 63d59b8dcf fs-util: add fsync_full() helper
We usually combine an fsync() with fsync_directory_of_file() hence let's
add a helper that does both in one.
2019-07-25 17:10:51 +02:00
Yu Watanabe 8f815e8b03 tree-wide: drop netinet/ether.h from socket-util.h and sd-netlink.h 2019-07-24 18:23:08 +09:00
Lennart Poettering ad3f86e6a4
Merge pull request #13109 from poettering/revert-kbd-mode
Revert of #12378 ("VT kbd reset check")
2019-07-23 14:58:37 +02:00
Zbigniew Jędrzejewski-Szmek 5f4a882395 pid1: make sure we look at /proc/1/cmdline when parsing config
In recent systemd-nspawn we wouldn't parse init args like systemd.log-level=debug.
This is because we wouldn't even look at /proc/1/cmdline.

$ systemd-nspawn -n cat /proc/1/stat
1 (cat) R 0 1 1 34816 ....
                ^^^^^
34816 is 136:0 a.k.a. /dev/pts/0.
2019-07-22 09:06:22 +02:00
Zbigniew Jędrzejewski-Szmek a505166845
Merge pull request #13096 from keszybz/unit-loading
Preparatory work for the unit loading rework
2019-07-19 21:47:10 +02:00
Zbigniew Jędrzejewski-Szmek 4293c32b0e fs-util: adjust punctuation in comments 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek b47aa73a9a basic/path-util: move two path_simplify* functions to be adjacent
No functional change.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 3c4e303136 basic/set: constify operations which don't modify Set
No functional change, but it's nicer to the reader.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 87da87846d basic/hashmap: add hashops variant that does strdup/freeing on its own
So far, we'd use hashmap_free_free to free both keys and values along with
the hashmap. I think it's better to make this more encapsulated: in this variant
the way contents are freed can be decided when the hashmap is created, and
users of the hashmap can always use hashmap_free.
2019-07-19 16:50:36 +02:00
Zbigniew Jędrzejewski-Szmek cde7910993 sysusers,strv: export the hash ops to map char* → strv
Also make string_strv_hashmap_put return 0 only if the entry already existed.
2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek b124d3f2ce basic/unit-name: allow unit_name_to_instance() to be used to classify units
This could already be done by calling unit_name_is_*(), but if we don't know
if the argument is a valid unit name, it is more convenient to have a single
function which returns the type or possibly an error if the unit name is not
valid.

The values in the enum are sorted "by length". Not really important, but it
seems more natural to me.
2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek 69de5c16ff basic/unit-name: drop unused function 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek cc4d7d818d path-util: add path_startswith_strv() 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek f4c961169c
Merge pull request #13102 from mbiebl/nologin-path
meson: make nologin path build time configurable
2019-07-18 17:17:23 +02:00
Lennart Poettering 26382cab1b Revert "Move verify_vc_kbmode() to terminal-util.c as vt_verify_kbmode()"
This reverts commit bb5ac84d79.
2019-07-18 16:21:02 +02:00
Lennart Poettering 15bba61325 Revert "Add check to switch VTs only between K_XLATE or K_UNICODE"
This reverts commit 13a43c73d8.
2019-07-18 16:21:02 +02:00
Michael Biebl 6db904625d meson: make nologin path build time configurable
Some distros install nologin as /usr/sbin/nologin, others as
/sbin/nologin.
Since we can't really on merged-usr everywhere (where the path wouldn't
matter), make the path build time configurable via -Dnologin-path=.

Closes #13028
2019-07-18 12:46:35 +02:00
Michael Olbrich fcfc7e1137 basic: reorder UnitType enum
The enum order will be used to order jobs in the job queue.
Make sure that unit types that fork aditional processes come first to
maximize parallelism.
2019-07-18 09:54:03 +02:00
Frantisek Sumsal c087dc0c35
Merge pull request #13093 from keszybz/two-assert-cc-cleanups
Two assert_cc cleanups
2019-07-17 15:53:35 +00:00
Lennart Poettering 81c07a9555
Merge pull request #13080 from keszybz/firstboot-fixes
Firstboot fixes
2019-07-17 14:43:15 +02:00
Zbigniew Jędrzejewski-Szmek d268ab389c Rewrite IN_SET()
This restores proper speed with asan builds with gcc 9.1.1.
Fixes #12997.

$ rpm -q gcc
gcc-9.1.1-2.fc31.x86_64

$ time ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 build-rawhide-sanitize/test-conf-parser

(old) 86.99s user 20.22s system 361% cpu 29.635 total
(new)  3.05s user  0.29s system  99% cpu  3.377 total

Size is increased a bit:

$ size build/systemd
(old) 1683421	 246100	   1208	1930729	 1d75e9	build/systemd
(new) 1688237	 246100	   1208	1935545	 1d88b9	build/systemd

... but that's <0.1%, so we don't really care.
2019-07-17 14:22:53 +02:00
Lennart Poettering 76c887fdaa
Merge pull request #13092 from keszybz/coverity-fixes
Coverity fixes
2019-07-17 14:18:49 +02:00
Lennart Poettering 5f3626bb13
Merge pull request #13091 from poettering/nspawn-copy
nspawn: allow nspawn's copy operation to be abortable via C-c
2019-07-17 14:10:06 +02:00
Zbigniew Jędrzejewski-Szmek ab1a1ba5dc Drop trailing slash from assert_cc() definition
We use assert_cc(...); almost everywhere. Let's always require that.

https://github.com/systemd/systemd/issues/12997#issuecomment-510103988
2019-07-17 12:57:20 +02:00
Zbigniew Jędrzejewski-Szmek cfec3117d4 basic/macro: drop do {} while(0) from assert_not_reached
log_assert_failed_unreachable is just a normal function call, no need to wrap
it.

https://github.com/systemd/systemd/issues/12997#issuecomment-510103988
2019-07-17 12:27:33 +02:00
Zbigniew Jędrzejewski-Szmek 03d9429468 firstboot: actually accept empty input to mean skip
We'd loop if the input was empty. We need to return to the caller.
2019-07-17 12:07:19 +02:00
Zbigniew Jędrzejewski-Szmek ee41670ffb firstboot: fix hang waiting for second Enter on input
The comment explains the reason: we'd wait for the second \n
and then ungetc() it. Then the buffered \n would cause a problem
when the next prompt was issued, so in effect it wasn't possible
to answer the second question.
2019-07-17 12:07:19 +02:00
Zbigniew Jędrzejewski-Szmek 8a07b4033e shared/conf-parser,networkd: EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE → EXTRACT_UNQUOTE
It's hard to even say what exactly this combination means. Escaping is
necessary when quoting to have quotes within the string. So the escaping of
quote characters is inherently tied to quoting. When unquoting, it seems
natural to remove escaping which was done for the quoting purposes. But with
both flags we would be expected to re-add this escaping after unqouting? Or
maybe keep the escaping which is not necessary for quoting but otherwise
present? This all seems too complicated, let's just forbid such usage and
always fully unescape when unquoting.
2019-07-17 11:35:04 +02:00
Zbigniew Jędrzejewski-Szmek ba5d26ccb2 shared: voidify call to loop_write() and trim duplicate code
Coverity CID#1402375.
2019-07-17 11:35:04 +02:00
Anita Zhang 31cd5f63ce core: ExecCondition= for services
Closes #10596
2019-07-17 11:35:02 +02:00
Lennart Poettering 07a30bb18a btrfs-util: expose SIGINT behaviour in snapshot copy fallback, too 2019-07-17 11:14:11 +02:00
Lennart Poettering 85559592a6 copy: optionally check for SIGINT regularly, and abort operation safely 2019-07-17 11:14:11 +02:00
Lennart Poettering f200a3564c
Merge pull request #13063 from keszybz/cgroup-path-fixes
Cgroup path fixes
2019-07-16 11:53:31 +02:00
Yu Watanabe 8cec0a5c32 tree-wide: drop duplicated blank lines
```
$ for i in */*.[ch] */*/*.[ch]; do sed -e '/^$/ {N; s/\n$//g}' -i $i; done
$ git checkout HEAD -- basic/linux shared/linux
```
2019-07-15 18:41:27 +02:00
Zbigniew Jędrzejewski-Szmek 95b21cff0e Apply empty_to_root() in three more spots for safety 2019-07-15 18:39:26 +02:00
Lennart Poettering a7d9fccd0e locale-util: suppress non-UTF-8 locales when enumerating them
Let's hide non-UTF-8 locales by default. It's 2019 after all.

Let's add an undocumented env var to reenable listing them though.

This should substantially shorten the list of choices we offer users,
and only show realistic choices.

note that only firstboot and localectl make use of this information, and
both allow configuration of values outside of these lists, hence all
this change does is hide legacy options, but they are still available if
you know what you do, and that's how it should be.
2019-07-14 11:05:34 +02:00
Lennart Poettering 13f4580626 locale-util: normalize UTF-8 locale names
Let's generate out lists in the format people expect.
2019-07-14 11:05:34 +02:00
Yu Watanabe 94e016650d
Merge pull request #13043 from poettering/strip-tab-ansi-no-static-size
util-lib: [static] array argument sizes are apparently not OK for NUL…
2019-07-13 18:12:39 +09:00
Lennart Poettering b65011dad0 alloc-util: drop _alloc_ decorator from memdup_suffix0()
Fixes: https://github.com/systemd/systemd/pull/13034#issuecomment-510801671
2019-07-13 11:04:20 +02:00
Lennart Poettering 6fb0569065 util-lib: [static] array argument sizes are apparently not OK for NULL parameters
Let's drop the 'static' logic when a parameter can be NULL.

I think asan/ubsan are right here, judging by the C99 spec language:

"A declaration of a parameter as ‘‘array of type’’ shall be adjusted to
‘‘qualified pointer to type’’, where the type qualifiers (if any) are
those specified within the [ and ] of the array type derivation. If the
keyword static also appears within the [ and ] of the array type
derivation, then for each call to the function, the value of the
corresponding actual argument shall provide access to the first element
of an array with at least as many elements as specified by the size
expression."

If we specify NULL, then we certainly don't pvode access to any valid
array.

Fixes: #13039
2019-07-12 16:40:10 +02:00