From b1f2a499e23e913a02bcd12ea650d410e17206b0 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Tue, 29 Aug 2006 21:46:49 +0000 Subject: * Let the collector store the IP peer info about each entry. Not yet working, as the getpeername() code is broken. --- debian/changelog | 2 ++ sitesummary-collector.cgi | 34 +++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5c54e22..de17647 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ sitesummary (0.0.6) UNRELEASED; urgency=low in after the initial submission after boot. * Add trivial sitesummary-makewebreport to make a web page with the summary results. + * Let the collector store the IP peer info about each entry. Not + yet working, as the getpeername() code is broken. -- Petter Reinholdtsen Tue, 29 Aug 2006 08:26:35 +0200 diff --git a/sitesummary-collector.cgi b/sitesummary-collector.cgi index e7a3785..0ae7fd7 100644 --- a/sitesummary-collector.cgi +++ b/sitesummary-collector.cgi @@ -83,21 +83,13 @@ close SITESUMMARY; print "Thanks for your submission to site-summary!\n"; print "SITESUMMARY HTTP-POST OK\n"; -process_entry($savefile); +process_entry($peeripaddr, $peername, $savefile); unlink $savefile; exit 0; -sub process_entry { - my $filename = shift; - my $dirname; - if ($filename =~ m/(.+).tar.gz$/) { - $dirname = $1; - mkdir $dirname; - chdir $dirname; - `tar zxf $filename`; - } +sub extract_unique_id { my $eth0mac; open(IFCONFIG, "system/ifconfig-a") || die; while () { @@ -106,7 +98,27 @@ sub process_entry { } close (IFCONFIG); #print STDERR "MAC: $eth0mac\n"; - my $newdir = "$basedir/entries/ether-$eth0mac"; + return "ether-$eth0mac"; +} + +sub process_entry { + my ($peeripaddr, $peername, $filename) = @_; + my $dirname; + if ($filename =~ m/(.+).tar.gz$/) { + $dirname = $1; + mkdir $dirname; + chdir $dirname; + `tar zxf $filename`; + } else { + die "Unhandled file format '$filename'"; + } + + open(PEERINFO, ">peerinfo") || die; + print PEERINFO "$peeripaddr $peername\n"; + close(PEERINFO) || die; + + my $id = extract_unique_id($dirname); + my $newdir = "$basedir/entries/$id"; my $status = "new"; if ( -d $newdir ) { -- cgit v1.2.3