mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
initctl: touch does not support template services
Fixes #403 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
052136cb99
commit
7b501f255b
2 files changed
+30
No files matched your search
+10
@@ -374,6 +374,15 @@ int serv_touch(char *arg)
|
|||||||
return serv_list("enabled");
|
return serv_list("enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 1. Try /etc/finit.d/enabled/$arg.conf to handle template@.conf */
|
||||||
|
paste(path, sizeof(path), finit_rcsd, "enabled/");
|
||||||
|
strlcat(path, arg, sizeof(path));
|
||||||
|
if (!suffix(path, sizeof(path), ".conf") && fexist(path)) {
|
||||||
|
fn = path;
|
||||||
|
goto touchit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2. Try /etc/finit.d/available/$arg.conf and other combos (legacy) */
|
||||||
fn = conf(path, sizeof(path), arg, 0);
|
fn = conf(path, sizeof(path), arg, 0);
|
||||||
if (!fexist(fn)) {
|
if (!fexist(fn)) {
|
||||||
if (!strstr(arg, "finit.conf"))
|
if (!strstr(arg, "finit.conf"))
|
||||||
@@ -385,6 +394,7 @@ int serv_touch(char *arg)
|
|||||||
fn = path;
|
fn = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
touchit:
|
||||||
/* libite:touch() follows symlinks */
|
/* libite:touch() follows symlinks */
|
||||||
if (utimensat(AT_FDCWD, fn, NULL, AT_SYMLINK_NOFOLLOW))
|
if (utimensat(AT_FDCWD, fn, NULL, AT_SYMLINK_NOFOLLOW))
|
||||||
ERR(noerr ? 0 : 71, "failed marking %s for reload", fn);
|
ERR(noerr ? 0 : 71, "failed marking %s for reload", fn);
|
||||||
|
|||||||
+20
@@ -109,6 +109,26 @@ static inline int paste(char *buf, size_t len, const char *dir, const char *file
|
|||||||
fisslashdir(dir) ? "" : file[0] == '/' ? "" : "/", file);
|
fisslashdir(dir) ? "" : file[0] == '/' ? "" : "/", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ensure path has suffix */
|
||||||
|
static inline int suffix(char *path, size_t len, const char *sfx)
|
||||||
|
{
|
||||||
|
size_t slen = strlen(sfx);
|
||||||
|
size_t plen = strlen(path);
|
||||||
|
|
||||||
|
if (plen < slen)
|
||||||
|
slen = strlcat(path, sfx, len);
|
||||||
|
else {
|
||||||
|
plen -= slen;
|
||||||
|
if (strcmp(&path[plen], sfx))
|
||||||
|
slen = strlcat(path, sfx, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slen >= len)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* FINIT_UTIL_H_ */
|
#endif /* FINIT_UTIL_H_ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user