summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-convenience.c
Commit message (Collapse)AuthorAgeFilesLines
* sd-bus: Add sd_bus_reply()Daan De Meyer2021-01-251-2/+2
| | | | | | | | | | While sd-bus already provides sd_bus_call() for calling a method from a complete bus message object, We don't have an equivalent function for replying from a method with a complete bus message object. Currently, we use sd_bus_send(call->bus, m, NULL) instead. Let's add a shorthand for this pattern and name it sd_bus_reply().
* test: drop bus-util.h from sd-busYu Watanabe2021-01-191-1/+0
| | | | To drop src/shared from include directories to build libsystemd.so later.
* sd-bus: 'ret' parameter to sd_bus_query_sender_creds() is not optional, ↵Lennart Poettering2020-12-151-0/+1
| | | | check for it
* sd-bus: make credential acquisition more gracefulLennart Poettering2020-12-151-5/+13
| | | | | | | | | | | | | | | | | | | So far when asked for augmented bus credentials and the process was already gone we'd fail fatally. Let's make this graceful instead, and never allow augmenting fail due to PID having vanished — unless the augmenting is the explicit and only purpose of the requested operation. This should be safe as clients have to explicitly query the acquired creds anyway and handle if they couldn't be acquired. Moreover we already handle permission problems gracefully, thus clients must be ready to deal with missing creds. This is useful to make selinux authorization work for short-lived client proceses. PReviously we'd augment creds to have more info to log about (the selinux decision would not be based on augmented data however, because that'd be unsafe), and would fail if we couldn't get it. Now, we'll try to acquire the data, but if we cannot acquire it, we'll still do the selinux check, except that logging will be more limited.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* sd-bus: add va_list variants of variadic convenience functionsVito Caputo2020-04-021-39/+137
| | | | | | | | | | | | Consumers of the sd-bus convenience API can't make convenience helpers of their own without va_list variants. This commit is a mechanical change splitting out the existing function bodies into bare va_list variants having a 'v' suffixed to the names. The original functions now simply create the va_list before forwarding the call on to the va_list variant, and the va_list variants dispense with those steps.
* sd-bus: whitespace adjustmentsZbigniew Jędrzejewski-Szmek2020-03-191-1/+4
|
* sd-bus: make sure SD_BUS_DEFAULT* works everywhereZbigniew Jędrzejewski-Szmek2020-03-191-0/+6
| | | | | | I'm not sure why those functions were not touched in 45b1f410ba699990e4033805fe64cc369b835f10. Anyway, it seems easier to just support the magic parameters everywhere.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+3
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* tree-wide: drop empty commentsYu Watanabe2018-06-291-2/+0
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | 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.
* Add support for SD_BUS_DEFAULT*Nathaniel McCallum2018-01-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | 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.
* sd-bus: add new API sd_bus_match_signal() + sd_bus_match_signal_asnyc()Lennart Poettering2018-01-051-0/+66
| | | | | | These are convenience helpers that hide the match string logic (which we probably should never have exposed), and instead just takes regular C arguments.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* Drop kdbus bitsZbigniew Jędrzejewski-Szmek2017-07-231-13/+3
| | | | | | | | | Some kdbus_flag and memfd related parts are left behind, because they are entangled with the "legacy" dbus support. test-bus-benchmark is switched to "manual". It was already broken before (in the non-kdbus mode) but apparently nobody noticed. Hopefully it can be fixed later.
* Export sd_bus_message_append_ap. It is renamed to sd_bus_message_appendv to ↵Federico2017-04-251-5/+5
| | | | | | follow systemd naming conventions. (#5753) Moreover, man page for sd_bus_message_append is updated with reference to new exposed function. Makefile-man is updated too, to reflect new alias.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-1/+2
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* Revert "sd-bus: do not connect to dbus-1 socket when kdbus is available"David Herrmann2015-08-271-0/+1
| | | | | | | | This reverts commit d4d00020d6ad855d65d31020fefa5003e1bb477f. The idea of the commit is broken and needs to be reworked. We really cannot reduce the bus-addresses to a single address. We always will have systemd with native clients and legacy clients at the same time, so we also need both addresses at the same time.
* sd-bus: always fill in sd_bus_error paramters, on errorLennart Poettering2015-08-161-57/+89
| | | | | | | | | | | | | | | Whenever one of our calls is invoked with a non-NULL, writable sd_bus_error parameter, let's fill in some valid error on failure. We previously only filled in remote errors, but never local errors, which is hard to handle by users. Hence, let's clean this up to always fill in the error. This introduces a new bus_assert_return() macro that works like assert_return() but optionally also initializes a bus_error struct. Fixes #224. Based on a patch by Umut Tezduyar.
* sd-bus: do not connect to dbus-1 socket when kdbus is availableKay Sievers2015-08-111-1/+0
| | | | | | | | | | | | We should not fall back to dbus-1 and connect to the proxy when kdbus returns an error that indicates that kdbus is running but just does not accept new connections because of quota limits or something similar. Using is_kdbus_available() in libsystemd/ requires it to move from shared/ to libsystemd/. Based on a patch from David Herrmann: https://github.com/systemd/systemd/pull/886
* sd-bus: add async convenience method call APIUmut Tezduyar Lindskog2015-06-091-0/+37
|
* sd-bus: when augmenting creds, remember which ones were augmentedLennart Poettering2015-04-211-0/+15
| | | | | Also, when we do permissions checks using creds, verify that we don't do so based on augmented creds, as extra safety check.
* sd-bus: add more comments to the credential decision logicLennart Poettering2015-04-161-1/+12
|
* sd-bus: export sd_bus_error_set_errnofv()Lennart Poettering2015-02-131-1/+1
|
* sd-bus: update to current kernel version, by splitting off the extended ↵Lennart Poettering2014-11-251-10/+15
| | | | | | | | | | | | | | | | | | | | | | KDBUS_ITEM_PIDS structure from KDBUS_ITEM_CREDS Also: - adds support for euid, suid, fsuid, egid, sgid, fsgid fields. - makes augmentation of creds with data from /proc explicitly controllable to give apps better control over this, given that this is racy. - enables augmentation for kdbus connections (previously we only did it for dbus1). This is useful since with recent kdbus versions it is possible for clients to control the metadata they want to send. - changes sd_bus_query_sender_privilege() to take the euid of the client into consideration, if known - when we don't have permissions to read augmentation data from /proc, don't fail, just don't add the data in
* sd-bus: rename sd_bus_get_owner_uid(), sd_bus_get_owner_machine_id() and ↵Daniel Mack2014-10-221-2/+2
| | | | | | | | | | sd_bus_get_peer_creds() Clean up the function namespace by renaming the following: sd_bus_get_owner_uid() → sd_bus_get_name_creds_uid() sd_bus_get_owner_machine_id() → sd_bus_get_name_machine_id() sd_bus_get_peer_creds() → sd_bus_get_owner_creds()
* sd-bus: add API to check if a client has privilegesLennart Poettering2014-08-151-0/+53
| | | | | | | | | | | | | This is a generalization of the vtable privilege check we already have, but exported, and hence useful when preparing for a polkit change. This will deal with the complexity that on dbus1 one cannot trust the capability field we retrieve via the bus, since it is read via /proc/$$/stat (and thus might be out-of-date) rather than directly from the message (like on kdbus) or bus connection (as for uid creds on dbus1). Also, port over all code to this new API.
* sd-bus: don't use assert_return() to check for disconnected bus connectionsLennart Poettering2014-03-191-13/+45
| | | | | A terminated connection is a runtime error and not a developer mistake, hence don't use assert_return() to check for it.
* api: in constructor function calls, always put the returned object pointer ↵Lennart Poettering2014-02-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | first (or second) Previously the returned object of constructor functions where sometimes returned as last, sometimes as first and sometimes as second parameter. Let's clean this up a bit. Here are the new rules: 1. The object the new object is derived from is put first, if there is any 2. The object we are creating will be returned in the next arguments 3. This is followed by any additional arguments Rationale: For functions that operate on an object we always put that object first. Constructors should probably not be too different in this regard. Also, if the additional parameters might want to use varargs which suggests to put them last. Note that this new scheme only applies to constructor functions, not to all other functions. We do give a lot of freedom for those. Note that this commit only changes the order of the new functions we added, for old ones we accept the wrong order and leave it like that.
* libsystemd: split up into subdirsTom Gundersen2014-01-211-0/+442
We still only produce on .so, but let's keep the sources separate to make things a bit less messy.