OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: proposal to add a cgi scripting interface to tftpd

From: Don Jackson (don.jacksongmail.com)
Date: Sun Feb 01 2009 - 11:14:57 CST


The CGI interface to tftpd I proposed in the message below has been
implemented.

The code is hosted on SourceForge:

        https://sourceforge.net/projects/tftpd-cgi/

An OpenBSD port which makes it easy to build and install has been
posted to the portsopenbsd.org mailing list:

        http://archives.neohapsis.com/archives/openbsd/2009-02/0019.html

Regards,

Don Jackson

On Dec 11, 2008, at 1:47 PM, Don Jackson wrote:

> There are times when it would provide needed flexibility and be more
> scalable if some files requested by network devices during boot/
> installation could be generated
> dynamically by an application on the tftp server. Two examples are
> device specific configuration files for VoIP telephones, and the
> boot.conf file requested by pxeboot during
> an OpenBSD installation.
>
> I've specified one possible approach to this below, and I'm actively
> seeking to contract with someone to implement this feature.
>
> If this effort is successful, I intend to contribute the result as a
> port & package.
>
> I'd welcome input/feedback on the spec/requirements below, and if you
> might be interested in working on it, I'm currently seeking bids
> via Elance:
>
> http://www.elance.com/job?jobid=15906827&rid=1DIUU
>
> (or email me directly)
>
> Don
>
>
> Project goals:
> ===========
>
> Develop extensions to OpenBSD's tftpd server that will enable an
> external application to process read/write requests to the tftp
> server.
> Given that this scenario is extremely similar to the CGI interface
> supported by http/web servers, and that there are number of useful
> packages to support CGI based scripting,
> the CGI interface will be used as the basis for the API between the
> tftpd server and the dynamic content generating app.
>
> Requirements:
> ===========
>
> The resulting tftp-cgi will run under OpenBSD (4.4 stable, and 4.4
> curent), and be capable of replacing the existing OpenBSD tftpd
> server.
>
> The starting codebase for the tftpd-cgi will be the OpenBSD 4.4 stable
> tftpd
>
> The tftp-cgi app must be able to create an OpenBSD "port", as
> specified by (see list of docs), eg "make port".
> The resulting port should be buildable/installable on OpenBSD 4.4 and
> subsequent versions.
>
> The tftp-cgi app will support some way of specifying the command/
> string to be executed for tftpd client requests.
> Probably this string should be specified as a command line argument to
> tftpd-cgi. If no such string is specified,
> tftpd-cgi will exhibit identical behavior to the existing OpenBSD
> tftpd
>
> The TFTP protocol is specified in: http://www.ietf.org/rfc/rfc1350
>
> The CGI interface is specified in: http://www.ietf.org/rfc/rfc3875
>
> The proposed mapping of CGI to the TFTP protocol should be as follows:
>
> The TFTP read method will map to a CGI REQUEST_METHOD of GET
>
> The TFTP write method will map to a CGI REQUEST_METHOD of PUT
>
> The file name in the TFTP read/write request will be provided to the
> CGI script in the PATH_INFO variable
>
> REMOTE_ADDR must be provided by tftpd-cgi
>
> REMOTE_HOST must be provided by tftpd-cgi
>
> The ethernet MAC address of the tftp client must be provided via the
> non-standard CGI variable REMOTE_MAC_ADDR.
>
> For a TFTP read, the tftpd-cgi will return the result that the cgi
> script returns on its standard output
>
> For a TFTP write, tftpd-cgi will provide the data to be written on the
> standard input of the cgi script.
>
> The CGI script can specify that the tftpd-cgi should return a file
> local to the tftpd-cgi via the CGI Local Redirect Response
>
> There are likely other questions about TFTP/CGI protocol mapping that
> will arise during implementation
>
> Acceptance Testing:
> ================
>
> 1) "make port", take the resulting port, "make", then "make
> install". Grab the resulting OpenBSD package, and install
> on yet another system.
>
> 2) Demonstrate that tfptd-cgi behaves identically to existing tftpd if
> CGI feature not specified on command line.
>
> 3) Provide simple cgi-script (ideally sh or perl script) that logs
> request (including REMOTE_MAC_ADDR, and other relevant info, and also
> returns all this info
> as the contents of the requested file
>
> 4) Provide simple cgi-script that returns the incoming request back to
> the tftpd-cgi server, telling it to "just provide the requested file
> yourself" via the
> Local Redirect Response mechanism