mirror of
https://github.com/systemd/systemd.git
synced 2024-10-28 20:25:38 +03:00
unit-name: fix detection of unit templates/instances
We need to check for the last dot, not the first one in a unit name, for the suffix. Correct that.
This commit is contained in:
parent
e94b5a7bc2
commit
6ef9eeed61
Notes:
Zbigniew Jędrzejewski-Szmek
2014-06-22 11:44:06 -04:00
Backport: bugfix
@ -332,7 +332,7 @@ char *unit_name_path_unescape(const char *f) {
|
||||
}
|
||||
|
||||
bool unit_name_is_template(const char *n) {
|
||||
const char *p;
|
||||
const char *p, *e;
|
||||
|
||||
assert(n);
|
||||
|
||||
@ -340,11 +340,15 @@ bool unit_name_is_template(const char *n) {
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
return p[1] == '.';
|
||||
e = strrchr(p+1, '.');
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
return e == p + 1;
|
||||
}
|
||||
|
||||
bool unit_name_is_instance(const char *n) {
|
||||
const char *p;
|
||||
const char *p, *e;
|
||||
|
||||
assert(n);
|
||||
|
||||
@ -352,7 +356,11 @@ bool unit_name_is_instance(const char *n) {
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
return p[1] != '.';
|
||||
e = strrchr(p+1, '.');
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
return e > p + 1;
|
||||
}
|
||||
|
||||
char *unit_name_replace_instance(const char *f, const char *i) {
|
||||
|
Loading…
Reference in New Issue
Block a user