summaryrefslogtreecommitdiff
path: root/httpdocs/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'httpdocs/index.php')
-rw-r--r--httpdocs/index.php31
1 files changed, 19 insertions, 12 deletions
diff --git a/httpdocs/index.php b/httpdocs/index.php
index e6874fe..b519fe3 100644
--- a/httpdocs/index.php
+++ b/httpdocs/index.php
@@ -10,7 +10,8 @@ if (isset($_GET['r'])) {
if (!isset($_GET['t']))
die('Repository type not given');
- if ($_GET['t']!='git')
+ if (($_GET['t']!='git') &&
+ ($_GET['t']!='hg'))
die('Repository type not implemented');
if (!is_dir($work_dir . 'repositories/' . $_GET['t'] . '/' . $_GET['r'])) {
@@ -30,7 +31,7 @@ if (isset($_GET['r'])) {
'echo "' . $_GET['tag'] . '" | ' .
'base64 -d' .
')';
- } elseif (isset($_GET['commit'])) {
+ } elseif (($_GET['t']=='git') && isset($_GET['commit'])) {
if (!preg_match('/^[A-Fa-f0-9]{40}$/', $_GET['commit']))
die('The given commit does not have exactly 40 hex digits');
$commit_identifier = $_GET['commit'];
@@ -65,11 +66,14 @@ if (isset($_GET['r'])) {
'--recv-keys ' . implode(' ',explode(',',$_GET['valid_keys']))
);
- if (trim(shell_exec(
- 'GNUPGHOME="' . $work_dir . 'gnupg" git -C "' . $work_dir . 'repositories/' . $_GET['t'] . '/' . $_GET['r'] . '" verify-tag --raw "' . $commit_identifier . '" 2>&1 | ' .
- 'grep -c "\[GNUPG:\] VALIDSIG ' . $key_regex . ' "'
- )) == '0')
- die('Commit ' . $commit_identifier . ' is not signed by ' . $_GET['valid_keys']);
+ if ($_GET['t']=='git') {
+ if (trim(shell_exec(
+ 'GNUPGHOME="' . $work_dir . 'gnupg" git -C "' . $work_dir . 'repositories/' . $_GET['t'] . '/' . $_GET['r'] . '" verify-tag --raw "' . $commit_identifier . '" 2>&1 | ' .
+ 'grep -c "\[GNUPG:\] VALIDSIG ' . $key_regex . ' "'
+ )) == '0')
+ die('Commit ' . $commit_identifier . ' is not signed by ' . $_GET['valid_keys']);
+ } else
+ die('Checking signatures is not implemented for ' . $_GET['t'] . ' repositories');
}
if (isset($_GET['p'])) {
if (base64_decode($_GET['p'],true)===false)
@@ -81,11 +85,14 @@ if (isset($_GET['r'])) {
} else {
$prefix = '';
}
- $handle = popen(
- 'git -C "../work/repositories/' . $_GET['t'] . '/' . $_GET['r'] . '" archive' . $prefix . ' "' . $commit_identifier . '" | ' .
- 'gzip -nc',
- 'r'
- );
+ if ($_GET['t']=='git')
+ $handle = popen(
+ 'git -C "../work/repositories/' . $_GET['t'] . '/' . $_GET['r'] . '" archive' . $prefix . ' "' . $commit_identifier . '" | ' .
+ 'gzip -nc',
+ 'r'
+ );
+ else
+ $handle = false;
if ($handle === false)
die('Unable to create archive');
header('Content-type: application/x-gzip');