CGI Everywhere
This commit is contained in:
4
README
4
README
@@ -35,6 +35,10 @@ Thanks to tiwesdaeg for figuring it out.
|
|||||||
|
|
||||||
## CGI Environments
|
## CGI Environments
|
||||||
|
|
||||||
|
In the configuration file there's "cgi" which is an optional bool to turn cgi
|
||||||
|
on. If it's true it'll run scripts from any directory. To limit it to only one
|
||||||
|
directory set "cgipath"
|
||||||
|
|
||||||
Scripts have 5 seconds to complete or they will be terminated.
|
Scripts have 5 seconds to complete or they will be terminated.
|
||||||
|
|
||||||
These variables are preset for you. If you need more you can define them in the
|
These variables are preset for you. If you need more you can define them in the
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ cert = "/path/to/cert"
|
|||||||
# index is optional but defaults to index.gemini. The server will serve files
|
# index is optional but defaults to index.gemini. The server will serve files
|
||||||
# ending in gemini or gmi.
|
# ending in gemini or gmi.
|
||||||
index = "index.gmi"
|
index = "index.gmi"
|
||||||
# cgi dir is optional
|
# cgi is optional bool
|
||||||
|
cgi = true
|
||||||
|
# cgipath is optional and only checked if cgi is true. It restricts cgi to only
|
||||||
|
# this directory.
|
||||||
cgi = "/path/to/cgi-bin/"
|
cgi = "/path/to/cgi-bin/"
|
||||||
# cgienv is optional
|
# cgienv is optional
|
||||||
cgienv = { "GIT_PROJECT_ROOT" = "/srv/git" }
|
cgienv = { "GIT_PROJECT_ROOT" = "/srv/git" }
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ pub struct Server {
|
|||||||
pub key: String,
|
pub key: String,
|
||||||
pub cert: String,
|
pub cert: String,
|
||||||
pub index: Option<String>,
|
pub index: Option<String>,
|
||||||
pub cgi: Option<String>,
|
pub cgi: Option<bool>,
|
||||||
|
pub cgipath: Option<String>,
|
||||||
pub cgienv: Option<HashMap<String, String>>,
|
pub cgienv: Option<HashMap<String, String>>,
|
||||||
pub usrdir: Option<bool>,
|
pub usrdir: Option<bool>,
|
||||||
pub proxy: Option<HashMap<String, String>>,
|
pub proxy: Option<HashMap<String, String>>,
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -232,8 +232,8 @@ async fn handle_connection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if srv.server.cgi.unwrap_or(false) {
|
||||||
match &srv.server.cgi {
|
match &srv.server.cgipath {
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
if c.trim_end_matches("/") == path.parent().unwrap().to_str().unwrap() {
|
if c.trim_end_matches("/") == path.parent().unwrap().to_str().unwrap() {
|
||||||
if perm.mode() & 0o0111 == 0o0111 {
|
if perm.mode() & 0o0111 == 0o0111 {
|
||||||
@@ -244,9 +244,23 @@ async fn handle_connection(
|
|||||||
con.send_status(Status::CGIError, None).await?;
|
con.send_status(Status::CGIError, None).await?;
|
||||||
return Ok(());
|
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 {
|
if perm.mode() & 0o0444 != 0o0444 {
|
||||||
|
|||||||
Reference in New Issue
Block a user