function gwvp_AskForBasicAuth()
{
+ error_log("AUTH: asking for basic auth");
if(!isset($_SERVER["PHP_AUTH_USER"])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
$pass = $_SERVER["PHP_AUTH_PW"];
} else return false;
- return gwvp_authUserPass($user, $pass);
+ error_log("passing basic auth for $user, $pass to backend");
+ $auth = gwvp_authUserPass($user, $pass);
+ if($auth !== false) {
+ error_log("auth passes");
+ }
+
+ return $auth;
}
function gwvp_IsLoggedIn()
gwvp_SendMessage("info", "blank db re-created");
- gwvp_AddRepo("repo1", "this is a test repo1", $adminid);
- gwvp_AddRepo("repo2", "this is a test repo2", $userid1);
- gwvp_AddRepo("repo3", "this is a test repo3", $userid2);
-
+ //gwvp_createGitRepo($name, $ownerid, $desc, $bundle=null, $defaultperms=0)
gwvp_setConfigVal("repodir", "/tmp/");
+ // TODO change these to create not add.
+ system("rm -rf /tmp/repo1.git /tmp/repo2.git /tmp/repo3.git");
+ gwvp_createGitRepo("repo1", $adminid, "test repo1");
+ gwvp_createGitRepo("repo2", $userid1, "test repo2");
+ gwvp_createGitRepo("repo3", $userid2, "test repo3");
+
+
+
header("Location: $BASE_URL/debug");
break;
case "dropallusersandgroups":
// TODO: we need to stop passing the repo name around as "repo.git", it needs to be just "repo"
$repo = "";
- $repoid = -1;
+ $repoid = false;
$newloc = "/";
if(isset($_REQUEST["q"])) {
$query = $_REQUEST["q"];
$qspl = explode("/", $query);
- $repo = $qspl[1];
- $repoid = gwvp_resolvRepoPerms($repo);
+ // TODO do this with
+ $repo = preg_replace("/\.git$/", "", $qspl[1]);
+ $repoid = gwvp_GetRepoId($repo);
for($i=2; $i < count($qspl); $i++) {
$newloc .= "/".$qspl[$i];
}
}
- if($repoid == -1) {
+ if($repoid == false) {
gwvp_fourZeroFour();
return;
}
+ // we do an update server cause its weird and i cant figure out when it actually needs to happen
+ chdir("$repo_base/$repo.git");
+ exec("/usr/bin/git update-server-info");
+
+
// so now we have the repo
// next we determine if this is a read or a write
$write = false;
gwvp_AskForBasicAuth();
return;
} else {
- $perms = gwvp_resolvRepoPerms($person["id"], $repoid);
+ error_log("checking perms for $person against $repoid");
+ $perms = gwvp_resolvRepoPerms(gwvp_getUserId($person), $repoid);
if($perms < 3) {
gwvp_fourZeroThree();
return;
} else {
// here we pass to the git backend
+ error_log("perms are $perms and im allowed");
gwvp_callGitBackend($person["username"], $repo);
}
}
gwvp_AskForBasicAuth();
return;
} else {
- $perms = gwvp_resolvRepoPerms($person["id"], $repoid);
+ $perms = gwvp_resolvRepoPerms(gwvp_getUserId($person), $repoid);
if($perms < 3) {
+ $dump = print_r($person, true);
+ error_log("in basic read, called 403 for $perms $dump");
gwvp_fourZeroThree();
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/$newloc")) {
+ if(file_exists("$repo_base/$repo.git/$newloc")) {
error_log("would ask $repo,$actual_repo_name for $repo/$newloc from $repo_base/$repo/$newloc");
- $fh = fopen("$repo_base/$repo/$newloc", "rb");
+ $fh = fopen("$repo_base/$repo.git/$newloc", "rb");
error_log("pushing file");
while(!feof($fh)) {
return false;
}
-function gwvp_callGitBackend($username, $reponame)
+function gwvp_callGitBackend($username, $repo)
{
// this is where things become a nightmare
$fh = fopen('php://input', "r");
$ruri = $_SERVER["REQUEST_URI"];
- $strrem = "git/$repo";
+ $strrem = "git/$repo.git";
$euri = str_replace($strrem, "", $_REQUEST["q"]);
//$euri = preg_replace("/^git\/$repo\.git/", "", $_REQUEST["q"]);
// setup env
if(isset($procenv)) unset($procenv);
$procenv["GATEWAY_INTERFACE"] = "CGI/1.1";
- $procenv["PATH_TRANSLATED"] = "/tmp/$repo/$euri";
+ $procenv["PATH_TRANSLATED"] = "/tmp/$repo.git/$euri";
$procenv["REQUEST_METHOD"] = "$rmeth";
$procenv["GIT_HTTP_EXPORT_ALL"] = "1";
$procenv["QUERY_STRING"] = "$qs";
$procenv["CONTENT_LENGTH"] = $_SERVER["CONTENT_LENGTH"];
}
- error_log("path trans'd is /tmp/$repo/$euri from $ruri with ".$_REQUEST["q"]." $strrem");
+ error_log("path trans'd is /tmp/$repo.git/$euri from $ruri with ".$_REQUEST["q"]." $strrem");