From: Andreas Schneider Date: Fri, 15 Dec 2023 07:23:25 +0000 (+0100) Subject: s3:utils: Fix the auth function to print correct values to the user X-Git-Tag: talloc-2.4.2~166 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1134c4f3a63c9618c3fb79abefb40a798c7c1701;p=thirdparty%2Fsamba.git s3:utils: Fix the auth function to print correct values to the user In order to show correct values in the password prompt displayed by cli_credentials_get_password*(). We need to set the domain and username in the credentials system. The credentials supplied via the SMB URL have a higher priority than the command line options. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15538 Signed-off-by: Andreas Schneider Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Thu Jan 4 11:26:52 UTC 2024 on atb-devel-224 --- diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c index 1deda744581..67ea259afb8 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -129,6 +129,7 @@ static void get_auth_data_with_context_fn(SMBCCTX *ctx, strncpy(dom, domain, dom_len - 1); } } + cli_credentials_set_domain(creds, dom, obtained); username = cli_credentials_get_username_and_obtained(creds, &obtained); if (username != NULL) { @@ -143,6 +144,7 @@ static void get_auth_data_with_context_fn(SMBCCTX *ctx, strncpy(usr, username, usr_len - 1); } } + cli_credentials_set_username(creds, usr, obtained); password = cli_credentials_get_password_and_obtained(creds, &obtained); if (password != NULL) { @@ -157,16 +159,17 @@ static void get_auth_data_with_context_fn(SMBCCTX *ctx, strncpy(pwd, password, pwd_len - 1); } } + cli_credentials_set_password(creds, pwd, obtained); - smbc_set_credentials_with_fallback(ctx, domain, username, password); + smbc_set_credentials_with_fallback(ctx, dom, usr, pwd); - if (!opt.quiet && username != NULL) { - if (username[0] == '\0') { + if (!opt.quiet) { + if (usr[0] == '\0') { printf("Using guest user\n"); + } else if (dom[0] == '\0') { + printf("Using user: %s\n", usr); } else { - printf("Using domain: %s, user: %s\n", - domain, - username); + printf("Using domain: %s, user: %s\n", dom, usr); } } }