2 # $Id: receive.in,v 1.17 2005/07/24 18:42:41 don Exp $
3 # usage: mail is piped directly into program
5 #set umask in order to have group-writable incoming/*
8 use Debbugs::Config qw(:globals :text);
9 my $lib_path = $gLibPath;
11 $ENV{'PATH'} = '/usr/lib/debbugs:'.$ENV{'PATH'};
13 #set source of mail delivery
14 #sets any prefix needed to get mailer to add it to error mail
15 if ( $gMailer eq 'exim' )
16 { $gBadEmailPrefix = '';
17 $_ = $ENV{'LOCAL_PART'};
18 } elsif ( $gMailer eq 'qmail' )
19 { $gBadEmailPrefix = '//';
21 # $_ = $ENV{'RECIPIENT'};
24 { $gBadEmailPrefix = '';
30 #remove everything from @ to end of line
33 #convert remaining upper case to lower case
36 #set up to determine command
37 %withbugaddressmap= ('-submit', 'B',
46 # Used for bug subscription
47 #'-list-nothing-will-match-this', 'L',
50 %withpkgaddressmap= ('-request', 'R');
52 %withoutaddressmap= ('submit', 'B',
64 if (s/^(\d{1,9})\b//) {
66 if (not exists $withbugaddressmap{$_} and
67 /-(?:(?:un)?subscribe|subhelp|help|ignore|(?:sub(?:yes|approve|reject)
68 |unsubyes|bounce|probe|approve|reject|
69 setlistyes|setlistsilentyes).*)/x
74 $map= $withbugaddressmap{$_};
76 $addrrec= "$bugnumber$_";
77 } elsif (s/^(\w+)-//) {
79 $map= $withpkgaddressmap{"-$_"};
80 $addrrec= "$bugnumber-$_";
83 $map= $withoutaddressmap{$_};
87 #print no command received
89 print STDERR <<ENDTEXT;
91 $gBadEmailPrefix Unknown $gBug service address $_\@$gEmailDomain.
92 $gBadEmailPrefix Recognised addresses are:
94 $gBadEmailPrefix General: Read $gBug# in Subject: $gBug# is NNNN:
96 $gBadEmailPrefix request submit $gBug NNNN NNNN-submit
97 $gBadEmailPrefix control maintonly NNNN-maintonly
98 $gBadEmailPrefix owner quiet NNNN-quiet
99 $gBadEmailPrefix postmaster forwarded NNNN-forwarded
100 $gBadEmailPrefix done close NNNN-done NNNN-close
101 $gBadEmailPrefix submitter NNNN-submitter
103 $gBadEmailPrefix (all \@$gEmailDomain.)
105 $gBadEmailPrefix For instructions via the WWW see:
106 $gBadEmailPrefix http://$gWebDomain/
107 $gBadEmailPrefix http://$gWebDomain/Reporting$gHTMLSuffix
108 $gBadEmailPrefix http://$gWebDomain/Developer$gHTMLSuffix
109 $gBadEmailPrefix http://$gWebDomain/Access$gHTMLSuffix
111 $gBadEmailPrefix For details of how to access $gBug report logs by email:
112 $gBadEmailPrefix send \`request\@$gEmailDomain' the word \`help'
118 @months=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
119 ($sec,$min,$hour,$mday,$mon,$year)= gmtime(time);
121 $queue= "$map$bugnumber";
123 chdir("$gSpoolDir/incoming") || &failure("chdir to spool: $!");
126 open(FILE,">T.$id") || &failure("open temporary file: $!");
127 printf(FILE "Received: (at %s) by $gEmailDomain; %d %s %d %02d:%02d:%02d +0000\n",
128 $addrrec, $mday,$months[$mon],$year+1900, $hour,$min,$sec) ||
129 &failure("write header to temporary file: $!");
130 while(<STDIN>) { print(FILE) || &failure("write temporary file: $!"); }
131 close(FILE) || &failure("close temporary file: $!");
139 rename("T.$id","$prefix$queue.$id") || &failure("rename spool message: $!");
144 length($id) && unlink("T.$id");
145 print STDERR "bugs receive failure: @_\n";
146 exit(75); # EX_TEMPFAIL