[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu Jan 4 11:27:02 UTC 2024


The branch, master has been updated
       via  1134c4f3a63 s3:utils: Fix the auth function to print correct values to the user
       via  25021b836f7 s3:utils: Handle the domain before username and password
      from  2cfbf43f706 smbd: Fix traversing snapshot dirs that vanished in current fileset

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1134c4f3a63c9618c3fb79abefb40a798c7c1701
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Dec 15 08:23:25 2023 +0100

    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 <asn at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu Jan  4 11:26:52 UTC 2024 on atb-devel-224

commit 25021b836f74d3d247bce44c6c02a2d8b2cc39ea
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Dec 15 09:41:06 2023 +0100

    s3:utils: Handle the domain before username and password
    
    The cli_credentials_get_password*() function will interactively ask the
    user for a password if none has been supplied via another ways. To show
    the correct domain and username in the prompt, we need handle domain
    and user first.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15538
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/utils/smbget.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index 70b3685c89f..67ea259afb8 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -116,22 +116,23 @@ static void get_auth_data_with_context_fn(SMBCCTX *ctx,
 	const char *domain = NULL;
 	enum credentials_obtained obtained = CRED_UNINITIALISED;
 
-	username = cli_credentials_get_username_and_obtained(creds, &obtained);
-	if (username != NULL) {
+	domain = cli_credentials_get_domain_and_obtained(creds, &obtained);
+	if (domain != NULL) {
 		bool overwrite = false;
-		if (usr[0] == '\0') {
+		if (dom[0] == '\0') {
 			overwrite = true;
 		}
 		if (obtained >= CRED_CALLBACK_RESULT) {
 			overwrite = true;
 		}
 		if (overwrite) {
-			strncpy(usr, username, usr_len - 1);
+			strncpy(dom, domain, dom_len - 1);
 		}
 	}
+	cli_credentials_set_domain(creds, dom, obtained);
 
-	password = cli_credentials_get_password_and_obtained(creds, &obtained);
-	if (password != NULL) {
+	username = cli_credentials_get_username_and_obtained(creds, &obtained);
+	if (username != NULL) {
 		bool overwrite = false;
 		if (usr[0] == '\0') {
 			overwrite = true;
@@ -140,33 +141,35 @@ static void get_auth_data_with_context_fn(SMBCCTX *ctx,
 			overwrite = true;
 		}
 		if (overwrite) {
-			strncpy(pwd, password, pwd_len - 1);
+			strncpy(usr, username, usr_len - 1);
 		}
 	}
+	cli_credentials_set_username(creds, usr, obtained);
 
-	domain = cli_credentials_get_domain_and_obtained(creds, &obtained);
-	if (domain != NULL) {
+	password = cli_credentials_get_password_and_obtained(creds, &obtained);
+	if (password != NULL) {
 		bool overwrite = false;
-		if (usr[0] == '\0') {
+		if (pwd[0] == '\0') {
 			overwrite = true;
 		}
 		if (obtained >= CRED_CALLBACK_RESULT) {
 			overwrite = true;
 		}
 		if (overwrite) {
-			strncpy(dom, domain, dom_len - 1);
+			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);
 		}
 	}
 }


-- 
Samba Shared Repository



More information about the samba-cvs mailing list