-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.PCRE
31 lines (24 loc) · 1.39 KB
/
README.PCRE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
File name mangling with PCRE in atftpd
======================================
Here is an attempt at using PCRE (Perl Compatible Regular Expressions)
with a TFTP server. The first question on your mind is most likely "Why in
blazes would anyone want to use a regular expression with a TFTP server?"
Imagine you have a network of machines that all download an identical
config file, but each machine requests its file as <serialno>.conf where
<serialno> is the serial number of the machine. This set up is useful when
you wish each machine to have custom configs. When you which to have
identical configurations on each box this is annoying. The solution is to
map all requested files ending in .conf to one master.conf file via a
regex. The exact expression I use is
^\w*\.conf$ master.conf
The left hand side is the expression to match, the right hand side is the
substitution. This is equivalent to perls s/// statement. One or more of these
expressions can be stored in a file (one per line) and feed to atftpd via a
--pcre <filename> switch on the command line. For example,
./atftpd --daemon --pcre ./test/pcre_pattern.txt /tftpboot/
Also included is a test program using the --pcre-test <filename> option. You
can interactively (or via redirection) feed file name to atftpd and look at
the substitution to verify your rules. for example,
./atftpd --pcre-test ./test/pcre_pattern.txt
Jeff.