diff options
-rw-r--r-- | sitesummary-collector.cgi | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sitesummary-collector.cgi b/sitesummary-collector.cgi index 26e00f3..6f1a10c 100644 --- a/sitesummary-collector.cgi +++ b/sitesummary-collector.cgi @@ -13,7 +13,7 @@ use Socket; my $basedir = "/var/lib/sitesummary"; -$ENV{PATH}=""; +$ENV{PATH} = "/bin:/usr/bin"; print "Content-Type: text/plain\n\n"; if (exists $ENV{REQUEST_METHOD} && $ENV{REQUEST_METHOD} ne "POST") @@ -72,6 +72,7 @@ if ($filename =~ m/.tar.gz$/) { die "Unhandled file type '$filename'" } +# XXX Come up with some unique file name. my $savefile = "$basedir/tmpstorage/$peeripaddr-$timestamp-$filename"; open(SITESUMMARY, ">$savefile") or die "Unable to write to $savefile"; @@ -81,8 +82,18 @@ close SITESUMMARY; print "Thanks for your submission to site-summary!\n"; print "SITESUMMARY HTTP-POST OK\n"; +process_entry($savefile); + exit 0; +sub process_entry { + my $filename = shift; + if ($filename =~ m/(.+).tar.gz$/) { + mkdir $1; + chdir $1; + `tar zxf $filename`; + } +} sub get_peerinfo { my $sockethandle = shift; |