From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id QMd4EReSMWXEEAAAauVa8A:P1 (envelope-from ) for ; Thu, 19 Oct 2023 22:31:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id QMd4EReSMWXEEAAAauVa8A (envelope-from ) for ; Thu, 19 Oct 2023 22:31:19 +0200 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 009705CB25 for ; Thu, 19 Oct 2023 22:31:19 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Zh+f3B5m; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697747479; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-to:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=YuqmrsYRuZzp5Hu4lr6tEXVqT58o0HgxfKW4i77voLg=; b=M/MwvnWjlUfvc+dOparZLBo80Ql/1xCoqHhdkVwH2XIUK5Q4lz+Ea8Ey2o4IEiHq1wYB8t XXOWbuaHWyH/Py/Qn08TPwEHeLVzZszvmhE47eqKdg/4BT3vNN9VKIm/PY4PgZXlSajFQn pT0WfgkI7UP3hPo4WR3WxUbCCR4DWl7breVH1MU30YZfyY5X0wPUuU95+bRupwHgL7mFam ZjIUA2TiQsDcc9XkT1qE82DuDxtjBswDT1VHEdH6+z6/XScQ94mG1og0pjPujiWqfpXWpc TEDOrU1T1dwDjV5UMzit6X5Af3Z1c1ebC5df0sgkrHw4RR1LZ3/xVWNn8+N2+Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Zh+f3B5m; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1697747479; a=rsa-sha256; cv=none; b=o/35XfLWmEj7C+XOMC3NVAWJimksxqO67M0JXUVJerCtUw3bA+mz0jKHmOajoqGp0BAl/2 vA/xAJPFGY/6OObphh9MYH9xf4PDFDeWIy2KG0UhHQ8DcRrp57vPuX4VCUwSxgNbz+SidZ daG9IkZMnF/tqzFLQrnBmizikIaey5KrQuJMV8rZMqP1PMvtwVT6cfVO2o4x3UdMtWQzKg tnPNiFYqRXblMQ4fFZrYU4Mq+RF7zYR2vDLRhv3XFqXMbYnoWsq9sanV+7q8Ij5c0+I9sK 03qx+4Efd1GOh0jnwwUd+cLYnkJH+8WMo/6UkuPPZ6QhS7wDTJk9JiJx1PskzA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtZfC-0002Tu-Dr; Thu, 19 Oct 2023 16:30:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtZf9-0002T4-VT for guix-patches@gnu.org; Thu, 19 Oct 2023 16:30:35 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtZf9-000522-Mz for guix-patches@gnu.org; Thu, 19 Oct 2023 16:30:35 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qtZfa-0000h8-1E for guix-patches@gnu.org; Thu, 19 Oct 2023 16:31:02 -0400 Subject: bug#66387: [PATCH] home: services: Fix race condition when detecting first login Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Thu, 19 Oct 2023 20:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 66387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Carlo Zancanaro Cc: 66387-done@debbugs.gnu.org, Andrew Tropin , paren@disroot.org Mail-Followup-To: 66387@debbugs.gnu.org, ludo@gnu.org, carlo@zancanaro.id.au Received: via spool by 66387-done@debbugs.gnu.org id=D66387.16977474142596 (code D ref 66387); Thu, 19 Oct 2023 20:31:01 +0000 Received: (at 66387-done) by debbugs.gnu.org; 19 Oct 2023 20:30:14 +0000 Received: from localhost ([127.0.0.1]:37924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtZen-0000fo-Vi for submit@debbugs.gnu.org; Thu, 19 Oct 2023 16:30:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtZel-0000eS-2v for 66387-done@debbugs.gnu.org; Thu, 19 Oct 2023 16:30:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtZeC-0004iR-V7; Thu, 19 Oct 2023 16:29:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=YuqmrsYRuZzp5Hu4lr6tEXVqT58o0HgxfKW4i77voLg=; b=Zh+f3B5mIHAynh35A9FD 8NPi4KgMe62Q9yJHOTl0NKpl/xVHqpxY0fy9C+FgwwVLRTRYEiIPOG/faRjRPboTkLoOXxlz97bKj 3A3ztyHswunyllo4shdYdvjsZQA5pTtY6VOLhECgTFRjU4G1hZziJUy2ZUtXLBKTGfgLVAUgYNhnH YW22sb7qMtLqVKb08QMZb607eSdMfQ59Cg7TyAiqdSR/P4i3C9oh0MYNTylqIZTGWVC2hmKk2yMmm w2i9dcUjXPfulGgzEyhjBuQ1CAIn80z69fL7u2s0FcA4mlIGkAqdvolJE+Gh9IrgqgUlvczjyLMPo IlGGfE+qhl3Vsw==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: (Carlo Zancanaro's message of "Wed, 11 Oct 2023 22:57:19 +1100") References: <87bkd8djri.fsf@zancanaro.id.au> Date: Thu, 19 Oct 2023 22:29:34 +0200 Message-ID: <87v8b2xsnl.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -5.83 X-Spam-Score: -5.83 X-Migadu-Queue-Id: 009705CB25 X-Migadu-Scanner: mx2.migadu.com X-TUID: 9zI8JBPFw5vQ --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Carlo, Carlo Zancanaro skribis: > * gnu/home/services.scm (compute-on-first-login-script): Use open to > atomically check whether a file exists and create it if not. Good catch! I made the following cosmetic changes (=E2=80=98open-fdes=E2=80=99 is cheap= er than =E2=80=98open=E2=80=99) and applied it. Thanks! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/home/services.scm b/gnu/home/services.scm index 7137925b30..651c068f79 100644 --- a/gnu/home/services.scm +++ b/gnu/home/services.scm @@ -414,15 +414,15 @@ (define (compute-on-first-login-script _ gexps) (use-modules (guix i18n) (guix diagnostics)) - (define (claim-first-run file-name) + (define (claim-first-run file) (catch #t (lambda () - ;; This incantation will raise an error if the file at - ;; flag-file-path already exists, and will create it otherwise. - (close (open file-name (logior O_CREAT O_EXCL))) + ;; This incantation raises an error if FILE already exists, and + ;; creates it otherwise. + (close-fdes + (open-fdes file (logior O_CREAT O_EXCL O_CLOEXEC))) #t) - (lambda _ - #f))) + (const #f))) #$%initialize-gettext --=-=-=--