summaryrefslogtreecommitdiff
path: root/src/libelogind/sd-bus
Commit message (Collapse)AuthorAge
...
* bus-message: use streq_ptr() (#8786)Yu Watanabe2018-08-24
|
* timedate: move error mapping to bus-common-errors.[ch]Yu Watanabe2018-08-24
|
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-08-24
| | | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* sd-bus: allow description to be set for system/user busses (#8594)Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | sd_bus_open/sd_bus_open_system/sd_bus_open_user are convenient, but don't allow the description to be set. After they return, the bus is is already started, and sd_bus_set_description() fails with -EBUSY. It would be possible to allow sd_bus_set_description() to update the description "live", but messages are already emitted from sd_bus_open functions, so it's better to allow the description to be set in sd_bus_open/sd_bus_open_system/sd_bus_open_user. Fixes message like: Bus n/a: changing state UNSET → OPENING
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* sd-bus: allow description to be set for system/user busses (#8594)Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | sd_bus_open/sd_bus_open_system/sd_bus_open_user are convenient, but don't allow the description to be set. After they return, the bus is is already started, and sd_bus_set_description() fails with -EBUSY. It would be possible to allow sd_bus_set_description() to update the description "live", but messages are already emitted from sd_bus_open functions, so it's better to allow the description to be set in sd_bus_open/sd_bus_open_system/sd_bus_open_user. Fixes message like: Bus n/a: changing state UNSET → OPENING
* macro: introduce TAKE_PTR() macroLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* sd-bus: drop fd_nonblock() calls that are implied by rearrange_stdio() (#8514)Lennart Poettering2018-06-28
| | | | (cherry picked from commit 68b525d1d1e8153cbc2e2354fa650aa165f7a434)
* sd-bus: do not try to close already closed fd (#8392)Yu Watanabe2018-06-28
| | | | | | Fixes #8376, which is introduced by 2b33ab0957f453a06b58e4bee482f2c2d4e100c1. (cherry picked from commit 280029d18f470a64403d68717eef1be5274ff8af)
* Prep v238: Uncomment now needed headers and unmask now needed functions in ↵Sven Eden2018-06-05
| | | | src/libelogind (3/6)
* Prep v238: Remove obsolete sources and add missing new ones.Sven Eden2018-06-05
|
* Prep v238: Applied some upstream updates to src/libelogind (5/5)Sven Eden2018-06-04
|
* sd-bus: let's better not invade stdio territory when duplicating fdsLennart Poettering2018-05-30
|
* tree-wide: port various places over to use new rearrange_stdio()Lennart Poettering2018-05-30
|
* coccinelle: add reallocarray() coccinelle scriptLennart Poettering2018-05-30
| | | | | Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
* sd-bus: add APIs to query the current read and write queue sizeLennart Poettering2018-05-30
|
* tree-wide: use reallocarray instead of our home-grown realloc_multiply (#8279)Zbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | | There isn't much difference, but in general we prefer to use the standard functions. glibc provides reallocarray since version 2.26. I moved explicit_bzero is configure test to the bottom, so that the two stdlib functions are at the bottom.
* sd-bus: synthesize a description for user/system bus if otherwise unsetLennart Poettering2018-05-30
| | | | | Let's make debugging easier, by synthesizing a name when we have some indication what kind of bus this is.
* fd-util: move certain fds above fd #2 (#8129)Lennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds some paranoia code that moves some of the fds we allocate for longer periods of times to fds > 2 if they are allocated below this boundary. This is a paranoid safety thing, in order to avoid that external code might end up erroneously use our fds under the assumption they were valid stdin/stdout/stderr. Think: some app closes stdin/stdout/stderr and then invokes 'fprintf(stderr, …' which causes writes on our fds. This both adds the helper to do the moving as well as ports over a number of users to this new logic. Since we don't want to litter all our code with invocations of this I tried to strictly focus on fds we keep open for long periods of times only and only in code that is frequently loaded into foreign programs (under the assumptions that in our own codebase we are smart enough to always keep stdin/stdout/stderr allocated to avoid this pitfall). Specifically this means all code used by NSS and our sd-xyz API: 1. our logging APIs 2. sd-event 3. sd-bus 4. sd-resolve 5. sd-netlink This changed was inspired by this: https://github.com/systemd/systemd/issues/8075#issuecomment-363689755 This shows that apparently IRL there are programs that do close stdin/stdout/stderr, and we should accomodate for that. Note that this won't fix any bugs, this just makes sure that buggy programs are less likely to interfere with out own code.
* sd-bus: cleanup ssh sessions (Closes: #8076)Shawn Landden2018-05-30
| | | | | | | | | | | | | | | | | | | we still invoke ssh unnecessarily when there in incompatible or erreneous input The fallow-up to finish that would make the code a bit more verbose, as it would require repeating this bit: ``` r = bus_connect_transport(arg_transport, arg_host, false, &bus); if (r < 0) { log_error_errno(r, "Failed to create bus connection: %m"); goto finish; } sd_bus_set_allow_interactive_authorization(bus, arg_ask_password); ``` in every verb, after parsing. v2: add waitpid() to avoid a zombie process, switch to SIGTERM from SIGKILL v3: refactor, wait in bus_start_address()
* sd-bus: explicitly convert int to boolYu Watanabe2018-05-30
|
* sd-bus: use free_and_replace()Yu Watanabe2018-05-30
|
* sd-bus: avoid potential memory leaksYu Watanabe2018-05-30
|
* sd-bus: cleanup ssh sessions (Closes: #8076)Shawn Landden2018-05-30
| | | | | | | | | | | | | | | | | | | | we still invoke ssh unnecessarily when there in incompatible or erreneous input The fallow-up to finish that would make the code a bit more verbose, as it would require repeating this bit: ``` r = bus_connect_transport(arg_transport, arg_host, false, &bus); if (r < 0) { log_error_errno(r, "Failed to create bus connection: %m"); goto finish; } sd_bus_set_allow_interactive_authorization(bus, arg_ask_password); ``` in every verb, after parsing. v2: add waitpid() to avoid a zombie process, switch to SIGTERM from SIGKILL v3: refactor, wait in bus_start_address() (cherry picked from commit 392cf1d05dbfa1395f6d99102e5ea41debb58fec)
* sd-bus: avoid potential memory leaksYu Watanabe2018-05-30
| | | | (cherry picked from commit b4ca3f45dc5742ad76e8feebd363c490f92b804f)
* Add support for SD_BUS_DEFAULT*Nathaniel McCallum2018-05-30
| | | | | | | | | | | | | | | | | | | | | | Currently, sd-bus supports the ability to have thread-local default busses. However, this is less useful than it can be since all functions which require an sd_bus* as input require the caller to pass it. This patch adds a new macro which allows the developer to pass a constant SD_BUS_DEFAULT, SD_BUS_DEFAULT_USER or SD_BUS_DEFAULT_SYSTEM instead. This reduces work for the caller. For example: r = sd_bus_default(&bus); r = sd_bus_call_method(bus, ...); sd_bus_unref(bus); Becomes: r = sd_bus_call_method(SD_BUS_DEFAULT, ...); If the specified thread-local default bus does not exist, the function calls will return -ENOPKG. No bus will ever be implicitly created.
* bus-message: avoid -Wnull-pointer-arithmetic warning on new clangZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | We just need some pointer, so use alignment directly converted to the right type.
* log: minimize includes in log.hLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | log.h really should only include the bare minimum of other headers, as it is really pulled into pretty much everything else and already in itself one of the most basic pieces of code we have. Let's hence drop inclusion of: 1. sd-id128.h because it's entirely unneeded in current log.h 2. errno.h, dito. 3. sys/signalfd.h which we can replace by a simple struct forward declaration 4. process-util.h which was needed for getpid_cached() which we now hide in a funciton log_emergency_level() instead, which nicely abstracts the details away. 5. sys/socket.h which was needed for struct iovec, but a simple struct forward declaration suffices for that too. Ultimately this actually makes our source tree larger (since users of the functionality above must now include it themselves, log.h won't do that for them), but I think it helps to untangle our web of includes a tiny bit. (Background: I'd like to isolate the generic bits of src/basic/ enough so that we can do a git submodule import into casync for it)
* sd-bus: drop bloom stuff, it's not needed anymore since kdbus is goneLennart Poettering2018-05-30
|
* bus-socket: slight simplification in bus_get_peercred()Zbigniew Jędrzejewski-Szmek2018-05-30
|
* 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.
* sd-bus: drop some unused fields from the sd_bus_message structureLennart 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
* 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.
* 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