summaryrefslogtreecommitdiff
path: root/src/shared/bus-util.c
AgeCommit message (Collapse)AuthorFilesLines
2023-01-31shared: split out polkit stuff from bus-util.c → bus-polkit.cLennart Poettering1-356/+6
It's enough, complex stuff to warrant its own source file. No other changes, just splitting out. (Resolve build error from cherry-pick) In bus-util.c, leave fd-util.h and proc-cmdline.h for code preprocessed by ENABLE_KDBUS macro. +#if ENABLE_KDBUS +#include "fd-util.h" +#include "proc-cmdline.h" +#endif Origin: upstream, https://github.com/systemd/systemd/commit/269e4d2d6b75329ae39a71ebe2c14500e03cda95 Change-Id: I9cc9f51f614bf5f8059422cc1923aa88a5812560 Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
2020-04-02Merge v244 into tizenAdrian Szyndela1-6/+4
systemd v244
2020-03-27Merge v243 into tizenAdrian Szyndela1-18/+18
systemd v243
2020-03-27Merge v242 into tizenAdrian Szyndela1-23/+39
systemd v242
2020-03-27Merge v241 into tizensandbox/adrians/upgrade-to-241Adrian Szyndela1-4/+4
systemd 241
2020-03-26Merge v240 into tizenAdrian Szyndela1-245/+79
systemd 240
2020-03-26Merge v239 into tizenAdrian Szyndela1-98/+347
systemd 239
2020-02-26Merge v237 into tizenAdrian Szyndela1-24/+88
systemd 237
2020-02-26Merge v236 into tizensandbox/adrians/upgrade-to-236Adrian Szyndela1-7/+3
Change-Id: Id62f08b8ecf2a909a49e5f93b2f7594b3880ef44
2020-02-26Revert "Drop kdbus bits"Adrian Szyndela1-2/+42
This reverts commit a132bef0239e6c3f04096eee3a00c7ecf24a4f5c. There are people somewhere that need kdbus. Change-Id: I5a1f09485c524d47ef8ae53712d5fb77949bc7fa
2020-02-26Merge v235 into tizenAdrian Szyndela1-54/+60
Change-Id: Iafcca23df73f2694eda50a97771acac4b7996f30
2020-02-26Merge v234 into tizenAdrian Szyndela1-67/+116
Change-Id: If676fe909a40eadc60ee5ff023abe4ee2c64b44e
2019-11-15core: do not propagate polkit error to callerZbigniew Jędrzejewski-Szmek1-2/+2
If we fail to start polkit, we get a message like "org.freedesktop.DBus.Error.NameHasNoOwner: Could not activate remote peer.", which has no meaning for the caller of our StartUnit method. Let's just return -EACCES. $ systemctl start apache Failed to start apache.service: Could not activate remote peer. (before) Failed to start apache.service: Access denied (after) Fixes #13865.
2019-11-04tree-wide: drop stdio.h when stdio-util.h is includedYu Watanabe1-1/+0
2019-11-04tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe1-1/+0
2019-10-31tree-wide: drop missing.hYu Watanabe1-1/+0
2019-10-15bus-util: make map_basic handle SD_BUS_TYPE_OBJECT_PATH typeYu Watanabe1-1/+2
2019-08-27sd-bus: adjust indentation of commentsZbigniew Jędrzejewski-Szmek1-3/+4
2019-08-27shared/but-util: drop trusted annotation from ↵Zbigniew Jędrzejewski-Szmek1-4/+0
bus_open_system_watch_bind_with_description() https://bugzilla.redhat.com/show_bug.cgi?id=1746057 This only affects systemd-resolved. bus_open_system_watch_bind_with_description() is also used in timesyncd, but it has no methods, only read-only properties, and in networkd, but it annotates all methods with SD_BUS_VTABLE_UNPRIVILEGED and does polkit checks.
2019-07-29bus-util: convert bus_log_{parse,create}_error into definesZbigniew Jędrzejewski-Szmek1-8/+0
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.
2019-07-12tree-wide: get rid of strappend()Lennart Poettering1-1/+1
It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
2019-06-21tree-wide: replace strjoin() with path_join()Yu Watanabe1-1/+2
2019-05-24logind: add SetBrightness() bus call for setting brightness of ↵Lennart Poettering1-0/+10
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
2019-05-08cgroup: Readd some plumbing for DefaultMemoryMinChris Down1-1/+1
Somehow these got lost in the previous PR, rendering DefaultMemoryMin not very useful.
2019-04-12cgroup: Implement default propagation of MemoryLow with DefaultMemoryLowChris Down1-1/+1
In cgroup v2 we have protection tunables -- currently MemoryLow and MemoryMin (there will be more in future for other resources, too). The design of these protection tunables requires not only intermediate cgroups to propagate protections, but also the units at the leaf of that resource's operation to accept it (by setting MemoryLow or MemoryMin). This makes sense from an low-level API design perspective, but it's a good idea to also have a higher-level abstraction that can, by default, propagate these resources to children recursively. In this patch, this happens by having descendants set memory.low to N if their ancestor has DefaultMemoryLow=N -- assuming they don't set a separate MemoryLow value. Any affected unit can opt out of this propagation by manually setting `MemoryLow` to some value in its unit configuration. A unit can also stop further propagation by setting `DefaultMemoryLow=` with no argument. This removes further propagation in the subtree, but has no effect on the unit itself (for that, use `MemoryLow=0`). Our use case in production is simplifying the configuration of machines which heavily rely on memory protection tunables, but currently require tweaking a huge number of unit files to make that a reality. This directive makes that significantly less fragile, and decreases the risk of misconfiguration. After this patch is merged, I will implement DefaultMemoryMin= using the same principles.
2019-04-04bus-util: treat org.freedesktop.DBus.Error.ServiceUnknown nicely when polkit ↵Yu Watanabe1-2/+2
does not exist Fixes #12209.
2019-04-02util-lib: use FLAGS_SET() where appropriateLennart Poettering1-1/+1
2019-03-04systemctl: format IPIngressBytes= or friends nicelyYu Watanabe1-0/+2
2019-03-04bus-util: drop unnecessary re-formattingYu Watanabe1-20/+34
2019-01-17tree-wide: whenever we allocate a new bus object, close it before dropping ↵Lennart Poettering1-4/+4
final ref This doesn't really change much, but feels more correct to do, as it ensures that all messages currently queued in the bus connections are definitely unreffed and thus destryoing of the connection object will follow immediately. Strictly speaking this change is entirely unnecessary, since nothing else could have acquired a ref to the connection and queued a message in, however, now that we have the new sd_bus_close_unref() helper it makes a lot of sense to use it here, to ensure that whatever happens nothing that might have been queued fucks with us.
2018-12-02tree-wide: remove various unused functionsLennart Poettering1-38/+0
All found with "cppcheck --enable=unusedFunction".
2018-11-29Split out part of mount-util.c into mountpoint-util.cZbigniew Jędrzejewski-Szmek1-1/+1
The idea is that anything which is related to actually manipulating mounts is in mount-util.c, but functions for mountpoint introspection are moved to the new file. Anything which requires libmount must be in mount-util.c. This was supposed to be a preparation for further changes, with no functional difference, but it results in a significant change in linkage: $ ldd build/libnss_*.so.2 (before) build/libnss_myhostname.so.2: linux-vdso.so.1 (0x00007fff77bf5000) librt.so.1 => /lib64/librt.so.1 (0x00007f4bbb7b2000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f4bbb755000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4bbb734000) libc.so.6 => /lib64/libc.so.6 (0x00007f4bbb56e000) /lib64/ld-linux-x86-64.so.2 (0x00007f4bbb8c1000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f4bbb51b000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f4bbb512000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4bbb4e3000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f4bbb45e000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f4bbb458000) build/libnss_mymachines.so.2: linux-vdso.so.1 (0x00007ffc19cc0000) librt.so.1 => /lib64/librt.so.1 (0x00007fdecb74b000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fdecb744000) libmount.so.1 => /lib64/libmount.so.1 (0x00007fdecb6e7000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdecb6c6000) libc.so.6 => /lib64/libc.so.6 (0x00007fdecb500000) /lib64/ld-linux-x86-64.so.2 (0x00007fdecb8a9000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fdecb4ad000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fdecb4a2000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fdecb475000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fdecb3f0000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fdecb3ea000) build/libnss_resolve.so.2: linux-vdso.so.1 (0x00007ffe8ef8e000) librt.so.1 => /lib64/librt.so.1 (0x00007fcf314bd000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fcf314b6000) libmount.so.1 => /lib64/libmount.so.1 (0x00007fcf31459000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcf31438000) libc.so.6 => /lib64/libc.so.6 (0x00007fcf31272000) /lib64/ld-linux-x86-64.so.2 (0x00007fcf31615000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fcf3121f000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fcf31214000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcf311e7000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fcf31162000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fcf3115c000) build/libnss_systemd.so.2: linux-vdso.so.1 (0x00007ffda6d17000) librt.so.1 => /lib64/librt.so.1 (0x00007f610b83c000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f610b835000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f610b7d8000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f610b7b7000) libc.so.6 => /lib64/libc.so.6 (0x00007f610b5f1000) /lib64/ld-linux-x86-64.so.2 (0x00007f610b995000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f610b59e000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f610b593000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f610b566000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f610b4e1000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f610b4db000) (after) build/libnss_myhostname.so.2: linux-vdso.so.1 (0x00007fff0b5e2000) librt.so.1 => /lib64/librt.so.1 (0x00007fde0c328000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fde0c307000) libc.so.6 => /lib64/libc.so.6 (0x00007fde0c141000) /lib64/ld-linux-x86-64.so.2 (0x00007fde0c435000) build/libnss_mymachines.so.2: linux-vdso.so.1 (0x00007ffdc30a7000) librt.so.1 => /lib64/librt.so.1 (0x00007f06ecabb000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f06ecab4000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f06eca93000) libc.so.6 => /lib64/libc.so.6 (0x00007f06ec8cd000) /lib64/ld-linux-x86-64.so.2 (0x00007f06ecc15000) build/libnss_resolve.so.2: linux-vdso.so.1 (0x00007ffe95747000) librt.so.1 => /lib64/librt.so.1 (0x00007fa56a80f000) libcap.so.2 => /lib64/libcap.so.2 (0x00007fa56a808000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa56a7e7000) libc.so.6 => /lib64/libc.so.6 (0x00007fa56a621000) /lib64/ld-linux-x86-64.so.2 (0x00007fa56a964000) build/libnss_systemd.so.2: linux-vdso.so.1 (0x00007ffe67b51000) librt.so.1 => /lib64/librt.so.1 (0x00007ffb32113000) libcap.so.2 => /lib64/libcap.so.2 (0x00007ffb3210c000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffb320eb000) libc.so.6 => /lib64/libc.so.6 (0x00007ffb31f25000) /lib64/ld-linux-x86-64.so.2 (0x00007ffb3226a000) I don't quite understand what is going on here, but let's not be too picky.
2018-11-22coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek1-5/+3
Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
2018-10-19tree-wide: replace 'unsigned int' with 'unsigned'Yu Watanabe1-2/+2
2018-09-20bus-util: drop now-unused functionsZbigniew Jędrzejewski-Szmek1-162/+0
2018-09-12bus-util: make --property= optionally take valueYu Watanabe1-35/+72
2018-06-29bus-util: update commentYu Watanabe1-5/+4
Originally, request_name_handler_may_reload_dbus() was written for timesyncd. But now it is also called by networkd or resolved.
2018-06-29bus-util: drop unnecessary !!Yu Watanabe1-1/+1
2018-06-27bus-util: make log level lower in request_name_destroy_callback()Yu Watanabe1-1/+1
Fixes #9442.
2018-06-25bus-util: fix error handlingYu Watanabe1-1/+1
2018-06-14tree-wide: remove Lennart's copyright linesLennart Poettering1-3/+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.
2018-06-14tree-wide: drop 'This file is part of systemd' blurbLennart Poettering1-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.
2018-06-14timedatectl: add 'show' command to display machine-readable outputYu Watanabe1-1/+2
Closes #9249.
2018-06-13tree-wide: drop !! casts to booleansZbigniew Jędrzejewski-Szmek1-3/+3
They are not needed, because anything that is non-zero is converted to true. C11: > 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the > value compares equal to 0; otherwise, the result is 1. https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
2018-06-06shared/bus-util: use the new cleanup functionality to avoid a memleakZbigniew Jędrzejewski-Szmek1-11/+51
If the async callbacks didn't get a chance to finish properly, we'd leak memory. The output from test-bus-util with additional log line in the callbacks to show what is happening: $ build/test-bus-util /* test_name_async (0) */ Bus test-bus: changing state UNSET → OPENING Bus test-bus: changing state OPENING → AUTHENTICATING Bus test-bus: changing state AUTHENTICATING → HELLO Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=2 reply_cookie=0 signature=su error-name=n/a error-message=n/a Got message type=method_return sender=org.freedesktop.DBus destination=:1.732 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1 signature=s error-name=n/a error-message=n/a Bus test-bus: changing state HELLO → RUNNING Bus test-bus: changing state RUNNING → CLOSED request_name_destroy_callback n_ref=1 /* test_name_async (20) */ Bus test-bus: changing state UNSET → OPENING Bus test-bus: changing state OPENING → AUTHENTICATING Bus test-bus: changing state AUTHENTICATING → HELLO stage 0: sd_bus_process returned 1 Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=2 reply_cookie=0 signature=su error-name=n/a error-message=n/a stage 1: sd_bus_process returned 1 Got message type=method_return sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1 signature=s error-name=n/a error-message=n/a Bus test-bus: changing state HELLO → RUNNING stage 2: sd_bus_process returned 1 Got message type=signal sender=org.freedesktop.DBus.Local destination=n/a path=/org/freedesktop/DBus/Local interface=org.freedesktop.DBus.Local member=Connected cookie=4294967295 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a stage 3: sd_bus_process returned 1 Got message type=signal sender=org.freedesktop.DBus destination=:1.733 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=4294967295 reply_cookie=0 signature=s error-name=n/a error-message=n/a stage 4: sd_bus_process returned 1 Got message type=error sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=2 signature=s error-name=org.freedesktop.DBus.Error.AccessDenied error-message=Request to own name refused by policy Unable to request name, will retry after reloading DBus configuration: Request to own name refused by policy Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=ReloadConfig cookie=3 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a request_name_destroy_callback n_ref=2 stage 5: sd_bus_process returned 1 Got message type=method_return sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=3 signature= error-name=n/a error-message=n/a Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=4 reply_cookie=0 signature=su error-name=n/a error-message=n/a request_name_destroy_callback n_ref=1 stage 6: sd_bus_process returned 1 Got message type=error sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=4 signature=s error-name=org.freedesktop.DBus.Error.AccessDenied error-message=Request to own name refused by policy Unable to request name, failing connection: Request to own name refused by policy Bus test-bus: changing state RUNNING → CLOSING stage 7: sd_bus_process returned 1 Bus test-bus: changing state CLOSING → CLOSED stage 8: sd_bus_process returned 1 stage 9: sd_bus_process returned -104 Processing failed: Connection reset by peer
2018-06-06bus-util: avoid unneeded initalization to zeroZbigniew Jędrzejewski-Szmek1-4/+6
2018-05-31Use const char* for timestamp strings which we don't plan to modifyZbigniew Jędrzejewski-Szmek1-1/+2
Makes the intent a bit clearer.
2018-05-29tree-wide: fix typo in comments and NEWSYu Watanabe1-1/+1
2018-05-24machined: move bus_reply_pair_array() into generic utilitiesLennart Poettering1-0/+31
This way, we can reuse it in portabled.
2018-05-24Merge pull request #8817 from yuwata/cleanup-nsflagsLennart Poettering1-1/+1
core: allow to specify RestrictNamespaces= multiple times