summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* sd-bus: remove 'hint_sync_call' parameter from various function callsLennart Poettering2018-05-30
| | | | | | 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.
* sd-bus: add API to optionally set a sender field on all outgoing messagesLennart Poettering2018-05-30
| | | | | | | | | | 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.
* verbs: suppress debug log message if SYSTEMD_OFFLINE is not setLennart Poettering2018-05-30
| | | | | 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.
* sd-bus: drop some unused fields from the sd_bus_message structureLennart Poettering2018-05-30
|
* tree-wide: make the Subscribe() method calls asynchronous tooLennart Poettering2018-05-30
|
* sd-bus: accept NULL callbacks in sd_bus_call_async()Lennart Poettering2018-05-30
| | | | | | 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.
* sd-bus: log about bus state changesLennart Poettering2018-05-30
| | | | | Let's unify all state changes in a new helper function, from which we can then debug log all state changes
* networkd,resolved: make use of watch_bind feature to connect to the busLennart Poettering2018-05-30
| | | | | | | | | | 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.
* sd-bus: add new sd_bus_set_connected_signal() APILennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | 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.
* sd-bus: add new sd_bus_is_ready() APILennart Poettering2018-05-30
| | | | | | | | 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.
* sd-bus: modernize how we generate the match string in sd-bus-trackLennart Poettering2018-05-30
| | | | strjoina() FTW!
* sd-bus: drop references to legacy /var/run D-Bus socketLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | 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.
* tree-wide: install matches asynchronouslyLennart Poettering2018-05-30
| | | | | | | | | 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.
* tree-wide: make name requesting asynchronous in all our servicesLennart Poettering2018-05-30
| | | | | This optimizes service startup a bit, and makes it less prone to deadlocks.
* sd-bus: when disconnecting a slot, also reset its memoryLennart Poettering2018-05-30
| | | | | Yes, we aren#t accessing this anymore after, but it's still nicer if this is actually guaranteed.
* sd-bus: add new API sd_bus_match_signal() + sd_bus_match_signal_asnyc()Lennart Poettering2018-05-30
| | | | | | These are convenience helpers that hide the match string logic (which we probably should never have exposed), and instead just takes regular C arguments.
* sd-bus: add asynchronous version of sd_bus_match()Lennart Poettering2018-05-30
| | | | | | | 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.
* sd-bus: when removing a server-side match, do so in "fire and forget" fashionLennart Poettering2018-05-30
| | | | | | | 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.
* sd-bus: remove bus_remove_match_by_string() helper which is unusedLennart Poettering2018-05-30
|
* sd-bus: drop unused parameters from bus_add_match_internal()Lennart Poettering2018-05-30
| | | | | We don't need the match components anymore, since kdbus is gone, hence drop it.
* sd-bus: add APIs to request/release names asynchronouslyLennart Poettering2018-05-30
| | | | | | | | | | | 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.
* bus-control: remove kdbus indirection cruftLennart Poettering2018-05-30
| | | | | | | | | 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
* sd-bus: get rid of kdbus flags cruftLennart Poettering2018-05-30
| | | | | We only need three bits from the old kdbus flags cruft, hence let's make them proper booleans.
* sd-bus: start reply callback timeouts only when the connection is establishedLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | 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...
* sd-bus: optionally, use inotify to wait for bus sockets to appearLennart Poettering2018-05-30
| | | | | | | | | | | 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.
* socket-util: explicitly ensure there's one trailing NUL byte on AF_UNIX ↵Lennart Poettering2018-05-30
| | | | | | | | | | | | | | | | 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.
* socket-util: use parse_ip_port() for parsing IP portsLennart Poettering2018-05-30
| | | | | Let's unify some code here, and also use parse_ip_port() for all our IP port parsing needs in socket_address_parse().
* fs-util: rework touch_file() so that it can touch socket file nodesLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | 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.
* sd-bus: when attached to an sd-event loop, disconnect on processing errorsLennart Poettering2018-05-30
| | | | | | 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.
* sd-bus: propagate handling errors for Hello method reply directlyLennart Poettering2018-05-30
| | | | | | | | | | | | | 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.
* sd-bus: minor coding style fixLennart Poettering2018-05-30
|
* sd-bus: cast some syscall invocations explicitly to (void)Lennart Poettering2018-05-30
| | | | Let's clarify that we knowingly ignore the return values.
* sd-bus: when debug logging about messages, show the same bits of it everywhereLennart Poettering2018-05-30
| | | | Also, include the message signature everywhere.
* io-util: make flush_fd() return how many bytes where flushedLennart Poettering2018-05-30
| | | | | | | | | | | 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.
* update TODOLennart Poettering2018-05-30
|
* fileio: minor tweak to executable_is_script()Lennart Poettering2018-05-30
| | | | | | If read_line() returns ENOBFUS this means the line was overly long. When we use this for checking whether an executable is a script, then this shouldn't be propagated as-is, but simply as "this is not a script".
* fileio: tweak write_string_stream_ts() to write out trailing \n in one go ↵Lennart Poettering2018-05-30
| | | | | | | | | | | | even if buffering is off This tweaks write_string_stream_ts() in one minor way: when stdio buffering has been turned off, let's append the newline we shall append to the buffer we write ourselves so that the kernel only gets one syscall for the result. When buffering is enabled stdio will take care of that anyway. Follow-up for #7750.
* sd-bus: port one use of SO_PEERCRED by getpeercred()Lennart Poettering2018-05-30
|
* sd-bus: let's use mfree() where we canLennart Poettering2018-05-30
|
* sd-bus: use SO_PEERGROUPS when available to identify groups of peerLennart Poettering2018-05-30
|
* socket-util: slight rework of getpeersec()Lennart Poettering2018-05-30
| | | | | | | | | | Let's call getsockopt() in a loop, so that we can deal correctly with the label changing while we are trying to read it. (also, while we are at it, let's make sure that there's always one trailing NUL byte at the end of the buffer, after all SO_PEERSEC has zero documentation, and multiple implementing backends, hence let's better be safe than sorry)
* tree-wide: use {pid,uid,gid}_is_valid() where appropriateLennart Poettering2018-05-30
| | | | | | Also, drop UID/GID validity checks from getpeercred() as the kernel will never pass us invalid UID/GID on userns, but the overflow UID/GID instead. Add a comment about this.
* user-util: minor updates of in_gid()Lennart Poettering2018-05-30
| | | | | Let's use newa() and use the right type for storing sysconf() return values.
* socket-util: add new getpeergroups() callLennart Poettering2018-05-30
| | | | | It's a wrapper around the new SO_PEERGROUPS sockopt, similar in style as getpeersec() and getpeercred().
* process-util: add new FORK_NEW_MOUNTNS flag to safe_fork()Lennart Poettering2018-05-30
| | | | That way we can move one more code location to use safe_fork()
* pager: let's move static variables up, to the rest of themLennart Poettering2018-05-30
| | | | | let's keep static variables together, and before the function definitions.
* pager,agent: insist that we are called from the main threadLennart Poettering2018-05-30
| | | | | | We maintain static process-wide variables in these subsystems without locking, hence let's refuse operation unless we are called from the main thread (which we do anyway) just as a safety precaution.
* tree-wide: make use of wait_for_terminate_and_check() at various placesLennart Poettering2018-05-30
| | | | | | Using wait_for_terminate_and_check() instead of wait_for_terminate() let's us simplify, shorten and unify the return value checking and logging of waitid(). Hence, let's use it all over the place.
* process-spec: add another flag FORK_WAIT to safe_fork()Lennart Poettering2018-05-30
| | | | | | | | | This new flag will cause safe_fork() to wait for the forked off child before returning. This allows us to unify a number of cases where we immediately wait on the forked off child, witout running any code in the parent after the fork, and without direct interest in the precise exit status of the process, except recgonizing EXIT_SUCCESS vs everything else.
* exec-util: drop redundant log message in do_spawn()Lennart Poettering2018-05-30
| | | | safe_fork() logs that anyway, hence no need to do this twice.