summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-03-22 22:05:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:42 -0500
commite836508704dd964e22e8bfc0f8e9ec520a2c94f2 (patch)
tree8128e5217661a19e3adcdfde5e812f845d2c611b /examples
parent853ad11aaf281d8f83561bd273b3271ff7f388cc (diff)
downloadsamba-e836508704dd964e22e8bfc0f8e9ec520a2c94f2.tar.gz
samba-e836508704dd964e22e8bfc0f8e9ec520a2c94f2.tar.bz2
samba-e836508704dd964e22e8bfc0f8e9ec520a2c94f2.zip
r14664: r13868@cabra: derrell | 2006-03-22 17:04:30 -0500
Implement enhancement request 3505. Two additional features are added here. There is now a method of saving an opaque user data handle in the smbc_ context, and there is now a way to request that the context be passed to the authentication function. See examples/libsmbclient/testbrowse.c for an example of using these features. (This used to be commit 203b4911c16bd7e10198a6f0e63960f2813025ef)
Diffstat (limited to 'examples')
-rw-r--r--examples/libsmbclient/get_auth_data_fn.h1
-rw-r--r--examples/libsmbclient/testbrowse.c51
2 files changed, 49 insertions, 3 deletions
diff --git a/examples/libsmbclient/get_auth_data_fn.h b/examples/libsmbclient/get_auth_data_fn.h
index 2954039f0a..eb493885af 100644
--- a/examples/libsmbclient/get_auth_data_fn.h
+++ b/examples/libsmbclient/get_auth_data_fn.h
@@ -7,7 +7,6 @@ get_auth_data_fn(const char * pServer,
int maxLenUsername,
char * pPassword,
int maxLenPassword)
-
{
char temp[128];
diff --git a/examples/libsmbclient/testbrowse.c b/examples/libsmbclient/testbrowse.c
index ca126c9510..96f78aad85 100644
--- a/examples/libsmbclient/testbrowse.c
+++ b/examples/libsmbclient/testbrowse.c
@@ -24,6 +24,16 @@ static void browse(char * path,
int indent);
+static void
+get_auth_data_with_context_fn(SMBCCTX * context,
+ const char * pServer,
+ const char * pShare,
+ char * pWorkgroup,
+ int maxLenWorkgroup,
+ char * pUsername,
+ int maxLenUsername,
+ char * pPassword,
+ int maxLenPassword);
int
main(int argc, char * argv[])
@@ -31,6 +41,7 @@ main(int argc, char * argv[])
int debug = 0;
int debug_stderr = 0;
int no_auth = 0;
+ int context_auth = 0;
int scan = 0;
int iterations = -1;
int again;
@@ -64,6 +75,10 @@ main(int argc, char * argv[])
0, "Do not request authentication data", "integer"
},
{
+ "contextauth", 'C', POPT_ARG_NONE, &context_auth,
+ 0, "Use new authentication function with context", "integer"
+ },
+ {
NULL
}
};
@@ -94,12 +109,21 @@ main(int argc, char * argv[])
/* Set mandatory options (is that a contradiction in terms?) */
context->debug = debug;
- context->callbacks.auth_fn = (no_auth ? no_auth_data_fn : get_auth_data_fn);
+ if (context_auth) {
+ context->callbacks.auth_fn = NULL;
+ smbc_option_set(context,
+ "auth_function",
+ (void *) get_auth_data_with_context_fn);
+ smbc_option_set(context, "user_data", "hello world");
+ } else {
+ context->callbacks.auth_fn =
+ (no_auth ? no_auth_data_fn : get_auth_data_fn);
+ }
/* If we've been asked to log to stderr instead of stdout... */
if (debug_stderr) {
/* ... then set the option to do so */
- smbc_option_set(context, "debug_stderr");
+ smbc_option_set(context, "debug_stderr", (void *) 1);
}
/* Initialize the context using the previously specified options */
@@ -161,6 +185,29 @@ no_auth_data_fn(const char * pServer,
return;
}
+
+static void
+get_auth_data_with_context_fn(SMBCCTX * context,
+ const char * pServer,
+ const char * pShare,
+ char * pWorkgroup,
+ int maxLenWorkgroup,
+ char * pUsername,
+ int maxLenUsername,
+ char * pPassword,
+ int maxLenPassword)
+{
+ printf("Authenticating with context 0x%lx", context);
+ if (context != NULL) {
+ char *user_data = smbc_option_get(context, "user_data");
+ printf(" with user data %s", user_data);
+ }
+ printf("\n");
+
+ get_auth_data_fn(pServer, pShare, pWorkgroup, maxLenWorkgroup,
+ pUsername, maxLenUsername, pPassword, maxLenPassword);
+}
+
static void browse(char * path, int scan, int indent)
{
char * p;