summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorChristian Ambach <ambi@samba.org>2015-12-30 21:25:13 +0100
committerAndreas Schneider <asn@cryptomilk.org>2016-01-25 10:24:23 +0100
commitec802d27ce4dc6dd9b5e5ebd6992f90364d855a2 (patch)
tree3a69eedef46b9422d01b9e955918df8a3e73e27a /source3/utils
parentc8a5ab9ed2cdde3958000d00e634955e437afa05 (diff)
downloadsamba-ec802d27ce4dc6dd9b5e5ebd6992f90364d855a2.tar.gz
s3:utils/smbget fix recursive download
get_auth_data is called multiple times (once for the directory listing and then for every file to be downloaded). Save the obtained values across multiple calls to make smbclient use the correct username for each download. Bug: https://bugzilla.samba.org/show_bug.cgi?id=6482 Signed-off-by: Christian Ambach <ambi@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/smbget.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index b3ce7432ede..a077aa16a41 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -91,10 +91,18 @@ static void human_readable(off_t s, char *buffer, int l)
static void get_auth_data(const char *srv, const char *shr, char *wg, int wglen, char *un, int unlen, char *pw, int pwlen)
{
static char hasasked = 0;
+ static char *savedwg;
+ static char *savedun;
+ static char *savedpw;
char *wgtmp, *usertmp;
char tmp[128];
- if(hasasked) return;
+ if (hasasked) {
+ strncpy(wg, savedwg, wglen - 1);
+ strncpy(un, savedun, unlen - 1);
+ strncpy(pw, savedpw, pwlen - 1);
+ return;
+ }
hasasked = 1;
if(!nonprompt && !username) {
@@ -119,6 +127,11 @@ static void get_auth_data(const char *srv, const char *shr, char *wg, int wglen,
if(workgroup)strncpy(wg, workgroup, wglen-1);
+ /* save the values found for later */
+ savedwg = SMB_STRDUP(wg);
+ savedun = SMB_STRDUP(un);
+ savedpw = SMB_STRDUP(pw);
+
wgtmp = SMB_STRNDUP(wg, wglen);
usertmp = SMB_STRNDUP(un, unlen);
if(!quiet)printf("Using workgroup %s, %s%s\n", wgtmp, *usertmp?"user ":"guest user", usertmp);