Commit 9764b311 authored by Kevin Atkinson's avatar Kevin Atkinson

Add support for fetch-vis proxy which is used to fetch proj. vis. web

pages from the /proj directory, without having to set the exec. bit on
/proj/PID.  Will also be used to handle authorization in the future.
parent b197a13c
......@@ -447,10 +447,12 @@ DocumentRoot "/usr/local/www/data"
#
# Per-proj/exp visualizations
#
AliasMatch ^/proj-vis/([a-zA-Z0-9-]+)/(.*) /q/proj/$1/public_html/proj-vis/$2
AliasMatch ^/exp-vis/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/(.*) /q/proj/$1/public_html/exp-vis/$2/$3
ScriptAlias /proj-vis /usr/testbed/www/cgi-bin/fetch-vis
ScriptAlias /exp-vis /usr/testbed/www/cgi-bin/fetch-vis
<Directory "/q/proj/*/public_html/">
<Directory "/usr/testbed/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
......
......@@ -11,7 +11,7 @@ SUBDIR = collab
include $(OBJDIR)/Makeconf
SUBDIRS = mailman cvstools jabber trac
SUBDIRS = mailman cvstools jabber trac exp-vis
all: all-subdirs
......@@ -31,6 +31,7 @@ post-install:
@$(MAKE) -C cvstools post-install
@$(MAKE) -C jabber post-install
@$(MAKE) -C trac post-install
@$(MAKE) -C exp-vis post-install
# How to recursively descend into subdirectories to make general
# targets such as `all'.
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2009 University of Utah and the Flux Group.
# All rights reserved.
#
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = collab/exp-vis
include $(OBJDIR)/Makeconf
CGI_SCRIPTS = fetch-vis
#
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: $(CGI_SCRIPTS)
include $(TESTBED_SRCDIR)/GNUmakerules
install: \
$(addprefix $(TBROOT)/opsdir/www/cgi-bin/, $(CGI_SCRIPTS))
$(TBROOT)/opsdir/www/cgi-bin/fetch-vis: fetch-vis
-$(SUDO) mkdir -m 775 $(TBROOT)/opsdir/www/cgi-bin
$(SUDO) $(INSTALL) -o root -m 4775 $< $@
post-install:
clean:
#!/usr/bin/perl -T
use strict;
use warnings;
use POSIX qw(setuid setgid);
use Cwd qw(realpath);
use Data::Dumper;
#print "\n\n";
#print Dumper(\%ENV);
my $FSDIR_PROJ = "@FSDIR_PROJ@";
sub error($) {
print "Content-Type: text/plain\n";
print "Status: 404 Not Found\n\n";
print "$_[0]\n";
#die "$_[0]\n";
exit 1;
}
my $SCRIPT_URL = $ENV{SCRIPT_URL};
my ($proj,$dir,$file);
local $_ = $SCRIPT_URL;
if (/^\/proj-vis\/([a-zA-Z0-9-]+)\/?(.*)$/) {
$proj = $1;
$dir = "/proj/$1/www/proj-vis";
$file = $2;
} elsif (/^\/exp-vis\/([a-zA-Z0-9-]+)\/?([a-zA-Z0-9-]+)\/?(.*)$/) {
$proj = $1;
$dir = "/proj/$1/www/exp-vis/$2";
$file = $3;
} else {
error("Malformed URL");
}
# Lookup up the gid from the project name and make that the
# only group we have access to
my ($name, undef, $gid) = getgrnam($proj);
error("Invalid proj: $proj") if $proj ne $name;
undef $!;
$) = "$gid $gid";
setgid($gid);
die $! if $!;
# Now drop privileges, using setuid to make sure the saved uid
# is also changes, ie, so that the change is permanent.
setuid($<) or die $!;
# For security remove any ".." from the path and abort if we would
# leave $dir
my @dirs = split /\//, $file;
my @res;
foreach my $d (@dirs) {
if ($d eq '' || $d eq '.') {
# nothing to do
} elsif ($d eq '..') {
error("Malformed URL") if @res == 0;
pop @res;
} else {
push @res, $d;
}
}
$file = join ('/', @res);
my $path = "$dir/$file";
error("File Doesn't Exist: $path") unless -e $path;
if (-d $path) {
my $orig_path = $path;
$path .= "/index.html" if -e "$path/index.html";
$path .= "/index.htm" if -e "$path/index.htm";
error("Can't index dir: $path") unless $path ne $orig_path;
}
# Make sure that the path, after resolving any symbolic links,
# still resides is /proj/<pid>
my $realpath = realpath $path;
error("Invalid path: $realpath") unless $realpath =~ /^$FSDIR_PROJ\/$proj/;
my %mime_map =
qw(html text/html htm text/html
txt text/plain
png image/png
gif image/gif
jpg image/jpeg jpeg image/jpeg
zip application/zip);
my ($ext) = $path =~ /\.([^.]+)$/;
$ext = lc $ext;
my $mime_type = $mime_map{$ext};
print "Content-Type: $mime_type\n" if defined $mime_type;
print "\n";
$/ = undef;
open F, "$path" or error "Can't open file: $path";
print <F>;
exit 0;
......@@ -2770,6 +2770,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
collab/cvstools/cvs.proxy collab/cvstools/cvs_ctrl \
collab/cvstools/cvsrepo_ctrl.proxy collab/cvstools/cvsrepo_ctrl \
collab/cvstools/webcvsrepo_ctrl \
collab/exp-vis/GNUmakefile collab/exp-vis/fetch-vis \
node_usage/GNUmakefile node_usage/mk-plots \
node_usage/analy node_usage/publish \
node_usage/analy2 node_usage/refresh \
......
......@@ -1016,6 +1016,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
collab/cvstools/cvs.proxy collab/cvstools/cvs_ctrl \
collab/cvstools/cvsrepo_ctrl.proxy collab/cvstools/cvsrepo_ctrl \
collab/cvstools/webcvsrepo_ctrl \
collab/exp-vis/GNUmakefile collab/exp-vis/fetch-vis \
node_usage/GNUmakefile node_usage/mk-plots \
node_usage/analy node_usage/publish \
node_usage/analy2 node_usage/refresh \
......
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