Commit graph

23893 commits

Author SHA1 Message Date
Yu Watanabe d8a0bcfd77 tree-wide: drop header for emacs from python scripts 2018-12-10 03:17:33 +09:00
Zbigniew Jędrzejewski-Szmek 6e076600d0
Merge pull request #10931 from yuwata/daemon-util
sd-daemon: add notify_on_cleanup() helper function and use it where applicable
2018-12-09 12:10:57 +01:00
Lennart Poettering be24321f3d mount-point: honour AT_SYMLINK_FOLLOW correctly
Fixes: #11092
2018-12-08 22:43:55 +01:00
Yu Watanabe d8dd35fd31 journal-remote: define main through macro
Also, this fixes memleaks on failure.
2018-12-08 18:09:40 +09:00
Yu Watanabe 94952201e1 journal-remote: destroy RemoteServer object by using _cleanup_ attribute 2018-12-08 18:09:40 +09:00
Yu Watanabe f36bb1e182 journal-upload: define main through macro 2018-12-08 18:09:40 +09:00
Yu Watanabe c9ed608679 journal-upload: use _cleanup_ attribute to clear uploader 2018-12-08 18:09:40 +09:00
Yu Watanabe 29cd4c8ffb journal-gateway: define main through macro 2018-12-08 18:09:40 +09:00
Yu Watanabe 0d2a1a2085 journal-gateway: use _cleanup_ attribute to stop microhttpd daemon 2018-12-08 18:09:40 +09:00
Yu Watanabe c03a80c419 wait-online: define main through macro 2018-12-08 18:09:40 +09:00
Yu Watanabe 82310c7981 timesync: define main through macro 2018-12-08 18:09:40 +09:00
Yu Watanabe 2362a8f547 network: define main through macro 2018-12-08 18:09:40 +09:00
Yu Watanabe 1e88b8199b resolve: define main through macro 2018-12-08 18:09:40 +09:00
Yu Watanabe c157884f09 sd-daemon: add notify_start() and notify_on_cleanup() helper function 2018-12-08 18:09:25 +09:00
Yu Watanabe 1437822638 meson: rename sd_event_c to sd_event_sources 2018-12-08 18:06:45 +09:00
Lennart Poettering 99b5b0d0ef
Merge pull request #11055 from poettering/resolved-close-fix
a number of resolved fixes
2018-12-08 00:23:43 +01:00
Lennart Poettering 06721f39f6 swap: always add in extras when we load a swap unit
Much like for the mount units we need fields such as the slice
initialized by the time we activate the swap, hence when the kernel
let's us know about a new swap that appeared we need to initialize the
slice in any Swap object we allocated for that right-away, even if we
can't read the real unit file for the swap device.
2018-12-07 17:35:32 +01:00
Lennart Poettering a0a424083f swap: drop return value
We don't actually return any valid 'r' here, let's explicitly return 0
here hence instead.
2018-12-07 17:35:32 +01:00
Lennart Poettering eb04385dc5 swap: don't propagate issues with processing /proc/swaps
This follows similar recent changes in mount.c: error should be consider
local, and not be propagated.
2018-12-07 17:35:32 +01:00
Lennart Poettering 46f944802c swap: when loading a unit from /proc/swaps, mark its load state as good
This follows similar logic in the mount unit.
2018-12-07 17:35:32 +01:00
Lennart Poettering 15332d738f swap: split out code adding in additional unit props into a function of its own
This adds swap_add_extras() similar to mount_add_extras().

No change in behaviour, just some refactoring.
2018-12-07 17:35:32 +01:00
Lennart Poettering ba6fbb2cee swap: fix misplaced comment 2018-12-07 17:35:32 +01:00
Lennart Poettering 31135818e4 swap: flush out state when activating a unit, not when deactivating it
This is similar to the previous commit which did the same change for
mount units.
2018-12-07 17:35:32 +01:00
Lennart Poettering 7eba1463de mount: flush out cycle state on DEAD→MOUNTED only, not the other way round
For services (and other units) we generally follow the rule that at the
beginning of each cycle, i.e. when the INACTIVE/FAILED state is left for
ACTIVATING/ACTIVE we flush out various state variables. Mount units
handled this differently so far when the unit state change was effected
outside of systemd: in that case these variables would be flushed out
when going back to INACTIVE/FAILED already.

Let's fix that, and flush out this state always during the activating
transition, not during the deactivating transition.
2018-12-07 17:35:32 +01:00
Lennart Poettering ec88d1ea05 mount: replace three closely related mount flags into a proper flags enum
We pass these flags around, and even created a structure for them. Let's
fix things properly, and make them a flags value of its own.
2018-12-07 17:35:32 +01:00
Lennart Poettering b6418dc94e mount: strdup() device paths we collect
We never know what the changes triggered by mount_set_state() do to the
unit. Let's be safe and copy the device path into our set, so that we
are safe against that.
2018-12-07 17:35:32 +01:00
Lennart Poettering f8064c4fda mount: when the kernel reports a mount to be established reset all kinds of load failures
It doesn't matter what kind of precise failure we had earlier with
loading the unit, let's report that it loaded successfully now, after
all the kernel is an OK source for that, like any other.
2018-12-07 17:35:32 +01:00
Lennart Poettering a37422045f mount: regenerate all deps whenever a mount's parameters changes
Whenever we notice a change on an existing /proc/self/mountinfo line,
let's update the deps generated from it. For that, let's flush out the
old deps generated this way, and add in the new ones.

This takes benefit of the fact that today (unlike a comment this patch
removes says) we can remove deps in a somewhat reasonable way.
2018-12-07 17:35:32 +01:00
Lennart Poettering 6d7e89b070 mount: when allocating a Mount object based on /proc/self/mountinfo mark it so
Let's set 'from_proc_self_mountinfo' right away, since we know its from
there. This is important so that when the load queue is dispatched (and
thus mount_load() called) this
fact is already known.
2018-12-07 17:35:32 +01:00
Lennart Poettering 26e35b164b mount: let mount_add_extras() take care of remote-fs.target deps
In a previous commit we added logic that mount_add_extras() (or more
precisely mount_add_default_dependencies()) adds in dependencies on
remote-fs.target and local-fs.target, hence we can drop this from
mount_setup_new_unit() and let the usual load queue dispatching take
care of this.
2018-12-07 17:34:29 +01:00
Lennart Poettering e10fe04266 mount: use free_and_strdup() over plain strdup()
Let's initialize two fields with free_and_strdup() rather than directly
with strdup(). The fields should not be initialized so far, but it's
still nicer to be prepared for futzre code changes and always free
what's stored before replacing it.
2018-12-07 17:34:29 +01:00
Lennart Poettering 60b8c203f8 mount: generate error message matching the error location 2018-12-07 17:34:29 +01:00
Lennart Poettering 839ee05838 mount: move allocation of Unit object into mount_setup_new_unit()
This should encapsulate things in a nicer way.
2018-12-07 17:34:29 +01:00
Lennart Poettering bbee24bc96 mount: add a common helper for filling in info from /proc/self/mountinfo 2018-12-07 17:30:14 +01:00
Lennart Poettering ba0d56f55f mount: don't propagate errors from mount_setup_unit() further up
If we can't process a specific line in /proc/self/mountinfo we should
log about it (which we do), but this should not affect other lines, nor
further processing of mount units. Let's keep these failures local.

Fixes: #10874
2018-12-07 17:30:14 +01:00
Lennart Poettering 3f459cd96e mount: simplify de-serialization of control PID a bit 2018-12-07 17:30:14 +01:00
Lennart Poettering 2c09fb818f mount: serialize umount retry counter across reloads/reexec 2018-12-07 17:30:14 +01:00
Lennart Poettering 780ae0221a mount: make sure mount_add_extras() is always invoked when we load a mount unit
We need to make sure that the slice property is initialized whenever
mount_load() is invoked, even if we fail to load things properly off
disk. This is important since we generally don't allow changing the
slice after a unit has been started. But given that we must track the
state of external objects with mount units we must hence initialize the
property no matter what.
2018-12-07 17:30:14 +01:00
Lennart Poettering 1f73647647 mount: document that mount_add_extras() must work with active units, too 2018-12-07 17:30:14 +01:00
Lennart Poettering d54bab90e6 mount: set up local-fs.target/remote-fs.target deps in mount_add_default_dependencies() too
This deps are very similar to the -pre deps, hence establish them at the
same place, in particular as they should only be generated if default
deps are on.

This allows us to later on remove similar code that adds in these deps
whenever /proc/self/mountinfo changes.
2018-12-07 17:30:14 +01:00
Lennart Poettering 32a5f8fe22 mount: remove unnecessary initialization of device_wants_mount and 'if' 2018-12-07 17:30:14 +01:00
Lennart Poettering a26592cf58 mount: use mfree() where appropriate 2018-12-07 17:30:14 +01:00
Lennart Poettering 06e457b1a3 mount: rename needs_quota() → mount_needs_quota()
No change of logic, just some renaming, in order to match more closely
the naming of the other, similar functions.
2018-12-07 17:30:14 +01:00
Lennart Poettering 7121cbcffe mount: merge redundant call mount_needs_network() into mount_is_network() 2018-12-07 17:30:14 +01:00
Lennart Poettering c23b62b40b resolved: drop unused field structure 2018-12-07 17:22:59 +01:00
Lennart Poettering 7172e4ee1e resolved: implicitly disconnect a stream from its server when a stream is closed
Previously, the callback function did this, but let's do this in the
caller instead, to make this more robust, and use our new helper
function for it.
2018-12-07 17:22:59 +01:00
Lennart Poettering 808089ae3d resolved: add new helper for carefully detach a stream from any server
This adds a helper call for detaching a DnsServer from a DnsStream if
the latter is the "default" stream of the server.

Also, let's unref the stream in dns_stream_stop() rather than
dns_stream_free(): as soon as our stream is disconnected by stopping
there's really no need to keep it as default stream for the server
around.

Since dns_stream_free() calls dns_stream_stop() we can remove it from
the former.
2018-12-07 17:22:59 +01:00
Lennart Poettering d973d94dec resolved: pin stream while calling callbacks for it
These callbacks might unref the stream, but we still have to access it,
let's hence ref it explicitly.

Maybe fixes: #10725
2018-12-07 17:22:59 +01:00
Lennart Poettering 904dcaf9d4 resolved: take particular care when detaching DnsServer from its default stream
DnsStream and DnsServer have a symbiotic relationship: one DnsStream is
the current "default" stream of the server (and thus reffed by it), but
each stream also refs the server it is connected to. This cyclic
dependency can result in weird situations: when one is
destroyed/unlinked/stopped it needs to unregister itself from the other,
but doing this will trigger unregistration of the other. Hence, let's
make sure we unregister the stream from the server before destroying it,
to break this cycle.

Most likely fixes: #10725
2018-12-07 17:16:29 +01:00
Lennart Poettering 199dda9c25 resolved: before assuming we have a server, check we are talking DNS and not LLMNR/mDNS 2018-12-07 17:16:29 +01:00