| 257 | sub findaction { |
| 258 | my ($ctllist, $type, $newsgroup, $sender) = @_; |
| 259 | my ($action, $hier); |
| 260 | |
| 261 | foreach (@$ctllist) { |
| 262 | my @ctlline = split /:/; |
| 263 | # 0: type 1: from@addr 2: group.* 3: action |
| 264 | if ($type =~ /$ctlline[0]/ and $sender =~ /$ctlline[1]/i and |
| 265 | ($type !~ /(?:new|rm)group/ or $newsgroup =~ /$ctlline[2]/)) { |
| 266 | $action = $ctlline[3]; |
| 267 | $action =~ s/\^(.+)\$/$1/; |
| 268 | $action =~ s/\\//g; |
| 269 | $hier = $ctlline[2] if $type eq 'checkgroups'; |
| 270 | last; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | ($action, $hier); |
| 275 | } |
| 276 | |
| 277 | # Does the group exist in the active file ? |
| 278 | sub group_exists { |
| 279 | my $group = shift; |
| 280 | my $found = 0; |
| 281 | local *ACTIVE; |
| 282 | |
| 283 | unless (open(ACTIVE, $inn::active)) { |
| 284 | logdie("cannot open active file $inn::active"); |
| 285 | } |
| 286 | |
| 287 | while (<ACTIVE>) { |
| 288 | next unless (/^([^:]+):/); |
| 289 | if ($group eq $1) { |
| 290 | $found = 1; |
| 291 | last; |
| 292 | } |
| 293 | } |
| 294 | close ACTIVE; |
| 295 | |
| 296 | $found; |
| 297 | } |
| 298 | |
| 299 | |
274 | | foreach (@$ctllist) { |
275 | | my @ctlline = split /:/; |
276 | | # 0: type 1: from@addr 2: group.* 3: action |
277 | | if ($type =~ /$ctlline[0]/ and $sender =~ /$ctlline[1]/i and |
278 | | ($type !~ /(?:new|rm)group/ or $newsgroup =~ /$ctlline[2]/)) { |
279 | | $action = $ctlline[3]; |
280 | | $action =~ s/\^(.+)\$/$1/; |
281 | | $action =~ s/\\//g; |
282 | | $hier = $ctlline[2] if $type eq 'checkgroups'; |
283 | | last; |
284 | | } |
| 316 | if (lc $type eq 'newgroup' && group_exists($newsgroup)) { |
| 317 | ($action, $hier) = findaction($ctllist, 'updategroup', |
| 318 | $newsgroup, $sender); |
| 319 | } |
| 320 | if (!defined($action)) { |
| 321 | ($action, $hier) = findaction($ctllist, $type, $newsgroup, $sender); |