naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
572a44
From 8588ecf209ae4f8a198614b3786c58e584528f98 Mon Sep 17 00:00:00 2001
572a44
From: Lennart Poettering <lennart@poettering.net>
572a44
Date: Wed, 6 Nov 2013 17:31:20 +0100
572a44
Subject: [PATCH] run: support --system to match other commands, even if
572a44
 redundant
572a44
572a44
Conflicts:
572a44
	man/systemd-run.xml
572a44
	src/run/run.c
572a44
---
572a44
 man/systemd-run.xml |  9 +++++++++
572a44
 src/run/run.c       | 20 +++++++++++++-------
572a44
 2 files changed, 22 insertions(+), 7 deletions(-)
572a44
572a44
diff --git a/man/systemd-run.xml b/man/systemd-run.xml
572a44
index 252335b..48a0715 100644
572a44
--- a/man/systemd-run.xml
572a44
+++ b/man/systemd-run.xml
572a44
@@ -113,6 +113,15 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
572a44
       </varlistentry>
572a44
 
572a44
       <varlistentry>
572a44
+        <term><option>--system</option></term>
572a44
+
572a44
+        <listitem>
572a44
+          <para>Talk to the service manager of the system. This is the
572a44
+          implied default.</para>
572a44
+        </listitem>
572a44
+      </varlistentry>
572a44
+
572a44
+      <varlistentry>
572a44
         <term><option>--scope</option></term>
572a44
 
572a44
         <listitem>
572a44
diff --git a/src/run/run.c b/src/run/run.c
572a44
index 18a4920..a6abead 100644
572a44
--- a/src/run/run.c
572a44
+++ b/src/run/run.c
572a44
@@ -61,6 +61,7 @@ static int parse_argv(int argc, char *argv[]) {
572a44
         enum {
572a44
                 ARG_VERSION = 0x100,
572a44
                 ARG_USER,
572a44
+                ARG_SYSTEM,
572a44
                 ARG_SCOPE,
572a44
                 ARG_UNIT,
572a44
                 ARG_DESCRIPTION,
572a44
@@ -72,6 +73,7 @@ static int parse_argv(int argc, char *argv[]) {
572a44
                 { "help",              no_argument,       NULL, 'h'             },
572a44
                 { "version",           no_argument,       NULL, ARG_VERSION     },
572a44
                 { "user",              no_argument,       NULL, ARG_USER        },
572a44
+                { "system",            no_argument,       NULL, ARG_SYSTEM      },
572a44
                 { "scope",             no_argument,       NULL, ARG_SCOPE       },
572a44
                 { "unit",              required_argument, NULL, ARG_UNIT        },
572a44
                 { "description",       required_argument, NULL, ARG_DESCRIPTION },
572a44
@@ -103,6 +105,10 @@ static int parse_argv(int argc, char *argv[]) {
572a44
                         arg_user = true;
572a44
                         break;
572a44
 
572a44
+                case ARG_SYSTEM:
572a44
+                        arg_user = false;
572a44
+                        break;
572a44
+
572a44
                 case ARG_SCOPE:
572a44
                         arg_scope = true;
572a44
                         break;
572a44
@@ -333,12 +339,12 @@ int main(int argc, char* argv[]) {
572a44
 
572a44
         r = parse_argv(argc, argv);
572a44
         if (r <= 0)
572a44
-                goto fail;
572a44
+                goto finish;
572a44
 
572a44
         r = find_binary(argv[optind], &command);
572a44
         if (r < 0) {
572a44
                 log_error("Failed to find executable %s: %s", argv[optind], strerror(-r));
572a44
-                goto fail;
572a44
+                goto finish;
572a44
         }
572a44
         argv[optind] = command;
572a44
 
572a44
@@ -346,7 +352,7 @@ int main(int argc, char* argv[]) {
572a44
                 description = strv_join(argv + optind, " ");
572a44
                 if (!description) {
572a44
                         r = log_oom();
572a44
-                        goto fail;
572a44
+                        goto finish;
572a44
                 }
572a44
 
572a44
                 arg_description = description;
572a44
@@ -357,8 +363,8 @@ int main(int argc, char* argv[]) {
572a44
         else
572a44
                 r = sd_bus_open_system(&bus;;
572a44
         if (r < 0) {
572a44
-                log_error("Failed to create new bus connection: %s", strerror(-r));
572a44
-                goto fail;
572a44
+                log_error("Failed to create bus connection: %s", strerror(-r));
572a44
+                goto finish;
572a44
         }
572a44
 
572a44
         if (arg_scope)
572a44
@@ -368,9 +374,9 @@ int main(int argc, char* argv[]) {
572a44
         if (r < 0) {
572a44
                 log_error("Failed start transient unit: %s", error.message ? error.message : strerror(-r));
572a44
                 sd_bus_error_free(&error);
572a44
-                goto fail;
572a44
+                goto finish;
572a44
         }
572a44
 
572a44
-fail:
572a44
+finish:
572a44
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
572a44
 }