summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+config@madore.org>2010-02-16 16:28:50 (GMT)
committerDavid A. Madore <david+config@madore.org>2010-02-16 16:28:50 (GMT)
commitc93beedc46c0495a45c449fc66a7eb04630567f4 (patch)
tree0289bcac33d9fb2d1a0d49ddad64f1e24493a5fd
parent7427c871abee6768cdd1c12d0ddf23f13cb37197 (diff)
downloademergency-c93beedc46c0495a45c449fc66a7eb04630567f4.zip
emergency-c93beedc46c0495a45c449fc66a7eb04630567f4.tar.gz
emergency-c93beedc46c0495a45c449fc66a7eb04630567f4.tar.bz2
Work against the dreadful habit of concatenatingallmywords in identifiers.
-rwxr-xr-xemergencyc.pl14
-rwxr-xr-xemergencyd.pl24
2 files changed, 19 insertions, 19 deletions
diff --git a/emergencyc.pl b/emergencyc.pl
index b8bebb6..296297f 100755
--- a/emergencyc.pl
+++ b/emergencyc.pl
@@ -10,8 +10,8 @@
# Options recognized:
#
-# -K <key> specifies the key to use; or -k <filename> specifies a
-# keyfile (the client will use the first line as key).
+# -K <key> specifies the key to use; or -k <filename> specifies a key
+# file (the client will use the first line as key).
#
# -h <hostname> and -p <number> specifies the host and port to connect
# to.
@@ -39,10 +39,10 @@ my $key;
if ( defined($opts{K}) ) {
$key = $opts{K};
} elsif ( defined($opts{k}) ) {
- open my $keyfile, "<", $opts{k} or die "Cannot open key file $opts{k}: $!";
- $key = <$keyfile>;
+ open my $key_file, "<", $opts{k} or die "Cannot open key file $opts{k}: $!";
+ $key = <$key_file>;
chomp $key;
- close $keyfile;
+ close $key_file;
}
die "No key specified (use -K or -k option)" unless defined($key);
@@ -65,8 +65,8 @@ sub curtime {
my $command = $ARGV[0] // "PING";
my $timestamp = $opts{t} // curtime;
my $validate = "$command|$timestamp";
-my $maccheck = hmac_sha256_hex($validate, $key);
-send $socket, "$command|$timestamp|$maccheck", 0, $haddr;
+my $mac_check = hmac_sha256_hex($validate, $key);
+send $socket, "$command|$timestamp|$mac_check", 0, $haddr;
my $buf;
my $sender;
diff --git a/emergencyd.pl b/emergencyd.pl
index 200881b..6019029 100755
--- a/emergencyd.pl
+++ b/emergencyd.pl
@@ -46,7 +46,7 @@
# binds to the IPv6 unspecified address with the IPV6_V6ONLY option
# set to 0, thus listening on both IPv6 and IPv4 families.
#
-# -k <filename> specifies the keyfile to use. This file contains one
+# -k <filename> specifies the key file to use. This file contains one
# or more keys, one per line, which will all be equally valid when
# computing the MAC.
#
@@ -72,19 +72,19 @@ getopts("k:p:f", \%opts);
my @authorized_keys;
-my $keyfilename = $opts{k};
-die "No key file specified (use -k option)" unless defined($keyfilename);
-sub readkeys {
- open my $keyfile, "<", $keyfilename
+my $key_filename = $opts{k};
+die "No key file specified (use -k option)" unless defined($key_filename);
+sub read_keys {
+ open my $key_file, "<", $key_filename
or die "Cannot open key file $opts{k}: $!";
@authorized_keys = ();
- while (<$keyfile>) {
+ while (<$key_file>) {
chomp;
push @authorized_keys, $_;
}
- close $keyfile;
+ close $key_file;
}
-readkeys;
+read_keys;
my $proto = getprotobyname("udp") or die "Can't resolve udp protocol: $!";
my $port;
@@ -135,13 +135,13 @@ while (1) {
send $socket, ("DATE\n".curtime."\n".$mintime."\n"), 0, $sender;
} else {
my $validate = "$command|$timestamp";
- my $macchecked = 0;
+ my $mac_checked = 0;
foreach my $key ( @authorized_keys ) {
if ( $maccheck eq hmac_sha256_hex($validate, $key) ) {
- $macchecked = 1;
+ $mac_checked = 1;
}
}
- unless ( $macchecked ) {
+ unless ( $mac_checked ) {
send $socket, "!MAC\n", 0, $sender;
next PACKET;
}
@@ -162,7 +162,7 @@ while (1) {
exit 0;
} elsif ( $command eq "RKEY" ) {
my $resp = "DONE\n";
- eval { readkeys };
+ eval { read_keys };
if ( $@ ) {
$resp = "!ERR\n$@";
}