From 38c5136ce16ca1f61a0d64a89269ccc556d1d7ea Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 31 May 2005 23:42:29 +0000 Subject: r7156: file was missing; svn isn't smart enough to even notify me. sigh. (This used to be commit fce48fa1b462ded1453520355bf2dce0f607b8dc) --- examples/libsmbclient/get_auth_data_fn.h | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 examples/libsmbclient/get_auth_data_fn.h (limited to 'examples/libsmbclient/get_auth_data_fn.h') diff --git a/examples/libsmbclient/get_auth_data_fn.h b/examples/libsmbclient/get_auth_data_fn.h new file mode 100644 index 0000000000..2954039f0a --- /dev/null +++ b/examples/libsmbclient/get_auth_data_fn.h @@ -0,0 +1,52 @@ +static void +get_auth_data_fn(const char * pServer, + const char * pShare, + char * pWorkgroup, + int maxLenWorkgroup, + char * pUsername, + int maxLenUsername, + char * pPassword, + int maxLenPassword) + +{ + char temp[128]; + + fprintf(stdout, "Workgroup: [%s] ", pWorkgroup); + fgets(temp, sizeof(temp), stdin); + + if (temp[strlen(temp) - 1] == '\n') /* A new line? */ + { + temp[strlen(temp) - 1] = '\0'; + } + + if (temp[0] != '\0') + { + strncpy(pWorkgroup, temp, maxLenWorkgroup - 1); + } + + fprintf(stdout, "Username: [%s] ", pUsername); + fgets(temp, sizeof(temp), stdin); + + if (temp[strlen(temp) - 1] == '\n') /* A new line? */ + { + temp[strlen(temp) - 1] = '\0'; + } + + if (temp[0] != '\0') + { + strncpy(pUsername, temp, maxLenUsername - 1); + } + + fprintf(stdout, "Password: "); + fgets(temp, sizeof(temp), stdin); + + if (temp[strlen(temp) - 1] == '\n') /* A new line? */ + { + temp[strlen(temp) - 1] = '\0'; + } + + if (temp[0] != '\0') + { + strncpy(pPassword, temp, maxLenPassword - 1); + } +} -- cgit From e836508704dd964e22e8bfc0f8e9ec520a2c94f2 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 22 Mar 2006 22:05:19 +0000 Subject: 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) --- examples/libsmbclient/get_auth_data_fn.h | 1 - 1 file changed, 1 deletion(-) (limited to 'examples/libsmbclient/get_auth_data_fn.h') 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]; -- cgit From 12d31ba2b8b4c0e15567d427abef97a184450b1f Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 16 Jan 2008 14:35:44 +0000 Subject: Add a (very!) trivial cache to the example authentication callback. (This used to be commit 01f6a4cca7a91ae41ff393263418216324502f84) --- examples/libsmbclient/get_auth_data_fn.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'examples/libsmbclient/get_auth_data_fn.h') diff --git a/examples/libsmbclient/get_auth_data_fn.h b/examples/libsmbclient/get_auth_data_fn.h index eb493885af..b1d36c8bea 100644 --- a/examples/libsmbclient/get_auth_data_fn.h +++ b/examples/libsmbclient/get_auth_data_fn.h @@ -8,7 +8,23 @@ get_auth_data_fn(const char * pServer, char * pPassword, int maxLenPassword) { - char temp[128]; + char temp[128]; + char server[256] = { '\0' }; + char share[256] = { '\0' }; + char workgroup[256] = { '\0' }; + char username[256] = { '\0' }; + char password[256] = { '\0' }; + + if (strcmp(server, pServer) == 0 && + strcmp(share, pShare) == 0 && + *workgroup != '\0' && + *username != '\0') + { + strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1); + strncpy(pUsername, username, maxLenUsername - 1); + strncpy(pPassword, password, maxLenPassword - 1); + return; + } fprintf(stdout, "Workgroup: [%s] ", pWorkgroup); fgets(temp, sizeof(temp), stdin); @@ -48,4 +64,8 @@ get_auth_data_fn(const char * pServer, { strncpy(pPassword, temp, maxLenPassword - 1); } + + strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1); + strncpy(username, pUsername, sizeof(username) - 1); + strncpy(password, pPassword, sizeof(password) - 1); } -- cgit From ef0a7b0b94cfb9b57d634b083d2b2652bb88865d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 23 Jun 2008 11:00:20 +0200 Subject: Add krb5 support for the testbrowse example. Signed-off-by: Andreas Schneider Signed-off-by: Derrell Lipman (This used to be commit 84b1ea39a4f27ebcf06a2bafed78396c7353df0e) --- examples/libsmbclient/get_auth_data_fn.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'examples/libsmbclient/get_auth_data_fn.h') 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 + 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; } -- cgit