Commit 304e04b1 authored by Robert Ricci's avatar Robert Ricci

Add cvsweb, a web interface into CVS. Since it's in perl, and all of

our web access checks are in php3, it's wrapped in a php3 wrapper
script. Access to it is controlled via the cvsweb column in the
users table.

cvsweb only gets installed on the main emulab site - that is, if
OURDOMAIN is defined to be emulab.net

cvsweb itself is originally from http://www.idaemons.org/~knu/cvsweb/
parent cc66455e
......@@ -6,6 +6,12 @@ TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ..
SUBDIR = www
#
# A hack for only installing some things if installing on the main site
#
MAINSITE = emulab.net
OURDOMAIN = @OURDOMAIN@
include $(OBJDIR)/Makeconf
#
......@@ -55,16 +61,29 @@ BUIFILES += $(wildcard $(SRCDIR)/buildui/*.class)
WEBDBFILES = $(wildcard $(SRCDIR)/webdb/*.php3)
#
# This stuff only gets installed on the main site
#
ifeq ($(OURDOMAIN),$(MAINSITE))
CVSWEBFILES = $(wildcard $(SRCDIR)/cvsweb/*.php3)
CVSWEBFILES += $(wildcard $(SRCDIR)/cvsweb/*.conf)
CVSWEBFILES += $(wildcard $(SRCDIR)/cvsweb/*.gif)
CVSWEBCGI = $(wildcard $(SRCDIR)/cvsweb/*.cgi)
INSTALL_CVSWEBCGI = $(INSTALL_PROGRAM) $(CVSWEBCGI) $(INSTALL_WWWDIR)/cvsweb
endif
#
# Kill the directory part of the names. The vpath rule will do the rest.
#
ALLFILES = $(notdir $(FILES))
ALLPIXES = $(notdir $(PIXFILES))
ALLDOCS = $(notdir $(DOCFILES))
ALLTUTS = $(notdir $(TUTFILES))
ALLICONS = $(notdir $(AUTOICONS))
ALLWEBDB = $(notdir $(WEBDBFILES))
ALLBUI = $(notdir $(BUIFILES))
ALLFILES = $(notdir $(FILES))
ALLPIXES = $(notdir $(PIXFILES))
ALLDOCS = $(notdir $(DOCFILES))
ALLTUTS = $(notdir $(TUTFILES))
ALLICONS = $(notdir $(AUTOICONS))
ALLWEBDB = $(notdir $(WEBDBFILES))
ALLCVSWEB = $(notdir $(CVSWEBFILES))
ALLBUI = $(notdir $(BUIFILES))
install: $(addprefix $(INSTALL_WWWDIR)/, $(ALLFILES)) \
$(addprefix $(INSTALL_WWWDIR)/pix/, $(ALLPIXES)) \
......@@ -72,7 +91,8 @@ install: $(addprefix $(INSTALL_WWWDIR)/, $(ALLFILES)) \
$(addprefix $(INSTALL_WWWDIR)/doc/, $(ALLDOCS)) \
$(addprefix $(INSTALL_WWWDIR)/webdb/, $(ALLWEBDB)) \
$(addprefix $(INSTALL_WWWDIR)/buildui/, $(ALLBUI)) \
$(addprefix $(INSTALL_WWWDIR)/autostatus-icons/, $(ALLICONS))
$(addprefix $(INSTALL_WWWDIR)/autostatus-icons/, $(ALLICONS)) \
$(addprefix $(INSTALL_WWWDIR)/cvsweb/, $(ALLCVSWEB))
cd $(INSTALL_WWWDIR) && \
if test -d ../webglimpse; \
then \
......@@ -84,7 +104,7 @@ install: $(addprefix $(INSTALL_WWWDIR)/, $(ALLFILES)) \
ln -s index.html tbdb.html; \
rm -f icons; \
ln -s /usr/local/www/icons icons;
$(INSTALL_CVSWEBCGI)
$(INSTALL_WWWDIR)/%: %
@echo "Installing $<"
......
This diff is collapsed.
This diff is collapsed.
<?php
#
# Wrapper script for cvsweb.cgi
#
chdir("../");
require("defs.php3");
#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
if (! TBCvswebAllowed($uid)) {
USERERROR("You do not have permission to use cvsweb!", 1);
}
$script = "cvsweb.cgi";
#
# Sine PHP helpfully scrubs out environment variables that we _want_, we
# have to pass them to env.....
#
$query = escapeshellcmd($QUERY_STRING);
$path = escapeshellcmd($PATH_INFO);
$name = escapeshellcmd($SCRIPT_NAME);
$agent = escapeshellcmd($HTTP_USER_AGENT);
$encoding = escapeshellcmd($HTTP_ACCEPT_ENCODING);
#
# Helpfully enough, escapeshellcmd doesn't escape spaces. Sigh.
#
$script = preg_replace("/ /","\\ ",$script);
$query = preg_replace("/ /","\\ ",$query);
$name = preg_replace("/ /","\\ ",$name);
$agent = preg_replace("/ /","\\ ",$agent);
$encoding = preg_replace("/ /","\\ ",$encoding);
$output = `env PATH=./cvsweb/ QUERY_STRING=$query PATH_INFO=$path SCRIPT_NAME=$name HTTP_USER_AGENT=$agent HTTP_ACCEPT_ENCODING=$encoding $script`;
#
# Yuck. Since we can't tell php to shut up and not print headers, we have to
# 'merge' headers from cvsweb with PHP's. And, since preg_match returns
# totally unhelpful results, we have to split it up into lines and iterate
# through them. Again, yuck!
#
$array = split("\n",$output);
$headers_done = 0;
for ($i = 0; $i < count($array); $i++) {
#
# A blank line signifies the end of headers
#
if (!preg_match("/\w+/",$array[$i])) {
$headers_done = 1;
} else {
#
# If it's a header, we use the PHP header() function to add it
# to the list of headers that PHP maintains. Otherwise, we
# just print it out.
#
if (!$headers_done) {
header($array[$i]);
} else {
echo "$array[$i]\n";
}
}
}
?>
......@@ -1069,6 +1069,14 @@ function TBWebdbAllowed($uid) {
return mysql_num_rows($query_result);
}
function TBCvswebAllowed($uid) {
$query_result =
DBQueryFatal("select cvsweb from users ".
"WHERE uid='$uid' and cvsweb=1");
return mysql_num_rows($query_result);
}
#
# DB Interface.
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment