valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0089-run-support-system-to-match-other-commands-even-if-r.patch

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