Syntax of string in dhcpd.conf
Peter Rathlev
peter at rathlev.dk
Wed Feb 16 23:05:20 UTC 2011
On Wed, 2011-02-16 at 17:09 -0500, John Wobus wrote:
> Below is the most elaborate description I could find about the syntax
> of quoted strings as parsed in dhcpd.config by dhcpd. Short of the
> code, can anyone point me at a more complete description?
There's no better/more complete description that I know of. If you want
to read the code, you should look at the "read_string" function in
common/conflex.c (line 492 in 4.2.0-P2).
> My actual interest is in strings as used for specifying option values.
> This is for a web app that allows administrators choose their own
> options, e.g filenames. If practical, I'd like to validate the string
> before trying out the config. For example:
>
> option bootfile-name "boot\\x86\\wdsnbp.com";
The lexer starts at double quotes and stops at the first non-escaped
double quote after this. Generally the strings should only contain
printable characters. Any non-printable characters should be escaped via
\ooo or \xhhh. Backslashes are only a problem for the string
termination, since dhcpd handles backslashes just fine.
After initial validation you could also use dhcpd itself to test the new
configuration:
dhcpd -q -f -t -cf /tmp/test-config.conf
If it returns 0 (exit code) it's a valid configuration file. (Certain
elements don't seem to be tested, like if all referenced keys are
defined.)
--
Peter
More information about the dhcp-users
mailing list