summaryrefslogtreecommitdiff
path: root/src/shared/bus-util.h
Commit message (Collapse)AuthorAgeFilesLines
* basic: add RuntimeScope enumLennart Poettering2023-03-101-2/+3
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* manager: add GetMallocInfo() hidden/debug methodLuca Boccassi2023-02-231-0/+3
| | | | | | | | | Return the output of malloc_info() via a file descriptor (in case it gets large on a busy system). Useful to get live data about memory usage when it is not possible to run under a profiler from the get-go. Do not formally register the method, but add a 'hidden' interface so that it cannot be seen by introspection or by looking at the object.
* bus-util: Add bus_log_parse_error_debug()Daan De Meyer2023-02-071-0/+3
|
* shared/bus-util: rename variables to follow newer styleZbigniew Jędrzejewski-Szmek2022-06-091-2/+2
|
* tree-wide: do not print hint about -M if -M is already usedZbigniew Jędrzejewski-Szmek2021-11-041-1/+1
| | | | | | | | (Or when -H is used, since -H and -M are incompatible.) Note that the slightly unusual form with separate boolean variables (hint_vars, hint_addr) instead of e.g. a const char* variable to hold the message, because this way we don't trigger the warning about non-literal format.
* busctl: do not print hint about -M if -M is already usedZbigniew Jędrzejewski-Szmek2021-11-041-1/+1
| | | | (Or when -H is used, since -H and -M are incompatible.)
* shared/bus-util: make bus_log_*_error() functions functionsZbigniew Jędrzejewski-Szmek2021-11-041-16/+2
| | | | | They were defined as macros, but they are a bit too complicated for this, so it's getting unwieldy. We can make them functions without any loss.
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* bus-util: improve logging when we can't connect to the busLennart Poettering2020-12-151-6/+15
| | | | | | | | | | | | | | | | Previously, we'd already have explicit logging for the case where $XDG_RUNTIME_DIR is not set. Let's also add some explicit logging for the EPERM/ACCESS case. Let's also in both cases suggest the --machine=<user>@.host syntax. And while we are at it, let's remove side-effects from the macro. By checking for both the EPERM/EACCES case and the $XDG_RUNTIME_DIR case we will now catch both the cases where people use "su" to issue a "systemctl --user" operation, and those where they (more correctly, but still not good enough) call "su -". Fixes: #17901
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* sd-bus: add custom return code when $XDG_RUNTIME_DIR is not setZbigniew Jędrzejewski-Szmek2020-10-141-5/+11
| | | | | | | We would return ENOENT, which is extremely confusing. Strace is not helpful because no *file* is actually missing. So let's add some logs at debug level and also use a custom return code. Let all user-facing utilities print a custom error message in that case.
* various: treat BUS_ERROR_NO_SUCH_UNIT the same as SD_BUS_ERROR_SERVICE_UNKNOWNZbigniew Jędrzejewski-Szmek2020-08-241-0/+1
| | | | | | | | | | | | | | | | We return BUS_ERROR_NO_SUCH_UNIT a.k.a. org.freedesktop.systemd1.NoSuchUnit in various places. In #16813: Aug 22 06:14:48 core sudo[2769199]: pam_systemd_home(sudo:account): Failed to query user record: Unit dbus-org.freedesktop.home1.service not found. Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.home1.service': Unit dbus-org.freedesktop.home1.service not found. Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activating via systemd: service name='org.freedesktop.home1' unit='dbus-org.freedesktop.home1.service' requested by ':1.6564' (uid=0 pid=2769199 comm="sudo su ") This particular error comes from bus_unit_validate_load_state() in pid1: case UNIT_NOT_FOUND: return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not found.", u->id); It seems possible that we should return a different error, but it doesn't really matter: if we change pid1 to return a different error, we still need to handle BUS_ERROR_NO_SUCH_UNIT as in this patch to handle pid1 with current code.
* bus: use bus_log_connect_error to print error messagefangxiuning2020-07-211-0/+3
|
* shared: split out property get helpersLennart Poettering2020-06-301-95/+0
| | | | No code changes, just some refactoring.
* shared: split out code for printing propertiesLennart Poettering2020-06-301-8/+0
| | | | No code changes, just some refactoring.
* shared: split out code that maps properties to local structsLennart Poettering2020-06-301-20/+0
| | | | Just some refactoring, no code changes.
* shared: actually move all BusLocator related calls to bus-locator.cLennart Poettering2020-06-301-16/+0
|
* shared: split out BusObjectImplementor APIsLennart Poettering2020-06-301-26/+0
| | | | Just some refactoring, no code changes
* bus: introduce bus-locator.[ch]Vito Caputo2020-05-071-6/+1
| | | | | Move BusLocator into its own header, introduce collection of locators for use throughout the code.
* bus-util: add wrapper for interface introspectionZbigniew Jędrzejewski-Szmek2020-05-051-0/+4
|
* sd-bus: add helper struct for interface definitionsZbigniew Jędrzejewski-Szmek2020-05-051-3/+26
| | | | | | The idea is to have a static table that defines the dbus API. The vtable is defined right next to the interface name and path because they are logically connected.
* bus: add sd_bus_message_new_method_call() helperVito Caputo2020-04-101-0/+1
| | | | adds BusLocator variant called bus_message_new_method_call()
* bus: s/BusAddress/BusLocator/Vito Caputo2020-04-101-11/+11
| | | | | Mechanical rename in response to https://github.com/systemd/systemd/pull/15331#issuecomment-611472240
* bus: introduce some sd-bus convenience helpersVito Caputo2020-04-041-0/+19
| | | | | | | | | | | | | | | | | | Many of the convenience functions from sd-bus operate on verbose sets of discrete strings for destination/path/interface/member. For most callers, destination/path/interface are uniform, and just the member is distinct. This commit introduces a new struct encapsulating the destination/path/interface pointers called BusAddress, and wrapper functions which take a BusAddress* instead of three strings, and just pass the encapsulated strings on to the sd-bus convenience functions. Future commits will update call sites to use these helpers throwing out a bunch of repetitious destination/path/interface strings littered throughout the codebase, replacing them with some appropriately named static structs passed by pointer to these new helpers.
* shared: split out polkit stuff from bus-util.c → bus-polkit.cLennart Poettering2020-01-221-6/+1
| | | | | | It's enough, complex stuff to warrant its own source file. No other changes, just splitting out.
* bus-util: convert bus_log_{parse,create}_error into definesZbigniew Jędrzejewski-Szmek2019-07-291-2/+5
| | | | | | | With SYSTEMD_LOG_LOCATION=1, it is much more useful to see the location where the call to bus_log_{parse,create}_error() was made, rather then the one-line body of the helper function. Also, it's our internal code, so having a one-line non-inline function doesn't make much sense anyway.
* logind: add SetBrightness() bus call for setting brightness of ↵Lennart Poettering2019-05-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | leds/backlight devices associated with a seat This augments the drm/input device management by adding a single method call for setting the brightness of an "leds" or "backlight" kernel class device. This method call requires no privileges to call, but a caller can only change the brightness on sessions that are currently active, and they must own the session. This does not do enumeration of such class devices, feature or range probing, chnage notification; it doesn't help associating graphics or input devices with their backlight or leds devices. For all that clients should go directly to udev/sysfs. The SetBrightness() call is just for executing the actual change operation, that is otherwise privileged. Example line: busctl call org.freedesktop.login1 /org/freedesktop/login1/session/self org.freedesktop.login1.Session SetBrightness ssu "backlight" "intel_backlight" 200 The parameter the SetBrightness() call takes are the kernel subsystem (i.e. "leds" or "backlight"), the device name, and the brightness value. On some hw setting the brightness is slow, and implementation and write access to the sysfs knobs exposes this slowness. Due to this we'll fork off a writer process in the background so that logind doesn't have to block. Moreover, write requestes are coalesced: when a write request is enqueued while one is already being executed it is queued. When another write reques is then enqueued the earlier one is replaced by the newer one, so that only one queued write request per device remains at any time. Method replies are sent as soon as the first write request that happens after the request was received is completed. It is recommended that bus clients turn off the "expect_reply" flag on the dbus messages they send though, that relieves logind from sending completion notification and is particularly a good idea if clients implement reactive UI sliders that send a quick secession of write requests. Replaces: #12413
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+1
| | | | | 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.
* bus-util: drop unnecessary re-formattingYu Watanabe2019-03-041-1/+2
|
* tree-wide: remove various unused functionsLennart Poettering2018-12-021-1/+0
| | | | All found with "cppcheck --enable=unusedFunction".
* bus-util: drop now-unused functionsZbigniew Jędrzejewski-Szmek2018-09-201-2/+0
|
* bus-util: use _printf_ attributeYu Watanabe2018-09-151-1/+1
| | | | | | Follow-up for eda193578effbc3cee0f6d56ade52434778737c9. Fixes oss-fuzz#10350.
* bus-util: make --property= optionally take valueYu Watanabe2018-09-121-2/+2
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-4/+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: unify how we define bit mak enumsLennart Poettering2018-06-121-2/+2
| | | | | | Let's always write "1 << 0", "1 << 1" and so on, except where we need more than 31 flag bits, where we write "UINT64(1) << 0", and so on to force 64bit values.
* machined: move bus_reply_pair_array() into generic utilitiesLennart Poettering2018-05-241-0/+2
| | | | This way, we can reuse it in portabled.
* timesync,shared: move logic requesting bus name to sharedYu Watanabe2018-05-221-0/+2
| | | | | Preparation for setting DynamicUser= to other services which request bus names.
* bus-util: add more macros for defining functions of getting dbus propertiesYu Watanabe2018-05-151-25/+6
|
* bus-util: add several macros for defining functions of getting dbus propertiesYu Watanabe2018-05-131-0/+38
|
* bus-util: introduce bus_open_system_watch_bind_with_description()Yu Watanabe2018-04-171-1/+4
| | | | | | Similar to 56fbd7187a5af44a90c258fbeb1f17114f226bb3, this adds bus_open_system_watch_bind_with_description() to set description for busses.
* 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.
* bus-util: fix a meaningless assertionYu Watanabe2018-04-051-1/+1
|
* bus-util: add flags for bus_map_all_properties() (#8546)Yu Watanabe2018-03-281-3/+9
| | | | | | | | | This adds flags BUS_MAP_STRDUP and BUS_MAP_BOOLEAN_AS_BOOL. If BUS_MAP_STRDUP is set, then each "s" message is duplicated. If BUS_MAP_BOOLEAN_AS_BOOL is set, then each "b" message is written to a bool pointer. Follow-up for #8488. See https://github.com/systemd/systemd/pull/8488#discussion_r175816270.
* bus-util: introduce bus_message_print_all_properties()Yu Watanabe2018-03-201-1/+4
| | | | Then, use it where applicable.
* bus-util: make bus_map_all_properties() not copy stringYu Watanabe2018-03-201-3/+3
|
* core: drop unnecessary __useless_struct_to_allow_trailing_semicolon__Zbigniew Jędrzejewski-Szmek2018-03-061-2/+1
| | | | | | | | | | | | | | ISO C does not allow empty statements outside of functions, and gcc will warn the trailing semicolons when compiling with -pedantic: warning: ISO C does not allow extra ‘;’ outside of a function [-Wpedantic] But our code cannot compile with -pedantic anyway, at least because warning: ISO C does not support ‘__PRETTY_FUNCTION__’ predefined identifier [-Wpedantic] Without -pedatnic, clang and even old gcc (3.4) generate no warnings about those semicolons, so let's just drop __useless_struct_to_allow_trailing_semicolon__.
* bus-util: add bool property setterJan Klötzke2018-01-221-0/+1
|
* networkd,resolved: make use of watch_bind feature to connect to the busLennart Poettering2018-01-051-0/+2
| | | | | | | | | | 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.
* 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.