msg.sock: is it really private dir, or a runtime/pid dir?

Michael Tokarev mjt at tls.msk.ru
Tue Apr 26 11:22:19 UTC 2022


24.04.2022 23:08, Michael Tokarev via samba-technical wrote:
> I noticed msg.sock/ subdir is created within samba private directory,
> and it contains sockets for various samba processes.  This smells like
> it should be done in a runtime directory (/run/samba/) instead.
> 
> In the code, in source3/lib/messages.c, this is indeed done in private dir:
> 
>        priv_path = private_path("msg.sock");
> 
> I think the sockets should not be in a private state directory to start
> with.

How about the attached patch?

It moves msg.sock from private_directory to lock_directory, to the same
place where msg.lock directory is created (usually in /run/samba/ or
in /var/lock/samba/).

Note it immediately shows some issues in the existing code:

1. one user (out of two in total) of private_path() in source3/lib/messages.c
checks for the result to be non-NULL, while the other user does not.
(eg 6279773fed4c31bc5fb93979756125b184070443 is exactly this issue)

2. different code use different functions. I guess this is intentional.
source4/lib/messaging/messaging.c uses lpcfg_private_path() while
source3/lib/messages.c open-codes this.

3. the most important: there's no single place where this path is
defined, but it looks like clients should use the same function
to find this pathname as the server which puts the messages into
there.

4. It looks like whole "private path" usage should be audited,
there are all sorts of fun stuff being created there which don't
belong there.

The msg.sock where introduced by this commit:

commit 1aabd9298d59d4f57d321ecaee59e99d966089ff
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Sep 16 12:44:43 2015 +0200

     s3:lib/messages: use 'msg.lock' and 'msg.sock' for messaging related subdirs

The intention is clear, but what is NOT clear is why for the
new msg.sock, private_path() was used instead of lock_path().
(Cc'ing Stefan).

Thanks,

/mjt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: move-msg.sock-from-var-lib-samba-to-run-samba.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20220426/93bb4848/move-msg.sock-from-var-lib-samba-to-run-samba.bin>


More information about the samba-technical mailing list