/usr/lib/news/bin/mod-active is in inn2 2.5.2+20110413-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #! /usr/bin/perl -w
use lib '/usr/share/perl5'; use INN::Config;
# $Id: mod-active.in 8203 2008-12-02 17:18:23Z iulius $
# batch-active-update
# Author: David Lawrence <tale@isc.org>
# Reads a series of ctlinnd newgroup/rmgroup/changegroup commands, such as
# is output by docheckgroups and actsync, and efficiently handles them all at
# once. Input can come from command-line files or stdin, a la awk/sed.
$oldact = $INN::Config::active; # active file location
$newact = "$oldact.new$$"; # temporary name for new active file
$actime = $INN::Config::activetimes; # active.times file
$pausemsg = 'batch active update, ok'; # message to be used for pausing?
$diff_flags = ''; # flags for diff(1); default chosen if null
$changes = 0; # number of changes to do
$0 =~ s#^.*/##;
die "$0: must run as $INN::Config::newsuser user"
unless $> == (getpwnam($INN::Config::newsuser))[2];
$debug = -t STDOUT ? 1 : 0;
$| = 1; # show output as it happens (for an rsh/ssh pipe)
# Guess at best flags for a condensed diff listing. The
# checks for alternative operating systems is incomplete.
unless ($diff_flags) {
if (`diff -v 2>&1` =~ /GNU/) {
$diff_flags = '-U0';
} elsif ($^O =~ /^(dec_osf|solaris)$/) {
$diff_flags = '-C0';
} elsif ($^O eq 'nextstep') {
$diff_flags = '-c0';
} else {
$diff_flags = '-c';
}
}
print "reading list of groups to update\n" if $debug;
$eval = "while (<OLDACT>) {\n";
$eval .= " \$group = (split)[0];\n";
while (<>) {
if (/^\s*\S*ctlinnd newgroup (\S+) (\S+)/) {
$toadd{$1} = $2;
$changes++;
} elsif (/^\s*\S*ctlinnd rmgroup (\S+)/) {
$eval .= " next if \$group eq '$1';\n";
$changes++;
} elsif (/^\s*\S*ctlinnd changegroup (\S+) (\S+)/) {
$eval .= " s/ \\S+\$/ $2/ if \$group eq '$1';\n";
$changes++;
}
}
$eval .= " delete \$toadd{\$group};\n";
$eval .= " if (!print(NEWACT \$_)) {\n";
$eval .= " die \"\$0: writing \$newact failed (\$!), aborting\\n\";\n";
$eval .= " }\n";
$eval .= "}\n";
if ($changes == 0) {
print "active file not changed\n" if $debug;
exit 0;
}
print "$changes change(s) to do\n" if $debug;
&ctlinnd("pause $pausemsg");
open(OLDACT, "< $oldact") || die "$0: open $oldact: $!\n";
open(NEWACT, "> $newact") || die "$0: open $newact: $!\n";
print "rewriting active file\n" if $debug;
eval $eval;
for (sort keys %toadd) {
$add = "$_ 0000000000 0000000001 $toadd{$_}\n";
if (!print(NEWACT $add)) {
&ctlinnd("go $pausemsg");
die "$0: writing $newact failed ($!), aborting\n";
}
}
close(OLDACT) || warn "$0: close $oldact: $!\n";
close(NEWACT) || warn "$0: close $newact: $!\n";
if (!rename("$oldact", "$oldact.old")) {
warn "$0: rename $oldact $oldact.old: $!\n";
}
if (!rename("$newact", "$oldact")) {
die "$0: rename $newact $oldact: $!\n";
}
&ctlinnd("reload active 'updated from checkgroups'");
system("diff $diff_flags $oldact.old $oldact");
&ctlinnd("go $pausemsg");
print "updating $actime\n" if $debug;
if (open(TIMES, ">> $actime")) {
$time = time;
for (sort keys %toadd) {
print TIMES "$_ $time checkgroups-update\n" || last;
}
close(TIMES) || warn "$0: close $actime: $!\n";
} else {
warn "$0: $actime not updated: $!\n";
}
print "chmoding active files\n" if $debug;
if (! chmod 0664, $oldact, "$oldact.old", $actime) {
warn "$0: chmod $oldact $oldact.old $actime: $!\n";
}
exit 0;
sub
ctlinnd
{
local($command) = @_;
print "ctlinnd $command\n" if $debug;
if (system("$INN::Config::newsbin/ctlinnd -s $command")) {
die "$0: \"$command\" failed, aborting\n";
}
}
|