Index: ossp-pkg/petidomo/petidomo-approve RCS File: /v/ossp/cvs/ossp-pkg/petidomo/petidomo-approve,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/petidomo/petidomo-approve,v' | diff -u /dev/null - -L'ossp-pkg/petidomo/petidomo-approve' 2>/dev/null --- ossp-pkg/petidomo/petidomo-approve +++ - 2024-05-15 17:12:11.958749710 +0200 @@ -0,0 +1,76 @@ +: +eval 'exec perl -S $0 ${1+"$@"}' + if $running_under_some_shell; +## +## petidomo-approve -- Petidomo approval tool +## Copyright (c) 2000 Ralf S. Engelschall +## + +# locate the file with the approval passwords +my $config = "$ENV{HOME}/.petidomo"; + +# locate the Sendmail program +my $sendmail = "sendmail"; +foreach my $dir (split(/:/, "$ENV{PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/lib:/usr/lib")) { + if (-x "$dir/sendmail") { + $sendmail = "$dir/sendmail"; + last; + } +} + +# suck in the whole mail +my $mail = ''; +$mail .= $_ while (); + +# dispatch over the two mail types which need approval... +if ($mail =~ m|^Subject:\s+Petidomo:\s+APPROVE\s+(\S+):|mi) { + # approve a request + my $list = $1; + my $replyto = 'petidomo'; + $replyto = $1 if ($mail =~ m|^Reply-to:\s+(\S+)|mi); + my $password = 'petidomo'; + open(FP, "<$config"); + while () { + next if (m|^\s*#.*| or m|^\s*$|); + $password = $1 if (m|^\s*(?:$list)\s+(\S+)|); + } + close(FP); + $mail =~ s|^.+?\n(password\s+.+?)\n\n.*|$1|s; + $mail =~ s||$password|s; + open(SM, "|$sendmail $replyto") || die "cannot spawn $sendmail"; + print SM "To: $replyto\n\n"; + print SM $mail; + close(SM); + print STDERR "petidomo-approve: sent approved mail back to $replyto\n"; + sleep(1); + exit(0); +} +elsif ($mail =~ m|^Subject:\s+Petidomo:\s+BOUNCE|mi) { + # approve a posting + my $list = 'petidomo'; + $list = $1 if ($mail =~ m|^Subject:\s+Petidomo:\s+BOUNCE\s+(\S+):|m); + my $replyto = $list; + my $password = 'petidomo'; + open(FP, "<$config"); + while () { + next if (m|^\s*#.*| or m|^\s*$|); + $password = $1 if (m|^\s*(?:$list)\s+(\S+)|); + } + close(FP); + $mail =~ s|^.+?\n\n||s; + $mail =~ s|^.+?\n>?From .+?\n||s; + $mail = "Approved: $password\n" . $mail; # best + #$mail =~ s|^(.+?\n\n)(.*)$|$1Approved $password\n$2|s; # not good + open(SM, "|$sendmail $replyto") || die "cannot spawn $sendmail"; + print SM $mail; + close(SM); + print STDERR "petidomo-approve: sent approved mail back to $replyto\n"; + sleep(1); + exit(0); +} +else { + print STDERR "petidomo-approve: unrecognized mail type\n"; + sleep(1); + exit(1); +} + Index: ossp-pkg/petidomo/petidomo-kickout RCS File: /v/ossp/cvs/ossp-pkg/petidomo/petidomo-kickout,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/petidomo/petidomo-kickout,v' | diff -u /dev/null - -L'ossp-pkg/petidomo/petidomo-kickout' 2>/dev/null --- ossp-pkg/petidomo/petidomo-kickout +++ - 2024-05-15 17:12:11.961347596 +0200 @@ -0,0 +1,75 @@ +: +eval 'exec perl -S $0 ${1+"$@"}' + if $running_under_some_shell; +## +## petidomo-kickout -- Petidomo kickout tool +## Copyright (c) 2000 Ralf S. Engelschall +## + +my $pattern = $ARGV[0] || die "Usage: petidomo-kickout "; + +# locate the file with the approval passwords +my $config = "$ENV{HOME}/.petidomo"; + +# locate the Sendmail program +my $sendmail = "sendmail"; +foreach my $dir (split(/:/, "$ENV{PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/lib:/usr/lib")) { + if (-x "$dir/sendmail") { + $sendmail = "$dir/sendmail"; + last; + } +} + +# locate the Petidomo basedir +my $basedir = `petidomo --version 2>&1`; +$basedir =~ s|^.+\((\S+)\).*$|$1|s; + +# read config +my $list = {}; +open(FP, "<$config") || die "No ~/.petidomo file found"; +while () { + next if (m|^\s*#.*| or m|^\s*$|); + if (m|^\s*(\S+)\s+(\S+)|) { + my ($l, $pw) = ($1, $2); + $l =~ s|@[^@]+$||; + if (-f "$basedir/$l.list") { + $list->{$l} = {}; + $list->{$l}->{PASSWORD} = $pw; + $list->{$l}->{MEMBERS} = []; + open(LST, "<$basedir/$l.list"); + while () { + s|\n$||s; + push(@{$list->{$l}->{MEMBERS}}, $_); + } + close(LST); + } + } +} +close(FP); + +# iterate over all mailing lists +foreach my $l (keys(%{$list})) { + foreach my $m (@{$list->{$l}->{MEMBERS}}) { + if ($m =~ m|$pattern|) { + print "petidomo-kickout: $l: <$m> Kickout? [Y/n] "; + my $yn = ; + $yn =~ s|\n$||s; + $yn = "y" if ($yn eq ''); + $yn = lc($yn); + if ($yn eq 'y') { + open(SM, "|$sendmail petidomo") || die "cannot spawn $sendmail"; + print SM "To: petidomo\n" . + "\n" . + "password ".$list->{$l}->{PASSWORD}."\n" . + "unsubscribe $l $m\n"; + "password ".$list->{petidomo}->{PASSWORD}."\n" . + "subscribe bounces $m\n"; + close(SM); + print "petidomo-kickout: kicked out <$m>\n"; + } + } + } +} +sleep(1); +exit(0); +