diff options
author | Erich Eckner <git@eckner.net> | 2018-09-29 10:49:18 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-09-29 10:49:18 +0200 |
commit | 6bbc898d2f1022665f4254f63f3df735e398340c (patch) | |
tree | bffdf227d7f2aa5b1fc9c96683f6bbeaece71e8e /httpdocs | |
parent | 15585cf57db2760a50121d8d74e073310bf95f5a (diff) | |
download | archive-server-6bbc898d2f1022665f4254f63f3df735e398340c.tar.xz |
httpdocs/index.php: allow for hg to be requested for wish-list
Diffstat (limited to 'httpdocs')
-rw-r--r-- | httpdocs/index.php | 31 |
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'); |