From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id gEGoGEYKxmJhWwAAbAwnHQ (envelope-from ) for ; Thu, 07 Jul 2022 00:18:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id KNmfGEYKxmLOQgAAauVa8A (envelope-from ) for ; Thu, 07 Jul 2022 00:18:46 +0200 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 CAE5419107 for ; Thu, 7 Jul 2022 00:18:45 +0200 (CEST) Received: from localhost ([::1]:38556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9DM2-0005tX-C1 for larch@yhetil.org; Wed, 06 Jul 2022 18:18:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9CwE-0005ao-C6 for guix-patches@gnu.org; Wed, 06 Jul 2022 17:52:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9CwE-0006M6-32 for guix-patches@gnu.org; Wed, 06 Jul 2022 17:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o9CwD-0008Ag-UT for guix-patches@gnu.org; Wed, 06 Jul 2022 17:52:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56046] [PATCH] services: mail: add opensmtpd records to enhance opensmtpd-configuration. Version 2 Resent-From: jbranso@dismail.de Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Jul 2022 21:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56046 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "Liliana Marie Prikler" , 56046@debbugs.gnu.org Received: via spool by 56046-submit@debbugs.gnu.org id=B56046.165714430531382 (code B ref 56046); Wed, 06 Jul 2022 21:52:01 +0000 Received: (at 56046) by debbugs.gnu.org; 6 Jul 2022 21:51:45 +0000 Received: from localhost ([127.0.0.1]:55313 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o9Cvp-00089w-5V for submit@debbugs.gnu.org; Wed, 06 Jul 2022 17:51:45 -0400 Received: from mx1.dismail.de ([78.46.223.134]:41044) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o9Cvk-00089Z-91 for 56046@debbugs.gnu.org; Wed, 06 Jul 2022 17:51:35 -0400 Received: from mx1.dismail.de (localhost [127.0.0.1]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 32b3ce11; Wed, 6 Jul 2022 23:51:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=dismail.de; h= mime-version:date:content-type:content-transfer-encoding:from :message-id:subject:to:in-reply-to:references; s=20190914; bh=M3 lAaEhkW86YkTagxi7uVUSv51d6g7TerXXrvKBSwCI=; b=iclNkuBRM/HOGMQfE/ icAjrYe+AI6t7hKmghf4R+cC1npyLHk84fC8cSS7uPGOP0LfDowl3Co+mcsVucye mq0VPYPUANl8NBVlJF8DlolCwzEJ7y/jKQgORYnxe6mE1SLvodTuZtlrg7g9XnXn sXiocHBxvLbrkXaB7ggAa8gdpQvnHGdc/STxGescxAP9rmNM9noH64Xqv+fwprty +H/GhryNdpKjm63XjMI93s+egY4QSbZM6OuwJnj0L6qrtkbX94uqYZtPkIR4ltuB N2B1gQHmPfHBGBOk9QGSiu2bp5xZ7JEB822fxsrRw+/TEpWhgmNLk7pPn7eZDzf8 CCgw== Received: from smtp1.dismail.de ( [10.240.26.11]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 655320fa; Wed, 6 Jul 2022 23:51:21 +0200 (CEST) Received: from smtp1.dismail.de (localhost [127.0.0.1]) by smtp1.dismail.de (OpenSMTPD) with ESMTP id e411c72a; Wed, 6 Jul 2022 23:51:21 +0200 (CEST) Received: by dismail.de (OpenSMTPD) with ESMTPSA id 097f58c9 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 6 Jul 2022 23:51:20 +0200 (CEST) MIME-Version: 1.0 Date: Wed, 06 Jul 2022 21:51:19 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: RainLoop/1.16.0a Message-ID: <6a272ff438ca4e2efc8e196c9160f857@dismail.de> In-Reply-To: <756a905107d7783bab238091d668fddbc1e712ab.camel@gmail.com> References: <756a905107d7783bab238091d668fddbc1e712ab.camel@gmail.com> <20220704211759.8314-1-jbranso@dismail.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: jbranso@dismail.de X-ACL-Warn: , jbranso--- via Guix-patches From: jbranso--- via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1657145926; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ZSTDv71i0TR1rhol/fEHS9350eUHmpLQCobyeRK/z8c=; b=UM2FTLq76mByuF+R21AZ+R6SUSA/zxnF3t4m/+G0/afh5nSo36ChXWOEJDrwljfuGMcSJr vk3yu+evtxUTHbn5V2lEX25JhljbLelagdXtJT1iYBgnENtc/OOKepe+Kdz1LDCsi4qz0M IzDa/Chvzeb4LGm5D9fz3rDDTfdIWwQGylHRO86F+axB4hNSL0obthmJ+6KLnq00q8/XZ9 q6BgCiFN+m9srdMRLRhYkEHez6cimj4Nt0kVR7TAs8oZcMb5l/oy5G+7X46lrfNepraJ1l E5QqGcz6aAZs9lb7HNf1pcH7ELcy5uHx6CnrmnaIQRSduInhljV7GOa00mtMLQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657145926; a=rsa-sha256; cv=none; b=VJpCn0Tk8qCtMBuIZYbRQt5cqODTXlcdBzT8x2GTuO7ttukKTdTuN9k5/rh32NBiQQV4ev 7tudo6D737VEm16yBqeTNvbftcZnbj4gaO5B9IdJplR9/xuXTGUkn8PtrpNIt9yk3Z7JyL oNZzxtbz3uBzNE5eLpzL79HSC6K4iWaXkPEVNClSKQbaU+gzi398QyWpKVQWRXwvFv9a0n 2BfiJ18vYYZsrnqgZpWRdnRmAL6bkOqM3MhDcnJz4YKOry0vgLfHnSJ+ciokvNIKYNBKYS tlt2o4zRENZvo2JpGe3QwAjydfWI8bA8hxJLTmfY9CC04W4UxSJ8K37lfQkySA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=dismail.de header.s=20190914 header.b=iclNkuBR; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.35 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=dismail.de header.s=20190914 header.b=iclNkuBR; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: CAE5419107 X-Spam-Score: -4.35 X-Migadu-Scanner: scn0.migadu.com X-TUID: vmrQk60WB7do July 6, 2022 12:27 AM, "Liliana Marie Prikler" wrote: > Am Montag, dem 04.07.2022 um 17:17 -0400 schrieb Joshua Branson: >=20 >>=20Openmstpd-configuration may only be configured by a config-file.=20 >>=20This >> patch, enables one to configure opensmtpd by using some guile record >> types (defined via define-record-type*). >>=20 >>=20* gnu/services/mail.scm: New records (opensmtpd-table- >> configuration), >> (opensmtpd-ca-configuration), >> (opensmtpd-pki-configuration), >> (opensmtpd-action-local-delivery-configuration), >> (opensmtpd-maildir-configuration), >> (opensmtpd-mda-configuration), >> (opensmtpd-action-relay-configuration), >> (opensmtpd-option-configuration), >> (opensmtpd-filter-phase-configuration), >> (opensmtpd-filter-configuration), >> (opensmtpd-listen-on-configuration), >> (opensmtpd-listen-on-socket-configuration), >> (opensmtpd-match-configuration), >> (opensmtpd-smtp-configuration), >> (opensmtpd-srs-configuration), >> (opensmtpd-queue-configuration), and >> (opensmtpd-configuration). >=20 >=20Not a ChangeLog. I'll actually go and learn how to do that thanks. >=20 >>=20New procedures: false?, is-value-right-type, add-comma-or-string, >> file-exists?, list-of-procedures->string, string-in-list?, my- >> sanitize, >> opensmtpd-filter-chain?, throw-error-duplicate-option, >> sanitize-list-of-options-for-match-configuration, sanitize-filters, >> list-has-duplicates-or-non-filters?, >> filter-phase-has-message-and-value?, >> filter-phase-decision-lacks-proper-message?, >> filter-phase-lacks-proper-value?, >> filter-phase-has-incorrect-junk-or-bypass?, >> filter-phase-junks-after-commit?, >> list-of-unique-filter-or-filter-phase?, throw-error, >> contains-duplicate?, list-of-type?, list-of-strings?, >> list-of-unique-opensmtpd-option-configuration?, >> list-of-opensmtpd-ca-configuration?, >> list-of-opensmtpd-pki-configuration?, >> list-of-opensmtpd-listen-on-configuration?, >> list-of-unique-opensmtpd-match-configuration?, list-of-strings- >> string, >> assoc-list? assoc-list, variable->string, >> table-whose-data-are-assoc-list?, >> table-whose-data-are-a-list-of-strings?, assoc-list->string, >> opensmtpd-table-configuration->string, >> opensmtpd-listen-on-configuration->string, >> opensmtpd-listen-on-socket-configuration->string, >> opensmtpd-action-relay-configuration->string, >> opensmtpd-lmtp-configuration->string, >> opensmtpd-mda-configuration->string, >> opensmtpd-maildir-configuration->string, >> opensmtpd-action-local-delivery-configuration->string, >> opensmtpd-action->string, opensmtpd-option-configuration->string, >> opensmtpd-match-configuration->string, >> opensmtpd-ca-configuration->string, opensmtpd-pki-configuration- >> string, >> generate-filter-chain-name, opensmtpd-filter-chain->string, >> opensmtpd-filter-phase-configuration->string, opensmtpd-filters- >> string, >> opensmtpd-configuration-listen->string, >> opensmtpd-configuration-srs->string, >> opensmtpd-smtp-configuration->string, >> opensmtpd-configuration-queue->string, get-opensmtpd-actions, >> get-opensmtpd-pki-configurations, get-opensmtpd-filters, flatten, >> get-opensmtpd-tables, opensmtpd-configuration-fieldname->string, >> list-of-records->string, opensmtpd-configuration->mixed-text-file. >=20 >=20Neither is this. >> * doc/guix.texi added documentation for the new records for >> opensmtpd. >=20 >=20Or this. >=20 >>=20--- >> doc/guix.texi | 1051 ++++++++++++++++++++- >> gnu/services/mail.scm | 2016 >> ++++++++++++++++++++++++++++++++++++++++- >> 2 files changed, 3056 insertions(+), 11 deletions(-) >>=20 >>=20diff --git a/doc/guix.texi b/doc/guix.texi >> index eda0956260..e8564240d1 100644 >> --- a/doc/guix.texi >> +++ b/doc/guix.texi >> @@ -24849,14 +24849,59 @@ could instantiate a dovecot service like >> this: >> @subsubheading OpenSMTPD Service >>=20 >>=20@deffn {Scheme Variable} opensmtpd-service-type >> -This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD} >> -service, whose value should be an @code{opensmtpd-configuration} >> object >> -as in this example: >> - >> -@lisp >> -(service opensmtpd-service-type >> - (opensmtpd-configuration >> - (config-file (local-file "./my-smtpd.conf")))) >> +OpenSMTPD is an easy-to-use mail transfer agent (MTA). Its >> configuration file is >> +throughly documented in @code{man 5 smtpd.conf}. OpenSMTPD >> @strong{listens} for incoming >> +mail and @strong{matches} the mail to @strong{actions}. The >> following records represent those >> +stages: >> + >> +@multitable {aaaaaaaaa} >> {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} >=20 >=20I suggest using fractions here. I'll take a look at the texinfo fractions bit. This was all generated=20 from=20an org-mode document. >=20 >>=20[...] >> +This is a string of one of these options: >> + >> +@multitable {aaaaaaaaaaaaaaaaaaaa} >> {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} >=20 >=20Same here. Btw. I did not actually check all the doc in between, so I > might be missing something. >> +@multitable {aaaaaaaaaaaaaaaaaaaaaaaaa} >> {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} >=20 >=20Likewise. >> +@multitable {aaaaaaaaaa} >> {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} >=20 >=20You get the drill. >=20 >>=20[more doc with strange multitables] >> diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm >> index d99743ac31..2a344e303e 100644 >> --- a/gnu/services/mail.scm >> +++ b/gnu/services/mail.scm >> @@ -57,8 +57,143 @@ (define-module (gnu services mail) >> mailbox-configuration >> namespace-configuration >>=20 >>=20+ opensmtpd-table-configuration >> + opensmtpd-table-configuration? >> + opensmtpd-table-configuration-name >> + opensmtpd-table-configuration-file-db >> + opensmtpd-table-configuration-data >> + >> + opensmtpd-ca-configuration >> + opensmtpd-ca-configuration? >> + opensmtpd-ca-configuration-name >> + opensmtpd-ca-configuration-file >> + >> + opensmtpd-pki-configuration >> + opensmtpd-pki-configuration? >> + opensmtpd-pki-configuration-domain >> + opensmtpd-pki-configuration-cert >> + opensmtpd-pki-configuration-key >> + opensmtpd-pki-configuration-dhe >> + >> + opensmtpd-action-local-delivery-configuration >> + opensmtpd-action-local-delivery-configuration? >> + opensmtpd-action-local-delivery-configuration-method >> + opensmtpd-action-local-delivery-configuration-alias >> + opensmtpd-action-local-delivery-configuration-ttl >> + opensmtpd-action-local-delivery-configuration-user >> + opensmtpd-action-local-delivery-configuration-userbase >> + opensmtpd-action-local-delivery-configuration-virtual >> + opensmtpd-action-local-delivery-configuration-wrapper >> + >> + opensmtpd-maildir-configuration >> + opensmtpd-maildir-configuration? >> + opensmtpd-maildir-configuration-pathname >> + opensmtpd-maildir-configuration-junk >> + >> + opensmtpd-mda-configuration >> + opensmtpd-mda-configuration-name >> + opensmtpd-mda-configuration-command >> + >> + opensmtpd-action-relay-configuration >> + opensmtpd-action-relay-configuration? >> + opensmtpd-action-relay-configuration-backup >> + opensmtpd-action-relay-configuration-backup-mx >> + opensmtpd-action-relay-configuration-helo >> + opensmtpd-action-relay-configuration-domain >> + opensmtpd-action-relay-configuration-host >> + opensmtpd-action-relay-configuration-pki >> + opensmtpd-action-relay-configuration-srs >> + opensmtpd-action-relay-configuration-tls >> + opensmtpd-action-relay-configuration-auth >> + opensmtpd-action-relay-configuration-mail-from >> + opensmtpd-action-relay-configuration-src >> + >> +=20=20=20=20=20 opensmtpd-option-configuration >> + opensmtpd-option-configuration? >> + opensmtpd-option-configuration-option >> + opensmtpd-option-configuration-not >> + opensmtpd-option-configuration-regex >> + opensmtpd-option-configuration-data >> + >> + opensmtpd-filter-phase-configuration >> + opensmtpd-filter-phase-configuration? >> + opensmtpd-filter-phase-configuration-name >> + opensmtpd-filter-phase-configuration-phase-name >> + opensmtpd-filter-phase-configuration-options >> + opensmtpd-filter-phase-configuration-decision >> + opensmtpd-filter-phase-configuration-message >> + opensmtpd-filter-phase-configuration-value >> + >> + opensmtpd-filter-configuration >> + opensmtpd-filter-configuration? >> + opensmtpd-filter-configuration-name >> + opensmtpd-filter-configuration-proc >> + >> + opensmtpd-listen-on-configuration >> + opensmtpd-listen-on-configuration? >> + opensmtpd-listen-on-configuration-interface >> + opensmtpd-listen-on-configuration-family >> + opensmtpd-listen-on-configuration-auth >> + opensmtpd-listen-on-configuration-auth-optional >> + opensmtpd-listen-on-configuration-filters >> + opensmtpd-listen-on-configuration-hostname >> + opensmtpd-listen-on-configuration-hostnames >> + opensmtpd-listen-on-configuration-mask-src >> + opensmtpd-listen-on-configuration-disable-dsn >> + opensmtpd-listen-on-configuration-pki >> + opensmtpd-listen-on-configuration-port >> + opensmtpd-listen-on-configuration-proxy-v2 >> + opensmtpd-listen-on-configuration-received-auth >> + opensmtpd-listen-on-configuration-senders >> + opensmtpd-listen-on-configuration-secure-connection >> + opensmtpd-listen-on-configuration-tag >> + >> + opensmtpd-listen-on-socket-configuration >> + opensmtpd-listen-on-socket-configuration? >> + opensmtpd-listen-on-socket-configuration-filters >> + opensmtpd-listen-on-socket-configuration-mask-src >> + opensmtpd-listen-on-socket-configuration-tag >> + >> + opensmtpd-match-configuration >> + opensmtpd-match-configuration? >> + opensmtpd-match-configuration-action >> + opensmtpd-match-configuration-options >> + >> + opensmtpd-smtp-configuration >> + opensmtpd-smtp-configuration? >> + opensmtpd-smtp-configuration-ciphers >> + opensmtpd-smtp-configuration-limit-max-mails >> + opensmtpd-smtp-configuration-limit-max-rcpt >> + opensmtpd-smtp-configuration-max-message-size >> + opensmtpd-smtp-configuration-sub-addr-delim character >> + >> + opensmtpd-srs-configuration >> + opensmtpd-srs-configuration? >> + opensmtpd-srs-configuration-key >> + opensmtpd-srs-configuration-backup-key >> + opensmtpd-srs-configuration-ttl-delay >> + >> + opensmtpd-queue-configuration >> + opensmtpd-queue-configuration? >> + opensmtpd-queue-configuration-compression >> + opensmtpd-queue-configuration-encryption >> + opensmtpd-queue-configuration-ttl-delay >> + >> opensmtpd-configuration >> opensmtpd-configuration? >> + opensmtpd-package >> + opensmtpd-config-file >> + opensmtpd-configuration-bounce >> + opensmtpd-configuration-listen-ons >> + opensmtpd-configuration-listen-on-socket >> + opensmtpd-configuration-includes >> + opensmtpd-configuration-matches >> + opensmtpd-configuration-mda-wrappers >> + opensmtpd-configuration-mta-max-deferred >> + opensmtpd-configuration-srs >> + opensmtpd-configuration-smtp >> + opensmtpd-configuration-queue >> + >> opensmtpd-service-type >> %default-opensmtpd-config-file >>=20 >>=20@@ -1651,13 +1786,1888 @@ (define (generate-dovecot-documentation) >> ;;; OpenSMTPD. >> ;;; >>=20 >>=20+;; some fieldnames have a default value of #f, which is ok. They >> cannot have a value of #t. >> +;; for example opensmtpd-table-configuration-data can be #f, BUT NOT >> true. >> +;; my/sanitize procedure tests values to see if they are of the >> right kind. >> +;; procedure false? is needed to allow fields like 'values' to be >> blank, (empty), or #f BUT also >> +;; have a value like a list of strings. >> +(define (false? var) >> + (eq? #f var)) >=20 >=20I'm pretty sure it'd be fine to use not in lieu of false?, even at th= e > risk of matching nil. Sounds ok. I may need to double check that there are no places that have nil values. >=20 >>=20+;; this procedure takes in a var and a list of procedures. It loop= s >> through list of procedures passing in var to each. >> +;; if one procedure returns #t, the function returns true.=20 >>=20Otherwise #f. >> +;; TODO for fun rewrite this using map >> +;; If I rewrote it in map, then it may help with sanitizing. >> +;; eg: I could then potentially easily sanitize vars with lambda >> procedures. >> +(define (is-value-right-type? var list-of-procedures record >> fieldname) >> + (if (null? list-of-procedures) >> + #f >> + (cond [(procedure? (car list-of-procedures)) >> + (if ((car list-of-procedures) var) >> + #t >> + (is-value-right-type? var (cdr list-of- >> procedures) record fieldname))] >> + [(and (sanitize-configuration? (car list-of- >> procedures)) >> + (sanitize-configuration-error-if-proc-fails (car >> list-of-procedures)) >> + (if ((sanitize-configuration-proc (car list-of- >> procedures)) var) >> + #t >> + (begin >> + (apply string-append >> + (sanitize-configuration-error- >> message (car list-of-procedures))) >> + (throw 'bad! var))))] >> + [else (if ((sanitize-configuration-proc (car list-of- >> procedures)) var) >> + #t >> + (is-value-right-type? var (cdr list-of- >> procedures) record fieldname))]))) >=20 >=20Don't we have field sanitizers already that make this obsolete? >=20 >>=20+;; converts strings like this: >> +;; "apple, ham, cherry" -> "apple, ham, or cherry" >> +;; "pineapple" -> "pinneapple". >> +;; "cheese, grapefruit, or jam" -> "cheese, grapefruit, or jam" >> +(define (add-comma-or string) >> + (define last-comma-location (string-rindex string #\,)) >> + (if last-comma-location >> + (if (string-contains string ", or" last-comma-location) >> + string >> + (string-replace string ", or" last-comma-location >> + (+ 1 last-comma-location))) >> + string)) >> + >> +;; I could test for read-ability of a file, but then I would have to >> +;; test the program as root everytime instead of as a normal user... >> +(define (file-exists? file) >> +(if (string? file) >> + (access? file F_OK) >> + #f)) >=20 >=20Is this not part of the Guile standard library? I do not believe that guile has a file-exists? thunk.=20=20 I=20could use (access? file F_OK) every time, but I think file-exists? is easier to use. My two cents. >=20 >>=20+(define (list-of-procedures->string procedures) >> + (define string >> + (let loop ([procedures procedures]) >> + (if (null? procedures) >> + "" >> + (begin >> + (string-append >> + (cond [(eq? false? (car procedures)) >> + "#f , "] >> + [(eq? boolean? (car procedures)) >> + "boolean, "] >> + [(eq? string? (car procedures)) >> +=20=20=20=20=20=20=20=20=20=20 "string, "] >> + [(eq? integer? (car procedures)) >> + "integer, "] >> + [(eq? list-of-strings? (car procedures)) >> + "list of strings, "] >> + [(eq? assoc-list? (car procedures)) >> + "an association list, "] >> + [(eq? opensmtpd-pki-configuration? (car >> procedures)) >> + "an record, "] >> + [(eq? opensmtpd-table-configuration? (car >> procedures)) >> + "an record, "] >> + [(eq? list-of-unique-opensmtpd-match- >> configuration? (car procedures)) >> + "a list of unique > configuration> records, "] >> + [(eq? table-whose-data-are-assoc-list? (car >> procedures)) >> + (string-append >> + "an record whose >> fieldname 'values' are an assoc-list \n" >> + "(eg: (opensmtpd-table-configuration (name >> \"table\") (data '(\"joshua\" . \"$encrypted$password\")))), ")] >> + [(eq? file-exists? (car procedures)) >> + "file, "] >> + [else "has an incorrect value, "]) >> + (loop (cdr procedures))))))) >> + (add-comma-or (string-append (string-drop-right string 2) ".\n"))) >=20 >=20Using a table, map and string-join might be wiser. If this is the onl= y > place add-comma-or is used, you can replace it by=20 >=20(string-append > (string-join (butlast strings) ",") > ", or " (last strings)) > where you only need to define butlast. I'll take a look. >=20 >>=20+;; TODO can I M-x raise-sexp (string=3D? string var) in this >> procedure? and get rid of checking >> +;; if the var is a string? The previous string-in-list? had that >> check. >> +;; (string-in-list? '("hello" 5 "cat")) currently works. If I M-x >> raise-sexp (string=3D? string var) >> +;; then it will no longer work. >> +(define (string-in-list? string list) >> + (primitive-eval (cons 'or (map (lambda (var) (and (string? var) >> (string=3D? string var))) list)))) >=20 >=20Ever heard of member? Will use it. >=20 >>=20+(define (my/sanitize var record fieldname list-of-procedures) >> + (if (is-value-right-type? var list-of-procedures record fieldname) >> + var >> + (begin >> + (display (string-append "<" record "> fieldname: '" >> fieldname "' is of type " >> + (list-of-procedures->string list-of- >> procedures) "\n")) >> + (throw 'bad! var)))) >> + >> +;; Some example opensmtpd-table-configurations: >> +;; >> +;; (opensmtpd-table-configuration (name "root accounts") (data >> '(("joshua" . "root@dismail.de") ("joshua" . >> "postmaster@dismail.de")))) >> +;; (opensmtpd-table-configuration (name "root accounts") (data >> (list "mysite.me" "your-site.com"))) >> +;; TODO should support have a >> fieldname 'file'? >> +;; Or should I change name to name-or-file ? >> +(define-record-type* >> + opensmtpd-table-configuration make-opensmtpd-table-configuration >> + opensmtpd-table-configuration? >> + this-record >> + (name opensmtpd-table-configuration-name ;; string >> + (default #f) >> + (sanitize (lambda (var) >> + (my/sanitize var "opensmtpd-table-configuration" >> "name" (list string?))))) >> + (file-db opensmtpd-table-configuration-file-db >> + (default #f) >> + (sanitize (lambda (var) >> + (my/sanitize var "opensmtpd-table- >> configuration" "file-db" >> + (list boolean?))))) >> + ;; FIXME support an aliasing table as described here: >> + ;; https://man.openbsd.org/table.5 >> + ;; One may have to use the record file for this. I don't think >> tables support a table like this: >> + ;; table "name" { joshua =3D >> joshua@gnucode.me,joshua@gnu-hurd.com,joshua@propernaming.org, root = =3D >> root@gnucode.me } >> + ;; If values is an absolute filename, then it will use said >> filename to house the table info. >> + ;; filename must be an absolute filename. >> + (data opensmtpd-table-configuration-data >> + (default #f) >> + (sanitize (lambda (var) >> + (my/sanitize var "opensmtpd-table- >> configuration" "values" >> + (list file-exists? list-of- >> strings? assoc-list?))))) >> + ;; is a list of values or key values >> + ;; eg: (list "mysite.me" "your-site.com") >> + ;; eg: (list ("joshua" . "joshua@gnu.org") ("james" . >> "james@gnu.org")) >> + ;; I am currently making these values be as assocation list of >> strings only. >> + ;; FIXME should I allow a var like this? >> + ;; (list (cons "gnucode.me" 234.949.392.23)) >> + ;; can be of type: (quote list-of-strings) or (quote assoc-list) >> + ;; (opensmtpd-table-configuration-type record) returns the values' >> type. The user SHOULD NEVER set the type. >> + ;; TODO jpoiret: on irc reccomends that I just use an outside >> function to determine fieldname 'values', type. >> + ;; it would be "simpler" and possibly easier for the next person >> working on this code to understand what is happening. >> + (type opensmtpd-table-configuration-type >> + (default #f) >> + (thunked) >> + (sanitize (lambda (var) >> + (cond [(opensmtpd-table-configuration-data this- >> record) >> + (if (list-of-strings? (opensmtpd-table- >> configuration-data this-record)) >> + (quote list-of-strings) >> + (quote assoc-list))] >=20 >=20Just a quick side note, we don't usually intermix [ and (. It's all (= . Yeah I saw that in the coding style. I'll fix it. >=20 >>=20[skipping a bit of stuff, may check later...] >> +(define-record-type* >> + opensmtpd-option-configuration make-opensmtpd-option-configuration >> + opensmtpd-option-configuration? >> + (option opensmtpd-option-configuration-option >> + (default #f) >> + (sanitize (lambda (var) >> + (if (and (string? var) >> + (or (string-in-list? var (list >> "fcrdns" "rdns" >> + "src" >> "helo" >> + "auth" >> "mail-from" >> + "rcpt-to" >> + "for" >> + "for any" >> "for local" >> + "for >> domain" "for rcpt-to" >> + "from any" >> "from auth" >> + "from >> local" "from mail-from" >> + "from >> rdns" "from socket" >> + "from src" >> "auth" >> + "helo" >> "mail-from" >> + "rcpt-to" >> "tag" "tls" >> + )))) >> + var >> + (begin >> + (display (string-append "> option-configuration> fieldname: 'option' is of type \n" >> + "string. The >> string can be either 'fcrdns', \n" >> + " 'rdns', 'src', >> 'helo', 'auth', 'mail-from', or 'rcpt-to', \n" >> + "'for', 'for >> any', 'for local', 'for domain', 'for rcpt-to', \n" >> + "'from any', >> 'from auth', 'from local', 'from mail-from', 'from rdns', 'from >> socket', \n" >> + "'from src', >> 'auth helo', 'mail-from', 'rcpt-to', 'tag', or 'tls' \n" >> + )) >> + (throw 'bad! var)))))) >=20 >=20This is a little verbose for what it does. Fair I suppose. I'll see if I can shorten it. >=20 >>=20+(define-record-type* >=20 >=20What is a "listen-on"? "listen-on" refers to the "listen on" in smtpd.conf: https://man.openbsd.org/smtpd.conf lan_addr =3D "192.168.0.1" listen on $lan_addr listen on $lan_addr tls auth >> +(define-record-type* > configuration> >=20 >=20Again, could this just be ? I would prefer to have two data types for "listen on" and "listen on socket". "listen on socket" only supports 3 options, where "listen on" supports 19.=20=20 https://man.openbsd.org/smtpd.conf ;;valid=20record (openstmpd-listen-on-configuration (tag "port-48") (port 48)) ;;invalid record and will result in an error as it should. (openstmpd-listen-on-socket-configuration (tag "port-48") (port 48)) >=20 >>=20(define-record-type* >> opensmtpd-configuration make-opensmtpd-configuration >> opensmtpd-configuration? >> - (package opensmtpd-configuration-package >> - (default opensmtpd)) >> + (package opensmtpd-configuration-package >> + (default opensmtpd)) >> (config-file opensmtpd-configuration-config-file >> - (default %default-opensmtpd-config-file))) >> + (default #f)) >> + ;; FIXME/TODO should I include a admd authservid entry? >> + >> + ;; TODO sanitize this properly with perhaps a > configuration>. >> + (bounce opensmtpd-configuration-bounce >> + (default #f) >> + (sanitize (lambda (var) >> + (my/sanitize var "opensmtpd-configuration" >> "bounce" >> + (list false? list?))))) >> + (cas opensmtpd-configuration-cas >> + (default #f) >> + (sanitize (lambda (var) >> + (my/sanitize var "opensmtpd-configuration" "cas" >> + (list false? list-of-opensmtpd-ca- >> configuration?))))) >> + ;; list of many records of type opensmtpd-listen-on-configuration >> + (listen-ons opensmtpd-configuration-listen-ons >=20 >=20What does opensmtpd acutally listen on? >From the documentation: listen on interface [family] [options] Listen on the interface for incoming connections, using the same synt= ax as ifconfig(8). The interface parameter may also be an interface group= , an IP address, or a domain name. Listening can optionally be restricted= to a specific address family, which can be either inet4 or inet6.=20 listen=20on socket [options] Listen for incoming SMTP connections on the Unix domain socket /var/r= un/smtpd.sock. This is done by default, even if the directive is absent.= =20 >=20 >> [...] >=20 >=20Too much to check, too little time. Maybe return later. To summarize the tasks that you have given me are: 1) Write a proper changelog. 2) define "string-in-list?" with member?=20 =20 Are there other procedures that could use this? 3) replace [] with () 4) Shorten the sanitize procedure for opensmtpd-option-configuration Thanks for reviewing! Joshua