From patchwork Wed Apr 27 16:56:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 38938 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 B9B8827BBE9; Wed, 27 Apr 2022 17:59:04 +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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 0597127BBEA for ; Wed, 27 Apr 2022 17:59:04 +0100 (BST) Received: from localhost ([::1]:57120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njl0J-0005pX-5C for patchwork@mira.cbaines.net; Wed, 27 Apr 2022 12:59:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njkzP-0004Y6-GF for guix-patches@gnu.org; Wed, 27 Apr 2022 12:58:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njkzP-0005D9-6Z for guix-patches@gnu.org; Wed, 27 Apr 2022 12:58:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1njkzP-0003ua-5u for guix-patches@gnu.org; Wed, 27 Apr 2022 12:58:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54997] [PATCH v2 09/15] services: bitlbee: Use 'make-inetd-constructor'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Apr 2022 16:58:07 +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: 54997@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 54997-submit@debbugs.gnu.org id=B54997.165107864814861 (code B ref 54997); Wed, 27 Apr 2022 16:58:07 +0000 Received: (at 54997) by debbugs.gnu.org; 27 Apr 2022 16:57:28 +0000 Received: from localhost ([127.0.0.1]:44151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njkym-0003rX-68 for submit@debbugs.gnu.org; Wed, 27 Apr 2022 12:57:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njkyM-0003oH-A0 for 54997@debbugs.gnu.org; Wed, 27 Apr 2022 12:57:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njkyE-00053V-9X; Wed, 27 Apr 2022 12:56:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=hqz/X8pTaIpKmynCFVw6ehRqbeudnNNz6KcSmFlF8kU=; b=rcDgwWx/SLkrWvN4vyPR iLMXD3heLe3Fv5VouzjEltDIWB4WMopZkDb2l0eVY52KPqxyEWoOI7Mj3XabhQPBfhkvn5JQmVTuq KmXBVnL/YjgHMlpnelfRx7+kNCg/97nXY4vqttxa4vZS0TDDJzL0+IdoY60GbkuJ1RTqe004yC/cE DMIqTFPT+Zy4A+6gYcmBT19IZc5HjIO7bVa/I2xMMioFkH/CpolFwLK3MrWCIoAita81zfu7V85jf kmFxrtdRu0ZoMVxpHO0lVHOd54YxmE7sJA7x5X5wS1rkv3qQmOQB3sDt/WVIihJ0ZwNqIrkOvEPHV RdPqDZ52x3Ustw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:64439 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njkyD-0000Hl-U3; Wed, 27 Apr 2022 12:56:54 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Apr 2022 18:56:29 +0200 Message-Id: <20220427165635.8015-10-ludo@gnu.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427165635.8015-1-ludo@gnu.org> References: <878rrrk1v1.fsf_-_@gnu.org> <20220427165635.8015-1-ludo@gnu.org> 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" X-getmail-retrieved-from-mailbox: Patches * gnu/services/messaging.scm (bitlbee-shepherd-service): Add call to 'least-authority-wrapper'. In 'start' method, use 'make-inetd-constructor' when available. * gnu/tests/messaging.scm (run-bitlbee-test)["valid PID"]: Remove test. --- gnu/services/messaging.scm | 63 ++++++++++++++++++++++++++++---------- gnu/tests/messaging.scm | 21 +------------ 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm index 4bceb1d37a..7fdd8cf285 100644 --- a/gnu/services/messaging.scm +++ b/gnu/services/messaging.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018 Clément Lassieur ;;; Copyright © 2017 Mathieu Othacehe -;;; Copyright © 2015, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2015, 2017-2020, 2022 Ludovic Courtès ;;; Copyright © 2018 Pierre-Antoine Rouby ;;; ;;; This file is part of GNU Guix. @@ -28,11 +28,14 @@ (define-module (gnu services messaging) #:use-module (gnu services shepherd) #:use-module (gnu services configuration) #:use-module (gnu system shadow) + #:autoload (gnu build linux-container) (%namespaces) + #:use-module ((gnu system file-systems) #:select (file-system-mapping)) #:use-module (guix gexp) #:use-module (guix modules) #:use-module (guix records) #:use-module (guix packages) #:use-module (guix deprecation) + #:use-module (guix least-authority) #:use-module (srfi srfi-1) #:use-module (srfi srfi-35) #:use-module (ice-9 match) @@ -821,7 +824,18 @@ (define bitlbee-shepherd-service DaemonInterface = " interface " DaemonPort = " (number->string port) " PluginDir = " plugins "/lib/bitlbee -" extra-settings))) +" extra-settings)) + (bitlbee* (least-authority-wrapper + (file-append bitlbee "/sbin/bitlbee") + #:name "bitlbee" + #:mappings (list (file-system-mapping + (source "/var/lib/bitlbee") + (target source) + (writable? #t)) + (file-system-mapping + (source conf) + (target conf))) + #:namespaces (delq 'net %namespaces)))) (with-imported-modules (source-module-closure '((gnu build shepherd) @@ -836,20 +850,37 @@ (define bitlbee-shepherd-service (modules '((gnu build shepherd) (gnu system file-systems))) - (start #~(make-forkexec-constructor/container - (list #$(file-append bitlbee "/sbin/bitlbee") - "-n" "-F" "-u" "bitlbee" "-c" #$conf) - - ;; Allow 'bitlbee-purple' to use libpurple plugins. - #:environment-variables - (list (string-append "PURPLE_PLUGIN_PATH=" - #$plugins "/lib/purple-2")) - - #:pid-file "/var/run/bitlbee.pid" - #:mappings (list (file-system-mapping - (source "/var/lib/bitlbee") - (target source) - (writable? #t))))) + (start #~(if (defined? 'make-inetd-constructor) + + (make-inetd-constructor + (list #$bitlbee* "-I" + "-u" "bitlbee" "-c" #$conf) + (addrinfo:addr + (car (getaddrinfo #$interface + #$(number->string port) + (logior AI_NUMERICHOST + AI_NUMERICSERV)))) + #:service-name-stem "bitlbee" + + ;; Allow 'bitlbee-purple' to use libpurple plugins. + #:environment-variables + (list (string-append "PURPLE_PLUGIN_PATH=" + #$plugins "/lib/purple-2"))) + + (make-forkexec-constructor/container + (list #$(file-append bitlbee "/sbin/bitlbee") + "-n" "-F" "-u" "bitlbee" "-c" #$conf) + + ;; Allow 'bitlbee-purple' to use libpurple plugins. + #:environment-variables + (list (string-append "PURPLE_PLUGIN_PATH=" + #$plugins "/lib/purple-2")) + + #:pid-file "/var/run/bitlbee.pid" + #:mappings (list (file-system-mapping + (source "/var/lib/bitlbee") + (target source) + (writable? #t)))))) (stop #~(make-kill-destructor))))))))) (define %bitlbee-accounts diff --git a/gnu/tests/messaging.scm b/gnu/tests/messaging.scm index 202a1c2f73..1e26c0ddea 100644 --- a/gnu/tests/messaging.scm +++ b/gnu/tests/messaging.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018 Clément Lassieur -;;; Copyright © 2017, 2018, 2021 Ludovic Courtès +;;; Copyright © 2017-2018, 2021-2022 Ludovic Courtès ;;; Copyright © 2018 Efraim Flashner ;;; ;;; This file is part of GNU Guix. @@ -198,25 +198,6 @@ (define marionette (start-service 'bitlbee)) marionette)) - (test-equal "valid PID" - #$(file-append bitlbee "/sbin/bitlbee") - (marionette-eval - '(begin - (use-modules (srfi srfi-1) - (gnu services herd)) - - (let ((bitlbee - (find (lambda (service) - (equal? '(bitlbee) - (live-service-provision service))) - (current-services)))) - (and (pk 'bitlbee-service bitlbee) - (let ((pid (live-service-running bitlbee))) - (readlink (string-append "/proc/" - (number->string pid) - "/exe")))))) - marionette)) - (test-assert "connect" (let* ((address (make-socket-address AF_INET INADDR_LOOPBACK 6667))