Posts from November 2018

fixing Dovecot stats writer permissions

I tend to switch Linux distributions quite often. Consequently, I tend to have this process down to a fine art and it doesnt take me that long. The most time consuming element is ensuring the necessary backups are in place.

However, you normally find some package or configuration option you forgot about and my recent switch from Arch Linux to Fedora 29 and back again unearthed a strange problem with the Dovecot IMAP server I hadn't encountered before.

When I accessed my email, my automatic message filtering (using sieve) wasn't working so all messages ended up in INBOX. Worse, on every transfer, the messages were duplicated.

The logging revealed a strange error related to file permissions

$ journalctl | grep dovecot
Nov 29 08:45:32 <host> CROND[3356]: (andy) CMDOUT (msg 53/60 (12176 bytes),
delivery error (command dovecot-lda 3415 wrote to stderr: lda(andy,)
Error: net_connect_unix(/var/run/dovecot/stats-writer) failed:
Permission denied))

The permissions on this socket file were as follows:

$ ls -l /var/run/dovecot/stats-writer
srw-rw---- 1 root dovecot 0 Nov 29 08:52 /var/run/dovecot/stats-writer

Google revealed a couple of fixes. One was to simply change the permissions on the socket file to mode 777 which works for the duration of that session but the problem simply reappears after the next reboot.

Another, more promising avenue was to add a new section to '/etc/dovecot.conf'.

service stats {
   ...
}

I tried a couple of combinations which didn't work but then I went back to basics. I am processing my email as 'andy' but the dovecot processes are running as 'root' and' 'dovecot' (although they could be SETUID executables).

root      8276     1  0 11:45 ?        00:00:00 /usr/bin/dovecot -F
dovecot   8278  8276  0 11:45 ?        00:00:00 dovecot/anvil
root      8279  8276  0 11:45 ?        00:00:00 dovecot/log
root      8280  8276  0 11:45 ?        00:00:00 dovecot/config

However, I wondered if Local Delivery Agent (LDA) was somehow running as 'andy' (the error log implied this) which explained the permissions issue as the Linux user 'andy' isn't able to read that socket file.

Sure enough, the fix, inevitably, was a simple one-liner to add user 'andy' to the existing 'dovecot' group.

sudo usermod -a -G dovecot andy

in praise of Silver Searcher

Occasionally, I have to search lots of files for a pattern. It was only recently I discovered the wonderful silver searcher utility which saves me a lot of time.

To install 'ag' on Fedora, use the following (which isn't entirely obvious or intuitive if you're used to typing 'ag').

# sudo dnf install the_silver_searcher

I believe there is an Emacs interface which would save me even more time.

$ time ag 'sql statement execute time' ~

real    0m0.125s
user    0m0.128s
sys     0m0.257s

$ time find ~ -type f -print0 | xargs -0 grep -i 'sql statement execute time'

real    0m23.725s
user    0m7.965s
sys     0m1.618s

Another blog migration

It all started innocuously enough with this post from Alex Shroeder

https://octodon.social/@kensanata/101052266709264418

Writing tools. 1. Emacs 2. Wiki What about you?

I spontaneously replied.

Emacs Orgmode Nikola

This reminded me that since, I had recently migrated my desktop from Arch Linux to Fedora 29, I needed to reinstall Nikola and check that the blog I never use still could be built successfully.

Oh - how exciting. Nikola has recently released version 8.0.1[] and I was on the previous version - 7.8.15. I quickly created a Python 3 virtual environment and installed Nikola.

I generated my site as normal but encountered an error. One post failed to be processed correctly. This was strange so I created another virtual environment and tried using the tried and trusted Nikola 7.8.15 which I knew worked. Definitely.

Only, inevitably, Nikola 7.8.15 also failed. Oh well, a lot has changed since I last posted to my blog way back in January 2017. The version of Emacs has changed, the version of orgmode has changed. I examined the blog entry that was causing a problem. It was a fairly standard text article with a single source code block. As the source block was 'BASIC', the language wasn't explicitly specified. This isn't a problem in orgmode normally but the Nikola orgmode plugin got confused so I just pretended the code snippet was 'C' and everything worked again.

As I was researching the issue, I noticed that another static site generator, Hugo, had also added native orgmode support over a year ago. I had previously experimented with Hugo and found it was incredibly fast to generate my site - even when I added in my entire blog output (978 posts).

Clearly, there was no point whatsoever in experimenting with the Hugo orgmode support for a blog I never used any more. So I went ahead and did so anyway and found the Hugo orgmode support was pretty good. The orgmode headers were supported whereas Nikola used a comment section for the front matter.

Actually, there was a reason for this resurrected interest in maintaining a blog. After Google decided to pull the plug on Google Plus, I had ditched that platform in a fit of pique and experimented with Diaspora for longer form articles and Mastodon for microblogging.

The problem with Diaspora is that it doesn't currently federate with the ActivityPub protocol (which includes Mastodon sites) and the other problem is that, just like Google, it could disappear.

A Mastodon/Pleroma instance with no character limit might solve the problem but, to be honest, I prefer to read longer articles on a blog.

So I think there is still a place for a self-hosted blog, complete with an RSS feed.

What I have learned however is that blog migrations are still problematic and time-consuming. Even converting from a Markdown blog to another Markdown blog, the differences in the meta-data (categories, tags), inevitably no-one has though to standardise on a single, universal timestamp format and images (no matter where you locate them) are always a problem so there will always be some sort of migration effort required.

To guard against this, I have re-converted from orgmode to Markdown and my front-matter now consists solely of:-

---
title: "Another blog migration"
date: 2018-11-14T10:43:58Z
---

No categories, no tags, no author, no description, no keywords, no slugs, no comments.

Just words.

The National - You were a kindness

I was in a fog,
I didnt notice everything
Was coming all apart inside of me
There wasnt anyway for anyone to settle in
You made a slow disaster out of me

There's a radiant darkness upon us
I don't want you to worry
I was careful but nothing is harmless
Baby, you better hurry

You were a kindness when I was a stranger
But I wouldn't ask for what I didn't need
Everything's weird and we're always in danger
Why would you shatter somebody like me?

It doesn't work that way
Wanting not to want you won't make it so
It doesn't work that way
Don't leave me here alone

I'll do what I can to be a confident wreck
Can't feel this way forever, I mean
There wasn't any way for anyone to settle in
You made a slow disaster out of me

There's a radiant darkness upon us
But I don't want you to worry
I was careful but nothing is harmless
Baby, you better hurry

You were a kindness when I was a stranger
But I wouldn't ask for what I didn't need
Everything's weird and we're always in danger
Why would you shatter somebody like me?

It doesn't work that way
Wanting not to want you won't make it so
It doesn't work that way
Don't leave me here alone
It doesn't work that way
Wanting not to want you won't make it so
It doesn't work that way
Don't leave me here alone