mirror of
https://github.com/cesanta/mongoose.git
synced 2025-06-12 12:42:50 +08:00
CGI directory logic fixed
This commit is contained in:
parent
9ba1596c46
commit
ddbe690698
@ -1131,16 +1131,17 @@ static const char cgi_status[] = "HTTP/1.1 200 OK\r\n";
|
|||||||
|
|
||||||
static void open_cgi_endpoint(struct connection *conn, const char *prog) {
|
static void open_cgi_endpoint(struct connection *conn, const char *prog) {
|
||||||
struct cgi_env_block blk;
|
struct cgi_env_block blk;
|
||||||
char dir[MAX_PATH_SIZE];
|
char dir[MAX_PATH_SIZE], *p;
|
||||||
sock_t fds[2];
|
sock_t fds[2];
|
||||||
|
|
||||||
prepare_cgi_environment(conn, prog, &blk);
|
prepare_cgi_environment(conn, prog, &blk);
|
||||||
// CGI must be executed in its own directory. 'dir' must point to the
|
// CGI must be executed in its own directory. 'dir' must point to the
|
||||||
// directory containing executable program, 'p' must point to the
|
// directory containing executable program, 'p' must point to the
|
||||||
// executable program name relative to 'dir'.
|
// executable program name relative to 'dir'.
|
||||||
mg_snprintf(dir, sizeof(dir), "%s", prog);
|
if ((p = strrchr(prog, '/')) == NULL) {
|
||||||
if (strrchr(dir, '/') == NULL) {
|
|
||||||
mg_snprintf(dir, sizeof(dir), "%s", ".");
|
mg_snprintf(dir, sizeof(dir), "%s", ".");
|
||||||
|
} else {
|
||||||
|
mg_snprintf(dir, sizeof(dir), "%.*s", p - prog, prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to create socketpair in a loop until success. mg_socketpair()
|
// Try to create socketpair in a loop until success. mg_socketpair()
|
||||||
|
Loading…
Reference in New Issue
Block a user