// and this is where i re-code the git backend interface from scratch
global $BASE_URL;
+ header_remove("Pragma");\r
+ header_remove("Cache-Control");\r
+ header_remove("Set-Cookie");\r
+ header_remove("Expires");\r
+ header_remove("X-Powered-By");\r
+ header_remove("Vary");\r
+
+
$repo_base = gwvpmini_getConfigVal("repodir");
// TODO: we need to stop passing the repo name around as "repo.git", it needs to be just "repo"
$write = true;
}
}
- if($_SERVER["REQUEST_METHOD"] == "POST") {
- $write = true;
- }
//$write = true;
// THIS MAY CAUSE ISSUES LATER ON but we do it cause the git client ignores our 403 when it uses git-receive-pack after an auth
//$write = true;
//}
- $perms = 5;
- $write = true;
+ $person = gwvpmini_checkBasicAuthLogin();
+ //$write = true;
+ // next, figure out permissions for repo
+ $rid = gwvpmini_GetRepoId($repo);
+ $uid = -1;
+ error_log("AT THIS POINT WE HAVE $uid, $rid, $repo $person");
- // if its a write, we push for authentication
- if($write) {
- error_log("is write attempt, ask for login");
- $person = gwvpmini_checkBasicAuthLogin();
- if($person == false) {
- error_log("person is false, push auth");
+ if(!$person) {
+ if($write) {
+ error_log("ASK FOR BASIC AUTH");
gwvpmini_AskForBasicAuth();
- echo "Login";
return;
} else {
- error_log("checking perms for $person against $repoid for repo $repo");
- // here we pass to the git backend
- error_log("perms are $perms and im allowed");
- gwvpmini_callGitBackend($person["username"], $repo);
+ $perm = gwvpmini_GetRepoPerm($rid, "a");
+ if($perm < 1) {
+ error_log("ASK FOR BASIC AUTH 2");
+ gwvpmini_AskForBasicAuth();
+ return;
+ }
}
- return;
- }
-
-
- // if they're less then read, we need to then check the user auth permissions
- if($perms < 2) {
- // we ask for auth
- $person = gwvpmini_checkBasicAuthLogin();
- if($person == false) {
- gwvpmini_AskForBasicAuth();
- return;
+ } else {
+ $uid = gwvpmini_GetUserId($person);
+ $perm = gwvpmini_GetRepoPerm($rid, $uid);
+ if($write) {
+ if($perm < 2) {
+ error_log("SEND FOFF");
+ gwvpmini_fourZeroThree();
+ return;
+ }
} else {
+ if($perm < 1) {
+ gwvpmini_fourZeroThree();
+ return;
+ }
}
}
+ // if its a write, we push for authentication
+
+ //if($write) {
+ if(!$person) {
+ $person = "anonymous";
+ }
+ gwvpmini_callGitBackend($person, $repo);
+ return;
+ //}
+
// if we made it this far, we a read and we have permissions to do so, just search the file from the repo
- if(file_exists("$repo_base/$repo.git/$newloc")) {
+ /*if(file_exists("$repo_base/$repo.git/$newloc")) {
error_log("would ask $repo for $repo.git/$newloc from $repo_base/$repo.git/$newloc");
$fh = fopen("$repo_base/$repo.git/$newloc", "rb");
echo fread($fh, 8192);
}
} else {
- //echo "would ask $repo,$actual_repo_name for $repo/$newloc from $repo_base/$repo/$newloc, NE";
+ error_log("would ask $repo for $repo/$newloc from $repo_base/$repo/$newloc, NE");
gwvpmini_fourZeroFour();
return;
- }
+ }*/
}
error_log("cant set pipe1 non-blocking");
}
+
+ $fp = fopen("/tmp/gitup.".rand(0,4000000), "w");
// i was going to use stream_select, but i feel this works better like this
while($continue) {
// do client
if(!feof($fh)) {
$from_client_data = fread($fh,8192);
- if($from_client_data !== false) fwrite($pipes[0], $from_client_data);
+ if($from_client_data !== false) {
+ fwrite($pipes[0], $from_client_data);
+ fwrite($fp, $from_client_data);
+ }
fflush($pipes[0]);
//fwrite($fl, $from_client_data);
$client_len = strlen($from_client_data);