Cannot list printers on protected SMB2-only server
It is impossible to add a printer from a protected (domain/username/password) SMB2-only server. In particular, no authentication dialog is shown when trying to list the printers available on the server in the "Add Printer" dialog.
I did some debugging and the first cause of this issue appeared to be a bug in libsmbclient
. In particular, the call to smbclient_opendir
here, was not setting errno
correctly. It was always EINVAL
instead of EACCES
on authentication failed. You can find the bug report here; it includes both a description of the problem and a patch that fixes it.
After recompiling libsmbclient
with the patch, however, the problem is not yet fixed. In particular, I verified with a debugger that the get_auth_info
function is now called, so the authentication-required
signal appears to be emitted correctly here. However, at the moment in which the signal is emitted, there appears to be no handler set for it. The only handler for that signal is set here, when the authenticate_samba_server
function is called. I checked with a debugger and I can confirm that the function is never called during my test.
My impression, but I could be mistaken given my lack of experience with GTK, is that the authenticate_samba_server
function is called only when one is trying to authenticate a printer that is already on the list, but not to authenticate to a server in order to list the printers on it. The expected behavior would be to get an authentication prompt when the URL is entered, or have the possibility to click on a button to open the prompt once it is discovered that additional authentication information is required.
Steps to reproduce:
- Build a patched version of
libsmbclient
(the patch can be found here) - Open GNOME Settings
- Go to the "Printers" panel
- Click on the "Unlock" button and insert your credentials
- Insert the URL of a valid protected SMB2 server in the "Add Printer" dialog
- No authentication dialog is shown to list the printers.
Without the patched library, this check on errno
will fail, but you can also flip it using gdb
and avoid having to rebuild the whole samba
project.