submitting-opensmtpd-service-to-guixrus.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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>Submitting Opensmtpd Service to Guixrus — 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>Submitting Opensmtpd Service to Guixrus</h1><main><section class="basic-section-padding"><article><h3>by Joshua Branson — December 22, 2022</h3><div><p>EDIT 02-24-2023: Through this whole process, I have used this guide to set up email.
  2. If you are going to try to set up your own email service, do check it out:
  3. <a href="https://poolp.org/posts/2019-09-14/setting-up-a-mail-server-with-opensmtpd-dovecot-and-rspamd/">https://poolp.org/posts/2019-09-14/setting-up-a-mail-server-with-opensmtpd-dovecot-and-rspamd/</a></p><p>I was recently encouraged by the delightfully friendly raghavgururajan to try to
  4. merge my opensmtpd service project into guixrus, which is a small community
  5. actively working to upstream packages and services into guix proper. I figured,
  6. why not? Sounds like fun. The following post will describe my developmental
  7. workflow, which is probably pretty poor…</p><p>tl;dr</p><p>Soonish, I will clean up the code for a proper ~opensmtpd-service-type~ with
  8. ~opensmtpd-records~ for guix system. It may take 6 months to get it in a clean
  9. state. Until it is merged, you may find it here:</p><p><a href="https://git.sr.ht/~whereiseveryone/guixrus/commit/255875f7d86e92bb64006a59be26c64430c0c046">https://git.sr.ht/~whereiseveryone/guixrus/commit/255875f7d86e92bb64006a59be26c64430c0c046</a></p><p>The current documentation is here:</p><p><a href="https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd-records-documentation.txt">https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd-records-documentation.txt</a></p><p>My server's config is here:</p><p><a href="https://notabug.org/jbranso/linode-guix-system-configuration/src/master/linode-locke-lamora-current-config.scm">https://notabug.org/jbranso/linode-guix-system-configuration/src/master/linode-locke-lamora-current-config.scm</a></p><p>The current task list is here:</p><p><a href="https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd.org">https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd.org</a></p><p>Added, the guixrus channel to my ~/.config/guix/channels.scm</p><pre><code>cat ~/.config/guix/channels.scm
  10. (cons* (channel ;; for firefox-wayland
  11. (name 'nonguix)
  12. (url &quot;https://gitlab.com/nonguix/nonguix&quot;)
  13. ;; Enable signature verification:
  14. (introduction
  15. (make-channel-introduction
  16. &quot;897c1a470da759236cc11798f4e0a5f7d4d59fbc&quot;
  17. (openpgp-fingerprint
  18. &quot;2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5&quot;))))
  19. (channel ;; for sway-latest
  20. (name 'guixrus)
  21. (url &quot;https://git.sr.ht/~whereiseveryone/guixrus&quot;)
  22. (introduction
  23. (make-channel-introduction
  24. &quot;7c67c3a9f299517bfc4ce8235628657898dd26b2&quot;
  25. (openpgp-fingerprint
  26. &quot;CD2D 5EAA A98C CB37 DA91 D6B0 5F58 1664 7F8B E551&quot;))))
  27. %default-channels)</code></pre><p>Before I submit the patch, I should make sure that the code actually works. To
  28. do that, I logged into my gnucode.me server tried to set up the opensmtpd
  29. server.</p><pre><code>guix pull --url=https://notabug.org/jbranso/guix/src/newOpensmtpdBranch \
  30. --branch=newOpensmtpdBranch
  31. Updating channel 'guix' from Git repository at 'https://notabug.org/jbranso/guix'...
  32. guix pull: error: Git error: cannot locate remote-tracking branch 'origin/keyring'
  33. guix pull --url=https://notabug.org/jbranso/guix \
  34. --commit=8abbb6c442d135ae8e7c1cb0e17525478fafe8f0
  35. Updating channel 'guix' from Git repository at 'https://notabug.org/jbranso/guix'...
  36. guix pull: error: Git error: cannot locate remote-tracking branch 'origin/keyring'</code></pre><p>Hmm, well my opensmtpd service is NOT using signed commits. That’s probably the
  37. problem. Hmmm… Well I guess I need to start signing my commits. Generate an
  38. gpg key. grrr….</p><p>These three pages are seem promising:</p><p><a href="https://moser-isi.ethz.ch/gpg.html">https://moser-isi.ethz.ch/gpg.html</a></p><p><a href="https://wiki.debian.org/Keysigning">https://wiki.debian.org/Keysigning</a></p><p><a href="https://risanb.com/code/backup-restore-gpg-key/">https://risanb.com/code/backup-restore-gpg-key/</a></p><pre><code>gpg --full-generate-key
  39. gpg: directory '/home/joshua/.gnupg/openpgp-revocs.d' created
  40. h.lgpg: revocation certificate stored as '/home/joshua/.gnupg/openpgp-revocs.d/LOTSOFNUMBERS.rev'</code></pre><p>I copied my Revocation-Certificate into my spare usb:</p><pre><code>sudo cp .gnupg/openpgp-revocs.d/LOTSOFNUMBERS.rev /mnt/gnucode.gpg.rev</code></pre><p>Let’s export my gpg key to the server.</p><pre><code>gpg --auto-key-locate keyserver -a --send-keys 67A42A3CC23F979886F9686C750BCFEF3A579572
  41. gpg -a --export gnucode
  42. -----BEGIN PGP PUBLIC KEY BLOCK-----
  43. mQINBGOSU7sBEAC/8renj2OgTHKJfbqz7CRplPQ0su8aasJXTkunx70IhVpTFBS+
  44. 9Bwvjbo7HM2aBYD/NYa6n24J3OXla17uDxFt2i63ojhbl5AVntac3ZOeyn661Y2U
  45. r9szIRM+edTieWZZvY5G49ZFTH5VJ+jZS2leRLpIqsYCst+Ru61MdUUggBNvPgBm
  46. q97HAylBqQs0kf7XfctyqKbkChLsvkuD5cR1X8BQL8KAn/KDXrDSwj4hIO+tSdv5
  47. VmaTC+6/xbdqfq6gpywJMEPkLNUjCArlF+Oz5UqQvLh1lRXWPejzFa0LmXsviqb3
  48. RmQh+9cNvDVge+kYIRWHhCXY5dTau7ABnYsgxnW3zlBkFNbc+I5Sqiz6LDcuInlA
  49. QznFw90GL3l0+1WGzeAD5DhNx6hgpOYvFZV7S3OgbOGeOHvF7bFBixB6Pa3oByMn
  50. euKqol+rOZiUkjcaxo5XUKsglFLgOaxfmZujO7lwoipYXxiyD7jf1+ou1WZ5C3l+
  51. YCOnia2qWE5DRpR/WDBRLQl3ZrCUtDQW7dKNAuweEgDT5T53k2m3Gqu1Z28SrzIS
  52. is+SHZcZhv4dx9Cs6sX6me3WzQ3wgoI9DNW5v8XGitaGQFjIRI33Y8MeGjEBMip3
  53. ZnT6Cl8WJgd0JBXsPQnKw1EO1sh2S5cU5drvHkuCPMA/PaBb8XrNpobSlwARAQAB
  54. tDNKb3NodWEgQWxsZW4gQnJhbnNvbiAoZ251Y29kZSkgPGpicmFuc29AZGlzbWFp
  55. bC5kZT6JAk4EEwEIADgWIQRnpCo8wj+XmIb5aGx1C8/vOleVcgUCY5JTuwIbAwUL
  56. CQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRB1C8/vOleVcgwwEACp4ZwBIM/4Udc9
  57. ndZvUJeegSP0W7o86v+9ELXfXdX99ZO0iErr6/XTWxov0mw7AaoDJR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MpUBFbk5OqLsMqPbL2VvL6x1zgg4P0LmGQYoikKiwmPl/OyRQW6btWCG
  90. 1f7+w1RrcKjUANLQNjXm
  91. =Vl9S
  92. -----END PGP PUBLIC KEY BLOCK-----
  93. gpg -a --export gnucode &gt; gnucode.pub
  94. sudo cp gnucode.pub /mnt/</code></pre><p>Now let’s backup the gpg key.</p><pre><code> gpg --export-secret-keys --armor gnucode &gt; secret-key-backup.asc
  95. sudo mv secret-key-backup.asc /mnt/</code></pre><p>If I ever need to move that gpg key to another computer, all I have to do is:</p><pre><code>gpg --import /path/to/secret-key-backup.asc</code></pre><p>Let’s try testing a signed commit.</p><pre><code>git config --global commit.gpgsign true</code></pre><p><a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key">https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key</a></p><pre><code>gpg --list-secret-keys --keyid-format=long
  96. # git config --global user.signingkey MYSIGNINGKEY
  97. git config --global alias.logs &quot;log --show-signature&quot;
  98. git commit -m &quot;mail.scm: minor sanitization improvements.&quot;</code></pre><p>Ok well let’s try this to see what the error was:</p><pre><code>GIT_TRACE=1 git commit -m &quot;blah&quot; -S
  99. 23:07:37.656401 git.c:460 trace: built-in: git commit -m blah -S
  100. 23:07:37.678825 run-command.c:655 trace: run_command: gpg --status-fd=2 -bsau 750BCFEF3A579572
  101. error: gpg failed to sign the data
  102. fatal: failed to write commit object
  103. gpg --status-fd=2 -bsau 750BCFEF3A579572</code></pre><p>As I was running through the above command, I realized that, it is possible that
  104. I did not have pinentry installed:</p><pre><code>guix install pinentry
  105. git logs</code></pre><p>Now I think I will try rebooting and check to see if I can still sign git
  106. commits.</p><p>And after I rebooted, I cannot sign commits with emacs…</p><p>Emacs says “hint: Waiting for your editor to close the file…”
  107. “Waiting for Emacs”</p><p>Well online, I see this as a possible solution</p><pre><code>git config --global core.editor emacs</code></pre><p>Well that didn’t quite work. I was able to squash two commits, via emacs, but
  108. only after I had the gpg agent had cached my private key password. That makes
  109. me think that magit is having a hard time querying my for my password.</p><p>Well let me try updating doom emacs. I doubt that will work, but I’ll try it.
  110. That didn’t work. :(</p><p>Well I found a possible error here:</p><p><a href="https://github.com/magit/with-editor/issues/69">https://github.com/magit/with-editor/issues/69</a></p><p><a href="https://emacs.stackexchange.com/questions/74097/magit-cannot-commit-emacsclient-on-path-pop-os">https://emacs.stackexchange.com/questions/74097/magit-cannot-commit-emacsclient-on-path-pop-os</a></p><p><a href="https://magit.vc/manual/with-editor/Configuring-With_002dEditor.html">https://magit.vc/manual/with-editor/Configuring-With_002dEditor.html</a></p><p>Then I thought, how about I disable the with-editor elisp package that doom
  111. emacs ships and instead <code>guix install emacs-with-editor</code>. Let’s try that.</p><pre><code>cat .doom.d/packages.el | grep with-editor
  112. (package! with-editor :disable t)
  113. doom upgrade
  114. doom sync
  115. guix install emacs-with-editor</code></pre><p>Nope. That didn’t work either. Hmmm. I can get emacs to commit the message,
  116. after the gpg agent caches my key’s password.</p><p>Well let’s try running emacs without any configuration: <code>emacs -q</code>. Nope. That
  117. also didn’t work. :(</p><p>My current theory is that my wayland only session is prohibiting the pinentry
  118. from displaying, which is NOT allowing me to enter in my gpg password. I shall
  119. try temporarily enabling Xwayland and see if that fixed it.</p><pre><code>cat config | grep xwayland
  120. # disable xwayland. Just trying it out
  121. xwayland enable</code></pre><p>Yup! That fixed it. With the above, I can now sign my commits with emacs! But
  122. I would rather keep my wayland only session. Let’s try pinetry-bemenu:</p><pre><code>guix package -i pinentry-bemenu -r pinentry
  123. cat config | grep xwayland
  124. # disable xwayland.
  125. xwayland disable</code></pre><p>Well that didn’t work. Let’s try pinetry-gnome3.</p><pre><code>guix package -r pinentry-bemenu -i pinentry-gnome3</code></pre><p>Nope. It’s X only. Let’s try qt:</p><pre><code>guix package -r pinentry-gnome3 -i pinentry-qt</code></pre><p>Nope. That also seems to be X only. grr. Maybe this bemenu thing works, but I
  126. need to configure it properly.</p><p>Well let’s install pinentry, and temporarily enable xwayland.</p><pre><code>guix package -r pinentry-tty -i pinentry
  127. cat config | grep xwayland
  128. # enable xwayland.
  129. xwayland enable</code></pre><p>Well I should probably try eventually to edit <code>.config/gpg.conf</code> and tell it to
  130. use pinentry-bemu as the pinentry program.</p><p>I think that spending all that time working on getting gpg key signing to work
  131. was probably a big waste of time. :( I think instead of keeping my opensmtpd
  132. code in guix-src/gnu/services/mail.scm, I will move it to
  133. guixrus/services/opensmtpd.scm. Then I can just copy opensmtpd.scm file to my
  134. linode server, and manually load in that code to start my opensmtpd service.</p><p>First I will delete the opensmtpd record stuff in gnu/services/mail.scm. I
  135. don’t want myself getting confused where I am storing my developmental code.</p><p>Now I will cp my opensmtpd.scm code into my linode service git repo.</p><pre><code>cp opensmtpd.scm ~/prog/gnu/guix/guix-config/linode-guix-system-configuration/guixrus/services/
  136. ls ~/prog/gnu/guix/guix-config/linode-guix-system-configuration/guixrus/services/opensmtpd.scm
  137. cat ~/prog/gnu/guix/guix-config/linode-guix-system-configuration/guixrus/services/opensmtpd.scm | tail
  138. /home/joshua/prog/gnu/guix/guix-config/linode-guix-system-configuration/guixrus/services/opensmtpd.scm
  139. (service-extension pam-root-service-type
  140. (const %opensmtpd-pam-services))
  141. (service-extension profile-service-type
  142. (compose list opensmtpd-configuration-package))
  143. (service-extension shepherd-root-service-type
  144. opensmtpd-shepherd-service)
  145. (service-extension setuid-program-service-type
  146. opensmtpd-set-gids)))
  147. (description &quot;Run the OpenSMTPD, a lightweight @acronym{SMTP, Simple Mail
  148. Transfer Protocol} server.&quot;)))</code></pre><p>Now I will commit the changes to my linode git repo and push them.</p><pre><code>git add opensmtpd.scm
  149. git commit -m &quot;copying opensmtpd.scm from guixrus.&quot;
  150. [master 7399550] copying opensmtpd.scm from guixrus.
  151. 1 file changed, 7 insertions(+)
  152. rename opensmtpd.scm =&gt; guixrus/services/opensmtpd.scm (99%)</code></pre><p>Hmmm, was that commit signed? No idea.</p><p>Now let’s push that commit.</p><pre><code>git push</code></pre><p>Now let's log into the gnucode service and pull that commit.</p><pre><code>git pull
  153. cat opensmtpd.scm | tail
  154. Updating a8d88b9..7399550
  155. Fast-forward
  156. opensmtpd.scm =&gt; guixrus/services/opensmtpd.scm | 7 +++++++
  157. 1 file changed, 7 insertions(+)
  158. rename opensmtpd.scm =&gt; guixrus/services/opensmtpd.scm (99%)</code></pre><p>I am realizing that it will probably be easiest to reconfigure my server with my
  159. opensmtpd records, if my server has the same directory structure as my local
  160. machine. Namely my git repos are in the same directories. So I did some changes
  161. on my server to make sure that my server's directory structure matches my local
  162. one. Now my server’s <code>config.scm</code> is no longer at
  163. ~/linode-guix-system-configuration/linode-locke-lamora-current-config.scm. Now
  164. it is at:</p><pre><code>find . -name '*current-config.scm'
  165. ./prog/gnu/guix/guix-config/linode-guix-system-configuration/linode-locke-lamora-current-config.scm</code></pre><p>I want to make sure that my remote server has a copy of the guixrus source code
  166. with my newest commit committing <code>services/opensmtpd.scm</code>.</p><p>So, I made a guixrus repo on <a href="https://notabug.org/jbranso/guixrus">notabug.org</a>, then I pulled that repo on my server:</p><pre><code>git clone https://notabug.org/jbranso/guixrus
  167. git show HEAD | head
  168. commit 147a9ce316be2f9f7c9ed25b3e097fd84b8b01eb
  169. Author: Joshua Branson &lt;jbranso@dismail.de&gt;
  170. Date: Thu Dec 22 09:21:19 2022 -0500
  171. services (opensmtpd): add opensmtpd records to enhance opensmtpd-configuration.
  172. Openmstpd-configuration may only be configured by a config-file that
  173. uses the smtpd.conf syntax. This patch, enables one to configure
  174. opensmtpd by using record types.</code></pre><p>It would be nice to test the configuration locally, to see if it will work
  175. before I push it to the server.</p><pre><code>guix system vm linode-locke-lamora-current-config.scm
  176. guix system: error: (cert &quot;/etc/letsencrypt/live/gnucode.me/fullchain.pem&quot;) is invalid.
  177. hint: Try a file.</code></pre><p>The above is actually a good sign. I do not have that certificate locally, but
  178. it is available on the server. If that is the only error, then let’s go ahead
  179. and try to reconfigure the server.</p><p>The relevant opensmtpd-service looks like:</p><pre><code>(service opensmtpd-service-type
  180. (let ([action-receive (opensmtpd-local-delivery
  181. (name &quot;receive&quot;)
  182. (method (opensmtpd-maildir
  183. (pathname &quot;/home/%{rcpt.user}/Maildir&quot;)
  184. (junk #t)))
  185. (virtual (opensmtpd-table
  186. (name &quot;vusers&quot;)
  187. (data '((&quot;joshua@gnucode.me&quot; . &quot;joshua&quot;)
  188. (&quot;jbranso@gnucode.me&quot; . &quot;joshua&quot;)
  189. (&quot;postmaster@gnucode.me&quot; . &quot;joshua&quot;))))))]
  190. [pki-gnucode (opensmtpd-pki
  191. (domain &quot;smtp.gnucode.me&quot;)
  192. (cert &quot;/etc/letsencrypt/live/gnucode.me/fullchain.pem&quot;)
  193. (key &quot;/etc/letsencrypt/live/gnucode.me/privkey.pem&quot;))]
  194. [filter-dkimsign (opensmtpd-filter
  195. (name &quot;dkimsign&quot;)
  196. (exec #t)
  197. (proc (list (file-append opensmtpd-filter-dkimsign &quot;/libexec/opensmtpd/filter-dkimsign&quot;)
  198. &quot; -d gnucode.me -s 2021-09-22 -c relaxed/relaxed -k &quot;
  199. &quot;/etc/dkim/private.key &quot;
  200. &quot;user nobody group nogroup&quot;)))]
  201. [table-creds (opensmtpd-table
  202. (name &quot;creds&quot;)
  203. (data
  204. (list
  205. (cons &quot;joshua&quot;
  206. &quot;$6$Ec4m8FgKjT2F/03Y$k66ABdse9TzCX6qaALB3WBL9GC1rmAWJmaoSjFMpbhzat7DOpFqpnOwpbZ34wwsQYIK8RQlqwM1I/v6vsRq86.&quot;))))])
  207. (opensmtpd-configuration
  208. (interfaces
  209. (list
  210. ;; this forum help suggests that I listen on 0.0.0.0 and NOT eth0
  211. ;; https://serverfault.com/questions/726795/opensmtpd-wont-work-at-reboot
  212. ;; this listens for email from the outside world
  213. (opensmtpd-interface
  214. (interface &quot;eth0&quot;)
  215. (port 25)
  216. (secure-connection &quot;tls&quot;)
  217. (pki pki-gnucode))
  218. ;; this lets local users logged into the system via ssh send email
  219. (opensmtpd-interface
  220. (interface &quot;lo&quot;)
  221. (port 25)
  222. (secure-connection &quot;tls&quot;)
  223. (pki pki-gnucode))
  224. (opensmtpd-interface
  225. (interface &quot;eth0&quot;)
  226. (port 465)
  227. (secure-connection &quot;smtps&quot;)
  228. (pki pki-gnucode)
  229. (auth table-creds)
  230. (filters (list filter-dkimsign)))
  231. (opensmtpd-interface
  232. (interface &quot;eth0&quot;)
  233. (port 587)
  234. (secure-connection &quot;tls-require&quot;)
  235. (pki pki-gnucode)
  236. (auth table-creds)
  237. (filters (list filter-dkimsign)))))
  238. (matches (list
  239. (opensmtpd-match
  240. (action (opensmtpd-relay
  241. (name &quot;relay&quot;)))
  242. (options
  243. (list
  244. (opensmtpd-option
  245. (option &quot;for any&quot;))
  246. (opensmtpd-option
  247. (option &quot;from any&quot;))
  248. (opensmtpd-option
  249. (option &quot;auth&quot;)))))
  250. (opensmtpd-match
  251. (action action-receive)
  252. (options
  253. (list
  254. (opensmtpd-option
  255. (option &quot;from any&quot;))
  256. (opensmtpd-option
  257. (option &quot;for domain&quot;)
  258. (data (opensmtpd-table
  259. (name &quot;vdoms&quot;)
  260. (data (list &quot;gnucode.me&quot;
  261. &quot;gnu-hurd.com&quot;))))))))
  262. (opensmtpd-match
  263. (action action-receive)
  264. (options
  265. (list
  266. (opensmtpd-option
  267. (option &quot;for local&quot;))))))))))</code></pre><p>I was curious to see how outdated my server is. It’s dated apparently.</p><pre><code>guix system describe
  268. Generation 118 Aug 14 2022 02:45:18 (current)
  269. file name: /var/guix/profiles/system-118-link
  270. canonical file name: /gnu/store/7jkrafkf61bw3fdxlrlzvkrl98ys1icj-system
  271. label: GNU with Linux-Libre 5.18.16
  272. bootloader: grub
  273. root device: /dev/sda
  274. kernel: /gnu/store/iz6xn1b1dyk6pwaf6dym3jm3vwnh4gz9-linux-libre-5.18.16/bzImage
  275. channels:
  276. guix:
  277. repository URL: https://git.savannah.gnu.org/git/guix.git
  278. branch: master
  279. commit: 43decd1f7ea4ebd911199ad10c0ca555d0dffbd6
  280. configuration file: /gnu/store/rv7rhwn5kd9yxv8kayqlsgxwyhcz55ca-configuration.scm</code></pre><p>Let's try reconfiguring my server with the opensmtpd configuration.</p><pre><code>guix pull
  281. sudo guix system reconfigure linode-locke-lamora-current-config.scm
  282. In srfi/srfi-1.scm:
  283. 586:29 19 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type mingetty 7f8…&gt; …))
  284. 586:29 18 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type mingetty 7f8…&gt; …))
  285. 586:29 17 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type mingetty 7f8…&gt; …))
  286. 586:29 16 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type mingetty 7f8…&gt; …))
  287. 586:29 15 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type mingetty 7f8…&gt; …))
  288. 586:29 14 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type agetty 7f8c1…&gt; …))
  289. 586:29 13 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type syslog 7f8c1…&gt; …))
  290. 586:29 12 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type console-font…&gt; …))
  291. 586:29 11 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type virtual-term…&gt; …))
  292. 586:17 10 (map1 (#&lt;&lt;service&gt; type: #&lt;service-type opensmtpd 7f…&gt; …))
  293. In guixrus/services/opensmtpd.scm:
  294. 2567:27 9 (opensmtpd-shepherd-service #&lt;&lt;opensmtpd-configuration&gt;…&gt;)
  295. 2541:19 8 (opensmtpd-configuration-&gt;mixed-text-file #&lt;&lt;opensmtpd-…&gt;)
  296. 2496:3 7 (opensmtpd-configuration-&gt;string #&lt;&lt;opensmtpd-configura…&gt;)
  297. 2421:9 6 (opensmtpd-configuration-fieldname-&gt;string #&lt;&lt;opensmtp…&gt; …)
  298. 2430:10 5 (list-of-records-&gt;string (#&lt;&lt;opensmtpd-interface&gt; i…&gt; …) …)
  299. 2434:17 4 (loop (#&lt;&lt;opensmtpd-interface&gt; interface: &quot;eth0&quot; fam…&gt; …))
  300. 1848:5 3 (opensmtpd-interface-&gt;string #&lt;&lt;opensmtpd-interface&gt; in…&gt;)
  301. In unknown file:
  302. 2 (string-append &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; &quot;tls &quot; #&lt;unspecified&gt; &quot;p…&quot; …)
  303. In ice-9/boot-9.scm:
  304. 1685:16 1 (raise-exception _ #:continuable? _)
  305. 1685:16 0 (raise-exception _ #:continuable? _)
  306. ice-9/boot-9.scm:1685:16: In procedure raise-exception:
  307. In procedure string-append: Wrong type (expecting string): #&lt;unspecified&gt;</code></pre><p>Ahh, I know what that problem is! Let’s fix that. So now I have make a local
  308. commit. Push it to my notabug.org/guixrus, ssh into lamora, run <code>git pull</code> on
  309. the guixrus repo, then try to reconfigure. This seems like a very odd/poor way
  310. to test changes. By making a commit locally, pushing it, pulling it, and then
  311. wondering if the reconfigure will work. I should really set up guix deploy.</p><pre><code>sudo guix system reconfigure linode-locke-lamora-current-config.scm
  312. module-import-compiled 1.0MiB 1.6MiB/s 00:01 [##################] 100.0%
  313. building /gnu/store/mw8x4pbl11a5pdgxqcw2vvczdccpmicf-switch-to-system.scm.drv...
  314. making '/gnu/store/0v5sbvlx9r151gjlc906lxyhps7xx1h8-system' the current system...
  315. setting up setuid programs in '/run/setuid-programs'...
  316. populating /etc from /gnu/store/1n0l349b03h7dclwai9l0kxglb8kwyv0-etc...
  317. checking syntax of /gnu/store/51hahfmqlkj9jfxa2cqbm6dd05qrzxzd-smtpd.conf
  318. /gnu/store/51hahfmqlkj9jfxa2cqbm6dd05qrzxzd-smtpd.conf:14: syntax error
  319. /gnu/store/51hahfmqlkj9jfxa2cqbm6dd05qrzxzd-smtpd.conf:21: no such dispatcher: relay</code></pre><p>Ok, so I have a configuration error. Let’s take a look at the generated
  320. configuration file:</p><ul><li><p>The first error is this:</p><pre><code>cat /gnu/store/51hahfmqlkj9jfxa2cqbm6dd05qrzxzd-smtpd.conf | grep '&lt;&quot;&lt;&quot;'
  321. listen on eth0 filter &quot;dkimsign&quot; smtps port 465 pki smtp.gnucode.me auth &lt;&quot;&lt;&quot;creds&quot;&gt;&quot;&gt;
  322. listen on eth0 filter &quot;dkimsign&quot; tls-require port 587 pki smtp.gnucode.me auth &lt;&quot;&lt;&quot;creds&quot;&gt;&quot;&gt;</code></pre><p>It should be &lt;“creds”&gt;.</p></li><li><p>Another error is this:</p><pre><code>cat /gnu/store/51hahfmqlkj9jfxa2cqbm6dd05qrzxzd-smtpd.conf | grep match
  323. match !for any !from any !auth action &quot;relay&quot;
  324. match !from any !for domain &lt;&quot;vdoms&quot;&gt; action &quot;receive&quot;
  325. match !for local action &quot;receive&quot;</code></pre></li></ul><p>These match options should NOT be false. Let's quickly fix those issues
  326. reconfigure again:</p><pre><code>sudo guix system reconfigure linode-locke-lamora-current-config.scm
  327. checking syntax of /gnu/store/a69a5vn2r94glh58wlfq41ygfl38ikgn-smtpd.conf
  328. configuration OK</code></pre><p>That’s a good sign!</p><p>Let’s reboot and see what happens!</p><p>Well when I reboot, smtpd refused to start. Let’s look at the config file.</p><pre><code>cat /gnu/store/a69a5vn2r94glh58wlfq41ygfl38ikgn-smtpd.conf
  329. filter &quot;dkimsign&quot; proc-exec &quot;/gnu/store/n2f5waxzdzcsdvh0xydhnc174n3kingw-opensmtpd-filter-dkimsign-0.6/libexec/opensmtpd/filter-dkimsign -d gnucode.me -s 2021-09-22 -c relaxed/relaxed -k /etc/dkim/private.key user nobody group nogroup&quot;
  330. mta max-deferred 100
  331. table &quot;creds&quot; { &quot;joshua&quot; = &quot;$6$Ec4m8FgKjT2F/03Y$k66ABdse9TzCX6qaALB3WBL9GC1rmAWJmaoSjFMpbhzat7DOpFqpnOwpbZ34wwsQYIK8RQlqwM1I/v6vsRq86.&quot; }
  332. table &quot;vusers&quot; { &quot;joshua@gnucode.me&quot; = &quot;joshua&quot;, &quot;jbranso@gnucode.me&quot; = &quot;joshua&quot;, &quot;postmaster@gnucode.me&quot; = &quot;joshua&quot; }
  333. table &quot;vdoms&quot; { &quot;gnucode.me&quot;, &quot;gnu-hurd.com&quot; }
  334. pki smtp.gnucode.me cert &quot;/etc/letsencrypt/live/gnucode.me/fullchain.pem&quot;
  335. pki smtp.gnucode.me key &quot;/etc/letsencrypt/live/gnucode.me/privkey.pem&quot;
  336. listen on eth0 tls port 25 pki smtp.gnucode.me
  337. listen on lo tls port 25 pki smtp.gnucode.me
  338. listen on eth0 filter &quot;dkimsign&quot; smtps port 465 pki smtp.gnucode.me auth &lt;&quot;creds&quot;&gt;
  339. listen on eth0 filter &quot;dkimsign&quot; tls-require port 587 pki smtp.gnucode.me auth &lt;&quot;creds&quot;&gt;
  340. action &quot;relay&quot; relay
  341. action &quot;receive&quot; maildir &quot;/home/%{rcpt.user}/Maildir&quot; junk virtual &lt;&quot;vusers&quot;&gt;
  342. match for any from any auth action &quot;relay&quot;
  343. match from any for domain &lt;&quot;vdoms&quot;&gt; action &quot;receive&quot;
  344. match for local action &quot;receive&quot;</code></pre><p>It seems to be just fine...hmmm. What does the error log say?</p><pre><code>cat /var/log/maillog | tail
  345. Dec 22 10:05:41 localhost smtpd[19325]: warn: lost processor: dkimsign exited abnormally
  346. Dec 22 10:05:41 localhost smtpd[19328]: dkimsign: Can't open key file (/etc/dkim/private.key): No such file or directory
  347. Dec 22 10:05:41 localhost smtpd[19330]: warn: invalid envelope a565cee5a763bf31: unknown dispatcher
  348. Dec 22 10:05:41 localhost smtpd[19325]: Exiting
  349. Dec 22 11:22:18 localhost smtpd[268]: info: OpenSMTPD 6.8.0p2 starting
  350. Dec 22 11:22:18 localhost smtpd[269]: warn: lost processor: dkimsign exited abnormally
  351. Dec 22 11:22:18 localhost smtpd[272]: dkimsign: Can't open key file (/etc/dkim/private.key): No such file or directory
  352. Dec 22 11:22:18 localhost smtpd[274]: warn: invalid envelope a565cee5a763bf31: unknown dispatcher
  353. Dec 22 11:22:18 localhost smtpd[269]: Exiting</code></pre><p>Ok, well I think I found the problem. haha. Let’s see, ah, looks like that key
  354. is here:</p><pre><code>find . -name '*key'
  355. /etc/opensmtpd/dkimsign/2021-09-22-rsa1024-gnucode.me.key</code></pre><p>Let’s commit my current-config locally, push it upstream, pull it from my server
  356. and reconfigure.</p><pre><code>sudo guix system reconfigure linode-locke-lamora-current-config.scm
  357. checking syntax of /gnu/store/42q90z8n03zi9rx29gwdnms4sdr2g2p9-smtpd.conf
  358. configuration OK</code></pre><p>After I rebooted, smtpd still was not starting. Let’s try to find out why:</p><pre><code>cat /var/log/maillog | tail
  359. Dec 22 11:38:03 localhost smtpd[498]: warn: invalid envelope a565cee5a763bf31: unknown dispatcher
  360. Dec 22 11:38:03 localhost smtpd[493]: warn: lost processor: dkimsign exited abnormally
  361. Dec 22 11:38:03 localhost smtpd[496]: dkimsign: Can't open key file (/etc/opensmtpd/dkimsign/2021-09-22-rsa1024-gnucode.me.key): Permission denied
  362. Dec 22 11:38:03 localhost smtpd[493]: Exiting
  363. Dec 22 11:40:02 localhost dovecot: master: Dovecot v2.3.19.1 (9b53102964) starting up for imap (core dumps disabled)
  364. Dec 22 11:42:41 localhost smtpd[258]: info: OpenSMTPD 6.8.0p2 starting
  365. Dec 22 11:42:41 localhost smtpd[259]: warn: lost processor: dkimsign exited abnormally
  366. Dec 22 11:42:41 localhost smtpd[262]: dkimsign: Can't open key file (/etc/opensmtpd/dkimsign/2021-09-22-rsa1024-gnucode.me.key): Permission denied
  367. Dec 22 11:42:41 localhost smtpd[264]: warn: invalid envelope a565cee5a763bf31: unknown dispatcher
  368. Dec 22 11:42:41 localhost smtpd[259]: Exiting</code></pre><p>Ok, this is just a permissions error. That’s an easy fix! I changed a
  369. <code>sudo chown -R smtpd /etc/opensmtpd</code>. Then I got this beauty:</p><pre><code>sudo herd start smtpd
  370. Service smtpd has been started.</code></pre><p>Woo hoo! Now let’s try to send an email and see if it works!</p><p>I sent an email to gmail, and if you select an email in gmail, you can click on
  371. view original. It showed me that I did pass dkimsigning! That’s awesome! And
  372. my email was in my gmail inbox. That’s a really good sign! Now I am off to
  373. submit a patch to guixrus!</p><p>I did get a tip from someone on irc that mentioned that I should verify my
  374. dkimsigning and SPF via https://dkimvalidator.com/ And when I used that tool, I
  375. discovered that my SPF was failing, so I will need to fix that.</p></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>