From patchwork Fri Jan 3 17:35:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Wurmus X-Patchwork-Id: 19563 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 13398179EB; Fri, 3 Jan 2020 17:36:48 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id CA0F117979 for ; Fri, 3 Jan 2020 17:36:47 +0000 (GMT) Received: from localhost ([::1]:55256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inQsR-0007qb-6a for patchwork@mira.cbaines.net; Fri, 03 Jan 2020 12:36:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37539) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inQrm-00078T-CD for guix-patches@gnu.org; Fri, 03 Jan 2020 12:36:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1inQrk-0003HE-Tk for guix-patches@gnu.org; Fri, 03 Jan 2020 12:36:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1inQrk-0003G5-O4 for guix-patches@gnu.org; Fri, 03 Jan 2020 12:36:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1inQrk-0008HB-LM for guix-patches@gnu.org; Fri, 03 Jan 2020 12:36:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38902] [PATCH 6/9] services: nfs: Allow idmap-service-type to be extended. Resent-From: Ricardo Wurmus Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 03 Jan 2020 17:36:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38902 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38902@debbugs.gnu.org Cc: Ricardo Wurmus Received: via spool by 38902-submit@debbugs.gnu.org id=B38902.157807294231709 (code B ref 38902); Fri, 03 Jan 2020 17:36:04 +0000 Received: (at 38902) by debbugs.gnu.org; 3 Jan 2020 17:35:42 +0000 Received: from localhost ([127.0.0.1]:41399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inQrO-0008FN-4R for submit@debbugs.gnu.org; Fri, 03 Jan 2020 12:35:42 -0500 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21163) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inQrL-0008FF-V8 for 38902@debbugs.gnu.org; Fri, 03 Jan 2020 12:35:40 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1578072937; cv=none; d=zohomail.com; s=zohoarc; b=Ugz3nU//QFD5PrwooEk8JEx9GvnfVx2rg3/M7Y/CkGW3UQzPm93xrLkN8CXvYJ6U9gWtCs67pw9akv15RzPKZtLC4X0NyuxAIKMM2cyDM8KIHJe6GnK9Hc0cSR7zkZmS8PP5ORWZzb/GB//KQG2n0I4YJ7GpXMUqPqtcaq3zCNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578072937; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=/6Dm6p95FEyshdRfln2/V+9DsqWH8/rSf9pTcR+PF18=; b=FlGkexcukYHG4hDAKbGdq5HE7PcaL1l5Jq9/Zg7zMDrvbRYAYm5BQUekznFKaREqIQpwAzYU4SwhjBGcSsj76hoIZHwBePCdqYIfwxCkrrKfcMz/nMLpue4BoB6lLDPm62hPCkf8mb7NHecSRgSTUyygD39Fs5OXqZgh3l0UN6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1578072937; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=/6Dm6p95FEyshdRfln2/V+9DsqWH8/rSf9pTcR+PF18=; b=QOXrgahQWb6FnkoMX57LoLhaw7F5FqG/wS2JH0ICVb5mBJl0auESjYQ2/vJojb4k lzXuoKN1QuvbB0vcDXgQj3cRi84Bl8Pp+EY6ZnJGmZdVVaQtjTw2xJWy6vzhouaB80R 17Dx3DY/kEglvGYNVEltaj2NebDje79bHskuqSHg= Received: from localhost (p54AD4FBF.dip0.t-ipconnect.de [84.173.79.191]) by mx.zohomail.com with SMTPS id 1578072935167765.4979943978356; Fri, 3 Jan 2020 09:35:35 -0800 (PST) From: Ricardo Wurmus Message-ID: <20200103173506.9779-6-rekado@elephly.net> Date: Fri, 3 Jan 2020 18:35:03 +0100 X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200103173506.9779-1-rekado@elephly.net> References: <20200103173506.9779-1-rekado@elephly.net> MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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/nfs.scm (idmap-service-type): Rewrite using SERVICE-TYPE to add ability to extend the service. --- gnu/services/nfs.scm | 67 ++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/gnu/services/nfs.scm b/gnu/services/nfs.scm index 451020be31..9fb95bde7e 100644 --- a/gnu/services/nfs.scm +++ b/gnu/services/nfs.scm @@ -170,37 +170,48 @@ (default nfs-utils))) (define idmap-service-type - (shepherd-service-type - 'idmap - (lambda (config) - - (define nfs-utils - (idmap-configuration-nfs-utils config)) + (let ((proc + (lambda (config) - (define pipefs-directory - (idmap-configuration-pipefs-directory config)) + (define nfs-utils + (idmap-configuration-nfs-utils config)) - (define domain (idmap-configuration-domain config)) + (define pipefs-directory + (idmap-configuration-pipefs-directory config)) - (define (idmap-config-file config) - (plain-file "idmapd.conf" - (string-append - "\n[General]\n" - (if domain - (format #f "Domain = ~a\n" domain)) - "\n[Mapping]\n" - "Nobody-User = nobody\n" - "Nobody-Group = nogroup\n"))) + (define domain (idmap-configuration-domain config)) - (define idmap-command - #~(list (string-append #$nfs-utils "/sbin/rpc.idmapd") "-f" - "-p" #$pipefs-directory - "-c" #$(idmap-config-file config))) + (define (idmap-config-file config) + (plain-file "idmapd.conf" + (string-append + "\n[General]\n" + (if domain + (format #f "Domain = ~a\n" domain) + "") + "\n[Mapping]\n" + "Nobody-User = nobody\n" + "Nobody-Group = nogroup\n"))) - (shepherd-service - (documentation "Start the RPC IDMAP daemon.") - (requirement '(rpcbind-daemon rpc-pipefs)) - (provision '(idmap-daemon)) - (start #~(make-forkexec-constructor #$idmap-command)) - (stop #~(make-kill-destructor)))))) + (define idmap-command + #~(list (string-append #$nfs-utils "/sbin/rpc.idmapd") "-f" + "-p" #$pipefs-directory + ;; TODO: this is deprecated + "-c" #$(idmap-config-file config))) + (shepherd-service + (documentation "Start the RPC IDMAP daemon.") + (requirement '(rpcbind-daemon rpc-pipefs)) + (provision '(idmap-daemon)) + (start #~(make-forkexec-constructor #$idmap-command)) + (stop #~(make-kill-destructor)))))) + (service-type + (name 'idmap) + (extensions + (list (service-extension shepherd-root-service-type + (compose list proc)))) + ;; We use the extensions feature to allow other services to automatically + ;; configure and start this service. Only one value can be provided. We + ;; override it with the value returned by the extending service. + (compose identity) + (extend (lambda (config values) (first values))) + (default-value (idmap-configuration)))))