From 1dbfde26ce2b413bed52a7cf7f93f349496951e0 Mon Sep 17 00:00:00 2001 From: paulr Date: Mon, 31 Oct 2011 02:53:38 +1100 Subject: [PATCH] pulls/clones now work thru git-http-backend THRU my php script unbelievable... and painful... but unbelievable none the less --- gwvplib/gwvplib.php | 5 ++ gwvplib/gwvpweb.php | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++- www/index.php | 5 +- 3 files changed, 109 insertions(+), 4 deletions(-) diff --git a/gwvplib/gwvplib.php b/gwvplib/gwvplib.php index e69de29..7e671e0 100644 --- a/gwvplib/gwvplib.php +++ b/gwvplib/gwvplib.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/gwvplib/gwvpweb.php b/gwvplib/gwvpweb.php index 8148e00..03daa77 100644 --- a/gwvplib/gwvpweb.php +++ b/gwvplib/gwvpweb.php @@ -1,9 +1,108 @@ $var) { + if($key != "q") { + error_log("adding, $var from $key"); + if($qs == "") $qs.="$key=$var"; + else $qs.="&$key=$var"; + } + } + + //sleep(2); + + $body = ''; + if($rmeth == "POST") { + $body = file_get_contents("php://input"); + } + + + // this is where the fun, it ends. + $myoutput = ""; + unset($myoutput); + + // this be nasty! + + // setup env + if(isset($procenv)) unset($procenv); + $procenv["GATEWAY_INTERFACE"] = "CGI/1.1"; + $procenv["PATH_TRANSLATED"] = "/var/cache/git/test.git$euri"; + $procenv["REQUEST_METHOD"] = "$rmeth"; + $procenv["GIT_HTTP_EXPORT_ALL"] = "1"; + $procenv["QUERY_STRING"] = "$qs"; + $procenv["HTTP_USER_AGENT"] = "git/1.7.1"; + $procenv["REMOTE_USER"] = "paulr"; + $procenv["REMOTE_ADDR"] = "1.2.3.4"; + $procenv["CONTENT_TYPE"] = "application/x-git-upload-pack-request"; + + $pwd = "/var/cache/git"; + + error_log("openproc"); + $proc = proc_open("/usr/lib/git-core/git-http-backend", array(array("pipe","r"),array("pipe","w"),array("file","/dev/null", "w")), $pipes, $pwd, $procenv); + error_log("openproc2, $proc"); + + $stdin = $pipes[0]; + $stdout = $pipes[1]; + + error_log("openproc3"); + + if($body != "") { + fwrite($pipes[0], $body); + } + + error_log("openproc4"); + + $untilblank = false; + while(!$untilblank&&!feof($pipes[1])) { + $lines = rtrim(fgets($pipes[1])); + error_log("got line: $lines"); + if($lines == "") { + $untilblank = true; + error_log("now blank"); + } else header($lines); + if($lines === false) exit(0); + + } + + error_log("openproc5"); + + // now the body + while(!feof($pipes[1])) { + echo fread($pipes[1], 1024); + } + + error_log("openproc6"); + + fclose($stdout); + fclose($stdin); + + + + } } ?> \ No newline at end of file diff --git a/www/index.php b/www/index.php index fb71493..cfe2386 100644 --- a/www/index.php +++ b/www/index.php @@ -13,8 +13,9 @@ require_once("config.php"); * 5. do we auth? */ -goWeb(); +goWebGitBackEnd(); +/* echo "
";
 echo "BASEURL: $BASE_URL\n";
 echo "CUSTOM\n";
@@ -23,6 +24,6 @@ print_r($_REQUEST);
 
 
 echo "
"; - +*/ ?> -- 1.7.0.4