Commit Graph

31614 Commits

Author SHA1 Message Date
Lennart Poettering d97eac36d8 man: document all the new APIs we added 2018-01-05 13:58:33 +01:00
Lennart Poettering 51b13863a2 meson: resurrect API documentation target
We had this functionality back in Automake times, let's resurrect it.
2018-01-05 13:58:33 +01:00
Lennart Poettering 66baf8c644 sd-bus: remove 'hint_sync_call' parameter from various function calls
This is unused since kdbus is gone, hence remove this too. This permits
us to get rid of sd_bus_send_internal() and just implement sd_bus_send()
directly.
2018-01-05 13:58:33 +01:00
Lennart Poettering a5ea30b75b pid1: set org.freedesktop.systemd1 as sender service name for direct connections
This way, clients can install the very same match on direct and broker
connections as in both cases the messages will originate from the o.f.s1
service.
2018-01-05 13:58:33 +01:00
Lennart Poettering 48ef41a335 sd-bus: add API to optionally set a sender field on all outgoing messages
This is useful on direct connections to generate messages with valid
sender fields.

This is particularly useful for services that are accessible both
through direct connections and the broker, as it allows clients to
install matches on the sender service name, and they work the same in
both cases.
2018-01-05 13:58:33 +01:00
Lennart Poettering c944ca8e82 verbs: suppress debug log message if SYSTEMD_OFFLINE is not set
If SYSTEMD_OFFLINE is not set getenv_bool() for it will return -ENXIO,
which is nothing we should log about, not even at LOG_DEBUG level.
2018-01-05 13:58:33 +01:00
Lennart Poettering 2767027bb7 test: fix condition test if there are no controllers
As an optimization cg_mask_to_string() returns NULL if there are no
controllers available. We need to handle that.
2018-01-05 13:58:32 +01:00
Lennart Poettering 0f08647120 sd-bus: drop some unused fields from the sd_bus_message structure 2018-01-05 13:58:32 +01:00
Lennart Poettering 31b2cd5d23 tree-wide: make the Subscribe() method calls asynchronous too 2018-01-05 13:58:32 +01:00
Lennart Poettering dbc526f0bc sd-bus: accept NULL callbacks in sd_bus_call_async()
This way sd_bus_call_method_async() (which is just a wrapper around
sd_bus_call_async()) can be used to put method calls together that
expect no reply.
2018-01-05 13:58:32 +01:00
Lennart Poettering 3e0e196efd sd-bus: log about bus state changes
Let's unify all state changes in a new helper function, from which we
can then debug log all state changes
2018-01-05 13:58:32 +01:00
Lennart Poettering d7afd945b5 networkd,resolved: make use of watch_bind feature to connect to the bus
The changes both networkd and resolved to make use of the watch_bind
feature of sd-bus to connect to the system bus. This way, both daemons
can be started during early boot, and automatically and instantly
connect to the system bus as it becomes available.

This replaces prior code that used a time-based retry logic to connect
to the bus.
2018-01-05 13:58:32 +01:00
Lennart Poettering b38cc8d563 sd-bus: add new sd_bus_set_connected_signal() API
With this new API sd-bus can synthesize a local "Connected" signal when
the connection is fully established. It mirrors the local "Disconnected"
signal that is already generated when the connection is terminated. This
is useful to be notified when connection setup is done, in order to
start method calls then, in particular when using "slow" connection
methods (for example slow TCP, or most importantly the "watch_bind"
inotify logic).

Note that one could also use hook into the initial NameAcquired signal
received from the bus broker, but that scheme works only if we actually
connect to a bus. The benefit of "Connected" OTOH is that it works with
any kind of connection.

Ideally, we'd just generate this message unconditionally, but in order
not to break clients that do not expect this message it is opt-in.
2018-01-05 13:58:32 +01:00
Lennart Poettering bdbc866914 sd-bus: add new sd_bus_is_ready() API
This new call is much light sd_bus_is_open(), but returns true only if
the connection is fully set up, i.e. after we finished with the
authentication and Hello() phase. This API is useful for clients in
particular when using the "watch_bind" feature, as that way it can be
determined in advance whether it makes sense to sync on some operation.
2018-01-05 13:58:32 +01:00
Lennart Poettering f9d5fcceaf sd-bus: modernize how we generate the match string in sd-bus-track
strjoina() FTW!
2018-01-05 13:58:32 +01:00
Lennart Poettering 15ca0a42c7 sd-bus: drop references to legacy /var/run D-Bus socket
Let's directly reference /run instead, so that we can work without /var
being around, or with /var/run being incorrectly set up.

Note that we keep the old socket path in place when referencing the
system bus of containers, as they might be foreign operating systems,
that still don't have adopted /run, and where it makes sense to use the
standardized name instead. On local systems, we insist on /run being set
up properly however, hence this limitation does not apply.

Also, get rid of the UNIX_SYSTEM_BUS_ADDRESS and
UNIX_USER_BUS_ADDRESS_FMT defines. They had a purpose when we still did
kdbus, as we then had to support two different backends. But since
that's gone, we don't need this indirection anymore, hence settle on a
one define only.
2018-01-05 13:58:32 +01:00
Lennart Poettering 8c095a070b man: let's drop references to /var/run in public man pages
/var/run is a legacy compatibility feature, let's avoid mentioning it.
2018-01-05 13:58:32 +01:00
Lennart Poettering 75152a4d6a tree-wide: install matches asynchronously
Let's remove a number of synchronization points from our service
startups: let's drop synchronous match installation, and let's opt for
asynchronous instead.

Also, let's use sd_bus_match_signal() instead of sd_bus_add_match()
where we can.
2018-01-05 13:58:32 +01:00
Lennart Poettering 0c0b930647 tree-wide: make name requesting asynchronous in all our services
This optimizes service startup a bit, and makes it less prone to
deadlocks.
2018-01-05 13:58:32 +01:00
Lennart Poettering 45754e01ea sd-bus: when disconnecting a slot, also reset its memory
Yes, we aren#t accessing this anymore after, but it's still nicer if
this is actually guaranteed.
2018-01-05 13:58:32 +01:00
Lennart Poettering b423e4fb73 sd-bus: add new API sd_bus_match_signal() + sd_bus_match_signal_asnyc()
These are convenience helpers that hide the match string logic (which we
probably should never have exposed), and instead just takes regular C
arguments.
2018-01-05 13:58:32 +01:00
Lennart Poettering 7593c7a495 sd-bus: add asynchronous version of sd_bus_match()
We usually enqueue a number of these calls on each service
initialization. Let's do this asynchronously, and thus remove
synchronization points. This improves both performance behaviour and
reduces the chances to deadlock.
2018-01-05 13:58:32 +01:00
Lennart Poettering acd340158a sd-bus: when removing a server-side match, do so in "fire and forget" fashion
We currently wait for the RemoveMatch() reply, but then ignore what it
actually says. Let's optimize this a bit, and not even ask for an answer
back: just enqueue the RemoveMatch() operation, and do not request not
wait for any answer.
2018-01-05 13:58:32 +01:00
Lennart Poettering aec7b7bae7 sd-bus: remove bus_remove_match_by_string() helper which is unused 2018-01-05 13:58:32 +01:00
Lennart Poettering 0259b87f5e sd-bus: drop unused parameters from bus_add_match_internal()
We don't need the match components anymore, since kdbus is gone, hence
drop it.
2018-01-05 13:58:32 +01:00
Lennart Poettering 98c5bbc85d sd-bus: add APIs to request/release names asynchronously
They do the same thing as their synchronous counterparts, but only
enqueue the operation, thus removing synchronization points during
service initialization.

If the callback function is passed as NULL we'll fallback to generic
implementations of the reply handlers, that terminate the connection if
the requested name cannot be acquired, under the assumption that not
being able to acquire the name is a technical problem.
2018-01-05 13:58:32 +01:00
Lennart Poettering e8bd7b092f bus-control: remove kdbus indirection cruft
When kdbus was still around we always had two implementations of the
various control calls: one for dbus1 and one for kdbus. Let'sget rid of
this, simplify things, and just merge the wrappers that used to
multiplex this with the implementations.

No change in behaviour, just some merging of functions
2018-01-05 13:58:32 +01:00
Lennart Poettering c7db1984d0 sd-bus: get rid of kdbus flags cruft
We only need three bits from the old kdbus flags cruft, hence let's make
them proper booleans.
2018-01-05 13:55:08 +01:00
Lennart Poettering 56d820b6a4 busctl: add a new --watch-bind switch
This is useful for testing, and early-boot scripting.
2018-01-05 13:55:08 +01:00
Lennart Poettering ac8029fc25 sd-bus: start reply callback timeouts only when the connection is established
Currently, reply callback timeouts are started the instant the method
calls are enqueued, which can be very early on. For example, the Hello()
method call is enqueued right when sd_bus_start() is called, i.e. before
the socket connection and everything is established.

With this change we instead start the method timeout the moment we
actually leave the authentication phase of the connection. This way, the
timeout the kernel applies on socket connecting, and we apply on the
authentication phase no longer runs in parallel to the Hello() method
call, but all three run serially one after the other, which is
definitely a cleaner approach.

Moreover, this makes the "watch bind" feature a lot more useful, as it
allows enqueuing method calls while we are still waiting for inotify
events, without them timeouting until the connection is actually
established, i.e. when the method call actually has a chance of being
actually run.

This is a change of behaviour of course, but I think the new behaviour
is much better than the old one, since we don't race timeouts against
each other anymore...
2018-01-05 13:55:08 +01:00
Lennart Poettering 8a5cd31e5f sd-bus: optionally, use inotify to wait for bus sockets to appear
This adds a "watch-bind" feature to sd-bus connections. If set and the
AF_UNIX socket we are connecting to doesn't exist yet, we'll establish
an inotify watch instead, and wait for the socket to appear. In other
words, a missing AF_UNIX just makes connecting slower.

This is useful for daemons such as networkd or resolved that shall be
able to run during early-boot, before dbus-daemon is up, and want to
connect to dbus-daemon as soon as it becomes ready.
2018-01-05 13:55:08 +01:00
Lennart Poettering 5b5e6deabb bus: touch() the AF_UNIX sockets we listen() on after the fact
We'd like to use inotify to get notified when AF_UNIX sockets become
connectable. That happens at the moment of listen(), but this is doesn't
necessarily create in a watchable inotify event. Hence, let's synthesize
one whenever we generically create a socket, or when we know we created
it for a D-Bus server.

Ideally we wouldn't have to do this, and the kernel would generate an
event anyway for this. Doing this explicitly isn't too bad however, as
the event is still nicely associated with the AF_UNIX socket node, and
we generate all D-Bus sockets in our code hence it's safe.
2018-01-05 13:55:08 +01:00
Lennart Poettering 8b7f989a58 socket-util: explicitly ensure there's one trailing NUL byte on AF_UNIX socket addresses
AF_UNIX socket addresses aren't necessarily NUL terminated, however
they are usually used as strings which are assumed to be NUL terminated.
Let's hence add an extra byte to the end of the sockaddr_un structure,
that contains this NUL byte, simply for safety reasons.

Note that actually this patch changes exactly nothing IRL, as the other
sockaddr structures already are large enough to accomodate for an extra
NUL byte. The size of the union hence doesn't change at all by doing
this. The entire value of this patch is hence in the philosophical
feeling of safety, and by making something explicit that before was
implicit.
2018-01-05 13:55:08 +01:00
Lennart Poettering 89220e2fb6 socket-util: use parse_ip_port() for parsing IP ports
Let's unify some code here, and also use parse_ip_port() for all our IP
port parsing needs in socket_address_parse().
2018-01-05 13:55:08 +01:00
Lennart Poettering 706d7c27ad socket-label: tweak socket_address_listen() a bit
This changes two things when binding to AF_UNIX file system sockets:

1. When wethe socket already exists in the fs, and unlink() on it fails,
   don't bother to bind() a second time: since nothing changed it won't
   work either.

2. Also use SELinux-aware bind() for the second attempt.
2018-01-05 13:55:08 +01:00
Lennart Poettering 294d46f138 socket-label: simplify things a bit by using socket_address_get_path()
Let's make this more generic and descriptive, and let's reuse our
existing utility functions.
2018-01-05 13:55:08 +01:00
Lennart Poettering 9e3fa6e827 fs-util: rework touch_file() so that it can touch socket file nodes
Let's rework touch_file() so that it works correctly on sockets, fifos,
and device nodes: let's open an O_PATH file descriptor first and operate
based on that, if we can. This is usually the better option as it this
means we can open AF_UNIX nodes in the file system, and update their
timestamps and ownership correctly. It also means we can correctly touch
symlinks and block/character devices without triggering their drivers.

Moreover, by operating on an O_PATH fd we can make sure that we
operate on the same inode the whole time, and it can't be swapped out in
the middle.

While we are at it, rework the call so that we try to adjust as much as
we can before returning on error. This is a good idea as we call the
function quite often without checking its result, and hence it's best to
leave the files around in the most "correct" fashion possible.
2018-01-05 13:55:08 +01:00
Lennart Poettering 5ae37ad833 sd-bus: when attached to an sd-event loop, disconnect on processing errors
If we can't process the bus for some reason we shouldn't just disable
the event source, but log something and give up on the connection. Hence
do that, and disconnect.
2018-01-05 13:55:08 +01:00
Lennart Poettering b057498a52 sd-bus: propagate handling errors for Hello method reply directly
Currently, when sd-bus is used to issue a method call, and we get a
reply and the specified reply handler fails, we log this locally at
debug priority and proceed. The idea is that a bad server-side reply
should not be fatal for the program, except when the developer
explicitly terminates the event loop.

The reply to the initial Hello() method call we issue when joining a bus
should not be handled like that however. Instead, propagate the error
immediately, as anything that is wrong with the Hello() reply should be
considered a fatal connection problem.
2018-01-05 13:55:08 +01:00
Lennart Poettering b33652fe91 sd-bus: minor coding style fix 2018-01-05 13:55:08 +01:00
Lennart Poettering 6ae22ffb72 sd-bus: cast some syscall invocations explicitly to (void)
Let's clarify that we knowingly ignore the return values.
2018-01-05 13:55:08 +01:00
Lennart Poettering e32fd6b47c sd-bus: when debug logging about messages, show the same bits of it everywhere
Also, include the message signature everywhere.
2018-01-05 13:55:08 +01:00
Lennart Poettering 665dfe9318 io-util: make flush_fd() return how many bytes where flushed
This is useful so that callers know whether anything at all and how much
was flushed.

This patches through users of this functions to ensure that the return
values > 0 which may be returned now are not propagated in public APIs.

Also, users that ignore the return value are changed to do so explicitly
now.
2018-01-05 13:55:08 +01:00
John Lin 7c59ab4ba1 install: search preset files in /run (#7715)
According to systemd.preset(5), presets files in /run should take
effect. However, before this patch, preset files in /run were
ignored.
2018-01-05 13:15:42 +01:00
Zbigniew Jędrzejewski-Szmek 5035800495
Merge pull request #7763 from yuwata/fix-7761
Revert "core/execute: RuntimeDirectory= or friends requires mount namespace"
2018-01-05 12:38:29 +01:00
Bruce A. Johnson 94d4acbe4b systemd-udevd: fix speed/duplex processing with valid .link files (#7808)
Including BitsPerSecond or Duplex values in .link files did not work when
set_slinksettings was called because the routine was not copying the base
parameters to the structure given to ioctl.  As a result, EINVAL was always
reported, and no change occurred on the Ethernet device.
2018-01-05 10:02:38 +01:00
Alexis Deruelle c559eecaad Touchpad range : add another Macbook4,1 variant (#7749)
#Add "Early 2008 Core 2 Duo/Penryn" Macbook4,1 match string to the existing touchpad range definition

##Symptoms
* Jerky/Jumpy cursor motion using touchpad
* "Axis value outside expected range" message in Xorg.0.log

##Fix
I followed the instructions described here :https://wayland.freedesktop.org/libinput/doc/latest/absolute_coordinate_ranges.html and came up with the following :

evdev:input:b0003v05ACp022A*
 EVDEV_ABS_00=256:1469:12
 EVDEV_ABS_01=256:829:12

The ranges and resolutions are the same as stated in the existing definition (+/- 2) so only add the match string.
2018-01-05 10:17:17 +10:00
Hans de Goede dd1d57b0d1 hwdb: Add accel mount settings for Asus T200TA 2-in-1 (#7810)
Add accel mount settings for the INVN6500 accelerometer found in
Asus T200TA 2-in-1 devices to 60-sensor.hwdb.
2018-01-04 19:43:27 +01:00
Zbigniew Jędrzejewski-Szmek bbc79ae5c9
Merge pull request #7767 from poettering/fork-wait
A variety of smaller improvements all over the place
2018-01-04 15:25:07 +01:00
Lennart Poettering 9ad45f460f
Merge pull request #7805 from keszybz/coverity-prep
Two small workarounds to help coverity
2018-01-04 15:20:29 +01:00