diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-30 20:21:00 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-05-05 15:06:42 -0700 |
commit | 7410616cd9dbbec97cf98d75324da5cda2b2f7a2 (patch) | |
tree | 6d968995b3bdf961603ab4853bf078c0dbdce27c /src/journal/journalctl.c | |
parent | 6442185ab674cc202d63c18605057b9a51ca2722 (diff) |
core: rework unit name validation and manipulation logic
A variety of changes:
- Make sure all our calls distuingish OOM from other errors if OOM is
not the only error possible.
- Be much stricter when parsing escaped paths, do not accept trailing or
leading escaped slashes.
- Change unit validation to take a bit mask for allowing plain names,
instance names or template names or an combination thereof.
- Refuse manipulating invalid unit name
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r-- | src/journal/journalctl.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 666aa20480..627e43ba35 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1135,9 +1135,9 @@ static int add_units(sd_journal *j) { STRV_FOREACH(i, arg_system_units) { _cleanup_free_ char *u = NULL; - u = unit_name_mangle(*i, MANGLE_GLOB); - if (!u) - return log_oom(); + r = unit_name_mangle(*i, UNIT_NAME_GLOB, &u); + if (r < 0) + return r; if (string_is_glob(u)) { r = strv_push(&patterns, u); @@ -1181,9 +1181,9 @@ static int add_units(sd_journal *j) { STRV_FOREACH(i, arg_user_units) { _cleanup_free_ char *u = NULL; - u = unit_name_mangle(*i, MANGLE_GLOB); - if (!u) - return log_oom(); + r = unit_name_mangle(*i, UNIT_NAME_GLOB, &u); + if (r < 0) + return r; if (string_is_glob(u)) { r = strv_push(&patterns, u); @@ -1840,9 +1840,8 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; r = add_units(j); - strv_free(arg_system_units); - strv_free(arg_user_units); - + arg_system_units = strv_free(arg_system_units); + arg_user_units = strv_free(arg_user_units); if (r < 0) { log_error_errno(r, "Failed to add filter for units: %m"); return EXIT_FAILURE; |