Make libsmbclient work with DFS
[ira/wip.git] / source3 / libsmb / libsmb_path.c
index 6d69924231b61b77014386e40771152ef93f1718..3ea03446d8931d38d79659097bb6c7429293394e 100644 (file)
@@ -233,6 +233,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
        char *s;
        const char *p;
        char *q, *r;
+       char *workgroup = NULL;
        int len;
         
        /* Ensure these returns are at least valid pointers. */
@@ -332,7 +333,6 @@ SMBC_parse_path(TALLOC_CTX *ctx,
                u = userinfo;
                 
                if (strchr_m(u, ';')) {
-                       char *workgroup;
                        next_token_no_ltrim_talloc(ctx, &u, &workgroup, ";");
                        if (!workgroup) {
                                return -1;
@@ -394,6 +394,19 @@ decoding:
        (void) urldecode_talloc(ctx, pp_share, *pp_share);
        (void) urldecode_talloc(ctx, pp_user, *pp_user);
        (void) urldecode_talloc(ctx, pp_password, *pp_password);
+
+       if (!workgroup) {
+               workgroup = talloc_strdup(ctx, smbc_getWorkgroup(context));
+       }
+       if (!workgroup) {
+               return -1;
+       }
+
+       /* set the credentials to make DFS work */
+       smbc_set_credentials_with_fallback(context,
+                                          workgroup,
+                                          *pp_user,
+                                          *pp_password);
         
        return 0;
 }