You are not logged in.

#1 2012-04-15 02:29:47

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

[WORKAROUND FOUND] Sshfs mail spool - mutt says "Lock count exceeded"

Hello Archers,

My department offers both mail and ssh services on its RHEL cluster. Direct mail access, however, is restricted to on-site IP addresses. Most people who want to access their mail use webmail. This works both on- and off-site.

For a while, instead of using webmail, I've used mutt in a screen session accessed over ssh to send and receive mail. This setup was very nice, except I only have a choice ADSL or 3G internet connection. Connecting either way can be very slow, so writing an email directly over ssh can sometimes be very frustrating.

Today, I started seeing whether I could use sshfs to mount the required mail folders. This way when I'm writing an email, it's done locally and therefore fast regardless of how bad the network is.

The following commands should show what I'm doing:

sshfs host_name:/maildir maildir # host_name is defined as a Host in my ssh config
mkdir spool
sshfs host_name:/var/spool/mail spool

Then in my .muttrc I have

set spoolfile="~/spool/<remote user>"
set folder="~/maildir"

Well, this is working okay, except that whenever my inbox refreshes, I get:

Lock count exceeded, remove lock for /home/<local user>/spool/<remote user>? ([yes]/no):

This doesn't happen when I'm using mutt while logged directly into the server. I can send mail without problems. When I approve removing the lock, I receive mail correctly.

I tried searching google for both this and variations on it,

Me Googling wrote:

"Lock count exceeded, remove lock for" "ssh*" spool

but the only results did not appear relevant or useful.

I also tried getting mutt from abs and compiling in debug support; even with debugging set to level 5, there was nothing more verbose to indicate the reason for the interference.

Any ideas on how to get rid of the annoying repetitive requests for lock removal would be much appreciated.

Edit: I've since tried recompiling mutt with and without "external_dotlock", with and without flock enabled, with and without fcntl enabled. Still no love.

Last edited by /dev/zero (2012-04-15 22:28:35)

Offline

#2 2012-04-15 22:05:10

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [WORKAROUND FOUND] Sshfs mail spool - mutt says "Lock count exceeded"

Well, still no luck; however, I've created a workaround, which I'll explain for posterity.

In your ssh_config (i.e. eg ~/.ssh/config):

Host host_name
HostName your.mail.server
User remote_username
ControlPath ~/.ssh/master-%r@%h:%p
ControlMaster auto
ControlPersist yes

Create a script called ~/bin/update_mail and of course make it executable:

#! /bin/bash

spooldir=/var/spool/mail
remote_user=$(ssh -q host_name whoami)
[[ $? -eq 0 ]] || exit 1

local_user=$(whoami)
oldspool=~/.mutt/oldspool
newspool=/tmp/spool
rsync -aze ssh host_name:$spooldir/$remote_user $spooldir
[[ $? -eq 0 ]] || exit 1 # Bail out gracefully if there is a bad connection.

diff3 -me $spooldir/$local_user $oldspool $spooldir/$remote_user > $newspool
for f in $spooldir/{$local_user,$remote_user}; do
    cp $newspool $f
done
mv $newspool $oldspool
rsync -b --backup-dir="$(ssh host_name echo '$HOME')/.mutt" --suffix='.spool' -aze ssh $spooldir/$remote_user host_name:$spooldir

Finally, in your muttrc:

unset wait_key
set spoolfile=/var/spool/mail/$(whoami)
macro index,pager i "<shell-escape>update_mail\n<change-folder>$spoolfile<enter>"

Last edited by /dev/zero (2012-04-15 22:08:57)

Offline

Board footer

Powered by FluxBB