From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2KQ2KXiqrGPeZwAAbAwnHQ (envelope-from ) for ; Wed, 28 Dec 2022 21:43:36 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GF8yKXiqrGOtwgAA9RJhRA (envelope-from ) for ; Wed, 28 Dec 2022 21:43:36 +0100 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 1A6CE3CE4B for ; Wed, 28 Dec 2022 21:43:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAdGS-0003fq-ET; Wed, 28 Dec 2022 15:43:04 -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 1pAdGR-0003fQ-2w for guix-patches@gnu.org; Wed, 28 Dec 2022 15:43:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAdGQ-0005je-R9 for guix-patches@gnu.org; Wed, 28 Dec 2022 15:43:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pAdGQ-0005PR-FB for guix-patches@gnu.org; Wed, 28 Dec 2022 15:43:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#56046] [PATCH opensmtpd-records v3] services (opensmtpd): add opensmtpd records to enhance opensmtpd-configuration. Resent-From: jbranso@dismail.de Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 28 Dec 2022 20:43:02 +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" Cc: Joshua Branson , 56046@debbugs.gnu.org Received: via spool by 56046-submit@debbugs.gnu.org id=B56046.167226016920772 (code B ref 56046); Wed, 28 Dec 2022 20:43:02 +0000 Received: (at 56046) by debbugs.gnu.org; 28 Dec 2022 20:42:49 +0000 Received: from localhost ([127.0.0.1]:58794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAdGD-0005Oy-5H for submit@debbugs.gnu.org; Wed, 28 Dec 2022 15:42:49 -0500 Received: from mx2.dismail.de ([159.69.191.136]:10650) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAdGA-0005Oi-GA for 56046@debbugs.gnu.org; Wed, 28 Dec 2022 15:42:47 -0500 Received: from mx2.dismail.de (localhost [127.0.0.1]) by mx2.dismail.de (OpenSMTPD) with ESMTP id 7dc366de; Wed, 28 Dec 2022 21:42:40 +0100 (CET) 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:cc:in-reply-to:references; s=20190914; bh=1lMazhV2Yb0sViVQHnclqYCkRYd4ZiyVP7KjCTAo+fo=; b=UgOvDUZyDm1z 3tKk7XgaP9kNWtAQCs7Ecj/WH75GasZdCcnuCzmD85513uIRlFTd8JBx7rNDtKEM NFEv/8XN7KMXpfIDYGTAJMIjhapfEYqwx9C9VmXxnC8lAL/zsqq1f6dCMqY2Ib6S +6/ZNmbFhenMgJNfBVpOLup5tmfhkY7MGpVBbJ/K1HKTQDABBzcMO159yz+0Yeun ttUFbdEacQqyONUES7lDPy3s+JgDvvFeLtBJpPvrwkCvX2yDLXsEmAe6KvjzNLHz x7BsJWvyUaUVVd28R8RJygIAcIEwn7M1YzvqEvAA3fomLfqN42OO925/2+SI66IF QD37PS3ANA== Received: from smtp1.dismail.de ( [10.240.26.11]) by mx2.dismail.de (OpenSMTPD) with ESMTP id 4e35cc36; Wed, 28 Dec 2022 21:42:39 +0100 (CET) Received: from smtp1.dismail.de (localhost [127.0.0.1]) by smtp1.dismail.de (OpenSMTPD) with ESMTP id df747f82; Wed, 28 Dec 2022 21:42:39 +0100 (CET) Received: by dismail.de (OpenSMTPD) with ESMTPSA id bc6ac4f7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 28 Dec 2022 21:42:38 +0100 (CET) MIME-Version: 1.0 Date: Wed, 28 Dec 2022 20:42:37 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: RainLoop/1.16.0a Message-ID: <69ac260cb40f16a47a6683f11f2b9af0@dismail.de> In-Reply-To: <91b2d3a6834780b36b876dd55699c2941349b5bf.camel@gmail.com> References: <91b2d3a6834780b36b876dd55699c2941349b5bf.camel@gmail.com> <8001f404c0e54baba71ef9c5536abc54275c4167.1671803496.git.joshua@gnucode.me> <37239abae388f1fadcba559b62c0aae07de9d319.camel@gmail.com> <87k02co01c.fsf@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: , Reply-to: jbranso@dismail.de X-ACL-Warn: , jbranso--- via Guix-patches From: jbranso--- 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 ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672260216; a=rsa-sha256; cv=none; b=NzmYSUV1+yCFDopFyn1Vix+Q2E8kmH2t6UWDApKPbZknj1YOUqPBqMVdhfTecV8mnsO7qh R37iWLzToetSOBE/kvVF0HhE9mfxz5KD3WtJkJVvQSbEZof0ac9tNwz2nXWKshEUv5F4RX rxA74eiB/UyRSdtEVDBnBKmvXWHgjHumzxvQd9l5ERXvgeBgCZa5fCiJjGZaSmyzkcWe3B z/9WTlEzCk5HWa6XAFn6a174y5T6ZnmzhOLgW0SscuGcs7QkRZ3Q+/90sVK5hm4znzZW1k DfexZxYpkEJhB7HuGSxTLR2n4ki6/BCAVBLiZx+F9bwfa8cS9clRTEyvfutOqw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=dismail.de header.s=20190914 header.b=UgOvDUZy; 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=1672260216; 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: 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=kEaw973DosGZOLD9Og61eZO53ueEi2vCxRxIOuJ+gRc=; b=HWwQY6RVLsxGQp5jKAl7QfZJMOVKuf29BbwDOYz3EcuP6bjNvHzT8n5kJVsX0Ks0yf8hMr WEFmLHURSZPk8AwlXNxt2A+l20uDz/8/+sQQsimgY7WcNyMCm+B39wKtML3khDqXyN6gHu Z+VZYKY6/SvZlkkbxA9g/eg3MRuAguoklYgeIM2vbple0V5JPM3Wyza2phdfcXEuX3g/WV zvHWhtwY+eP7xCnc3wqd4RK9D+tFqq7LJZ/R8W85MLF9Se2vRezWnHh5IOPIGFjvPMF+PQ DVjQe3eD+NebtyIeGBnf/XIWQIfnc3PwIH0E9fyiI17YzIMRhuw4Vs/ok38KBw== X-Spam-Score: -2.53 X-Migadu-Queue-Id: 1A6CE3CE4B Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=dismail.de header.s=20190914 header.b=UgOvDUZy; 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 X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -2.53 X-TUID: lu8RgQOF4Sje December 28, 2022 3:04 PM, "Liliana Marie Prikler" wrote: > Am Dienstag, dem 27.12.2022 um 19:16 -0500 schrieb Joshua Branson: >=20 >>=20Are you giving me a triple A+ ? :) Org generated the the like that. = I >> think you mentioned that I should use fractions last time. Sorry I >> did not do that. >=20 >=20Do you have to convert your documentation from org? Writing Texinfo > code manually is an option, as is generating it from define- > configuration IIRC. There is also nothing wrong with manually touching > up generated docs, but I imagine doing so consistently might be a bit > more adventurous. I wrote the first draft of the documentation in org. Then converted it to texinfo. I have been writing in texinfo ever since. :) >=20 >>=20If I wait 'til I implement every one of your suggestions, I will >> probably never submit it. I am really probably "perfecting" this >> service. >=20 >=20You can submit whatever, but don't expect me or any other committer t= o > upstream the patches while there are open points to address. Of course. :) I wish I could implement all of your suggestions sooner,= =20 but=20I am still learning. And I might be a bit of a slow coder. :( >> Instead of a string, take 'no-verify as symbol perhaps? >>=20 >>=20Sounds good to me. May I ask why you prefer a symbol instead of a >> string? >=20 >=20Symbols can be compared with eq?, case et al. >=20 >>>=20-;;; >>> ;;; OpenSMTPD. >>> ;;; >>> +;;; This next bit of code helps me create my own sanitizer >>> functions. >>> + >>> +;; some fieldnames have a default value of #f, which is ok.=20 >>>=20They >>> cannot have >>> +;; a value of #t. >>> +;; for example opensmtpd-table-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. >> Use less egocentric comments ;) >>=20 >>=20I'm not sure what you mean here? I know I had a comment in my task >> list that said something like my sanitizer function are probably >> better than those found in guix. Apologies for that. >=20 >=20For what it's worth, it definitely wasn't I. [1] >=20 >>>=20+(define (false? var) >>> + (eq? #f var)) >>> + >>> +;; TODO I have to have this procedure, or I need to change >>> my/sanitize >>> +;; procedure. >>> +(define (my-file-exists? file) >>> + (and (string? file) >>> + (access? file F_OK))) >> Does file-exists? not work for you? >>=20 >>=20The file-exists? function causes my-sanitize function to break. >=20 >=20Why? >=20 >>=20I think. >=20 >=20Prove it. Oh, the last time I used guile's file-exist? It broke a one of=20 my=20tests. I intend to use guile's file-exist? I just have not figured out how to yet. :) >=20 >>=20If you get rid of it, then what happens when a user types in (file >> 4), you get an raise-exception. >=20 >=20(file-exists? "(file 4)") ; =3D> #f The way I am sanitizing it, something like this happens.=20=20 A=20silly user puts this in their configuration: (opensmtpd-configuration (config-file 4)) (file-exists? (openstmtpd-configuration-config-file record)) (file-exists? 4) =3D> raise-exception >> I can probably just rework my-sanitizer function to >> deal with that possibility, but I have not yet. I would love some >> guidance on how to do that. Because I feel like having to handle that >> exception is hard. >=20 >=20From the Guile manual: >=20 >=20-- Scheme Procedure: stat object [exception-on-error?] > -- C Function: scm_stat (object, exception_on_error) > [...] > If the optional EXCEPTION_ON_ERROR argument is true, which is the > default, an exception will be raised if the underlying system call > returns an error, for example if the file is not found or is not > readable. Otherwise, an error will cause =E2=80=98stat=E2=80=99 to retu= rn =E2=80=98#f=E2=80=99. >=20 >=20Now, in (ice-9 boot-9), file-exists? is defined (assuming posix) as >=20 >=20(lambda (str) > (->bool (stat str #f))) >=20 >=20Thus, I am pretty sure that no exception should be raised from the > check ;) >=20 >>>=20+;; This procedure takes in a var and a list of procedures. It >>> loops >>> 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 >>> + (if ((car list-of-procedures) var) >>> + #t >>> + (is-value-right-type? var (cdr list-of-procedures) >>> record >>> + fieldname)))) >> Alternatively, (any (cut <> var) list-of-procedures). >>=20 >>=20You mentioned that in the last review, I just can't figure out how t= o >> use your >> suggestion. This is the code that I have in the task list WIP: >>=20 >>=20*** TODO simplify my sanitizing funcions (any (cut <> var)) >>=20 >>=20#+BEGIN_SRC scheme >> (use-modules (ice-9 curried-definitions) >> (srfi srfi-26)) >>=20 >>=20(define (((expect-any predicates) record field) var) >> (if (any (cut <> var) predicates) >> var >> (begin >> ;; code code code >> ;; how do I tell the user which function failed? >> (display "error") >> (throw 'bad! var)))) >=20 >=20All of them failed, that's the point. As for constructing a string > from a list of procedures, see list-of-procedures->string. >=20 >>=20;; here is how you use it. >> (name opensmtpd-table-name ;; string >> (default #f) >> (sanitize (lambda (var) >> (((expect-any (list string? number?)) "hello" >> "that") var)))) >>=20 >>=20#+END_SRC >>=20 >>=20Does that look close to what you want? I feel like it is way off, bu= t >> I don't know. Honestly when I say this suggestion I was completely >> blown away, I have been using (any ) and (every) in a few places to >> get rid of some uses of primitive eval. >=20 >=20I don't see that, but I do see functions that have been dropped still > mentioned in the ChangeLog. Another hint at this patch being too > convoluted for its own sake ;) How would I unconvoluted it? Use define-configuration?=20=20 >=20 >> This procedure needs a proper name, like sanitize/check-type, but >> more importantly, why not simply use define-configuration? >>=20 >>=20Yes! I have slowly been realizing that I have been clumsily re- >> inventing define-configuration. I hope to switch to define- >> configuration, because a lot of this code would go away. But I need >> to explore how define-configuration works. >> That would be quite a major change. :) >=20 >=20Manchmal erspart einem monatelange Implementier-Arbeit einen Nachmitt= ag > in der B=C3=BCcherei. >=20 >=20Cheers >=20 >=20[1] https://issues.guix.gnu.org/issue/56046#4-lineno323