summaryrefslogtreecommitdiffstats
path: root/src/busctl (follow)
Commit message (Collapse)AuthorAgeFilesLines
* meson: Start adding devel and rc suffixes to the project versionDaan De Meyer2024-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Let's make sure that versions generated by meson-vcs-tag.sh always sort higher than official and stable releases. We achieve this by immediately updating the meson version in meson.build after a new release. To make sure this version always sorts lower than future rcs, we suffix it with "~devel" which will sort lower than "~rcX". The new release workflow is to update the version in meson.build for each rc and the official release and to also update the version number after a new release to the next development version. The full version is exposed as PROJECT_VERSION_FULL and used where it makes sense over PROJECT_VERSION. We also switch to reading the version from a meson.version file in the repo instead of hardcoding it in meson.build. This makes it easier to access both inside and outside of the project. The meson-vcs-tag.sh script is rewritten to query the version from meson.version instead of passing it in via the command line. This makes it easier to use outside of systemd since users don't have to query the version themselves first.
* busctl: avoid asserting on NULL messageFrantisek Sumsal2023-12-241-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid passing a NULL message to sd_bus_message_is_signal(), to not trip over an assertion: [ 132.869436] H testsuite-82.sh[614]: + systemctl --no-block --check-inhibitors=yes soft-reboot [ 132.967386] H systemd[1]: Created slice system-systemd\x2dcoredump.slice. [ 133.018292] H systemd[1]: Starting inhibit.service... [ 133.122610] H systemd[1]: Started systemd-coredump@0-665-0.service. [ 133.163643] H systemd[1]: Started inhibit.service. [ 133.206836] H testsuite-82.sh[614]: + exec sleep infinity [ 133.236762] H systemd-logind[611]: The system will reboot now! [ 135.891607] H systemd-coredump[667]: [🡕] Process 663 (busctl) of user 0 dumped core. Stack trace of thread 663: #0 0x00007f2ec45e6acf raise (libc.so.6 + 0x4eacf) #1 0x00007f2ec45b9ea5 abort (libc.so.6 + 0x21ea5) #2 0x00007f2ec4b5c9a6 log_assert_failed (libsystemd-shared-255.so + 0x1ff9a6) #3 0x00007f2ec4b5dca5 log_assert_failed_return (libsystemd-shared-255.so + 0x200ca5) #4 0x00007f2ec4bb3df6 sd_bus_message_is_signal (libsystemd-shared-255.so + 0x256df6) #5 0x000000000040e478 monitor (busctl + 0xe478) #6 0x000000000040e82f verb_monitor (busctl + 0xe82f) #7 0x00007f2ec4b202cb dispatch_verb (libsystemd-shared-255.so + 0x1c32cb) #8 0x00000000004074fa busctl_main (busctl + 0x74fa) #9 0x0000000000407525 run (busctl + 0x7525) #10 0x000000000040ff67 main (busctl + 0xff67) #11 0x00007f2ec45d2d85 __libc_start_main (libc.so.6 + 0x3ad85) #12 0x00000000004044be _start (busctl + 0x44be) ELF object binary architecture: AMD x86-64 [ 136.141152] H dbus-daemon[634]: [system] Monitoring connection :1.2 closed. [ 136.152233] H systemd[1]: busctl.service: Main process exited, code=dumped, status=6/ABRT [ 136.153996] H systemd[1]: busctl.service: Failed with result 'core-dump'. The asertion in question: Assertion 'm' failed at src/libsystemd/sd-bus/bus-message.c:1015, function sd_bus_message_is_signal(). Aborting. We can get a NULL message here through sd_bus_process() -> bus_process_internal() -> process_running(), so let's handle this case appropriately.
* various: clean up isatty() handlingMike Yuan2023-12-221-1/+1
| | | | As per https://github.com/systemd/systemd/pull/30547#discussion_r1434371627
* busctl: send READY=1 when we become a monitorFrantisek Sumsal2023-11-081-0/+2
| | | | | | | This is pretty much the same stuff as `resolvectl monitor` does, and allows us to run `busctl monitor` in a Type=notify unit which ensures that `busctl` is really listening for messages once the unit is marked as started.
* busctl: do not print start/stop monitoring messages with --quiet/--jsonLuca Boccassi2023-08-301-2/+4
|
* busctl: fix showing array of dictionary in JSON formatYu Watanabe2023-08-081-8/+14
| | | | | | | This partially reverts the commit 684bce3d54463b3222246f72adfe82ad5d176fea and fixes the issue introduced by it. Fixes #28711.
* meson: merge declarations of normal and test executablesYu Watanabe2023-08-031-4/+1
|
* meson: move declarations of busctl, stdio-bridge, and runYu Watanabe2023-08-011-0/+8
|
* bus: add some minimal bounds check on signaturesLuca Boccassi2023-07-161-1/+4
| | | | | | | | | | | CID#1491292 CID#1491291 CID#1491290 CID#1491289 CID#1491284 CID#1491281 CID#1491280 CID#1491278
* busctl: use json_variant_append_array()Yu Watanabe2023-07-131-25/+29
|
* json: free array in json_variant_unref_many()Daan De Meyer2023-07-121-41/+21
| | | | | | This allows using it with CLEANUP_ARRAY(). For the 2 call sites where we don't need to free the array, we do a regular for loop calling json_variant_unref() instead.
* tree-wide: "<n>bit" → "<n>-bit"Zbigniew Jędrzejewski-Szmek2023-07-021-7/+7
| | | | In some places, "<n> bits" is used when more appropriate.
* tree-wide: use memstream-utilYu Watanabe2023-05-311-7/+7
|
* tree-wide: check memstream buffer after closing the handleFrantisek Sumsal2023-05-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When closing the FILE handle attached to a memstream, it may attempt to do a realloc() that may fail during OOM situations, in which case we are left with the buffer pointer pointing to NULL and buffer size > 0. For example: ``` #include <errno.h> #include <stdio.h> #include <stdlib.h> void *realloc(void *ptr, size_t size) { return NULL; } int main(int argc, char *argv[]) { FILE *f; char *buf; size_t sz = 0; f = open_memstream(&buf, &sz); if (!f) return -ENOMEM; fputs("Hello", f); fflush(f); printf("buf: 0x%lx, sz: %lu, errno: %d\n", (unsigned long) buf, sz, errno); fclose(f); printf("buf: 0x%lx, sz: %lu, errno: %d\n", (unsigned long) buf, sz, errno); return 0; } ``` ``` $ gcc -o main main.c $ ./main buf: 0x74d4a0, sz: 5, errno: 0 buf: 0x0, sz: 5, errno: 0 ``` This might do unexpected things if the underlying code expects a valid pointer to the memstream buffer after closing the handle. Found by Nallocfuzz.
* busctl: Add space before "tree" paths for copyingMatt Johnston2023-05-181-1/+1
| | | | | | | | | | | | | | | | | | This allows a double-click on the path in a terminal to select the whole path. Otherwise the leading '-' character is also included in the copied path. ``` New output: ./busctl tree org.freedesktop.network1 `- /org `- /org/freedesktop |- /org/freedesktop/LogControl1 `- /org/freedesktop/network1 |- /org/freedesktop/network1/link | |- /org/freedesktop/network1/link/_31 | |- /org/freedesktop/network1/link/_32 ```
* busctl: set a description for the bus connectionLennart Poettering2023-05-161-0/+2
| | | | | | | Unlike most other bus connections in our codebase this one is created manually and every setting set invididually. It hence does not have a description by default (as all automatic connections have). Set one explicitly.
* busctl: add --xml-interface to the help messageMasatake YAMATO2023-04-111-0/+1
| | | | Signed-off-by: Masatake YAMATO <yamato@redhat.com>
* busctl: also assume --full if not writing to terminalZbigniew Jędrzejewski-Szmek2023-03-281-3/+6
| | | | If people grep the output, it probably shouldn't be ellipsized.
* busctl: use size_t for set sizeZbigniew Jędrzejewski-Szmek2023-03-281-9/+9
| | | | Also reduce the scope of variables.
* busctl: do not truncate property values when --fullZbigniew Jędrzejewski-Szmek2023-03-281-1/+1
|
* basic: add RuntimeScope enumLennart Poettering2023-03-101-6/+18
| | | | | | | | | | | | 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.
* meson: Use dicts for test definitionsJan Janssen2023-02-211-2/+6
| | | | | | | Although this slightly more verbose it makes it much easier to reason about. The code that produces the tests heavily benefits from this. Test lists are also now sorted by test name.
* meson: Do not include headers in source listsJan Janssen2023-01-241-4/+3
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* busctl: simplify peeking the typeLennart Poettering2023-01-161-20/+10
| | | | | | | let's peek the type before we enter the variant, not after, so that we can reuse it as-is, instead having to recombine it later. Follow-up for: #26049
* busctl: fix introspecting DBus propertiesYu Watanabe2023-01-151-2/+19
| | | | | | Follow-up for f2f7785d7a47ffa48ac929648794e1288509ddd8. Fixes #26033.
* busctl-introspect: use _cleanup_David Tardon2022-12-141-23/+11
|
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* shared/format-table: use enum instead of Table.empty_stringZbigniew Jędrzejewski-Szmek2022-09-221-3/+1
| | | | | | | | | | | | All users were setting this to some static string (usually "-"), so let's simplify things by not doing strdup, but instead limiting callers to a fixed set of values. In preparation for the next commit, the function is renamed from "empty" to "replacement", because it'll be used for more than empty fields. I didn't do the whole string-table setup, because it's all used internally in one file and this way we can immediately assert if an invalid value is passed in. Some callers were (void)ing the error, others were ignoring it, and others propagating. It's nicer to remove the boilerplate.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-132-7/+3
|
* busctl: Add introspect support for methods with same name but different ↵Sebastian Scheibner2022-09-061-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | signature D-Bus interfaces can have multiple methods with the same name, as long as they have different arguments (signature). Currently busctl can call those methods but when introspecting the interface it just displays "Duplicate method" This PR fixes the behavior, by also adding the signature to the hash for the members set. Before this patch: $ busctl introspect org.asamk.Signal /org/asamk/Signal Invalid introspection data: duplicate method 'sendMessage' on interface 'org.asamk.Signal'. After this patch: $ busctl introspect org.asamk.Signal /org/asamk/Signal NAME TYPE SIGNATURE RESULT/VALUE FLAGS org.asamk.Signal interface - - - .sendMessage method as x - .sendMessage method s x - Calling the methods already works as expected, as the user must specify the signature explicitely: busctl --user call org.asamk.Signal /org/asamk/Signal org.asamk.Signal sendMessage "as" 2 foo bar busctl --user call org.asamk.Signal /org/asamk/Signal org.asamk.Signal sendMessage "s" foo $ busctl --xml introspect org.asamk.Signal /org/asamk/Signal <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/org/asamk/Signal"> <interface name="org.asamk.Signal"> <method name="sendMessage" > <arg type="as" direction="in"/> <arg type="x" direction="out"/> </method> <method name="sendMessage" > <arg type="s" direction="in"/> <arg type="x" direction="out"/> </method> <interface name="org.freedesktop.DBus.Introspectable"> <method name="Introspect"> <arg type="s" direction="out"/> </method> </interface> <interface name="org.freedesktop.DBus.Peer"> <method name="Ping"> </method> </interface> </node>
* busctl: Fix warning about invaild introspection dataSebastian Scheibner2022-09-061-8/+12
| | | | | The set_put function returns 0 if the element is already in the set and not EEXIST, like e.g. hashmap does.
* Use https for freedesktop.orgMichael Biebl2022-06-281-7/+7
| | | | grep -l -r http:// | xargs sed -E -i s'#http://(.*).freedesktop.org#https://\1.freedesktop.org#'
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-4/+1
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* test: Use TEST macros in more placesJan Janssen2022-03-161-10/+2
|
* meson: Use files() for testsJan Janssen2022-01-111-3/+3
| | | | | | Not having to provide the full path in the source tree is much nicer and the produced lists can also be used anywhere in the source tree.
* bus-dump: change capture output to use pcapng (#21738)Stephen Hemminger2021-12-251-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge pull request #20138 from keszybz/coding-style-variable-declsLuca Boccassi2021-11-051-11/+11
|\ | | | | A coding style tweak and checking of sd_notify() calls and voidification of pager_open()
| * Make pager_open() return voidZbigniew Jędrzejewski-Szmek2021-11-031-11/+11
| |
* | tree-wide: do not print hint about -M if -M is already usedZbigniew Jędrzejewski-Szmek2021-11-041-3/+3
| | | | | | | | | | | | | | | | (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.)
* test: shorten code a bitYu Watanabe2021-10-111-42/+4
|
* test: add a test for parsing xml obtained by DBus Introspect methodYu Watanabe2021-10-102-0/+416
|
* busctl: add missing headerYu Watanabe2021-10-101-0/+1
|
* busctl: shorten code a bitYu Watanabe2021-10-101-2/+1
|
* busctl: use set_ensure_consume()Yu Watanabe2021-10-101-9/+1
|
* 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.
* tree-wide: port everything over to new sd-id128 compund literal blissLennart Poettering2021-08-201-3/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-032-5/+5
| | | | | | | | | | | | | | | | | 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.
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.)