chiark / gitweb /
new lwc_fixed for distrib.pats and distributions
[nntp-merge-chiark.git] / nyxpost
1 #!/usr/bin/perl
2
3 defined($la= $ENV{'NNTPMERGE_AUTHD_AS'}) || die "no la";
4 $la.= "\@chiark";
5 $outnews= "/usr/local/lib/exchange/outnews";
6 $route= "nyx";
7
8 $|=1;
9 print "200 nyxpost\r\n";
10 while (<>) {
11     s/\s*\n$//;
12     if (m/^POST$/i) {
13         print "340 mmmm\r\n";
14         $art= '';
15         for (;;) {
16             length($_=<>) || exit(1);
17             last if m/^\.\r?\n$/;
18             s/^\.//; s/\r\n$/\n/; $art.= $_;
19         }
20         defined($c= open(P,"-|")) || die "fork: $!";
21         if (!$c) {
22             open(STDERR,">&STDOUT");
23             defined($c2= open(Q,"|-")) || die "fork: $!";
24             if (!$c2) {
25                 exec($outnews,"--sender",$la,$route);
26                 die "exec: $!";
27             }
28             print(Q $art) || die "write: $!";
29             close(Q); $? && die "outnews: $?";
30             exit(0);
31         }
32         undef $/; $_= <P>; $/= "\n"; s/\n/ /g;
33         close(P);
34         if ($?) {
35             print "441 $_\r\n";
36         } else {
37             print "240 $_\r\n";
38         }
39     } elsif (m/^QUIT$/i) {
40         print "205 ttfn\r\n";
41         exit(0);
42     } else {
43         print "500 too stupid\r\n";
44     }
45 }