Commit Graph

32768 Commits

Author SHA1 Message Date
Yu Watanabe ef5018515a
Merge pull request #8468 from fbuihuu/sysusers-support-nis
Sysusers support nis

Fixes #8467.
2018-03-18 19:57:18 +09:00
Karol Augustin 94a1d03e27 units: Fix SuccessAction that belongs to [Unit] section not [Service] section (#8478) 2018-03-18 19:40:07 +09:00
Franck Bui 97e34e945c test: add a sysusers test with NIS entries 2018-03-17 14:18:26 +01:00
Yu Watanabe a6d09d946b
Merge pull request #8473 from keszybz/fix-dbus-reload
Fix dbus reload. Fixes #8414.
2018-03-17 19:45:38 +09:00
Zbigniew Jędrzejewski-Szmek 1c56d50109 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.
2018-03-17 09:48:22 +01:00
Zbigniew Jędrzejewski-Szmek 10062bbc35 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.
2018-03-17 09:01:53 +01:00
Zbigniew Jędrzejewski-Szmek 064c593899 core/service: fix memleak of USBFunctionStrings and USBFunctionDescriptors
oss-fuzz #6892.
2018-03-17 09:01:53 +01:00
Zbigniew Jędrzejewski-Szmek 4b8d0cdf04 Add .gitattributes for test/fuzz-regressions
Those reproducers are essentially binary, hence let's ignore whitespace
in them.
2018-03-17 09:01:53 +01:00
Zbigniew Jędrzejewski-Szmek 7435315812 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.
2018-03-17 08:59:25 +01:00
Filipe Brandenburger 9b796f3523 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.
2018-03-16 16:31:17 -07:00
Zbigniew Jędrzejewski-Szmek ba0c7754d8 core/manager: move some comments to a better place 2018-03-16 23:15:54 +01:00
Zbigniew Jędrzejewski-Szmek e63ebf71ed 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 8559b3b75c, 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.
2018-03-16 23:14:04 +01:00
Filipe Brandenburger b4346b9a77 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.
2018-03-16 13:45:03 -07:00
futpib d24e70fe8b hwdb: fix comment suggested `udevadm trigger` command (#8465) 2018-03-16 23:25:14 +09:00
Yu Watanabe 0caa99466d udev: use startswith() instead of the combination of strneq() and strlen() (#8459) 2018-03-16 10:29:57 +01:00
Zbigniew Jędrzejewski-Szmek 71ae04c400 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
2018-03-16 10:12:50 +01:00
Zbigniew Jędrzejewski-Szmek 1fd8edb53a 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
2018-03-16 10:12:50 +01:00
Zbigniew Jędrzejewski-Szmek a6dcd22976 core/umount: use _cleanup_ 2018-03-16 10:12:50 +01:00
Zbigniew Jędrzejewski-Szmek 6fa392bf91 tests: add a simple test for the mountinfo parsing logic 2018-03-16 10:12:50 +01:00
Zbigniew Jędrzejewski-Szmek 95b862b054 shutdown: use libmount to enumerate /proc/self/mountinfo
This is analogous to 8d3ae2bd4c, 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.
2018-03-16 10:09:46 +01:00
Franck Bui 563dc6f8e2 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
2018-03-16 10:01:33 +01:00
Filipe Brandenburger 8eebb6a9e5 udev/net-id: Fix check for address to keep interface names stable (#8458)
This was a bug inadvertently added by commit 73fc96c8ac.

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.
2018-03-16 02:42:38 +09:00
Franck Bui 848e863acc 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.
2018-03-15 14:23:46 +09:00
Zbigniew Jędrzejewski-Szmek 5ee45c6d63 test-calendarspec: add the test case from oss-fuzz 6886
Before the fix 55a30fd4e8 in this would crash in calendarspec_from_time_t().
2018-03-15 00:15:15 +01:00
Evgeny Vereshchagin 3b71cf46be
Merge pull request #8441 from keszybz/oss-fuzz-fixes
Fixes for bugs found by oss-fuzz
2018-03-14 21:25:56 +03:00
Zbigniew Jędrzejewski-Szmek 55a30fd4e8 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.
2018-03-14 16:50:09 +01:00
Zbigniew Jędrzejewski-Szmek 20d52ab60e shared/conf-parser: fix crash when specifiers cannot be resolved in config_parse_device_allow()
oss-fuzz #6885.
2018-03-14 16:50:08 +01:00
Zbigniew Jędrzejewski-Szmek 0d032da993 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 ba7f4ae617.
2018-03-14 16:37:09 +01:00
Zbigniew Jędrzejewski-Szmek 8d89e51f3c 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.
2018-03-14 15:20:02 +01:00
Zbigniew Jędrzejewski-Szmek 52d4d1d339 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
2018-03-14 14:27:04 +01:00
Zbigniew Jędrzejewski-Szmek b93618644b core/umount: fix unitialized fields in MountPoint in dm_list_get()
This one might actually might cause a crash.
2018-03-14 12:38:43 +01:00
Peter Hutterer 539ad37f18 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
2018-03-14 05:36:29 +09:00
Zbigniew Jędrzejewski-Szmek 46af0be929 boot: also use _cleanup_freepool_ in util.c
efivar_get() was leaking memory on success, afaict.
2018-03-13 11:42:02 +01:00
Zbigniew Jędrzejewski-Szmek a42d7cf165 sd-boot: introduce _cleanup_freepool_ 2018-03-13 11:41:32 +01:00
Zbigniew Jędrzejewski-Szmek d4f5c00153
Merge pull request #8429 from medhefgo/sd-shutdown
sd-shutdown improvements
2018-03-13 09:47:09 +01:00
Doug Christman ce21568dc3 zsh-completion: add calendar to systemd-analyze (#8438) 2018-03-13 09:41:07 +01:00
Zbigniew Jędrzejewski-Szmek 6a2b82a713 basic: trivial indentation fix 2018-03-13 08:33:14 +01:00
Evgeny Vereshchagin 7a30dfeb18
Merge pull request #8423 from keszybz/unit-file-fuzzer
Unit file fuzzer
2018-03-12 23:08:32 +03:00
Jan Janssen 456b2199f6 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.
2018-03-12 18:32:26 +01:00
Jan Janssen e783b4902f umount: Don't bother remounting api and ro filesystems read-only 2018-03-12 18:32:26 +01:00
Jan Janssen 8645ffd12b umount: Try unmounting even if remounting read-only failed
In the case of some api filesystems remounting read-only fails
while unmounting succeeds.
2018-03-12 18:32:26 +01:00
Jan Janssen 3bc341bee9 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.
2018-03-12 18:32:26 +01:00
Jan Janssen 1d62d22d94 umount: Decide whether to remount read-only earlier 2018-03-12 18:32:26 +01:00
Jan Janssen 0494cae03d umount: Add more asserts and remove some unused arguments 2018-03-12 18:32:10 +01:00
Zbigniew Jędrzejewski-Szmek 99eae076eb
Merge pull request #8296 from poettering/resolvconf
resolvconf(8) compat interface
2018-03-12 17:27:39 +01:00
Yu Watanabe dace710c4a dhcp4: introduce new option 'duid-only' for ClientIdentifier= (#8350)
This makes users can configure DHCPv4 client with ClientIdentifier=duid-only.
If set so, then DHCP client sends only DUID as the client identifier.
This may not be RFC compliant, but some setups require this.

Closes #7828.
2018-03-12 17:18:07 +01:00
Zbigniew Jędrzejewski-Szmek 36cd9913ce tools/oss-fuzz: add clang library dir using -L
I have no idea why clang doesn't do this on its own, and why clang
makes it so hard to query this path (-dumpversion returns something
unrelated...).

I know this is an ugly hack, but this is a very specialized script,
so it should be OK to make it a bit hacky.

Tested to work on Fedora (27) and Debian (unstable).

Fixes #8428.
2018-03-12 15:59:25 +01:00
Zbigniew Jędrzejewski-Szmek 9037a0e022 Rename scripts/oss-fuzz.sh to tools/oss-fuzz.sh 2018-03-12 15:40:37 +01:00
Zbigniew Jędrzejewski-Szmek 748c59b110 Rename scripts/coverity.sh to tools/coverity.sh
There are only two files in tools/, I don't think we need a separate
directory for them.
2018-03-12 15:39:21 +01:00
Jan Janssen 659b15313b umount: Fix memory leak 2018-03-12 13:40:14 +01:00