mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-11-19 20:38:35 +00: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.
(cherry picked from commit 6ef9eeed61)
(cherry picked from commit 2992a46a54b65b349b8d5b6330fe8fd19234e321)
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
f6c97dfac6
commit
b2c7ff14c2
+12
-4
@@ -334,7 +334,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);
|
||||
|
||||
@@ -342,11 +342,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);
|
||||
|
||||
@@ -354,7 +358,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) {
|
||||
|
||||
Reference in New Issue
Block a user