platform/upstream/systemd.git
6 years agodoc: update TODO
Yu Watanabe [Thu, 8 Mar 2018 03:53:43 +0000 (12:53 +0900)]
doc: update TODO

6 years agonss-systemd: make dynamic users enumerable by `getent`
Yu Watanabe [Wed, 21 Mar 2018 04:39:03 +0000 (13:39 +0900)]
nss-systemd: make dynamic users enumerable by `getent`

This adds `setpwent()`, `getpwent_r()`, `endpwent()`, `setgrent()`,
`getgrent_r()`, and `endgrent()` interfaces to nss-systemd library.
Thus, dynamic users can be enumerated by e.g. `getent passwd` command.

6 years agonss-systemd: define dynamic user properties
Yu Watanabe [Tue, 6 Mar 2018 06:39:26 +0000 (15:39 +0900)]
nss-systemd: define dynamic user properties

6 years agonss-systemd: cleanup bypassing dbus logic
Yu Watanabe [Tue, 6 Mar 2018 12:31:16 +0000 (21:31 +0900)]
nss-systemd: cleanup bypassing dbus logic

6 years agocore: add new dbus method GetDynamicUsers
Yu Watanabe [Wed, 21 Mar 2018 04:11:01 +0000 (13:11 +0900)]
core: add new dbus method GetDynamicUsers

This intruduces a new dbus method GetDynamicUsers for systemd1.Manager,
which enumerates all dynamic users realized in the system.

6 years agobasic/fs-util: skip fsync_directory_of_file() if /proc/self/fd/ is not available...
Zbigniew Jędrzejewski-Szmek [Tue, 20 Mar 2018 17:20:01 +0000 (18:20 +0100)]
basic/fs-util: skip fsync_directory_of_file() if /proc/self/fd/ is not available (#8386)

When systemd is running under lorax (in Fedora compose process), it'd think that
it failed to write /etc/machine-id, even though the write succeeded, because
fsync_directory_of_file() would fail, because /proc/self/fd/ is not available.
fsync_directory_of_file() is mostly an additional safety net, so I think it's best
to just silently ignore the error.

Strace of pid1:
35791 stat("/etc", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
35791 openat(AT_FDCWD, "/etc/machine-id", O_RDWR|O_CREAT|O_NOCTTY|O_CLOEXEC, 0444) = 3
35791 umask(022)                        = 000
35791 read(3, "", 38)                   = 0
35791 openat(AT_FDCWD, "/var/lib/dbus/machine-id", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = -1 ENOENT (No such file o
r directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/product_name", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/sys_vendor", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/board_vendor", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/bios_vendor", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 access("/proc/xen", F_OK)         = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/hypervisor/type", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 getrandom("\xb8\x82\xed\xd4\x35\x11\xd0\xeb\xa6\x79\xd7\x31\x6e\x7b\x99\xce", 16, GRND_NONBLOCK) = 16
35791 writev(2, [{iov_base="Initializing machine ID from random generator.", iov_len=46}, {iov_base="\n", iov_len=1}],
 2) = 47
35791 lseek(3, 0, SEEK_SET)             = 0
35791 ftruncate(3, 0)                   = 0
35791 write(3, "b882edd4351140eba679d7316e7b99ce\n", 33) = 33
35791 fsync(3)                          = 0
35791 fstat(3, {st_mode=S_IFREG|0444, st_size=33, ...}) = 0
35791 readlinkat(AT_FDCWD, "/proc/self/fd/3", 0x564df8c694c0, 99) = -1 ENOENT (No such file or directory)
35791 close(3)                          = 0
35791 umask(022)                        = 022
35791 openat(AT_FDCWD, "/run/machine-id", O_WRONLY|O_CREAT|O_NOCTTY|O_TRUNC|O_CLOEXEC, 0444) = 3
35791 write(3, "b882edd4351140eba679d7316e7b99ce\n", 33) = 33
35791 close(3)                          = 0
35791 umask(022)                        = 022
35791 mount("/run/machine-id", "/etc/machine-id", NULL, MS_BIND, NULL) = 0
35791 writev(2, [{iov_base="Installed transient /etc/machine-id file.", iov_len=41}, {iov_base="\n", iov_len=1}], 2) = 42
35791 mount(NULL, "/etc/machine-id", NULL, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = 0

https://bugzilla.redhat.com/show_bug.cgi?id=1552843

6 years agoMerge pull request #8440 from keszybz/use-cleanup-in-efi
Lennart Poettering [Tue, 20 Mar 2018 17:17:57 +0000 (18:17 +0100)]
Merge pull request #8440 from keszybz/use-cleanup-in-efi

Use cleanup in sd-boot

6 years agonspawn: move network namespace creation to a separate step (#8430)
Zbigniew Jędrzejewski-Szmek [Tue, 20 Mar 2018 17:07:17 +0000 (18:07 +0100)]
nspawn: move network namespace creation to a separate step (#8430)

Fixes #8427.

Unsharing the namespace in a separate step changes the ownership of
/proc/net/ip_tables_names (and related files) from nobody:nobody to
root:root. See [1] and [2] for all the details.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f13f2aeed154da8e48f90b85e720f8ba39b1e881
[2] https://bugzilla.netfilter.org/show_bug.cgi?id=1064#c9

6 years agoMerge pull request #8106 from dqminh/route-expires-kernel
Lennart Poettering [Tue, 20 Mar 2018 16:38:30 +0000 (17:38 +0100)]
Merge pull request #8106 from dqminh/route-expires-kernel

move route expiration to kernel

6 years agomkosi: set file permissions in copy of source tree (#8370)
Filipe Brandenburger [Tue, 20 Mar 2018 16:21:36 +0000 (09:21 -0700)]
mkosi: set file permissions in copy of source tree (#8370)

Meson keeps permissions around during the build, so details of how umask
was set when cloning the original git tree will leak all the way to the
installed files in the mkosi image.

So reset the permissions of the files in the copy of the tree before
starting the build.

Also set the umask explicitly.

Tested by creating a mkosi image and booting it on a tree that was
cloned with a umask of 027, confirmed that the *.target files were not
created as world-unreadable anymore.

6 years agoseccomp: enable RestrictAddressFamilies on ppc (#8505)
Mathieu Malaterre [Tue, 20 Mar 2018 15:08:20 +0000 (16:08 +0100)]
seccomp: enable RestrictAddressFamilies on ppc (#8505)

In commit da1921a5c3 ppc64/ppc64el were added as supported architectures for
socketcall() for the POWER family. Extend the support for the 32bits
architectures.

6 years agoMerge pull request #8499 from fbuihuu/shadow-support-nis
Lennart Poettering [Tue, 20 Mar 2018 11:16:43 +0000 (12:16 +0100)]
Merge pull request #8499 from fbuihuu/shadow-support-nis

sysusers: also add support for NIS entries in /etc/shadow

6 years agosysusers: make sure to reset errno before calling fget*ent()
Franck Bui [Tue, 20 Mar 2018 10:38:00 +0000 (11:38 +0100)]
sysusers: make sure to reset errno before calling fget*ent()

Due to the glibc interface we have to test errno in various places to detect if
an error occured after calling fget*ent() helpers.

6 years agosysusers: also add support for NIS entries in /etc/shadow
Franck Bui [Tue, 20 Mar 2018 08:32:05 +0000 (09:32 +0100)]
sysusers: also add support for NIS entries in /etc/shadow

Commit 563dc6f8e2cda4114dd20f32655890ed378c3740 added support for
/etc/{passwd,group} only but since nsswitch.conf(5) appears to document the NIS
entries also for shadow, let's support this case too.

6 years agov4l_id: check mplane video capture and output capailities (#8464)
Jui-Chi Ricky Liang [Tue, 20 Mar 2018 08:54:18 +0000 (16:54 +0800)]
v4l_id: check mplane video capture and output capailities (#8464)

Video devices using mplane buffer API declare capture and output
capabilities with V4L2_CAP_VIDEO_CAPTURE_MPLANE and
V4L2_CAP_VIDEO_OUTPUT_MPLANE.

6 years agoman: use unicode ellipsis in one more place (#8496)
Zbigniew Jędrzejewski-Szmek [Tue, 20 Mar 2018 08:54:01 +0000 (09:54 +0100)]
man: use unicode ellipsis in one more place (#8496)

Also add note where it should *not* be used.

https://github.com/systemd/systemd/pull/8408#discussion_r175606771

6 years agoMerge pull request #8452 from keszybz/use-libmount-more
Lennart Poettering [Tue, 20 Mar 2018 08:53:34 +0000 (09:53 +0100)]
Merge pull request #8452 from keszybz/use-libmount-more

Use libmount in systemd-shutdown, add tests

6 years agohwdb: ThinkPad 4x0s and X1 Carbon 3rd gen LEDs (#8492)
Matteo F. Vescovi [Tue, 20 Mar 2018 06:41:19 +0000 (07:41 +0100)]
hwdb: ThinkPad 4x0s and X1 Carbon 3rd gen LEDs (#8492)

6 years agohwdb: ThinkPad T560 doesn't have a caps lock led (#8490)
Salvo 'LtWorf' Tomaselli [Mon, 19 Mar 2018 18:19:53 +0000 (19:19 +0100)]
hwdb: ThinkPad T560  doesn't have a caps lock led (#8490)

Similar to 16bed3afa1b916ace5e927392a1baab9dd9ff963, this model also doesn't have the
LED.
```
cat /sys/class/dmi/id/modalias
dmi:bvnLENOVO:bvrN1KET16W(1.03):bd01/20/2016:svnLENOVO:pn20FH001AMX:pvrThinkPadT560:rvnLENOVO:rn20FH001AMX:rvrSDK0J40705WIN:cvnLENOVO:ct10:cvrNone:
```

6 years agomacros: fix sysusers_create_inline (#8489)
Filipe Brandenburger [Mon, 19 Mar 2018 17:05:49 +0000 (10:05 -0700)]
macros: fix sysusers_create_inline (#8489)

This typo was introduced in commit dd2490ae12ad1e when using
here-documents for the macro values.

6 years agoMerge pull request #8488 from yuwata/client-update
Zbigniew Jędrzejewski-Szmek [Mon, 19 Mar 2018 16:58:14 +0000 (17:58 +0100)]
Merge pull request #8488 from yuwata/client-update

Many client updates

6 years agoresolve: show more global settings in `systemd-resolve --status`
Yu Watanabe [Mon, 19 Mar 2018 15:40:05 +0000 (00:40 +0900)]
resolve: show more global settings in `systemd-resolve --status`

Closes #8455.

6 years agoresolve: expose global LLMNR, MulticastDNS, and DNSSEC settings as bus property
Yu Watanabe [Mon, 19 Mar 2018 05:29:22 +0000 (14:29 +0900)]
resolve: expose global LLMNR, MulticastDNS, and DNSSEC settings as bus property

6 years agodoc: update TODO
Yu Watanabe [Mon, 19 Mar 2018 15:38:36 +0000 (00:38 +0900)]
doc: update TODO

6 years agobus-util: introduce bus_message_print_all_properties()
Yu Watanabe [Mon, 19 Mar 2018 15:37:00 +0000 (00:37 +0900)]
bus-util: introduce bus_message_print_all_properties()

Then, use it where applicable.

6 years agosystemctl: use bus_map_all_properties() in status command
Yu Watanabe [Mon, 19 Mar 2018 15:20:39 +0000 (00:20 +0900)]
systemctl: use bus_map_all_properties() in status command

6 years agosystemctl: use string table for show()
Yu Watanabe [Mon, 19 Mar 2018 15:09:04 +0000 (00:09 +0900)]
systemctl: use string table for show()

6 years agobus-util: make bus_map_all_properties() not copy string
Yu Watanabe [Mon, 19 Mar 2018 14:46:29 +0000 (23:46 +0900)]
bus-util: make bus_map_all_properties() not copy string

6 years agohwdb: ThinkPad T450s doesn't have a caps lock led (#8433)
Paride Legovini [Mon, 19 Mar 2018 14:56:11 +0000 (15:56 +0100)]
hwdb: ThinkPad T450s doesn't have a caps lock led (#8433)

6 years agobus-util: store boolean message to bool
Yu Watanabe [Thu, 15 Mar 2018 17:35:29 +0000 (02:35 +0900)]
bus-util: store boolean message to bool

6 years agosystemctl: use bus_map_all_properties() in list-dependencies command
Yu Watanabe [Thu, 15 Mar 2018 09:44:34 +0000 (18:44 +0900)]
systemctl: use bus_map_all_properties() in list-dependencies command

6 years agotree-wide: voidify pager_open()
Yu Watanabe [Wed, 14 Mar 2018 08:48:29 +0000 (17:48 +0900)]
tree-wide: voidify pager_open()

Even if pager_open() fails, in general, we should continue the operations.
All erroneous cases in pager_open() show log message in the function.
So, it is not necessary to check the returned value.

6 years agoman: mention 'status' is the default command for timedatectl
Yu Watanabe [Wed, 14 Mar 2018 06:10:46 +0000 (15:10 +0900)]
man: mention 'status' is the default command for timedatectl

6 years agotimedatectl: use dispatch_verb()
Yu Watanabe [Wed, 14 Mar 2018 06:09:28 +0000 (15:09 +0900)]
timedatectl: use dispatch_verb()

6 years agoman: mention 'status' is the default command for localectl
Yu Watanabe [Wed, 14 Mar 2018 05:52:45 +0000 (14:52 +0900)]
man: mention 'status' is the default command for localectl

6 years agolocalectl: use dispatch_verb()
Yu Watanabe [Wed, 14 Mar 2018 05:50:40 +0000 (14:50 +0900)]
localectl: use dispatch_verb()

6 years agohostnamectl: use dispatch_verb()
Yu Watanabe [Wed, 14 Mar 2018 05:29:55 +0000 (14:29 +0900)]
hostnamectl: use dispatch_verb()

6 years agoman: mention that 'status' is the default command for `hostnamectl`
Yu Watanabe [Wed, 14 Mar 2018 05:06:50 +0000 (14:06 +0900)]
man: mention that 'status' is the default command for `hostnamectl`

6 years agocoredumpctl: use dispatch_verb()
Yu Watanabe [Wed, 14 Mar 2018 08:46:34 +0000 (17:46 +0900)]
coredumpctl: use dispatch_verb()

6 years agobusctl: drop redundant pager_open()
Yu Watanabe [Mon, 12 Mar 2018 08:47:16 +0000 (17:47 +0900)]
busctl: drop redundant pager_open()

6 years agobusctl: add missing oom check
Yu Watanabe [Mon, 12 Mar 2018 08:45:42 +0000 (17:45 +0900)]
busctl: add missing oom check

6 years agobusctl: use dispatch_verb()
Yu Watanabe [Tue, 13 Mar 2018 20:09:16 +0000 (05:09 +0900)]
busctl: use dispatch_verb()

6 years agonetworkctl,hwdb: make verbs static
Yu Watanabe [Mon, 12 Mar 2018 05:05:08 +0000 (14:05 +0900)]
networkctl,hwdb: make verbs static

6 years agoMerge pull request #8399 from keszybz/systemctl-kexec
Yu Watanabe [Mon, 19 Mar 2018 09:35:41 +0000 (18:35 +0900)]
Merge pull request #8399 from keszybz/systemctl-kexec

Systemctl kexec buglet fixes

6 years agoMerge pull request #8408 from keszybz/ln-relative
Yu Watanabe [Mon, 19 Mar 2018 09:32:30 +0000 (18:32 +0900)]
Merge pull request #8408 from keszybz/ln-relative

bugs.fd.o bug archelogy

6 years agoshutdown: Don't limit unmount attempts prematurely (#8469)
Jan Janssen [Mon, 19 Mar 2018 09:27:49 +0000 (10:27 +0100)]
shutdown: Don't limit unmount attempts prematurely (#8469)

Once upon a time shutdown.c didn't have the logic to check whether any
unmount attempts succeeded or not. So instead it kept looping for
a fixed amount and hoped all was right. Nowadays, we do know if we
changed anything during a iteration and also stop looping then, but
we still limit ourselves to FINALIZE_ATTEMPTS.

But, theoretically, we could have such a complicated and nested
setup that would survive that limit, leaving stuff around we
might actually be able to unmount. And we could also end up in a
situation where the extra loop with raised unmount error level could
be skipped too.

So let's just drop the retries logic and rely fully on the changed
flag.

6 years agohwdb: fix accelerometer mount matrix for Asus TP300LD (#8327) (#8463)
futpib [Mon, 19 Mar 2018 09:25:07 +0000 (12:25 +0300)]
hwdb: fix accelerometer mount matrix for Asus TP300LD (#8327) (#8463)

6 years agomacros: use here-docs instead of echo (#8480)
Zbigniew Jędrzejewski-Szmek [Mon, 19 Mar 2018 08:07:44 +0000 (09:07 +0100)]
macros: use here-docs instead of echo (#8480)

It's common for sysusers files to contain quotes (in particular around the
comment/GECOS field), and using echo "..." is very likely to not work properly
in that case. Let's use <<EOF redirection. It's not bulletproof, but should
work in general.

6 years agoMerge pull request #8476 from EliaGeretto/n550jv-touchpad-fix
Yu Watanabe [Mon, 19 Mar 2018 08:06:42 +0000 (17:06 +0900)]
Merge pull request #8476 from EliaGeretto/n550jv-touchpad-fix

hwdb: correct touchpad resolution for Asus N550JV

6 years agohwdb: Correct touchpad resolution for Asus N550JV
Elia Geretto [Mon, 19 Mar 2018 07:02:40 +0000 (08:02 +0100)]
hwdb: Correct touchpad resolution for Asus N550JV

6 years agohwdb: Split touchpad rules for X550CC and S550C
Elia Geretto [Mon, 19 Mar 2018 07:00:28 +0000 (08:00 +0100)]
hwdb: Split touchpad rules for X550CC and S550C

6 years agoMerge pull request #8461 from keszybz/oss-fuzz-fixes
Evgeny Vereshchagin [Sun, 18 Mar 2018 21:06:44 +0000 (00:06 +0300)]
Merge pull request #8461 from keszybz/oss-fuzz-fixes

Oss fuzz fixes

6 years agocore/unit: delay creating a stack variable until after length has been checked
Zbigniew Jędrzejewski-Szmek [Sun, 18 Mar 2018 11:51:31 +0000 (12:51 +0100)]
core/unit: delay creating a stack variable until after length has been checked

path_is_normalized() will reject paths longer than 4095 bytes, so it's better
to not create a stack variable of unbounded size, but instead do the check first
and only then do that allocation.

Also use _cleanup_ to make things a bit shorter.

https://oss-fuzz.com/v2/issue/5424177403133952/7000

6 years agofuzz-unit-file: simply do not test ListenNetlink= at all
Zbigniew Jędrzejewski-Szmek [Sun, 18 Mar 2018 12:39:38 +0000 (13:39 +0100)]
fuzz-unit-file: simply do not test ListenNetlink= at all

msan doesn't understand sscanf with %ms, so it falsely reports unitialized
memory. Using sscanf with %ms is quite convenient in
socket_address_parse_netlink(), so let's just not run the fuzzer for
ListenNetlink= at all for now. If msan is fixed, we can remove this.

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6884

6 years agotest-socket-util: add test for ListenNetlink with spaces
Zbigniew Jędrzejewski-Szmek [Sun, 18 Mar 2018 12:01:13 +0000 (13:01 +0100)]
test-socket-util: add test for ListenNetlink with spaces

6 years agobasic/cgroup-util: fix typo in debug message
Zbigniew Jędrzejewski-Szmek [Sat, 17 Mar 2018 13:32:40 +0000 (14:32 +0100)]
basic/cgroup-util: fix typo in debug message

6 years agosystemd-link: Remove UDP Fragmentation Offload support. (#8183)
Rosen Penev [Sun, 18 Mar 2018 13:28:14 +0000 (06:28 -0700)]
systemd-link: Remove UDP Fragmentation Offload support. (#8183)

Support was killed in kernel 4.15 as well as ethtool 4.13.

Justification was lack of use by drivers and too much of a maintenance burden.
https://www.spinics.net/lists/netdev/msg443815.html

Also moved config_parse_warn_compat to conf-parser.[ch] to fix compile errors.

6 years agoMerge pull request #8471 from filbranden/envnewline1
Yu Watanabe [Sun, 18 Mar 2018 11:29:55 +0000 (20:29 +0900)]
Merge pull request #8471 from filbranden/envnewline1

basic/env-util: Allow newlines in values of environment variables

6 years agoMerge pull request #8468 from fbuihuu/sysusers-support-nis
Yu Watanabe [Sun, 18 Mar 2018 10:57:18 +0000 (19:57 +0900)]
Merge pull request #8468 from fbuihuu/sysusers-support-nis

Sysusers support nis

Fixes #8467.

6 years agounits: Fix SuccessAction that belongs to [Unit] section not [Service] section (#8478)
Karol Augustin [Sun, 18 Mar 2018 10:40:07 +0000 (10:40 +0000)]
units: Fix SuccessAction that belongs to [Unit] section not [Service] section (#8478)

6 years agotest: add a sysusers test with NIS entries
Franck Bui [Thu, 15 Mar 2018 12:39:38 +0000 (13:39 +0100)]
test: add a sysusers test with NIS entries

6 years agoMerge pull request #8473 from keszybz/fix-dbus-reload
Yu Watanabe [Sat, 17 Mar 2018 10:45:38 +0000 (19:45 +0900)]
Merge pull request #8473 from keszybz/fix-dbus-reload

Fix dbus reload. Fixes #8414.

6 years agofuzz: add test case for oss-fuzz #6897 and a work-around
Zbigniew Jędrzejewski-Szmek [Fri, 16 Mar 2018 11:02:54 +0000 (12:02 +0100)]
fuzz: add test case for oss-fuzz #6897 and a work-around

The orignal reproducer from oss-fuzz depends on the hostname (via %H and %c).
The hostname needs a dash for msan to report this, so a simpler case from
@evverx with the dash hardcoded is also added.

The issue is a false positive from msan, which does not instruct stpncpy
(https://github.com/google/sanitizers/issues/926). Let's add a work-around
until this is fixed.

6 years agounit-file: do not allow bogus IOSchedulingClass values
Zbigniew Jędrzejewski-Szmek [Fri, 16 Mar 2018 10:15:58 +0000 (11:15 +0100)]
unit-file: do not allow bogus IOSchedulingClass values

We have only three bits of space, i.e. 8 possible classes. Immediately reject
anything outside of that range. Add the fuzzer test case and an additional
unit test.

oss-fuzz #6908.

6 years agocore/service: fix memleak of USBFunctionStrings and USBFunctionDescriptors
Zbigniew Jędrzejewski-Szmek [Thu, 15 Mar 2018 10:42:00 +0000 (11:42 +0100)]
core/service: fix memleak of USBFunctionStrings and USBFunctionDescriptors

oss-fuzz #6892.

6 years agoAdd .gitattributes for test/fuzz-regressions
Zbigniew Jędrzejewski-Szmek [Thu, 15 Mar 2018 10:21:00 +0000 (11:21 +0100)]
Add .gitattributes for test/fuzz-regressions

Those reproducers are essentially binary, hence let's ignore whitespace
in them.

6 years agobasic/calendarspec: set a limit on length of calendarspec component chains
Zbigniew Jędrzejewski-Szmek [Thu, 15 Mar 2018 09:12:48 +0000 (10:12 +0100)]
basic/calendarspec: set a limit on length of calendarspec component chains

We probably should allow very deep calls of our recursive functions. Let's add
a limit to avoid resource exhaustion. 240 is 10 per hour (if somebody is using
this for time based triggers...), so it should be more than enough for most use
cases, and is conveniently below the 250 stack limit in msan.

oss-fuzz #6917.

6 years agotest-execute: Introduce tests for environment values containing newlines
Filipe Brandenburger [Fri, 16 Mar 2018 23:30:42 +0000 (16:30 -0700)]
test-execute: Introduce tests for environment values containing newlines

Also fix one case where the presence of a newline was used to generate
an invalid environment assignment.

Tested: with mkosi, which builds the local tree and run ninja tests.

6 years agocore/manager: move some comments to a better place
Zbigniew Jędrzejewski-Szmek [Fri, 16 Mar 2018 19:46:39 +0000 (20:46 +0100)]
core/manager: move some comments to a better place

6 years agocore: when reloading, delay any actions on journal and dbus connections
Zbigniew Jędrzejewski-Szmek [Fri, 16 Mar 2018 22:01:05 +0000 (23:01 +0100)]
core: when reloading, delay any actions on journal and dbus connections

manager_recheck_journal() and manager_recheck_dbus() would be called to early
while we were deserialiazing units, before the systemd-journald.service and
dbus.service have been deserialized. In effect we'd disable logging to the
journald and close the bus connection. The first is not very noticable, it
mostly means that logs emitted during deserialization are lost. The second is
more noticeable, because manager_recheck_dbus() would call bus_done_api() and
bus_done_system() and close dbus connections. Logging and bus connection would
then be restored later after the respective units have been deserialized.

This is easily reproduced by calling:
  $ sudo gdbus call --system --dest org.freedesktop.systemd1 --object-path /org/freedesktop/systemd1 --method "org.freedesktop.systemd1.Manager.Reload"
which works fine before 8559b3b75cb, and then starts failing with:
  Error: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Remote peer disconnected

None of this should happen, and we should delay changing state until after
deserialization is complete when reloading. manager_reload() already included
the calls to manager_recheck_journal() and manager_recheck_dbus(), so the
connection state will be updated after deserialization during reloading is done.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1554578.

6 years agobasic/env-util: Allow newlines in values of environment variables
Filipe Brandenburger [Fri, 16 Mar 2018 20:41:54 +0000 (13:41 -0700)]
basic/env-util: Allow newlines in values of environment variables

They are allowed by the shell and the EnvironmentFile parsing passes
them through, so we should just accept them, same as we accept tabs.

6 years agohwdb: fix comment suggested `udevadm trigger` command (#8465)
futpib [Fri, 16 Mar 2018 14:25:14 +0000 (17:25 +0300)]
hwdb: fix comment suggested `udevadm trigger` command (#8465)

6 years agoudev: use startswith() instead of the combination of strneq() and strlen() (#8459)
Yu Watanabe [Fri, 16 Mar 2018 09:29:57 +0000 (18:29 +0900)]
udev: use startswith() instead of the combination of strneq() and strlen() (#8459)

6 years agocore/umount: use libmount to enumerate /proc/swaps
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 11:22:27 +0000 (12:22 +0100)]
core/umount: use libmount to enumerate /proc/swaps

example.swaps with "(deleted)" does not cause bogus entries in the list now,
but a memleak in libmount instead. The memleaks is not very important since
this code is run just once.
Reported as https://github.com/karelzak/util-linux/issues/596.

$ build/test-umount
...
/* test_swap_list("/proc/swaps") */
path=/var/tmp/swap o= f=0x0 try-ro=no dev=0:0
path=/dev/dm-2 o= f=0x0 try-ro=no dev=0:0
/* test_swap_list("/home/zbyszek/src/systemd/test/test-umount/example.swaps") */
path=/some/swapfile o= f=0x0 try-ro=no dev=0:0
path=/dev/dm-2 o= f=0x0 try-ro=no dev=0:0
==26912==
==26912== HEAP SUMMARY:
==26912==     in use at exit: 16 bytes in 1 blocks
==26912==   total heap usage: 1,546 allocs, 1,545 frees, 149,008 bytes allocated
==26912==
==26912== 16 bytes in 1 blocks are definitely lost in loss record 1 of 1
==26912==    at 0x4C31C15: realloc (vg_replace_malloc.c:785)
==26912==    by 0x55C5D8C: _IO_vfscanf (in /usr/lib64/libc-2.26.so)
==26912==    by 0x55D8AEC: vsscanf (in /usr/lib64/libc-2.26.so)
==26912==    by 0x55D25C3: sscanf (in /usr/lib64/libc-2.26.so)
==26912==    by 0x53236D0: mnt_table_parse_stream (in /usr/lib64/libmount.so.1.1.0)
==26912==    by 0x53249B6: mnt_table_parse_file (in /usr/lib64/libmount.so.1.1.0)
==26912==    by 0x10D157: swap_list_get (umount.c:194)
==26912==    by 0x10B06E: test_swap_list (test-umount.c:34)
==26912==    by 0x10B24B: main (test-umount.c:56)
==26912==
==26912== LEAK SUMMARY:
==26912==    definitely lost: 16 bytes in 1 blocks
==26912==    indirectly lost: 0 bytes in 0 blocks
==26912==      possibly lost: 0 bytes in 0 blocks
==26912==    still reachable: 0 bytes in 0 blocks
==26912==         suppressed: 0 bytes in 0 blocks

6 years agotest-umount: add a simple test for swap_list_get()
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 11:06:34 +0000 (12:06 +0100)]
test-umount: add a simple test for swap_list_get()

The implementation seems buggy:
/* test_swap_list("/home/zbyszek/src/systemd/test/test-umount/example.swaps") */
path=0 o= f=0x0 try-ro=no dev=0:0
path=/some/swapfile2 o= f=0x0 try-ro=no dev=0:0
path=/some/swapfile o= f=0x0 try-ro=no dev=0:0
path=/dev/dm-2 o= f=0x0 try-ro=no dev=0:0

6 years agocore/umount: use _cleanup_
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 10:32:13 +0000 (11:32 +0100)]
core/umount: use _cleanup_

6 years agotests: add a simple test for the mountinfo parsing logic
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 10:03:36 +0000 (11:03 +0100)]
tests: add a simple test for the mountinfo parsing logic

6 years agoshutdown: use libmount to enumerate /proc/self/mountinfo
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 10:32:30 +0000 (11:32 +0100)]
shutdown: use libmount to enumerate /proc/self/mountinfo

This is analogous to 8d3ae2bd4c9bf9fc2e57f7b3776325a1c750ca30, except that now
src/core/umount.c not src/core/mount.c is converted.

Might help with https://bugzilla.redhat.com/show_bug.cgi?id=1554943, or not.

In the patch, mnt_free_tablep and mnt_free_iterp are declared twice. It'd
be nicer to define them just once in mount-setup.h, but then libmount.h would
have to be included there. libmount.h seems to be buggy, and declares some
defines which break other headers, and working around this is more pain than
the two duplicate lines. So let's live with the duplication for now.

This fixes memleak of MountPoint in mount_points_list_get() on error, not that
it matters any.

6 years agosysusers: do not append entries after the NIS ones
Franck Bui [Thu, 15 Mar 2018 17:46:28 +0000 (18:46 +0100)]
sysusers: do not append entries after the NIS ones

The NIS-catchall entry switches from files to NIS lookup and never goes back,
so it must be the last entry in /etc/passwd (the other +/-{user,@netgroup}
entries don't have to be).

That's how the nss_compat mode for /etc/passwd (and /etc/group) traditionally
works.

It's age-old historic behaviour that the NIS entry must be the last one.  It
doesn't seem to be specified somewhere, but it worked like this since very
early SunOS when NIS was first included.

Fixes: #8467

6 years agoudev/net-id: Fix check for address to keep interface names stable (#8458)
Filipe Brandenburger [Thu, 15 Mar 2018 17:42:38 +0000 (10:42 -0700)]
udev/net-id: Fix check for address to keep interface names stable (#8458)

This was a bug inadvertently added by commit 73fc96c8ac0aa9.

The intent of the check is to "match slot address with device by
stripping the function" (as the comment above states it), for example
match network device PCI address 0000:05:00.0 (including a .0 for
function) to PCI slot address 0000:05:00, but changing that to a streq()
call prevented the match.

Change that to startswith(), which should both fix the bug and make the
intent of the check more clear and prevent unintentional bugs from being
introduced by future refactorings.

6 years agobasic/macros: rename noreturn into _noreturn_ (#8456)
Franck Bui [Thu, 15 Mar 2018 05:23:46 +0000 (06:23 +0100)]
basic/macros: rename noreturn into _noreturn_ (#8456)

"noreturn" is reserved and can be used in other header files we include:

  [   16s] In file included from /usr/include/gcrypt.h:30:0,
  [   16s]                  from ../src/journal/journal-file.h:26,
  [   16s]                  from ../src/journal/journal-vacuum.c:31:
  [   16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token
  [   16s]  void gpgrt_log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);

Here we include grcrypt.h (which in turns include gpg-error.h) *after* we
"noreturn" was defined in macro.h.

6 years agotest-calendarspec: add the test case from oss-fuzz 6886
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 11:51:08 +0000 (12:51 +0100)]
test-calendarspec: add the test case from oss-fuzz 6886

Before the fix 55a30fd4e8 in this would crash in calendarspec_from_time_t().

6 years agoMerge pull request #8441 from keszybz/oss-fuzz-fixes
Evgeny Vereshchagin [Wed, 14 Mar 2018 18:25:56 +0000 (21:25 +0300)]
Merge pull request #8441 from keszybz/oss-fuzz-fixes

Fixes for bugs found by oss-fuzz

6 years agobasic/calendarspec: fix assert crash when year is too large in calendarspec_from_time_t()
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 11:51:08 +0000 (12:51 +0100)]
basic/calendarspec: fix assert crash when year is too large in calendarspec_from_time_t()

gmtime_r() will return NULL in that case, and we would crash.

I committed the reproducer case in fuzz-regressions/, even though we don't have
ubsan hooked up yet. Let's add it anyway in case it is useful in the future. We
actually crash anyway when compiled with asserts, so this can be easily
reproduced without ubsan.

oss-fuzz #6886.

6 years agoshared/conf-parser: fix crash when specifiers cannot be resolved in config_parse_devi...
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 11:25:06 +0000 (12:25 +0100)]
shared/conf-parser: fix crash when specifiers cannot be resolved in config_parse_device_allow()

oss-fuzz #6885.

6 years agoTODO: trim obsolete entries
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 11:22:59 +0000 (12:22 +0100)]
TODO: trim obsolete entries

set -e is now used in test/TEST-*/test.sh, BUILD_DIR may be specified,
and symlinks are created as of ba7f4ae6178309dc937e10cf7dce0eca9dafb8de.

6 years agofuzz: commit test case for oss-fuzz issue 6884
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 13:31:24 +0000 (14:31 +0100)]
fuzz: commit test case for oss-fuzz issue 6884

This seems to be a false positive in msan:
https://github.com/google/sanitizers/issues/767.

I don't see anything wrong with the code either, and valgrind does not see the
issue. Anyway, let's add the test case.

We don't have msan hooked up yet, but hopefully we'll in the future.

oss-fuzz #6884.

6 years agotest: run all fuzz regression tests with all sanitizers
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 13:27:04 +0000 (14:27 +0100)]
test: run all fuzz regression tests with all sanitizers

We currently have just one sanitizer for tests, asan, but we may add more in
the future. So let's keep the loop over the sanitizers in meson.build, but
just enable all regression cases under all sanitizers. If it fails under one
of them, it might fail under a different one.

In subsequent commits I'll add test cases which might not fail under asan,
but it's good to commit them for future use.

The test names are made more verbose:
256/257 fuzz-dns-packet:oss-fuzz-5465:address   OK       0.04 s
257/257 fuzz-dns-packet:issue-7888:address      OK       0.03 s

6 years agocore/umount: fix unitialized fields in MountPoint in dm_list_get()
Zbigniew Jędrzejewski-Szmek [Wed, 14 Mar 2018 11:37:19 +0000 (12:37 +0100)]
core/umount: fix unitialized fields in MountPoint in dm_list_get()

This one might actually might cause a crash.

6 years agohwdb: add axis override for the Razer Blade Stealth (#8436)
Peter Hutterer [Tue, 13 Mar 2018 20:36:29 +0000 (06:36 +1000)]
hwdb: add axis override for the Razer Blade Stealth (#8436)

This touchpad has heavy jitter, set a fuzz of 8 to work around this.

From https://bugs.freedesktop.org/show_bug.cgi?id=105409

6 years agoboot: also use _cleanup_freepool_ in util.c
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 10:15:10 +0000 (11:15 +0100)]
boot: also use _cleanup_freepool_ in util.c

efivar_get() was leaking memory on success, afaict.

6 years agosd-boot: introduce _cleanup_freepool_
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 09:47:17 +0000 (10:47 +0100)]
sd-boot: introduce _cleanup_freepool_

6 years agoMerge pull request #8429 from medhefgo/sd-shutdown
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 08:47:09 +0000 (09:47 +0100)]
Merge pull request #8429 from medhefgo/sd-shutdown

sd-shutdown improvements

6 years agozsh-completion: add calendar to systemd-analyze (#8438)
Doug Christman [Tue, 13 Mar 2018 08:41:07 +0000 (16:41 +0800)]
zsh-completion: add calendar to systemd-analyze (#8438)

6 years agobasic: trivial indentation fix
Zbigniew Jędrzejewski-Szmek [Tue, 13 Mar 2018 07:32:37 +0000 (08:32 +0100)]
basic: trivial indentation fix

6 years agoMerge pull request #8423 from keszybz/unit-file-fuzzer
Evgeny Vereshchagin [Mon, 12 Mar 2018 20:08:32 +0000 (23:08 +0300)]
Merge pull request #8423 from keszybz/unit-file-fuzzer

Unit file fuzzer

6 years agoshutdown: Reduce log level of unmounts
Jan Janssen [Mon, 12 Mar 2018 12:33:16 +0000 (13:33 +0100)]
shutdown: Reduce log level of unmounts

There is little point in logging about unmounting errors if the
exact mountpoint will be successfully unmounted in a later retry
due unmounts below it having been removed.

Additionally, don't log those errors if we are going to switch back
to a initrd, because that one is also likely to finalize the remaining
mountpoints. If not, it will log errors then.

6 years agoumount: Don't bother remounting api and ro filesystems read-only
Jan Janssen [Thu, 8 Mar 2018 17:51:13 +0000 (18:51 +0100)]
umount: Don't bother remounting api and ro filesystems read-only

6 years agoumount: Try unmounting even if remounting read-only failed
Jan Janssen [Thu, 8 Mar 2018 17:46:58 +0000 (18:46 +0100)]
umount: Try unmounting even if remounting read-only failed

In the case of some api filesystems remounting read-only fails
while unmounting succeeds.

6 years agoumount: Provide the same mount flags too when remounting read-only
Jan Janssen [Thu, 8 Mar 2018 17:37:21 +0000 (18:37 +0100)]
umount: Provide the same mount flags too when remounting read-only

This most likely amounts to no real benefits and is just here for
completeness sake.