forked from aniani/gmnisrv
Check index before serving autoindex
if a directory is being served.
This commit is contained in:
parent
9f2481dcdf
commit
32854b79c7
12
src/serve.c
12
src/serve.c
@ -526,15 +526,16 @@ serve_request(struct gmnisrv_client *client)
|
||||
}
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if (route->autoindex) {
|
||||
serve_autoindex(client, real_path);
|
||||
free(url_path);
|
||||
return;
|
||||
} else {
|
||||
strcpy(temp_path, real_path);
|
||||
strncat(real_path,
|
||||
route->index ? route->index : "index.gmi",
|
||||
sizeof(real_path) - 1);
|
||||
if (stat(real_path, &st) != 0) {
|
||||
if (route->autoindex) {
|
||||
serve_autoindex(client, temp_path);
|
||||
free(url_path);
|
||||
return;
|
||||
}
|
||||
server_error("CGI path %s has no index",
|
||||
client_path);
|
||||
client_submit_response(client,
|
||||
@ -542,7 +543,6 @@ serve_request(struct gmnisrv_client *client)
|
||||
"Not found", NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (S_ISLNK(st.st_mode)) {
|
||||
++nlinks;
|
||||
if (nlinks > 3) {
|
||||
|
Loading…
Reference in New Issue
Block a user