diff --git a/www/cvsweb/cvsweb.cgi b/www/cvsweb/cvsweb.cgi index afb6c55467064454c294927ad7af40806533f2a3..f2704f04f1b5fc8537c8db8116c063b01341df44 100755 --- a/www/cvsweb/cvsweb.cgi +++ b/www/cvsweb/cvsweb.cgi @@ -46,7 +46,7 @@ # SUCH DAMAGE. # # $FreeBSD: projects/cvsweb/cvsweb.cgi,v 1.119.2.6 2002/09/26 20:56:05 scop Exp $ -# $Id: cvsweb.cgi,v 1.9 2007-04-07 05:39:29 johnsond Exp $ +# $Id: cvsweb.cgi,v 1.10 2007-07-20 18:52:07 stoller Exp $ # $Idaemons: /home/cvs/cvsweb/cvsweb.cgi,v 1.84 2001/10/07 20:50:10 knu Exp $ # ### @@ -312,7 +312,7 @@ $maycompress = # their current value) to any link/query string # you construct @stickyvars = qw(cvsroot hideattic sortby logsort f only_with_tag - pid eid exptidx); + pid eid exptidx guid version); @unsafevars = qw(logsort only_with_tag r1 r2 rev sortby tr1 tr2); if (-f $config) { diff --git a/www/cvsweb/cvsweb.php3 b/www/cvsweb/cvsweb.php3 index 5e96615d215be34e38a196c5bb8a982db5aab9fd..97d7bc6ed24eecbf37f50a0e59acf4a80e711e2c 100644 --- a/www/cvsweb/cvsweb.php3 +++ b/www/cvsweb/cvsweb.php3 @@ -32,9 +32,7 @@ $use_viewvc = 0; # # Verify form arguments. # -$optargs = OptionalPageArguments("experiment", PAGEARG_EXPERIMENT, - "instance", PAGEARG_INSTANCE, - "template", PAGEARG_TEMPLATE, +$optargs = OptionalPageArguments("template", PAGEARG_TEMPLATE, "project", PAGEARG_PROJECT, "embedded", PAGEARG_BOOLEAN); if (!isset($embedded)) { @@ -57,111 +55,44 @@ if (isset($project)) { header("Location: $url"); return; } - if (isset($experiment)) { - # - # Wants access to the experiment archive, which is really a repo. - # - $pid = $experiment->pid(); - $eid = $experiment->eid(); - - if (! ISADMIN() && - ! $experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) { - USERERROR("Not enough permission to view '$pid/$eid'", 1); - } - # Get the repo index for the experiment. + # + # Authenticated access to the project repo. + # + if (! ISADMIN() && + ! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) { + # Then check to see if the project cvs repo is public. $query_result = - DBQueryFatal("select s.archive_idx from experiments as e ". - "left join experiment_stats as s on s.exptidx=e.idx ". - "where e.pid='$pid' and e.eid='$eid'"); - + DBQueryFatal("select cvsrepo_public from projects ". + "where pid='$pid'"); if (!mysql_num_rows($query_result)) { - TBERROR("Error getting repo index for '$pid/$eid'", 1); + TBERROR("Error getting cvsrepo_public bit", 1); } $row = mysql_fetch_array($query_result); - if (!isset($row[0])) { - TBERROR("Error getting repo index for '$pid/$eid'", 1); - } - $repoidx = $row[0]; - $repodir = "/usr/testbed/exparchive/$repoidx/repo/"; - $use_viewvc = 1; - } - else { - # - # Wants access to the project repo. - # - if (! ISADMIN() && - ! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) { - # Then check to see if the project cvs repo is public. - $query_result = - DBQueryFatal("select cvsrepo_public from projects ". - "where pid='$pid'"); - if (!mysql_num_rows($query_result)) { - TBERROR("Error getting cvsrepo_public bit", 1); - } - $row = mysql_fetch_array($query_result); - if ($row[0] == 0) { - USERERROR("You are not a member of Project $pid.", 1); - } + if ($row[0] == 0) { + USERERROR("You are not a member of Project $pid.", 1); } - $repodir = "$TBCVSREPO_DIR/$pid"; } + $repodir = "$TBCVSREPO_DIR/$pid"; } -elseif (isset($experiment) || isset($instance) || isset($template)) { +elseif (isset($template)) { if (!$CVSSUPPORT) { USERERROR("Project CVS support is not enabled!", 1); } # Must be logged in for this! - if ($this_user) { - CheckLoginOrDie(); - } + $this_user = CheckLoginOrDie(); - if (isset($template)) { - $experiment = $template->GetExperiment(); - } - - if (isset($instance)) { - $pid = $instance->pid(); - $eid = $instance->eid(); - $idx = $instance->exptidx(); - $project = $instance->Project(); - } - else { - $pid = $experiment->pid(); - $eid = $experiment->eid(); - $idx = $experiment->idx(); - $project = $experiment->Project(); - } - - # Need the pid/eid/gid. Access the stats table since we want to provide - # cvs access to terminated experiments via the archive. - $query_result = - DBQueryFatal("select s.archive_idx,a.archived ". - " from experiment_stats as s ". - "left join archives as a on a.idx=s.archive_idx ". - "where s.exptidx='$idx'"); - if (!mysql_num_rows($query_result)) { - USERERROR("Experiment '$idx' is not a valid experiment", 1); - } - $row = mysql_fetch_array($query_result); - $repoidx = $row[0]; - $archived = $row[1]; + $guid = $template->guid(); + $vers = $template->vers(); + $pid = $template->pid(); + $project = $template->GetProject(); - # Lets do group level check since it might not be a current experiment. - if (!$archived) { - if (! ISADMIN() && - ! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) { - USERERROR("Not enough permission to view archive", 1); - } - $repodir = "/usr/testbed/exparchive/$repoidx/repo/"; - } - else { - if (! ISADMIN()) { - USERERROR("Must be administrator to view historical archives!", 1); - } - $repodir = "/usr/testbed/exparchive/Archive/$repoidx/repo/"; + if (! ISADMIN() && + ! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) { + USERERROR("Not enough permission to view cvs repo for template", 1); } - $use_viewvc = 1; + # Repo for the entire template stored here per-template. + $repodir = "$TBPROJ_DIR/$pid/templates/$guid/cvsrepo/$guid"; } else { $this_user = CheckLoginOrDie(); diff --git a/www/cvsweb/cvswebwrap.php3 b/www/cvsweb/cvswebwrap.php3 index 1f9d02ba7f84cbf70f00e9eb5e92ae46374434d4..2ac0b27c25aa5fdaf7c416227aaaadf33f098ef2 100644 --- a/www/cvsweb/cvswebwrap.php3 +++ b/www/cvsweb/cvswebwrap.php3 @@ -11,16 +11,21 @@ chdir("../"); require("defs.php3"); -# -# Make sure that URL args are cleaned. -# -RequiredPageArguments(); - # Must be logged in. $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); +# +# Verify form arguments. +# +$optargs = OptionalPageArguments("template", PAGEARG_TEMPLATE, + "project", PAGEARG_PROJECT, + "embedded", PAGEARG_BOOLEAN); +if (!isset($embedded)) { + $embedded = 0; +} + # # Form the real url. # @@ -32,24 +37,20 @@ $newurl = preg_replace("/php3/","php3/",$newurl); # PAGEHEADER("Emulab CVS Repository"); -?> - - - - - -
- -
+echo "
\n"; +echo "
\n"; -\n"; +echo "SetupOutputArea('outputframe', false);\n"; +echo "\n"; # # Standard Testbed Footer diff --git a/www/template_defs.php b/www/template_defs.php index ca5b80b9d792d7015012a072a6cea2d2684cad20..c543378ab9fda3404e040496743a234acaeba209 100644 --- a/www/template_defs.php +++ b/www/template_defs.php @@ -167,6 +167,15 @@ class Template return $this->experiment; } + function GetProject() { + $pid = $this->pid(); + + if (! ($project = Project::Lookup($pid))) { + TBERROR("Could not lookup project $pid!", 1); + } + return $project; + } + # Return the unixgid for operating on this template. function UnixGID() { $experiment = $this->experiment; @@ -2282,7 +2291,7 @@ function MakeLink($which, $args, $text) $page = "showuser.php3"; } elseif ($which == "template") { - $page = "template_show.php"; + $page = "/template_show.php"; } elseif ($which == "metadata") { $page = "template_metadata.php"; diff --git a/www/template_show.php b/www/template_show.php index c613e9c5db118ea61c15038dd72d82b20f38ab42..a62a48f963b1d23cc24b28bf55787c25e9a4804a 100644 --- a/www/template_show.php +++ b/www/template_show.php @@ -323,6 +323,9 @@ if ($template->EventCount() > 0) { WRITESUBMENUBUTTON("Browse Datastore", CreateURL("archive_view", $template)); +WRITESUBMENUBUTTON("Browse CVS Repository", + CreateURL("cvswebwrap", $template)); + WRITESUBMENUBUTTON("View Records", CreateURL("template_history", $template)); diff --git a/www/url_defs.php b/www/url_defs.php index f24826d9f4ac5b51fdfdc657e2f21e15971458fb..7511ec9ebf00cd71b0c385214ad91adf1ca199c0 100644 --- a/www/url_defs.php +++ b/www/url_defs.php @@ -105,6 +105,7 @@ $url_mapping["spitreport"] = "spitreport.php"; $url_mapping["statechange"] = "statechange.php"; $url_mapping["experimentrun_show"] = "experimentrun_show.php"; $url_mapping["instance_show"] = "instance_show.php"; +$url_mapping["cvswebwrap"] = "cvsweb/cvswebwrap.php3"; # # The caller will pass in a page id, and a list of things. If the thing