Commit Graph

30514 Commits

Author SHA1 Message Date
Lennart Poettering ecd48322c2 core: sd-bus can handle NULL strings nicely, let's use it
No need to set an empty string here, sd-bus serializes NULL as empty
string anway.
2017-11-12 14:27:19 +01:00
Lennart Poettering 3e3852b3c6 core: make "tmpfs" dependencies on swapfs a "default" dep, not an "implicit"
There should be a way to turn this logic of, and DefaultDependencies=
appears to be the right option for that, hence let's downgrade this
dependency type from "implicit" to "default, and thus honour
DefaultDependencies=.

This also drops mount_get_fstype() as we only have a single user needing
this now.

A follow-up for #7076.
2017-11-10 19:52:41 +01:00
Lennart Poettering dcebc9bae4 core: when a unit template is specified in SYSTEMD_WANTS=, instantiate it with sysfs path
This should make cases like the user's setup in #7109 a lot easier to
handle, as in that case we'll do the right escaping automatically.
2017-11-10 19:52:41 +01:00
Lennart Poettering 3ac62a0ee4 test: add test case for adding/removing dependencies via udev rules 2017-11-10 19:52:41 +01:00
Lennart Poettering 38b9b72ec1 core: remove SYSTEMD_WANTS udev property configured dependencies at the right moment
Previously dependencies configured with SYSTEMD_WANTS would be collected
on a device unit as long as it was loaded. let's fix that, and remove
dependencies again when SYTEMD_WANTS changes.
2017-11-10 19:45:29 +01:00
Lennart Poettering de04054349 device: Let's simplify device_add_udev_wants() a bit
Let's drop use of one variable and make the rest more explicit.
2017-11-10 19:45:29 +01:00
Lennart Poettering c999cf385a core: add internal API to remove dependencies again, based on dependency mask
let's make use of the dependency mask, and add internal API to remove
dependencies ago, based on bits in the dependency mask.
2017-11-10 19:45:29 +01:00
Lennart Poettering 2651d03751 man: extend documentation on the unit name escaping logic 2017-11-10 19:45:29 +01:00
Lennart Poettering 40b1a32ca8 device: rework device_is_bound_by_mounts() a bit
Let's log when we can't parse the udev property, and always use the most
precise, correct types.
2017-11-10 19:45:29 +01:00
Lennart Poettering eef85c4a3f core: track why unit dependencies came to be
This replaces the dependencies Set* objects by Hashmap* objects, where
the key is the depending Unit, and the value is a bitmask encoding why
the specific dependency was created.

The bitmask contains a number of different, defined bits, that indicate
why dependencies exist, for example whether they are created due to
explicitly configured deps in files, by udev rules or implicitly.

Note that memory usage is not increased by this change, even though we
store more information, as we manage to encode the bit mask inside the
value pointer each Hashmap entry contains.

Why this all? When we know how a dependency came to be, we can update
dependencies correctly when a configuration source changes but others
are left unaltered. Specifically:

1. We can fix UDEV_WANTS dependency generation: so far we kept adding
   dependencies configured that way, but if a device lost such a
   dependency we couldn't them again as there was no scheme for removing
   of dependencies in place.

2. We can implement "pin-pointed" reload of unit files. If we know what
   dependencies were created as result of configuration in a unit file,
   then we know what to flush out when we want to reload it.

3. It's useful for debugging: "systemd-analyze dump" now shows
   this information, helping substantially with understanding how
   systemd's dependency tree came to be the way it came to be.
2017-11-10 19:45:29 +01:00
Lennart Poettering 8f50e86a86 gpt-auto-generator: make sure "r" is always set 2017-11-10 19:00:06 +01:00
Lennart Poettering 8da0592c5d mkosi: fix build script to use right sysvinit path
On Fedora /etc/init.d is a symlink to /etc/rc.d/init.d. Our build
scripts default to /etc/init.d since that is the LSB default. Let's make
sure the build script thus follows the symlink correctly and configures
to path explicitly, since otherwise our build artifacts in $DESTDIR are
incompatible with the setup we actually need for Fedora.
2017-11-10 19:00:06 +01:00
Lennart Poettering f33a319f99 mkosi: configure mkosi.cache/ and mkosi.builddir/ explicitly
This way these dirs will be created automatically if they are missing,
thus always guaranteeing optimal speedy behaviour.

(Well at least, after https://github.com/systemd/mkosi/pull/181 is
merged)
2017-11-10 19:00:06 +01:00
Lennart Poettering e37fae1ea0 core: include a bad /var/run symlink in the "tainted" string 2017-11-10 19:00:06 +01:00
Lennart Poettering 45e1c7d5ca virt: trivial whitespace fixes 2017-11-10 19:00:06 +01:00
Boucman f332611abe device : reload when udev generates a "changed" event (#6850) 2017-11-10 17:00:32 +01:00
Lennart Poettering 8d644046d9
Merge pull request #7089 from oniko/luks2-support
LUKS2 support for systemd-cryptsetup and dissect-image
2017-11-10 16:16:36 +01:00
juga0 28522b0d8c networkd: set dhcp_use_routes to true when dhcp_anonymize is true (#7209)
It does not send duplicated options in the PRL.
Fix #7048.
2017-11-10 16:03:43 +01:00
Alan Jenkins 9b9881d75b core: add missing error_message cases (#6911)
We neglected to set error_message for errors which occur _after_ the
`finish` label.  These fatal errors only happen in paths where `finish`
was reached successfully, i.e. error_message has not already been set
(and this analysis is simple enough that this need not cause too much
headaches.  Also our new assignments to error_message come immediately
after execve() calls, which would have lost the error_message if it had
been set).

Also print a status message when we fail to exec init, otherwise the only
sign the user will see is `# ` :).

This addresses the lack of error messages pointed out in issue #6827.
2017-11-10 15:57:52 +01:00
Lennart Poettering 67595fce2d
Merge pull request #7096 from keszybz/logind-session-killing
Logind session killing fix
2017-11-10 15:51:39 +01:00
Zbigniew Jędrzejewski-Szmek 556c7bae0c basic/hashmap: add cleanup of memory pools (#7164)
It was dropped in 89439d4fc0. As a result, every
process that uses a hashmap allocates and then leaks the hashmap mempools.
The mempools are only allocated in the main thread, but we don't know where
the memory is used.

So let's check if we are the last thread and free the mempools then. This is
fairly heavy, because /proc/self/status has to be opened and parsed, but we do
it only when compiled for valgrind, i.e. not by default, and compared to running
under valgrind or asan, the extra cost is acceptable. The big advantage is that
we don't have to think or filter out this false positive.

As a micro-opt, cleanup is attempted only in the main thread. We could allow
any thread to check if it is the last one and perform cleanup, but that'd mean
that we'd have to _do_ the check in every thread. We don't use threads like
that, our non-main threads are always short-lived, so let's just accept the
possibility that we'll leak memory if a thread survives. The check is also
non-atomic, but it's called in a destructor of the main thread _and_ we do
cleanup only when there are no other threads, so the risk of some library
suddenly spawning another thread is very low. All in all, this is not perfect,
but should work in 999‰ of cases.

Fixes the following valgrind warning:

==22564== HEAP SUMMARY:
==22564==     in use at exit: 8,192 bytes in 2 blocks
==22564==   total heap usage: 243 allocs, 241 frees, 151,905 bytes allocated
==22564==
==22564== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 2
==22564==    at 0x4C2FB6B: malloc (vg_replace_malloc.c:299)
==22564==    by 0x4F08A8C: mempool_alloc_tile (mempool.c:62)
==22564==    by 0x4F08B16: mempool_alloc0_tile (mempool.c:81)
==22564==    by 0x4EF8DE0: hashmap_base_new (hashmap.c:748)
==22564==    by 0x4EF8ED9: internal_hashmap_new (hashmap.c:782)
==22564==    by 0x11045D: test_hashmap_copy (test-hashmap-plain.c:87)
==22564==    by 0x115722: test_hashmap_funcs (test-hashmap-plain.c:914)
==22564==    by 0x10FC9D: main (test-hashmap.c:60)
==22564==
==22564== 4,096 bytes in 1 blocks are still reachable in loss record 2 of 2
==22564==    at 0x4C2FB6B: malloc (vg_replace_malloc.c:299)
==22564==    by 0x4F08A8C: mempool_alloc_tile (mempool.c:62)
==22564==    by 0x4F08B16: mempool_alloc0_tile (mempool.c:81)
==22564==    by 0x4EF8DE0: hashmap_base_new (hashmap.c:748)
==22564==    by 0x4EF8EF8: internal_ordered_hashmap_new (hashmap.c:786)
==22564==    by 0x10A2A0: test_ordered_hashmap_copy (test-hashmap-ordered.c:89)
==22564==    by 0x10F70F: test_ordered_hashmap_funcs (test-hashmap-ordered.c:916)
==22564==    by 0x10FCA2: main (test-hashmap.c:61)
==22564==
==22564== LEAK SUMMARY:
==22564==    definitely lost: 0 bytes in 0 blocks
==22564==    indirectly lost: 0 bytes in 0 blocks
==22564==      possibly lost: 0 bytes in 0 blocks
==22564==    still reachable: 8,192 bytes in 2 blocks
==22564==         suppressed: 0 bytes in 0 blocks

v2:
- check if we are the main thread

v3:
- check if there are no other threads
2017-11-10 15:44:58 +01:00
Antonio Rojas 8e6a7a8b2b Fix typo in statx macro (#7180)
This makes statx properly whitelisted in supported systems.
2017-11-10 11:07:36 +01:00
Simon Arlott 6fcae8e4de rules: run all persistent-input rules for rmi and i8042 (#7287)
Commit 83b48159 set ID_BUS for these subsystems but copied the intent
of commit c49df207 by not creating symlinks for those devices.

Remove the GOTO so that the rest of the rules are still processed and
symlinks are created for rmi and i8042 devices.
2017-11-10 10:32:51 +01:00
John Lin ff21046656 systemctl: fix memory leak (#7289)
Fixes: #7283
2017-11-10 10:32:25 +01:00
tblume ed457f1380 systemd-firstboot: add vconsole keymap support (#7035)
Enable systemd-firstboot to set the keymap.

RFE:

https://github.com/systemd/systemd/issues/6346
2017-11-10 10:31:44 +01:00
Yu Watanabe c54515b1e4 core/load-fragment: add RemoveIPC= (#7288)
PR #3865 introduced RemoveIPC= but the option is not listed in
load-fragment-gperf.gperf. So, the option could be used only via d-bus.
This adds RemoveIPC= in load-fragment-gperf.gperf. Then, now we can
set the option in unit files.

Fixes #7281.
2017-11-10 10:15:55 +01:00
John Lin caa45f5b4e man: remove restrictions in [Install] section (#7278)
Now [Install] section also supports drop-in files.

Follow-up for 142468d895.
2017-11-10 00:12:01 +09:00
Collin Eggert 79f3cd2bf5 hwdb: Add ACCEL_MOUNT_MATRIX for HP Stream 8 (#7279) 2017-11-09 15:38:34 +01:00
Lennart Poettering 4deff0b92b
Merge pull request #7280 from yuwata/fix-7270-2
test-event: do not work in assert()
2017-11-09 14:26:42 +01:00
Lukáš Nykrýn f7576eb9fd cryptsetup: ignore _netdev, since it is used in generator (#7282) 2017-11-09 14:24:57 +01:00
Yu Watanabe 3fcf65c352 test-parse-util: add more tests, mainly for empty string 2017-11-09 18:39:50 +09:00
Yu Watanabe ccd1fc2f69 libsystemd-network: coding style fix 2017-11-09 18:39:41 +09:00
Yu Watanabe 1950011227 tree-wide: do not work in assert()
Follow-up for 85e55d14de.
2017-11-09 18:38:02 +09:00
Lennart Poettering f5f0dca0ce
Merge pull request #7112 from tstellar/udev-for-kfd
udev-rules: Add rules for /dev/kfd
2017-11-09 09:22:55 +01:00
Dimitri John Ledkov 02ec6e04fd test-bpf: use /bin/ping path (#7276)
This path to ping is compatible with both debian-like and usr-merged
distros. This keeps the test simple, and should thus pass everywhere.

Fixes: #7267
2017-11-08 20:04:55 +01:00
John Lin 142468d895 systemctl: respect [Install] section in drop-ins (#7158)
Fixes: #7114
2017-11-08 18:04:31 +01:00
Tom Stellard 3754abc58f NEWS: Add note about udev changes for /dev/kvm, /dev/dri/renderD*, and /dev/kfd 2017-11-08 08:37:18 -08:00
Lennart Poettering f9007887a6
Merge pull request #7268 from yuwata/rfe-7262
timesync: make poll interval configurable
2017-11-08 17:35:56 +01:00
Lennart Poettering 376065ee26
Merge pull request #7275 from yuwata/fix-7070-7260
core: fixes related to RuntimeDirectory=, ReadWritePaths= and DynamicUser=
2017-11-08 17:34:39 +01:00
Tom Stellard f301622d84 udev-rules: Add rule for /dev/kfd 2017-11-08 08:22:05 -08:00
Tom Stellard 4e15a7343c udev-rules: Permission changes for /dev/dri/renderD*
- Remove the uaccess tag from /dev/dri/renderD*.
- Change the owning group from video to render.
- Change default mode to 0666.
- Add an option to allow users to set the access mode for these devices at
compile time.
2017-11-08 08:21:31 -08:00
Tom Stellard b8fd3d8220 udev-rules: Permission changes for /dev/kvm
- Remove uaccess tag from /dev/kvm.
- Change the default mode for /dev/kvm to 0666.
2017-11-08 08:17:49 -08:00
NeilBrown c44cac7c6c umount: always use MNT_FORCE in umount_all() (#7213)
The linux umount2() systemcall accepts a MNT_FORCE flags
which some filesystems honor, particularly FUSE and various
network filesystems such as NFS.
These filesystems can sometimes wait for an indefinite period
for a response from an external service, and the wait if
sometimes "uninterruptible" meaning that the process cannot be
killed.
Using MNT_FORCE causes any such request that are outstanding to
be aborted.  This normally allows the waiting process to
be killed.  It will then realease and reference it has to the
filesytem, this allowing the filesystem to be unmounted.

If there remain active references to the filesystem, MNT_FORCE
is *not* forcefull enough to unmount the filesystem anyway.

By the time that umount_all() is run by systemd-shutdown, all
filesystems *should* be unmounted, and sync() will have been
called.  Anything that remains cannot be unmounted in a
completely clean manner and just nees to be dealt with as firmly
as possible.  So use MNT_FORCE and try to explain why in the
comment.

Also enhance an earlier comment to explain why umount2() is
safe even though mount(MNT_REMOUNT) isn't.
2017-11-08 11:29:32 +03:00
Yu Watanabe fdfcb94631 man: update documents for RuntimeDirectory= and friends 2017-11-08 15:52:08 +09:00
Yu Watanabe 8092a48cc1 core/execute: do not create RuntimeDirectory= under private/ sub-directory
RuntimeDirectory= often used for sharing files or sockets with other
services. So, if creating them under private/ sub-directory, we cannot
set DynamicUser= to service units which want to share something through
RuntimeDirectory=.
This makes the directories given by RuntimeDirectory= are created under
/run/ even if DynamicUser= is set.

Fixes #7260.
2017-11-08 15:50:58 +09:00
Yu Watanabe 2bf13bd51e core/load-fragment: fix alignment 2017-11-08 15:49:22 +09:00
Yu Watanabe 652bb2637a core/execute: RuntimeDirectory= or friends requires mount namespace
Since #6940, RuntimeDirectory= or their friends imply BindPaths=.
So, if at least one of them are set, mount namespace is required.
2017-11-08 15:48:51 +09:00
Yu Watanabe 23fd04e92d test: add test for ReadOnlyPaths= with RuntimeDirectory= 2017-11-08 15:48:32 +09:00
Yu Watanabe d18aff0422 core: ReadWritePaths= and friends assume '+' prefix when BindPaths= or freinds are set
When at least one of BindPaths=, BindReadOnlyPaths=, RootImage=,
RuntimeDirectory= or their friends are set, systemd prepares
a namespace under /run/systemd/unit-root. Thus, ReadWritePaths=
or their friends without '+' prefix is completely meaningless.
So, let's assume '+' prefix when one of them are set.

Fixes #7070 and #7080.
2017-11-08 15:48:01 +09:00
Yu Watanabe 7bcef4efe6 core: remove compile_read_write_paths()
From 6c47cd7d3b, RuntimeDirectory= and
their friends also imply BindPaths=. Thus, implying ReadWritePaths=
is meaningless.
2017-11-08 15:07:22 +09:00