summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus
Commit message (Collapse)AuthorAgeFilesLines
* sd-bus: use _cleanup_ in one more placeZbigniew Jędrzejewski-Szmek2022-03-221-10/+7
|
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-195-15/+1
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-192-14/+1
|
* test: Use TEST macros in more placesJan Janssen2022-03-164-54/+26
|
* man: describe capability checks on the busZbigniew Jędrzejewski-Szmek2022-03-041-5/+3
| | | | | | | | | | A description of SD_BUS_VTABLE_CAPABILITY is added, and the discussion on SD_BUS_VTABLE_UNPRIVILEGED in expanded. I think it would be nice to add longer description of how access is checked (maybe in sd-bus(3)), but I'm leaving that for later. I think the text that was added here describes everything, even if tersely. Fixes #21882.
* bus: Use OrderedSet for introspectionJan Janssen2022-01-193-27/+26
| | | | Otherwise, the generated xml files are not reproducible.
* bus-dump: change capture output to use pcapng (#21738)Stephen Hemminger2021-12-252-49/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes busctl capture to generate pcapng format instead of the legacy pcap format files. It includes basic meta-data in the file and still uses microsecond time resolution. In future, more things can be added such as high resolution timestams, statistics, etc. PCAP Next Generation capture file format is what tshark uses and is in process of being standardized in IETF. It is also readable with libpcap. $ capinfos /tmp/new.pcapng File name: /tmp/new.pcapng File type: Wireshark/... - pcapng File encapsulation: D-Bus File timestamp precision: microseconds (6) Packet size limit: file hdr: (not set) Packet size limit: inferred: 4096 bytes Number of packets: 22 File size: 21kB Data size: 20kB Capture duration: 0.005694 seconds First packet time: 2021-12-11 11:57:42.788374 Last packet time: 2021-12-11 11:57:42.794068 Data byte rate: 3,671kBps Data bit rate: 29Mbps Average packet size: 950.27 bytes Average packet rate: 3,863 packets/s SHA256: b85ed8b094af60c64aa6d9db4a91404e841736d36b9e662d707db9e4096148f1 RIPEMD160: 81f9bac7ec0ec5cd1d55ede136a5c90413894e3a SHA1: 8400822ef724b934d6000f5b7604b9e6e91be011 Strict time order: True Capture oper-sys: Linux 5.14.0-0.bpo.2-amd64 Capture application: systemd 250 (250-rc2-33-gdc79ae2+) Number of interfaces in file: 1 Interface #0 info: Encapsulation = D-Bus (146 - dbus) Capture length = 4096 Time precision = microseconds (6) Time ticks per second = 1000000 Number of stat entries = 0 Number of packets = 22
* test,static-destruct: Use retain attribute to prevent linker garbage collectionJan Janssen2021-12-221-1/+1
| | | | Fixes: #21847
* libsystemd: ignore both EINTR and EAGAINYu Watanabe2021-11-301-9/+11
|
* homed: add explicit API for requesting rebalancing tooLennart Poettering2021-11-252-0/+2
|
* sd-bus: Fix standard method argument namesMiika Karanki2021-11-231-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | The argument names of methods under org.freedesktop.DBus.Properties and org.freedesktop.DBus.Introspectable interfaces are specifies in D-Bus specification[1]. They are: org.freedesktop.DBus.Introspectable.Introspect (out STRING xml_data) org.freedesktop.DBus.Properties.Get (in STRING interface_name, in STRING property_name, out VARIANT value); org.freedesktop.DBus.Properties.Set (in STRING interface_name, in STRING property_name, in VARIANT value); org.freedesktop.DBus.Properties.GetAll (in STRING interface_name, out DICT<STRING,VARIANT> props); sd-bus is using different argument names in the introspection document. Usually this is not a problem but in case something tries to map the argument names based on the introspection document to the position of the arguments in the method call, then using names different than the ones specified in the D-Bus specification is confusing. So fix the names to match the D-Bus specification. [1] https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-introspectable
* Change gendered terms to be gender-neutral (#21325)Emily Gonyer2021-11-122-3/+3
| | | Some typos are also fixed.
* escape: add flags argument to quote_command_line()Lennart Poettering2021-11-111-1/+1
| | | | That way, we can reuse the call at one more place (see later patch).
* tree-wide: use sd_event_source_disable_unref() where we canLennart Poettering2021-11-091-31/+6
|
* tree-wide: always use TAKE_FD() when calling rearrange_stdio()Lennart Poettering2021-11-031-1/+3
| | | | | | | | | | | | rearrange_stdio() invalidates specified fds even on failure, which means we should always invalidate the fds we pass in no matter what. Let's make this explicit by using TAKE_FD() for that everywhere. Note that in many places we such invalidation doesnt get us much behaviour-wise, since we don't use the variables anymore later. But TAKE_FD() in a way is also documentation, it encodes explicitly that the fds are invalidated here, so I think it's a good thing to always make this explicit here.
* tree-wide: port various places to use TAKE_PID()Lennart Poettering2021-11-031-4/+4
|
* alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhereLennart Poettering2021-10-144-6/+7
| | | | | | | | | | | | | Let's define two helpers strdupa_safe() + strndupa_safe() which do the same as their non-safe counterparts, except that they abort if called with allocations larger than ALLOCA_MAX. This should ensure that all our alloca() based allocations are subject to this limit. afaics glibc offers three alloca() based APIs: alloca() itself, strndupa() + strdupa(). With this we have now replacements for all of them, that take the limit into account.
* Merge pull request #20985 from yuwata/test-bus-node-enumeratorYu Watanabe2021-10-121-0/+39
|\ | | | | test: add more tests for sd-bus node enumerator
| * test: add more node enumerator testsYu Watanabe2021-10-121-0/+39
| |
* | test: use assert_se() instead of assert()Yu Watanabe2021-10-121-1/+1
| |
* | homed: take BSD file lock on LUKS file while activatedLennart Poettering2021-10-112-0/+2
| | | | | | | | Fixes: #19758
* | util: define initializer for 'struct ucred' that properly invalidates all fieldsLennart Poettering2021-10-111-0/+1
|/ | | | | i.e. let's make sure to invalid uid/gid to UID_INVAID + GID_INVALID instead of zero.
* basic: split out glyph/emoji related calls from locale-util.[ch] into ↵Lennart Poettering2021-10-051-1/+1
| | | | | | | | glyph-util.[ch] These functions are used pretty much independently of locale, i.e. the only info relevant is whether th locale is UTF-8 or not. Hence let's give this its own pair of .c/.h files.
* format-util/sd-bus: do not ignore snprintf resultLuca Boccassi2021-08-201-8/+4
|
* tree-wide: port everything over to new sd-id128 compund literal blissLennart Poettering2021-08-201-2/+1
|
* sd-bus: Improve (sd-buscntr) error loggingDaan De Meyer2021-08-191-1/+1
| | | | | | We're only doing one thing in the child process which is connecting to the D-Bus socket so let's mention that in the error message when something goes wrong instead of having a generic error message.
* sd-bus: Return detailed (sd-buscntr) error from bus_container_connect_socket()Daan De Meyer2021-08-191-2/+4
| | | | | | | Previously, when the connect() call in (sd-buscntr) failed, we returned -EPROTO without ever reading the actual errno from the error pipe. To fix the issue, delay checking the process exit status until after we've read and processed any error from the error pipe.
* tree-wide: use memmem_safe()Lennart Poettering2021-08-101-3/+3
| | | | | | | | Let's be paranoid and do something useful if we operate with empty haystack/needle. This doesn't actually fix anything, as the places as far as I can see check for non-emptyness already beforehand, but I will sleep safer at night, if we don't even allow the trap to be fallen in, ever, even if the code is changed sooner or later.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-038-20/+20
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* Merge pull request #20109 from keszybz/timestamp-macrosYu Watanabe2021-07-142-14/+11
|\ | | | | Add macros that define scratch buffer internally for timestamp/timespan formatting
| * tree-wide: do not use (void) asprintfZbigniew Jędrzejewski-Szmek2021-07-091-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | asprintf(3) says that the pointer is "undefined" after a failed call. In the current glibc implementation it is just NULL. In principle the call could return a valid pointer with bad contents or something. We have two styles of error handling: in a majority of cases we would check the return value, but sometimes we used (void) and relied on the pointer not being set. In practice both styles should be equivalent, but gcc doesn't like the second one with -Wunused-result. (Though only sometimes. E.g. on my F34 box I don't get the same warnings as in CI, even though the compiler version is very similar and the compilation options are the same…). It's also nice to be consistent in our code base. So let's always use the first style of error checking.
| * Inline some iterator variablesZbigniew Jędrzejewski-Szmek2021-07-091-3/+1
| |
| * tree-wide: add FORMAT_TIMESTAMP_STYLE()Zbigniew Jędrzejewski-Szmek2021-07-091-7/+1
| |
* | sd-bus: allow numerical uids in -M user@.hostZbigniew Jędrzejewski-Szmek2021-07-091-9/+18
| | | | | | | | | | | | UIDs don't work well over ssh, but locally or with containers they are OK. In particular, user@.service uses UIDs as identifiers, and it's nice to be able to copy&paste that UID for interaction with the user's managers.
* | sd-bus: print debugging information if bus_container_connect_socket() failsZbigniew Jędrzejewski-Szmek2021-07-091-8/+10
| | | | | | | | | | We would return the errno, but there are many steps, and without some debugging info it's hard to figure out what exactly failed.
* | sd-bus: print quoted commandline when in bus_socket_exec()Zbigniew Jędrzejewski-Szmek2021-07-091-6/+14
|/ | | | | | | The arguments are where the interesting part is: src/libsystemd/sd-bus/bus-socket.c:965: sd-bus: starting bus with systemd-run... ↓ src/libsystemd/sd-bus/bus-socket.c:972: sd-bus: starting bus with systemd-run -M.host -PGq --wait -pUser=1000 -pPAMName=login systemd-stdio-bridge "-punix:path=\${XDG_RUNTIME_DIR}/bus"
* basic,shared: move a bunch of files to src/shared/Zbigniew Jędrzejewski-Szmek2021-06-241-1/+0
| | | | | | | | | | | | The goal is to move everything that requires selinux or smack away from src/basic/. This means that src/basic/label.[ch] must move, which implies btrfs-util.[ch], copy.[ch], and a bunch of other files which form a cluster of internal use. This is just moving text around, so there should be no functional difference. test-blockdev-util is new, because path_is_encrypted() is moved to blockdev-util.c, and so far we didn't have any tests for code there.
* tree-wide: add missing whitespace at the end of commentsYu Watanabe2021-06-151-1/+1
|
* homectl: store FIDO2 up/uv/clientPin fields in user records tooLennart Poettering2021-06-012-0/+3
| | | | | | | | | | | | This catches up homed's FIDO2 support with cryptsetup's: we'll now store the uv/up/clientPin configuration at enrollment in the user record JSON data, and use it when authenticating with it. This also adds explicit "uv" support: we'll only allow it to happen when the client explicity said it's OK. This is then used by clients to print a nice message suggesting "uv" has to take place before retrying allowing it this time. This is modelled after the existing handling for "up".
* sd-bus: use strextend()Yu Watanabe2021-05-201-7/+1
|
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-197-27/+16
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* tree-wide: use af_to_ipv4_ipv6() + af_from_ipv4_ipv6() helpers at various placesLennart Poettering2021-05-111-5/+3
|
* Merge pull request #19226 from keszybz/reenable-maybe-unitialized-warningZbigniew Jędrzejewski-Szmek2021-04-082-14/+16
|\ | | | | meson: re-enable -Wmaybe-uninitialized
| * sd-bus: make sd_bus_error_set() more like sd_bus_error_setfv()Zbigniew Jędrzejewski-Szmek2021-04-071-13/+15
| | | | | | | | | | | | | | In b9c19bc384fd41c173a8e453bd157544400af059, I added an assert to _setfv() and _setf(), but I forgot to do the same in _set(). Let's do this for completeness. While at it, restructure _set() to use the same style as _setfv().
| * tree-wide: sd_bus_error_setf → set_bus_error_setZbigniew Jędrzejewski-Szmek2021-04-071-1/+1
| | | | | | | | strdup() is more efficient than asprintf().
* | sd-bus: make sd_bus_is_{ready,open} accept NULLZbigniew Jędrzejewski-Szmek2021-04-081-2/+6
|/ | | | | | | | | We didn't document this behaviour one way or another, so I think it's OK to change. All callers do the NULL check before callling this to avoid the assert warning, so it seems reasonable to do it internally. sd_bus_can_send() is similar, but there we expressly say that an error is returned on NULL, so I didn't change it.
* man: split the description of sd_bus_error_set()Zbigniew Jędrzejewski-Szmek2021-03-311-1/+1
| | | | | | | | | It was one giant all of text in pseudo-random order. Let's split it into paragraphs talk about one subject each. And unfortunately, the description of what happens when the error is not set was not correct. In general, various functions treat 0/NULL as not-an-error, and return 0.
* sd-bus: add asserts showing that sd_bus_error_setf() returns negativeZbigniew Jędrzejewski-Szmek2021-03-311-3/+9
| | | | (when name is specified).
* sd-bus: add assert to tell the compiler that the error code is positiveZbigniew Jędrzejewski-Szmek2021-03-311-2/+6
| | | | | | | | | | | | | | | | | | I was hoping it would help with the following gcc warning: [35/657] Compiling C object src/shared/libsystemd-shared-248.a.p/bus-message-util.c.o ../src/shared/bus-message-util.c: In function ‘bus_message_read_dns_servers’: ../src/shared/bus-message-util.c:165:21: warning: ‘family’ may be used uninitialized in this function [-Wmaybe-uninitialized] 165 | r = in_addr_full_new(family, &a, port, 0, server_name, dns + n); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/shared/bus-message-util.c:165:21: warning: ‘port’ may be used uninitialized in this function [-Wmaybe-uninitialized] ../src/shared/bus-message-util.c:165:21: warning: ‘server_name’ may be used uninitialized in this function [-Wmaybe-uninitialized] It actually doesn't, but the compiler has a point here: the code is specified in sd_bus_error_map[], and it has no way of knowning that we want it to be a positive value. I think this should be an assert, because if this assumption fails, a programming error has occured, something that'd want to catch.
* sd-bus: set retain attribute on BUS_ERROR_MAP_ELF_REGISTERFangrui Song2021-03-291-0/+6
| | | | | | | | | | | | | | | | | LLD 13 and GNU ld 2.37 support -z start-stop-gc which allows garbage collection of C identifier name sections despite the __start_/__stop_ references. Simply set the retain attribute so that GCC 11 (if configure-time binutils is 2.36 or newer)/Clang 13 will set the SHF_GNU_RETAIN section attribute to prevent garbage collection. Without the patch, there are linker errors like the following with -z start-stop-gc. ``` ld: error: undefined symbol: __start_SYSTEMD_BUS_ERROR_MAP >>> referenced by bus-error.c:93 (../src/libsystemd/sd-bus/bus-error.c:93) >>> sd-bus_bus-error.c.o:(bus_error_name_to_errno) in archive src/libsystemd/libsystemd_static.a ```