From patchwork Tue Dec 17 19:38:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1211643 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108158-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ay+z5l5H"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47cpNp5s2Sz9sR7 for ; Wed, 18 Dec 2019 06:39:04 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=Cl5 /+47mw4wxNAeCsjQrIZ2upL4mY367RwVnT04/dpMS0fWJpaSbn26vxO/QGoxR4TS l6m7kkqfHdYzlzaNieeH/8kNZugcTvLTuBl7GJ7WId4MXeC5v/bjIsMq3rd8xwFj 8UO2tw8bzVrDCwP2JM9FbEJjdfORnj1oswWRT66o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=1CiDip/Ki LeIy1STuchJwHw3l+c=; b=ay+z5l5HcOXDk0Yh2t4qsk+wFgXtLFVl3WXQm6ywU pcMqacmuBxSabRf/I/PpFludgKltZxDWyvI1R49uNlgdmZhcRQ8qrwMFiRaV3bnp vOCH4ccX6c5RMiQ5PXKDmDx/kVneXIU1uLzB9KX6VQmV7ZojZfftblk4DYxJLWBw ZU= Received: (qmail 96828 invoked by alias); 17 Dec 2019 19:38:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 96818 invoked by uid 89); 17 Dec 2019 19:38:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: James Clarke , commit-hurd@gnu.org Subject: [hurd,commited] hurd: Make getrandom honour GRND_NONBLOCK Date: Tue, 17 Dec 2019 20:38:45 +0100 Message-Id: <20191217193845.8162-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 From: James Clarke * sysdeps/mach/hurd/getrandom.c (__getrandom): Open the random source with O_NONBLOCK when the GRND_NONBLOCK flag is provided. Message-Id: <20191217182929.90989-1-jrtc27@jrtc27.com> --- sysdeps/mach/hurd/getrandom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/getrandom.c b/sysdeps/mach/hurd/getrandom.c index 8bf42aa40d..aac9c6f8c6 100644 --- a/sysdeps/mach/hurd/getrandom.c +++ b/sysdeps/mach/hurd/getrandom.c @@ -27,13 +27,17 @@ ssize_t __getrandom (void *buffer, size_t length, unsigned int flags) { const char *random_source = "/dev/urandom"; + int open_flags = O_RDONLY | O_CLOEXEC; size_t amount_read; int fd; if (flags & GRND_RANDOM) random_source = "/dev/random"; - fd = __open_nocancel(random_source, O_RDONLY | O_CLOEXEC); + if (flags & GRND_NONBLOCK) + open_flags |= O_NONBLOCK; + + fd = __open_nocancel(random_source, open_flags); if (fd == -1) return -1;