From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:5f26::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id a3YhD/YEeGWQqQAAkFu2QA (envelope-from ) for ; Tue, 12 Dec 2023 08:00:06 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id yMBZCfYEeGV7vQAAqHPOHw (envelope-from ) for ; Tue, 12 Dec 2023 08:00:06 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=laesvuori.fi header.s=mail header.b=Rt9p1jk2; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1702364405; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: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: dkim-signature; bh=oj1wmLzZQUSD6ms+pZgd6shBVQCGdQe+S4jz5UELIdU=; b=V2QblEsAT6ULxJE3igtZjCc3EiNQM/TPdJajx4axA6Rm3UMWYaH3plNzsx+dGecfFdIQvk mLf84Z5MzYbQtMPeVJHk8kK6c3m3TKUD3DXNTrBr1kpU8enF3pCL0/T3bxw7rNsR5iihDo V4LVE+c4BRDwGPg9nEmAfTIqr7XiW5Z26Gz2Jorkyu530CPyBKzkRfKwdT83KquDFVu7pk 0njIgMolnGjze0Wx7I0qeB3I/AE8Xmqmk/ujlqwBwEa6MFvrpPSUzNH68lN5GLadH/AlSM FOtgfgRKyH3hlbrUhitSA/PBvKVZ8ui8VrCC/Lj4g3vcZ6WDOpctFVjmbQ2tNQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=laesvuori.fi header.s=mail header.b=Rt9p1jk2; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1702364405; a=rsa-sha256; cv=none; b=nDUuTqrLlpkU89KahYvWAXj9NZELoL7/7uPmP4bH0PxVpwgB8dk01GfMoc9Fo4qp4TQnwT hyJ3JNdIWHdAMWKpw3Vq//AAbF9WiA3YVyIY3yC7wFFQXgoIDVCYwEMOV3NrQRh+X43BZO FVeLnyDXEfbOEbKSDwsJUaFA9O61cDSX5Ii/6DFE29YyHVNwPDE0cdr1EaEC+8lNdq6M2g VznwnYQHDKFUgebEQbIaFx5wFa1LejXlHPUl7uxA44PLgbJyZEsbvx4/AukUuMoyePxWr8 FIpgAvNwmHiqg29Q1QbTlBiut4MkKjDCQD9S2Ce9Q505MmB3FiSudu9kG+wIAA== 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 F29E6246FA for ; Tue, 12 Dec 2023 08:00:04 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCwkB-0007eK-NU; Tue, 12 Dec 2023 01:59:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rCwk7-0007e6-Qe for guix-patches@gnu.org; Tue, 12 Dec 2023 01:59:48 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCwk7-0006mg-Iv for guix-patches@gnu.org; Tue, 12 Dec 2023 01:59:47 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCwkM-0005Ss-O0 for guix-patches@gnu.org; Tue, 12 Dec 2023 02:00:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61740] [PATCH v5] services: Add rspamd-service-type (was [PATCH v4] services: Add rspamd-service-type.) Resent-From: Saku Laesvuori Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 12 Dec 2023 07:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61740 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: moreinfo patch To: Bruno Victal Cc: Thomas Ieong , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Felix Lechner , 61740@debbugs.gnu.org Received: via spool by 61740-submit@debbugs.gnu.org id=B61740.170236434620887 (code B ref 61740); Tue, 12 Dec 2023 07:00:02 +0000 Received: (at 61740) by debbugs.gnu.org; 12 Dec 2023 06:59:06 +0000 Received: from localhost ([127.0.0.1]:55146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCwjR-0005Qo-Fy for submit@debbugs.gnu.org; Tue, 12 Dec 2023 01:59:06 -0500 Received: from vmi571514.contaboserver.net ([75.119.130.101]:59490 helo=mail.laesvuori.fi) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCwjN-0005QJ-SK for 61740@debbugs.gnu.org; Tue, 12 Dec 2023 01:59:04 -0500 Received: from X-kone (unknown [130.233.144.30]) by mail.laesvuori.fi (Postfix) with ESMTPSA id 5C26E342469; Tue, 12 Dec 2023 07:58:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=laesvuori.fi; s=mail; t=1702364328; bh=7B+n0wqkcrqav6QQTpOvwHUxccohCwUPY84+gSLEECI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Rt9p1jk2xQlarQgufPbBiffAIXe0jfh4mFMsr3HI2BZ+v0WvbILWDCLdgGwfUuOeQ 6O8irqBbv2XpKlAJgGHqEavoMUXtnmdZ6rCOvsYYSnxuvCJbuQ1Bexo3sP/kDhZvVn CAyA/+U4B6JP1W/FMfledOWajMG/3rIv9QiO3pq8= Date: Tue, 12 Dec 2023 08:58:41 +0200 Message-ID: References: <87sf7fqi3x.fsf@lease-up.com> <4xf4fec5gensjq534b7iyxpxlfg4foinwyls3mvwigubs3vagj@sujka7hlplro> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xpjbuzuxmc7l3piz" Content-Disposition: inline In-Reply-To: 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: , Reply-to: Saku Laesvuori X-ACL-Warn: , Saku Laesvuori via Guix-patches From: Saku Laesvuori via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -8.28 X-Spam-Score: -8.28 X-Migadu-Queue-Id: F29E6246FA X-Migadu-Scanner: mx10.migadu.com X-TUID: mutQVtSvFk4g --xpjbuzuxmc7l3piz Content-Type: multipart/mixed; boundary="peahjj64yl6nprpm" Content-Disposition: inline --peahjj64yl6nprpm Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > >>> + (service-extension profile-service-type > >>> + (compose list rspamd-configuration-package)) > >> > >> What's the motivation for adding the rspamd package to the profile? > >=20 > > That was also there when I picked up this patch. I assume it is added to > > the profile so that the `rspamadm` and `rspamc` programs are available > > and compatible with the daemon. I don't have strong feelings about this > > in either direction. >=20 > I think it's better to omit this, users who are interested in the tools > can use 'guix shell rspamd'. Yes, except if the rspamd package in the configuration is incompatible with the one in the user's Guix. Anyway, this is now removed in v5. > > +(define (list-of-symbols? x) > > + (and (list? x) > > + (every symbol? x))) >=20 > list-of-symbols? is already defined in (gnu services configuration), > you can omit this. Done after a rebase in v5. Apparently it also defines some other useful functions that I didn't know about. > > + (shepherd-action > > + (name 'reopenlog) > > + (documentation "Reopen log files.") >=20 > Missed this in my previous reply, I'd prefer naming this action as > 'reopen instead. Done in v5. > > +(define %rspamd-os > > + (simple-operating-system > > + (service dhcp-client-service-type) >=20 > [=E2=80=A6] >=20 > > + (service rspamd-service-type > > + (rspamd-configuration > > + (shepherd-requirements '(networking)) > > + (local.d-files `(("worker-controller.inc" > > + ,(plain-file > > + "rspamd-public-web-controller.conf" > > + "bind_socket =3D \"0.0.0.0:11334\";= ")))))))) >=20 > I wonder if you could remove dhcp-client-service-type and use the > loopback device for this test instead, by binding to '[::1]' or '127.0.0.= 1'. > (You don't need to add %loopback-static-networking here since it is alrea= dy > included in %base-services.) I tried that but it didn't work because the vm does not have an IP route configured to the host... >=20 > > +(define (run-rspamd-test) > > + "Return a test of an OS running Rspamd service." > > + > > + (define rspamd-ports > > + '((22668 . 11334))) ;; web controller >=20 > [=E2=80=A6] >=20 > > + > > + (define vm > > + (virtual-machine > > + (operating-system (marionette-operating-system > > + %rspamd-os > > + #:imported-modules '((gnu services herd)))) > > + (port-forwardings rspamd-ports))) >=20 > [=E2=80=A6] >=20 > > + ;; Check that we can access the web ui > > + > > + (test-equal "http-get" > > + 200 > > + (response-code (http-get "http://localhost:22668/"))) ; HE= AD is unsupported >=20 > Actually I've realized that these port-forwards are unnecessary > and it would be better to instead do: >=20 > --8<---------------cut here---------------start------------->8--- > ;; Note: remove (web client) and (web response) in the imports above > ;; i.e. after the #~(begin (use-modules =E2=80=A6 >=20 > (test-equal "http-get" > 200 > (marionette-eval > '(begin > (use-modules (web client) > (web response)) > (response-code (http-head "http://localhost:11334/"))) > marionette)) > --8<---------------cut here---------------end--------------->8--- =2E.. However with changes like these it does work in v5. --peahjj64yl6nprpm Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =46rom 7aee03ff1a7ada82436ff424fe7fdbac117fbf29 Mon Sep 17 00:00:00 2001 Message-ID: <7aee03ff1a7ada82436ff424fe7fdbac117fbf29.1702364088.git.saku@l= aesvuori.fi> =46rom: Thomas Ieong Date: Thu, 23 Feb 2023 21:16:14 +0100 Subject: [PATCH v5] services: Add rspamd-service-type. * gnu/services/mail.scm (rspamd-service-type): New variable. * gnu/tests/mail.scm (%test-rspamd): New variable. * doc/guix.texi: Document it. Co-authored-by: Saku Laesvuori Change-Id: I7196643f087ffe9fc91aab231b69d5ed8dc9d198 --- doc/guix.texi | 62 +++++++++++++ gnu/services/mail.scm | 200 +++++++++++++++++++++++++++++++++++++++++- gnu/tests/mail.scm | 67 +++++++++++++- 3 files changed, 327 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3ad8508a32..9dabd51f87 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -120,6 +120,8 @@ Copyright @copyright{} 2023 Brian Cully@* Copyright @copyright{} 2023 Felix Lechner@* Copyright @copyright{} 2023 Foundation Devices, Inc.@* +Copyright @copyright{} 2023 Thomas Ieong@* +Copyright @copyright{} 2023 Saku Laesvuori@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -27617,6 +27619,66 @@ Mail Services @end table @end deftp =20 +@subsubheading Rspamd Service +@cindex email +@cindex spam + +@defvar rspamd-service-type +This is the type of the @uref{https://rspamd.com/, Rspamd} filtering +system whose value should be a @code{rspamd-configuration}. +@end defvar + +@c %start of fragment + +@deftp {Data Type} rspamd-configuration +Available @code{rspamd-configuration} fields are: + +@table @asis +@item @code{package} (default: @code{rspamd}) (type: file-like) +The package that provides rspamd. + +@item @code{config-file} (default: @code{%default-rspamd-config-file}) (ty= pe: file-like) +File-like object of the configuration file to use. By default all +workers are enabled except fuzzy and they are binded to their usual +ports, e.g localhost:11334, localhost:11333 and so on + +@item @code{local.d-files} (default: @code{()}) (type: directory-tree) +Configuration files in local.d, provided as a list of two element lists +where the first element is the filename and the second one is a +file-like object. Settings in these files will be merged with the +defaults. + +@item @code{override.d-files} (default: @code{()}) (type: directory-tree) +Configuration files in override.d, provided as a list of two element +lists where the first element is the filename and the second one is a +file-like object. Settings in these files will override the defaults. + +@item @code{user} (default: @code{%default-rspamd-account}) (type: user-ac= count) +The user to run rspamd as. + +@item @code{group} (default: @code{%default-rspamd-group}) (type: user-gro= up) +The group to run rspamd as. + +@item @code{debug?} (default: @code{#f}) (type: boolean) +Force debug output. + +@item @code{insecure?} (default: @code{#f}) (type: boolean) +Ignore running workers as privileged users. + +@item @code{skip-template?} (default: @code{#f}) (type: boolean) +Do not apply Jinja templates. + +@item @code{shepherd-requirements} (default: @code{(loopback)}) (type: lis= t-of-symbols) +This is a list of symbols naming Shepherd services that this service +will depend on. + +@end table + +@end deftp + + +@c %end of fragment + @node Messaging Services @subsection Messaging Services =20 diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index 12dcc8e71d..afe1bb6016 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -5,6 +5,8 @@ ;;; Copyright =C2=A9 2017, 2020 Tobias Geerinckx-Rice ;;; Copyright =C2=A9 2019 Kristofer Buffington ;;; Copyright =C2=A9 2020 Jonathan Brielmaier +;;; Copyright =C2=A9 2023 Thomas Ieong +;;; Copyright =C2=A9 2023 Saku Laesvuori ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,7 +82,13 @@ (define-module (gnu services mail) radicale-configuration radicale-configuration? radicale-service-type - %default-radicale-config-file)) + %default-radicale-config-file + + rspamd-configuration + rspamd-service-type + %default-rspamd-account + %default-rspamd-config-file + %default-rspamd-group)) =20 ;;; Commentary: ;;; @@ -1987,3 +1995,193 @@ (define radicale-service-type (service-extension account-service-type (const %radicale-account= s)) (service-extension activation-service-type radicale-activation))) (default-value (radicale-configuration)))) + +;;; +;;; Rspamd. +;;; + +(define (directory-tree? xs) + (match xs + ((((? string?) (? file-like?)) ...) #t) + (_ #f))) + +(define-configuration/no-serialization rspamd-configuration + (package + (file-like rspamd) + "The package that provides rspamd.") + (config-file + (file-like %default-rspamd-config-file) + "File-like object of the configuration file to use. By default +all workers are enabled except fuzzy and they are binded +to their usual ports, e.g localhost:11334, localhost:11333 and so on") + (local.d-files + (directory-tree '()) + "Configuration files in local.d, provided as a list of two element list= s where +the first element is the filename and the second one is a file-like object= =2E Settings +in these files will be merged with the defaults.") + (override.d-files + (directory-tree '()) + "Configuration files in override.d, provided as a list of two element l= ists where +the first element is the filename and the second one is a file-like object= =2E Settings +in these files will override the defaults.") + (user + (user-account %default-rspamd-account) + "The user to run rspamd as.") + (group + (user-group %default-rspamd-group) + "The group to run rspamd as.") + (debug? + (boolean #f) + "Force debug output.") + (insecure? + (boolean #f) + "Ignore running workers as privileged users.") + (skip-template? + (boolean #f) + "Do not apply Jinja templates.") + (shepherd-requirements + (list-of-symbols '(loopback)) + "This is a list of symbols naming Shepherd services that this service +will depend on.")) + +(define %default-rspamd-account + (user-account + (name "rspamd") + (group "rspamd") + (system? #t) + (comment "Rspamd daemon") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin")))) + +(define %default-rspamd-group + (user-group + (name "rspamd") + (system? #t))) + +(define %default-rspamd-config-file + (plain-file "rspamd.conf" " +.include \"$CONFDIR/common.conf\" + +options { + pidfile =3D \"$RUNDIR/rspamd.pid\"; + .include \"$CONFDIR/options.inc\" + .include(try=3Dtrue; priority=3D1,duplicate=3Dmerge) \"$LOCAL_CONFDIR/= local.d/options.inc\" + .include(try=3Dtrue; priority=3D10) \"$LOCAL_CONFDIR/override.d/option= s.inc\" +} + +logging { + type =3D \"file\"; + filename =3D \"$LOGDIR/rspamd.log\"; + .include \"$CONFDIR/logging.inc\" + .include(try=3Dtrue; priority=3D1,duplicate=3Dmerge) \"$LOCAL_CONFDIR/= local.d/logging.inc\" + .include(try=3Dtrue; priority=3D10) \"$LOCAL_CONFDIR/override.d/loggin= g.inc\" +} + +worker \"normal\" { + bind_socket =3D \"localhost:11333\"; + .include \"$CONFDIR/worker-normal.inc\" + .include(try=3Dtrue; priority=3D1,duplicate=3Dmerge) \"$LOCAL_CONFDIR/= local.d/worker-normal.inc\" + .include(try=3Dtrue; priority=3D10) \"$LOCAL_CONFDIR/override.d/worker= -normal.inc\" +} + +worker \"controller\" { + bind_socket =3D \"localhost:11334\"; + .include \"$CONFDIR/worker-controller.inc\" + .include(try=3Dtrue; priority=3D1,duplicate=3Dmerge) \"$LOCAL_CONFDIR/= local.d/worker-controller.inc\" + .include(try=3Dtrue; priority=3D10) \"$LOCAL_CONFDIR/override.d/worker= -controller.inc\" +} + +worker \"rspamd_proxy\" { + bind_socket =3D \"localhost:11332\"; + .include \"$CONFDIR/worker-proxy.inc\" + .include(try=3Dtrue; priority=3D1,duplicate=3Dmerge) \"$LOCAL_CONFDIR/= local.d/worker-proxy.inc\" + .include(try=3Dtrue; priority=3D10) \"$LOCAL_CONFDIR/override.d/worker= -proxy.inc\" +} + +# Local fuzzy storage is disabled by default + +worker \"fuzzy\" { + bind_socket =3D \"localhost:11335\"; + count =3D -1; # Disable by default + .include \"$CONFDIR/worker-fuzzy.inc\" + .include(try=3Dtrue; priority=3D1,duplicate=3Dmerge) \"$LOCAL_CONFDIR/= local.d/worker-fuzzy.inc\" + .include(try=3Dtrue; priority=3D10) \"$LOCAL_CONFDIR/override.d/worker= -fuzzy.inc\" +} +")) + +(define (rspamd-accounts config) + (match-record config + (user group) + (list group user))) + +(define (rspamd-shepherd-service config) + (match-record config + (package config-file user group debug? insecure? skip-template? + local.d-files override.d-files shepherd-requirements) + (list + (shepherd-service + (provision '(rspamd)) + (documentation "Run the rspamd daemon.") + (requirement shepherd-requirements) + (start (let ((rspamd (file-append package "/bin/rspamd")) + (local-confdir + (file-union + "rspamd-local-confdir" + `(("local.d" ,(file-union "local.d" local.d-files)) + ("override.d" ,(file-union "override.d" override.d= -files)))))) + (with-imported-modules (source-module-closure '((gnu build = activation))) + #~(begin + (use-modules (gnu build activation)) ; for mkdir-p/pe= rms + (let ((user (getpwnam #$(user-account-name user)))) + (mkdir-p/perms "/var/run/rspamd" user #o755) + (mkdir-p/perms "/var/log/rspamd" user #o755) + (mkdir-p/perms "/var/lib/rspamd" user #o755)) + (make-forkexec-constructor + (list #$rspamd "--config" #$config-file + "--var" (string-append "LOCAL_CONFDIR=3D" #$lo= cal-confdir) + "--no-fork" + #$@(if debug? + '("--debug") + '()) + #$@(if insecure? + '("--insecure") + '()) + #$@(if skip-template? + '("--skip-template") + '())) + #:user #$(user-account-name user) + #:group #$(user-group-name group)))))) + (stop #~(make-kill-destructor)) + (actions + (list + (shepherd-configuration-action config-file) + (shepherd-action + (name 'reload) + (documentation "Reload rspamd.") + (procedure + #~(lambda (pid) + (if pid + (begin + (kill pid SIGHUP) + (display "Service rspamd has been reloaded")) + (format #t "Service rspamd is not running."))))) + (shepherd-action + (name 'reopen) + (documentation "Reopen log files.") + (procedure + #~(lambda (pid) + (if pid + (begin + (kill pid SIGUSR1) + (display "Reopening the logs for rspamd")) + (format #t "Service rspamd is not running."))))))))))) + +(define rspamd-service-type + (service-type + (name 'rspamd) + (description "Run the rapid spam filtering system.") + (extensions + (list + (service-extension shepherd-root-service-type rspamd-shepherd-service) + (service-extension account-service-type rspamd-accounts))) + (default-value (rspamd-configuration)))) diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm index dcb8f08ea8..176e7c1d07 100644 --- a/gnu/tests/mail.scm +++ b/gnu/tests/mail.scm @@ -6,6 +6,7 @@ ;;; Copyright =C2=A9 2018 Cl=C3=A9ment Lassieur ;;; Copyright =C2=A9 2019 Christopher Baines ;;; Copyright =C2=A9 2019, 2020 Tobias Geerinckx-Rice +;;; Copyright =C2=A9 2023 Thomas Ieong ;;; ;;; This file is part of GNU Guix. ;;; @@ -40,7 +41,8 @@ (define-module (gnu tests mail) #:export (%test-opensmtpd %test-exim %test-dovecot - %test-getmail)) + %test-getmail + %test-rspamd)) =20 (define %opensmtpd-os (simple-operating-system @@ -579,3 +581,66 @@ (define %test-getmail (name "getmail") (description "Connect to a running Getmail server.") (value (run-getmail-test)))) + +(define %rspamd-os + (simple-operating-system + (service rspamd-service-type))) + +(define (run-rspamd-test) + "Return a test of an OS running Rspamd service." + + (define vm + (virtual-machine + (marionette-operating-system + %rspamd-os + #:imported-modules '((gnu services herd))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-64) + (gnu build marionette)) + + (define marionette + (make-marionette '(#$vm))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "rspamd") + + (test-assert "service is running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'rspamd)) + marionette)) + + (test-assert "rspamd socket ready" + (wait-for-unix-socket + "/var/lib/rspamd/rspamd.sock" + marionette)) + + (test-assert "rspamd log file" + (wait-for-file "/var/log/rspamd/rspamd.log" marionette)) + + ;; Check that we can access the web ui + + (test-equal "http-get" + 200 + (marionette-eval + '(begin + (use-modules (web client) + (web response)) + ;; HEAD returns 500 internal server error, so use GET eve= n though + ;; only the headers are relevant + (response-code (http-get "http://localhost:11334"))) + marionette)) + + (test-end)))) + + (gexp->derivation "rspamd-test" test)) + +(define %test-rspamd + (system-test + (name "rspamd") + (description "Basic rspamd service test.") + (value (run-rspamd-test)))) base-commit: 06587003b896755f876ecd57b848e1d663fafb87 --=20 2.41.0 --peahjj64yl6nprpm-- --xpjbuzuxmc7l3piz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEoMkZR3NPB29fCOn/JX0oSiodOjIFAmV4BKEACgkQJX0oSiod OjJc8RAAjfQ+eEV+QE8sKjnrFBMIcFO5HG72bJSJl8RymsmzMzoZYExfMmYbwfmw 0KMijd+s+3iq7sMXFhUjkGBN0q7OwdBavFsE7Zd9Xn7pNCNiYITZvYxxz5a6edow KF1oK3njFtOscpibJ2TmdiQZzfTfptuzFB5a3Yl8wUMZEk8GW2g/O/lLPzZn2Xms CvRI77n674H3Fhe9x7zNUD2FoRlBRH/tblUrfkk5DOUzmkI4ccuuvMdS2e9vUGp/ FCK9GjmzUrVntpCd0EQRMLGc60boEI9WOLOBtJkH+0UtZbd7OwUZsdmn/VeKmWGG d0XkDnKJNxhShFBCb8eUG9ca3h1Dwmc0tYtzhSpCk3o1tceZAGPv2DP0CBzxIHCM a/UlZV0R3BeDquw1RwpSi2wvQXbf5lSyxLNX8mkpEuXmGsnkV5rw0UUgan2xsKzZ nOJnLlCr5T45OqfBI9612UyA7NNexHjoeQ+iDQ9lqYpm02L6qweDJZnx/sa/YmfQ mnM/1Jhn6HmacmBFypYsnGeZ4sMlT3VWEztoW8RBFxw5rgHnrLni4bv2XL41wkSs joEsvT7RGKIdthNm8SBCK6bNvdBMV72dNYr3k6rzP8pJn92++dyFfbwJn7gak+4U 3p3qjpImCejPDy5QTPm7qjFz9ZzKYmvrUvHlX/PNSsrbzYaZqro= =8QwL -----END PGP SIGNATURE----- --xpjbuzuxmc7l3piz--