mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
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>
57 lines
2.0 KiB
C
57 lines
2.0 KiB
C
/* Internal interface between conf.c and the legacy one-liner parser
|
|
*
|
|
* Copyright (c) 2012-2026 Joachim Wiberg <troglobit@gmail.com>
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
#ifndef FINIT_LEGACY_H_
|
|
#define FINIT_LEGACY_H_
|
|
|
|
#include <sys/resource.h>
|
|
|
|
extern struct rlimit initial_rlimit[RLIMIT_NLIMITS];
|
|
extern int runparts_progress;
|
|
extern int runparts_sysv;
|
|
|
|
/*
|
|
* legacy.c -- the frozen legacy one-liner parser. No new features
|
|
* land here, only in the libconfuse format frontend in conf.c
|
|
*/
|
|
int legacy_parse_conf (char *file, int is_rcsd);
|
|
void legacy_parse_env (char *line);
|
|
void kmod_load (char *mod);
|
|
void conf_parse_rlimit (char *line, struct rlimit arr[]);
|
|
char *lim2str (struct rlimit *rlim);
|
|
|
|
/*
|
|
* conf.c -- format-detecting frontend. The legacy include directive
|
|
* routes back through this so included files are format-detected too.
|
|
*/
|
|
int conf_parse_file (char *file, int is_rcsd);
|
|
|
|
#endif /* FINIT_LEGACY_H_ */
|
|
|
|
/**
|
|
* Local Variables:
|
|
* indent-tabs-mode: t
|
|
* c-file-style: "linux"
|
|
* End:
|
|
*/
|