summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAndreas Schneider <anschneider@suse.de>2008-06-23 11:00:20 +0200
committerDerrell Lipman <derrell.lipman@unwireduniverse.com>2008-06-23 15:36:37 -0400
commitef0a7b0b94cfb9b57d634b083d2b2652bb88865d (patch)
tree065df92389a971509a39426718d7765dcc14f19c /examples
parent1ef07a6686d3f21052e4105b4d996aa931b6ddc4 (diff)
downloadsamba-ef0a7b0b94cfb9b57d634b083d2b2652bb88865d.tar.gz
samba-ef0a7b0b94cfb9b57d634b083d2b2652bb88865d.tar.bz2
samba-ef0a7b0b94cfb9b57d634b083d2b2652bb88865d.zip
Add krb5 support for the testbrowse example.
Signed-off-by: Andreas Schneider <anschneider@suse.de> Signed-off-by: Derrell Lipman <derrell.lipman@unwireduniverse.com> (This used to be commit 84b1ea39a4f27ebcf06a2bafed78396c7353df0e)
Diffstat (limited to 'examples')
-rw-r--r--examples/libsmbclient/get_auth_data_fn.h13
-rw-r--r--examples/libsmbclient/testbrowse.c3
2 files changed, 15 insertions, 1 deletions
diff --git a/examples/libsmbclient/get_auth_data_fn.h b/examples/libsmbclient/get_auth_data_fn.h
index b1d36c8bea..6b91c97337 100644
--- a/examples/libsmbclient/get_auth_data_fn.h
+++ b/examples/libsmbclient/get_auth_data_fn.h
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+
static void
get_auth_data_fn(const char * pServer,
const char * pShare,
@@ -15,6 +17,8 @@ get_auth_data_fn(const char * pServer,
char username[256] = { '\0' };
char password[256] = { '\0' };
+ static int krb5_set = 1;
+
if (strcmp(server, pServer) == 0 &&
strcmp(share, pShare) == 0 &&
*workgroup != '\0' &&
@@ -25,7 +29,12 @@ get_auth_data_fn(const char * pServer,
strncpy(pPassword, password, maxLenPassword - 1);
return;
}
-
+
+ if (krb5_set && getenv("KRB5CCNAME")) {
+ krb5_set = 0;
+ return;
+ }
+
fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
fgets(temp, sizeof(temp), stdin);
@@ -68,4 +77,6 @@ get_auth_data_fn(const char * pServer,
strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
strncpy(username, pUsername, sizeof(username) - 1);
strncpy(password, pPassword, sizeof(password) - 1);
+
+ krb5_set = 1;
}
diff --git a/examples/libsmbclient/testbrowse.c b/examples/libsmbclient/testbrowse.c
index a7eda365af..a6e6395078 100644
--- a/examples/libsmbclient/testbrowse.c
+++ b/examples/libsmbclient/testbrowse.c
@@ -117,6 +117,9 @@ main(int argc, char * argv[])
smbc_setFunctionAuthData(context, get_auth_data_fn);
}
+ smbc_setOptionUseKerberos(context, 1);
+ smbc_setOptionFallbackAfterKerberos(context, 1);
+
/* If we've been asked to log to stderr instead of stdout, ... */
if (debug_stderr) {
/* ... then set the option to do so */