aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-03-14 13:18:39 +0100
committermetamuffin <metamuffin@disroot.org>2025-03-14 13:18:39 +0100
commitae08cd5ff7429b2d5fd5161f8ca18e52f8fb4d1d (patch)
treed9d3f76ee97f7adaf2560984ea2999f1a8e0c9ed
parentc17d5d20d6985ff10b3a06a86d1618c5bcc74e0d (diff)
downloadgnix-ae08cd5ff7429b2d5fd5161f8ca18e52f8fb4d1d.tar
gnix-ae08cd5ff7429b2d5fd5161f8ca18e52f8fb4d1d.tar.bz2
gnix-ae08cd5ff7429b2d5fd5161f8ca18e52f8fb4d1d.tar.zst
cgi: add env map option; close #5
-rw-r--r--src/modules/cgi.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/modules/cgi.rs b/src/modules/cgi.rs
index 2af8537..7d58539 100644
--- a/src/modules/cgi.rs
+++ b/src/modules/cgi.rs
@@ -11,7 +11,8 @@ use hyper::{
use serde::Deserialize;
use serde_yml::Value;
use std::{
- future::Future, io::ErrorKind, path::PathBuf, pin::Pin, process::Stdio, str::FromStr, sync::Arc,
+ collections::BTreeMap, future::Future, io::ErrorKind, path::PathBuf, pin::Pin, process::Stdio,
+ str::FromStr, sync::Arc,
};
use tokio::{
io::{copy, AsyncBufReadExt, BufReader, BufWriter},
@@ -26,8 +27,11 @@ pub struct CgiKind;
#[derive(Deserialize)]
struct CgiConfig {
bin: PathBuf,
+ #[serde(default)]
+ env: BTreeMap<String, String>,
user: Option<String>,
}
+
struct Cgi {
config: CgiConfig,
user: Option<u32>,
@@ -74,7 +78,7 @@ impl Node for Cgi {
command.uid(uid);
}
- // command.env("AUTH_TYPE", );
+ command.envs(&self.config.env);
command.env(
"CONTENT_LENGTH",
request