<p dir="ltr">Nice, I was in the process of implementing this. Looks good to me. But I think it would be better to use "vi" instead of "vim" if no &editor is set. Vim is not installed on every system as default but vi is most likely.</p>
<div class="gmail_quote">Den 11/10/2014 18.37 skrev "Ronny Chevalier" <<a href="mailto:chevalier.ronny@gmail.com">chevalier.ronny@gmail.com</a>>:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It helps editing units by either creating a drop-in file, like<br>
/etc/systemd/system/my.service.d/amendments.conf, or by copying the<br>
original unit from /usr/lib/systemd/ to /etc/systemd/ if the --full<br>
option is specified. Then it invokes the $SYSTEMD_EDITOR or $EDITOR or<br>
vim to the related files and daemon-reload is invoked when the editor exited<br>
successfully.<br>
<br>
See <a href="https://bugzilla.redhat.com/show_bug.cgi?id=906824" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=906824</a><br>
---<br>
 TODO                      |   2 -<br>
 man/journalctl.xml        |   6 +-<br>
 man/less-variables.xml    |  40 +++---<br>
 man/localectl.xml         |   6 +-<br>
 man/loginctl.xml          |   6 +-<br>
 man/machinectl.xml        |   6 +-<br>
 man/systemctl.xml         |  44 +++++-<br>
 man/systemd-analyze.xml   |   6 +-<br>
 man/timedatectl.xml       |   6 +-<br>
 src/systemctl/systemctl.c | 346 +++++++++++++++++++++++++++++++++++++++++++++-<br>
 10 files changed, 435 insertions(+), 33 deletions(-)<br>
<br>
diff --git a/TODO b/TODO<br>
index 0aaa9f2..857bdd0 100644<br>
--- a/TODO<br>
+++ b/TODO<br>
@@ -65,8 +65,6 @@ Features:<br>
<br>
 * systemctl: if it fails, show log output?<br>
<br>
-* maybe add "systemctl edit" that copies unit files from /usr/lib/systemd/system to /etc/systemd/system and invokes vim on them<br>
-<br>
 * dbus: add new message hdr field for allowing interactive auth, write spec for it. update dbus spec to mandate that unknown flags *must* be ignored...<br>
<br>
 * maybe introduce AssertXYZ= similar to ConditionXYZ= that causes a unit to fail (instead of skipping it) if some condition is not true...<br>
diff --git a/man/journalctl.xml b/man/journalctl.xml<br>
index 7fb6afc..d36889f 100644<br>
--- a/man/journalctl.xml<br>
+++ b/man/journalctl.xml<br>
@@ -891,7 +891,11 @@<br>
                 failure code is returned.</para><br>
         </refsect1><br>
<br>
-        <xi:include href="less-variables.xml" /><br>
+        <refsect1><br>
+                <title>Environment</title><br>
+<br>
+                <xi:include href="less-variables.xml" /><br>
+        </refsect1><br>
<br>
         <refsect1><br>
                 <title>Examples</title><br>
diff --git a/man/less-variables.xml b/man/less-variables.xml<br>
index 09cbd42..1b8aae0 100644<br>
--- a/man/less-variables.xml<br>
+++ b/man/less-variables.xml<br>
@@ -2,28 +2,24 @@<br>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"<br>
                  "<a href="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" target="_blank">http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd</a>"><br>
<br>
-<refsect1><br>
-        <title>Environment</title><br>
+<variablelist class='environment-variables'><br>
+       <varlistentry><br>
+               <term><varname>$SYSTEMD_PAGER</varname></term><br>
<br>
-        <variablelist class='environment-variables'><br>
-                <varlistentry><br>
-                        <term><varname>$SYSTEMD_PAGER</varname></term><br>
+               <listitem><para>Pager to use when<br>
+               <option>--no-pager</option> is not given;<br>
+               overrides <varname>$PAGER</varname>.  Setting<br>
+               this to an empty string or the value<br>
+               <literal>cat</literal> is equivalent to passing<br>
+               <option>--no-pager</option>.</para></listitem><br>
+       </varlistentry><br>
<br>
-                        <listitem><para>Pager to use when<br>
-                        <option>--no-pager</option> is not given;<br>
-                        overrides <varname>$PAGER</varname>.  Setting<br>
-                        this to an empty string or the value<br>
-                        <literal>cat</literal> is equivalent to passing<br>
-                        <option>--no-pager</option>.</para></listitem><br>
-                </varlistentry><br>
+       <varlistentry><br>
+               <term><varname>$SYSTEMD_LESS</varname></term><br>
<br>
-                <varlistentry><br>
-                        <term><varname>$SYSTEMD_LESS</varname></term><br>
-<br>
-                        <listitem><para>Override the default<br>
-                        options passed to<br>
-                        <command>less</command><br>
-                        (<literal>FRSXMK</literal>).</para></listitem><br>
-                </varlistentry><br>
-        </variablelist><br>
-</refsect1><br>
+               <listitem><para>Override the default<br>
+               options passed to<br>
+               <command>less</command><br>
+               (<literal>FRSXMK</literal>).</para></listitem><br>
+       </varlistentry><br>
+</variablelist><br>
diff --git a/man/localectl.xml b/man/localectl.xml<br>
index 38e73c7..7ae6c60 100644<br>
--- a/man/localectl.xml<br>
+++ b/man/localectl.xml<br>
@@ -223,7 +223,11 @@<br>
                 code otherwise.</para><br>
         </refsect1><br>
<br>
-        <xi:include href="less-variables.xml" /><br>
+        <refsect1><br>
+                <title>Environment</title><br>
+<br>
+                <xi:include href="less-variables.xml" /><br>
+        </refsect1><br>
<br>
         <refsect1><br>
                 <title>See Also</title><br>
diff --git a/man/loginctl.xml b/man/loginctl.xml<br>
index 749db92..4754790 100644<br>
--- a/man/loginctl.xml<br>
+++ b/man/loginctl.xml<br>
@@ -438,7 +438,11 @@<br>
                 code otherwise.</para><br>
         </refsect1><br>
<br>
-        <xi:include href="less-variables.xml" /><br>
+        <refsect1><br>
+                <title>Environment</title><br>
+<br>
+                <xi:include href="less-variables.xml" /><br>
+        </refsect1><br>
<br>
         <refsect1><br>
                 <title>See Also</title><br>
diff --git a/man/machinectl.xml b/man/machinectl.xml<br>
index 2f2e257..b95b7fe 100644<br>
--- a/man/machinectl.xml<br>
+++ b/man/machinectl.xml<br>
@@ -281,7 +281,11 @@<br>
                 code otherwise.</para><br>
         </refsect1><br>
<br>
-        <xi:include href="less-variables.xml" /><br>
+        <refsect1><br>
+                <title>Environment</title><br>
+<br>
+                <xi:include href="less-variables.xml" /><br>
+        </refsect1><br>
<br>
         <refsect1><br>
                 <title>See Also</title><br>
diff --git a/man/systemctl.xml b/man/systemctl.xml<br>
index 61a23de..34f689b 100644<br>
--- a/man/systemctl.xml<br>
+++ b/man/systemctl.xml<br>
@@ -1150,6 +1150,31 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service<br>
             <filename>default.target</filename> to the given unit.</para><br>
           </listitem><br>
         </varlistentry><br>
+<br>
+        <varlistentry><br>
+          <term><command>edit <replaceable>NAME</replaceable>...</command></term><br>
+<br>
+          <listitem><br>
+            <para>Edit one or more unit files, as specified on the command<br>
+            line.</para><br>
+<br>
+            <para>Depending on whether <option>--system</option> (the default),<br>
+            <option>--user</option>, or <option>--global</option> is specified,<br>
+            this create a drop-in file for each units either for the system,<br>
+            for the calling user or for all futures logins of all users. Then<br>
+            the editor is invoked on them (see section "Environment" below).</para><br>
+<br>
+            <para>If <option>--full</option> is specified, this will copy the original<br>
+            units instead of creating drop-in files.</para><br>
+<br>
+            <para>After the units have been edited, the systemd configuration is<br>
+            reloaded (in a way that is equivalent to <command>daemon-reload</command>),<br>
+            but it does not restart or reload the units.</para><br>
+<br>
+            <para>Note that this command cannot be used with <option>--runtime</option> or<br>
+            to remotely edit units.</para><br>
+          </listitem><br>
+        </varlistentry><br>
       </variablelist><br>
     </refsect2><br>
<br>
@@ -1559,7 +1584,22 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service<br>
     code otherwise.</para><br>
   </refsect1><br>
<br>
-  <xi:include href="less-variables.xml" /><br>
+  <refsect1><br>
+    <title>Environment</title><br>
+<br>
+    <variablelist class='environment-variables'><br>
+      <varlistentry><br>
+        <term><varname>$SYSTEMD_EDITOR</varname></term><br>
+<br>
+        <listitem><para>Editor to use when editing units; overrides<br>
+        <varname>$EDITOR</varname>. If neither <varname>$SYSTEMD_EDITOR</varname><br>
+        nor <varname>$EDITOR</varname> are present or if it is set to an empty string,<br>
+        <citerefentry><refentrytitle>vim</refentrytitle><manvolnum>1</manvolnum></citerefentry><br>
+        is used as default.</para></listitem><br>
+      </varlistentry><br>
+    </variablelist><br>
+    <xi:include href="less-variables.xml" /><br>
+  </refsect1><br>
<br>
   <refsect1><br>
     <title>See Also</title><br>
@@ -1572,7 +1612,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service<br>
       <citerefentry><refentrytitle>systemd.resource-management</refentrytitle><manvolnum>5</manvolnum></citerefentry>,<br>
       <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,<br>
       <citerefentry project='man-pages'><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry>,<br>
-      <citerefentry><refentrytitle>systemd.preset</refentrytitle><manvolnum>5</manvolnum></citerefentry><br>
+      <citerefentry><refentrytitle>systemd.preset</refentrytitle><manvolnum>5</manvolnum></citerefentry>,<br>
       <citerefentry><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry><br>
     </para><br>
   </refsect1><br>
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml<br>
index 073e807..0dd21a5 100644<br>
--- a/man/systemd-analyze.xml<br>
+++ b/man/systemd-analyze.xml<br>
@@ -383,7 +383,11 @@ Service b@0.service not loaded, b.socket cannot be started.<br>
                 </example><br>
         </refsect1><br>
<br>
-        <xi:include href="less-variables.xml" /><br>
+        <refsect1><br>
+                <title>Environment</title><br>
+<br>
+                <xi:include href="less-variables.xml" /><br>
+        </refsect1><br>
<br>
         <refsect1><br>
                 <title>See Also</title><br>
diff --git a/man/timedatectl.xml b/man/timedatectl.xml<br>
index f3edb8d..849cc06 100644<br>
--- a/man/timedatectl.xml<br>
+++ b/man/timedatectl.xml<br>
@@ -197,7 +197,11 @@<br>
                 code otherwise.</para><br>
         </refsect1><br>
<br>
-        <xi:include href="less-variables.xml" /><br>
+        <refsect1><br>
+                <title>Environment</title><br>
+<br>
+                <xi:include href="less-variables.xml" /><br>
+        </refsect1><br>
<br>
         <refsect1><br>
                 <title>Examples</title><br>
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c<br>
index 8d6d162..1c2e5a9 100644<br>
--- a/src/systemctl/systemctl.c<br>
+++ b/src/systemctl/systemctl.c<br>
@@ -72,6 +72,8 @@<br>
 #include "bus-message.h"<br>
 #include "bus-error.h"<br>
 #include "bus-errors.h"<br>
+#include "copy.h"<br>
+#include "mkdir.h"<br>
<br>
 static char **arg_types = NULL;<br>
 static char **arg_states = NULL;<br>
@@ -5535,6 +5537,346 @@ static int is_system_running(sd_bus *bus, char **args) {<br>
         return streq(state, "running") ? EXIT_SUCCESS : EXIT_FAILURE;<br>
 }<br>
<br>
+static int unit_file_find_path(LookupPaths *lp, const char *unit_name, char **unit_path) {<br>
+        char **p;<br>
+<br>
+        assert(lp);<br>
+        assert(unit_name);<br>
+        assert(unit_path);<br>
+<br>
+        STRV_FOREACH(p, lp->unit_path) {<br>
+                char *path;<br>
+<br>
+                path = strjoin(*p, "/", unit_name, NULL);<br>
+                if (!path)<br>
+                        return log_oom();<br>
+<br>
+                if (access(path, F_OK) == 0) {<br>
+                        *unit_path = path;<br>
+                        return 1;<br>
+                }<br>
+<br>
+                free(path);<br>
+        }<br>
+<br>
+        return 0;<br>
+}<br>
+<br>
+static int unit_file_drop_in(const char *unit_name, const char *config_home, char **new_path) {<br>
+        char *tmp_path;<br>
+        int r;<br>
+<br>
+        assert(unit_name);<br>
+        assert(new_path);<br>
+<br>
+        switch (arg_scope) {<br>
+                case UNIT_FILE_SYSTEM:<br>
+                        tmp_path = strjoin(SYSTEM_CONFIG_UNIT_PATH, "/", unit_name, ".d/amendments.conf", NULL);<br>
+                        break;<br>
+                case UNIT_FILE_GLOBAL:<br>
+                        tmp_path = strjoin(USER_CONFIG_UNIT_PATH, "/", unit_name, ".d/amendments.conf", NULL);<br>
+                        break;<br>
+                case UNIT_FILE_USER:<br>
+                        assert(config_home);<br>
+                        tmp_path = strjoin(config_home, "/", unit_name, ".d/amendments.conf", NULL);<br>
+                        break;<br>
+                default:<br>
+                        assert_not_reached("Invalid scope");<br>
+        }<br>
+        if (!tmp_path)<br>
+                return log_oom();<br>
+<br>
+        r = mkdir_parents(tmp_path, 0755);<br>
+        if (r < 0) {<br>
+                log_error("Failed to create directories for %s: %s", tmp_path, strerror(-r));<br>
+                free(tmp_path);<br>
+                return r;<br>
+        }<br>
+<br>
+        *new_path = tmp_path;<br>
+<br>
+        return 0;<br>
+}<br>
+<br>
+static int unit_file_copy_if_needed(const char *unit_name, const char *fragment_path, char **new_path) {<br>
+        char *tmp_path;<br>
+        int r;<br>
+<br>
+        assert(fragment_path);<br>
+        assert(unit_name);<br>
+        assert(new_path);<br>
+<br>
+        /* If it's a unit for the --user scope there is no need to copy it, it's already in the right directory.<br>
+         * Same if this is --system/--global scope and the file is in {SYSTEM,USER}_CONFIG_UNIT_PATH<br>
+         */<br>
+        if (arg_scope == UNIT_FILE_USER<br>
+            || startswith(fragment_path, SYSTEM_CONFIG_UNIT_PATH)<br>
+            || startswith(fragment_path, USER_CONFIG_UNIT_PATH)) {<br>
+                *new_path = strdup(fragment_path);<br>
+                if (!*new_path)<br>
+                        return log_oom();<br>
+                return 0;<br>
+        }<br>
+<br>
+        switch (arg_scope) {<br>
+                case UNIT_FILE_SYSTEM:<br>
+                        tmp_path = strjoin(SYSTEM_CONFIG_UNIT_PATH, "/", unit_name, NULL);<br>
+                        break;<br>
+                case UNIT_FILE_GLOBAL:<br>
+                        tmp_path = strjoin(USER_CONFIG_UNIT_PATH, "/", unit_name, NULL);<br>
+                        break;<br>
+                default:<br>
+                        assert_not_reached("Invalid scope");<br>
+        }<br>
+        if (!tmp_path)<br>
+                return log_oom();<br>
+<br>
+        if (access(tmp_path, F_OK) == 0) {<br>
+                char response;<br>
+<br>
+                r = ask_char(&response, "yn", "%s already exists, are you sure to overwrite it with %s? [(y)es, (n)o] ", tmp_path, fragment_path);<br>
+                if (r < 0) {<br>
+                        free(tmp_path);<br>
+                        return r;<br>
+                }<br>
+                if (response != 'y') {<br>
+                        log_warning("%s ignored", unit_name);<br>
+                        free(tmp_path);<br>
+                        return -1;<br>
+                }<br>
+        }<br>
+<br>
+        r = mkdir_parents(tmp_path, 0755);<br>
+        if (r < 0) {<br>
+                log_error("Failed to create directories for %s: %s", tmp_path, strerror(-r));<br>
+                free(tmp_path);<br>
+                return r;<br>
+        }<br>
+<br>
+        r = copy_file(fragment_path, tmp_path, 0, 0644);<br>
+        if (r < 0) {<br>
+                log_error("Failed to copy %s to %s: %s", fragment_path, tmp_path, strerror(-r));<br>
+                free(tmp_path);<br>
+                return r;<br>
+        }<br>
+<br>
+        *new_path = tmp_path;<br>
+<br>
+        return 0;<br>
+}<br>
+<br>
+static int run_editor(char **paths) {<br>
+        _cleanup_strv_free_ char **args = NULL;<br>
+        char *editor;<br>
+        pid_t pid;<br>
+        siginfo_t status;<br>
+        int r;<br>
+<br>
+        assert(paths);<br>
+<br>
+        args = strv_copy(paths);<br>
+        if (!args)<br>
+                return log_oom();<br>
+<br>
+        /* SYSTEMD_EDITOR takes precedence over EDITOR<br>
+         * If neither SYSTEMD_EDITOR nor EDITOR are present, we use vim as default<br>
+         */<br>
+        editor = getenv("SYSTEMD_EDITOR");<br>
+        if (!editor)<br>
+                editor = getenv("EDITOR");<br>
+<br>
+        if (!editor || isempty(editor))<br>
+                editor = strdup("vim");<br>
+        else<br>
+                editor = strdup(editor);<br>
+        if (!editor)<br>
+                return log_oom();<br>
+<br>
+        r = strv_push_prepend(&args, editor);<br>
+        if (r < 0)<br>
+                return log_oom();<br>
+<br>
+        pid = fork();<br>
+        if (pid < 0) {<br>
+                log_error("Failed to fork: %m");<br>
+                return -errno;<br>
+        }<br>
+<br>
+        if (pid == 0) {<br>
+                execvp(editor, args);<br>
+                log_error("Failed to execute %s: %m", editor);<br>
+                _exit(EXIT_FAILURE);<br>
+        }<br>
+<br>
+        r = wait_for_terminate(pid, &status);<br>
+        if (r < 0) {<br>
+                log_error("Failed to wait for child: %s", strerror(-r));<br>
+                return r;<br>
+        }<br>
+<br>
+        return WIFEXITED(status) ? WEXITSTATUS(status) : -1;<br>
+}<br>
+<br>
+static int find_units_path(sd_bus *bus, char **names, char ***paths) {<br>
+        _cleanup_free_ char *config_home = NULL;<br>
+        _cleanup_free_ char *unit = NULL;<br>
+        char **name;<br>
+        int r;<br>
+<br>
+        assert(names);<br>
+        assert(paths);<br>
+<br>
+        if (arg_scope == UNIT_FILE_USER) {<br>
+                r = user_config_home(&config_home);<br>
+                if (r < 0)<br>
+                        return log_oom();<br>
+<br>
+                if (r == 0) {<br>
+                        log_error("Cannot edit units for the user instance: home directory unknown");<br>
+                        return -1;<br>
+                }<br>
+        }<br>
+<br>
+        if (!bus || avoid_bus()) {<br>
+                _cleanup_lookup_paths_free_ LookupPaths lp = {};<br>
+<br>
+                /* If there is no bus, we try to find the units by testing each available directory<br>
+                 * according to the scope.<br>
+                 */<br>
+                r = lookup_paths_init(&lp,<br>
+                                arg_scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER,<br>
+                                arg_scope == UNIT_FILE_USER,<br>
+                                arg_root,<br>
+                                NULL, NULL, NULL);<br>
+                if (r < 0) {<br>
+                        log_error("Cannot get lookup paths: %s", strerror(-r));<br>
+                        return r;<br>
+                }<br>
+<br>
+                STRV_FOREACH(name, names) {<br>
+                        _cleanup_free_ char *path = NULL;<br>
+                        char *new_path;<br>
+<br>
+                        r = unit_file_find_path(&lp, *name, &path);<br>
+                        if (r < 0)<br>
+                                return r;<br>
+                        if (r == 0) {<br>
+                                log_warning("%s ignored: not found", *name);<br>
+                                continue;<br>
+                        }<br>
+<br>
+                        if (arg_full)<br>
+                                r = unit_file_copy_if_needed(*name, path, &new_path);<br>
+                        else<br>
+                                r = unit_file_drop_in(*name, config_home, &new_path);<br>
+<br>
+                        if (r < 0)<br>
+                                continue;<br>
+<br>
+                        r = strv_push(paths, new_path);<br>
+                        if (r < 0)<br>
+                                return log_oom();<br>
+                }<br>
+        } else {<br>
+                STRV_FOREACH(name, names) {<br>
+                        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;<br>
+                        _cleanup_free_ char *fragment_path = NULL;<br>
+                        char *new_path;<br>
+<br>
+                        unit = unit_dbus_path_from_name(*name);<br>
+                        if (!unit)<br>
+                                return log_oom();<br>
+<br>
+                        if (need_daemon_reload(bus, *name) > 0) {<br>
+                                log_warning("%s ignored: unit file changed on disk. Run 'systemctl%s daemon-reload'.",<br>
+                                        *name, arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");<br>
+                                continue;<br>
+                        }<br>
+<br>
+                        r = sd_bus_get_property_string(<br>
+                                        bus,<br>
+                                        "org.freedesktop.systemd1",<br>
+                                        unit,<br>
+                                        "org.freedesktop.systemd1.Unit",<br>
+                                        "FragmentPath",<br>
+                                        &error,<br>
+                                        &fragment_path);<br>
+                        if (r < 0) {<br>
+                                log_warning("Failed to get FragmentPath: %s", bus_error_message(&error, r));<br>
+                                continue;<br>
+                        }<br>
+<br>
+                        if (isempty(fragment_path)) {<br>
+                                log_warning("%s ignored: not found", *name);<br>
+                                continue;<br>
+                        }<br>
+<br>
+                        if (arg_full)<br>
+                                r = unit_file_copy_if_needed(*name, fragment_path, &new_path);<br>
+                        else<br>
+                                r = unit_file_drop_in(*name, config_home, &new_path);<br>
+                        if (r < 0)<br>
+                                continue;<br>
+<br>
+                        r = strv_push(paths, new_path);<br>
+                        if (r < 0)<br>
+                                return log_oom();<br>
+                }<br>
+        }<br>
+<br>
+        return 0;<br>
+}<br>
+<br>
+static int edit(sd_bus *bus, char **args) {<br>
+        _cleanup_strv_free_ char **names = NULL;<br>
+        _cleanup_strv_free_ char **paths = NULL;<br>
+        int r;<br>
+<br>
+        assert(args);<br>
+<br>
+        if (!on_tty())<br>
+                return 0;<br>
+<br>
+        if (arg_transport != BUS_TRANSPORT_LOCAL) {<br>
+                log_error("Cannot remotely edit units");<br>
+                return -EINVAL;<br>
+        }<br>
+<br>
+        if (arg_runtime) {<br>
+                log_error("Cannot edit runtime units");<br>
+                return -EINVAL;<br>
+        }<br>
+<br>
+        r = expand_names(bus, args + 1, NULL, &names);<br>
+        if (r < 0) {<br>
+                log_error("Failed to expand names: %s", strerror(-r));<br>
+                return r;<br>
+        }<br>
+<br>
+        if (!names) {<br>
+                log_error("No unit name found by expanding names");<br>
+                return -ENOENT;<br>
+        }<br>
+<br>
+        r = find_units_path(bus, names, &paths);<br>
+        if (r < 0)<br>
+                return r;<br>
+<br>
+        if (strv_isempty(paths)) {<br>
+                log_error("Cannot find any units to edit");<br>
+                return -ENOENT;<br>
+        }<br>
+<br>
+        r = run_editor(paths);<br>
+        if (r < 0)<br>
+                return r;<br>
+<br>
+        if (!arg_no_reload)<br>
+                r = daemon_reload(bus, args);<br>
+<br>
+        return r;<br>
+}<br>
+<br>
 static void systemctl_help(void) {<br>
<br>
         pager_open_if_enabled();<br>
@@ -5632,7 +5974,8 @@ static void systemctl_help(void) {<br>
                "  add-requires TARGET NAME...     Add 'Requires' dependency for the target\n"<br>
                "                                  on specified one or more units\n"<br>
                "  get-default                     Get the name of the default target\n"<br>
-               "  set-default NAME                Set the default target\n\n"<br>
+               "  set-default NAME                Set the default target\n"<br>
+               "  edit NAME...                    Edit one or more unit files\n\n"<br>
                "Machine Commands:\n"<br>
                "  list-machines [PATTERN...]      List local containers and host\n\n"<br>
                "Job Commands:\n"<br>
@@ -6643,6 +6986,7 @@ static int systemctl_main(sd_bus *bus, int argc, char *argv[], int bus_error) {<br>
                 { "is-system-running",     EQUAL, 1, is_system_running },<br>
                 { "add-wants",             MORE,  3, add_dependency,        NOBUS },<br>
                 { "add-requires",          MORE,  3, add_dependency,        NOBUS },<br>
+                { "edit",                  MORE,  2, edit,             NOBUS },<br>
                 {}<br>
         }, *verb = verbs;<br>
<br>
--<br>
2.1.2<br>
<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div>