Commit graph

20344 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 483ed8a6a0 fuzz-unit-file: adjust check for ListenNetlink yet again
The test for ListenNetlink would abort the loop if a line longer then LINE_MAX
was encountered (read_line() returns -ENOBUFS in that case). Let's use the
the line length limit that the unit file parses uses.

https://oss-fuzz.com/v2/issue/5546208027213824/7094.
2018-03-26 10:42:19 +02:00
Zbigniew Jędrzejewski-Szmek 1238250f1d
Merge pull request #8565 from poettering/cocci-again
run all coccinelle again
2018-03-23 19:22:24 +01:00
Zbigniew Jędrzejewski-Szmek 1b25e0351a
Merge pull request #8559 from poettering/integration-test-fixes
make integration tests pass again
2018-03-23 19:21:25 +01:00
Lennart Poettering be6bca47ec coccinelle: run no-if-assignments.cocci again 2018-03-23 16:33:38 +01:00
Lennart Poettering f5c4b520ba coccinelle: run safe_fclose.cocci again 2018-03-23 16:32:48 +01:00
Lennart Poettering d2f646828e coccinelle: run while-true.cocci again 2018-03-23 16:32:26 +01:00
James Cowgill 303d6b4ca6 Partially revert "seccomp: add mmap and address family restrictions for MIPS" (#8563)
This reverts the mmap parts of f5aeac1439,
but keeps the part which restricts address families which works
correctly.

Unfortunately the MIPS toolchains still do not implement PT_GNU_STACK.
This means that while the commit to restrict mmap on MIPS was "correct",
it had the side effect of causing pthread_create to fail because glibc tries
to allocate an executable stack for new threads in the absense of
PT_GNU_STACK. We should wait until PT_GNU_STACK is implemented in all
the relevant parts of the toolchain (at least gcc and glibc) before
enabling this again.
2018-03-23 16:04:16 +01:00
Lennart Poettering 34d267776a coccinelle: run const-strlen.cocci again 2018-03-23 15:46:12 +01:00
Lennart Poettering 29f74559d4 stat-util: fix fd_is_network_ns()
This was broken in 77f9fa3b8e. My fault.

Fixes: #8543
2018-03-23 15:29:35 +01:00
Michal Sekletar 19496554e2 core: delay adding target dependencies until all units are loaded and aliases resolved (#8381)
Currently we add target dependencies while we are loading units. This
can create ordering loops even if configuration doesn't contain any
loop. Take for example following configuration,

$ systemctl get-default
multi-user.target

$ cat /etc/systemd/system/test.service
[Unit]
After=default.target

[Service]
ExecStart=/bin/true

[Install]
WantedBy=multi-user.target

If we encounter such unit file early during manager start-up (e.g. load
queue is dispatched while enumerating devices due to SYSTEMD_WANTS in
udev rules) we would add stub unit default.target and we order it Before
test.service. At the same time we add implicit Before to
multi-user.target. Later we merge two units and we create ordering cycle
in the process.

To fix the issue we will now never add any target dependencies until we
loaded all the unit files and resolved all the aliases.
2018-03-23 15:28:06 +01:00
Lennart Poettering 959071cac2
Merge pull request #8552 from keszybz/test-improvements
Test and diagnostics improvements
2018-03-23 15:26:54 +01:00
Lennart Poettering 2f5fa62bf7 tree-wide: tabs suck (#8527) 2018-03-23 15:21:35 +01:00
Lennart Poettering 3e44d24d3b backlight: minor modernizations (#8528)
Use strjoina() and STR_IN_SET()
2018-03-23 15:20:34 +01:00
Zbigniew Jędrzejewski-Szmek 4ddc526ce8
Merge pull request #8529 from poettering/logind-fixlets
three trivial logind improvements
2018-03-23 15:19:32 +01:00
Peter Hutterer 0cd6767cf0 udev: don't label high-button mice as joysticks (#8493)
If a device exposes more than 16 mouse buttons, we run into the BTN_JOYSTICK
range, also labelling it as joystick. And since 774ff9b this results in only
ID_INPUT_JOYSTICK but no ID_INPUT_MOUSE.

Fixes #8460
2018-03-23 15:15:41 +01:00
Zbigniew Jędrzejewski-Szmek fbbffb8c09
Merge pull request #8530 from poettering/include-is-obsolete
actively say that .include is obsolete
2018-03-23 15:13:02 +01:00
Zbigniew Jędrzejewski-Szmek ee5a59d144
Merge pull request #8534 from poettering/safe-atoi-full
some improvements to safe_atou() to allow specification of arbitrary bases
2018-03-23 12:30:12 +01:00
Zbigniew Jędrzejewski-Szmek 37c1d5e97d tree-wide: warn when a directory path already exists but has bad mode/owner/type
When we are attempting to create directory somewhere in the bowels of /var/lib
and get an error that it already exists, it can be quite hard to diagnose what
is wrong (especially for a user who is not aware that the directory must have
the specified owner, and permissions not looser than what was requested). Let's
print a warning in most cases. A warning is appropriate, because such state is
usually a sign of borked installation and needs to be resolved by the adminstrator.

$ build/test-fs-util

Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing.
   (or)
Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing.
   (or)
Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing.

Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting.

No functional change except for the new log lines.
2018-03-23 10:26:38 +01:00
Lennart Poettering b53f3386e5 vconsole: minor modernizations 2018-03-22 20:30:40 +01:00
Lennart Poettering 16dbd110a7 vconsole-setup: don't concat strv if we don't need to (i.e. not in debug log mode) 2018-03-22 20:30:40 +01:00
Lennart Poettering c10d6bdb89 macro: introduce new TAKE_FD() macro
This is similar to TAKE_PTR() but operates on file descriptors, and thus
assigns -1 to the fd parameter after returning it.

Removes 60 lines from our codebase. Pretty good too I think.
2018-03-22 20:30:40 +01:00
Lennart Poettering 2f4cefe6ce sleep-config: replace USE() macro with TAKE_PTR() usage
let's use the new generic macor instead of the locally defined, specific
one.
2018-03-22 20:21:42 +01:00
Lennart Poettering ae2a15bc14 macro: introduce TAKE_PTR() macro
This macro will read a pointer of any type, return it, and set the
pointer to NULL. This is useful as an explicit concept of passing
ownership of a memory area between pointers.

This takes inspiration from Rust:

https://doc.rust-lang.org/std/option/enum.Option.html#method.take

and was suggested by Alan Jenkins (@sourcejedi).

It drops ~160 lines of code from our codebase, which makes me like it.
Also, I think it clarifies passing of ownership, and thus helps
readability a bit (at least for the initiated who know the new macro)
2018-03-22 20:21:42 +01:00
Zbigniew Jędrzejewski-Szmek d50b5839b0 basic/mkdir: convert bool flag to enum
In preparation for subsequent changes...
2018-03-22 15:57:56 +01:00
James Cowgill f5aeac1439 seccomp: add mmap and address family restrictions for MIPS (#8547) 2018-03-22 15:40:44 +01:00
Lennart Poettering 7f19eb3592
Merge pull request #8531 from poettering/dhcp-server-mini-fixes
some minor tweaks to sd-dhcp-server
2018-03-22 15:36:48 +01:00
juergbi 39362f6f7d main: add NoNewPrivileges config option (#8475)
This makes it possible to disable new privileges for the whole system.
2018-03-21 23:41:19 +01:00
Lennart Poettering 65baa289cf parse-util: similar to safe_atou16_full() add safe_atou_full()
What's good for uint16_t is also good for unsigned.

This is preparation for: #8140
2018-03-21 22:31:40 +01:00
Lennart Poettering 5ef56aa205 parse-util: introduce safe_atou16_full()
safe_atou16_full() is like safe_atou16() but also takes a base
parameter. safe_atou16() is then implemented as inline function on top
of it, passing 0 as base. Similar safe_atoux16() is reworked as inline
function too, with 16 as base.
2018-03-21 22:27:19 +01:00
Lennart Poettering 57027d0356 dhcp-server: don't propagate erros up the event loop
If we can't send a message this is no reason to completely abort the
event handler.

Issue identified by Nandor Han <nandor.han@ge.com>, Sebastian Reichel
<sebastian.reichel@collabora.co.uk>.

Replaces: #8525
2018-03-21 20:32:52 +01:00
Lennart Poettering cfcbb13583 dhcp-sever: check properly for invalid fds
We generally just compare for negativity, not for equlity to -1, let's
do so here too.
2018-03-21 20:30:29 +01:00
Lennart Poettering c3922c0c1c dhcp_server_handle_message: don't pretend there was a difference between return code 0 or 1
We ignore the difference anyway, hence let's systematically return 0.
2018-03-21 20:29:43 +01:00
Lennart Poettering 6408ba5fa9 dhcp-server: reduce level of indentation a bit
Less indentation is good, let's do that where it's easy.
2018-03-21 20:29:07 +01:00
Lennart Poettering 6e741541ed dhcp-server: introduce log_dhcp_server_errno()
Sometimes we want to print the error number, hence do so properly, and
avoid to use strerror() which is not reentrant.
2018-03-21 20:28:01 +01:00
Lennart Poettering 0f01c1f918 dhcp-server: don't assign sendmsg() return value to "int"
The type is "ssize_t", not "int", let's be accurate about that, as these
types are different on some archs.

Given that we don't actually care about the return value reall, drop
the whole assignment, just check if negative.
2018-03-21 20:27:16 +01:00
Lennart Poettering bdc8e623bb conf-parse: small prettification
Let's use first_word() instead of startswith(), it's more explanatory
and a bit more correct. Also, let's use the return value instead of
adding +9 when looking for the second part of the directive.
2018-03-21 20:04:16 +01:00
Lennart Poettering 41b283d0f1 conf-parser: let's explicitly deprecate .include in unit files
.include lines are already deprecated somewhat, and for example
explicitly not mentioned in the documentation for this reason. Let's get
one step further and generatea warning when we encounter them (but still
process them).

Why are they deprecated? Because they are semantically awful — they
complicate stat() based mtime checks for configuration files and they
allow arbitrary loops we currently have zero protection against and
really shouldn't have to have.
2018-03-21 20:04:16 +01:00
Lennart Poettering e743bca2a6 logind: drop obsolete comment
The code matching this comment was removed in
a50df72b37 in 2014, let's drop the comment
too.
2018-03-21 20:01:20 +01:00
Lennart Poettering bc2b6332a2 logind: use manager_get_user_by_pid() where appropriate
The current code reimplemented something like the
manager_get_user_by_pid() logic on its own, manually. Let's unify this.
2018-03-21 20:01:20 +01:00
Lennart Poettering 14ef4a6506 logind: rework manager_get_{user|session}_by_pid() a bit
Let's make sure we always initialize the return value if we return
non-negative.

Just a matter of coding style: we should always initialize our return
values when we return >= 0, and leave them unclobbered if we return < 0.
2018-03-21 20:01:20 +01:00
Zbigniew Jędrzejewski-Szmek 37cbc1d579 When mangling names, optionally emit a warning (#8400)
The warning is not emitted for absolute paths like /dev/sda or /home, which are
converted to .device and .mount unit names without any fuss.

Most of the time it's unlikely that users use invalid unit names on purpose,
so let's warn them. Warnings are silenced when --quiet is used.

$ build/systemctl show -p Id hello@foo-bar/baz
Invalid unit name "hello@foo-bar/baz" was escaped as "hello@foo-bar-baz" (maybe you should use systemd-escape?)
Id=hello@foo-bar-baz.service

$ build/systemd-run --user --slice foo-bar/baz --unit foo-bar/foo true
Invalid unit name "foo-bar/foo" was escaped as "foo-bar-foo" (maybe you should use systemd-escape?)
Invalid unit name "foo-bar/baz" was escaped as "foo-bar-baz" (maybe you should use systemd-escape?)
Running as unit: foo-bar-foo.service

Fixes #8302.
2018-03-21 15:26:47 +01:00
Lennart Poettering b85aca4f92
Merge pull request #8523 from keszybz/oss-fuzz-fixes
A fix for oss-fuzz msan ListenNetlink workaround
2018-03-21 15:26:25 +01:00
Franck Bui 100d5f6ee6 user-util: add new wrappers for reading/writing {passwd,shadow,gshadow} database files (#8521)
The API povided by the glibc is too error-prone as one has to deal directly
with errno in order to detect if errors occured.

Suggested by Zbigniew.
2018-03-21 15:26:02 +01:00
Zbigniew Jędrzejewski-Szmek af3865abf1 fuzz-unit-file: fix check if ListenNetlink is used
A line may contain leading spaces which we should skip.
Fixes https://oss-fuzz.com/v2/issue/5546208027213824/7049.
2018-03-21 13:16:52 +01:00
Zbigniew Jędrzejewski-Szmek 8a37ce6545 shared/conf-parser: fix outdated comment 2018-03-21 13:15:01 +01:00
Lennart Poettering ed47df8967 ac-power: add simple getopt() argument parsing to systemd-ac-power (#8516)
We should probably do that for all our tools, hence fill in this gap
here.
2018-03-21 12:52:18 +01:00
Zbigniew Jędrzejewski-Szmek 55c36ec0c1
Merge pull request #8508 from poettering/more-cocci
two new coccinelle rules files and their results
2018-03-21 12:50:49 +01:00
Peter A. Bigot 5c3376efcd time-sync-wait: add service (#8494)
This one-shot service waits until the kernel time has been set to
synchronized.
2018-03-21 12:42:04 +01:00
Lennart Poettering d9a43665eb
Merge pull request #8313 from alexgartrell/compression-threshold
Compression threshold
2018-03-21 12:37:54 +01:00
Lennart Poettering 0ba6791f46
Merge pull request #8368 from yuwata/nss-systemd-getpwent
nss-systemd: make dynamic users enumerable by `getent`
2018-03-21 12:36:47 +01:00