version 1.214, 2004/07/27 11:10:47
|
version 1.216, 2004/07/27 11:34:49
|
Line 1035 sub tie_user_hash {
|
Line 1035 sub tie_user_hash {
|
|
|
#--------------------- Request Handlers -------------------------------------------- |
#--------------------- Request Handlers -------------------------------------------- |
# |
# |
# By convention each request handler registers itself prior to the sub declaration: |
# By convention each request handler registers itself prior to the sub |
|
# declaration: |
# |
# |
|
|
|
#++ |
|
# |
# Handles ping requests. |
# Handles ping requests. |
# Parameters: |
# Parameters: |
# $cmd - the actual keyword that invoked us. |
# $cmd - the actual keyword that invoked us. |
Line 1062 sub ping_handler {
|
Line 1065 sub ping_handler {
|
} |
} |
®ister_handler("ping", \&ping_handler, 0, 1, 1); # Ping unencoded, client or manager. |
®ister_handler("ping", \&ping_handler, 0, 1, 1); # Ping unencoded, client or manager. |
|
|
|
#++ |
|
# |
|
# Handles pong requests. Pong replies with our current host id, and |
|
# the results of a ping sent to us via our lonc. |
|
# |
|
# Parameters: |
|
# $cmd - the actual keyword that invoked us. |
|
# $tail - the tail of the request that invoked us. |
|
# $replyfd- File descriptor connected to the client |
|
# Implicit Inputs: |
|
# $currenthostid - Global variable that carries the name of the host we are |
|
# connected to. |
|
# Returns: |
|
# 1 - Ok to continue processing. |
|
# 0 - Program should exit. |
|
# Side effects: |
|
# Reply information is sent to the client. |
|
|
|
sub pong_handler { |
|
my ($cmd, $tail, $replyfd) = @_; |
|
|
|
my $reply=&reply("ping",$clientname); |
|
&Reply( $replyfd, "$currenthostid:$reply\n", "$cmd:$tail"); |
|
return 1; |
|
} |
|
®ister_handler("pong", \&pong_handler, 0, 1, 1); # Pong unencoded, client or manager |
|
|
|
#++ |
|
# Called to establish an encrypted session key with the remote client. |
|
# Note that with secure lond, in most cases this function is never |
|
# invoked. Instead, the secure session key is established either |
|
# via a local file that's locked down tight and only lives for a short |
|
# time, or via an ssl tunnel...and is generated from a bunch-o-random |
|
# bits from /dev/urandom, rather than the predictable pattern used by |
|
# by this sub. This sub is only used in the old-style insecure |
|
# key negotiation. |
|
# Parameters: |
|
# $cmd - the actual keyword that invoked us. |
|
# $tail - the tail of the request that invoked us. |
|
# $replyfd- File descriptor connected to the client |
|
# Implicit Inputs: |
|
# $currenthostid - Global variable that carries the name of the host |
|
# known as. |
|
# $clientname - Global variable that carries the name of the hsot we're connected to. |
|
# Returns: |
|
# 1 - Ok to continue processing. |
|
# 0 - Program should exit. |
|
# Implicit Outputs: |
|
# Reply information is sent to the client. |
|
# $cipher is set with a reference to a new IDEA encryption object. |
|
# |
|
sub establish_key_handler { |
|
my ($cmd, $tail, $replyfd) = @_; |
|
|
|
my $buildkey=time.$$.int(rand 100000); |
|
$buildkey=~tr/1-6/A-F/; |
|
$buildkey=int(rand 100000).$buildkey.int(rand 100000); |
|
my $key=$currenthostid.$clientname; |
|
$key=~tr/a-z/A-Z/; |
|
$key=~tr/G-P/0-9/; |
|
$key=~tr/Q-Z/0-9/; |
|
$key=$key.$buildkey.$key.$buildkey.$key.$buildkey; |
|
$key=substr($key,0,32); |
|
my $cipherkey=pack("H32",$key); |
|
$cipher=new IDEA $cipherkey; |
|
&Reply($replyfd, "$buildkey\n", "$cmd:$tail"); |
|
|
|
return 1; |
|
|
|
} |
|
®ister_handler("ekey", \&establish_key_handler, 0, 1,1); |
|
|
|
|
|
|
#--------------------------------------------------------------- |
#--------------------------------------------------------------- |
# |
# |
Line 1174 sub process_request {
|
Line 1250 sub process_request {
|
|
|
} |
} |
|
|
# ------------------------------------------------------------- Normal commands |
#------------------- Commands not yet in spearate handlers. -------------- |
if ($userinput =~ /^pong/) { # client only |
|
if(isClient) { |
|
my $reply=&reply("ping",$clientname); |
|
print $client "$currenthostid:$reply\n"; |
|
} else { |
|
Reply($client, "refused\n", $userinput); |
|
} |
|
# ------------------------------------------------------------------------ ekey |
|
} elsif ($userinput =~ /^ekey/) { # ok for both clients & mgrs |
|
my $buildkey=time.$$.int(rand 100000); |
|
$buildkey=~tr/1-6/A-F/; |
|
$buildkey=int(rand 100000).$buildkey.int(rand 100000); |
|
my $key=$currenthostid.$clientname; |
|
$key=~tr/a-z/A-Z/; |
|
$key=~tr/G-P/0-9/; |
|
$key=~tr/Q-Z/0-9/; |
|
$key=$key.$buildkey.$key.$buildkey.$key.$buildkey; |
|
$key=substr($key,0,32); |
|
my $cipherkey=pack("H32",$key); |
|
$cipher=new IDEA $cipherkey; |
|
print $client "$buildkey\n"; |
|
# ------------------------------------------------------------------------ load |
# ------------------------------------------------------------------------ load |
} elsif ($userinput =~ /^load/) { # client only |
if ($userinput =~ /^load/) { # client only |
if (isClient) { |
if (isClient) { |
my $loadavg; |
my $loadavg; |
{ |
{ |