various tools: be more explicit when a glob is passed when not supported

See https://bugzilla.redhat.com/show_bug.cgi?id=1763488: when we say that
'foo@*.service' is not a valid unit name, this is not clear enough. Let's
include the name of the operation that does not support globbing in the
error message:

$ build/systemctl enable 'foo@*.service'
Glob pattern passed to enable, but globs are not supported for this.
Invalid unit name "foo@*.service" escaped as "foo@\x2a.service".
...
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-10-25 13:41:49 +09:00
committed by Yu Watanabe
parent 1c089741d3
commit df7c4eb62a
7 changed files with 50 additions and 32 deletions
+2 -2
View File
@@ -52,10 +52,10 @@ typedef enum UnitNameMangle {
UNIT_NAME_MANGLE_WARN = 1 << 1,
} UnitNameMangle;
int unit_name_mangle_with_suffix(const char *name, UnitNameMangle flags, const char *suffix, char **ret);
int unit_name_mangle_with_suffix(const char *name, const char *operation, UnitNameMangle flags, const char *suffix, char **ret);
static inline int unit_name_mangle(const char *name, UnitNameMangle flags, char **ret) {
return unit_name_mangle_with_suffix(name, flags, ".service", ret);
return unit_name_mangle_with_suffix(name, NULL, flags, ".service", ret);
}
bool service_unit_name_is_valid(const char *name);