[systemd-commits] 3 commits - shell-completion/bash src/core src/shared src/test

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sun Jul 27 12:27:31 PDT 2014


 shell-completion/bash/systemctl.in |   13 ++++++++++++-
 src/core/namespace.c               |    3 +--
 src/shared/util.c                  |    4 ++--
 src/test/test-util.c               |    1 +
 4 files changed, 16 insertions(+), 5 deletions(-)

New commits:
commit c317a1a19cd9584e07ee43f1b6fafc26c2c75cca
Author: Eric Cook <llua at gmx.com>
Date:   Sun Jul 27 15:07:03 2014 -0400

    shell-completion: prevent mangling unit names (bash)
    
    This fixes the issue noted by Zbigniew in most cases.
    if a unit's name is enclosed in single quotes completion still
    will not happen after the first `\'.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=78388

diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in
index 69ef04b..64b15df 100644
--- a/shell-completion/bash/systemctl.in
+++ b/shell-completion/bash/systemctl.in
@@ -158,20 +158,25 @@ _systemctl () {
 
         elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then
                 comps=$( __get_all_units $mode )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[ENABLED_UNITS]}; then
                 comps=$( __get_enabled_units $mode )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then
                 comps=$( __get_disabled_units $mode )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[REENABLABLE_UNITS]}; then
                 comps=$( __get_disabled_units $mode;
                          __get_enabled_units $mode )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then
                 comps=$( __filter_units_by_property $mode CanStart yes \
                       $( __get_startable_units $mode))
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then
                 comps=$( __filter_units_by_property $mode CanStart yes \
@@ -179,24 +184,30 @@ _systemctl () {
                         | while read -r line; do \
                                 [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || echo " $line"; \
                         done ))
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then
                 comps=$( __filter_units_by_property $mode CanStop yes \
                       $( __get_active_units $mode ) )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[RELOADABLE_UNITS]}; then
                 comps=$( __filter_units_by_property $mode CanReload yes \
                       $( __get_active_units $mode ) )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[ISOLATABLE_UNITS]}; then
                 comps=$( __filter_units_by_property $mode AllowIsolate yes \
                       $( __get_all_units $mode ) )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[FAILED_UNITS]}; then
                 comps=$( __get_failed_units $mode )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[MASKED_UNITS]}; then
                 comps=$( __get_masked_units $mode )
+                compopt -o filenames
 
         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[NAME]}; then
                 comps=''
@@ -221,7 +232,7 @@ _systemctl () {
                         | { while read -r a b; do echo " $a"; done; } )
         fi
 
-        COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
+        COMPREPLY=( $(compgen -o filenames -W '$comps' -- "$cur") )
         return 0
 }
 

commit e2d7c1a0758ce80d7cb439745deefefdffd67655
Author: Ansgar Burchardt <ansgar at debian.org>
Date:   Sun Jul 27 16:32:13 2014 +0200

    drop_duplicates: copy full BindMount struct
    
    At least
    
      t->ignore = f->ignore;
    
    is missing here. Just copy the full struct to be sure.

diff --git a/src/core/namespace.c b/src/core/namespace.c
index 5466b7b..fe95377 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -124,8 +124,7 @@ static void drop_duplicates(BindMount *m, unsigned *n) {
                 if (previous && path_equal(f->path, previous->path))
                         continue;
 
-                t->path = f->path;
-                t->mode = f->mode;
+                *t = *f;
 
                 previous = t;
 

commit 0f625d0b87139fc18cd565c9b6da05c53a0eb7ab
Author: Ansgar Burchardt <ansgar at debian.org>
Date:   Sun Jul 27 15:19:00 2014 +0200

    parse_boolean: require exact matches
    
    Require exact matches in all cases instead of treating strings
    starting with 't' ('f') as true (false).
    
    This is required for config_parse_protect_system to parse ProtectSystem=full
    correctly: it uses parse_boolean and only tries a more specific parsing
    function if that did not return a valid result. Thus "full" was treated as
    "false" before.

diff --git a/src/shared/util.c b/src/shared/util.c
index 4fda31c..49c17ef 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -231,9 +231,9 @@ int unlink_noerrno(const char *path) {
 int parse_boolean(const char *v) {
         assert(v);
 
-        if (streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || strcaseeq(v, "on"))
+        if (streq(v, "1") || strcaseeq(v, "yes") || strcaseeq(v, "y") || strcaseeq(v, "true") || strcaseeq(v, "t") || strcaseeq(v, "on"))
                 return 1;
-        else if (streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || strcaseeq(v, "off"))
+        else if (streq(v, "0") || strcaseeq(v, "no") || strcaseeq(v, "n") || strcaseeq(v, "false") || strcaseeq(v, "f") || strcaseeq(v, "off"))
                 return 0;
 
         return -EINVAL;
diff --git a/src/test/test-util.c b/src/test/test-util.c
index ed91a67..9a28ef9 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -129,6 +129,7 @@ static void test_parse_boolean(void) {
 
         assert_se(parse_boolean("garbage") < 0);
         assert_se(parse_boolean("") < 0);
+        assert_se(parse_boolean("full") < 0);
 }
 
 static void test_parse_pid(void) {



More information about the systemd-commits mailing list