From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8OrACeBAx2NA9gAAbAwnHQ (envelope-from ) for ; Wed, 18 Jan 2023 01:44:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id UEKbCeBAx2O+FQEAauVa8A (envelope-from ) for ; Wed, 18 Jan 2023 01:44:16 +0100 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 402C1783E for ; Wed, 18 Jan 2023 01:41:36 +0100 (CET) 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 Content-Transfer-Encoding: 8bit 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-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1674002496; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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; bh=AOO5y5VP/mEYtnQ9//ZADBLVu8vpIbU7uUFFOCxG6C4=; b=RiiG9xFeTrbCrki6E/mOFhRfL7OB1iarW2H9GiytqYCHVaMvHO9HHtpGBPFBWfziOyfBLb im38d0MeL7XD3Cos+vOIhs/L5ZEckIMjIEpKBq/GfCLdLwx9LqlW+N+dHr5hnBQtOAFVap 2c+BQBiZ1MgbTABnQ+6LJfGTdp98qwP+iZA2gL+ssjI8vflMrbi9J5pPcou0qWmfGTDysh q3TIIAdCMKHi6tD+fn6wztmDhLYVevDQvalbjaJwjwr6MSRSmj9Sm4zl49qZbmRL5AnizL yFAIlJpeffZbm17bd9DgCiUXEO4t7COc7tYHfYfy17GZvmR6sSe/jEE/pFUbIg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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=1674002496; a=rsa-sha256; cv=none; b=MzImCjJZVUhes/aH+JR0+7Q1Yi1b1/nLXT07J7dDGEQyQ58MVKMCHF/5P/DZEGJgZpRONQ Y8sWEBeB8vCnmgqTaokuOE/onGGjyRapIVTRlIYw7rfzFNSKuEfOL3QpDODXdwGN0xzQJZ 7oXK+o8ryIp1GSVoe0FmrQbb2xNUhNDQ+fezjZg8KYOhzbsbCWF41oC2+bxF19Ys4aZlNi fEPmpBKeaPvcToYJzOmNeYRkVphu2vlS2azqEj/3URIszp8D5B87LQUIWV8Ai2Wev3mMfl UnTOmlbWU+kbubx9hBgjejoDD2PpkB7PUwXnT0WAH98B6XS4vzbLf+EUBId2mg== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -1.63 X-Spam-Score: -1.63 X-Migadu-Queue-Id: 402C1783E Authentication-Results: aspmx1.migadu.com; dkim=none; 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" X-TUID: cYq5S7evGjA9 * 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) -- 2.38.1