summaryrefslogtreecommitdiffstats
path: root/src/shared/install-printf.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-10-20 06:27:46 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-10-20 15:12:42 +0200
commit6e3136b209679d88c4347ce2f6d5e22c031e4d3e (patch)
treed9148b74b9236bca3e156238348abb5fe7204995 /src/shared/install-printf.c
parentcore: let's upgrade the log level for service processes dying of signal (#4415) (diff)
downloadsystemd-6e3136b209679d88c4347ce2f6d5e22c031e4d3e.tar.xz
systemd-6e3136b209679d88c4347ce2f6d5e22c031e4d3e.zip
shared/install: fix DefaultInstance expansion in %i
We should substitute DefaultInstance if the instance is not specified. Test case: [Install] DefaultInstance=bond1 WantedBy= foobar-i-%i.device $ systemctl --root=/ enable testing4@.service Created symlink /etc/systemd/system/foobar-i-bond1.device.wants/testing4@bond1.service → /etc/systemd/system/testing4@.service. (before, the symlink would be created as /etc/systemd/system/foobar-i-.device.wants/testing4@bond1.service) Fixes #4411.
Diffstat (limited to 'src/shared/install-printf.c')
-rw-r--r--src/shared/install-printf.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c
index 88143361da..9fc915d62e 100644
--- a/src/shared/install-printf.c
+++ b/src/shared/install-printf.c
@@ -27,6 +27,7 @@
#include "install.h"
#include "macro.h"
#include "specifier.h"
+#include "string-util.h"
#include "unit-name.h"
#include "user-util.h"
@@ -47,7 +48,7 @@ static int specifier_prefix(char specifier, void *data, void *userdata, char **r
}
static int specifier_instance(char specifier, void *data, void *userdata, char **ret) {
- UnitFileInstallInfo *i = userdata;
+ const UnitFileInstallInfo *i = userdata;
char *instance;
int r;
@@ -57,8 +58,8 @@ static int specifier_instance(char specifier, void *data, void *userdata, char *
if (r < 0)
return r;
- if (!instance) {
- instance = strdup("");
+ if (isempty(instance)) {
+ instance = strdup(i->default_instance ?: "");
if (!instance)
return -ENOMEM;
}