[cgiwrap-users] patch for REMOTE_USER variable with cgiwrap via AddHandler
Brought to you by:
nneul
From: Jo R. <jr...@sv...> - 2006-07-19 18:04:50
|
If you are using "AddHandler .cgi" (the easy way to handle CGI scripts) then when you upgrade to Apache2 you suddently might not have REMOTE_USER information. This is because they (perhaps rightly so) decided that if something was redirected, it was useful to know if the redirection url had different authentication than the original url. We decided that it was better to fix this in cgiwrap, then to try and fix every possible application looking for REMOTE_USER. Following is the patch. --- util.c.orig Tue Dec 23 06:59:26 2003 +++ util.c Mon Feb 6 00:06:53 2006 @@ -1329,6 +1329,17 @@ sprintf(buf, "SCRIPT_NAME=%s", redurl); } SafePutenv(buf, "set SCRIPT_NAME environment variable"); + + /* Apache2 doesn't passthru REMOTE_USER */ + char* remote_user = getenv("REMOTE_USER"); + char* redirect_remote_user = getenv("REDIRECT_REMOTE_USER"); + if( redirect_remote_user && ! remote_user ) { + buf = (char*) SafeMalloc (strlen ("REMOTE_USER=") + + strlen( redirect_remote_user ) + 2, + "new REMOTE_USER environment variable"); + sprintf(buf, "REMOTE_USER=%s", redirect_remote_user ); + } + SafePutenv(buf, "set REMOTE_USER environment variable"); return; } #endif -- Jo Rhett senior geek SVcolo : Silicon Valley Colocation |