libsmbclient, Dolphin and Windows Server 2016

I never heard of libsmbclient until recently, when I discovered that Windows Server 2016, by default disables for file servers version 1 of the smb protocol due to WannaCrypt threat: so, due to a recent update of the file server in my company, I was not able to access anymore through dolphin the directories and files provided by that server.

libsmbclient

Dolphin and smb

In KDE System Settings -> Connectivity no preference is available for changing the protocol version for a connection: since I needed to solve that issue I started to look at the panel source code, in order to understand if a protocol version combo-box could be easily added. Digging through the kioslave code I arrived to the smb kioslave configuration panel and then, from there, to the smb kioslave source code, but there was no sign of code to manage the protocol version.

The smb kioslave uses libsmbclient, so it was worth taking a look at the library interface in order to see if there was something related to the protocol version. Guess what? No luck!

libsmbclient and samba configuration file

If I understood well samba code, it seems that every connection operation relies on function SMBC_server_internal in libsmb_server.c.

When creating a connection there is a step to negotiate the protocol

status = smbXcli_negprot(c->conn, c->timeout,
                         lp_client_min_protocol(),
                         lp_client_max_protocol());

lp_client_min_protocol and lp_client_max_protocol are symbols defined in libsmbconf.so, the library that takes care of collecting the configuration parameters in Samba configuration file (usually in
/etc/samba/smb.conf). That seemed a strong hint.

Looking at the samba configuration options there is “client min protocol” setting. Adding in the global section of the configuration file the line

client min protocol = SMB2

solved my issue with Windows Server 2016, libsmbclient and Dolphin.

It sounds a bit strange to me that this is considered a global parameter and there is no chance to manage the protocol version per connection: what if I need connecting to different servers that require different options?

But probably it’s just my fault and there is some advanced configuration to manage this scenario.