Re: Random number generation, take two

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Random number generation, take two
Date: 2016-12-05 11:45:00
Message-ID: 3fd8ed88-2a5e-1336-bf26-4803c3287195@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/30/2016 03:22 PM, Michael Paquier wrote:
> On Wed, Nov 30, 2016 at 8:51 PM, Heikki Linnakangas <hlinnaka(at)iki(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-12-05 12:07:59 Re: Random number generation, take two
Previous Message Fujii Masao 2016-12-05 11:39:07 Re: GIN logging GIN_SEGMENT_UNMODIFIED actions?