This file is indexed.

/usr/lib/news/bin/send-uucp.pl is in inn 1:1.7.2q-41build1.

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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#!/usr/bin/perl -w
require '/usr/lib/news/innshellvars.pl';

##############################################################################
# send-uucp.pl	create news batches from the outgoing files
#
# Author:	Edvard Tuinder <ed@elm.net>
#
# Copyright (C) 1994 Edvard Tuinder - ELM Consultancy B.V.
# Copyright (C) 1995-1997 Miquel van Smoorenburg - Cistron Internet Services
#
# Copyright (C) 2003 Marco d'Itri <md@linux.it>
#   Nearly rewritten. Added syslog support, real errors checking and more.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
##############################################################################

use strict;
use Sys::Syslog;

# for compatibility with INN 1.x
$inn::pathetc ||= '/etc/news';
$inn::syslog_facility ||= 'news';

# some default values
my $MAXSIZE = 500000;
my $MAXJOBS = 200;

my %UNBATCHER = (
    compress    => 'cunbatch',
    bzip2       => 'bunbatch',
    gzip        => 'gunbatch',
);

my $UUX_FLAGS = '- -z -r -gd';
my $BATCHER_FLAGS = '';

##############################################################################
my $config_file = $inn::pathetc . '/send-uucp.cf';
my $lockfile = $inn::locks . '/LOCK.send-uucp';

openlog('send-uucp', 'pid', $inn::syslog_facility);

my @sitelist;
if (@ARGV) {
    foreach my $site (@ARGV) {
        my @cfg = read_cf($config_file, $site);
        if (not @cfg) {
            logmsg("site $site not found in the configuration", 'err');
            next;
        }
        push @sitelist, @cfg;
    }
} else {
    @sitelist = read_cf($config_file, undef);
}

if (not @sitelist) {
    logmsg('nothing to do', 'debug');
    exit 0;
}

chdir $inn::batch or logdie("Can't access $inn::batch: $!", 'crit');

shlock($lockfile);

run_site($_) foreach @sitelist;
unlink $lockfile;
exit 0;

# lint food
$inn::compress.$inn::locks.$inn::syslog_facility.$inn::have_uustat = 0 if 0;

##############################################################################
sub read_cf {
    my ($conf_file, $site_wanted) = @_;

    my $hour = (localtime time)[2];

    my @sites;
    open(CF, $conf_file) or logdie("cannot open $conf_file: $!", 'crit');
    while (<CF>) {
        chop;
        s/\s*\#.*$//;
        next if /^$/;

        my ($sitespec, $compress, $size, $time) = split(/\s+/);
        next if not $sitespec;

        my ($site, $host) = split(/:/, $sitespec);
        $host = $site if not $host;

        $compress =~ s/_/ /g if $compress;

        if ($site_wanted) {
            if ($site eq $site_wanted) {
                push @sites, [$site, $host, $compress, $size];
                last;
            }
            next;
        }

        if ($time) {
            foreach my $time (split(/,/, $time)) {
                next if $time != $hour;
                push @sites, [$site, $host, $compress, $size];
            }
        } else {
            push @sites, [$site, $host, $compress, $size];
        }
    }
    close CF;
    return @sites;
}

##############################################################################
# count number of jobs in the UUCP queue for a given site
sub count_jobs {
    my ($site) = @_;

    return 0 if not $inn::have_uustat;
    open(JOBS, "uustat -s $site 2> /dev/null |") or logdie("cannot fork: $!");
    my $count = grep(/ Executing rnews /, <JOBS>);
    close JOBS;                    # ignore errors, uustat may fail
    return $count;
}

# select the rnews label appropriate for the compressor program used
sub unbatcher {
    my ($compressor) = @_;

    $compressor =~ s%.*/%%;
    return $UNBATCHER{$compressor} || 'cunbatch';
}

##############################################################################
# batch articles for one site
sub run_site {
    my ($cfg) = @_;
    my ($site, $host, $compress, $size) = @$cfg;

    logmsg("checking site $site", 'debug');
    my $maxjobs = '';
    if ($MAXJOBS) {
        my $jobs = count_jobs($site);
        if ($jobs >= $MAXJOBS) {
            logmsg("too many jobs queued for $site");
            return;
        }
        $maxjobs = '-N ' . ($MAXJOBS - $jobs);
    }

    $compress ||= $inn::compress;
    $size ||= $MAXSIZE;

    # if exists a .work temp file left by a previous invocation, append
    # it to the current batch file
    if (-f "$site.work") {
        my $err = '';
        open(OUT, ">>$site") or logdie("cannot open $site: $!");
        open(IN, "$site.work") or logdie("cannot open $site.work: $!");
        print OUT while <IN>;
        close IN;
        close OUT or logdie("cannot close $site: $!");;
    }

    if (not -f $site) {
        logmsg("no batch file for site $site", 'err');
        return;
    }

    rename($site, "$site.work") or logdie("cannot rename $site: $!", 'crit');
    ctlinnd('-t120', 'flush', $site);
    if (not -s "$site.work") {
        logmsg("no articles for $site", 'debug');
        unlink "$site.work" or logmsg("cannot delete $site.work: $!", 'err');
    } else {
        if ($compress eq 'none') {
            system "batcher -b $size $maxjobs $BATCHER_FLAGS "
                . "-p\"uux $UUX_FLAGS %s!rnews\" $host $site.work";
        } else {
            system "batcher -b $size $maxjobs $BATCHER_FLAGS "
                . "-p\"{ echo '#! " . unbatcher($compress)
                . "' ; exec $compress; } | "
                . "uux $UUX_FLAGS %s!rnews\" $host $site.work";
        }
        logmsg("batched articles for $site", 'debug');
    }
}

##############################################################################
sub logmsg {
    my ($msg, $lvl) = @_;

    syslog($lvl || 'notice', '%s', $msg);
}

sub logdie {
    my ($msg, $lvl) = @_;

    logmsg($msg, $lvl || 'err');
    unlink $lockfile;
    exit 1;
}

sub ctlinnd {
    my ($cmd, @args) = @_;

    my $st = system("$inn::newsbin/ctlinnd", '-s', $cmd, @args);
    logdie('Cannot run ctlinnd: ' . $!) if $st == -1;
    logdie('ctlinnd returned status ' . ($st & 255)) if $st > 0;
}

sub shlock {
    my $lockfile = shift;

    my $locktry = 0;
    while ($locktry < 60) {
        if (system("$inn::newsbin/shlock", '-p', $$, '-f', $lockfile) == 0) {
            return 1;
        }
        $locktry++;
        sleep 2;
    }

    my $lockreason;
    if (open(LOCKFILE, $lockfile)) {
        $lockreason = 'held by ' . (<LOCKFILE> || '?');
        close LOCKFILE;
    } else {
        $lockreason = $!;
    }
    logdie("Cannot get lock $lockfile: $lockreason");
    return undef;
}

__END__

=head1 NAME

send-uucp - Send Usenet articles via UUCP

=head1 SYNOPSIS

B<send-uucp> [I<SITE> ...]

=head1 DESCRIPTION

The B<send-uucp> program processes batch files written by innd(8) to send
Usenet articles to UUCP sites.  It reads a configuration file to control how
it behaves with various sites.  Normally, it's run periodically out of cron
to put together batches and send them to remote UUCP sites.

=head1 OPTIONS

Any arguments provided to the program are interpreted as a list of sites
specfied in F<send-uucp.cf> for which batches should be generated.  If no
arguments are supplied then batches will be generated for all sites listed
in that configuration file.

=head1 CONFIGURATION

The sites to which articles are to be sent must be configured in the
configuration file F<send-uucp.cf>.  Each site is specified with a line of
the form:

    site[:host] [compressor [maxsize [batchtime]]]

=over 4

=item I<site>

The news site name being configured.  This must match a site name 
from newsfeeds(5).

=item I<host>

The UUCP host name to which batches should be sent for this site.
If omitted, the news site name will be used as the UUCP host name.

=item I<compressor>

The compression method to use for batches.  This should be one of compress,
gzip or none.  Arguments for the compression command may be specified by
using C<_> instead of spaces. For example, C<gzip_-9>.  The default value is
C<compress>.

=item I<maxsize>

The maximum size of a single batch before compression.  The default value is
500,000 bytes.

=item I<batchtime>

A comma separated list of hours during which batches should be generated for
a given site.  When B<send-uucp> runs, a site will only be processed if the
current hour matches one of the hours in I<batchtime>.  The default is no
limitation on when to generate batches.

=back

Fields are seperated by spaces and only the site name needs to be specified,
with defaults being used for unspecified values.  If the first character on
a line is a C<#> then the rest of the line is ignored.

=head1 EXAMPLE

Here is an example send-uucp.cf configuration file:

    zoetermeer      gzip            1048576         5,18,22
    hoofddorp       gzip            1048576         5,18,22
    pa3ebv          gzip            1048576         5,18,22
    drinkel         gzip            1048576         5,6,18,20,22,0,2
    manhole         compress        1048576         5,18,22
    owl             compress        1048576
    able

This defines seven UUCP sites.  The first four use gzip compression and the
last three use compress.  The first six use a batch size of 1MB, and the
last site (able) uses the default of 500,000 bytes.  The zoetermeer,
hoofddorp, pa3ebv, and manhole sites will only have batches generated for
them during the hours of 05:00, 18:00, and 22:00, and the drinkel site will
only have batches generated during those hours and 20:00, 00:00, and 02:00.
There are no restrictions on when batches will be generated for owl or able.

=head1 FILES

=over 4

=item I<pathetc>/send-uucp.cf

Configuration file specifying a list of sites to be processed.  

=back

=head1 NOTES

The usual flags used for a UUCP feed in the I<newsfeeds> file are C<Tf,Wfb>.

=head1 SEE ALSO

innd(8), newsfeeds(5), uucp(8)

=head1 AUTHOR

This program was originally written by Edvard Tuinder <ed@elm.net> and then
maintained and extended by Miquel van Smoorenburg <miquels@cistron.nl>.
Marco d'Itri <md@linux.it> cleaned up the code for inclusion in INN.  This
manual page was written by Mark Brown <broonie@sirena.org.uk>.

=cut