Commit Graph

21825 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 9d0798a2ed
Merge pull request #9832 from yuwata/fix-9831
network: fixes related to setting MTU
2018-09-08 17:17:07 +02:00
Zbigniew Jędrzejewski-Szmek a5404992cc
Merge pull request #9942 from lucaswerkmeister/9939
seccomp: fix #9939 and allow specifying multiple errnos for syscall
2018-09-08 12:08:54 +02:00
Evgeny Vereshchagin 231dca5579 tests: put fuzz_journald_processing_function in a .c file 2018-09-08 12:05:14 +02:00
Lucas Werkmeister 9d7fe7c65a seccomp: permit specifying multiple errnos for a syscall
If more than one errno is specified for a syscall in SystemCallFilter=,
use the last one instead of reporting an error. This is especially
useful when used with system call sets:

    SystemCallFilter=@privileged:EPERM @reboot

This will block any system call requiring super-user capabilities with
EPERM, except for attempts to reboot the system, which will immediately
terminate the process. (@reboot is included in @privileged.)

This also effectively fixes #9939, since specifying different errnos for
“the same syscall” (same pseudo syscall number) is no longer an error.
2018-09-07 21:44:13 +02:00
Yu Watanabe e8596ca5c4 backlight: do not unref parent device
Fixes double-free introduced by 9aadd28149.
2018-09-07 20:00:01 +02:00
Yu Watanabe 3457a7a939
Merge pull request #10009 from evverx/rework-journald-fuzzers
Add a fuzzer for server_process_native_message
2018-09-05 11:46:17 +09:00
Yu Watanabe 53253d9c54 sd-dhcp6: set requested time for DUID-LLT
Follow-up for 7e90a499ab.
2018-09-04 13:07:37 -07:00
Yu Watanabe 339697f081 sd-dhcp: drop meaningless checking
mac_addr is not dynamically allocated.

Fixes CID 1395162 and 1395164.
2018-09-04 13:07:37 -07:00
Michal Sekletar 70f5f48eb8 cryptsetup-generator: introduce basic keydev support
Dracut has a support for unlocking encrypted drives with keyfile stored
on the external drive. This support is included in the generated initrd
only if systemd module is not included.

When systemd is used in initrd then attachment of encrypted drives is
handled by systemd-cryptsetup tools. Our generator has support for
keyfile, however, it didn't support keyfile on the external block
device (keydev).

This commit introduces basic keydev support. Keydev can be specified per
luks.uuid on the kernel command line. Keydev is automatically mounted
during boot and we look for keyfile in the keydev
mountpoint (i.e. keyfile path is prefixed with the keydev mount point
path). After crypt device is attached we automatically unmount
where keyfile resides.

Example:
        rd.luks.key=70bc876b-f627-4038-9049-3080d79d2165=/key:LABEL=KEYDEV
2018-09-04 16:54:53 +02:00
Zbigniew Jędrzejewski-Szmek 807690fb7f systemctl: fix compilation w/o logind
Fixes #10006.
2018-09-04 09:34:16 +02: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
Harald Hoyer 15720d0340 boot/efi/stub.c: fix Dell LoadOptions
On Dell machines LoadOptions is filled with:
01 00 00 00 <name of BIOS Boot Loader Entry> ... <unknown bytes>

So, in case of meaningfull LoadOptions, better check if the first char
is a printable character.
2018-09-03 14:10:38 +02:00
Alan Jenkins 81375d8026 user-runtime-dir: fix selinux regression
Fix #9993.  When this code was split out to user-runtime-dir, it forgot to
include the call to mac_selinux_init().  So mkdir_label() stopped working.

Fixes: a9f0f5e501 ("logind: split %t directory creation to a helper
unit")
2018-09-03 14:09:21 +02:00
Yu Watanabe 7dd05e9472 network: drop an unused variable
Follow-up for 53cb501a13.
2018-09-03 14:08:30 +02:00
Evgeny Vereshchagin 9cdea02db5 tests: add a fuzzer for server_process_native_message 2018-09-03 07:16:52 +00:00
Evgeny Vereshchagin 21acb27b71 journald: make server_process_native_message compatible with fuzz_journald_processing_function 2018-09-03 07:03:52 +00:00
Evgeny Vereshchagin b1bd453f36 tests: rework the code fuzzing journald
This should make it easier to add a new fuzzer without a lot of
duplication.
2018-09-03 06:46:24 +00:00
Yu Watanabe 0de4876496 core/socket: fix memleak in the error paths in usbffs_dispatch_eps() 2018-09-03 14:25:08 +09:00
Renaud Métrich fd790d6f09 journald: fixed assertion failure when system journal rotation fails (#9893) 2018-09-03 12:42:39 +09:00
Evgeny Vereshchagin a70f343cac tests: add a rudimentary fuzzer for server_process_syslog_message (#9979) 2018-09-03 12:18:26 +09:00
Yu Watanabe 645461f0cf
cryptsetup: do not define arg_sector_size if libgcrypt is v1.x (#9990)
Follow-up for #9936.
2018-09-01 23:47:46 +09:00
Yu Watanabe 0c09cb0e78
Merge pull request #9977 from sourcejedi/no-remount-superblock3
Namespace fixes
2018-09-01 23:18:01 +09:00
Alan Jenkins fcac12d150 namespace: remove redundant .has_prefix=false
The MountEntry's added for EMPTY_DIR work very similarly to the TMPFS ones.
In both cases, .has_prefix is false.  In fact, .has_prefix is false in
*all* the MountEntry's we add except for the access mounts (READONLY etc).

But EMPTY_DIR stuck out by explicitly setting .has_prefix = false.
Let's remove that.
2018-09-01 17:23:01 +09:00
Alan Jenkins 4a756839e6 namespace: we always use a root_directory now
We changed to always setup the new namespace in a separate directory
(commit 0722b35)
2018-09-01 17:23:01 +09:00
Alan Jenkins ad8e66dcc4 namespace: fix mode for TemporaryFileSystem=
... when no mount options are passed.

Change the code, to avoid the following failure in the newly added tests:

exec-temporaryfilesystem-rw.service: Executing: /usr/bin/sh -x -c
'[ "$(stat -c %a /var)" == 755 ]'
++ stat -c %a /var
+ '[' 1777 == 755 ']'
Received SIGCHLD from PID 30364 (sh).
Child 30364 (sh) died (code=exited, status=1/FAILURE)

(And I spotted an opportunity to use TAKE_PTR() at the end).
2018-09-01 17:22:14 +09:00
Alan Jenkins 69338c3dfb namespace: don't try to remount superblocks
We can't remount the underlying superblocks, if we are inside a user
namespace and running Linux <= 4.17.  We can only change the per-mount
flags (MS_REMOUNT | MS_BIND).

This type of mount() call can only change the per-mount flags, so we
don't have to worry about passing the right string options now.

Fixes #9914 ("Since 1beab8b was merged, systemd has been failing to start
systemd-resolved inside unprivileged containers" ... "Failed to re-mount
'/run/systemd/unit-root/dev' read-only: Operation not permitted").

> It's basically my fault :-). I pointed out we could remount read-only
> without MS_BIND when reviewing the PR that added TemporaryFilesystem=,
> and poettering suggested to change PrivateDevices= at the same time.
> I think it's safe to change back, and I don't expect anyone will notice
> a difference in behaviour.
>
> It just surprised me to realize that
> `TemporaryFilesystem=/tmp:size=10M,ro,nosuid` would not apply `ro` to the
> superblock (underlying filesystem), like mount -osize=10M,ro,nosuid does.
> Maybe a comment could note the kernel version (v4.18), that lets you
> remount without MS_BIND inside a user namespace.

This makes the code longer and I guess this function is still ugly, sorry.
One obstacle to cleaning it up is the interaction between
`PrivateDevices=yes` and `ReadOnlyPaths=/dev`.  I've added a test for the
existing behaviour, which I think is now the correct behaviour.
2018-08-30 11:17:16 +01: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
Lucas Werkmeister 851ee70a3d seccomp: improve error reporting
Only report OOM if that was actually the error of the operation,
explicitly report the possible error that a syscall was already blocked
with a different errno and translate that into a more sensible errno
(EEXIST only makes sense in connection to the hashmap), and pass through
all other potential errors unmodified. Part of #9939.
2018-08-29 21:42:03 +02:00
Alan Jenkins 8f8112f916 resolve: update comment, avoid alarming wrongness
`systemd-resolved.service` runs as `User=systemd-resolved`, and uses certain
Capabilit{y,ies} magic. By my understanding, this means it is started with a
number of "privileges".  Indeed, `capabilities(7)` explains

> Linux divides  the  privileges  traditionally
> associated  with  superuser into distinct units, known as capabilities,
> which can be independently enabled and disabled."

This situation appears to contradict our current code comment which said

> If we are not running as root we assume all privileges are already dropped.

This appears to be a confusion in the comment only.  The rest of the code
tells a much clearer story.  (Don't ask me if the story is correct.
`capabilities(7)` scares me).  Let's tweak the comment to make it consistent
and avoid worrying readers about this.
2018-08-29 18:07:06 +02: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
Samuel Morris c68867da32 systemctl: if no logind, don't try to schedule shutdown
If logind is not supported, don't try to schedule a shutdown,
immediately poweroff. This is the behavior indicated by the current
message given to the user, but the command is returning an error. I
believe this was broken on this commit:
7f96539d45
2018-08-29 17:51:53 +02:00
Zbigniew Jędrzejewski-Szmek 31e775ec38
Merge pull request #9959 from yuwata/small-fixes
tiny fixes and a cleanup
2018-08-29 17:47:00 +02:00
Yu Watanabe efa1463693 test: fix a memleak
Follow-up for #9901.

Fixes #9968.
2018-08-29 17:45:37 +02:00
Dimitri John Ledkov a9fc640671 cryptsetup: add support for sector-size= option (#9936)
Bug-Ubuntu: https://launchpad.net/bugs/1776626

Closes #8881.
2018-08-29 23:38:09 +09:00
Yu Watanabe a2b635eb39 sd-boot: fix header guard
Follow-up for a42d7cf165.
2018-08-29 23:05:15 +09:00
Yu Watanabe 3343021755 dynamic-user: drop unnecessary initialization 2018-08-29 23:04:26 +09:00
Zbigniew Jędrzejewski-Szmek 030836923d
Merge pull request #9901 from peterbaouoft/pr/preset_enable_multiple_instances
install: allow instantiated units to be enabled via presets
2018-08-29 14:22:27 +02:00
Yu Watanabe 22ac37aa00 string-table: do not ignore 'scope' argument 2018-08-28 12:40:25 +09:00
Yu Watanabe e094eb1188
Merge pull request #9950 from yuwata/macro-ref-unref
tree-wide: introduce macros to define *_ref() and *_unref() functions
2018-08-28 10:43:25 +09:00
Ruixin Bao 1e475a0ab4 install: small refactor to combine two function calls into one function
Combine consecutive function calls of install_info_discover and
install_info_may_process into one short helper function.
2018-08-27 23:56:31 +00:00
Ruixin Bao 4c9565eea5 install: allow instantiated units to be enabled via presets
This patch implements https://github.com/systemd/systemd/issues/9421.

The .preset file now is able to take a rule in the format of:(e.g)
enable foo@.service bar0 bar1 bar2

In the above example, when preset-all is called, all three instances of
foo@bar0.service, foo@bar1.service and foo@bar2.service will be enabled.

When preset is called on a single service(e.g: foo@bar1.service), only
the mentioned one(foo@bar1.service) will be enabled.

Tests are added for future regression.
2018-08-27 23:56:24 +00:00
Yu Watanabe 4005d3215e sd-device: sd_device_enumerator_get_subsystem_next() requests the device list is uptodate 2018-08-28 05:09:40 +09:00
Yu Watanabe 6116d2b275 sd-device: use structured initializers 2018-08-28 05:09:40 +09:00
Yu Watanabe 1c71f7f329 libsystemd: use DEFINE_ATOMIC_REF_UNREF_FUNC or frineds where applicable 2018-08-28 05:09:40 +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 6b6e07415c sd-netlink: fix indentation 2018-08-28 05:09:40 +09:00
Yu Watanabe 61e21d4ca1 sd-hwdb: drop unused variable 2018-08-28 05:09:40 +09:00
Yu Watanabe 288ca7af8c dynamic-user: fix potential segfault 2018-08-28 05:09:00 +09:00
Zbigniew Jędrzejewski-Szmek 649010a53d
Merge pull request #9935 from pfl/dhcp6_pd_assignment_fix
Dhcp6 pd assignment fix
2018-08-27 14:49:11 +02:00
Thomas Haller 3301f9eb97 link: allocate correct number of bytes in ethtool_set_features()
sfeatures is a "struct ethtool_sfeatures". Use sizeof() on the correct
data type.

Since "struct ethtool_gstrings" is larger than "struct ethtool_sfeatures",
this had no serious consequences.

Fixes: 50725d10e3
2018-08-27 14:14:30 +02:00