From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UHa0NAgvXWLvYQAAgWs5BA (envelope-from ) for ; Mon, 18 Apr 2022 11:27:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id gJMoMggvXWJSsAAA9RJhRA (envelope-from ) for ; Mon, 18 Apr 2022 11:27:36 +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 65806DB24 for ; Mon, 18 Apr 2022 11:27:36 +0200 (CEST) Received: from localhost ([::1]:53266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngNfT-0001Fa-6n for larch@yhetil.org; Mon, 18 Apr 2022 05:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngNNW-0005d7-LQ for guix-patches@gnu.org; Mon, 18 Apr 2022 05:09:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ngNNW-0003V7-9x for guix-patches@gnu.org; Mon, 18 Apr 2022 05:09:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ngNNW-0003Ek-4i for guix-patches@gnu.org; Mon, 18 Apr 2022 05:09:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54997] [PATCH 09/12] services: ipfs: Use 'least-authority-wrapper'. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 18 Apr 2022 09:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54997 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 54997@debbugs.gnu.org Received: via spool by 54997-submit@debbugs.gnu.org id=B54997.165027289212386 (code B ref 54997); Mon, 18 Apr 2022 09:09:02 +0000 Received: (at 54997) by debbugs.gnu.org; 18 Apr 2022 09:08:12 +0000 Received: from localhost ([127.0.0.1]:37955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngNMh-0003Di-U5 for submit@debbugs.gnu.org; Mon, 18 Apr 2022 05:08:12 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:44854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngNMf-0003DS-M7 for 54997@debbugs.gnu.org; Mon, 18 Apr 2022 05:08:10 -0400 Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by albert.telenet-ops.be with bizsmtp id L9872700N4UW6Th06987CP; Mon, 18 Apr 2022 11:08:07 +0200 Message-ID: <4eac7fd571ddafd46bcadfa2ef5c6b3e41a162ab.camel@telenet.be> From: Maxime Devos Date: Mon, 18 Apr 2022 11:08:02 +0200 In-Reply-To: <20220417210453.27884-9-ludo@gnu.org> References: <20220417210453.27884-1-ludo@gnu.org> <20220417210453.27884-9-ludo@gnu.org> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-fdJc32RJnBTAjvBynDkw" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1650272888; bh=Uu6qMmTFWD4NT/PmY8CQdTMPIHsBrQL7ewShocJXefU=; h=Subject:From:To:Date:In-Reply-To:References; b=NVGGr9XsMAI+P/GKDyGmTbnQCqyvzyTnDvzOiRkXGMldqABdHEdF/tIb+9tdMCA86 KYgqXSRWFjCrlqUgG9gtv5rggtYZJgdp7miCCX5yl2Xpp7YrjOyzO53UTEfPMKl/Mj KJyhj940LX6fsHbv6JZ1DL3TSmBfUv1cKc8q+9VH7nZryjQC4YWKJ1COA2GDyAsJWM /dBupYrY88SgY1/HziW6UCxw6P3fpp9QAHRL7hqDRvDtpQe7J2vCqCUJ0pAWt29sw/ YDaFbztb0rh89I6fJ5UhjGRz5vKwH71Lz+AEg7jhoUy+Z6BP54VkuMdC/JQ1U8HorV Xbgj12sakWs9A== 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650274056; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=Uu6qMmTFWD4NT/PmY8CQdTMPIHsBrQL7ewShocJXefU=; b=UL4675DmZ19RJKV8diKC4zRq9W9cN/9VG/+r4KQzbqAd1HcqwQ4/ZzOy1jTfePUGxAeoQI VCVJc9j9yHdLt5h0HAnRG1YB0tn7YLk0pG4nwRtu4Oqi2J+BFF61YzO5B5eDQs2RnAiC94 JoP/kVBPW3pRd6fuAQBWq4aBi1iHPJBVqIZ8qQdV75HckOoF3hlXVVIo4afohDnBla6VI3 0+LeQylewckhElitRXM9G4z7yNpwfvnQ+xmOEfjEX+V+Bj29QCvsr2jFAYGL+4BAZ4IfHy vEOzGFmrVTNhxYwotyyEwJjW7BvZAjN6dndACtTJ5mmfdE4QepzdPZPjFLDNpQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650274056; a=rsa-sha256; cv=none; b=loR6Aj6Lh7VaH/I2li2u+ynqQnNkYwmigyN/JqBl64f0FRemzrveJmgoou7YDKXGk0Edwd d8POsv178AYDaNPNzf3Dlb60gef3K1n/uPn7gKdiOZd+Vlit1Oao65XojTl52w1FQ28vc9 3bx8WSDLcALUa1et04zCJE6AjcVBtIsdhP6GZ3+FfgnpYgpKw7lIOKL/xy/c4w//d9178D 4YWHZU0lkXIGGd32kU7YT0rUojv6saaPIqriWtJQGl2udFrpK1VjW474rSgct/jOzZspWe msPrnXID7pagHfdOZ41rPbpKbs6sjtLIOoUE1GynXcNKAoQ4QwX5k+4v6Bva1Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r22 header.b=NVGGr9Xs; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=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" X-Migadu-Spam-Score: 3.86 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r22 header.b=NVGGr9Xs; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=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" X-Migadu-Queue-Id: 65806DB24 X-Spam-Score: 3.86 X-Migadu-Scanner: scn1.migadu.com X-TUID: 5+ywowAkkd3r --=-fdJc32RJnBTAjvBynDkw Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s schreef op zo 17-04-2022 om 23:04 [+0200]: > [...] > =C2=A0 > =C2=A0(define (ipfs-binary config) > -=C2=A0 (file-append (ipfs-configuration-package config) "/bin/ipfs")) > +=C2=A0 (define command > +=C2=A0=C2=A0=C2=A0 (file-append (ipfs-configuration-package config) "/bi= n/ipfs")) > + > +=C2=A0 (least-authority-wrapper > +=C2=A0=C2=A0 command > +=C2=A0=C2=A0 #:name "ipfs" > +=C2=A0=C2=A0 #:mappings (list %ipfs-home-mapping) > +=C2=A0=C2=A0 #:namespaces (delq 'net %namespaces))) To simplify things later, could #:user "ipfs" and #:group "ipfs" be added to the least-authority wrapper (and implemented in the 'least- authority procedre)? Then ... > + (define (exec-command . args) > + ;; Exec the given ifps command with the right authority. > + #~(let ((pid (primitive-fork))) > + (if (zero? pid) > + (dynamic-wind > + (const #t) > + (lambda () > + ;; Run ipfs init and ipfs config from a container, > + ;; in case the IPFS daemon was compromised at some point > + ;; and ~/.ipfs is now a symlink to somewhere outside > + ;; %ipfs-home. > + (let ((pw (getpwnam "ipfs"))) > + (setgroups '#()) > + (setgid (passwd:gid pw)) > + (setuid (passwd:uid pw)) > + (environ #$%ipfs-environment) > + (execl #$(ipfs-binary config) #$@args))) > + (lambda () > + (primitive-exit 127))) > + (waitpid pid)))) would become simpler as it wouldn't need to fork, exec, waitpid and dynamic-wind. Alternatively, if associating a user and group with a pola wrapper is problematic (*), what do you think of defining a 'system*/with-capabilities' or 'invoke/with-capabilities' in a central location? Greetings, Maxime. --=-fdJc32RJnBTAjvBynDkw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYl0qchccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gqKAP9bcMlihKJ4zbJ6MMt090nH9tQD AWoJHwOrti+8q7jsZQEAhHs2tQxxY2kw28WCL+GuTCgcae+z5aI0xbbe/RrpAw8= =bdj/ -----END PGP SIGNATURE----- --=-fdJc32RJnBTAjvBynDkw--