X-Git-Url: https://git.distorted.org.uk/~mdw/userv-utils/blobdiff_plain/f7b4be5ac332970bb5937ae586cea6de64d14f66..d083b489fb37f322b4896a8f7c449ac4a1ea1f77:/www-cgi/ucgitarget.c diff --git a/www-cgi/ucgitarget.c b/www-cgi/ucgitarget.c index 6c579b6..866a2d5 100644 --- a/www-cgi/ucgitarget.c +++ b/www-cgi/ucgitarget.c @@ -60,6 +60,11 @@ static const char *const default_envok[]= { "PATH_INFO", "PATH_TRANSLATED", "QUERY_STRING", + "REDIRECT_HANDLER", + "REDIRECT_SCRIPT_URI", + "REDIRECT_SCRIPT_URL", + "REDIRECT_STATUS", + "REDIRECT_URL", "REMOTE_ADDR", "REMOTE_HOST", "REMOTE_USER", @@ -77,6 +82,10 @@ static const char *const default_envok[]= { "SERVER_PROTOCOL", "SERVER_SIGNATURE", "SERVER_SOFTWARE", + "SSL_CIPHER", + "SSL_CLIENT_S_DN", + "SSL_CLIENT_VERIFY", + "SSL_PROTOCOL", 0 }; @@ -100,19 +109,19 @@ int main(int argc, char **argv) { if (ev && *ev) debugmode= 1; D( if (debugmode) printf(";;; UCGITARGET\n"); ) - if (argc > MAX_ARGS) error("too many arguments"); + if (argc > MAX_ARGS) error("too many arguments", 500); for (;;) { i= getopt(argc, argv, "+e:"); if (i < 0) break; switch (i) { case 'e': filters= optarg; break; - default: error("bad command line"); break; + default: error("bad command line", 500); break; } } argc -= optind; argv += optind; - if (!*argv) error("no script directory argument"); - ev= getenv("HOME"); if (!ev) error("no HOME env. var"); + if (!*argv) error("no script directory argument", 500); + ev= getenv("HOME"); if (!ev) error("no HOME env. var", 500); l= strlen(*argv)+strlen(ev); newvar= xmalloc(l+2); sprintf(newvar,"%s/%s",ev,*argv); @@ -126,14 +135,13 @@ int main(int argc, char **argv) { ".userv/ucgitarget.env-filter", "/etc/userv/ucgitarget.env-filter", LF_END); - if (!envok) envok= default_envok; } - filter_environment(0, "USERV_U_E_", envok, setenvar, 0); + filter_environment(0, "USERV_U_E_", envok, default_envok, setenvar, 0); scriptpath= 0; pathi= getenv("PATH_INFO"); - if (!pathi) error("PATH_INFO not found"); + if (!pathi) error("PATH_INFO not found", 500); lastslash= pathi; D( if (debugmode) { printf(";; find script name...\n" @@ -141,23 +149,25 @@ int main(int argc, char **argv) { pathi); } ) for (;;) { - if (*lastslash != '/') error("PATH_INFO expected slash not found"); - if (lastslash[1]=='.' || lastslash[1]=='#' || !lastslash[1]) error("bad char begin"); + if (*lastslash != '/') error("PATH_INFO expected slash not found", 400); + if (lastslash[1]=='.' || lastslash[1]=='#' || !lastslash[1]) + error("bad char begin", 400); nextslash= strchr(lastslash+1,'/'); if (!nextslash) nextslash= lastslash+1+strlen(lastslash+1); - if (!nextslash) error("insufficient elements in PATH_INFO"); - if (nextslash==lastslash+1) error("empty component in PATH_INFO"); - if (nextslash-pathi > MAX_SCRIPTPATH_LEN) error("PATH_INFO script path too long"); + if (!nextslash) error("insufficient elements in PATH_INFO", 400); + if (nextslash==lastslash+1) error("empty component in PATH_INFO", 400); + if (nextslash-pathi > MAX_SCRIPTPATH_LEN) + error("PATH_INFO script path too long", 400); scriptpathlen= scriptdirlen+(nextslash-pathi); scriptpath= xrealloc(scriptpath,scriptpathlen+1); strcpy(scriptpath,scriptdir); memcpy(scriptpath+scriptdirlen,pathi,nextslash-pathi); scriptpath[scriptpathlen]= 0; - if (scriptpath[scriptpathlen-1]=='~') error("bad char end"); + if (scriptpath[scriptpathlen-1]=='~') error("bad char end", 400); D( if (debugmode) printf(";; try `%s'\n", scriptpath); ) r= stat(scriptpath,&stab); if (r) syserror("stat script"); if (S_ISREG(stab.st_mode)) break; - if (!S_ISDIR(stab.st_mode)) error("script not directory or file"); + if (!S_ISDIR(stab.st_mode)) error("script not directory or file", 500); lastslash= nextslash; } D( if (debugmode) printf(";; found script: tail = `%s'\n", nextslash); ) @@ -172,7 +182,7 @@ int main(int argc, char **argv) { ev= getenv("SCRIPT_NAME"); if (ev) { - ev2= getenv("USER"); if (!ev2) error("no USER variable"); + ev2= getenv("USER"); if (!ev2) error("no USER variable", 500); newvar= xmalloc(strlen(ev)+2+strlen(ev2)+scriptpathlen-scriptdirlen+2); sprintf(newvar,"%s/~%s%s",ev,ev2,scriptpath+scriptdirlen); xsetenv("SCRIPT_NAME",newvar,1);