mirror of
https://github.com/troglobit/finit.git
synced 2026-10-17 10:49:34 +00:00
conf: generate runtime .conf files in the block format
Finit's own generated services -- watchdogd, keventd, runparts, and
the dbus plugin -- still went through conf_save_service() as legacy
one-liners, so `initctl show keventd` taught the old format on a
system otherwise converted to the new one.
conf_save_service() now takes the block title and a printf-style body
and writes the file itself:
# Generated by finit:conf_save_service()
service keventd {
description = "Finit kernel event daemon"
runlevel = "S12345789"
notify = "none"
cgroup init {}
command = "/libexec/finit/keventd"
}
vfprintf() into the file also removes the fixed-size staging buffers
in the callers, where a long dbus pidfile path could truncate inside
a quoted string and take the whole generated file with it.
Semantics preserved: watch-only pid:! maps to pidfile without
pidfile-create, the watchdog keeps its watchdog:finit identity, and
log:console becomes log { file = "/dev/console" }.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
3 files changed
+45
-21
No files matched your search
+12
-8
@@ -100,7 +100,7 @@ static void setup(void *arg)
|
||||
{
|
||||
char *group = DBUS_DAEMONGROUP;
|
||||
char *user = DBUS_DAEMONUSER;
|
||||
char line[256];
|
||||
char pid[300];
|
||||
char *pidfn;
|
||||
mode_t prev;
|
||||
char *cmd;
|
||||
@@ -151,15 +151,19 @@ static void setup(void *arg)
|
||||
* Register service with Finit
|
||||
* Note: dbus drops privs after starting up.
|
||||
*/
|
||||
pid[0] = 0;
|
||||
if (pidfn) {
|
||||
snprintf(line, sizeof(line), "[S123456789] cgroup.system notify:none name:dbus pid:!%s %s %s -- %s",
|
||||
pidfn, cmd, DBUS_ARGS, DBUS_DESC);
|
||||
snprintf(pid, sizeof(pid), "\tpidfile = \"%s\"\n", pidfn);
|
||||
free(pidfn);
|
||||
} else
|
||||
snprintf(line, sizeof(line), "[S123456789] cgroup.system notify:none name:dbus %s %s -- %s",
|
||||
cmd, DBUS_ARGS, DBUS_DESC);
|
||||
|
||||
conf_save_service(SVC_TYPE_SERVICE, line, "dbus.conf");
|
||||
}
|
||||
conf_save_service(SVC_TYPE_SERVICE, "dbus", "dbus.conf",
|
||||
"\tdescription = \"" DBUS_DESC "\"\n"
|
||||
"\trunlevel = \"S123456789\"\n"
|
||||
"\tnotify = \"none\"\n"
|
||||
"\tcgroup system {}\n"
|
||||
"%s"
|
||||
"\tcommand = \"%s " DBUS_ARGS "\"\n",
|
||||
pid, cmd);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user