]> andersk Git - openssh.git/blame - fixprogs
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / fixprogs
CommitLineData
b13b6202 1#!/usr/bin/perl
2#
3# fixprogs - run through the list of entropy commands and
4# score out the losers
5#
6
7$entscale = 50; # divisor for optional entropy measurement
8
9sub usage {
10 return("Usage: $0 <command file>\n");
11}
12
13if (($#ARGV == -1) || ($#ARGV>1)) {
14 die(&usage);
15}
16
17# 'undocumented' option - run ent (in second param) on the output
18if ($#ARGV==1) {
19 $entcmd=$ARGV[1]
20} else {
21 $entcmd = ""
22};
23
24$infilename = $ARGV[0];
25
26if (!open(IN, "<".$infilename)) {
27 die("Couldn't open input file");
28}
29$outfilename=$infilename.".out";
30if (!open(OUT, ">$outfilename")) {
31 die("Couldn't open output file $outfilename");
32}
33@infile=<IN>;
34
35select(OUT); $|=1; select(STDOUT);
36
37foreach (@infile) {
38 if (/^\s*\#/ || /^\s*$/) {
39 print OUT;
40 next;
41 }
42 ($cmd, $path, $est) = /^\"([^\"]+)\"\s+([\w\/_-]+)\s+([\d\.\-]+)/o;
43 @args = split(/ /, $cmd);
44 if (! ($pid = fork())) {
45 # child
46 close STDIN; close STDOUT; close STDERR;
7f8f5e00 47 open (STDIN, "</dev/null");
159aca18 48 open (STDOUT, ">/dev/null");
7f8f5e00 49 open (STDERR, ">/dev/null");
b13b6202 50 exec $path @args;
51 exit 1; # shouldn't be here
52 }
53 # parent
54 waitpid ($pid, 0); $ret=$? >> 8;
55
56 if ($ret != 0) {
57 $path = "undef";
58 } else {
59 if ($entcmd ne "") {
60 # now try to run ent on the command
61 $mostargs=join(" ", splice(@args,1));
62 print "Evaluating '$path $mostargs'\n";
63 @ent = qx{$path $mostargs | $entcmd -b -t};
64 @ent = grep(/^1,/, @ent);
65 ($null, $null, $rate) = split(/,/, $ent[0]);
66 $est = $rate / $entscale; # scale the estimate back
67 }
aff51935 68 }
b13b6202 69 print OUT "\"$cmd\" $path $est\n";
70}
71
72close(IN);
This page took 0.751631 seconds and 5 git commands to generate.