1 ## $Id: rmgroup.pl 7743 2008-04-06 10:04:43Z iulius $
3 ## rmgroup control message handler.
5 ## Copyright 2001 by Marco d'Itri <md@linux.it>
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted provided that the following conditions
11 ## 1. Redistributions of source code must retain the above copyright
12 ## notice, this list of conditions and the following disclaimer.
14 ## 2. Redistributions in binary form must reproduce the above copyright
15 ## notice, this list of conditions and the following disclaimer in the
16 ## documentation and/or other materials provided with the distribution.
21 my ($par, $sender, $replyto, $site, $action, $log, $approved,
22 $headers, $body) = @_;
23 my ($groupname) = @$par;
25 # Scan active to see what sort of change we are making.
26 open(ACTIVE, $inn::active) or logdie("Cannot open $inn::active: $!");
29 next unless /^(\Q$groupname\E)\s\d+\s\d+\s(\w)/;
30 @oldgroup = split /\s+/;
36 $status = 'no change';
37 } elsif (not $approved) {
38 $status = 'unapproved';
43 if ($action eq 'mail' and $status !~ /(no change|unapproved)/) {
44 my $mail = sendmail("rmgroup $groupname $sender");
46 $sender asks for $groupname
49 If this is acceptable, type:
50 $inn::newsbin/ctlinnd rmgroup $groupname
52 And do not forget to remove the corresponding description, if any,
53 from your newsgroups file.
55 The control message follows:
58 print $mail map { s/^~/~~/; "$_\n" } @$headers;
60 print $mail map { s/^~/~~/; "$_\n" } @$body;
61 close $mail or logdie("Cannot send mail: $!");
62 } elsif ($action eq 'log') {
64 logger($log, "skipping rmgroup $groupname"
65 . " $sender (would be $status)", $headers, $body);
67 logmsg("skipping rmgroup $groupname $sender (would be $status)");
69 } elsif ($action eq 'doit' and $status !~ /(no change|unapproved)/) {
70 ctlinnd('rmgroup', $groupname);
71 # Update newsgroups too.
72 shlock("$inn::locks/LOCK.newsgroups");
73 open(NEWSGROUPS, $inn::newsgroups)
74 or logdie("Cannot open $inn::newsgroups: $!");
75 my $tempfile = "$inn::newsgroups.$$";
76 open(TEMPFILE, ">$tempfile") or logdie("Cannot open $tempfile: $!");
77 while (<NEWSGROUPS>) {
78 print TEMPFILE $_ if not /^\Q$groupname\E\s/;
82 rename($tempfile, $inn::newsgroups)
83 or logdie("Cannot rename $tempfile: $!");
84 unlink "$inn::locks/LOCK.newsgroups";
87 logger($log, "rmgroup $groupname $status $sender", $headers, $body)