1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Further cleanup from the strong-random patch.

Also use the new facility for generating RADIUS authenticator requests,
and salt in chkpass extension.

Reword the error messages to be nicer. Fix bogus error code used in the
message in BackendStartup.
This commit is contained in:
Heikki Linnakangas
2016-12-12 11:55:32 +02:00
parent 9bbbf029dd
commit 58445c5c8d
3 changed files with 13 additions and 17 deletions

View File

@ -17,6 +17,7 @@
#endif
#include "fmgr.h"
#include "utils/backend_random.h"
#include "utils/builtins.h"
PG_MODULE_MAGIC;
@ -77,8 +78,12 @@ chkpass_in(PG_FUNCTION_ARGS)
result = (chkpass *) palloc0(sizeof(chkpass));
mysalt[0] = salt_chars[random() & 0x3f];
mysalt[1] = salt_chars[random() & 0x3f];
if (!pg_backend_random(mysalt, 2))
ereport(ERROR,
(errmsg("could not generate random salt")));
mysalt[0] = salt_chars[mysalt[0] & 0x3f];
mysalt[1] = salt_chars[mysalt[1] & 0x3f];
mysalt[2] = 0; /* technically the terminator is not necessary
* but I like to play safe */