summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 14:47:31 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 15:08:42 -0400
commit0c6ea3a4e2ac3f350dcb58e8f08bb74b030cd624 (patch)
tree562a17aa7a48741002001b59b5ad04a428890217 /src/systemctl
parent60731f32f1d25070ed7559bdd64d65e7462a4df6 (diff)
Add utility function to append root to path
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 0631190504..599d590747 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4998,11 +4998,8 @@ static int enable_sysv_units(const char *verb, char **args) {
STRV_FOREACH(k, paths.unit_path) {
_cleanup_free_ char *path = NULL;
- if (!isempty(arg_root))
- j = asprintf(&path, "%s/%s/%s", arg_root, *k, name);
- else
- j = asprintf(&path, "%s/%s", *k, name);
- if (j < 0)
+ path = path_join(arg_root, *k, name);
+ if (!path)
return log_oom();
found_native = access(path, F_OK) >= 0;
@@ -5013,11 +5010,8 @@ static int enable_sysv_units(const char *verb, char **args) {
if (found_native)
continue;
- if (!isempty(arg_root))
- j = asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_root, name);
- else
- j = asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name);
- if (j < 0)
+ p = path_join(arg_root, SYSTEM_SYSVINIT_PATH, name);
+ if (!p)
return log_oom();
p[strlen(p) - strlen(".service")] = 0;