From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id wCSaHLwkMmXfdAAAauVa8A:P1 (envelope-from ) for ; Fri, 20 Oct 2023 08:57:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id wCSaHLwkMmXfdAAAauVa8A (envelope-from ) for ; Fri, 20 Oct 2023 08:57:00 +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 E336C58ED9 for ; Fri, 20 Oct 2023 08:56:59 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=LiIJsvhF; dmarc=none; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1697785020; a=rsa-sha256; cv=none; b=ejPRPPgZMjrdubzP+XtitEBHCfGWD+cmh8wpGY4kkARfqDetqbP7ztKSbS1rEpo+JdIPfw nLfb4JlENxJ6Nd01WSqIosqUgs3DyBtS+ACfS54OS8VbbpkxlS4CPqdbHL/Ip5qzmLAj5S DrVePbM8e674q15uwbXk9jI20OlC9V4HCJCThIn8al5VuGR+6HdBGb0+p/IJcj8eFo9F6q xj+GdL//J6m58oHE+eMKcC8StyXZZHeNbR1o7cvnUnD5kOZ1WPZDLT/wiQWXVOXPPc9Aov 0/76NtwQWsi+Dr0DValCfvy7FSD5O/9ElQVLuijbKCGOwnzwEgsa2IQVsmHdZg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=LiIJsvhF; dmarc=none; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697785020; 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-cc: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=uWUwm4UuJ5TlVjgrB7v4ovnCqtclASiLJHCn9RgTWKY=; b=U6m7VQ6vkfl2ejRXkU04OEAxE1/UJtSUxAMz1bRQGt7BsGLN9kaJhVOyMHNuq/T0N8i8zA lg8Z3QxK1+st0XO3nweVLj/T0iWbnuGvR1qppLjAv4ESAaYh+hRhGyN5bTI97bkAyLjlwF 26reYISKTncPxn5ErtciOJnN5l1uC0OeWhZc9GJV5gDziu91z5a7nPGFAGoPfb2+EMvyJ6 05RgfmzYYx4ycqQER3gtiZ8FWxKoE4kCkv8d0c0nDmJCqlLh8XiOtU22AHM4/e6ZAQnPj6 lT3pzY7P/Pp/JzhCJ9R1lxkNEG1nt+eCqbdh5BIF74v0HkU3+k6wnMWfDd4C2w== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjR0-0006mN-0P; Fri, 20 Oct 2023 02:56: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 1qtjQy-0006jh-Nf for guix-patches@gnu.org; Fri, 20 Oct 2023 02:56:36 -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 1qtjQy-00038W-E7 for guix-patches@gnu.org; Fri, 20 Oct 2023 02:56:36 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qtjRP-0003gZ-Db for guix-patches@gnu.org; Fri, 20 Oct 2023 02:57:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66387] [PATCH] home: services: Fix race condition when detecting first login Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 20 Oct 2023 06:57:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Carlo Zancanaro Cc: 66387-done@debbugs.gnu.org, paren@disroot.org Received: via spool by 66387-done@debbugs.gnu.org id=D66387.169778498714107 (code D ref 66387); Fri, 20 Oct 2023 06:57:03 +0000 Received: (at 66387-done) by debbugs.gnu.org; 20 Oct 2023 06:56:27 +0000 Received: from localhost ([127.0.0.1]:38511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtjQp-0003fS-1L for submit@debbugs.gnu.org; Fri, 20 Oct 2023 02:56:27 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]:50051) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtjQl-0003fC-Rz for 66387-done@debbugs.gnu.org; Fri, 20 Oct 2023 02:56:26 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 3B1C160002; Fri, 20 Oct 2023 06:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1697784951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uWUwm4UuJ5TlVjgrB7v4ovnCqtclASiLJHCn9RgTWKY=; b=LiIJsvhFCHInni/+R5w0Zy9+d8CcGAhs5nUuX1M5BeourDt2LSkU8HTgZcj+hjNTtEE9cf 5LbAcvVE8/u1wzTqn8Yi9yard3BY9vVSaZPk/KhiIHTRiuCTJK0ixBXfj6SqK7naKU+Fnr /I+yw0YVDubSSQOH5hq/+zR61TNA+pW+U/dzw0P5BYJjkqLUyAmeAsUycObrEEsqN3tmNs hjTJiv3woxLhqaH1Sh3Z4EdCWVu5hmWbvQ9EMIfJ+t1E+II3A+gyi7RnDHt+w3Xd5Qjgcy eV8zGORBVHxDK/a24dSJfuMb3zog4kJigEMUSPRKPZhMVG/rcrJKqbMARRVL5w== From: Andrew Tropin In-Reply-To: <87v8b2xsnl.fsf@gnu.org> References: <87bkd8djri.fsf@zancanaro.id.au> <87v8b2xsnl.fsf@gnu.org> Date: Fri, 20 Oct 2023 10:55:46 +0400 Message-ID: <87v8b1hjf1.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-GND-Sasl: andrew@trop.in 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-Scanner: mx1.migadu.com X-Migadu-Spam-Score: -4.36 X-Spam-Score: -4.36 X-Migadu-Queue-Id: E336C58ED9 X-TUID: 8BOrhxgSlVZ5 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2023-10-19 22:29, Ludovic Court=C3=A8s wrote: > 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 che= aper than > =E2=80=98open=E2=80=99) and applied it. > > Thanks! > > Ludo=E2=80=99. > > 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)) >=20=20 > - (define (claim-first-run file-name) > + (define (claim-first-run file) Very nice trick! Carol, Ludo, Thank you for the fix! > (catch #t > (lambda () > - ;; This incantation will raise an error if the file at > - ;; flag-file-path already exists, and will create it otherw= ise. > - (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))) >=20=20 > #$%initialize-gettext >=20=20 =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmUyJHIACgkQIgjSCVjB 3rAYug/7BkuTr4lnW54Mbtc+/SadOYy6DcmvGysj+EbvYJkbIkp+otnX4jeC1sXk KkYP9lCqJzlP3mOxv+yBmpq87ZDNnaRwfS8VfdIhLdnTNx89PlBXU/9s6aQ2CQ7a OIzoBJIJXLTTpMGCrskFXspdpsluFbguleuDy0mD8B619YZipxZnt/lJd2yQTAOG yLaT9eBoIqWSQjDATpH10dWRBYcAfTq5XczCmiyea2DektYqAg6GFqPnAYIwmgRv mSZiF9SBUjKIObp/jGjtc+texplNecCu70W9D1PYfPycIZVFhL/Xw8HWHR3lwcr1 ynmlVuCgYiuX7QHubfsbffKAHAYdNSyvjxgZH9nle7pLm9CffM1sPHjSWMaqpXdf VMWETOpD2DIcrL6s7QzRqoOTQXDeC4xJzRKGCylP9L3PAzKrG4nw5LOBL9dyNGbf dUk02arHBcw0+PnJjrQOYsvTZa+e5gQ6wrHnUfRNrAOdZzC1j67JQ2KXbNTUVWMA qjbRZcC5uKaXB0Bo0AIrmMNulqWO0QI48+OpizMaiTwHZ3nRDGFz83YI6R4kGZme GR3Ueo/wlg1JpUdG3kP5FoA3ujgbX1LlaM9A4lly1AHKCPfmb4/PnmY/iijpbcjw 4j7kqQPdz9a17Yc+SZ0kG0AGsoxByrs7kUWpo5/YO3DJgWjpZXE= =MSho -----END PGP SIGNATURE----- --=-=-=--