CGI Everywhere

This commit is contained in:
int 80h
2020-05-23 14:33:01 -04:00
parent 8ebe1becf1
commit 56384f35d0
4 changed files with 28 additions and 6 deletions

View File

@@ -18,7 +18,8 @@ pub struct Server {
pub key: String,
pub cert: String,
pub index: Option<String>,
pub cgi: Option<String>,
pub cgi: Option<bool>,
pub cgipath: Option<String>,
pub cgienv: Option<HashMap<String, String>>,
pub usrdir: Option<bool>,
pub proxy: Option<HashMap<String, String>>,

View File

@@ -232,9 +232,9 @@ async fn handle_connection(
}
}
}
match &srv.server.cgi {
Some(c) => {
if srv.server.cgi.unwrap_or(false) {
match &srv.server.cgipath {
Some(c) => {
if c.trim_end_matches("/") == path.parent().unwrap().to_str().unwrap() {
if perm.mode() & 0o0111 == 0o0111 {
cgi::cgi(con, srv, path, url).await?;
@@ -244,9 +244,23 @@ async fn handle_connection(
con.send_status(Status::CGIError, None).await?;
return Ok(());
}
} else {
logger::logger(con.peer_addr, Status::CGIError, &request);
con.send_status(Status::CGIError, None).await?;
return Ok(());
}
},
None => {
if perm.mode() & 0o0111 == 0o0111 {
cgi::cgi(con, srv, path, url).await?;
return Ok(());
} else {
logger::logger(con.peer_addr, Status::CGIError, &request);
con.send_status(Status::CGIError, None).await?;
return Ok(());
}
},
}
None => {}
}
if perm.mode() & 0o0444 != 0o0444 {