unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list.
       [not found] <handler.54561.B.16481981281164@debbugs.gnu.org>
@ 2022-07-28 22:22 ` simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 1/4] gnu: samba: Add avahi to inputs simon
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: simon @ 2022-07-28 22:22 UTC (permalink / raw)
  To: 54561; +Cc: Simon Streit

From: Simon Streit <simon@netpanic.org>

Hello, here my third iteration preparing this patch series.

Now there are tests included too.  There is a slight modification in samba's
package declaration to include avahi as a dependency.  Samba uses avahi to
advertise instances to other hosts that understand mDNS through avahi.

Simon Streit (4):
  gnu: samba: Add avahi to inputs.
  services: Add samba service.
  gnu: Add wsdd.
  services: Add wsdd service.

 doc/guix.texi          | 122 ++++++++++++++++++
 gnu/local.mk           |   2 +
 gnu/packages/samba.scm |  31 +++++
 gnu/services/samba.scm | 285 +++++++++++++++++++++++++++++++++++++++++
 gnu/tests/samba.scm    | 217 +++++++++++++++++++++++++++++++
 po/guix/POTFILES.in    |   1 +
 6 files changed, 658 insertions(+)
 create mode 100644 gnu/services/samba.scm
 create mode 100644 gnu/tests/samba.scm

--
2.37.1




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#54561] [PATCH v3 1/4] gnu: samba: Add avahi to inputs.
  2022-07-28 22:22 ` [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list simon
@ 2022-07-28 22:22   ` simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 2/4] services: Add samba service simon
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: simon @ 2022-07-28 22:22 UTC (permalink / raw)
  To: 54561; +Cc: Simon Streit

From: Simon Streit <simon@netpanic.org>

* gnu/packages/samba.scm (samba) <inputs>: 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 <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
 ;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2022 Simon Streit <simon@netpanic.org>
 ;;;
 ;;; 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
-- 
2.37.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#54561] [PATCH v3 2/4] services: Add samba service.
  2022-07-28 22:22 ` [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 1/4] gnu: samba: Add avahi to inputs simon
@ 2022-07-28 22:22   ` simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 3/4] gnu: Add wsdd simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 4/4] services: Add wsdd service simon
  3 siblings, 0 replies; 6+ messages in thread
From: simon @ 2022-07-28 22:22 UTC (permalink / raw)
  To: 54561; +Cc: Simon Streit

From: Simon Streit <simon@netpanic.org>

* 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 <simon@netpanic.org>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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>
+  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 <simon@netpanic.org>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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))
+
+\f
+;;;
+;;; 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
-- 
2.37.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#54561] [PATCH v3 3/4] gnu: Add wsdd.
  2022-07-28 22:22 ` [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 1/4] gnu: samba: Add avahi to inputs simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 2/4] services: Add samba service simon
@ 2022-07-28 22:22   ` simon
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 4/4] services: Add wsdd service simon
  3 siblings, 0 replies; 6+ messages in thread
From: simon @ 2022-07-28 22:22 UTC (permalink / raw)
  To: 54561; +Cc: Simon Streit

From: Simon Streit <simon@netpanic.org>

* 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)))
-- 
2.37.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#54561] [PATCH v3 4/4] services: Add wsdd service.
  2022-07-28 22:22 ` [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list simon
                     ` (2 preceding siblings ...)
  2022-07-28 22:22   ` [bug#54561] [PATCH v3 3/4] gnu: Add wsdd simon
@ 2022-07-28 22:22   ` simon
  3 siblings, 0 replies; 6+ messages in thread
From: simon @ 2022-07-28 22:22 UTC (permalink / raw)
  To: 54561; +Cc: Simon Streit

From: Simon Streit <simon@netpanic.org>

* doc/guix.texi: Add documentation for wsdd service.
* gnu/services/samba.scm (<wsdd-configuration>): 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))))
+
+\f
+;;;
+;;; WSDD
+;;;
+
+(define-record-type* <wsdd-configuration>
+  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
+    (($ <wsdd-configuration> 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))
 
 \f
 ;;;
@@ -156,3 +157,61 @@ (define %test-samba
    (name "samba")
    (description "Connect to a running Samba daemon.")
    (value (run-samba-test))))
+
+\f
+;;;
+;;; 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))))
-- 
2.37.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#54561] [PATCH v3 4/4] services: Add wsdd service.
  2022-08-08 14:56 [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list simon
@ 2022-08-08 14:56 ` simon
  0 siblings, 0 replies; 6+ messages in thread
From: simon @ 2022-08-08 14:56 UTC (permalink / raw)
  To: 54561; +Cc: Simon Streit

From: Simon Streit <simon@netpanic.org>

* doc/guix.texi: Add documentation for wsdd service.
* gnu/services/samba.scm (<wsdd-configuration>): 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))))
+
+\f
+;;;
+;;; WSDD
+;;;
+
+(define-record-type* <wsdd-configuration>
+  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
+    (($ <wsdd-configuration> 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))
 
 \f
 ;;;
@@ -156,3 +157,61 @@ (define %test-samba
    (name "samba")
    (description "Connect to a running Samba daemon.")
    (value (run-samba-test))))
+
+\f
+;;;
+;;; 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))))
-- 
2.37.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-08 14:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <handler.54561.B.16481981281164@debbugs.gnu.org>
2022-07-28 22:22 ` [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list simon
2022-07-28 22:22   ` [bug#54561] [PATCH v3 1/4] gnu: samba: Add avahi to inputs simon
2022-07-28 22:22   ` [bug#54561] [PATCH v3 2/4] services: Add samba service simon
2022-07-28 22:22   ` [bug#54561] [PATCH v3 3/4] gnu: Add wsdd simon
2022-07-28 22:22   ` [bug#54561] [PATCH v3 4/4] services: Add wsdd service simon
2022-08-08 14:56 [bug#54561] [PATCH v3 0/4] Add samba and wsdd to services list simon
2022-08-08 14:56 ` [bug#54561] [PATCH v3 4/4] services: Add wsdd service simon

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).