summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Echolot/Commands.pm6
-rw-r--r--Echolot/Storage/File.pm26
-rwxr-xr-xpingd62
3 files changed, 74 insertions, 20 deletions
diff --git a/Echolot/Commands.pm b/Echolot/Commands.pm
index 86ea89c..d00f2c0 100644
--- a/Echolot/Commands.pm
+++ b/Echolot/Commands.pm
@@ -1,7 +1,7 @@
package Echolot::Commands;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Commands.pm,v 1.3 2002/07/02 17:03:13 weasel Exp $
+# $Id: Commands.pm,v 1.4 2002/07/03 00:54:40 weasel Exp $
#
=pod
@@ -67,6 +67,10 @@ sub processCommands($) {
Echolot::Globals::get()->{'storage'}->add_address(@args);
} elsif ($command eq 'set') {
Echolot::Globals::get()->{'storage'}->set_stuff(@args);
+ } elsif ($command eq 'getkeyconf') {
+ Echolot::Globals::get()->{'scheduler'}->schedule('getkeyconf', time() );
+ } elsif ($command eq 'delete') {
+ Echolot::Globals::get()->{'storage'}->delete_remailer(@args);
} else {
warn("Unkown command: $_\n");
};
diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm
index 26b7ed8..cca5015 100644
--- a/Echolot/Storage/File.pm
+++ b/Echolot/Storage/File.pm
@@ -1,7 +1,7 @@
package Echolot::Storage::File;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: File.pm,v 1.19 2002/07/03 00:36:14 weasel Exp $
+# $Id: File.pm,v 1.20 2002/07/03 00:54:40 weasel Exp $
#
=pod
@@ -915,6 +915,30 @@ sub expire($) {
};
+sub delete_remailer($$) {
+ my ($self, $address) = @_;
+
+ unless (defined $self->{'METADATA'}->{'addresses'}->{$address}) {
+ delete $self->{'METADATA'}->{'addresses'}->{$address}
+ } else {
+ cluck("Remailer $address does not exist in addresses")
+ };
+
+ unless (defined $self->{'METADATA'}->{'remailers'}->{$address}) {
+
+ for my $type ( keys %{$self->{'METADATA'}->{'remailers'}->{$address}->{'keys'}} ) {
+ for my $key ( keys %{$self->{'METADATA'}->{'remailers'}->{$address}->{'keys'}->{$type}} ) {
+ $self->pingdata_close_one($address, $type, $key, 'delete');
+ };
+ };
+
+ delete $self->{'METADATA'}->{'remailers'}->{$address}
+ } else {
+ cluck("Remailer $address does not exist in addresses")
+ };
+};
+
+
# sub convert($) {
# my ($self) = @_;
diff --git a/pingd b/pingd
index 7fc15a7..eb7289d 100755
--- a/pingd
+++ b/pingd
@@ -1,7 +1,7 @@
#!/usr/bin/perl -wT
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: pingd,v 1.13 2002/07/03 00:29:02 weasel Exp $
+# $Id: pingd,v 1.14 2002/07/03 00:54:40 weasel Exp $
#
=pod
@@ -22,8 +22,12 @@ pingd - echolot ping daemon
=item B<pingd> B<add> I<address> [I<address> ...]
+=item B<pingd> B<delete> I<address> [I<address> ...]
+
=item B<pingd> B<set> option=value [option=value..] I<address> [I<address> ...]
+=item B<pingd> B<getkeyconf>
+
=item B<pingd> B<dumpconf>
=back
@@ -67,6 +71,11 @@ For other affects of sending the HUP Signal see the SIGNALS section below.
Add I<address> to the list of remailers to query for
keys and confs.
+=item B<delete> I<address> [I<address> ...]
+
+Delete I<address> from the list of remailers to query for
+keys and confs. Delete all statistics and key for that remailer.
+
=item B<set> option=value [option=value..] I<address> [I<address> ...]
Possible options and values:
@@ -90,6 +99,10 @@ either B<on> or B<off>.
=back
+=item B<getkeyconf>
+
+Send a command to immediatly request keys and configuration from remailers.
+
=item B<dumpconf>
Dumps the current configuration to standard output.
@@ -106,12 +119,14 @@ Verbose mode. Causes B<pingd> to print debugging messages about its progress.
Print a short help and exit sucessfully.
-=item --hup
+=item --nohup
+
+Usefull only when passwd with the B<add>, B<set> or B<getkeyconf> command.
-Usefull only when passwd with the B<add> or B<set> command.
+Don't send a HUP signal to the daemon which instructs it to process the
+commands after adding the command to the task list.
-Sends a HUP signal to the daemon which instructs it to process the commands
-after adding the command to the task list.
+Per default such a signal is sent.
=item --detach
@@ -172,13 +187,12 @@ $ENV{'PATH'} = '/bin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
-my $scheduler;
my $redirected_stdio = 0;
sub setSigHandlers() {
$SIG{'HUP'} = sub {
print "Got SIGINT. scheduling readcommands\n";
- $scheduler->schedule('readcommands', time() );
+ Echolot::Globals::get()->{'scheduler'}->schedule('readcommands', time() );
if ($redirected_stdio) {
close STDOUT;
close STDERR;
@@ -188,15 +202,15 @@ sub setSigHandlers() {
};
$SIG{'INT'} = sub {
print "Got SIGINT. scheduling exit\n";
- $scheduler->schedule('exit', time() );
+ Echolot::Globals::get()->{'scheduler'}->schedule('exit', time() );
};
$SIG{'QUIT'} = sub {
print "Got SIGQUIT. scheduling exit\n";
- $scheduler->schedule('exit', time() );
+ Echolot::Globals::get()->{'scheduler'}->schedule('exit', time() );
};
$SIG{'TERM'} = sub {
print "Got SIGTERM. scheduling exit\n";
- $scheduler->schedule('exit', time() );
+ Echolot::Globals::get()->{'scheduler'}->schedule('exit', time() );
};
};
@@ -213,9 +227,11 @@ sub expire() {
-sub command_add(@) {
+sub command_adddelete(@) {
+ my $command = shift @_;
my @argv = @_;
+ die ("command_adddelete requires command\n") unless defined $command;
die ("add requires argument <address>\n") unless scalar @argv;
my @addresses;
for my $address (@argv) {
@@ -223,7 +239,7 @@ sub command_add(@) {
push @addresses, $address;
};
for my $address (@addresses) {
- Echolot::Commands::addCommand("add $address");
+ Echolot::Commands::addCommand("$command $address");
};
};
@@ -249,6 +265,8 @@ sub command_set(@) {
};
};
+
+
sub pid_exists() {
return (-e Echolot::Config::get()->{'pidfile'});
};
@@ -264,7 +282,8 @@ sub daemon_run() {
Echolot::Globals::initStorage();
setSigHandlers();
- $scheduler = new Echolot::Scheduler;
+ Echolot::Globals::get()->{'scheduler'} = new Echolot::Scheduler;
+ my $scheduler = Echolot::Globals::get()->{'scheduler'};
$scheduler->add('exit' , -1 , 0, 'exit' );
$scheduler->add('readcommands' , -1 , 0, \&Echolot::Commands::processCommands );
@@ -356,7 +375,7 @@ Getopt::Long::config('bundling');
if (!GetOptions (
'help' => \$params->{'help'},
'verbose' => \$params->{'verbose'},
- 'hup' => \$params->{'hup'},
+ 'nohup' => \$params->{'nohup'},
'detach' => \$params->{'detach'},
)) {
die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [-fwhv]\n");
@@ -375,16 +394,23 @@ chdir( Echolot::Config::get()->{'homedir'} );
Echolot::Globals::init();
-if ($COMMAND eq 'add') {
- command_add(@ARGV);
- if ($params->{'hup'} && pid_exists()) {
+if ($COMMAND eq 'add' || $COMMAND eq 'delete') {
+ command_adddelete($COMMAND, @ARGV);
+ if (!$params->{'nohup'} && pid_exists()) {
daemon_hup()
} else {
print "Don't forget to run $PROGRAM_NAME process. You may also use --hup in the future\n";
};
} elsif ($COMMAND eq 'set') {
command_set(@ARGV);
- if ($params->{'hup'} && pid_exists()) {
+ if (!$params->{'nohup'} && pid_exists()) {
+ daemon_hup()
+ } else {
+ print "Don't forget to run $PROGRAM_NAME process. You may also use --hup in the future\n";
+ };
+} elsif ($COMMAND eq 'getkeyconf') {
+ Echolot::Commands::addCommand("getkeyconf");
+ if (!$params->{'nohup'} && pid_exists()) {
daemon_hup()
} else {
print "Don't forget to run $PROGRAM_NAME process. You may also use --hup in the future\n";