tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

inetd Enhancements - Progress and Quote Parsing

Hello tech-userlevel,

We would like to give you a small progress update, as well as inquire about
handling quotation parsing.  Currently, we have implemented the framework for
the new parser, such that inetd can successfully parse a config file which
contains the old syntax and new syntax, but the new syntax specifications are
currently ignored. The format of the new syntax as implemented (currently
without quote parsing) is as follows:

inetd services can be specified with a legacy (v1) syntax and a version 2 (v2) 
syntax. A v2 service configuration consists of 3 parts:
[listen-addr:]service-spec (which is the same as in the v1 syntax), the keyword
“on'' or “off” (which replaces the “dgram” or “stream” in v1), followed by a
series of key-value associations. A single key-value association is specified
with the syntax: <key> = <values>, where <values> may be a series of whitespace
and/or newline separated strings. The meaning of multiple values depends on the
specific key, and it may be a service definition error to specify more than one.
Key-value associations are separated by commas, i.e. commas terminate a 
key-value association and precede the beginning of a new key. A semicolon after
a key-value association terminates a service definition. All tokens (keys,
values, commas, semicolons, equals sign) can be separated by whitespace and/or

In inetd.c, new key handlers can easily be added by adding them to the list of
key handler functions:

static struct key_handler {
    const char *name;
    key_handler_func handler;
} key_handlers[] = {
    {"bind", bind_handler},
    {"port", port_handler},
    {"args", args_handler}

static int bind_handler(struct servtab *sep, vlist values_start);
static int port_handler(struct servtab *sep, vlist values_start);
static int args_handler(struct servtab *sep, vlist values_start);

The function next_value can be called to easily parse the next value for a
given key handler:

static char *next_value(vlist list);

Before we implement the actual “handlers” for the keys, we need to conclude how
we want to implement quote parsing. We are debating between two different ways
of handling the following case:

The shell-style syntax currently used in inetd where quotes can be anywhere:

This” “is 
becomes “this is” (a single value). 

Or programming language syntax, where quotes must enclose an entire value:
This” “is 
throws an error

The programming-language style is more restrictive but also a bit clearer and
potentially leaves more room for additions to the syntax parsing later on.

We also plan to implement standard C-style escape sequences (minus the weird 
ones like \? \a and octal). 

Thank you for your input
inetd Team 

Home | Main Index | Thread Index | Old Index