From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id gBxwESWxcF8oIwAA0tVLHw (envelope-from ) for ; Sun, 27 Sep 2020 15:35:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id SKw6DSWxcF9FVQAAB5/wlQ (envelope-from ) for ; Sun, 27 Sep 2020 15:35:01 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E0D799402DA for ; Sun, 27 Sep 2020 15:35:00 +0000 (UTC) Received: from localhost ([::1]:51794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMYhX-0003t0-U7 for larch@yhetil.org; Sun, 27 Sep 2020 11:34:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMYgd-0003fI-71 for guix-patches@gnu.org; Sun, 27 Sep 2020 11:34:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kMYgc-00043i-UG for guix-patches@gnu.org; Sun, 27 Sep 2020 11:34:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kMYgc-0002ng-S9 for guix-patches@gnu.org; Sun, 27 Sep 2020 11:34:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43650] [PATCH 8/8] secret-service: Add a timeout when waiting for a client. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 27 Sep 2020 15:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43650 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43650@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , janneke@gnu.org Received: via spool by 43650-submit@debbugs.gnu.org id=B43650.160122078710688 (code B ref 43650); Sun, 27 Sep 2020 15:34:02 +0000 Received: (at 43650) by debbugs.gnu.org; 27 Sep 2020 15:33:07 +0000 Received: from localhost ([127.0.0.1]:50222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMYfj-0002mF-1E for submit@debbugs.gnu.org; Sun, 27 Sep 2020 11:33:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMYfg-0002kh-An for 43650@debbugs.gnu.org; Sun, 27 Sep 2020 11:33:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52548) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMYfb-0003u6-2n; Sun, 27 Sep 2020 11:32:59 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=38894 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMYfa-00016f-C5; Sun, 27 Sep 2020 11:32:58 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 27 Sep 2020 17:32:21 +0200 Message-Id: <20200927153221.9154-8-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927153221.9154-1-ludo@gnu.org> References: <20200927153221.9154-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 3.49 X-TUID: 9MUrkfYXci8O * gnu/build/secret-service.scm (secret-service-receive-secrets) [wait-for-client]: Call 'select' with a 60s timeout before 'accept'. Return #f upon timeout. [read-secrets]: Return FILES on success. Adjust caller of 'wait-for-client' to handle #f. --- gnu/build/secret-service.scm | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/gnu/build/secret-service.scm b/gnu/build/secret-service.scm index aafb1684b5..40c24abf09 100644 --- a/gnu/build/secret-service.scm +++ b/gnu/build/secret-service.scm @@ -75,7 +75,8 @@ local PORT. If connect fails, sleep 1s and retry RETRY times." (define (secret-service-receive-secrets port) "Listen to local PORT and wait for a secret service client to send secrets. -Write them to the file system." +Write them to the file system. Return the list of files installed on success, +and #f otherwise." (define (wait-for-client port) ;; Wait for a TCP connection on PORT. Note: We cannot use the @@ -87,14 +88,20 @@ Write them to the file system." (format (current-error-port) "secret service: waiting for secrets on port ~a...~%" port) - (match (accept sock) - ((client . address) + (match (select (list sock) '() '() 60) + (((_) () ()) + (match (accept sock) + ((client . address) + (format (current-error-port) + "secret service: client connection from ~a~%" + (inet-ntop (sockaddr:fam address) + (sockaddr:addr address))) + (close-port sock) + client))) + ((() () ()) (format (current-error-port) - "secret service: client connection from ~a~%" - (inet-ntop (sockaddr:fam address) - (sockaddr:addr address))) - (close-port sock) - client)))) + "secret service: did not receive any secrets; time out~%") + #f)))) ;; TODO: Remove when (@ (guix build utils) dump-port) has a 'size' ;; parameter. @@ -128,15 +135,17 @@ installing file '~a' (~a bytes)...~%" (lambda (output) (dump port output size) (chmod file mode)))) - files sizes modes)) + files sizes modes) + files) (_ (format (current-error-port) "secret service: invalid secrets received~%") #f))) - (let* ((port (wait-for-client port)) - (result (read-secrets port))) - (close-port port) + (let* ((port (wait-for-client port)) + (result (and=> port read-secrets))) + (when port + (close-port port)) result)) ;;; secret-service.scm ends here -- 2.28.0