From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2KHtFfCBXGICPwEAgWs5BA (envelope-from ) for ; Sun, 17 Apr 2022 23:09:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id UJE9E/CBXGLNFQEA9RJhRA (envelope-from ) for ; Sun, 17 Apr 2022 23:09:04 +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 C28761762C for ; Sun, 17 Apr 2022 23:09:03 +0200 (CEST) Received: from localhost ([::1]:43412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngC8k-0001Qg-QX for larch@yhetil.org; Sun, 17 Apr 2022 17:09:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngC5t-0006JC-PO for guix-patches@gnu.org; Sun, 17 Apr 2022 17:06:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ngC5s-0000YP-J7 for guix-patches@gnu.org; Sun, 17 Apr 2022 17:06:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ngC5s-00026V-CM for guix-patches@gnu.org; Sun, 17 Apr 2022 17:06:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54997] [PATCH 07/12] 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: Sun, 17 Apr 2022 21:06:04 +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.16502295577986 (code B ref 54997); Sun, 17 Apr 2022 21:06:04 +0000 Received: (at 54997) by debbugs.gnu.org; 17 Apr 2022 21:05:57 +0000 Received: from localhost ([127.0.0.1]:37426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngC5l-00024d-C4 for submit@debbugs.gnu.org; Sun, 17 Apr 2022 17:05:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39476) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngC5a-00022W-LM for 54997@debbugs.gnu.org; Sun, 17 Apr 2022 17:05:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:58438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngC5V-0000W0-GF; Sun, 17 Apr 2022 17:05:41 -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=oMFApLoR2pG10Qb7FTUu Yg0Y47XCAWtgAJ6T/HcIVLsvax/T94dNCciZd9+5l6HPFeA92+RpmYgaGTe31yS9sH1JRW8+6zTan XakUxrfC18407Kma54YpdyP3aSJTJxZKXmhTFg28eKd6b4Eiazsp+OIf8DmLz8TbbpugD0lhSKd1p zfz4bsKPxwhVGK1tRGWb78KYnI9J8jAZaawtfJc2By73FGyJCfJomVzl3q5OISnl4HuIXRnPyx1aH F5ut0O449ovli8fyY5s7KGI+1TSGNtAZIAFu1+Zmt8bYQeo/Z83RagpeBl05Qga8Uv0fs0JCrjNRy UXDOttZgyVPOvg==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=38870 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 1ngC5V-000268-3t; Sun, 17 Apr 2022 17:05:41 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 17 Apr 2022 23:04:48 +0200 Message-Id: <20220417210453.27884-7-ludo@gnu.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220417210453.27884-1-ludo@gnu.org> References: <20220417210453.27884-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650229743; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=hqz/X8pTaIpKmynCFVw6ehRqbeudnNNz6KcSmFlF8kU=; b=B18sl6/ub8di7+5KHM2+1nnabKJ4IGJUXPtMbgCqTBRa941NFOYcxOyJcgJyyR9VbiqY7/ WO6A0Sw+pEKrW5wbyqFUvYX2rsEvhYphHZ6qFZFA3AmzpOjXi+hTrarpHW07YsxfXhjPvK 4eIwhuw8tjUAv56nuPaLMhanQbJ5u5J92f2Lno1cvWpvxQ9q7MF4rKEv4nrduOBmNoFf+S imKfDb2pzEGi5JfX95tzWGJdJxTEmivtHsNyKKE8cd2X7hB1FaXNPHbRC507qWjDsCZDVR 7WtgGfSnBW4UNo+4nRqqXW6uiKgXeQTuWKqdA14GoaFzbZWNQDFQr5pqSd/DSg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650229743; a=rsa-sha256; cv=none; b=bzCawSlPXIte7uHdtj0Xe/dEXgnYiq+GrfTRS4/0KNr3aLRpjk17ugXM2vlf1yT6Foqre+ 5uYADvihkYajDkhvFmJ1D4qG2t0S7T/eQkbPmz4vIZBVIOLMjT01iOmJDrOEvYaH54Gcn2 Q1K2tZxfyqw2nmgPNA4QZH41M7W9IaTyAdgfDfULA7Kn5dKYHZIZol2b6y0a5eHe+3nYee 94vkHs0lRLCitcHLGqwQl2mR2ZXQXKG5gOk6faa1A0h2pIJ7YrZh8cLJCZ45N7sr/HuIDx inG01LGjY8mQzjMrL72/zTtUm+PAFe/cIR8kLU6TFiZOL4NIjr89mPhrxE6CLg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=oMFApLoR; 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: -1.44 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=oMFApLoR; 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: C28761762C X-Spam-Score: -1.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: U/6jmfjBs/IG * 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)) -- 2.35.1