summaryrefslogtreecommitdiff
path: root/src/busctl
Commit message (Collapse)AuthorAgeFilesLines
* 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-121-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.)
* tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-141-4/+4
| | | | | | | With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
* tree-wide: use UINT64_MAX or friendsYu Watanabe2021-03-051-1/+1
|
* table: drop last SIZE_MAX from table_set_sort() and table_set_display()Yu Watanabe2021-03-051-5/+3
|
* Merge pull request #18596 from keszybz/systemctl-quiet-legendLennart Poettering2021-02-171-20/+11
|\ | | | | systemctl: hide legends with --quiet, allow overriding
| * tree-wide: add a helper to parse boolean optargZbigniew Jędrzejewski-Szmek2021-02-171-20/+11
| | | | | | | | | | | | | | | | | | This nicely covers the case when optarg is optional. The same parser can be used when the option string passed to getopt_long() requires a parameter and when it doesn't. The error messages are made consistent. Also fixes a log error c&p in --crash-reboot message.
* | tree-wide: return NULL from freeing functionsZbigniew Jędrzejewski-Szmek2021-02-161-7/+5
| | | | | | | | | | | | I started working on this because I wanted to change how DEFINE_TRIVIAL_CLEANUP_FUNC is defined. Even independently of that change, it's nice to make make things more consistent and predictable.
* | Merge pull request #18481 from keszybz/rpm-restart-post-transZbigniew Jędrzejewski-Szmek2021-02-161-2/+2
|\ \ | |/ |/| Restart units after the rpm transaction
| * sd-bus: standarize on NULL for empty signature in method callsZbigniew Jędrzejewski-Szmek2021-02-121-2/+2
| | | | | | | | | | We would use sometimes "" and sometimes NULL. They are equivalent, so let's use NULL everywhere, except for a two places in tests.
* | Move and rename parse_json_argument() functionZbigniew Jędrzejewski-Szmek2021-02-151-1/+2
|/ | | | | json.[ch] is a very generic implementation, and cmdline argument parsing doesn't fit there.
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-6/+5
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* busctl: show --help in pagerLennart Poettering2021-01-211-0/+2
| | | | We do this for other larger --help texts, do so here too.
* busctl/homectl: port the obvious cases to table_print_with_pager()Lennart Poettering2021-01-211-10/+1
|
* meson: move source file list for busctlYu Watanabe2021-01-191-0/+6
|
* busctl: port busctl to JSON_FORMAT_OFF tooLennart Poettering2021-01-091-44/+16
| | | | | This is a bit more complex, since busctl's JSON code predates json.c and was only minimally updated sofar.
* string-util: imply NULL termination of strextend() argument listLennart Poettering2021-01-061-3/+3
| | | | | The trailing NULL in the argument list is now implied (similar to what we already have in place in strjoin()).
* Merge pull request #17967 from poettering/connect-user-busLennart Poettering2020-12-151-1/+1
|\ | | | | add support for "systemctl --user --machine=foobar@.host" for connecting to user bus of user "foobar"
| * sd-bus: add API for connecting to a specific user's user bus of a specific ↵Lennart Poettering2020-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | container This is unfortunately harder to implement than it sounds. The user's bus is bound a to the user's lifecycle after all (i.e. only exists as long as the user has at least one PAM session), and the path dynamically (at least theoretically, in practice it's going to be the same always) generated via $XDG_RUNTIME_DIR in /run/. To fix this properly, we'll thus go through PAM before connecting to a user bus. Which is hard since we cannot just link against libpam in the container, since the container might have been compiled entirely differently. So our way out is to use systemd-run from outside, which invokes a transient unit that does PAM from outside, doing so via D-Bus. Inside the transient unit we then invoke systemd-stdio-bridge which forwards D-Bus from the user bus to us. The systemd-stdio-bridge makes up the PAM session and thus we can sure tht the bus exists at least as long as the bus connection is kept. Or so say this differently: if you use "systemctl -M lennart@foobar" now, the bus connection works like this: 1. sd-bus on the host forks off: systemd-run -M foobar -PGq --wait -pUser=lennart -pPAMName=login systemd-stdio-bridge 2. systemd-run gets a connection to the "foobar" container's system bus, and invokes the "systemd-stdio-bridge" binary as transient service inside a PAM session for the user "lennart" 3. The systemd-stdio-bridge then proxies our D-Bus traffic to the user bus. sd-bus (on host) → systemd-run (on host) → systemd-stdio-bridge (in container) Complicated? Well, to some point yes, but otoh it's actually nice in various other ways, primarily as it makes the -H and -M codepaths more alike. In the -H case (i.e. connect to remote host via SSH) a very similar three steps are used. The only difference is that instead of "systemd-run" the "ssh" binary is used to invoke the stdio bridge in a PAM session of some other system. Thus we get similar implementation and isolation for similar operations. Fixes: #14580
* | busctl: add a timestamp to the output of the busctl monitor commandd0327472020-12-161-0/+6
|/
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-093-3/+3
|
* sd-bus: add custom return code when $XDG_RUNTIME_DIR is not setZbigniew Jędrzejewski-Szmek2020-10-141-2/+2
| | | | | | | 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.
* tree-wide: assorted coccinelle fixesFrantisek Sumsal2020-10-091-2/+1
|
* busctl: add missing shortopt -lJuergen Hoetzel2020-09-151-1/+1
|
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-5/+3
|
* tree-wide: drop pointless zero initialization (#16884)fangxiuning2020-08-281-1/+1
| | | tree-wide: drop pointless zero initialization
* bus: use bus_log_parse_error to print messagefangxiuning2020-07-121-1/+1
|
* table use table_log_print_error() instead of table_log_show_errorfangxiuning2020-07-081-1/+1
|
* table add table_log_show_error()fangxiuning2020-07-081-1/+1
|
* log: introduce log_parse_environment_cli() and log_setup_cli()Filipe Brandenburger2020-06-241-3/+1
| | | | | | | | | | | | | | | | Presently, CLI utilities such as systemctl will check whether they have a tty attached or not to decide whether to parse /proc/cmdline or EFI variable SystemdOptions looking for systemd.log_* entries. But this check will be misleading if these tools are being launched by a daemon, such as a monitoring daemon or automation service that runs in background. Make log handling of CLI tools uniform by never checking /proc/cmdline or EFI variables to determine the logging level. Furthermore, introduce a new log_setup_cli() shortcut to set up common options used by most command-line utilities.
* busctl: drop unneeded paramZbigniew Jędrzejewski-Szmek2020-05-261-25/+11
|
* busctl: verify args early and always print results to stdoutZbigniew Jędrzejewski-Szmek2020-05-261-14/+17
| | | | | | | | | | We would print the error sometimes to stdout and sometimes to stderr. It *is* useful to get the message if one of the names is not found on the bus to stdout, so that this shows out in the pager. So let's do verification of args early to catch invalid arguments, and then if we receive an error over the bus (most likely that the name is not activatable), let's print to stdout so it gets paged. E.g. 'busctl tree org.freedesktop.systemd1 org.freedesktop.systemd2' gives a nicely usable output.
* sd-bus: internalize setting of bus is_system/is_userZbigniew Jędrzejewski-Szmek2020-05-251-5/+2
| | | | | | | | | Each of bus_set_address_{user,system} had two users, and each of the two users would set the internal flag manually. We should do that internally in the functions instead. While at it, only set the flag when setting the address is actually successful. This doesn't change anything for current users, but it seems more correct.
* tree-wide: use public sd-bus functions in more placesZbigniew Jędrzejewski-Szmek2020-05-251-1/+1
|
* busctl: use set_put_strdup()Zbigniew Jędrzejewski-Szmek2020-05-251-27/+9
|
* busctl: improve error messages on duplicate members/interfacesLennart Poettering2020-05-191-8/+16
| | | | Prompted by: #15833