summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-21 20:13:26 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-21 20:13:26 +0100
commit38051578360c211e88ef4082ce5746adb52a500e (patch)
treeef88007712a3e40819b6942143c169fef3b25ee7
parent574edc90066c3faeadcf4666928ed9b0ac409c75 (diff)
busctl: add options to control message header flags when invoking methods
-rw-r--r--man/busctl.xml50
-rw-r--r--src/libsystemd/sd-bus/busctl.c69
2 files changed, 115 insertions, 4 deletions
diff --git a/man/busctl.xml b/man/busctl.xml
index e9b758aed5..e0af30e6f5 100644
--- a/man/busctl.xml
+++ b/man/busctl.xml
@@ -156,12 +156,14 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<term><option>--quiet</option></term>
<listitem>
- <para>When used with the <command>call</command> command suppresses
- display of the response message.</para>
+ <para>When used with the <command>call</command> command
+ suppresses display of the response message payload. Note that even
+ if this option is specified errors returned will still be
+ printed and the tool will indicate success or failure with
+ the process exit code.</para>
</listitem>
</varlistentry>
-
<varlistentry>
<term><option>--verbose</option></term>
@@ -172,6 +174,48 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--expect-reply=</option><replaceable>BOOL</replaceable></term>
+
+ <listitem>
+ <para>When used with the <command>call</command> command
+ specifies whether <command>busctl</command> shall wait for
+ completion of the method call, output the returned method
+ response data, and return success or failure via the process
+ exit code. If this is set to <literal>no</literal> the
+ method call will be issued but no response is expected, the
+ tool terminates immediately, and thus no response can be
+ shown, and no success or failure is returned via the exit
+ code. To only suppress output of the reply message payload
+ use <option>--quiet</option> above. Defaults to
+ <literal>yes</literal>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--auto-start=</option><replaceable>BOOL</replaceable></term>
+
+ <listitem>
+ <para>When used with the <command>call</command> command specifies
+ whether the method call should implicitly activate the
+ called service should it not be running yet but is
+ configured to be auto-started. Defaults to
+ <literal>yes</literal>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--allow-interactive-authorization=</option><replaceable>BOOL</replaceable></term>
+
+ <listitem>
+ <para>When used with the <command>call</command> command
+ specifies whether the services may enforce interactive
+ authorization while executing the operation, if the security
+ policy is configured for this. Defaults to
+ <literal>yes</literal>.</para>
+ </listitem>
+ </varlistentry>
+
<xi:include href="user-system-options.xml" xpointer="user" />
<xi:include href="user-system-options.xml" xpointer="system" />
<xi:include href="user-system-options.xml" xpointer="host" />
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index 7f5124f800..145b3198c1 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -53,6 +53,9 @@ static size_t arg_snaplen = 4096;
static bool arg_list = false;
static bool arg_quiet = false;
static bool arg_verbose = false;
+static bool arg_expect_reply = true;
+static bool arg_auto_start = true;
+static bool arg_allow_interactive_authorization = true;
static void pager_open_if_enabled(void) {
@@ -1454,6 +1457,18 @@ static int call(sd_bus *bus, char *argv[]) {
if (r < 0)
return bus_log_create_error(r);
+ r = sd_bus_message_set_expect_reply(m, arg_expect_reply);
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_set_auto_start(m, arg_auto_start);
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_set_allow_interactive_authorization(m, arg_allow_interactive_authorization);
+ if (r < 0)
+ return bus_log_create_error(r);
+
if (!isempty(argv[5])) {
char **p;
@@ -1469,6 +1484,16 @@ static int call(sd_bus *bus, char *argv[]) {
}
}
+ if (!arg_expect_reply) {
+ r = sd_bus_send(bus, m, NULL);
+ if (r < 0) {
+ log_error("Failed to send message.");
+ return r;
+ }
+
+ return 0;
+ }
+
r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) {
log_error("%s", bus_error_message(&error, r));
@@ -1630,7 +1655,11 @@ static int help(void) {
" --match=MATCH Only show matching messages\n"
" --list Don't show tree, but simple object path list\n"
" --quiet Don't show method call reply\n"
- " --verbose Show result values in long format\n\n"
+ " --verbose Show result values in long format\n"
+ " --expect-reply=BOOL Expect a method call reply\n"
+ " --auto-start=BOOL Auto-start destination service\n"
+ " --allow-interactive-authorization=BOOL\n"
+ " Allow interactive authorization for operation\n\n"
"Commands:\n"
" list List bus names\n"
" status SERVICE Show service name status\n"
@@ -1667,6 +1696,9 @@ static int parse_argv(int argc, char *argv[]) {
ARG_SIZE,
ARG_LIST,
ARG_VERBOSE,
+ ARG_EXPECT_REPLY,
+ ARG_AUTO_START,
+ ARG_ALLOW_INTERACTIVE_AUTHORIZATION,
};
static const struct option options[] = {
@@ -1688,6 +1720,9 @@ static int parse_argv(int argc, char *argv[]) {
{ "list", no_argument, NULL, ARG_LIST },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, ARG_VERBOSE },
+ { "expect-reply", required_argument, NULL, ARG_EXPECT_REPLY },
+ { "auto-start", required_argument, NULL, ARG_AUTO_START },
+ { "allow-interactive-authorization", required_argument, NULL, ARG_ALLOW_INTERACTIVE_AUTHORIZATION },
{},
};
@@ -1789,6 +1824,38 @@ static int parse_argv(int argc, char *argv[]) {
arg_verbose = true;
break;
+ case ARG_EXPECT_REPLY:
+ r = parse_boolean(optarg);
+ if (r < 0) {
+ log_error("Failed to parse --expect-reply= parameter.");
+ return r;
+ }
+
+ arg_expect_reply = !!r;
+ break;
+
+
+ case ARG_AUTO_START:
+ r = parse_boolean(optarg);
+ if (r < 0) {
+ log_error("Failed to parse --auto-start= parameter.");
+ return r;
+ }
+
+ arg_auto_start = !!r;
+ break;
+
+
+ case ARG_ALLOW_INTERACTIVE_AUTHORIZATION:
+ r = parse_boolean(optarg);
+ if (r < 0) {
+ log_error("Failed to parse --allow-interactive-authorization= parameter.");
+ return r;
+ }
+
+ arg_allow_interactive_authorization = !!r;
+ break;
+
case '?':
return -EINVAL;