After session is established, 'smbstatus' utility could list client's information to help us understand which clients are connected, for example, 'Machine' column includes a machine name, an ip address, and a port. The client's 'machine name' seems always an ip address format, which is the same as ip address information in the brackets, this looks like repeated and is not able to give more information about clients which are connected, like their netbios name, computer name, or hostname. This patch uses is_ipaddress() for 'remote_name' checking, if 'remote_name' is ip address format, replace its content with get_remote_machine_name(), in order to make 'smbstatus' utility to show more clues to help us collect client's hostname information. Not sure if this patch do it in the correct way, any insights are appreciated. Before apply this patch: jones@u22044-2:~$ sudo /usr/local/samba/bin/smbstatus Samba version 4.20.5 PID Username Group Machine Protocol Version Encryption Signing ---------------------------------------------------------------------------------------------------------------------------------------- 3148638 jones jones 192.168.7.67 (ipv4:192.168.7.67:58620) SMB3_11 - partial(AES-128-GMAC) Service pid Machine Connected at Encryption Signing --------------------------------------------------------------------------------------------- samba 3148638 192.168.7.67 Thu Sep 19 05:54:31 PM 2024 CST - - After apply this patch: jones@u22044-2:~$ sudo /usr/local/samba/bin/smbstatus Samba version 4.20.5 PID Username Group Machine Protocol Version Encryption Signing ---------------------------------------------------------------------------------------------------------------------------------------- 3147285 jones jones jones-ws22-67 (ipv4:192.168.7.67:58616) SMB3_11 - partial(AES-128-GMAC) Service pid Machine Connected at Encryption Signing --------------------------------------------------------------------------------------------- samba 3147285 jones-ws22-67 Thu Sep 19 05:52:22 PM 2024 CST - - patch will follow.
oops, some ci jobs fail: https://gitlab.com/samba-team/devel/samba/-/pipelines/1460327204 patch: https://gitlab.com/samba-team/devel/samba/-/commit/157f5a82991e