From patchwork Wed Jan 18 00:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 46241 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 40E5227BBEB; Wed, 18 Jan 2023 00:41:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3694227BBE9 for ; Wed, 18 Jan 2023 00:41:36 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHwVl-0002PP-50; Tue, 17 Jan 2023 19:41:05 -0500 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 1pHwVi-0002Ov-Rm for guix-patches@gnu.org; Tue, 17 Jan 2023 19:41:02 -0500 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 1pHwVi-00065I-Jk for guix-patches@gnu.org; Tue, 17 Jan 2023 19:41:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHwVi-0005rx-9o for guix-patches@gnu.org; Tue, 17 Jan 2023 19:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60788] [PATCH v2] services: vnstat: Use least-authority-wrapper. References: <95b646eb6b23dec213cba43b6e4e7ddc4a601d0f.1673640404.git.mirai@makinata.eu> In-Reply-To: <95b646eb6b23dec213cba43b6e4e7ddc4a601d0f.1673640404.git.mirai@makinata.eu> Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 18 Jan 2023 00:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60788 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60788@debbugs.gnu.org Cc: Bruno Victal , maxim.cournoyer@gmail.com Received: via spool by 60788-submit@debbugs.gnu.org id=B60788.167400241222458 (code B ref 60788); Wed, 18 Jan 2023 00:41:02 +0000 Received: (at 60788) by debbugs.gnu.org; 18 Jan 2023 00:40:12 +0000 Received: from localhost ([127.0.0.1]:38539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHwUu-0005qA-7j for submit@debbugs.gnu.org; Tue, 17 Jan 2023 19:40:12 -0500 Received: from smtpmciv2.myservices.hosting ([185.26.107.238]:57868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHwUr-0005q0-Ho for 60788@debbugs.gnu.org; Tue, 17 Jan 2023 19:40:10 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.172]) by smtpmciv2.myservices.hosting (Postfix) with ESMTP id 0A2BA20358; Wed, 18 Jan 2023 01:40:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id B23CA80096; Wed, 18 Jan 2023 01:40:05 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-1.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vXiSNLV8gA3a; Wed, 18 Jan 2023 01:40:05 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-118-236.dsl.telepac.pt [85.242.118.236]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 3E9BD80093; Wed, 18 Jan 2023 01:40:05 +0100 (CET) From: Bruno Victal Date: Wed, 18 Jan 2023 00:37:11 +0000 Message-Id: X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/monitoring.scm (vnstat-shepherd-service): Use least-authority-wrapper. --- This patch SHOULD NOT be applied, this is a wip patch with least-authority-wrapper and it doesn't seem to work (at least when launched within a VM). I leave it here in case anyone interested wants to dig in further. gnu/services/monitoring.scm | 42 ++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index 78fc49da5c..c9e4f85701 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -29,6 +29,9 @@ (define-module (gnu services monitoring) #:use-module (gnu packages monitoring) #:use-module (gnu packages networking) #:use-module (gnu system shadow) + #:use-module ((gnu system file-systems) #:select (file-system-mapping)) + #:use-module (gnu build linux-container) + #:autoload (guix least-authority) (least-authority-wrapper) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix records) @@ -448,7 +451,7 @@ (define-configuration vnstat-configuration @var{save-interval}..@samp{60}") (pid-file - (maybe-string "/var/run/vnstatd.pid") + (maybe-string "/var/run/vnstatd/vnstatd.pid") "\ Specify pid file path and name to be used.") @@ -558,17 +561,40 @@ (define (vnstat-serialize-configuration config) (serialize-configuration config vnstat-configuration-fields))) (define (vnstat-shepherd-service config) - (let ((config-file (vnstat-serialize-configuration config))) - (match-record config (package pid-file) + (match-record config (package database-dir pid-file use-logging) + (let* ((config-file (vnstat-serialize-configuration config)) + (vnstatd (least-authority-wrapper + (file-append package "/sbin/vnstatd") + #:name "vnstatd" + #:mappings (append (if (eqv? use-logging 2) + (list (file-system-mapping + (source "/dev/log") ; for syslog + (target source))) + '()) + (list (file-system-mapping + (source database-dir) + (target source) + (writable? #t)) + (file-system-mapping + (source (dirname pid-file)) + (target source) + (writable? #t)) + (file-system-mapping + (source config-file) + (target source)))) + #:namespaces (delq 'net %namespaces)))) (shepherd-service (documentation "Run vnstatd.") (requirement `(networking)) (provision '(vnstatd)) - (start #~(make-forkexec-constructor - (list #$(file-append package "/sbin/vnstatd") - "--daemon" - "--config" #$config-file) - #:pid-file #$pid-file)) + (start #~(begin + (mkdir-p #$database-dir) + (mkdir-p (dirname #$pid-file)) + (make-forkexec-constructor + (list #$vnstatd + "--daemon" + "--config" #$config-file) + #:pid-file #$pid-file))) (stop #~(make-kill-destructor)) (actions (list (shepherd-configuration-action config-file)