chiark / gitweb /
www-cgi/: Allow customization of the environment filters.
[userv-utils.git] / www-cgi / ucgi.c
index 006f8ae4cd93223986d15c146967d032908eeefa..a2ebe64a4b0e18d9247216bfd71c4b6965d5069e 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "ucgi.h"
 
-static const char *const envok[] = {
+static const char *const default_envok[] = {
   "AUTH_TYPE",
   "CONTENT_TYPE",
   "CONTENT_LENGTH",
@@ -73,7 +73,8 @@ static void add_userv_var(const char *fulln,
 
 int main(int argc, const char **argv) {
   char *username;
-  const char *slash2, *pathi, *av;
+  const char *slash2, *pathi, *ev, *av;
+  const char *const *envok;
   size_t usernamelen, l;
   struct buildargs args;
   pid_t child, rchild;
@@ -91,6 +92,14 @@ int main(int argc, const char **argv) {
   
   if (argc > MAX_ARGS) error("too many arguments");
 
+  ev= getenv("UCGI_ENV_FILTER");
+  if (ev)
+    envok= load_filters(LOADF_MUST, ev, LF_END);
+  else {
+    envok= load_filters(0, "/etc/userv/ucgi.env-filter", LF_END);
+    if (!envok) envok= default_envok;
+  }
+
   pathi= getenv("PATH_INFO");
   if (!pathi) error("PATH_INFO not found");
   D( if (debugmode) {