openssh/fixprogs
Damien Miller 606f880e0f - (djm) Shadow expiry check fix from Pavel Troller <patrol@omni.sinus.cz>
- (djm) Re-enable int64_t types - we need them for sftp
 - (djm) Use libexecdir from configure , rather than libexecdir/ssh
 - (djm) Update Redhat SPEC file accordingly
 - (djm) Add Kevin Steves <stevesk@sweden.hp.com> HP/UX contrib files
 - (djm) Add Charles Levert <charles@comm.polymtl.ca> getpgrp patch
 - (djm) Fix password auth on HP/UX 10.20. Patch from Dirk De Wachter
   <Dirk.DeWachter@rug.ac.be>
 - (djm) Fixprogs and entropy list fixes from Larry Jones
   <larry.jones@sdrc.com>
 - (djm) Fix for SuSE spec file from Takashi YOSHIDA
   <tyoshida@gemini.rc.kyushu-u.ac.jp>
2000-09-16 15:39:56 +11:00

73 lines
1.6 KiB
Perl
Executable File

#!/usr/bin/perl
#
# fixprogs - run through the list of entropy commands and
# score out the losers
#
$entscale = 50; # divisor for optional entropy measurement
sub usage {
return("Usage: $0 <command file>\n");
}
if (($#ARGV == -1) || ($#ARGV>1)) {
die(&usage);
}
# 'undocumented' option - run ent (in second param) on the output
if ($#ARGV==1) {
$entcmd=$ARGV[1]
} else {
$entcmd = ""
};
$infilename = $ARGV[0];
if (!open(IN, "<".$infilename)) {
die("Couldn't open input file");
}
$outfilename=$infilename.".out";
if (!open(OUT, ">$outfilename")) {
die("Couldn't open output file $outfilename");
}
@infile=<IN>;
select(OUT); $|=1; select(STDOUT);
foreach (@infile) {
if (/^\s*\#/ || /^\s*$/) {
print OUT;
next;
}
($cmd, $path, $est) = /^\"([^\"]+)\"\s+([\w\/_-]+)\s+([\d\.\-]+)/o;
@args = split(/ /, $cmd);
if (! ($pid = fork())) {
# child
close STDIN; close STDOUT; close STDERR;
open (STDIN, "</dev/null");
open (STDOUT, ">/tmp/foo");
open (STDERR, ">/dev/null");
exec $path @args;
exit 1; # shouldn't be here
}
# parent
waitpid ($pid, 0); $ret=$? >> 8;
if ($ret != 0) {
$path = "undef";
} else {
if ($entcmd ne "") {
# now try to run ent on the command
$mostargs=join(" ", splice(@args,1));
print "Evaluating '$path $mostargs'\n";
@ent = qx{$path $mostargs | $entcmd -b -t};
@ent = grep(/^1,/, @ent);
($null, $null, $rate) = split(/,/, $ent[0]);
$est = $rate / $entscale; # scale the estimate back
}
}
print OUT "\"$cmd\" $path $est\n";
}
close(IN);