drupal-lua-conf.sh0000755000000000000000000000106311144514101013074 0ustar rootroot#! /bin/sh #usage: ./drupal-lua-conf.sh "" #usage: ./drupal-lua-conf.sh "drupal" #Directory, where the lua scripts are saved DIR="/etc/lighttpd/drupal-lua-scripts" # Create a lua script if necessary if [ ! -f "$DIR/p-$1.lua" ]; then sed -e "s/\%PATH/$1/g" $DIR/template.lua > "$DIR/p-$1.lua" fi # We add a trailing slash to %PATH2 if the path is not "" # %PATH never gets a trailing slash. SLASH="\/" if [ "$1" = "" ]; then SLASH="" fi #Replace %PATH and $PATH2 sed -e "s/\%PATH2/$1$SLASH/g" /etc/lighttpd/drupal-lua.conf | \ sed -e "s/\%PATH/$1/g" - drupal-lua-scripts/0000755000000000000000000000000011144572127013313 5ustar rootrootdrupal-lua-scripts/template.lua0000644000000000000000000000213611144566525015640 0ustar rootroot-- little helper function function file_exists(path) local attr = lighty.stat(path) if (attr) then return true else return false end end function removePrefix(str, prefix) return str:sub(1,#prefix+1) == prefix.."/" and str:sub(#prefix+2) end -- prefix without the trailing slash local prefix = '/%PATH' -- the magic ;) if (not file_exists(lighty.env["physical.path"])) then -- file still missing. pass it to the fastcgi backend request_uri = removePrefix(lighty.env["uri.path"], prefix) if request_uri then lighty.env["uri.path"] = prefix .. "/index.php" local uriquery = lighty.env["uri.query"] or "" lighty.env["uri.query"] = uriquery .. (uriquery ~= "" and "&" or "") .. "q=" .. request_uri lighty.env["physical.rel-path"] = lighty.env["uri.path"] lighty.env["request.orig-uri"] = lighty.env["request.uri"] lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"] end end -- fallthrough will put it back into the lighty request loop -- that means we get the 304 handling for free. ;) drupal-lua-scripts/p-.lua0000644000000000000000000000213011144572127014326 0ustar rootroot-- little helper function function file_exists(path) local attr = lighty.stat(path) if (attr) then return true else return false end end function removePrefix(str, prefix) return str:sub(1,#prefix+1) == prefix.."/" and str:sub(#prefix+2) end -- prefix without the trailing slash local prefix = '' -- the magic ;) if (not file_exists(lighty.env["physical.path"])) then -- file still missing. pass it to the fastcgi backend request_uri = removePrefix(lighty.env["uri.path"], prefix) if request_uri then lighty.env["uri.path"] = prefix .. "/index.php" local uriquery = lighty.env["uri.query"] or "" lighty.env["uri.query"] = uriquery .. (uriquery ~= "" and "&" or "") .. "q=" .. request_uri lighty.env["physical.rel-path"] = lighty.env["uri.path"] lighty.env["request.orig-uri"] = lighty.env["request.uri"] lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"] end end -- fallthrough will put it back into the lighty request loop -- that means we get the 304 handling for free. ;) drupal-lua.conf0000644000175000017500000000055311144603443012410 0ustar fagofago# % PATH will be replaced by sed # % PATH2 contains the path with a trailing slash $HTTP["url"] =~ "^/%PATH" { # "Fix" for Drupal SA-2006-006, requires lighttpd 1.4.13 $HTTP["url"] =~ "^/%PATH2.*/.*\.php$" { fastcgi.server = () url.access-deny = ("") } magnet.attract-physical-path-to = ("/etc/lighttpd/drupal-lua-scripts/p-%PATH.lua") }