fopen(/dev/urandom): failed to open stream: No such file or directory ??
Ciao, mi rivolgo a qualche drupalista linux che sicuramente sa cosa sta succedendo durante una mia installazione di Drupal 7 su WAMP:
Warning, fopen(/dev/urandom): failed to open stream: No such file or directory, drupal_random_bytes() nel file bootstrap.inc
E' chiaro che /dev/ non esiste in windows... ma come posso avere la generazione random equivalente. Piu che altro lo voglio fare a scopo didattico essendo bootstrap un file del core. Oppure mi devo accontentare di un
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { ?
la funzione in questione è questa:
/**
* Returns a string of highly randomized bytes (over the full 8-bit range).
*
* This function is better than simply calling mt_rand() or any other built-in
* PHP function because it can return a long string of bytes (compared to < 4
* bytes normally from mt_rand()) and uses the best available pseudo-random source.
*
* @param $count
* The number of characters (bytes) to return in the string.
*/
function drupal_random_bytes($count) {
// $random_state does not use drupal_static as it stores random bytes.
static $random_state;
// We initialize with the somewhat random PHP process ID on the first call.
if (empty($random_state)) {
$random_state = getmypid();
}
$output = '';
// /dev/urandom is available on many *nix systems and is considered the best
// commonly available pseudo-random source.
if ($fh = @fopen('/dev/urandom', 'rb')) {
$output = fread($fh, $count);
fclose($fh);
}
// If /dev/urandom is not available or returns no bytes, this loop will
// generate a good set of pseudo-random bytes on any system.
// Note that it may be important that our $random_state is passed
// through md5() prior to being rolled into $output, that the two md5()
// invocations are different, and that the extra input into the first one -
// the microtime() - is prepended rather than appended. This is to avoid
// directly leaking $random_state via the $output stream, which could
// allow for trivial prediction of further "random" numbers.
while (strlen($output) < $count) {
$random_state = md5(microtime() . mt_rand() . $random_state);
$output .= md5(mt_rand() . $random_state, TRUE);
}
return substr($output, 0, $count);
}
Grazie
Ps (non togliero la visualizzazione degli errori per motivi di sviluppo...)

Risposte
Non è possibile che non ci
Non è possibile che non ci sia nessun Linux-user che non sappia cosa fa /dev/urandom...
Up