conf: add libconfuse block format alongside the one-liner format

The one-liner format has grown crowded and very wide, and every new
service option makes it worse.

Add a second, block-based format, parsed with libconfuse:

    service sshd {
        description = "OpenSSH daemon"
        runlevel    = "2345"
        command     = "/usr/sbin/sshd -D $SSHD_OPTS"
    }

Both formats keep the .conf extension and are detected per file by
content.  Try-parse strictly with libconfuse; on a parse error,
re-parse leniently to tell a block file with a typo from a one-liner
file.  Only a one-liner file reaches the legacy parser, a typo is
reported with its file and line.

Each block is translated to the canonical one-liner and registered
through the existing entry points, so the two formats cannot drift.

The one-liner parser is frozen at the 4.x feature set, new options
land only in the block schema.  libconfuse 3.3 or later is required,
CFGF_KEYSTRVAL does not exist before it.

Covers service, task, run, sysv and tty blocks, the static directives,
and the cgroup, rlimit, set and log blocks.  Templating and the
documentation rewrite are still to come.

The regression test covers translation of a service block to the
one-liner, a block-format /etc/finit.conf booting with set {} applied
at bootstrap, both formats side by side, and rejection of a typo at
block and at root level.

A rejected file must not fall through to the legacy parser, which
registers a bogus unstartable service per line.  assert_num_children
cannot see that, the bogus service has no children either, so the
check is assert_num_services.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-07-30 15:21:25 +02:00
1 parent fc74f87986
commit 3b866c95e0
9 files changed
+1649 -528

No files matched your search

+2 -2
View File
@@ -49,7 +49,7 @@ extern char *osheading;
extern int logfile_size_max;
extern int logfile_count_max;
extern struct rlimit global_rlimit[];
extern struct rlimit global_rlimit[RLIMIT_NLIMITS];
extern char cgroup_current[];
extern char cgroup_settings_current[];
extern int cgroup_delegate_current;
@@ -58,7 +58,7 @@ int str2rlim(char *str);
char *rlim2str(int rlim);
int conf_init (uev_ctx_t *ctx);
void conf_reload (void);
int conf_reload (void);
int conf_any_change (void);
int conf_changed (char *file);
int conf_monitor (void);