cpython: ddc54f08bdfa (original) (raw)

Mercurial > cpython

changeset 103972:ddc54f08bdfa 3.5

Catch EPERM error in py_getrandom() Issue #27955: Fallback on reading /dev/urandom device when the getrandom() syscall fails with EPERM, for example when blocked by SECCOMP. [#27955]

Victor Stinner victor.stinner@gmail.com
date Tue, 20 Sep 2016 22:46:02 +0200
parents 41e9e711b9b5
children 27d05bb6f832 06efc625578a
files Misc/NEWS Python/random.c
diffstat 2 files changed, 11 insertions(+), 7 deletions(-)[+] [-] Misc/NEWS 3 Python/random.c 15

line wrap: on

line diff

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Release date: TBA Core and Builtins ----------------- +- Issue #27955: Fallback on reading /dev/urandom device when the getrandom()

--- a/Python/random.c +++ b/Python/random.c @@ -121,8 +121,8 @@ py_getentropy(unsigned char buffer, Py_ / Call getrandom() - Return 1 on success

@@ -131,7 +131,7 @@ static int py_getrandom(void buffer, Py_ssize_t size, int raise) { / Is getrandom() supported by the running kernel? Set to 0 if getrandom()

@@ -250,7 +251,7 @@ dev_urandom_noraise(unsigned char *buffe if (py_getrandom(buffer, size, 0) == 1) { return; }

#endif @@ -301,7 +302,7 @@ dev_urandom_python(char *buffer, Py_ssiz if (res == 1) { return 0; }

#endif