I present: The Elusive 'fixprogs' script

Andre Lucas andre.lucas at dial.pipex.com
Sat May 20 06:48:27 EST 2000


Hi,

Here's the 'fixprogs' perl script that got missed off the 2.1.0p1
distribution. Please put this in your openssh directory, and re-run
'make install'. it doesn't need to be made executable.

For those interested, it runs through all the commands in the
ssh_prng_cmds file and tests if they work (as opposed to 'configure'
merely verifying that the executable exists, as it was before.)
Commands that fail are marked and never run by openssh.

There is primitive measurement of each command's entropy rate as well,
but this may not survive the next release.

Ta,
-Andre'

-- 
Andre Lucas <andre.lucas at dial.pipex.com>
-------------- next part --------------
#!/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, ">/dev/null";
     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);


More information about the openssh-unix-dev mailing list