[systemd-commits] 3 commits - TODO man/systemctl.xml src/shared src/systemctl src/test

Lennart Poettering lennart at kemper.freedesktop.org
Fri May 3 10:06:42 PDT 2013


 TODO                        |    2 -
 man/systemctl.xml           |    9 +++++++
 src/shared/cgroup-util.c    |    7 +++++-
 src/systemctl/systemctl.c   |   50 +++++++++++++++++++++++++++++---------------
 src/test/test-cgroup-util.c |    4 +++
 5 files changed, 53 insertions(+), 19 deletions(-)

New commits:
commit a0ab566574303be1ca12cdb334f284cfd407caa5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 3 19:02:24 2013 +0200

    cgroup: when escaping a cgroup object name, also escape names that start with a dot

diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index c5a5f8d..43c415d 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1527,7 +1527,12 @@ char *cg_escape(const char *p) {
         /* The return value of this function (unlike cg_unescape())
          * needs free()! */
 
-        if (p[0] == '_' || streq(p, "notify_on_release") || streq(p, "release_agent") || streq(p, "tasks"))
+        if (p[0] == 0 ||
+            p[0] == '_' ||
+            p[0] == '.' ||
+            streq(p, "notify_on_release") ||
+            streq(p, "release_agent") ||
+            streq(p, "tasks"))
                 need_prefix = true;
         else {
                 const char *dot;
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
index cc1a6fd..c9634d4 100644
--- a/src/test/test-cgroup-util.c
+++ b/src/test/test-cgroup-util.c
@@ -146,11 +146,15 @@ static void test_escape_one(const char *s, const char *r) {
 
 static void test_escape(void) {
         test_escape_one("foobar", "foobar");
+        test_escape_one(".foobar", "_.foobar");
         test_escape_one("foobar.service", "foobar.service");
         test_escape_one("cgroup.service", "_cgroup.service");
         test_escape_one("cpu.service", "_cpu.service");
         test_escape_one("tasks", "_tasks");
         test_escape_one("_foobar", "__foobar");
+        test_escape_one("", "_");
+        test_escape_one("_", "__");
+        test_escape_one(".", "_.");
 }
 
 static void test_controller_is_valid(void) {

commit 4641a16b15a0e50b61259316b3fda43e0b48f7d5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 3 18:58:44 2013 +0200

    update TODO

diff --git a/TODO b/TODO
index eb00fba..087017f 100644
--- a/TODO
+++ b/TODO
@@ -635,7 +635,7 @@ External:
 
 * neither pkexec nor sudo initialize environ[] from the PAM environment?
 
-* fedora: update policy to declare access mode and ownership of unit files, and add an rpmlint check for it
+* fedora: update policy to declare access mode and ownership of unit files to root:root 0644, and add an rpmlint check for it
 
 Regularly:
 

commit 5d0c05e5f417325e8505dde857a93a88eb7ebdc0
Author: Lukas Nykryn <lnykryn at redhat.com>
Date:   Fri May 3 12:52:19 2013 +0200

    systemctl: add --plain option to list-dependencies
    
    This patch adds more script-friendly output for list-dependencies.

diff --git a/man/systemctl.xml b/man/systemctl.xml
index 2739df6..27eabf2 100644
--- a/man/systemctl.xml
+++ b/man/systemctl.xml
@@ -493,6 +493,15 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--plain</option></term>
+
+        <listitem>
+          <para>When used with <command>list-dependencies</command>
+          the output is printed as a list instead of a tree.</para>
+        </listitem>
+      </varlistentry>
+
     </variablelist>
   </refsect1>
 
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index f9a03ca..1905d0c 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -132,6 +132,7 @@ static enum transport {
 static const char *arg_host = NULL;
 static unsigned arg_lines = 10;
 static OutputMode arg_output = OUTPUT_SHORT;
+static bool arg_plain = false;
 
 static bool private_bus = false;
 
@@ -956,20 +957,22 @@ static int list_dependencies_print(const char *name, int level, unsigned int bra
         size_t len = 0;
         size_t max_len = MAX(columns(),20u);
 
-        for (i = level - 1; i >= 0; i--) {
+        if (!arg_plain) {
+                for (i = level - 1; i >= 0; i--) {
+                        len += 2;
+                        if(len > max_len - 3 && !arg_full) {
+                                printf("%s...\n",max_len % 2 ? "" : " ");
+                                return 0;
+                        }
+                        printf("%s", draw_special_char(branches & (1 << i) ? DRAW_TREE_VERT : DRAW_TREE_SPACE));
+                }
                 len += 2;
                 if(len > max_len - 3 && !arg_full) {
                         printf("%s...\n",max_len % 2 ? "" : " ");
                         return 0;
                 }
-                printf("%s", draw_special_char(branches & (1 << i) ? DRAW_TREE_VERT : DRAW_TREE_SPACE));
-        }
-        len += 2;
-        if(len > max_len - 3 && !arg_full) {
-                printf("%s...\n",max_len % 2 ? "" : " ");
-                return 0;
+                printf("%s", draw_special_char(last ? DRAW_TREE_RIGHT : DRAW_TREE_BRANCH));
         }
-        printf("%s", draw_special_char(last ? DRAW_TREE_RIGHT : DRAW_TREE_BRANCH));
 
         if(arg_full){
                 printf("%s\n", name);
@@ -1105,12 +1108,12 @@ static int list_dependencies_compare(const void *_a, const void *_b) {
         return strcasecmp(*a, *b);
 }
 
-static int list_dependencies_one(DBusConnection *bus, const char *name, int level, char **units, unsigned int branches) {
+static int list_dependencies_one(DBusConnection *bus, const char *name, int level, char ***units, unsigned int branches) {
         _cleanup_strv_free_ char **deps = NULL, **u;
         char **c;
         int r = 0;
 
-        u = strv_append(units, name);
+        u = strv_append(*units, name);
         if (!u)
                 return log_oom();
 
@@ -1122,9 +1125,11 @@ static int list_dependencies_one(DBusConnection *bus, const char *name, int leve
 
         STRV_FOREACH(c, deps) {
                 if (strv_contains(u, *c)) {
-                        r = list_dependencies_print("...", level + 1, (branches << 1) | (c[1] == NULL ? 0 : 1), 1);
-                        if (r < 0)
-                                return r;
+                        if (!arg_plain) {
+                                r = list_dependencies_print("...", level + 1, (branches << 1) | (c[1] == NULL ? 0 : 1), 1);
+                                if (r < 0)
+                                        return r;
+                        }
                         continue;
                 }
 
@@ -1133,17 +1138,22 @@ static int list_dependencies_one(DBusConnection *bus, const char *name, int leve
                         return r;
 
                 if (arg_all || unit_name_to_type(*c) == UNIT_TARGET) {
-                       r = list_dependencies_one(bus, *c, level + 1, u, (branches << 1) | (c[1] == NULL ? 0 : 1));
+                       r = list_dependencies_one(bus, *c, level + 1, &u, (branches << 1) | (c[1] == NULL ? 0 : 1));
                        if(r < 0)
                                return r;
                 }
         }
-
+        if (arg_plain) {
+                strv_free(*units);
+                *units = u;
+                u = NULL;
+        }
         return 0;
 }
 
 static int list_dependencies(DBusConnection *bus, char **args) {
         _cleanup_free_ char *unit = NULL;
+        _cleanup_strv_free_ char **units = NULL;
         const char *u;
 
         assert(bus);
@@ -1160,7 +1170,7 @@ static int list_dependencies(DBusConnection *bus, char **args) {
 
         puts(u);
 
-        return list_dependencies_one(bus, u, 0, NULL, 0);
+        return list_dependencies_one(bus, u, 0, &units, 0);
 }
 
 struct job_info {
@@ -4717,7 +4727,8 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 ARG_NO_ASK_PASSWORD,
                 ARG_FAILED,
                 ARG_RUNTIME,
-                ARG_FORCE
+                ARG_FORCE,
+                ARG_PLAIN
         };
 
         static const struct option options[] = {
@@ -4755,6 +4766,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 { "runtime",   no_argument,       NULL, ARG_RUNTIME   },
                 { "lines",     required_argument, NULL, 'n'           },
                 { "output",    required_argument, NULL, 'o'           },
+                { "plain",     no_argument,       NULL, ARG_PLAIN     },
                 { NULL,        0,                 NULL, 0             }
         };
 
@@ -4982,6 +4994,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         arg_ignore_inhibitors = true;
                         break;
 
+                case ARG_PLAIN:
+                        arg_plain = true;
+                        break;
+
                 case '?':
                         return -EINVAL;
 



More information about the systemd-commits mailing list