dryang / rpms / systemd

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