[RFC ] include with wildcard filenames

Timothe Litt litt at acm.org
Wed Feb 28 22:27:50 UTC 2018

On 28-Feb-18 04:48, dhcp-users-request at lists.isc.org wrote:
> Message: 1
> Date: Tue, 27 Feb 2018 23:33:10 +0100
> From: Ulf Samuelsson <dhcp at emagii.com>
> To: dhcp-users at lists.isc.org
> Subject: [RFC ] include with wildcard filenames
> Message-ID: <f80615ed-3ae0-e5af-a62a-799842ada91a at emagii.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
> I was trying out a dhcpd configuration, and found to my dismay
> that the DHCP server did not support wildcards for include statements.
> include "/etc/dhcp/pools/*.conf";
> did not work.

> ====================================
> I did a patch for dhcp-4.3.6 which is slightly limited.
> It supports only wildcards on files within a single directory.
> I.E: include "/etc/dhcp/pools/*.conf"; is supported
> I.E: include "/etc/dhcp/*/dhcp.conf"; is not supported
> The wildcard may not be in a directory.
> Did a small test program which tested the functionality of wildcards,
> and then patched the dhcp server, but it has not been tested yet, as 
> part of dhcp
> Still would like to have peoples opinion, whether this type of 
> functionality is desirable.
> It is certainly possible to do this without wildcards,
> but wildcards seems a much cleaner solution.
> ====================================
> .

Without commenting on your application, a note on your patch:

You should be aware that readdir does not order the directory entries. 
They are returned in
some implementation-specific order - which is generally NOT that of a
directory listing.  Commands
such as ls sort the results for presentation.

Users of config files in applications that have a wildcard option for
include generally assume
that the files will be included in lexical order; e.g. foo-001.conf will
be included before foo-002.conf.
This will not reliably be the case with your code.  The results will not
even be deterministic on most

If you pursue this, you should sort the results of readdir before
including them.

See qsort() for a fairly portable approach.  Or look at scandir()
(especially with versionsort()) for
a more convenient, if less portable approach to this.

Timothe Litt
ACM Distinguished Engineer
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20180228/c30975d4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4577 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20180228/c30975d4/attachment.bin>

More information about the dhcp-users mailing list