summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDerrell Lipman <derrell.lipman@unwireduniverse.com>2008-01-16 14:35:44 +0000
committerDerrell Lipman <derrell.lipman@unwireduniverse.com>2008-01-16 14:35:44 +0000
commit12d31ba2b8b4c0e15567d427abef97a184450b1f (patch)
treeff3eba069f94148ffd536756d95a0260b760c545 /examples
parentf426949e8861b3a97d321516edbcbd771b7d6273 (diff)
downloadsamba-12d31ba2b8b4c0e15567d427abef97a184450b1f.tar.gz
samba-12d31ba2b8b4c0e15567d427abef97a184450b1f.tar.bz2
samba-12d31ba2b8b4c0e15567d427abef97a184450b1f.zip
Add a (very!) trivial cache to the example authentication callback.
(This used to be commit 01f6a4cca7a91ae41ff393263418216324502f84)
Diffstat (limited to 'examples')
-rw-r--r--examples/libsmbclient/get_auth_data_fn.h22
1 files changed, 21 insertions, 1 deletions
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);
}