[fpc-pascal] Random(), Randomize, and Linux permissions

Florian Klaempfl F.Klaempfl at gmx.de
Wed Sep 29 08:49:22 CEST 2004


Alan Mead wrote:
> It's known that Randomize() is not effective when called rapidly... I
> tried to solve this using the code sample below.  I can cat /dev/null
> (without becoming root) but when I run the code below I get an access
> denied RTE at 'Reset(f,1);'.. this code works fine when run as

/dev/random isn't effective either when called permanently. The entropy 
pool of /dev/random is limited and /dev/random is a blocking device thus 
it will block after several thousand calls. /dev/urandom doesn't block 
but it's pseudo random as soon as /dev/random runs out of entropy.

> root... anyone have a suggestion? 

Do a filemode:=0; before.

> 
> -Alan
> 
>   procedure SuperRandomize;
>     var
>       f: file of cardinal;
>       Card: Cardinal;
>     begin
>         Assign(f,'/dev/random');
>         Reset(f,1);
>         read(f,Card);
>         RandSeed := Card;
>         close(f);
>     end;
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal





More information about the fpc-pascal mailing list