New jail(8) committed

Devin Teske devin.teske at
Sun Apr 29 02:00:47 UTC 2012

On Apr 28, 2012, at 3:52 PM, Jamie Gritton wrote:

> I don't know about wrapping a utility around it, but it would be nice to
> have in a library. If it could be made to work for not only jail, but
> apmd and devd as well, then we could make some existing code cleaner.

I'm thinking about throwing "figpar" into the CVS projects tree and then
creating a few examples for reading jail.conf, apmd.conf, and devd.conf
as well as dhcpd.conf.

Naturally, this would be a library that you load and then pass it a struct-array
describing how you're going to handle the config file directives and what
they look like. You're passing function pointers in the struct array and the
parse_config() function will call the functions you pass to handle keywords.

The header file (figpar.h) is 123 lines and the source file (figpar.c) is 376
lines. There's only 2 functions and one struct to learn. The 2 functions are:

config_t* get_config_option(config_t [], char *);
int parse_config(config_t [], char *, int (*)(u_int32_t, char *, char *));

NOTE: It will of course have to be cleaned up for style(9) compatibility
(that's where the ``dusting off'' part comes-in).

A link to the sources that I've uploaded temporarily to sourceforge (again,
if we're serious about needing a light-weight parser for this file-format, I
think we should import it into cvs:projects/figpar/ and hack on it together):


> On 04/28/12 10:52, Devin Teske wrote:
>> On Apr 28, 2012, at 7:38 AM, Jamie Gritton wrote:
>>> The main reason I didn't consider a jail.d approach is just that I
>>> haven't - such things are a little off the radar for me. It seemed very
>>> natural to use a configuration file format that other programs already
>>> use (e.g. named, apmd, devd). I suppose it's true that the "foo.d"
>>> approach is also in use by other programs, though I mostly seem to see
>>> those on Linux. And if I did opt for a directory approach, the files
>>> within the directory would still need a format - you can't get away from
>>> the fact that a config file needs a format.
>>> It would be nice to have a general parser for C-style config files, and
>>> I looked for such a library when I started on this. But such a library
>>> doesn't seem to exist.Perhaps it's time to make one.
>> The config file format that you've chosen is remarkably identical to config files for which I've already written parsers.
>> So, I guess I'm saying that I'm willing to help out in this area.
>> My parser is written in C, it's very small and light-weight, and it's called figpar (con[fig par]ser).
>> I can dust if off, slap a BSD license on it, wrap a utility around it and we could have something like sysrc (which operates on the collection of rc.conf(5) files).
>> Alternatively, I could rewrite it in something like sh(1) if C is not desired.

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.

More information about the freebsd-jail mailing list