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:
Joachim Wiberg committed 2026-08-01 11:25:40 +02:00
1 parent 2c6547635a
commit 1099d663ab
3 files changed
+29 -3

No files matched your search

+1
View File
@@ -71,6 +71,7 @@ int conf_monitor (void);
void conf_saverc (void);
void conf_save_exec_order (svc_t *svc, char *cmdline, int result);
char *conf_escape (const char *str, char *buf, size_t len);
void conf_save_service (int type, const char *name, char *file, const char *fmt, ...)
__attribute__ ((format (printf, 4, 5)));
void conf_parse_cmdline (int argc, char *argv[]);