Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a2bd8be
Showing
15 changed files
with
4,863 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use warnings; | ||
|
||
# The ever important debug-spew-enabler... | ||
my $debug = 0; | ||
|
||
# most of these can be altered at runtime with command line options. | ||
my $newshost = 'localhost'; | ||
my $newsauthor = 'postmaster'; | ||
my $postingagent = '/usr/local/bin/IcculusNews_post.pl'; | ||
my $queuenum = 1; | ||
my $newspass = undef; | ||
my $newspassfile = '/etc/IcculusNews_mailgatewaypass.txt'; | ||
my $portnum = 263; | ||
my $newssubj = undef; | ||
|
||
#-----------------------------------------------------------------------------# | ||
# The rest is probably okay without you laying yer dirty mits on it. # | ||
#-----------------------------------------------------------------------------# | ||
|
||
# the mainline. | ||
|
||
if ((not defined $newspass) && (not defined $ENV{'ICCNEWS_POST_PASS'})) { | ||
if (defined $newspassfile) { | ||
open(FH, $newspassfile) or die("failed to open $newspassfile: $!\n"); | ||
$newspass = <FH>; | ||
chomp($newspass); | ||
$newspass =~ s/\A\s*//; | ||
$newspass =~ s/\s*\Z//; | ||
close(FH); | ||
} | ||
} | ||
|
||
|
||
for (my $i = 0; $i < scalar(@ARGV); $i++) { | ||
my $arg = $ARGV[$i]; | ||
$debug = 1, next if ($arg eq '--debug'); | ||
$newshost = $ARGV[++$i], next if ($arg eq '--host'); | ||
$queuenum = $ARGV[++$i], next if ($arg eq '--queue'); | ||
$portnum = $ARGV[++$i], print("!!! FIXME: --port is ignored right now.\n"), next if ($arg eq '--port'); | ||
$newsauthor = $ARGV[++$i], next if ($arg eq '--user'); | ||
$newssubj = $ARGV[++$i], next if ($arg eq '--subj'); | ||
$postingagent = $ARGV[++$i], next if ($arg eq '--agent'); | ||
|
||
#$username = $arg, next if (not defined $username); | ||
#$subject = $arg, next if (not defined $subject); | ||
#$text = $arg, next if (not defined $text); | ||
#etc. | ||
|
||
print("Unknown argument \"$arg\".\n"); | ||
} | ||
|
||
print(" reading from STDIN...\n") if $debug; | ||
my $t = ''; | ||
$t .= $_ while (<STDIN>); | ||
|
||
if (not defined $newssubj) { | ||
if ($t =~ /^Subject:\s?(.*?)$/m) { | ||
$newssubj = $1; | ||
} | ||
} | ||
|
||
$newssubj = "Posting to IcculusNews mail gateway" if (not defined $newssubj); | ||
|
||
print(" posting to IcculusNews's submission queue...\n") if $debug; | ||
$ENV{'ICCNEWS_POST_PASS'} = $newspass if defined $newspass; | ||
my $rc = open(PH, "|'$postingagent' '$newshost' '$newsauthor' '$queuenum' '$newssubj' -"); | ||
if (not $rc) { | ||
print(" No pipe to IcculusNews: $!\n"); | ||
} else { | ||
print PH "<i>$ENV{'SENDER'} sent us the following email:" . | ||
"</i>\n<p>\n<pre>$t</pre>\n</p>\n"; | ||
close(PH); | ||
print(" posted to submission queue.\n") if $debug; | ||
} | ||
|
||
exit 99; # prevent further qmail delivery with successful status. | ||
|
||
# end of IcculusNews_dotqmail.pl ... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use Sys::Hostname; | ||
use IO::Socket::INET; | ||
|
||
my $version = "v2.0.0beta"; | ||
|
||
# The ever important debug-spew-enabler... | ||
my $debug = 0; | ||
|
||
#----------------------------------------------------------------------------# | ||
# End of setup vars. The rest is probably okay without you touching it. # | ||
#----------------------------------------------------------------------------# | ||
|
||
sub usage { | ||
print STDERR <<__EOF__; | ||
IcculusNews_post $version | ||
USAGE: $0 <host> <username> <queueid> <subject> <text> | ||
if <username> is '-', the Anonymous account is used. | ||
You will be prompted for a password if needed. You can | ||
avoid the prompt if you set the ICCNEWS_POST_PASS | ||
environment variable. | ||
if <text> is '-', news is read from stdin. | ||
__EOF__ | ||
|
||
exit 10; | ||
} | ||
|
||
|
||
sub okay_or_die { | ||
my ($sock, $sect) = @_; | ||
print "checking server response for: $sect\n" if $debug; | ||
my $response = <$sock>; | ||
chomp($response); | ||
print "server said: \"$response\".\n" if $debug; | ||
if ($response !~ /\A\+/) { | ||
print $sock "QUIT\012"; # just in case. | ||
close($sock); | ||
die("Error reported during $sect: \"$response\".\n"); | ||
} | ||
} | ||
|
||
|
||
# the mainline. | ||
|
||
my $user = undef; | ||
my $host = undef; | ||
my $pass = undef; | ||
my $subj = undef; | ||
my $text = undef; | ||
my $qid = undef; | ||
|
||
foreach (@ARGV) { | ||
usage() if ($_ eq '--help'); | ||
$debug = 1, next if ($_ eq '--debug'); | ||
$host = $_, next if (not defined $host); | ||
$user = $_, next if (not defined $user); | ||
$qid = $_, next if (not defined $qid); | ||
$subj = $_, next if (not defined $subj); | ||
$text = $_, next if (not defined $text); | ||
} | ||
|
||
usage() if ((!defined $user) or (!defined $host) or (!defined $subj) or (!defined $text)); | ||
|
||
$text =~ s/\A\s*//; | ||
$text =~ s/\s*\Z//; | ||
if ($text eq '-') { | ||
$text = ''; | ||
while (<STDIN>) { | ||
$text .= $_; | ||
} | ||
} | ||
|
||
$user =~ s/\A\s*//; | ||
$user =~ s/\s*\Z//; | ||
|
||
my $authstr = undef; | ||
if ($user eq '-') { | ||
$authstr = '-'; | ||
} else { | ||
$pass = $ENV{'ICCNEWS_POST_PASS'}; | ||
if (not defined $pass) { | ||
print("!!! FIXME: Prompt for a password here. export ICCNEWS_POST_PASS for now.\n"); | ||
exit(42); | ||
} | ||
|
||
$authstr = "\"$user\" \"$pass\""; | ||
} | ||
|
||
1 while ($text =~ s/\015\012/\012/s); | ||
1 while ($text =~ s/\015/\012/s); | ||
$text =~ s/^\.\012/..\012/sm; | ||
1 while ($text =~ s/\012.\012/\012..\012/s); | ||
|
||
print "Connecting to news server..." if $debug; | ||
my $sock = IO::Socket::INET->new(PeerAddr => $host, | ||
PeerPort => 263, | ||
Type => SOCK_STREAM, | ||
Proto => 'tcp'); | ||
|
||
die("Failed to connect to news server: $!\n") if not defined $sock; | ||
|
||
print "connected.\n" if $debug; | ||
|
||
okay_or_die($sock, 'initial welcome'); | ||
print $sock "AUTH $authstr\012"; | ||
okay_or_die($sock, 'user authorization'); | ||
print $sock "QUEUE $qid\012"; | ||
okay_or_die($sock, 'queue selection'); | ||
print $sock "POST $subj\012"; | ||
okay_or_die($sock, 'post command'); | ||
print $sock "$text\012.\012"; | ||
okay_or_die($sock, 'text posting'); | ||
print $sock "QUIT\012"; | ||
okay_or_die($sock, 'disconnection'); | ||
close($sock); | ||
|
||
print("News item successfully posted.\n") if $debug; | ||
exit 0; | ||
|
||
# end of IcculusNews_post.pl ... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- User interface to CREATEUSER. | ||
- User interface to CHANGEPASSWORD (including emailing forgotten passwords). | ||
- Have IcculusNews_post.pl prompt for a password. | ||
- CREATEQUEUE. | ||
- Shitloads more. | ||
|
Oops, something went wrong.