mirror of
https://github.com/troglobit/finit.git
synced 2026-10-30 12:50:34 +00:00
Drop hard coded path limit in glob of *.conf files
A simple distcheck revealed that the local path[] was too small to store something like /home/jocke/src/finit/finit-4.4-rc1/usr/lib/finit/system/ This refactor should cover all cases. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
f72f3febf9
commit
47d8a83668
1 file changed
+28
-8
+28
-8
@@ -1025,14 +1025,37 @@ static int parse_conf(char *file, int is_rcsd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void glob_append(glob_t *gl, int append, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
size_t len;
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
len = vsnprintf(NULL, 0, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
path = alloca(++len);
|
||||||
|
if (!path) {
|
||||||
|
warn("failed alloca() in glob_append()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(path, len, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
dbg("conf_reload(): glob %s ...", path);
|
||||||
|
glob(path, append ? GLOB_APPEND : 0, NULL, gl);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reload /etc/finit.conf and all *.conf in /etc/finit.d/
|
* Reload /etc/finit.conf and all *.conf in /etc/finit.d/
|
||||||
*/
|
*/
|
||||||
int conf_reload(void)
|
int conf_reload(void)
|
||||||
{
|
{
|
||||||
char path[strlen(finit_rcsd) + 16];
|
|
||||||
size_t i;
|
|
||||||
glob_t gl;
|
glob_t gl;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
/* Set time according to current time zone */
|
/* Set time according to current time zone */
|
||||||
tzset();
|
tzset();
|
||||||
@@ -1079,12 +1102,9 @@ int conf_reload(void)
|
|||||||
* /etc/finit.d -- similar to how tmfiles.d(5) work. E.g., add
|
* /etc/finit.d -- similar to how tmfiles.d(5) work. E.g., add
|
||||||
* an override .conf, or an ignore by symlinking to /dev/null
|
* an override .conf, or an ignore by symlinking to /dev/null
|
||||||
*/
|
*/
|
||||||
snprintf(path, sizeof(path), "%s/*.conf", finit_rcsd);
|
glob_append(&gl, 0, "%s/*.conf", finit_rcsd);
|
||||||
glob(path, 0, NULL, &gl);
|
glob_append(&gl, 1, "%s/*.conf", FINIT_SYSPATH);
|
||||||
snprintf(path, sizeof(path), "%s/*.conf", FINIT_SYSPATH);
|
glob_append(&gl, 1, "%s/enabled/*.conf", finit_rcsd);
|
||||||
glob(path, GLOB_APPEND, NULL, &gl);
|
|
||||||
snprintf(path, sizeof(path), "%s/enabled/*.conf", finit_rcsd);
|
|
||||||
glob(path, GLOB_APPEND, NULL, &gl);
|
|
||||||
|
|
||||||
for (i = 0; i < gl.gl_pathc; i++) {
|
for (i = 0; i < gl.gl_pathc; i++) {
|
||||||
char *path = gl.gl_pathv[i];
|
char *path = gl.gl_pathv[i];
|
||||||
|
|||||||
Reference in new issue
Block a user