summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorPreston Cody <codeman@gentoo.org>2007-12-30 03:41:53 +0000
committerPreston Cody <codeman@gentoo.org>2007-12-30 03:41:53 +0000
commit847a52beadb6e651e51bbf8bbe3a3746e11b776b (patch)
treef55d238f7912218db49bfcde54ca16f275646fec /server
parentadding debug() function. (diff)
downloadscire-847a52beadb6e651e51bbf8bbe3a3746e11b776b.tar.gz
scire-847a52beadb6e651e51bbf8bbe3a3746e11b776b.tar.bz2
scire-847a52beadb6e651e51bbf8bbe3a3746e11b776b.zip
adding in the DBI commands, commented out, to actually do stuff instead of faking it.
will continue faking it for now to ease development. svn path=/branches/new-fu/; revision=281
Diffstat (limited to 'server')
-rwxr-xr-xserver/scireserver.pl27
1 files changed, 22 insertions, 5 deletions
diff --git a/server/scireserver.pl b/server/scireserver.pl
index 6ea7543..88f17a3 100755
--- a/server/scireserver.pl
+++ b/server/scireserver.pl
@@ -97,11 +97,14 @@ sub register_client {
$mac =~ /^[a-zA-Z0-9\:]+$/ or print "ERROR invalid mac $mac!\n";
$ip =~ /^[a-zA-Z0-9\.\:]+$/ or print "ERROR invalid ip $ip!\n";
- my ($query, $status_id, $id);
+ my ($query, $status_id, $id, $sth);
eval {
$query = 'SELECT statusid FROM client_status WHERE statusname = "Pending"';
debug("DEBUG: Query is $query");
$status_id = "4"; #db.conn.GetRow($query)
+ #$sth = $dbh->prepare($query);
+ #my @result = $sth->fetchrow_array();
+ #$status_id = $result[0];
};
($@) and print "ERROR Could not get status id: $DBI::errstr";
@@ -109,26 +112,38 @@ sub register_client {
$query = 'LOCK TABLES `gacl_axo_seq` WRITE';
debug("DEBUG: Query is $query");
#execute it
+ #$dbh->do($query);
$query = 'SELECT id FROM `gacl_axo_seq`';
debug("DEBUG: Query is $query");
$id = "56"; #execute $query
- $query = 'UPDATE `gacl_axo_seq` SET id=%s';
+ #$sth = $dbh->prepare($query);
+ #my @result = $sth->fetchrow_array();
+ #$id = $result[0];
+
+ $query = 'UPDATE `gacl_axo_seq` SET id=?';
debug("DEBUG: Query is $query");
#execute with $id
+ #$sth = $dbh->prepare($query);
+ #$sth->execute($id);
$query = 'UNLOCK TABLES';
debug("DEBUG: Query is $query");
+ #$dbh->do($query);
};
($@) and print "ERROR during fetching of id sequence: $DBI::errstr";
eval {
- $query = 'INSERT INFO `gacl_axo` (id,section_value,value,order_value,name,hidden VALUES (%s,"clients",%s,1,%s,0)';
+ $query = 'INSERT INFO `gacl_axo` (id,section_value,value,order_value,name,hidden VALUES (?,"clients",?,1,?,0)';
debug("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 (%s,%s,%s,%s,%s,%s,%s)';
+ $query = 'INSERT INTO clients (clientid,digest,cert,hostname,mac,ip,status) VALUES (?,?,?,?,?,?,?)';
debug("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);
};
($@) and print "ERROR Could not insert client with $query: $DBI::errstr";
@@ -142,8 +157,10 @@ sub identify_client {
$fingerprint =~ s/"//g; #Clear the quotes.
$fingerprint =~ /^[A-Za-z0-9]+$/ or print "ERROR invalid fingerprint!\n";
#Validate your inputs!
- my $query = 'SELECT client_status.statusname FROM clients JOIN client_status on (clients.status = client_status.statusid) WHERE clients.digest=%s';
+ 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");
+ #$sth = $dbh->prepare($query);
+ #$sth->execute($fingerprint);
$identified = 1;
print "OK\n";
}