From patchwork Fri Jun 16 20:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 50991 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 5084327BBEA; Fri, 16 Jun 2023 21:26:23 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 8C6F227BBE2 for ; Fri, 16 Jun 2023 21:26:20 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qAG1E-0001gc-Mp; Fri, 16 Jun 2023 16:26:04 -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 1qAG1D-0001gF-6Q for guix-patches@gnu.org; Fri, 16 Jun 2023 16:26:03 -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 1qAG1C-0002I0-2C; Fri, 16 Jun 2023 16:26:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qAG1B-0003ow-QK; Fri, 16 Jun 2023 16:26:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64119] [PATCH] services: shepherd: Sanitize 'provision' field. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, attila@lendvai.name, guix-patches@gnu.org Resent-Date: Fri, 16 Jun 2023 20:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64119 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64119@debbugs.gnu.org Cc: Bruno Victal , ludo@gnu.org, attila@lendvai.name X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ludo@gnu.org, attila@lendvai.name Received: via spool by submit@debbugs.gnu.org id=B.168694715714674 (code B ref -1); Fri, 16 Jun 2023 20:26:01 +0000 Received: (at submit) by debbugs.gnu.org; 16 Jun 2023 20:25:57 +0000 Received: from localhost ([127.0.0.1]:50445 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAG16-0003oc-PF for submit@debbugs.gnu.org; Fri, 16 Jun 2023 16:25:57 -0400 Received: from lists.gnu.org ([209.51.188.17]:60874) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAG14-0003oU-QT for submit@debbugs.gnu.org; Fri, 16 Jun 2023 16:25:55 -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 1qAG14-0001fE-Il for guix-patches@gnu.org; Fri, 16 Jun 2023 16:25:54 -0400 Received: from smtpmciv5.myservices.hosting ([185.26.107.241]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAG12-0002Do-D7 for guix-patches@gnu.org; Fri, 16 Jun 2023 16:25:54 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv5.myservices.hosting (Postfix) with ESMTP id 7B9CE20DAD for ; Fri, 16 Jun 2023 22:25:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id CAABE8009E; Fri, 16 Jun 2023 22:25:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ovOEIYKzWLKU; Fri, 16 Jun 2023 22:25:35 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 155CF8009D; Fri, 16 Jun 2023 22:25:35 +0200 (CEST) From: Bruno Victal Date: Fri, 16 Jun 2023 21:25:24 +0100 Message-Id: <9770a88a008fd1d087e829a6ad57b556346be9c0.1686947093.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=185.26.107.241; envelope-from=mirai@makinata.eu; helo=smtpmciv5.myservices.hosting X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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 Fixes . * gnu/services/shepherd.scm ()[provision]: Set field sanitizer. (sanitize-shepherd-service-provision): New procedure. --- gnu/services/shepherd.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) base-commit: 31336e9f5d68512a9c1c6826bce9f17c892a2125 diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index de40454f7d..1333067817 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2018 Carlo Zancanaro ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +22,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu services shepherd) + #:use-module (guix diagnostics) #:use-module (guix ui) #:use-module (guix sets) #:use-module (guix gexp) @@ -186,12 +188,21 @@ (define %default-modules ((guix build utils) #:hide (delete)) (guix build syscalls))) +(define (sanitize-shepherd-service-provision expr) + (match expr + (((? symbol?) ..1) expr) + (_ + (raise + (formatted-message + (G_ "'provision' must be a non-empty list of symbols")))))) + (define-record-type* shepherd-service make-shepherd-service shepherd-service? (documentation shepherd-service-documentation ;string (default "[No documentation.]")) - (provision shepherd-service-provision) ;list of symbols + (provision shepherd-service-provision ;list of symbols + (sanitize sanitize-shepherd-service-provision)) (requirement shepherd-service-requirement ;list of symbols (default '())) (one-shot? shepherd-service-one-shot? ;Boolean