* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define _GNU_SOURCE
#include <libubox/blobmsg.h>
#include "uhttpd.h"
setenv(var->name, var->value, 1);
}
- chdir(pi->root);
-
- if (ip)
- execl(ip->path, ip->path, pi->phys, NULL);
- else
- execl(pi->phys, pi->phys, NULL);
+ if (!chdir(pi->root)) {
+ if (ip)
+ execl(ip->path, ip->path, pi->phys, NULL);
+ else
+ execl(pi->phys, pi->phys, NULL);
+ }
printf("Status: 500 Internal Server Error\r\n\r\n"
"Unable to launch the requested CGI program:\n"
}
pi->ip = NULL;
- return uh_path_match(conf.cgi_prefix, url);
+
+ if (conf.cgi_docroot_path)
+ return uh_path_match(conf.cgi_docroot_path, pi->phys);
+
+ return false;
}
struct dispatch_handler cgi_dispatch = {
+ .script = true,
.check_path = check_cgi_path,
.handle_request = cgi_handle_request,
};