unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26306: exim service patches (including mail-aliases-service-type)
@ 2017-03-30  4:50 Carlo Zancanaro
  2017-04-07 21:25 ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Carlo Zancanaro @ 2017-03-30  4:50 UTC (permalink / raw)
  To: 26306


[-- Attachment #1.1: Type: text/plain, Size: 443 bytes --]

I've wanted to fix up the exim service given Ludo's comments on my last
few patches (see #25789), so here are some patches to introduce a
mail-aliases-service-type, to change exim-service-type to use it
(instead of doing its own thing), and to add a system test for
exim-service-type.

I haven't yet written the updates necessary to the documentation, but I
thought I'd send these now to get feedback before I do the work to fix
up the docs.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-services-Add-mail-aliases-service-type.patch --]
[-- Type: text/x-patch, Size: 2128 bytes --]

From 11a5223f4a9487d3a9a17925488e18e80baec843 Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Thu, 30 Mar 2017 15:25:58 +1100
Subject: [PATCH 1/3] services: Add mail-aliases-service-type.

* gnu/services/mail.scm (mail-aliases-etc): New procedure.
(mail-aliases-service-type): New variable.
---
 gnu/services/mail.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 05978e006..146ed951f 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -35,6 +35,7 @@
   #:use-module (guix gexp)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
+  #:use-module (srfi srfi-1)
   #:export (dovecot-service
             dovecot-service-type
             dovecot-configuration
@@ -57,6 +58,8 @@
             opensmtpd-service-type
             %default-opensmtpd-config-file
 
+            mail-aliases-service-type
+
             exim-configuration
             exim-configuration?
             exim-service-type
@@ -1662,6 +1665,31 @@ accept from local for any relay
 
 \f
 ;;;
+;;; mail aliases.
+;;;
+
+(define (mail-aliases-etc aliases)
+  `(("aliases" ,(plain-file "aliases"
+                            ;; Ideally we'd use a format string like
+                            ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a
+                            ;; warning that I can't figure out how to fix,
+                            ;; so we'll just use string-join below instead.
+                            (format #f "~:{~a: ~a\n~}"
+                                    (map (lambda (entry)
+                                           (list (car entry)
+                                                 (string-join (cdr entry) ",")))
+                                         aliases))))))
+
+(define mail-aliases-service-type
+  (service-type
+   (name 'mail-aliases)
+   (extensions
+    (list (service-extension etc-service-type mail-aliases-etc)))
+   (compose concatenate)
+   (extend append)))
+
+\f
+;;;
 ;;; Exim.
 ;;;
 
-- 
2.12.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-services-Make-exim-service-type-use-mail-aliases-ser.patch --]
[-- Type: text/x-patch, Size: 3310 bytes --]

From 8ac4f5fba3420ba5525cd7dff93d30f7fed8b0ae Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Thu, 30 Mar 2017 15:28:26 +1100
Subject: [PATCH 2/3] services: Make exim-service-type use
 mail-aliases-service-type

* gnu/services/mail.scm (exim-configuration)[aliases]: Remove field.
(exim-activation, exim-shepherd-service): Remove alias from matches.
(exim-etc): Remove procedure.
(exim-service-type): Extend mail-aliases-service-type instead of
etc-service-type.
---
 gnu/services/mail.scm | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 146ed951f..f16f7e026 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -1699,9 +1699,7 @@ accept from local for any relay
   (package       exim-configuration-package ;<package>
                  (default exim))
   (config-file   exim-configuration-config-file ;file-like
-                 (default #f))
-  (aliases       exim-configuration-aliases ;; list of lists
-                 (default '())))
+                 (default #f)))
 
 (define %exim-accounts
   (list (user-group
@@ -1728,7 +1726,7 @@ exim_group = exim
 
 (define exim-shepherd-service
   (match-lambda
-    (($ <exim-configuration> package config-file aliases)
+    (($ <exim-configuration> package config-file)
      (list (shepherd-service
             (provision '(exim mta))
             (documentation "Run the exim daemon.")
@@ -1741,7 +1739,7 @@ exim_group = exim
 
 (define exim-activation
   (match-lambda
-    (($ <exim-configuration> package config-file aliases)
+    (($ <exim-configuration> package config-file)
      (with-imported-modules '((guix build utils))
        #~(begin
            (use-modules (guix build utils))
@@ -1754,20 +1752,6 @@ exim_group = exim
            (zero? (system* #$(file-append package "/bin/exim")
                            "-bV" "-C" #$(exim-computed-config-file package config-file))))))))
 
-(define exim-etc
-  (match-lambda
-    (($ <exim-configuration> package config-file aliases)
-     `(("aliases" ,(plain-file "aliases"
-                               ;; Ideally we'd use a format string like
-                               ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a
-                               ;; warning that I can't figure out how to fix,
-                               ;; so we'll just use string-join below instead.
-                               (format #f "~:{~a: ~a\n~}"
-                                       (map (lambda (entry)
-                                              (list (car entry)
-                                                    (string-join (cdr entry) ",")))
-                                            aliases))))))))
-
 (define exim-profile
   (compose list exim-configuration-package))
 
@@ -1779,4 +1763,4 @@ exim_group = exim
           (service-extension account-service-type (const %exim-accounts))
           (service-extension activation-service-type exim-activation)
           (service-extension profile-service-type exim-profile)
-          (service-extension etc-service-type exim-etc)))))
+          (service-extension mail-aliases-service-type (const '()))))))
-- 
2.12.0


[-- Attachment #1.4: 0003-tests-mail-Add-test-for-exim.patch --]
[-- Type: text/x-patch, Size: 6219 bytes --]

From 984298f4cea4ac3bff530a4a767bf96567ec284f Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Thu, 30 Mar 2017 15:13:56 +1100
Subject: [PATCH 3/3] tests: mail: Add test for exim

* gnu/tests/mail.scm (%exim-os, %test-exim): New variables.
(run-exim-test): New procedure.
---
 gnu/tests/mail.scm | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 142 insertions(+), 1 deletion(-)

diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm
index 47328a54a..1d8c0e22e 100644
--- a/gnu/tests/mail.scm
+++ b/gnu/tests/mail.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Sou Bunnbu <iyzsong@member.fsf.org>
+;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -29,7 +30,9 @@
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (guix store)
-  #:export (%test-opensmtpd))
+  #:use-module (ice-9 ftw)
+  #:export (%test-opensmtpd
+            %test-exim))
 
 (define %opensmtpd-os
   (operating-system
@@ -157,3 +160,141 @@ accept from any for local deliver to mbox
    (name "opensmtpd")
    (description "Send an email to a running OpenSMTPD server.")
    (value (run-opensmtpd-test))))
+
+
+(define %exim-os
+  (operating-system
+    (host-name "komputilo")
+    (timezone "Europe/Berlin")
+    (locale "en_US.UTF-8")
+    (bootloader (grub-configuration (device #f)))
+    (file-systems %base-file-systems)
+    (firmware '())
+    (services (cons*
+               (dhcp-client-service)
+               (service mail-aliases-service-type '())
+               (service exim-service-type
+                        (exim-configuration
+                         (config-file
+                          (plain-file "exim.conf" "
+primary_hostname = komputilo
+domainlist local_domains = @
+domainlist relay_to_domains =
+hostlist   relay_from_hosts = localhost
+
+never_users =
+
+acl_smtp_rcpt = acl_check_rcpt
+acl_smtp_data = acl_check_data
+
+begin acl
+
+acl_check_rcpt:
+  accept
+acl_check_data:
+  accept
+"))))
+               %base-services))))
+
+(define (run-exim-test)
+  "Return a test of an OS running an Exim service."
+  (mlet* %store-monad ((command (system-qemu-image/shared-store-script
+                                 (marionette-operating-system
+                                  %exim-os
+                                  #:imported-modules '((gnu services herd)))
+                                 #:graphic? #f)))
+    (define test
+      (with-imported-modules '((gnu build marionette)
+                               (ice-9 ftw))
+        #~(begin
+            (use-modules (rnrs base)
+                         (srfi srfi-64)
+                         (ice-9 ftw)
+                         (ice-9 rdelim)
+                         (ice-9 regex)
+                         (gnu build marionette))
+
+            (define marionette
+              (make-marionette
+               ;; Enable TCP forwarding of the guest's port 25.
+               '(#$command "-net" "user,hostfwd=tcp::1025-:25")))
+
+            (define (read-reply-code port)
+              "Read a SMTP reply from PORT and return its reply code."
+              (let* ((line      (read-line port))
+                     (mo        (string-match "([0-9]+)([ -]).*" line))
+                     (code      (string->number (match:substring mo 1)))
+                     (finished? (string= " " (match:substring mo 2))))
+                (if finished?
+                    code
+                    (read-reply-code port))))
+
+            (define smtp (socket AF_INET SOCK_STREAM 0))
+            (define addr (make-socket-address AF_INET INADDR_LOOPBACK 1025))
+
+            (mkdir #$output)
+            (chdir #$output)
+
+            (test-begin "exim")
+
+            (test-assert "service is running"
+              (marionette-eval
+               '(begin
+                  (use-modules (gnu services herd))
+                  (start-service 'exim)
+                  #t)
+               marionette))
+
+            (sleep 1) ;; give the service time to start working
+
+            (connect smtp addr)
+            ;; Be greeted.
+            (test-eq "greeting received"
+              220 (read-reply-code smtp))
+            ;; Greet the server.
+            (write-line "EHLO somehost" smtp)
+            (test-eq "greeting successful"
+              250 (read-reply-code smtp))
+            ;; Set sender email.
+            (write-line "MAIL FROM: test@example.com" smtp)
+            (test-eq "sender set"
+              250 (read-reply-code smtp)) ;250
+            ;; Set recipient email.
+            (write-line "RCPT TO: root@komputilo" smtp)
+            (test-eq "recipient set"
+              250 (read-reply-code smtp)) ;250
+            ;; Send message.
+            (write-line "DATA" smtp)
+            (test-eq "data begun"
+              354 (read-reply-code smtp)) ;354
+            (write-line "Subject: Hello" smtp)
+            (newline smtp)
+            (write-line "Nice to meet you!" smtp)
+            (write-line "." smtp)
+            (test-eq "message sent"
+              250 (read-reply-code smtp)) ;250
+            ;; Say goodbye.
+            (write-line "QUIT" smtp)
+            (test-eq "quit successful"
+              221 (read-reply-code smtp)) ;221
+            (close smtp)
+
+            (test-eq "the email is received"
+              1
+              (marionette-eval
+               '(begin
+                  (use-modules (ice-9 ftw))
+                  (length (scandir "/var/spool/exim/msglog"
+                                   (lambda (x) (not (string-prefix? "." x))))))
+               marionette))
+
+            (test-end)
+            (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+    (gexp->derivation "exim-test" test)))
+
+(define %test-exim
+  (system-test
+   (name "exim")
+   (description "Send an email to a running an Exim server.")
+   (value (run-exim-test))))
-- 
2.12.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* bug#26306: exim service patches (including mail-aliases-service-type)
  2017-03-30  4:50 bug#26306: exim service patches (including mail-aliases-service-type) Carlo Zancanaro
@ 2017-04-07 21:25 ` Ludovic Courtès
  2017-04-07 21:29   ` Ludovic Courtès
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Ludovic Courtès @ 2017-04-07 21:25 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: 26306

Hi Carlo,

Carlo Zancanaro <carlo@zancanaro.id.au> skribis:

> I've wanted to fix up the exim service given Ludo's comments on my last
> few patches (see #25789), so here are some patches to introduce a
> mail-aliases-service-type, to change exim-service-type to use it
> (instead of doing its own thing), and to add a system test for
> exim-service-type.
>
> I haven't yet written the updates necessary to the documentation, but I
> thought I'd send these now to get feedback before I do the work to fix
> up the docs.

This all LGTM.

Minor comments:

> From 11a5223f4a9487d3a9a17925488e18e80baec843 Mon Sep 17 00:00:00 2001
> From: Carlo Zancanaro <carlo@zancanaro.id.au>
> Date: Thu, 30 Mar 2017 15:25:58 +1100
> Subject: [PATCH 1/3] services: Add mail-aliases-service-type.
>
> * gnu/services/mail.scm (mail-aliases-etc): New procedure.
> (mail-aliases-service-type): New variable.

[...]

> +(define (mail-aliases-etc aliases)
> +  `(("aliases" ,(plain-file "aliases"
> +                            ;; Ideally we'd use a format string like
> +                            ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a
> +                            ;; warning that I can't figure out how to fix,
> +                            ;; so we'll just use string-join below instead.
> +                            (format #f "~:{~a: ~a\n~}"
> +                                    (map (lambda (entry)
> +                                           (list (car entry)
> +                                                 (string-join (cdr entry) ",")))

Please avoid car/cdr:

  (match-lambda
    ((user aliases ...)
     (list user (string-joint aliases ","))))

> +(define mail-aliases-service-type
> +  (service-type
> +   (name 'mail-aliases)
> +   (extensions
> +    (list (service-extension etc-service-type mail-aliases-etc)))
> +   (compose concatenate)
> +   (extend append)))

If you add it to guix.texi (which would be nice) please leave a note as
to what the values are (a list of user/addresses lists, right?).

> From 8ac4f5fba3420ba5525cd7dff93d30f7fed8b0ae Mon Sep 17 00:00:00 2001
> From: Carlo Zancanaro <carlo@zancanaro.id.au>
> Date: Thu, 30 Mar 2017 15:28:26 +1100
> Subject: [PATCH 2/3] services: Make exim-service-type use
>  mail-aliases-service-type
>
> * gnu/services/mail.scm (exim-configuration)[aliases]: Remove field.
> (exim-activation, exim-shepherd-service): Remove alias from matches.
> (exim-etc): Remove procedure.
> (exim-service-type): Extend mail-aliases-service-type instead of
> etc-service-type.

OK.

> From 984298f4cea4ac3bff530a4a767bf96567ec284f Mon Sep 17 00:00:00 2001
> From: Carlo Zancanaro <carlo@zancanaro.id.au>
> Date: Thu, 30 Mar 2017 15:13:56 +1100
> Subject: [PATCH 3/3] tests: mail: Add test for exim
>
> * gnu/tests/mail.scm (%exim-os, %test-exim): New variables.
> (run-exim-test): New procedure.

Nice test!

> +(define %exim-os
> +  (operating-system
> +    (host-name "komputilo")

Due to 892d9089a88abaa2ef1127f16308d03f4f08a4ce, this should use
‘simple-operating-system’.  Apologies!

With a guix.texi update, it’ll be perfect.

Could you send updated patches?

Thanks!

Ludo’.

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

* bug#26306: exim service patches (including mail-aliases-service-type)
  2017-04-07 21:25 ` Ludovic Courtès
@ 2017-04-07 21:29   ` Ludovic Courtès
  2017-04-17 21:27   ` Ludovic Courtès
  2017-04-19 14:46   ` Carlo Zancanaro
  2 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2017-04-07 21:29 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: 26306

BTW the tests pass but the log is a bit fishy:

--8<---------------cut here---------------start------------->8---
LOG: MAIN
  Warning: purging the environment.
 Suggested action: use keep_environment.
  408 LOG: MAIN
  408   exim 4.87_1 daemon started: pid=408, no queue runs, listening for SMTP on port 25 (IPv4)
  410 LOG: MAIN
  410   <= test@example.com H=(somehost) [10.0.2.2] P=esmtp S=225
  411 LOG: MAIN PANIC DIE
  411   re-exec of exim (/gnu/store/dph4aa2ql680y92rv1f0sg1h2218bnmm-exim-4.87.1/bin/exim) with -Mc failed: Permission denied
[   10.990230] exim[411]: segfault at 0 ip 00007f56dc8eb04d sp 00007fffb7145d78 error 6 in libc-2.25.so[7f56dc867000+196000]
  410 LOG: smtp_connection MAIN
  410   SMTP connection from (somehost) [10.0.2.2] closed by QUIT
--8<---------------cut here---------------end--------------->8---

Do you also get this segfault and “MAIN PANIC DIE” thing?

Ludo’.

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

* bug#26306: exim service patches (including mail-aliases-service-type)
  2017-04-07 21:25 ` Ludovic Courtès
  2017-04-07 21:29   ` Ludovic Courtès
@ 2017-04-17 21:27   ` Ludovic Courtès
  2017-04-18  0:57     ` Carlo Zancanaro
  2017-04-19 14:46   ` Carlo Zancanaro
  2 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2017-04-17 21:27 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: 26306

Hi Carlo,

Did you have a chance to look into this?  Those patches are 90% there!
:-)

Ludo’.

ludo@gnu.org (Ludovic Courtès) skribis:

> Hi Carlo,
>
> Carlo Zancanaro <carlo@zancanaro.id.au> skribis:
>
>> I've wanted to fix up the exim service given Ludo's comments on my last
>> few patches (see #25789), so here are some patches to introduce a
>> mail-aliases-service-type, to change exim-service-type to use it
>> (instead of doing its own thing), and to add a system test for
>> exim-service-type.
>>
>> I haven't yet written the updates necessary to the documentation, but I
>> thought I'd send these now to get feedback before I do the work to fix
>> up the docs.
>
> This all LGTM.
>
> Minor comments:
>
>> From 11a5223f4a9487d3a9a17925488e18e80baec843 Mon Sep 17 00:00:00 2001
>> From: Carlo Zancanaro <carlo@zancanaro.id.au>
>> Date: Thu, 30 Mar 2017 15:25:58 +1100
>> Subject: [PATCH 1/3] services: Add mail-aliases-service-type.
>>
>> * gnu/services/mail.scm (mail-aliases-etc): New procedure.
>> (mail-aliases-service-type): New variable.
>
> [...]
>
>> +(define (mail-aliases-etc aliases)
>> +  `(("aliases" ,(plain-file "aliases"
>> +                            ;; Ideally we'd use a format string like
>> +                            ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a
>> +                            ;; warning that I can't figure out how to fix,
>> +                            ;; so we'll just use string-join below instead.
>> +                            (format #f "~:{~a: ~a\n~}"
>> +                                    (map (lambda (entry)
>> +                                           (list (car entry)
>> +                                                 (string-join (cdr entry) ",")))
>
> Please avoid car/cdr:
>
>   (match-lambda
>     ((user aliases ...)
>      (list user (string-joint aliases ","))))
>
>> +(define mail-aliases-service-type
>> +  (service-type
>> +   (name 'mail-aliases)
>> +   (extensions
>> +    (list (service-extension etc-service-type mail-aliases-etc)))
>> +   (compose concatenate)
>> +   (extend append)))
>
> If you add it to guix.texi (which would be nice) please leave a note as
> to what the values are (a list of user/addresses lists, right?).
>
>> From 8ac4f5fba3420ba5525cd7dff93d30f7fed8b0ae Mon Sep 17 00:00:00 2001
>> From: Carlo Zancanaro <carlo@zancanaro.id.au>
>> Date: Thu, 30 Mar 2017 15:28:26 +1100
>> Subject: [PATCH 2/3] services: Make exim-service-type use
>>  mail-aliases-service-type
>>
>> * gnu/services/mail.scm (exim-configuration)[aliases]: Remove field.
>> (exim-activation, exim-shepherd-service): Remove alias from matches.
>> (exim-etc): Remove procedure.
>> (exim-service-type): Extend mail-aliases-service-type instead of
>> etc-service-type.
>
> OK.
>
>> From 984298f4cea4ac3bff530a4a767bf96567ec284f Mon Sep 17 00:00:00 2001
>> From: Carlo Zancanaro <carlo@zancanaro.id.au>
>> Date: Thu, 30 Mar 2017 15:13:56 +1100
>> Subject: [PATCH 3/3] tests: mail: Add test for exim
>>
>> * gnu/tests/mail.scm (%exim-os, %test-exim): New variables.
>> (run-exim-test): New procedure.
>
> Nice test!
>
>> +(define %exim-os
>> +  (operating-system
>> +    (host-name "komputilo")
>
> Due to 892d9089a88abaa2ef1127f16308d03f4f08a4ce, this should use
> ‘simple-operating-system’.  Apologies!
>
> With a guix.texi update, it’ll be perfect.
>
> Could you send updated patches?
>
> Thanks!
>
> Ludo’.

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

* bug#26306: exim service patches (including mail-aliases-service-type)
  2017-04-17 21:27   ` Ludovic Courtès
@ 2017-04-18  0:57     ` Carlo Zancanaro
  2017-04-18  8:10       ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Carlo Zancanaro @ 2017-04-18  0:57 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26306

[-- Attachment #1: Type: text/plain, Size: 636 bytes --]

Hey Ludo,

On Mon, Apr 17 2017, Ludovic Courtès wrote:
> Did you have a chance to look into this?  Those patches are 90% there!
> :-)

Sorry, yeah. I started to look at it, particularly trying to fix the
MAIN PANIC DIE issue that you mentioned in the other mail. I do see the
same issue, but I've struggled to find out how to fix it.

I have some time over the next few days, so I'll try to clean up these
patches and re-send them this week, but I don't think I'll be able to
fix the segfault/MAIN PANIC DIE issue. I'm fairly sure it only affects
the tests, though, and exim behaves normally when in actual use.

Carlo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* bug#26306: exim service patches (including mail-aliases-service-type)
  2017-04-18  0:57     ` Carlo Zancanaro
@ 2017-04-18  8:10       ` Ludovic Courtès
  0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2017-04-18  8:10 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: 26306

Heya,

Carlo Zancanaro <carlo@zancanaro.id.au> skribis:

> On Mon, Apr 17 2017, Ludovic Courtès wrote:
>> Did you have a chance to look into this?  Those patches are 90% there!
>> :-)
>
> Sorry, yeah. I started to look at it, particularly trying to fix the
> MAIN PANIC DIE issue that you mentioned in the other mail. I do see the
> same issue, but I've struggled to find out how to fix it.
>
> I have some time over the next few days, so I'll try to clean up these
> patches and re-send them this week, but I don't think I'll be able to
> fix the segfault/MAIN PANIC DIE issue. I'm fairly sure it only affects
> the tests, though, and exim behaves normally when in actual use.

Sounds reasonable; we can investigate that segfault further eventually.

Thanks!

Ludo’.

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

* bug#26306: exim service patches (including mail-aliases-service-type)
  2017-04-07 21:25 ` Ludovic Courtès
  2017-04-07 21:29   ` Ludovic Courtès
  2017-04-17 21:27   ` Ludovic Courtès
@ 2017-04-19 14:46   ` Carlo Zancanaro
  2017-04-19 20:13     ` Ludovic Courtès
  2 siblings, 1 reply; 8+ messages in thread
From: Carlo Zancanaro @ 2017-04-19 14:46 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26306


[-- Attachment #1.1: Type: text/plain, Size: 313 bytes --]

Hey Ludo!

On Fri, Apr 07 2017, Ludovic Courtès wrote:
> Could you send updated patches?

I finally got around to fixing up my patches! How exciting. I've also
added an extra patch for updating guix.texi.

The MAIN PANIC DIE is still an issue, but I'm fairly sure it only
affects the tests.

Carlo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-services-Add-mail-aliases-service-type.patch --]
[-- Type: text/x-diff, Size: 2137 bytes --]

From e2445e69f24baed9f0a625dcd6ff2dbfd8ec7f45 Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Thu, 30 Mar 2017 15:25:58 +1100
Subject: [PATCH 1/4] services: Add mail-aliases-service-type.

* gnu/services/mail.scm (mail-aliases-etc): New procedure.
(mail-aliases-service-type): New variable.
---
 gnu/services/mail.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 20043d751..6325589bf 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -35,6 +35,7 @@
   #:use-module (guix gexp)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
+  #:use-module (srfi srfi-1)
   #:export (dovecot-service
             dovecot-service-type
             dovecot-configuration
@@ -57,6 +58,8 @@
             opensmtpd-service-type
             %default-opensmtpd-config-file
 
+            mail-aliases-service-type
+
             exim-configuration
             exim-configuration?
             exim-service-type
@@ -1662,6 +1665,31 @@ accept from local for any relay
 
 \f
 ;;;
+;;; mail aliases.
+;;;
+
+(define (mail-aliases-etc aliases)
+  `(("aliases" ,(plain-file "aliases"
+                            ;; Ideally we'd use a format string like
+                            ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a
+                            ;; warning that I can't figure out how to fix,
+                            ;; so we'll just use string-join below instead.
+                            (format #f "~:{~a: ~a\n~}"
+                                    (map (match-lambda
+                                           ((alias addresses ...)
+                                            (list alias (string-join addresses ","))))
+                                         aliases))))))
+
+(define mail-aliases-service-type
+  (service-type
+   (name 'mail-aliases)
+   (extensions
+    (list (service-extension etc-service-type mail-aliases-etc)))
+   (compose concatenate)
+   (extend append)))
+
+\f
+;;;
 ;;; Exim.
 ;;;
 
-- 
2.12.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-services-Make-exim-service-type-use-mail-aliases-ser.patch --]
[-- Type: text/x-diff, Size: 3310 bytes --]

From ddfb6544a2b5404a4845179462e5388740428099 Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Thu, 30 Mar 2017 15:28:26 +1100
Subject: [PATCH 2/4] services: Make exim-service-type use
 mail-aliases-service-type

* gnu/services/mail.scm (exim-configuration)[aliases]: Remove field.
(exim-activation, exim-shepherd-service): Remove alias from matches.
(exim-etc): Remove procedure.
(exim-service-type): Extend mail-aliases-service-type instead of
etc-service-type.
---
 gnu/services/mail.scm | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 6325589bf..6305f06f8 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -1699,9 +1699,7 @@ accept from local for any relay
   (package       exim-configuration-package ;<package>
                  (default exim))
   (config-file   exim-configuration-config-file ;file-like
-                 (default #f))
-  (aliases       exim-configuration-aliases ;; list of lists
-                 (default '())))
+                 (default #f)))
 
 (define %exim-accounts
   (list (user-group
@@ -1728,7 +1726,7 @@ exim_group = exim
 
 (define exim-shepherd-service
   (match-lambda
-    (($ <exim-configuration> package config-file aliases)
+    (($ <exim-configuration> package config-file)
      (list (shepherd-service
             (provision '(exim mta))
             (documentation "Run the exim daemon.")
@@ -1741,7 +1739,7 @@ exim_group = exim
 
 (define exim-activation
   (match-lambda
-    (($ <exim-configuration> package config-file aliases)
+    (($ <exim-configuration> package config-file)
      (with-imported-modules '((guix build utils))
        #~(begin
            (use-modules (guix build utils))
@@ -1754,20 +1752,6 @@ exim_group = exim
            (zero? (system* #$(file-append package "/bin/exim")
                            "-bV" "-C" #$(exim-computed-config-file package config-file))))))))
 
-(define exim-etc
-  (match-lambda
-    (($ <exim-configuration> package config-file aliases)
-     `(("aliases" ,(plain-file "aliases"
-                               ;; Ideally we'd use a format string like
-                               ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a
-                               ;; warning that I can't figure out how to fix,
-                               ;; so we'll just use string-join below instead.
-                               (format #f "~:{~a: ~a\n~}"
-                                       (map (lambda (entry)
-                                              (list (car entry)
-                                                    (string-join (cdr entry) ",")))
-                                            aliases))))))))
-
 (define exim-profile
   (compose list exim-configuration-package))
 
@@ -1779,4 +1763,4 @@ exim_group = exim
           (service-extension account-service-type (const %exim-accounts))
           (service-extension activation-service-type exim-activation)
           (service-extension profile-service-type exim-profile)
-          (service-extension etc-service-type exim-etc)))))
+          (service-extension mail-aliases-service-type (const '()))))))
-- 
2.12.2


[-- Attachment #1.4: 0003-tests-mail-Add-test-for-exim.patch --]
[-- Type: text/x-diff, Size: 5899 bytes --]

From 763abe687f7d25f7c6d6cbbc161fca08910b1b3c Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Thu, 30 Mar 2017 15:13:56 +1100
Subject: [PATCH 3/4] tests: mail: Add test for exim

* gnu/tests/mail.scm (%exim-os, %test-exim): New variables.
(run-exim-test): New procedure.
---
 gnu/tests/mail.scm | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 134 insertions(+), 1 deletion(-)

diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm
index d5c08b7f0..247f4f667 100644
--- a/gnu/tests/mail.scm
+++ b/gnu/tests/mail.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Sou Bunnbu <iyzsong@member.fsf.org>
+;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,7 +27,9 @@
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (guix store)
-  #:export (%test-opensmtpd))
+  #:use-module (ice-9 ftw)
+  #:export (%test-opensmtpd
+            %test-exim))
 
 (define %opensmtpd-os
   (simple-operating-system
@@ -146,3 +149,133 @@ accept from any for local deliver to mbox
    (name "opensmtpd")
    (description "Send an email to a running OpenSMTPD server.")
    (value (run-opensmtpd-test))))
+
+
+(define %exim-os
+  (simple-operating-system
+   (dhcp-client-service)
+   (service mail-aliases-service-type '())
+   (service exim-service-type
+            (exim-configuration
+             (config-file
+              (plain-file "exim.conf" "
+primary_hostname = komputilo
+domainlist local_domains = @
+domainlist relay_to_domains =
+hostlist   relay_from_hosts = localhost
+
+never_users =
+
+acl_smtp_rcpt = acl_check_rcpt
+acl_smtp_data = acl_check_data
+
+begin acl
+
+acl_check_rcpt:
+  accept
+acl_check_data:
+  accept
+"))))))
+
+(define (run-exim-test)
+  "Return a test of an OS running an Exim service."
+  (mlet* %store-monad ((command (system-qemu-image/shared-store-script
+                                 (marionette-operating-system
+                                  %exim-os
+                                  #:imported-modules '((gnu services herd)))
+                                 #:graphic? #f)))
+    (define test
+      (with-imported-modules '((gnu build marionette)
+                               (ice-9 ftw))
+        #~(begin
+            (use-modules (rnrs base)
+                         (srfi srfi-64)
+                         (ice-9 ftw)
+                         (ice-9 rdelim)
+                         (ice-9 regex)
+                         (gnu build marionette))
+
+            (define marionette
+              (make-marionette
+               ;; Enable TCP forwarding of the guest's port 25.
+               '(#$command "-net" "user,hostfwd=tcp::1025-:25")))
+
+            (define (read-reply-code port)
+              "Read a SMTP reply from PORT and return its reply code."
+              (let* ((line      (read-line port))
+                     (mo        (string-match "([0-9]+)([ -]).*" line))
+                     (code      (string->number (match:substring mo 1)))
+                     (finished? (string= " " (match:substring mo 2))))
+                (if finished?
+                    code
+                    (read-reply-code port))))
+
+            (define smtp (socket AF_INET SOCK_STREAM 0))
+            (define addr (make-socket-address AF_INET INADDR_LOOPBACK 1025))
+
+            (mkdir #$output)
+            (chdir #$output)
+
+            (test-begin "exim")
+
+            (test-assert "service is running"
+              (marionette-eval
+               '(begin
+                  (use-modules (gnu services herd))
+                  (start-service 'exim)
+                  #t)
+               marionette))
+
+            (sleep 1) ;; give the service time to start talking
+
+            (connect smtp addr)
+            ;; Be greeted.
+            (test-eq "greeting received"
+              220 (read-reply-code smtp))
+            ;; Greet the server.
+            (write-line "EHLO somehost" smtp)
+            (test-eq "greeting successful"
+              250 (read-reply-code smtp))
+            ;; Set sender email.
+            (write-line "MAIL FROM: test@example.com" smtp)
+            (test-eq "sender set"
+              250 (read-reply-code smtp)) ;250
+            ;; Set recipient email.
+            (write-line "RCPT TO: root@komputilo" smtp)
+            (test-eq "recipient set"
+              250 (read-reply-code smtp)) ;250
+            ;; Send message.
+            (write-line "DATA" smtp)
+            (test-eq "data begun"
+              354 (read-reply-code smtp)) ;354
+            (write-line "Subject: Hello" smtp)
+            (newline smtp)
+            (write-line "Nice to meet you!" smtp)
+            (write-line "." smtp)
+            (test-eq "message sent"
+              250 (read-reply-code smtp)) ;250
+            ;; Say goodbye.
+            (write-line "QUIT" smtp)
+            (test-eq "quit successful"
+              221 (read-reply-code smtp)) ;221
+            (close smtp)
+
+            (test-eq "the email is received"
+              1
+              (marionette-eval
+               '(begin
+                  (use-modules (ice-9 ftw))
+                  (length (scandir "/var/spool/exim/msglog"
+                                   (lambda (x) (not (string-prefix? "." x))))))
+               marionette))
+
+            (test-end)
+            (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+    (gexp->derivation "exim-test" test)))
+
+(define %test-exim
+  (system-test
+   (name "exim")
+   (description "Send an email to a running an Exim server.")
+   (value (run-exim-test))))
-- 
2.12.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.5: 0004-doc-Update-exim-service-documentation.patch --]
[-- Type: text/x-diff, Size: 3042 bytes --]

From f133eca18dbf1b6483050ebe9e15ba7eafc457f0 Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Wed, 19 Apr 2017 23:58:24 +1000
Subject: [PATCH 4/4] doc: Update exim service documentation

* doc/guix.texi (Mail Services): Update exim service documentation to remove
mail-aliases, add mail-aliases-service-type documentation.
---
 doc/guix.texi | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f2eba59d9..8cc2c43d0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12644,12 +12644,14 @@ should be an @code{exim-configuration} object as in this example:
 @example
 (service exim-service-type
          (exim-configuration
-           (config-file (local-file "./my-exim.conf"))
-           (aliases '(("postmaster" "bob")
-                      ("bob" "bob@@example.com" "bob@@example2.com")))))
+           (config-file (local-file "./my-exim.conf"))))
 @end example
 @end deffn
 
+In order to use an @code{exim-service-type} service you must also have a
+@code{mail-aliases-service-type} service present in your
+@code{operating-system} (even if it has no aliases).
+
 @deftp {Data Type} exim-configuration
 Data type representing the configuration of exim.
 
@@ -12664,16 +12666,34 @@ provided in @code{package}. The resulting configuration file is loaded
 after setting the @code{exim_user} and @code{exim_group} configuration
 variables.
 
-@item @code{aliases} (default: @code{'()})
-List of aliases to use when delivering mail on this system. The
-@code{car} of each list is used to match incoming mail, with the
-@code{cdr} of each list designating how to deliver it. There may be many
-delivery methods provided, in which case the mail is delivered to them
-all.
-
 @end table
 @end deftp
 
+@subsubheading Mail Aliases Service
+
+@deffn {Scheme Variable} mail-aliases-service-type
+This is the type of the service which provides @code{/etc/aliases},
+specifying how to deliver mail to users on this system.
+
+@example
+(service mail-aliases-service-type
+         '(("postmaster" "bob")
+           ("bob" "bob@@example.com" "bob@@example2.com")))
+@end example
+@end deffn
+
+The configuration for a @code{mail-aliases-service-type} service is an
+association list denoting how to deliver mail that comes to this
+system. Each entry is of the form @code{(alias addresses ...)}, with
+@code{alias} specifying the local alias and @code{addresses} specifying
+where to deliver this user's mail.
+
+The aliases aren't required to exist as users on the local system. In
+the above example, there doesn't need to be a @code{postmaster} entry in
+the @code{operating-system}'s @code{user-accounts} in order to deliver
+the @code{postmaster} mail to @code{bob} (which subsequently would
+deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
+
 @node Messaging Services
 @subsubsection Messaging Services
 
-- 
2.12.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* bug#26306: exim service patches (including mail-aliases-service-type)
  2017-04-19 14:46   ` Carlo Zancanaro
@ 2017-04-19 20:13     ` Ludovic Courtès
  0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2017-04-19 20:13 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: 26306-done

Hi Carlo!

Carlo Zancanaro <carlo@zancanaro.id.au> skribis:

> I finally got around to fixing up my patches! How exciting. I've also
> added an extra patch for updating guix.texi.

Awesome!  I’ve committed them after adding a couple of @cindex in the
manual (to make it easier to find these bits).

Thank you!

Ludo’.

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

end of thread, other threads:[~2017-04-19 20:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30  4:50 bug#26306: exim service patches (including mail-aliases-service-type) Carlo Zancanaro
2017-04-07 21:25 ` Ludovic Courtès
2017-04-07 21:29   ` Ludovic Courtès
2017-04-17 21:27   ` Ludovic Courtès
2017-04-18  0:57     ` Carlo Zancanaro
2017-04-18  8:10       ` Ludovic Courtès
2017-04-19 14:46   ` Carlo Zancanaro
2017-04-19 20:13     ` Ludovic Courtès

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).