Busybox HTTPd cgi handlers

Denys Vlasenko vda.linux at googlemail.com
Sat Jul 4 14:40:56 UTC 2009


On Saturday 04 July 2009 04:46, Tomáš Mudruňka wrote:
> Hello,<br>i have small feature request.<br>Can you please add filelisting to httpd? Maybe you don't want httpd to be so big, so i have idea how to enable filelisting without pain.<br><br>i am using php in busybox httpd.conf:<br>*.php:/usr/bin/php-cgi<br><br>so why i cannot just set cgi binary to handle directories similar way? like:<br>/:/bin/ls<br>or<br>__DIR__:/bin/ls<br><br>and when you will enable assigning arguments to cgi binary it can be more cool ever<br>/:/bin/ls -l<br><br>or to have very nice listing with links:<br>/:/usr/bin/links -source<br>("links -source $DIRECTORY" is command which can generate html filelisting for some directory)<br>i can also write some small busybox-sh script to handle that instead of big links binary<br><br>BTW i miss full documentation for busybox httpd and httpd.conf on busybox webpage - not only small pieces allaround the google. for example i can't find any information about security of busybox httpd.<br><br>thanks (and thanks for busyb
>  ox ;)<br>&nbsp;&nbsp;&nbsp; Harvie<br><div></div>

It already does that.

If you have index.cgi, it will be called for directories.

Relevant httpd.c part:

#if ENABLE_FEATURE_HTTPD_CGI
        else if (urlp[-1] == '/') {
                /* It's a dir URL and there is no index.html
                 * Try cgi-bin/index.cgi */
                if (access("/cgi-bin/index.cgi"+1, X_OK) == 0) {
                        urlp[0] = '\0';
                        g_query = urlcopy;
                        send_cgi_and_exit("/cgi-bin/index.cgi", prequest, length, cookie, content_type);
                }
        }
#endif

and networking/httpd_indexcgi.c is a C example of such CGI.
--
vda


More information about the busybox mailing list