Re: Random number generation, take two - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Random number generation, take two
Date
Msg-id 3fd8ed88-2a5e-1336-bf26-4803c3287195@iki.fi
Whole thread Raw
In response to Re: Random number generation, take two  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Random number generation, take two  (Michael Paquier <michael.paquier@gmail.com>)
Re: Random number generation, take two  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 11/30/2016 03:22 PM, Michael Paquier wrote:
> On Wed, Nov 30, 2016 at 8:51 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>> On 11/30/2016 09:01 AM, Michael Paquier wrote:
>>> Attached is a patch for MSVC to apply on top of yours to enable the
>>> build for strong and weak random functions. Feel free to hack it as
>>> needs be, this base implementation works for the current
>>> implementation.
>>
>> Great, thanks! I wonder if this is overly complicated, though. For
>> comparison, we haven't bothered to expose --disable-spinlocks in
>> config_default.pl either. Perhaps we should just always use the Windows
>> native function on MSVC, whether or not configured with OpenSSL, and just
>> put USE_WIN32_RANDOM in pg_config.h.win32? See 2nd attached patch
>> (untested).
>
> I could live with that. Your patch is not complete though, you need to
> add pg_strong_random.c into the array @pgportfiles in Mkvcbuild.pm.
> You also need to remove fortuna.c and random.c from the list of files
> in $pgcrypto->AddFiles(). After doing so the code is able to compile
> properly.

Ok, did that, I hope I got it right.

> +               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> +                errmsg("pg_random_bytes() is not supported by this build"),
> +                errdetail("This functionality requires a source of
> strong random numbers"),
> +                errhint("You need to rebuild PostgreSQL using
> --enable-strong-random")));
> Perhaps this should say "You need to rebuild PostgreSQL without
> --disable-strong-random", the docs do not mention
> --enable-strong-random nor does ./configure --help.

I could go either way, but I left it as it is, to avoid the double 
negative "without disable".

> +/* port/pg_strong_random.c */
> +#ifndef USE_WEAK_RANDOM
> +extern bool pg_strong_random(void *buf, size_t len);
> +#endif
> This should be HAVE_STRONG_RANDOM.

Fixed.

Pushed with those fixes. Let's see what the buildfarm thinks now.

Tom: I expect pademelon to fail at the configure step, complaining that 
"no source of strong random numbers was found". Let's wait for one 
cycle, to verify that it does fail like that. After that, can you add 
the --disable-strong-random flag to fix it, please?

- Heikki




pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: GIN logging GIN_SEGMENT_UNMODIFIED actions?
Next
From: Michael Paquier
Date:
Subject: Re: Random number generation, take two