The reason for this is that clidfs.c opens a new connection after receiving a STATUS_PATH_NOT_COVERED error. This new connection is opened through the do_connect function. However the do_connect function uses credentials stored in global/static variables, not the ones of the prior connection. So the username, workgroup end up being anonymous, and you are prompted for a password. Being prompted for a password is not ideal if you are calling the lib programatically and not through an interactive client. To set these global/static credential variables you have to call the functions cli_cm_set_credentials and set_global_myworkgroup. Notice that smbclient does this (client/smbctool.c) in in its get_auth_data_fn callback. However if you use the libsmbclient library there is no way to access these functions (cli_cm_set_credentials and set_global_myworkgroup).
To fix this, a new function like smbc_set_credentials should be added to libsmbclient. Then the user of the library could include the function call in the get_auth_data_fn callback.
The function would look similar to what is in smbclient like this:
/* Set the credentials so DFS will work when following referrals.*/
smbc_set_credentials(char *workgroup, char *user, char *password)
struct user_auth_info auth_info;
auth_info.got_pass = True;
Created attachment 3378 [details]
Here is a proposed patch for this issue.
Thanks, Brian. I've taken your patch and modified it for use in the current development branch (v3-3-test). Please let me know if anything doesn't work as expected.
Derrell, is this appropriate for 3.0.x or 3.2 ? Is looks like a simple extension to the API.
It could be, but it's very much an enhancement, not a bug fix, so I see it as appropriate only for the development branch. I'm trying very hard (for both appropriateness of additions and to allow for my way-too-severe time limitations) to keep new code only in the development branch and limit my changes to the old branches only to significant bug fixes.
Created attachment 3489 [details]
patch with Kerberos
Added functionality to set the Kerberos details as well.