Bug 2828

Summary: Use MD5 digest for socket name
Product: Claws Mail (GTK 2) Reporter: ratinox
Component: OtherAssignee: users
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P3    
Version: 3.9.1   
Hardware: All   
OS: All   
Attachments:
Description Flags
Include MD5 digest in lock socket name. none

Description ratinox 2012-11-28 20:03:54 UTC
This patch replaces the lock socket behavior to always use /tmp (or other specified temporary file system). It uses the MD5 digest of the configuration directory to ensure that each lock socket and configuration directory pair is unique.
Comment 1 ratinox 2012-11-28 20:05:58 UTC
Created attachment 1199 [details]
Include MD5 digest in lock socket name.
Comment 2 Ricardo Mones 2012-11-28 21:33:34 UTC
Quick review:
 - don't remove uid from socket name, just add the MD5, otherwise two different users could clash using the same dir. Agreed that this wouldn't be a common setup, but it costs very little to keep it and helps identifying stale sockets.
 - unified diff format preferred ;-)
Comment 3 Colin Leroy 2012-12-01 22:30:59 UTC
Hi,

So, CVS now has rc_dir canonicalized. Two issues with that patch though:
1) unified diff please
2) the "normal", no alternate-config-dir-case socket is going to change name with that patch (from, for my example, /tmp/claws-mail-1000 to /tmp/claws-mail-SOMEHASH. That's a big problem for everyone who's going to upgrade his distro some day while Claws is running with a /tmp/claws-mail-1000 socket. After the upgrade, he'll click a mailto link in his browser, the new binary will see no /tmp/claws-mail-SOMEHASH socket, so will create it and start, and the poor user will have two claws-mail instances battling for his ~/.claws-mail.
There is no doubt that data loss would occur.

So, TL;DR for 2) is that the normal socket for normal RC dir must not change name until the sun goes red giant on us :)
Comment 4 Ricardo Mones 2012-12-02 03:08:25 UTC
The claws-mail-uid/md5hashsocket which has been proposed on the users list solves this problem, as clashes with existing claws-mail-uid socket files.

Furthermore, on detecting a file instead of a directory new versions can shutdown previous through the socket (probably asking/warning user) and continue loading. No fight would happen, and no need to wait for such astronomical events ;)
Comment 5 users 2012-12-02 21:36:34 UTC
Changes related to this bug have been committed.
Please check latest CVS and update the bug accordingly.
You can also get the patch from:
http://www.claws-mail.org/tracker/

2012-12-02 [colin]	3.9.0cvs36

	* src/main.c
		Move control sockets inside their own directory,
		$TMPDIR/claws-mail-$UID/, and name them after the configuration 		directory md5 hash. That allows
		- cleaner separation of sockets and config dirs in
		  case of alternate config directories
		- forward migration is handled: if $TMPDIR/claws-mail-$UID
		  exists as a socket, use it to control the running entity
		- backwards migration is handled: starting an old Claws Mail
		  version will bail out as creating the legacy socket won't
		  be possible.
		- migration for alternate-config-dirs is not handled, which
		  could be mentioned in release notes.
		Fixes bug #2828, "Use MD5 digest for socket name"