summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorAndrew Gaffney <agaffney@gentoo.org>2007-12-30 21:35:51 +0000
committerAndrew Gaffney <agaffney@gentoo.org>2007-12-30 21:35:51 +0000
commit86c88b4289b19479a2f1d0ca5e554ea06e9aa9d0 (patch)
treeade1aa0b8776b0b6a2f854251c049d8300a3565d /server
parentadd parse_command() and modify existing code to use it (diff)
downloadscire-86c88b4289b19479a2f1d0ca5e554ea06e9aa9d0.tar.gz
scire-86c88b4289b19479a2f1d0ca5e554ea06e9aa9d0.tar.bz2
scire-86c88b4289b19479a2f1d0ca5e554ea06e9aa9d0.zip
log server debug output to a file
svn path=/branches/new-fu/; revision=284
Diffstat (limited to 'server')
-rwxr-xr-xserver/scireserver.pl27
1 files changed, 18 insertions, 9 deletions
diff --git a/server/scireserver.pl b/server/scireserver.pl
index 2d5f11d..3c39b8c 100755
--- a/server/scireserver.pl
+++ b/server/scireserver.pl
@@ -9,6 +9,7 @@ $| = 1;
my $SCIRE_CONFIG_FILE = '../etc/scireserver.conf'; #will be /etc/scire.conf when released.
my %conf;
+my $LOGFILE;
my $conf_file = (defined($conf{config})) ? $conf{config} : $SCIRE_CONFIG_FILE;
read_config_file($conf_file);
@@ -17,10 +18,18 @@ Dumper(\%conf);
my $identified = 0; #Global variable to determine if already identified or not.
# Somehow this feels insecure.
+sub logger {
+ my $line = shift;
+ if(!defined $LOGFILE) {
+ open(*LOGFILE, ">>$conf{logfile}") or die "Cannot open logfile $conf{logfile}";
+ }
+ print LOGFILE localtime() . " " . $line . "\n";
+}
+
sub debug {
my $line = shift;
if ($conf{debug}) {
- print STDERR "$line\n";
+ logger("DEBUG: ${line}");
}
}
@@ -102,7 +111,7 @@ sub register_client {
my ($query, $status_id, $id, $sth);
eval {
$query = 'SELECT statusid FROM client_status WHERE statusname = "Pending"';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
$status_id = "4"; #db.conn.GetRow($query)
#$sth = $dbh->prepare($query);
#my @result = $sth->fetchrow_array();
@@ -112,37 +121,37 @@ sub register_client {
eval {
$query = 'LOCK TABLES `gacl_axo_seq` WRITE';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
#execute it
#$dbh->do($query);
$query = 'SELECT id FROM `gacl_axo_seq`';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
$id = "56"; #execute $query
#$sth = $dbh->prepare($query);
#my @result = $sth->fetchrow_array();
#$id = $result[0];
$query = 'UPDATE `gacl_axo_seq` SET id=?';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
#execute with $id
#$sth = $dbh->prepare($query);
#$sth->execute($id);
$query = 'UNLOCK TABLES';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
#$dbh->do($query);
};
($@) and print "ERROR during fetching of id sequence: $DBI::errstr\n";
eval {
$query = 'INSERT INFO `gacl_axo` (id,section_value,value,order_value,name,hidden VALUES (?,"clients",?,1,?,0)';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
#$sth = $dbh->prepare($query);
#$sth->execute($id, $hostname, $hostname);
#execute with $id, $hostname, $hostname
#NOTE: not sure if this query is still valid. may be using id instead of hostname for one of those two now.
$query = 'INSERT INTO clients (clientid,digest,cert,hostname,mac,ip,status) VALUES (?,?,?,?,?,?,?)';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
#execute with $id, client_cert.digest("sha1"),crypto.dump_certificate(crypto.FILETYPE_PEM,client_cert),$hostname,$mac,$ip,$status_id))
#$sth = $dbh->prepare($query);
#$sth->execute($id,$digest,$hostname,$mac,$ip,$status_id);
@@ -161,7 +170,7 @@ sub identify_client {
$fingerprint =~ /^[A-Za-z0-9]+$/ or print "ERROR invalid fingerprint!\n";
my $query = 'SELECT client_status.statusname FROM clients JOIN client_status on (clients.status = client_status.statusid) WHERE clients.digest=?';
- debug("DEBUG: Query is $query");
+ debug("Query is $query");
#$sth = $dbh->prepare($query);
#$sth->execute($fingerprint);
$identified = 1;