mirror of
https://github.com/troglobit/finit.git
synced 2026-10-28 12:30:44 +00:00
conf: escape runtime strings in generated .conf files
The runparts directory and the dbus pidfile and daemon paths are embedded in double-quoted values of the generated block files. A literal quote in either ends the value early and libconfuse rejects the whole file, and a backslash is read as an escape sequence, silently mangling the path. The legacy one-liners had no quoting, so neither failure existed before the block conversion. conf_escape() doubles backslashes and escapes quotes; verified by round-tripping hostile paths through cfg_parse_buf(). Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
3 files changed
+29
-3
No files matched your search
+6
-2
@@ -100,6 +100,7 @@ static void setup(void *arg)
|
||||
{
|
||||
char *group = DBUS_DAEMONGROUP;
|
||||
char *user = DBUS_DAEMONUSER;
|
||||
char esccmd[256];
|
||||
char pid[300];
|
||||
char *pidfn;
|
||||
mode_t prev;
|
||||
@@ -153,7 +154,10 @@ static void setup(void *arg)
|
||||
*/
|
||||
pid[0] = 0;
|
||||
if (pidfn) {
|
||||
snprintf(pid, sizeof(pid), "\tpidfile = \"%s\"\n", pidfn);
|
||||
char esc[280];
|
||||
|
||||
snprintf(pid, sizeof(pid), "\tpidfile = \"%s\"\n",
|
||||
conf_escape(pidfn, esc, sizeof(esc)));
|
||||
free(pidfn);
|
||||
}
|
||||
conf_save_service(SVC_TYPE_SERVICE, "dbus", "dbus.conf",
|
||||
@@ -163,7 +167,7 @@ static void setup(void *arg)
|
||||
"\tcgroup system {}\n"
|
||||
"%s"
|
||||
"\tcommand = \"%s " DBUS_ARGS "\"\n",
|
||||
pid, cmd);
|
||||
pid, conf_escape(cmd, esccmd, sizeof(esccmd)));
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user