Fix use of AuthDataWithContext capability
authorDerrell Lipman <derrell.lipman@unwireduniverse.com>
Mon, 17 Mar 2008 15:34:25 +0000 (11:34 -0400)
committerDerrell Lipman <derrell.lipman@unwireduniverse.com>
Mon, 17 Mar 2008 15:34:25 +0000 (11:34 -0400)
During my initial plans for, and the subsequent discussion of a more
significant change to the API for libsmbclient, I had removed the
AuthDataWithContext usage, in favor of a more generalized planned interface.
When the API returned to its original state, I neglected to reinsert this
code.

Use of an authentication function with the context can be tested using

  examples/libsmbclient/testbrowse -C

Derrell
(This used to be commit 38eab68dfb2d8abe8ad00f5a86fc54c778d0d303)

source3/libsmb/libsmb_context.c
source3/libsmb/libsmb_server.c

index 3e67943c83ce1730d989453d5a54525055d74b31..dd78bcee35524b7d97ddf5af28afae71d26d7723 100644 (file)
@@ -421,7 +421,8 @@ smbc_init_context(SMBCCTX *context)
                 return NULL;
         }
         
-        if (!smbc_getFunctionAuthData(context) ||
+        if ((!smbc_getFunctionAuthData(context) &&
+             !smbc_getFunctionAuthDataWithContext(context)) ||
             smbc_getDebug(context) < 0 ||
             smbc_getDebug(context) > 100) {
                 
index 37612c6e39f076076f968486158a8db0bb7b1ba6..7af5ca3a2457e4053ae6772a02b9917975910327 100644 (file)
@@ -101,15 +101,29 @@ SMBC_call_auth_fn(TALLOC_CTX *ctx,
        fstring workgroup;
        fstring username;
        fstring password;
+        smbc_get_auth_data_with_context_fn auth_with_context_fn;
         
        strlcpy(workgroup, *pp_workgroup, sizeof(workgroup));
        strlcpy(username, *pp_username, sizeof(username));
        strlcpy(password, *pp_password, sizeof(password));
         
-        smbc_getFunctionAuthData(context)(server, share,
-                                          workgroup, sizeof(workgroup),
-                                          username, sizeof(username),
-                                          password, sizeof(password));
+        /* See if there's an authentication with context function provided */
+        auth_with_context_fn = smbc_getFunctionAuthDataWithContext(context);
+        if (auth_with_context_fn)
+        {
+            (* auth_with_context_fn)(context,
+                                     server, share,
+                                     workgroup, sizeof(workgroup),
+                                     username, sizeof(username),
+                                     password, sizeof(password));
+        }
+        else
+        {
+            smbc_getFunctionAuthData(context)(server, share,
+                                              workgroup, sizeof(workgroup),
+                                              username, sizeof(username),
+                                              password, sizeof(password));
+        }
         
        TALLOC_FREE(*pp_workgroup);
        TALLOC_FREE(*pp_username);