From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 EDa+FJl9UGIHHgAAgWs5BA (envelope-from ) for ; Fri, 08 Apr 2022 20:23:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id eP97EZl9UGJlLAEAauVa8A (envelope-from ) for ; Fri, 08 Apr 2022 20:23:21 +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 D8F443C1C1 for ; Fri, 8 Apr 2022 20:23:20 +0200 (CEST) Received: from localhost ([::1]:33296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nctGS-00074P-0g for larch@yhetil.org; Fri, 08 Apr 2022 14:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nctGB-00070Q-4q for guix-patches@gnu.org; Fri, 08 Apr 2022 14:23:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nctGA-0001i3-Sy for guix-patches@gnu.org; Fri, 08 Apr 2022 14:23:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nctGA-0003aa-Pt for guix-patches@gnu.org; Fri, 08 Apr 2022 14:23:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54561] v2 [PATCH 1/5] services: Add samba service. Resent-From: Simon Streit Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 08 Apr 2022 18:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54561 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54561@debbugs.gnu.org Cc: Simon Streit Received: via spool by 54561-submit@debbugs.gnu.org id=B54561.164944213813674 (code B ref 54561); Fri, 08 Apr 2022 18:23:02 +0000 Received: (at 54561) by debbugs.gnu.org; 8 Apr 2022 18:22:18 +0000 Received: from localhost ([127.0.0.1]:35900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nctFR-0003YS-SH for submit@debbugs.gnu.org; Fri, 08 Apr 2022 14:22:18 -0400 Received: from smtprelay05.ispgateway.de ([80.67.31.93]:19591) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nctFP-0003Y6-0N for 54561@debbugs.gnu.org; Fri, 08 Apr 2022 14:22:15 -0400 Received: from [212.202.170.33] (helo=milk.d22.home.arpa) by smtprelay05.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nctFj-0007s3-E5; Fri, 08 Apr 2022 20:22:35 +0200 From: Simon Streit Date: Fri, 8 Apr 2022 20:21:27 +0200 Message-Id: <20220408182131.10271-2-simon@netpanic.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220408182131.10271-1-simon@netpanic.org> References: <02c2e04f0ef7404aab26e2c590cf3cd44634c74d.camel@telenet.be> <20220408182131.10271-1-simon@netpanic.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Df-Sender: c2ltb25AbmV0cGFuaWMub3Jn 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=1649442200; 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; bh=xYd1ZRmV19p8byVtCYud1I0QQrmHh4FokjdlqADqaHA=; b=Ghwo+u8JgBwwdoXudCoQw/pHzN0t6c06OLjek3d0t1ba2Oaxr9IjE6s/FEQlclv9t+e58l D/hjoDDrnWUVaF4KVEAuvLZes7C3hyc/4xP/eMDUwqtWQypoT94tB1141YTWIivmxsGPeg appHfBYP7j3SEcbsDqlB5gix47RcesY+33GQd24XH15c0opWXqeYziNRcHKDE7Mltkne7Q oVxZiyUSzhAH1YC+iMlJtiJbonfF238Nk1buS8H96/UnhLMEJInFoktKwu97uiGb/EEDDz sDdC4q/SHFRdU2mguKh+LbbO348fa1/1n8DfiPF8H+CQvdVpNb3d6Ylqy7fEqg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649442200; a=rsa-sha256; cv=none; b=TORreKX1I2sqLluFl7Bmuov9zUSSyqHSIYmepT/0UZyIQ0Ux12gDg0S7j8fvDshngIIXd0 KwHwGNsIW5hykbheZGSniAaNcRCyZs81Sl52Rpi3w4OXwwWQYIe9+NxGpdb9gOJsm49Fqa tk6uxBc+XhRRAhmimHfzxdZi9MZ9MY4U4dEXw9nCQOiakrNtQyUQ1aoyqqeLFhWW+Qq5ov PzXUkB6qrYZ6R8EGW7z3vb4JkYJRtiBGk9mLyGwKvb7CYItZCzF+GpBZq9gAfk4ZEMccMN mij1Mb6tGed4iXO5eQGcWxPlpsE+JNWde8TOcQL1IjikuH6Aa6+gtMR5+/c6YA== 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" X-Migadu-Spam-Score: -0.57 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-Migadu-Queue-Id: D8F443C1C1 X-Spam-Score: -0.57 X-Migadu-Scanner: scn1.migadu.com X-TUID: xUAakchAcqpS * gnu/services/samba.scm (): New record. (samba-service-type): New variable. (samba-shepherd-services): New Procedure. --- gnu/services/samba.scm | 177 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 gnu/services/samba.scm diff --git a/gnu/services/samba.scm b/gnu/services/samba.scm new file mode 100644 index 0000000000..70b07f93fb --- /dev/null +++ b/gnu/services/samba.scm @@ -0,0 +1,177 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 Simon Streit +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu services samba) + + #:use-module (gnu packages) + #:use-module (gnu packages base) + #:use-module (gnu packages admin) + #:use-module (gnu packages samba) + + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (gnu services shepherd) + #:use-module (gnu services base) + #:use-module (gnu system shadow) + + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (guix modules) + #:use-module (guix records) + + #:use-module (ice-9 format) + #:use-module (ice-9 match) + #:use-module (ice-9 textual-ports) + #:use-module (srfi srfi-1) + + #:export (samba-service-type + samba-configuration + samba-smb-conf + + wsdd-service-type + wsdd-configuration)) + +(define %smb-conf + (plain-file "smb.conf" "[global] + workgroup = WORKGROUP + server string = Samba Server + server role = standalone server + log file = /var/log/samba/log.%m + logging = file +")) + +(define-record-type* + samba-configuration + make-samba-configuration + samba-configuration? + (package samba-configuration-package + (default samba)) + (config-file samba-configuration-config-file + (default #f)) + (enable-samba? samba-configuration-enable-samba? + (default #f)) + (enable-smbd? samba-configuration-enable-smbd? + (default #t)) + (enable-nmbd? samba-configuration-enable-nmbd? + (default #t)) + (enable-winbindd? samba-configuration-enable-winbindd? + (default #t))) + +(define (samba-activation config) + (let ((package (samba-configuration-package config)) + (config-file (samba-configuration-config-file config))) + (with-imported-modules '((guix build utils)) + (let ((lib-dir "/var/lib/samba") + (log-dir "/var/log/samba") + (run-dir "/var/run/samba") + (etc-dir "/etc/samba") + (smb.conf "/etc/samba/smb.conf")) + #~(begin + (use-modules (guix build utils)) + (mkdir-p #$etc-dir) + (mkdir-p #$lib-dir) + (mkdir-p/perms (string-append #$lib-dir "/private") + (getpwnam "root") #o700) + (mkdir-p #$log-dir) + (mkdir-p #$run-dir) + (copy-file #$config-file #$smb.conf) + (invoke #$(file-append package "/bin/testparm") + "--suppress-prompt" #$smb.conf)))))) + +(define (samba-samba-shepherd-service config) + (let ((package (samba-configuration-package config)) + (config-file (samba-configuration-config-file config))) + (list (shepherd-service + (documentation "Run Samba") + (provision '(samba-samba)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/sbin/samba") + (string-append "--configfile=" #$config-file) + "--foreground" + "--no-process-group"))) + (stop #~(make-kill-destructor)))))) + +(define (samba-nmbd-shepherd-service config) + (let ((package (samba-configuration-package config)) + (config-file (samba-configuration-config-file config))) + (list (shepherd-service + (documentation "Run NMBD") + (provision '(samba-nmbd)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/sbin/nmbd") + (string-append "--configfile=" #$config-file) + "--foreground" + "--no-process-group"))) + (stop #~(make-kill-destructor)))))) + +(define (samba-smbd-shepherd-service config) + (let ((package (samba-configuration-package config)) + (config-file (samba-configuration-config-file config))) + (list (shepherd-service + (documentation "Run SMBD") + (provision '(samba-smbd)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/sbin/smbd") + (string-append "--configfile=" #$config-file) + "--foreground" + "--no-process-group"))) + (stop #~(make-kill-destructor)))))) + +(define (samba-winbindd-shepherd-service config) + (let ((package (samba-configuration-package config)) + (config-file (samba-configuration-config-file config))) + (list (shepherd-service + (documentation "Run Winnbindd for Name Service Switch") + (provision '(samba-winbindd)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/sbin/winbindd") + (string-append "--configfile=" #$config-file) + "--foreground" + "--no-process-group"))) + (stop #~(make-kill-destructor)))))) + +(define (samba-shepherd-services config) + (append (if (samba-configuration-enable-samba? config) + (samba-samba-shepherd-service config) + '()) + (if (samba-configuration-enable-nmbd? config) + (samba-nmbd-shepherd-service config) + '()) + (if (samba-configuration-enable-smbd? config) + (samba-smbd-shepherd-service config) + '()) + (if (samba-configuration-enable-winbindd? config) + (samba-winbindd-shepherd-service config) + '()))) + +(define samba-service-type + (service-type + (name 'samba) + (description "Samba") + (extensions + (list (service-extension shepherd-root-service-type + samba-shepherd-services) + (service-extension activation-service-type + samba-activation) + (service-extension profile-service-type + (compose list samba-configuration-package)))) + (default-value (samba-configuration)))) -- 2.34.0