summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/systemctl/systemctl.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index ddf46b66d5..509651c1fd 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4394,18 +4394,33 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
log_info("Use -t help to see a list of allowed values.");
return -EINVAL;
case 'p': {
- char **l;
+ char *word, *state;
+ size_t size;
+ /* Make sure that if the empty property list
+ was specified, we won't show any properties. */
+ const char *source = isempty(optarg) ? " " : optarg;
+
+ FOREACH_WORD_SEPARATOR(word, size, source, ",", state) {
+ char _cleanup_free_ *prop;
+ char **tmp;
+
+ prop = strndup(word, size);
+ if (!prop)
+ return -ENOMEM;
- if (!(l = strv_append(arg_property, optarg)))
- return -ENOMEM;
+ tmp = strv_append(arg_property, prop);
+ if (!tmp)
+ return -ENOMEM;
- strv_free(arg_property);
- arg_property = l;
+ strv_free(arg_property);
+ arg_property = tmp;
+ }
/* If the user asked for a particular
* property, show it to him, even if it is
* empty. */
arg_all = true;
+
break;
}