This file is indexed.

/usr/bin/post_faq is in post-faq 0.10-18.

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
#!/usr/bin/perl
# 
# $Id: post_faq.pl.base,v 1.42 1994/11/01 17:36:25 tkoenig Exp $
# 
# Copyright (c) 1991 Jonathan I. Kamens.  See the GNU Public License
# (any version) for terms of distribution.

push(@INC, "/usr/share/post-faq");

require 'faqfile.pl';

$SIG{'PIPE'} = 'sigpipe';

# These variables can be overridden by command-line options.

open(SERVER, "< /etc/news/server") || die "Opening /etc/news/server to read: $!.\n";
$server = <SERVER>;
chop $server;			# News server to which to connect, if NNTP
close SERVER;

$default_inews = "/usr/bin/inews";	# Inews program to use

open(IDHOST, "< /etc/mailname") || die "Opening /etc/mailname to read: $!.\n";
$idhost = <IDHOST>;
chop $idhost;			# News server to which to connect, if NNTP
close IDHOST;

$configfile = undef;
$faqfile'file_version = 2;
$expire_search = undef;

# These can be overridden by each FAQ.

$faqfile'default_interval = 0;	# Default interval to wait between postings
$faqfile'default_sigfile = "none";	# Signature file to append to posting
$faqfile'default_force = 0;		# Force posting of this FAQ?

# These can't be overridden at all without editing the script.

@months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
	   'Sep', 'Oct', 'Nov', 'Dec');

# This controls the number of days added to _twice_ the posting
# interval in order to determine how many days into the future the
# "Expires" header date should be set. I've picked a value of 7, which
# means that I'm assuming that an article will make it to the entire
# USENET within the interval plus 7 days of when it is posted.
$expire_slop = 7;

%faqs = ();
%only = ();
%omit = ();
$quiet = 0;
$newstamp = time;

$usage = "Usage: $0 -config file-name [ -interval days ]
	[ -inewscmd command ] [ -server nntp-server ] [ -idhost host-name ]
	[ -sigfile file-name ] [ -quiet number ] [ -omit id-list ]
	[ -only id-list ] [ -force ] [ -expire_search ] [ -debug ]";

# Parse command line arguments

while ($_ = $ARGV[0], /^-/) {
    shift;
    if (/^-interval$/) {
	((@ARGV > 0) || die "Missing argument to \"-interval\" option.\n")
	    && ($faqfile'default_interval = shift) && next;
    }
    elsif (/^-inewscmd$/) {
	((@ARGV > 0) || die "Missing argument to \"-inewscmd\" option.\n")
	    && ($inews = shift) && next;
    }
    elsif (/^-server$/) {
	((@ARGV > 0) || die "Missing argument to \"-server\" option.\n")
	    && ($server = shift) && next;
    }
    elsif (/^-idhost$/) {
	((@ARGV > 0) || die "Missing argument to \"-idhost\" option.\n")
	    && ($idhost = shift) && next;
    }
    elsif (/^-sigfile$/) {
	((@ARGV > 0) || die "Missing argument to \"-sigfile\" option.\n")
	    && ($faqfile'default_sigfile = shift) && next;
    }
    elsif (/^-config$/) {
	((@ARGV > 0) || die "Missing argument to \"-config\" option.\n")
	    && ($configfile = shift) && next;
    }
    elsif (/^-quiet$/) {
	((@ARGV > 0) || die "Missing argument to \"-quiet\" option.\n");
	$quiet = shift;
	next;
    }
    elsif (/^-omit$/) {
	if (@ARGV > 0) {
	    foreach $i (split(/,/, shift)) {
		$omit{$i}++;
	    }
	    next;
	}
	else {
	    die "Missing argument to \"-omit\" option.\n";
	}
    }
    elsif (/^-only$/) {
	if (@ARGV > 0) {
	    foreach $i (split(/,/, shift)) {
		$only{$i}++;
	    }
	    next;
	}
	else {
	    die "Missing argument to \"-only\" option.\n";
	}
    }
    elsif (/^-force$/) {
	($faqfile'default_force = 2) && next;
    }
    elsif (/^-debug$/) {
	++$debug && next;
    }
    elsif (/^-expire_search$/) {
	++$expire_search && next;
    }
    die "Unknown option \"$_\".\n$usage\n";
}

die "No config file specified!\n$usage\n" if (! $configfile);

($faqfile'default_sigfile = undef) if ($faqfile'default_sigfile eq "none");

if (! defined($inews)) {
    if ($debug) {
	$inews = "cat";
    }
    else {
	$inews = $default_inews . " -h";
    }
}

$ENV{'NNTPSERVER'} = $server;

if ($debug) {
    $configin = $configfile;
    $configout = "/dev/null";
    print "Not modifying config file, because -debug specified.\n"
	if ($quiet < 1);
}
else {
    if (-z $configfile) {
	die "Configuration file is zero size.... aborting!\n";
    }
    $configin = "$configfile.old";
    $configout = $configfile;
    rename($configout, $configin) || 
	die "Renaming $configout: $!.\n";
}
open(CONFIG, "$configin") || die "Opening $configin to read: $!.\n";
open(CONFIGOUT, ">$configout") || die "Opening $configout to write: $!.\n";

while (<CONFIG>) {
    chop;
    local($idname, $file, $oldstamp, $interval, $sigfile, $force, $parent) =
	&faqfile'parse_faq($_);
    ($sigfile = $faqfile'default_sigfile) if (! $sigfile);

    if (! $idname) {
	print CONFIGOUT $_, "\n" ||
	    die "Writing to $configout: $!.\n";
	next;
    }

    if (%only) {
	if (!$only{$idname}) {
	    print "Skipping $idname because of -only.\n"
		if ($quiet < 1);
	    goto nextone;
	}
    }
    elsif (%omit) {
	if ($omit{$idname}) {
	    print "Skipping $idname because of -omit.\n"
		if ($quiet < 1);
	    goto nextone;
	}
    }

    ($timeout, $reason) = &faqfile'should_post($idname);

    if (! $timeout) {
	print("Skipping $idname ($reason).\n") if ($quiet < 1);
	goto nextone;
    }
    else {
	print "Posting $idname ($reason).\n" if ($quiet < 1);
	$inews_pid = open(INEWS, "|$inews");
	open(FAQ, $file) || 
	    (warn("Opening $file (for $idname): $!.\n"), goto nextone);
	printf(INEWS "Message-ID: %s\n", 
	       &message_id($idname, $newstamp, $idhost)) ||
		   (warn("Printing to $inews pipe: $!.\n"), goto nextone);
	if ($oldstamp) {
	    printf(INEWS "Supersedes: %s\n",
		   &message_id($idname, $oldstamp, $idhost)) ||
		       (warn("Printing to $inews pipe: $!.\n"), goto nextone);
	}
	$expire_time = undef;
	if ($interval =~ /^[0-9]+$/) {
	    if ($interval > 0) {
		$expire_time = $newstamp + (2 * $interval + $expire_slop) *
		    (60 * 60 * 24);
	    }
	}
	elsif ($expire_search) {
	    $expire_time = &faqfile'expire_search($idname, $newstamp) +
		$expire_slop * (60 * 60 * 24);
	}
	if ($expire_time) {
	    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
		gmtime($expire_time);
	    $year += 1900;
	    printf(INEWS "Expires: %d %s %d %02d:%02d:%02d GMT\n",
		   $mday, $months[$mon], $year, $hour, $min, $sec) ||
		       (warn("Printing to $inews pipe: $!.\n"), goto nextone);
	}
	if ($parent) {
	    printf(INEWS "References: %s\n", 
		   &message_id($parent, &faqfile'timestamp($parent), 
			       $idhost)) ||
				   (warn("Printing to $inews pipe: $!.\n"),
				    goto nextone);
	}
	while (<FAQ>) {
	    while (/\@message-id +([^ \@]+) *\@/i) {
		local($newid) = &message_id($1, $newstamp, $idhost);
		$_ = $` . $newid . $'; #`
	    }
	    while (/\@old-id +([^ \@]+) *\@/i) {
		local($time) = &faqfile'timestamp($1);
		local($newid);
		if ($time) {
		    $newid = &message_id($1, $time, $idhost);
		}
		else {
		    warn "$idname requests Message ID of unknown posting $1.\n";
		    $newid = "<unknown>";
		}
		$_ = $` . $newid . $'; #`
	    }
	    print INEWS $_ || 
		(warn("Printing to $inews pipe: $!.\n"), goto nextone);
	}
	if ($sigfile && ($sigfile ne "none")) {
	    if (! open(SIGFILE, $sigfile)) {
		warn "Opening \"$sigfile\": $!.\nSignature will not be included on $idname.\n";
	    }
	    else {
		print INEWS "-- \n" || 
		    (warn("Printing to $inews pipe: $!.\n"), goto nextone);
		while (<SIGFILE>) {
		    print INEWS $_ ||
			(warn("Printing to $inews pipe: $!.\n"), goto nextone);
		}
	    }
	}

	close(INEWS);
	$inews_pid = undef;
	if ($?) {
	    warn "$inews exited with non-zero status posting $idname.\n";
	    goto nextone;
	}
	close(FAQ);
	printf("Article %s posted successfully.\n",
	       &message_id($idname, $newstamp, $idhost))
	    if ($quiet < 2);
	if ($force == 1) {
	    &faqfile'set_force($idname, undef);
	    print "Force disabled on $idname.\n"
		if ($quiet < 2);
	}
	elsif ($force == 3) {
	    &faqfile'set_force($idname, -2);
	    print "Force replaced with suspend on $idname.\n"
		if ($quiet < 2);
	}
	&faqfile'set_posted($idname);
	&faqfile'set_timestamp($idname, $newstamp);
    }
nextone:
    kill('TERM', $inews_pid) if ($inews_pid);
    print CONFIGOUT &faqfile'configline($idname), "\n" ||
	die "Writing to $configout: $!.\n";
}

close(CONFIG);
close(CONFIGOUT) || die "Closing $configout: $!.\n";

sub message_id {
    # Takes three arguments -- an ID name, a time, and a host name --
    # and returns the message ID to use.  If you want to do custom
    # message ID's for some or all of your FAQs, this is the routine
    # to modify.
    # 
    # Beware that this routine is used to generate message IDs of
    # parent articles as well as message IDs of articles currently
    # being posted, so don't put in any implicit dependencies that
    # won't work.

    local($idname, $time, $host) = @_;

    "<${idname}_${time}\@${host}>";
}

sub sigpipe {
    # Don't do anything; we'll notice it because $? will be non-zero
    # when the file handle is closed.
}