From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KOE9NuAcWmPmPAAAbAwnHQ (envelope-from ) for ; Thu, 27 Oct 2022 07:53:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QF9YNeAcWmNmjwAAG6o9tA (envelope-from ) for ; Thu, 27 Oct 2022 07:53: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 AE880CA6B for ; Thu, 27 Oct 2022 07:53:36 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onvpF-0007KL-HH; Thu, 27 Oct 2022 01:53:09 -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 1onvpA-0007BG-9v for guix-patches@gnu.org; Thu, 27 Oct 2022 01:53:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onvp9-0004W8-Ow for guix-patches@gnu.org; Thu, 27 Oct 2022 01:53:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1onvp8-0005ZR-HT for guix-patches@gnu.org; Thu, 27 Oct 2022 01:53:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 05:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57031 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: zimon.toutoune@gmail.com, 57031@debbugs.gnu.org X-Debbugs-Original-To: "zimoun" , "( via Guix-patches via" , <57031@debbugs.gnu.org> Received: via spool by 57031-submit@debbugs.gnu.org id=B57031.166684996221364 (code B ref 57031); Thu, 27 Oct 2022 05:53:02 +0000 Received: (at 57031) by debbugs.gnu.org; 27 Oct 2022 05:52:42 +0000 Received: from localhost ([127.0.0.1]:55931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1onvoo-0005YW-Ak for submit@debbugs.gnu.org; Thu, 27 Oct 2022 01:52:42 -0400 Received: from knopi.disroot.org ([178.21.23.139]:37408) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1onvol-0005YN-Py for 57031@debbugs.gnu.org; Thu, 27 Oct 2022 01:52:41 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 64C684E735; Thu, 27 Oct 2022 07:52:38 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OMjDqZlUFB0a; Thu, 27 Oct 2022 07:52:37 +0200 (CEST) Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1666849957; bh=3rAD1/KyJ69qz8QIvl9pzAPsYF/pcTUPIW0AT/nbCDw=; h=Date:Subject:From:To:References:In-Reply-To; b=b+/qMCfrgHsTEPbebTZLaWcYr8dYIeLKdEJBl3VEY5yxb50ETruPwu18zwZHj6xWP yKX5aG/3r8BaY6Tt7bITWOzgCffgg5FmujVEhKjntEhIfKb6uBroQ5OM7NrlGp1Fun XvLGZdEu/nfYBUXeC/T0hvatpCHpq/0b89EeTcfU8yzQZ5qRmv/9CfZ9kjTTaACQVm bM816vbSVTm+Mo/+t5/ZbHgDZGxmcHB2L/GSDD91qr6AsrcIgEoAhaCi9EisUVm5uj zs2qT3Qh67HK5obmGoaMgwDtpbn7DjR0gAL/Mcalr0u0AGMk6Ytkr382OOvhW2Zgvv MbWh/LnIgOh9A== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 27 Oct 2022 06:52:36 +0100 Message-Id: References: <20220911195941.8442-1-paren@disroot.org> <20220911195941.8442-2-paren@disroot.org> <86lep2jvty.fsf@gmail.com> In-Reply-To: <86lep2jvty.fsf@gmail.com> 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: , Sender: "Guix-patches" Reply-to: "\(" X-ACL-Warn: , "\( via Guix-patches" From: "\( via Guix-patches" via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666850016; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: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=rm3rGLkz/4uWTHu6aghw1f7fsph37T+Mp9U8cr7NmbQ=; b=t/bRtGCm3FywTOz+A7/GcfDXAmMfOGGAEh+7/EPtbl5VSCbpzKHGPfCdfY030lpxIalyNg AEphYk1ITmMZjQvGXv05TwC0cTFfBMQQ5n7jMYPQ7HSopbozVxp2AdelSbtmkzGZG85vRK 9Lks6agBaKNHGKH77mqA8Gh/KMTvcr7XOM+L/a+RiNLkFf6VIW3XLYtk5eN9iHYzA0IU65 KrjnLp22zBF5u8hvs1sWqcy/igzpXAWGtderqeh19RwuV/tkQA71wATHjhjYb1uCAac8aB Uh8NPm/rCNp4pe0WHBgFFf6ayWvBwqxF1xv+jgNMMB+3qyFJHMjXi4pbB49dXA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666850016; a=rsa-sha256; cv=none; b=CsttV/mA+KcebNCKXdpZdkgEJ6hi64gmcs/X4GW/2XYKUBmsxHSUQJfuger01H6bWYuuxh qJDREnidySkCOSOqCSxDtOF5Ohgim3WxClomOERUpEfzTBNdTG0xp6eh4URHrmK3C65xfF LBaLIx3uGjYMeilgBpOEnCviT6fRQK3AlmySGtCUQJK0uWXVXx4h1i3NPkZRQHQ8/JZ9Yj hpLbs+QaXifgMQD7yg4vvXaUitfOYN4VDkb/OhP65o9FMs/WjJjE/FpwC/b1jbicp5ZRwc 0X64hhXdjdB+E2DrBOTCLgRWaAjKA+6C5hEFcKjbR0JTmWwTvtoaxYG9J3gQKw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b="b+/qMCfr"; dmarc=pass (policy=none) header.from=gnu.org; 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: -0.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b="b+/qMCfr"; dmarc=pass (policy=none) header.from=gnu.org; 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: AE880CA6B X-Spam-Score: -0.92 X-Migadu-Scanner: scn1.migadu.com X-TUID: rcc+fODpsqkb Heya, On Wed Oct 26, 2022 at 7:14 PM BST, zimoun wrote: > > - (guix-package* opts)) > > + (guix-package* opts #:root-hint? #t)) > > [...] > > > - (guix-package* opts)) > > + (guix-package* opts #:root-hint? #t)) > > [...] > > > -(define (guix-package* opts) > > +(define* (guix-package* opts #:key (root-hint? #f)) > > Why this =E2=80=99root-hint?=E2=80=99 argument? Is it useful or can we d= rop it? This allows us to disable root hints for ``guix package'' variants, so eg ``sudo guix show'' will not trigger the root hint. > > + (when (and root-hint? > > + (not (hint-given? 'package-root-hint)) > > + (zero? (getuid))) > > + (record-hint 'package-root-hint) > > + (warning (G_ "this command is user-specific, so running it as ro= ot \ > > +will affect only the 'root' user~%"))) > > [...] > > > + (when (and (not (hint-given? 'pull-root-hint)) > > + (zero? (getuid))) > > + (record-hint 'pull-root-hint) > > + (warning (G_ "this command is user-specific, so running it as ro= ot \ > > +will affect only the 'root' user~%"))) > > It looks pretty similar. Is it possible to avoid the duplication? ...I guess? Maybe we could do something like this?: ;;;; guix/scripts.scm (define (warn-if-root hint-name) (when (and (not (hint-given hint-name)) (zero? (getuid))) (record-hint hint-name) (warning (G_ "this command is user-specific, so running it as root \ > > +will affect only the 'root' user~%")))) ;;;; guix/scripts/package.scm (when root-hint? (warn-if-root 'package-root-hint)) ;;;; guix/scripts/pull.scm (warn-if-root 'pull-root-hint) -- (