From patchwork Mon Aug 8 14:56:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Streit X-Patchwork-Id: 41381 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 8EB9527BBEA; Mon, 8 Aug 2022 15:57:55 +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.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS 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 5EDA427BBE9 for ; Mon, 8 Aug 2022 15:57:55 +0100 (BST) Received: from localhost ([::1]:43394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL4CY-0008Tp-J2 for patchwork@mira.cbaines.net; Mon, 08 Aug 2022 10:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL4Bk-0007D3-0K for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oL4Bj-0005I2-Nk for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oL4Bj-0004fu-KL for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54561] [PATCH v3 1/4] gnu: samba: Add avahi to inputs. Resent-From: simon@netpanic.org Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 08 Aug 2022 14:57:03 +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.165997062217951 (code B ref 54561); Mon, 08 Aug 2022 14:57:03 +0000 Received: (at 54561) by debbugs.gnu.org; 8 Aug 2022 14:57:02 +0000 Received: from localhost ([127.0.0.1]:41500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4Bi-0004fP-5t for submit@debbugs.gnu.org; Mon, 08 Aug 2022 10:57:02 -0400 Received: from smtprelay01.ispgateway.de ([80.67.31.35]:1793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4BZ-0004eS-NH for 54561@debbugs.gnu.org; Mon, 08 Aug 2022 10:56:58 -0400 Received: from [79.252.144.136] (helo=motorball.wh6.home.arpa) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1oL4CZ-000256-25; Mon, 08 Aug 2022 16:57:55 +0200 From: simon@netpanic.org Date: Mon, 8 Aug 2022 16:56:40 +0200 Message-Id: <20220808145643.3445-2-simon@netpanic.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808145643.3445-1-simon@netpanic.org> References: <20220808145643.3445-1-simon@netpanic.org> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Simon Streit * gnu/packages/samba.scm (samba) : Add avahi. --- gnu/packages/samba.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm index f6ead57cc1..da7d9ef2d3 100644 --- a/gnu/packages/samba.scm +++ b/gnu/packages/samba.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2020, 2022 Maxim Cournoyer ;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ ;;; Copyright © 2022 Guillaume Le Vaillant +;;; Copyright © 2022 Simon Streit ;;; ;;; This file is part of GNU Guix. ;;; @@ -40,6 +41,7 @@ (define-module (gnu packages samba) #:use-module (gnu packages acl) #:use-module (gnu packages admin) #:use-module (gnu packages autotools) + #:use-module (gnu packages avahi) #:use-module (gnu packages backup) #:use-module (gnu packages base) #:use-module (gnu packages check) @@ -239,6 +241,7 @@ (define-public samba #:tests? #f)) (inputs (list acl + avahi cmocka cups gamin From patchwork Mon Aug 8 14:56:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Streit X-Patchwork-Id: 41379 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 70F8C27BBEA; Mon, 8 Aug 2022 15:57:17 +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.9 required=5.0 tests=BAYES_00,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 3562127BBE9 for ; Mon, 8 Aug 2022 15:57:16 +0100 (BST) Received: from localhost ([::1]:41664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL4Bv-0007GT-9Q for patchwork@mira.cbaines.net; Mon, 08 Aug 2022 10:57:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL4Bj-0007CR-Kd for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oL4Bj-0005Hw-Ba for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oL4Bj-0004fl-7j for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54561] [PATCH v3 2/4] services: Add samba service. Resent-From: simon@netpanic.org Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 08 Aug 2022 14:57:03 +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.165997062017926 (code B ref 54561); Mon, 08 Aug 2022 14:57:03 +0000 Received: (at 54561) by debbugs.gnu.org; 8 Aug 2022 14:57:00 +0000 Received: from localhost ([127.0.0.1]:41497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4Bf-0004f3-1i for submit@debbugs.gnu.org; Mon, 08 Aug 2022 10:57:00 -0400 Received: from smtprelay01.ispgateway.de ([80.67.31.35]:7767) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4Bb-0004eU-4i for 54561@debbugs.gnu.org; Mon, 08 Aug 2022 10:56:56 -0400 Received: from [79.252.144.136] (helo=motorball.wh6.home.arpa) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1oL4Ca-000256-Gl; Mon, 08 Aug 2022 16:57:56 +0200 From: simon@netpanic.org Date: Mon, 8 Aug 2022 16:56:41 +0200 Message-Id: <20220808145643.3445-3-simon@netpanic.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808145643.3445-1-simon@netpanic.org> References: <20220808145643.3445-1-simon@netpanic.org> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Simon Streit * doc/guix.texi: Document it. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/local.mk (samba.scm): Add it. * gnu/services/samba.scm: New file. * gnu/tests/samba.scm: New file. * po/guix/POTFILES.in Add it. --- doc/guix.texi | 53 ++++++++++++ gnu/local.mk | 2 + gnu/services/samba.scm | 182 +++++++++++++++++++++++++++++++++++++++++ gnu/tests/samba.scm | 158 +++++++++++++++++++++++++++++++++++ po/guix/POTFILES.in | 1 + 5 files changed, 396 insertions(+) create mode 100644 gnu/services/samba.scm create mode 100644 gnu/tests/samba.scm diff --git a/doc/guix.texi b/doc/guix.texi index 12ecc1b952..614d0a0e03 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -106,6 +106,7 @@ Copyright @copyright{} 2022 Philip M@sup{c}Grath@* Copyright @copyright{} 2022 Karl Hallsby@* Copyright @copyright{} 2022 Justin Veilleux@* Copyright @copyright{} 2022 Reily Siegel@* +Copyright @copyright{} 2022 Simon Streit@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -385,6 +386,7 @@ Services * DNS Services:: DNS daemons. * VPN Services:: VPN daemons. * Network File System:: NFS related services. +* Samba Services:: Samba services. * Continuous Integration:: Cuirass and Laminar services. * Power Management Services:: Extending battery life. * Audio Services:: The MPD. @@ -17451,6 +17453,7 @@ declaration. * DNS Services:: DNS daemons. * VPN Services:: VPN daemons. * Network File System:: NFS related services. +* Samba Services:: Samba services. * Continuous Integration:: Cuirass and Laminar services. * Power Management Services:: Extending battery life. * Audio Services:: The MPD. @@ -31194,6 +31197,56 @@ The verbosity level of the daemon. @end table @end deftp +@node Samba Services, Continuous Integration, Network File System, Services +@subsection Samba Services + +@cindex Samba +@cindex SMB +The @code{(gnu services samba)} module provides service definitions for +Samba as well as additional helper services. Currently it provides the +following services. + +@subsubheading Samba + +@uref{https://www.samba.org, Samba} provides network shares for folders +and printers using the SMB/CIFS protocol commonly used on Windows. It +can also act as an Active Directory Domain Controller (AD DC) for other +hosts in an heterougenious network with different types of Computer +systems. + +@defvar {Scheme variable} samba-service-type + +The service type to enable the samba services @code{samba}, @code{nmbd}, +@code{smbd} and @code{winbindd}. By default this service type does not +run as an AD DC, hence @code{samba} remains disabled. + +@end defvar + +@deftp{Data Type} samba-service-configuration +Configuration record for the Samba suite. + +@table @asis +@item @code{package} (default: @code{samba}) +The samba package to use. + +@item @code{config-file} (default: @code{#f}) +The config file to use. + +@item @code{enable-samba?} (default: @code{#f}) +Manually enable the @code{samba} daemon. + +@item @code{enable-smbd?} (default: @code{#f}) +Manually enable the @code{smbd} daemon. + +@item @code{enable-nmbd?} (default: @code{#f}) +Manually enable the @code{nmbd} daemon. + +@item @code{enable-winbindd?} (default: @code{#f}) +Manually enable the @code{winbindd} daemon. + +@end table +@end deftp + @node Continuous Integration @subsection Continuous Integration diff --git a/gnu/local.mk b/gnu/local.mk index 72637761d5..9c1f5ff5b8 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -676,6 +676,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/herd.scm \ %D%/services/pm.scm \ %D%/services/rsync.scm \ + %D%/services/samba.scm \ %D%/services/sddm.scm \ %D%/services/spice.scm \ %D%/services/ssh.scm \ @@ -754,6 +755,7 @@ GNU_SYSTEM_MODULES = \ %D%/tests/package-management.scm \ %D%/tests/reconfigure.scm \ %D%/tests/rsync.scm \ + %D%/tests/samba.scm \ %D%/tests/security-token.scm \ %D%/tests/singularity.scm \ %D%/tests/ssh.scm \ diff --git a/gnu/services/samba.scm b/gnu/services/samba.scm new file mode 100644 index 0000000000..2c9e52a0b0 --- /dev/null +++ b/gnu/services/samba.scm @@ -0,0 +1,182 @@ +;;; 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)) + +(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") + (lock-dir "/var/lock/samba") + (cache-dir "/var/cache/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) + (mkdir-p #$lock-dir) + (mkdir-p #$cache-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 "Run @uref{https://www.samba.org/, Samba}, a network file and +print service for all clients using the SMB/CIFS protocol. Samba is an +important component to seamlessly integrate Linux/Unix Servers and Desktops +into Active Directory environments. It can function both as a domain +controller or as a regular domain member.") + (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)))) diff --git a/gnu/tests/samba.scm b/gnu/tests/samba.scm new file mode 100644 index 0000000000..27d7ea49c3 --- /dev/null +++ b/gnu/tests/samba.scm @@ -0,0 +1,158 @@ +;;; 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 tests samba) + #:use-module (gnu tests) + #:use-module (gnu system) + #:use-module (gnu system vm) + #:use-module (gnu services) + #:use-module (gnu services networking) + #:use-module (gnu services samba) + #:use-module (gnu packages samba) + #:use-module (guix gexp) + #:use-module (guix store) + #:export (%test-samba)) + + +;;; +;;; The Samba service. +;;; + +(define %samba-os + (let ((base-os (simple-operating-system + (simple-service 'create-target-directory activation-service-type + #~(begin + (mkdir-p "/srv/samba/guest") + (chown "/srv/samba/guest" + (passwd:uid (getpw "nobody")) + (passwd:gid (getpw "nobody"))))) + (service dhcp-client-service-type) + (service samba-service-type + (samba-configuration + (config-file (plain-file "smb.conf" " +[global] + workgroup = WORKGROUP + server string = Samba Server + server role = standalone server + log file = /var/log/samba/log.%m + logging = file + +[guest] + path = /srv/samba/guest + read only = no + guest ok = yes + guest only = yes +"))))))) + (operating-system + (inherit base-os) + (packages (cons samba (operating-system-packages base-os)))))) + +(define* (run-samba-test) + "Return a test of an OS running Samba service." + + (define vm + (virtual-machine + (operating-system (marionette-operating-system + %samba-os + #:imported-modules '((gnu services herd)))) + (port-forwardings '((8135 . 135) + (8137 . 137) + (8138 . 138) + (8445 . 445))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-26) + (srfi srfi-64)) + + (define marionette + (make-marionette '(#$vm))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "samba") + + (test-assert "samba-smbd running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'samba-smbd)) + marionette)) + + (test-assert "samba-nmbd running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'samba-nmbd)) + marionette)) + + (test-assert "samba-winbindd running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'samba-winbindd)) + marionette)) + + (test-assert "smbd service process id" + (let ((pid + (number->string (wait-for-file "/var/run/samba/smbd.pid" + marionette)))) + (marionette-eval `(file-exists? (string-append "/proc/" ,pid)) + marionette))) + + (test-assert "nmbd service process id" + (let ((pid + (number->string (wait-for-file "/var/run/samba/nmbd.pid" + marionette)))) + (marionette-eval `(file-exists? (string-append "/proc/" ,pid)) + marionette))) + + (test-assert "winbindd service process id" + (let ((pid + (number->string (wait-for-file "/var/run/samba/winbindd.pid" + marionette)))) + (marionette-eval `(file-exists? (string-append "/proc/" ,pid)) + marionette))) + + (test-assert "samba-smbd is listening for peers" + (wait-for-tcp-port 445 marionette)) + + (test-equal "smbclient connect" + 0 + (marionette-eval + '(system* #$(file-append samba "/bin/smbclient") + "--list=localhost" "--no-pass") + marionette)) + + (test-equal "smbclient connect" + 0 + (marionette-eval + '(system* #$(file-append samba "/bin/smbclient") + "--list=localhost" "--no-pass") + marionette)) + + (test-end)))) + + (gexp->derivation "samba-test" test)) + +(define %test-samba + (system-test + (name "samba") + (description "Connect to a running Samba daemon.") + (value (run-samba-test)))) diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index f50dd00422..9088a627ff 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in @@ -6,6 +6,7 @@ gnu/services.scm gnu/system.scm gnu/services/configuration.scm gnu/services/shepherd.scm +gnu/services/samba.scm gnu/home/services.scm gnu/home/services/ssh.scm gnu/home/services/symlink-manager.scm From patchwork Mon Aug 8 14:56:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Streit X-Patchwork-Id: 41380 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 0578F27BBEA; Mon, 8 Aug 2022 15:57:18 +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.9 required=5.0 tests=BAYES_00,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 A2A3427BBE9 for ; Mon, 8 Aug 2022 15:57:17 +0100 (BST) Received: from localhost ([::1]:41672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL4Bw-0007Gn-Rc for patchwork@mira.cbaines.net; Mon, 08 Aug 2022 10:57:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL4Bk-0007DP-AP for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oL4Bk-0005ID-1t for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oL4Bj-0004g1-V9 for guix-patches@gnu.org; Mon, 08 Aug 2022 10:57:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54561] [PATCH v3 3/4] gnu: Add wsdd. Resent-From: simon@netpanic.org Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 08 Aug 2022 14:57:03 +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.165997062317963 (code B ref 54561); Mon, 08 Aug 2022 14:57:03 +0000 Received: (at 54561) by debbugs.gnu.org; 8 Aug 2022 14:57:03 +0000 Received: from localhost ([127.0.0.1]:41502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4Bi-0004fT-JZ for submit@debbugs.gnu.org; Mon, 08 Aug 2022 10:57:03 -0400 Received: from smtprelay01.ispgateway.de ([80.67.31.35]:16293) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4Be-0004er-By for 54561@debbugs.gnu.org; Mon, 08 Aug 2022 10:56:58 -0400 Received: from [79.252.144.136] (helo=motorball.wh6.home.arpa) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1oL4Cd-000256-Py; Mon, 08 Aug 2022 16:57:59 +0200 From: simon@netpanic.org Date: Mon, 8 Aug 2022 16:56:42 +0200 Message-Id: <20220808145643.3445-4-simon@netpanic.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808145643.3445-1-simon@netpanic.org> References: <20220808145643.3445-1-simon@netpanic.org> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Simon Streit * gnu/packages/samba.scm (wsdd): New variable. --- gnu/packages/samba.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm index da7d9ef2d3..4edcf9c148 100644 --- a/gnu/packages/samba.scm +++ b/gnu/packages/samba.scm @@ -35,6 +35,7 @@ (define-module (gnu packages samba) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix build-system gnu) + #:use-module (guix build-system copy) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix utils) #:use-module (gnu packages) @@ -505,3 +506,30 @@ (define-public ppp license:bsd-4 license:gpl2+ license:public-domain)))) + +(define-public wsdd + (package + (name "wsdd") + (version "0.7.0") + (source + (origin + (method git-fetch) + (uri (git-reference (url "https://github.com/christgau/wsdd") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "04an2w6hamnai668ag4vq8x0i09fsg2jrayb4a7ar0x6bn837k7m")))) + (build-system copy-build-system) + (inputs + `(("python" ,python))) + (arguments + '(#:install-plan + '(("src/wsdd.py" "bin/wsdd") + ("man/wsdd.1" "share/man/man1/")))) + (home-page "https://github.com/christgau/wsdd") + (synopsis "A Web Service Discovery host daemon") + (description "This daemon allows (Samba) hosts to be found by Web +Service Dicovery Clients. It also implements the client side of the +discovery protocol which allows to search for devices implementing +WSD.") + (license license:expat))) From patchwork Mon Aug 8 14:56:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Streit X-Patchwork-Id: 41382 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 518C627BBEA; Mon, 8 Aug 2022 15:58:10 +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.9 required=5.0 tests=BAYES_00,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 A65B527BBE9 for ; Mon, 8 Aug 2022 15:58:09 +0100 (BST) Received: from localhost ([::1]:43640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL4Cm-0000DH-Rr for patchwork@mira.cbaines.net; Mon, 08 Aug 2022 10:58:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL4Cg-0000D2-GW for guix-patches@gnu.org; Mon, 08 Aug 2022 10:58:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oL4Cg-0005Pi-7l for guix-patches@gnu.org; Mon, 08 Aug 2022 10:58:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oL4Cg-0004hV-42 for guix-patches@gnu.org; Mon, 08 Aug 2022 10:58:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54561] [PATCH v3 4/4] services: Add wsdd service. Resent-From: simon@netpanic.org Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 08 Aug 2022 14:58: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.165997062518004 (code B ref 54561); Mon, 08 Aug 2022 14:58:02 +0000 Received: (at 54561) by debbugs.gnu.org; 8 Aug 2022 14:57:05 +0000 Received: from localhost ([127.0.0.1]:41508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4Bl-0004gJ-3T for submit@debbugs.gnu.org; Mon, 08 Aug 2022 10:57:05 -0400 Received: from smtprelay01.ispgateway.de ([80.67.31.35]:14405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oL4Bg-0004fB-Lk for 54561@debbugs.gnu.org; Mon, 08 Aug 2022 10:57:01 -0400 Received: from [79.252.144.136] (helo=motorball.wh6.home.arpa) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1oL4Cg-000256-0s; Mon, 08 Aug 2022 16:58:02 +0200 From: simon@netpanic.org Date: Mon, 8 Aug 2022 16:56:43 +0200 Message-Id: <20220808145643.3445-5-simon@netpanic.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808145643.3445-1-simon@netpanic.org> References: <20220808145643.3445-1-simon@netpanic.org> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Simon Streit * doc/guix.texi: Add documentation for wsdd service. * gnu/services/samba.scm (): New record. (wsdd-service-type): New variable. (wsdd-shepherd-services): New procedure. * gnu/tests/samba.scm: wsdd test. --- doc/guix.texi | 69 +++++++++++++++++++++++++++ gnu/services/samba.scm | 105 ++++++++++++++++++++++++++++++++++++++++- gnu/tests/samba.scm | 61 +++++++++++++++++++++++- 3 files changed, 233 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 614d0a0e03..c168f063c3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -31247,6 +31247,75 @@ Manually enable the @code{winbindd} daemon. @end table @end deftp +@cindex wsdd +@subsubheading Web Service Discovery Daemon + +Web Service Discovery Daemon implements +@uref{http://docs.oasis-open.org/ws-dd/discovery/1.1/os/wsdd-discovery-1.1-spec-os.html, +Web Services Dynamic Discovery} protocol that enables host discovery -- +similar to Avahi -- over Multicast DNS. It is a drop-in replacement for +SMB hosts that have had SMBv1 disabled for security reasons. + +@defvr {Scheme Variable} wsdd-service-type + +Service type for the WSD host daemon. The value for +this service type is a @code{wsdd-configuration} record. The details +for the @code{wsdd-configuration} record type are given below. +@end defvr + +@deftp{Data Type} wsdd-configuration This data type represents the +configuration for the wsdd service. + +@table @asis + +@item @code{package} (default: @code{wsdd}) +The wsdd package to use. + +@item @code{ipv4only?} (default: @code{#f}) +Only listen to IPv4 addresses. + +@item @code{ipv6only} (default: @code{#f}) +Only listen to IPv6 addresses. Please note: Activating both options is +not possible, since there would be no IP versions to listen to. + +@item @code{chroot} (default: @code{#f}) +Chroot into a separate directory to prevent access to other directories. +This is to increase security in case there is a vulnerability in +@command{wsdd}. + +@item @code{hop-limit} (default: @code{1}) +Limit to the level of hops for multicast packets. The default is +@var{1} which should prevent packets from leaving the local network. + +@item @code{interface} (default: @code{'()}) +Limit to the given list of interfaces to listen to. By default wsdd +will listen to all interfaces. Except the loopback interface is never +used. + +@item @code{uuid-device} (default: @code{#f}) +The WSD protocol requires a device to have a UUID. Set this to manually +assign the service a UUID. + +@item @code{domain} (default: @code{#f}) +Notify this host is a member of an Active Directory. + +@item @code{host-name} (default: @code{#f}) +Manually set the hostname rather than letting @command{wsdd} inherit +this host's hostname. Only the host name part of a possible FQDN will +be used in the default case. + +@item @code{preserve-case?} (default: @code{#f}) +By default @command{wsdd} will convert the hostname in workgroup to all +uppercase. The opposite is true for hostnames in domains. Setting this +parameter will preserve case. + +@item @code{workgroup} (default: @var{"WORKGROUP"}) +Change the name of the workgroup. By default @command{wsdd} reports +this host being member of a workgroup. + +@end table +@end deftp + @node Continuous Integration @subsection Continuous Integration diff --git a/gnu/services/samba.scm b/gnu/services/samba.scm index 2c9e52a0b0..c1f9033d63 100644 --- a/gnu/services/samba.scm +++ b/gnu/services/samba.scm @@ -41,7 +41,10 @@ (define-module (gnu services samba) #:export (samba-service-type samba-configuration - samba-smb-conf)) + samba-smb-conf + + wsdd-service-type + wsdd-configuration)) (define %smb-conf (plain-file "smb.conf" "[global] @@ -180,3 +183,103 @@ (define samba-service-type (service-extension profile-service-type (compose list samba-configuration-package)))) (default-value (samba-configuration)))) + + +;;; +;;; WSDD +;;; + +(define-record-type* + wsdd-configuration + make-wsdd-configuration + wsdd-configuration? + (package wsdd-configuration-package + (default wsdd)) + (ipv4only? wsdd-configuration-ipv4only? + (default #f)) + (ipv6only? wsdd-configuration-ipv6only? + (default #f)) + (chroot wsdd-configuration-chroot + (default #f)) + (hoplimit wsdd-configuration-hoplimit + (default 1)) + (interfaces wsdd-configuration-interfaces + (default '())) + (uuid-device wsdd-configuration-uuid-device + (default #f)) + (domain wsdd-configuration-domain + (default #f)) + (hostname wsdd-configuration-hostname + (default #f)) + (preserve-case? wsdd-configuration-preserve-case? + (default #f)) + (workgroup wsdd-configuration-workgroup + (default "WORKGROUP"))) + +(define wsdd-accounts + (list + (user-group (name "wsdd")) + (user-account (name "wsdd") + (group "wsdd") + (comment "Web Service Discovery user") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))) + +(define wsdd-shepherd-service + (match-lambda + (($ package ipv4only? ipv6only? chroot hoplimit + interfaces uuid-device domain hostname + preserve-case? workgroup) + (list (shepherd-service + (documentation "Run a Web Service Discovery service") + (provision '(wsdd)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/bin/wsdd") + #$@(if ipv4only? + #~("--ipv4only") + '()) + #$@(if ipv6only? + #~("--ipv6only") + '()) + #$@(if chroot + #~("--chroot" #$chroot) + '()) + #$@(if hoplimit + #~("--hoplimit" #$(number->string hoplimit)) + '()) + #$@(map (lambda (interfaces) + (string-append "--interface=" interfaces)) + interfaces) + #$@(if uuid-device + #~("--uuid" #$uuid-device) + '()) + #$@(if domain + #~("--domain" #$domain) + '()) + #$@(if hostname + #~("--hostname" #$hostname) + '()) + #$@(if preserve-case? + #~("--preserve-case") + '()) + #$@(if workgroup + #~("--workgroup" #$workgroup) + '())) + #:user "wsdd" + #:group "wsdd" + #:log-file "/var/log/wsdd.log")) + (stop #~(make-kill-destructor))))))) + +(define wsdd-service-type + (service-type + (name 'wsdd) + (description "Web Service Discovery Daemon") + (extensions + (list (service-extension shepherd-root-service-type + wsdd-shepherd-service) + (service-extension account-service-type + (const wsdd-accounts)) + (service-extension profile-service-type + (compose list wsdd-configuration-package)))) + (default-value (wsdd-configuration)))) diff --git a/gnu/tests/samba.scm b/gnu/tests/samba.scm index 27d7ea49c3..6b065cd5de 100644 --- a/gnu/tests/samba.scm +++ b/gnu/tests/samba.scm @@ -26,7 +26,8 @@ (define-module (gnu tests samba) #:use-module (gnu packages samba) #:use-module (guix gexp) #:use-module (guix store) - #:export (%test-samba)) + #:export (%test-samba + %test-wsdd)) ;;; @@ -156,3 +157,61 @@ (define %test-samba (name "samba") (description "Connect to a running Samba daemon.") (value (run-samba-test)))) + + +;;; +;;; The wsdd service. +;;; + +(define %wsdd-os + (let ((base-os (simple-operating-system + (service dhcp-client-service-type) + (service wsdd-service-type)))) + (operating-system + (inherit base-os) + (packages (cons wsdd (operating-system-packages base-os)))))) + +(define* (run-wsdd-test) + "Return a test of an OS running wsdd service." + + (define vm + (virtual-machine + (operating-system (marionette-operating-system + %wsdd-os + #:imported-modules '((gnu services herd)))) + (port-forwardings '((8135 . 135) + (8137 . 137) + (8138 . 138) + (8445 . 445))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-26) + (srfi srfi-64)) + + (define marionette + (make-marionette '(#$vm))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "wsdd") + + ;; Here shall be more tests to begin with. + + (test-assert "wsdd running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'wsdd)) + marionette)) + + (test-end)))) + + (gexp->derivation "samba-test" test)) + +(define %test-wsdd + (system-test + (name "wsdd") + (description "Connect to a running wsdd daemon.") + (value (run-wsdd-test))))