I'm changing a script from using FTP to SFTP. I have this code:
and I get the following error.
but as you can see, the code was able to see the existence of /dev/urandom before trying to open it.
Here are the permissions for /dev/urandom
Thanks in advance.
Josh
Code:
print "Trying to connect to $host.\n";
if ( $sftp = Net::SFTP->new( "$host" ) )
{
print "Connected to $host.\n";
$connected = "true";
}
else
{
$rc = 1;
push @ERRORS, "Can't connect to $host: $!\n";
}
The code in DH.pm is:Trying to connect to host_name. (output from my code)
Couldn't open /dev/urandom at /usr/local/lib/perl5/site_perl/5.8.8/Crypt/DH.pm line 96.
Code:
sub _makerandom {
my $size = shift;
my $bytes = int($size / 8) + ($size % 8 ? 1 : 0);
my $rand;
if (-e "/dev/urandom") {
my $fh;
[b][COLOR=red] open($fh, '/dev/urandom')
or die "Couldn't open /dev/urandom"; [/color][/b]
my $got = sysread $fh, $rand, $bytes;
die "Didn't read all bytes from urandom" unless $got == $bytes;
close $fh;
} else {
for (1..$bytes) {
$rand .= chr(int(rand(256)));
}
}
my $bits = unpack("b*", $rand);
die unless length($bits) >= $size;
Math::BigInt->new('0b' . substr($bits, 0, $size));
}
Here are the permissions for /dev/urandom
So I'm not sure why it can't read from it. I've been looking on-line and haven't found anything that would help. Any suggestions as to how to fix this or get around it?=> ls -l /dev/urandom
crw-r--r-- 1 root system 40, 1 May 21 2007 /dev/urandom
Thanks in advance.
Josh