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 kItdJ7isPWIzQQAAgWs5BA (envelope-from ) for ; Fri, 25 Mar 2022 12:51:20 +0100 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 oA60JLisPWKTGAAA9RJhRA (envelope-from ) for ; Fri, 25 Mar 2022 12:51:20 +0100 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 1CE7E33C00 for ; Fri, 25 Mar 2022 12:51:20 +0100 (CET) Received: from localhost ([::1]:43740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXiTO-0005zq-R3 for larch@yhetil.org; Fri, 25 Mar 2022 07:51:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXfog-0000yF-2N for guix-patches@gnu.org; Fri, 25 Mar 2022 05:01:13 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXfoc-0000eH-3G for guix-patches@gnu.org; Fri, 25 Mar 2022 05:01:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nXfob-0000dm-OC for guix-patches@gnu.org; Fri, 25 Mar 2022 05:01:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54561] [PATCH 1/4] services: Add samba service. References: In-Reply-To: Resent-From: Simon Streit Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Mar 2022 09:01:01 +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 Received: via spool by 54561-submit@debbugs.gnu.org id=B54561.16481988312418 (code B ref 54561); Fri, 25 Mar 2022 09:01:01 +0000 Received: (at 54561) by debbugs.gnu.org; 25 Mar 2022 09:00:31 +0000 Received: from localhost ([127.0.0.1]:50090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXfo6-0000cv-RO for submit@debbugs.gnu.org; Fri, 25 Mar 2022 05:00:31 -0400 Received: from smtprelay04.ispgateway.de ([80.67.18.16]:40613) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXfo5-0000cn-8r for 54561@debbugs.gnu.org; Fri, 25 Mar 2022 05:00:30 -0400 Received: from [93.195.170.97] (helo=milk) by smtprelay04.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nXfoF-0005RL-F5 for 54561@debbugs.gnu.org; Fri, 25 Mar 2022 10:00:39 +0100 From: Simon Streit Gcc: nnfolder+archive:sent.2022-03 Date: Fri, 25 Mar 2022 10:00:26 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Df-Sender: bGlzdHNAbmV0cGFuaWMub3Jn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Fri, 25 Mar 2022 07:49:33 -0400 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=1648209080; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=U2oCxhM4ILjwYwokdXuHXzPip9/x5OPMu+t/ictIrJ0=; b=eYv+9t77JcKIgiygzL5Wt4df/xCtMk1IedMavDb4S3izVaEE8lZsv3t/q/4CfYBVE1Xr/K y5eSSyo5uDr6AxgWPXkbYSf4/c/h3W8LZZAiHU1ULX39rLGm8URRB61imbpJ4sRxF2D0Xz b+eEVNWxlWE16sTrrjrHQai5MEMCMdjRoEi2FhHTsAcuF4wCN/90cra7WbH212l5b9zA1T xl/RHIMBKp/X6vqCJ73xcD/PojCWGsprbY1EXKH4BuZrYzHEx0/GvH5b6KsTY48c1Nc7jI jPYHE+sOS/z+3f2DCPJTkRltzBw80QdxBd/xtgBpCMNqQ4om2/v5dImH//OcQg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648209080; a=rsa-sha256; cv=none; b=FXIpMSfFKcBBg+dcjcqVE51+q5MKxcORKRaooO+nDY63Cgdhqz0DTI2cFZTj43o/J7AZhn AWw0xMDN69niQ/sHCG8IBudKc68PRPzOxse/3+LeL66p30cs/DsxZwAKnFnGlaGh5NtW5+ /kJgMVziAIt77LRdmCuKJX9Z0M7zH0VM1wopfU/QY8pEKMD+0ZpfLURCQT0+xSFhfnBOzC bR48x65DRZB3SzaeO3mIY0qi+l1wbrNY+G2pEVVAgMxrGVkki57v1nMvq/Xq7s7sVhVZtJ MSF84kV/jF9/o9tG/HD0ws1Ab+M7s/maWf40Xz7LDicYOiloi10zlimNmA8wYQ== 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: -3.09 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: 1CE7E33C00 X-Spam-Score: -3.09 X-Migadu-Scanner: scn1.migadu.com X-TUID: EnrZiHz/V+dZ * gnu/services/samba.scm (): New record. (samba-service-type): New variable. (samba-shepherd-services): New Procedure. --- gnu/services/samba.scm | 173 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 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..ffbf20fdbc --- /dev/null +++ b/gnu/services/samba.scm @@ -0,0 +1,173 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 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 =3D WORKGROUP + server string =3D Samba Server + server role =3D standalone server + log file =3D /var/log/samba/log.%m + logging =3D 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-directory "/var/lib/samba") + (log-directory "/var/log/samba") + (run-directory "/var/run/samba") + (smb.conf "/etc/samba/smb.conf")) + #~(begin + (use-modules (guix build utils)) + + (mkdir-p #$log-directory) + (mkdir-p #$run-directory) + (mkdir-p (string-append #$lib-directory "/private")) + (mkdir-p "/etc/samba") + (copy-file #$config-file #$smb.conf) + (system* (string-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=3D" #$config-fi= le) + "--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=3D" #$config-fi= le) + "--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=3D" #$config-fi= le) + "--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=3D" #$config-fi= le) + "--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))) + (default-value (samba-configuration)))) -- 2.34.0