status-update-april-2022.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <!DOCTYPE html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><meta name="keywords" content="GNU, Emacs, Libre Software, Hurd, Guile, Guix" /><meta name="description" content="GNUcode.me is a website focusing on libre software projects, especially the GNU project." /><link type="application/atom+xml" rel="alternate" title="GNUcode.me -- Feed" href="/feed.xml" /><a rel="me" href="https://fosstodon.org/@thegnuguy"></a><link type="text/css" href="css/footer.min.css" rel="stylesheet"></link><link type="text/css" href="css/header.min.css" rel="stylesheet"></link><link type="text/css" href="css/main.min.css" rel="stylesheet"></link><title>Status Update April 2022 — GNUcode.me</title></head><body><header><nav><ul><li><a href="index.html">GNUcode.me</a></li><li><a href="services.html">Services</a></li><li><a href="about.html">About</a></li><li><a href="business-ideas.html">Business-ideas</a></li></ul></nav></header><h1>Status Update April 2022</h1><main><section class="basic-section-padding"><article><h3>by Joshua Branson — April 01, 2022</h3><div><p>I am back to working on various records to support <code>&lt;opensmtpd-configuration&gt;</code>
  2. for the <code>opensmtpd-service-type</code>. I decided about a week ago, to just do some
  3. of the changes in the records that I want to do. Once I am satisfied with the
  4. updates, then I will work on making the code output the <code>smtpd.conf</code> file. I am
  5. fairly please with some of the changes to the records that I have made.</p><p>Feel free to play with the examples below from my repo!</p><pre><code>https://notabug.org/jbranso/linode-guix-system-configuration.git
  6. guile -L .
  7. scheme@(guile-user)&gt; ,use (opensmtpd-records)
  8. scheme@(guile-user)&gt; ,m (opensmtpd-records)
  9. (opensmtpd-table (name &quot;table&quot;) (values (list &quot;hello&quot; &quot;world&quot;)))</code></pre><p>Please note, that I am still working on changing the record names, so various
  10. things that work as described in the blog post may not work in a week or two.</p><h2>a pretty useful <code>&lt;opensmtpd-configuration&gt;</code> gives no errors</h2><pre><code>(define example-opensmtpd-configuration
  11. (let ([interface &quot;lo&quot;]
  12. [creds-table (opensmtpd-table
  13. (name &quot;creds&quot;)
  14. (values
  15. (list
  16. (cons &quot;joshua&quot;
  17. &quot;$some$encrypted$password&quot;))))]
  18. [receive-action (opensmtpd-action-local-delivery-configuration
  19. (name &quot;receive&quot;)
  20. (method (opensmtpd-maildir-configuration
  21. (pathname &quot;/home/%{rcpt.user}/Maildir&quot;)
  22. (junk #t)))
  23. (virtual (opensmtpd-table
  24. (name &quot;virtual&quot;)
  25. (values (list &quot;josh&quot; &quot;jbranso@dismail.de&quot;)))))]
  26. [filter-dkimsign (opensmtpd-filter
  27. (name &quot;dkimsign&quot;)
  28. (exec #t)
  29. (proc (string-append &quot;/path/to/dkimsign -d gnucode.me -s 2021-09-22 -c relaxed/relaxed -k &quot;
  30. &quot;/path/to/dkimsign-key user nobody group nobody&quot;)))]
  31. [smtp.gnucode.me (opensmtpd-pki
  32. (domain &quot;smtp.gnucode.me&quot;)
  33. (cert &quot;opensmtpd.scm&quot;)
  34. (key &quot;opensmtpd.scm&quot;))])
  35. (opensmtpd-configuration
  36. (mta-max-deferred 50)
  37. (queue
  38. (opensmtpd-queue-configuration
  39. (compression #t)))
  40. (smtp
  41. (opensmtpd-smtp-configuration
  42. (max-message-size &quot;10M&quot;)))
  43. (srs
  44. (opensmtpd-srs-configuration
  45. (ttl-delay &quot;5d&quot;)))
  46. (listen-ons
  47. (list
  48. (opensmtpd-listen-on
  49. (interface interface)
  50. (port 25)
  51. (secure-connection &quot;tls&quot;)
  52. (filters (list (opensmtpd-filter-phase
  53. (name &quot;noFRDNS&quot;)
  54. (phase &quot;commit&quot;)
  55. (conditions (list (opensmtpd-conditions-configuration
  56. (condition &quot;fcrdns&quot;)
  57. (not #t))))
  58. (decision &quot;disconnect&quot;)
  59. (message &quot;No FCRDNS&quot;))))
  60. (pki smtp.gnucode.me))
  61. ;; this lets local users logged into the system via ssh send email
  62. (opensmtpd-listen-on
  63. (interface interface)
  64. (port 465)
  65. (secure-connection &quot;smtps&quot;)
  66. (pki smtp.gnucode.me)
  67. (auth creds-table)
  68. (filters (list filter-dkimsign)))
  69. (opensmtpd-listen-on
  70. (interface interface)
  71. (port 587)
  72. (secure-connection &quot;tls-require&quot;)
  73. (pki smtp.gnucode.me)
  74. (auth creds-table)
  75. (filters (list filter-dkimsign)))))
  76. (matches (list
  77. (opensmtpd-match
  78. (action (opensmtpd-action-relay-configuration
  79. (name &quot;relay&quot;)))
  80. (for (opensmtpd-match-configuration
  81. (option &quot;for any&quot;)))
  82. (from (opensmtpd-match-configuration
  83. (option &quot;from any&quot;)))
  84. (auth (opensmtpd-match-configuration
  85. (option &quot;auth&quot;))))
  86. (opensmtpd-match
  87. (action receive-action)
  88. (from (opensmtpd-match-configuration
  89. (option &quot;from any&quot;)))
  90. (for (opensmtpd-match-configuration
  91. (option &quot;for domain&quot;)
  92. (value (opensmtpd-table
  93. (name &quot;domain-table&quot;)
  94. (values (list &quot;gnucode.me&quot; &quot;gnu-hurd.com&quot;)))))))
  95. (opensmtpd-match
  96. (action receive-action)
  97. (for (opensmtpd-match-configuration
  98. (option &quot;for local&quot;)))))))))</code></pre><p>However there’s still some work to do because this doesn’t work:</p><pre><code>(opensmtpd-configuration-&gt;mixed-text-file example-opensmtpd-configuration)
  99. ice-9/boot-9.scm:1685:16: In procedure raise-exception:
  100. error: value: unbound variable
  101. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
  102. scheme@(opensmtpd-records) [12]&gt; ,bt
  103. In /home/joshua/prog/gnu/guix/guix-config/linode-guix-system-configuration/opensmtpd-records.scm:
  104. 1667:3 4 (opensmtpd-configuration-&gt;mixed-text-file #&lt;&lt;opensmtpd-configuration&gt; package: #&lt;package opensmtpd@6.8.0p2 gnu/packages/mail.scm:2979 7f1e1a3…&gt;)
  105. 1628:9 3 (opensmtpd-configuration-fieldname-&gt;string _ _ _)
  106. 1634:10 2 (list-of-records-&gt;string _ _)
  107. 1669:99 1 (_ _)
  108. In ice-9/boot-9.scm:
  109. 1685:16 0 (raise-exception _ #:continuable? _)</code></pre><h2>I have also sanitized the <code>&lt;opensmtpd-conditions-configuration&gt;</code></h2><p>If you type in various incorrectly written
  110. <code>&lt;opensmtpd-conditions-configuration&gt;</code> records, then you will get some helpful
  111. error messages:</p><ol><li><p>if condition is rdns, src, helo, mail-from, rcpt-to, then they must also provide a table</p><p>What is interesting, is that I do not know how to sanitize a whole record when
  112. the record is initiated. I can only have a parent record sanitize it. For
  113. example the following record is invalid, because if the ’condition’ is “src”,
  114. then you need to provide a table. However, the following works in a REPL.</p><pre><code>(opensmtpd-conditions-configuration
  115. (condition &quot;src&quot;))</code></pre><p><code>$11 = #&lt;&lt;opensmtpd-conditions-configuration&gt; condition: &quot;src&quot; not: #f regex: #f table: #f&gt;</code></p><p>But when you put the same incorrect <code>&lt;opensmtpd-conditions-configuration&gt;</code>
  116. into an <code>&lt;opensmtpd-filter-phase&gt;</code>, then you get the right error message.</p><pre><code>(opensmtpd-filter-phase
  117. (name &quot;filter&quot;)
  118. (phase &quot;helo&quot;)
  119. (decision &quot;bypass&quot;)
  120. (conditions
  121. (list
  122. (opensmtpd-conditions-configuration
  123. (condition &quot;src&quot;)))))
  124. &lt;opensmtpd-conditions-configuration&gt;'s fieldname 'condition' values of
  125. 'src', 'helo', 'mail-from', or 'rcpt-to' need a corresponding 'table'
  126. of type &lt;opensmtpd-table&gt;. eg:
  127. (opensmtpd-conditions-configuration
  128. (condition &quot;src&quot;)
  129. (table (opensmtpd-table
  130. (name &quot;src-table&quot;)
  131. (values (list &quot;hello&quot; &quot;cat&quot;)))))
  132. ice-9/boot-9.scm:1685:16: In procedure raise-exception:
  133. Throw to key `bad!' with args `((#&lt;&lt;opensmtpd-conditions-configuration&gt; condition: &quot;mail-from&quot; not: #f regex: #f table: #f&gt;))'.
  134. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.</code></pre></li><li><p>make sure that there are no duplicate conditions</p><pre><code>(opensmtpd-filter-phase
  135. (name &quot;noFRDNS&quot;)
  136. (phase &quot;commit&quot;)
  137. (conditions (list (opensmtpd-conditions-configuration
  138. (condition &quot;fcrdns&quot;)
  139. (not #t))
  140. (opensmtpd-conditions-configuration
  141. (condition &quot;fcrdns&quot;)
  142. (not #t))))
  143. (decision &quot;disconnect&quot;)
  144. (message &quot;No FCRDNS&quot;))
  145. &lt;opensmtpd-filter-phase&gt; fieldname: 'conditions' is a list of unique
  146. &lt;opensmtpd-conditions-configuration&gt; records.
  147. ice-9/boot-9.scm:1685:16: In procedure raise-exception:
  148. Throw to key `bad!' with args `((#&lt;&lt;opensmtpd-conditions-configuration&gt; condition: &quot;fcrdns&quot; not: #t regex: #f table: #f&gt; #&lt;&lt;opensmtpd-conditions-configuration&gt; condition: &quot;fcrdns&quot; not: #t regex: #f table: #f&gt;))'.
  149. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.</code></pre></li><li><p>sanitize the phase-name</p><pre><code>(opensmtpd-filter-phase
  150. (name &quot;filter&quot;)
  151. (phase &quot;hello&quot;)
  152. (decision &quot;bypass&quot;)
  153. (conditions
  154. (list
  155. (opensmtpd-conditions-configuration
  156. (condition &quot;auth&quot;)))))
  157. &lt;opensmtpd-filter-phase&gt; fieldname: 'phase' is of type string. The string can be either 'connect', 'helo', 'mail-from', 'rcpt-to', 'data', or 'commit.'
  158. ice-9/boot-9.scm:1685:16: In procedure raise-exception:
  159. Throw to key `bad!' with args `(&quot;hello&quot;)'.
  160. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.</code></pre></li></ol><h2>Changes to the records eleminate potential errors like</h2><p>misspelling a table name, or calling an action that is not defined.</p><p>The <code>&lt;opensmtpd-configuration&gt;</code> used to be defined this way:</p><pre><code>(service opensmtpd-service
  161. (opensmtpd-configuration
  162. (includes ...)
  163. (tables ...)
  164. (pkis ...)
  165. (filters ...)
  166. (listen-on ...)
  167. (actions ...)
  168. (matches ...)))</code></pre><p>It would be possible to give a table a name of “password-table”, but then later
  169. to refer to it as “passwords-table”, which would NOT have worked. Like so:</p><pre><code>(service opensmtpd-service
  170. (opensmtpd-configuration
  171. (tables (list (opensmtpd-table
  172. (name &quot;&lt;passwords-table&gt;&quot;)
  173. (values
  174. (list
  175. (cons &quot;joshua&quot;
  176. &quot;$encrypted$password&quot;))))))
  177. (listen-on
  178. (list (opensmtpd-listen-on
  179. (auth &quot;&lt;password-table&gt;&quot; ))))
  180. (actions ...)
  181. (matches ...)))</code></pre><p>Now instead, you define the table where it is used!</p><pre><code>(opensmtpd-listen-on
  182. (interface interface)
  183. (port 587)
  184. (secure-connection &quot;tls-require&quot;)
  185. (pki smtp.gnucode.me)
  186. (auth (opensmtpd-table
  187. (name &quot;creds&quot;)
  188. (values
  189. (list
  190. (cons &quot;joshua&quot;
  191. &quot;$encrypted$password&quot;)))))
  192. (filters (list filter-dkimsign)))</code></pre></div></article></section></main><footer><p>© 2020 Joshua Branson. The text on this site is free culture under the Creative Commons Attribution Share-Alike 4.0 International license.</p><p>This website is build with Haunt, a static site generator written in Guile Scheme. Source code is <a href="https://notabug.org/jbranso/gnucode.me">available.</a></p><p>The color theme of this website is based off of the famous <a href="#3f3f3f" target="_blank">zenburn</a> theme.</p></footer></body>