If the locking.tdb is not found, (for example, fresh new installed samba server is not running yet) smbstatus utility would exit earlier, and lock files are left behind in the directory 'msg.sock' and 'msg.lock'. Consider that a script to run smbstatus utility in a loop, this might result in used space slowly growing-up on the underlying filesystem. Since the samba server is not running yet, there is no cleanupd daemon could delete these files to reclaim space. Supposed to use 'ret = 0; goto done;' instead of exit(0), this would go through the cmdline_messaging_context_free() which deletes the lock files in the directory msg.sock and msg.lock before smbstatus utility is exiting. patch will follow.
1) Before patch: smbstatus utility would exit earlier if locking.tbd is not found, the lock entries '16059' are left behind in the 'msg.sock' and 'msg.lock'. # smbstatus -L /var/lock/.samba/lock/locking.tdb not initialised This is normal if an SMB client has never connected to your server. # ls -l /var/lock/.samba/lock/msg.lock/ /usr/local/samba/private/msg.sock/ /usr/local/samba/private/msg.sock/: total 0 srwxr-xr-x 1 admin administrators 0 Jan 11 20:45 16059= /var/lock/.samba/lock/msg.lock/: total 4 -rw-r--r-- 1 admin administrators 20 Jan 11 20:45 16059 # strace shows that the lock entries are created and left behind, not deleted. # strace smbstatus -L 2>&1 | grep "msg..ock/" open("/var/lock/.samba/lock/msg.lock/21922", O_RDWR|O_CREAT|O_NONBLOCK, 0644) = 4 unlink("/usr/local/samba/private/msg.sock/21922") = -1 ENOENT (No such file or directory) bind(5, {sa_family=AF_UNIX, sun_path="/usr/local/samba/private/msg.sock/21922"}, 110) = 0 # 2) After patch: strace show that the lock entries are created and then deleted before smbstatus is exiting. # strace smbstatus -L 2>&1 | grep "msg..ock/" open("/var/lock/.samba/lock/msg.lock/23482", O_RDWR|O_CREAT|O_NONBLOCK, 0644) = 4 unlink("/usr/local/samba/private/msg.sock/23482") = -1 ENOENT (No such file or directory) bind(5, {sa_family=AF_UNIX, sun_path="/usr/local/samba/private/msg.sock/23482"}, 110) = 0 unlink("/usr/local/samba/private/msg.sock/23482") = 0 unlink("/var/lock/.samba/lock/msg.lock/23482") = 0 # strace with '-k' shows that the destructor is triggered. # strace -k smbstatus -L ... ... unlink("/usr/local/samba/private/msg.sock/25539") = 0 > /lib/libc-2.21.so(unlink+0x7) [0xdccb7] > /share/samba/lib/private/libmessages-dgm-samba4.so(messaging_dgm_context_destructor+0x12a) [0x370a] > /share/samba/lib/private/libtalloc.so.2.3.3(_tc_free_internal+0xcc9) [0x37a9] > /share/samba/lib/private/libmessages-dgm-samba4.so(messaging_dgm_destroy+0x1c) [0x4f7c] > /share/samba/lib/private/libmessages-dgm-samba4.so(msg_dgm_ref_destructor+0xc5) [0x5e85] > /share/samba/lib/private/libtalloc.so.2.3.3(_tc_free_internal+0xcc9) [0x37a9] > /share/samba/lib/private/libtalloc.so.2.3.3(_tc_free_internal+0x160) [0x2c40] > /share/samba/lib/libsmbconf.so.0.0.1(global_messaging_context_free+0x1c) [0x540bc] > /share/samba/bin/smbstatus(main+0x4d3) [0x3a73] > /lib/libc-2.21.so(__libc_start_main+0xf0) [0x20810] > /share/samba/bin/smbstatus(_start+0x29) [0x4059] unlink("/var/lock/.samba/lock/msg.lock/25539") = 0 > /lib/libc-2.21.so(unlink+0x7) [0xdccb7] > /share/samba/lib/private/libmessages-dgm-samba4.so(messaging_dgm_context_destructor+0x155) [0x3735] > /share/samba/lib/private/libtalloc.so.2.3.3(_tc_free_internal+0xcc9) [0x37a9] > /share/samba/lib/private/libmessages-dgm-samba4.so(messaging_dgm_destroy+0x1c) [0x4f7c] > /share/samba/lib/private/libmessages-dgm-samba4.so(msg_dgm_ref_destructor+0xc5) [0x5e85] > /share/samba/lib/private/libtalloc.so.2.3.3(_tc_free_internal+0xcc9) [0x37a9] > /share/samba/lib/private/libtalloc.so.2.3.3(_tc_free_internal+0x160) [0x2c40] > /share/samba/lib/libsmbconf.so.0.0.1(global_messaging_context_free+0x1c) [0x540bc] > /share/samba/bin/smbstatus(main+0x4d3) [0x3a73] > /lib/libc-2.21.so(__libc_start_main+0xf0) [0x20810] > /share/samba/bin/smbstatus(_start+0x29) [0x4059]
patch against master: https://gitlab.com/samba-team/devel/samba/-/commit/28981f67 CI pipeline is passed: https://gitlab.com/samba-team/devel/samba/-/pipelines/743962093 merge request: https://gitlab.com/samba-team/samba/-/merge_requests/2879
This bug was referenced in samba master: de5d31f452b2445bd92b1746efb05aa096716af8
Created attachment 17724 [details] git-am fix for 4.17.next Cherry-picked from master.
This bug was referenced in samba v4-17-test: 0bc115f75704c9dbad86117fd40b023920f31986
Closing out bug report. Thanks!
Thank you for kindly review! Just for reference: my test version is 4.15.13, so 4.16 & 4.17 might have this issue too.
This bug was referenced in samba v4-17-stable (Release samba-4.17.5): 0bc115f75704c9dbad86117fd40b023920f31986