[SCM] Samba Shared Repository - branch master updated

2024-01-04 Thread Björn Jacke
The branch, master has been updated
   via  1047abf3aa3 selftest: let list_servers.NT1 really use NT1 protocol
   via  5c2286ecf5c vfs_worm: add connect function to cache parameters
   via  e84437eae6a set_process_capability: log which capability was set or 
failed to be set
  from  7e0a18acde8 vfs_ceph: use extra 'ceph_*at()' calls when available

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


- Log -
commit 1047abf3aa352178c433051ede62353283513512
Author: Björn Jacke 
Date:   Thu Jan 4 12:55:53 2024 +0100

selftest: let list_servers.NT1 really use NT1 protocol

Signed-off-by: Bjoern Jacke 
Reviewed-by: Volker Lendecke 

Autobuild-User(master): Björn Jacke 
Autobuild-Date(master): Fri Jan  5 01:43:51 UTC 2024 on atb-devel-224

commit 5c2286ecf5c2ef5557dee4d5ec142a958c99b2ec
Author: Björn Jacke 
Date:   Sat Dec 30 19:53:36 2023 +0100

vfs_worm: add connect function to cache parameters

Signed-off-by: Bjoern Jacke 
Reviewed-by: Volker Lendecke 

commit e84437eae6a8356248cf7cc558903e86ead0eece
Author: Björn Jacke 
Date:   Sat Dec 30 18:28:59 2023 +0100

set_process_capability: log which capability was set or failed to be set

Signed-off-by: Bjoern Jacke 
Reviewed-by: Volker Lendecke 

---

Summary of changes:
 source3/lib/system.c   |  5 +++--
 source3/modules/vfs_worm.c | 44 ++--
 source3/selftest/tests.py  |  2 +-
 3 files changed, 46 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/system.c b/source3/lib/system.c
index bdaa723fd3c..721ffd17f88 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -627,11 +627,12 @@ static bool set_process_capability(enum smbd_capability 
capability,
cap_set_flag(cap, CAP_INHERITABLE, num_cap_vals, cap_vals, CAP_CLEAR);
 
if (cap_set_proc(cap) == -1) {
-   DEBUG(0, ("set_process_capability: cap_set_proc failed: %s\n",
-   strerror(errno)));
+   DBG_ERR("adding capability %d: cap_set_proc failed: %s\n",
+   capability, strerror(errno));
cap_free(cap);
return False;
}
+   DBG_INFO("added capability %d\n", capability);
 
cap_free(cap);
return True;
diff --git a/source3/modules/vfs_worm.c b/source3/modules/vfs_worm.c
index 833a0ac26fe..402705e96e6 100644
--- a/source3/modules/vfs_worm.c
+++ b/source3/modules/vfs_worm.c
@@ -22,6 +22,41 @@
 #include "system/filesys.h"
 #include "libcli/security/security.h"
 
+struct worm_config_data {
+   double grace_period;
+};
+
+static int vfs_worm_connect(struct vfs_handle_struct *handle,
+   const char *service, const char *user)
+{
+   struct worm_config_data *config = NULL;
+   int ret;
+
+   ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
+   if (ret < 0) {
+   return ret;
+   }
+
+   if (IS_IPC(handle->conn) || IS_PRINT(handle->conn)) {
+   return 0;
+   }
+
+   config = talloc_zero(handle->conn, struct worm_config_data);
+   if (config == NULL) {
+   DBG_ERR("talloc_zero() failed\n");
+   errno = ENOMEM;
+   return -1;
+   }
+   config->grace_period = lp_parm_int(SNUM(handle->conn), "worm",
+   "grace_period", 3600);
+
+   SMB_VFS_HANDLE_SET_DATA(handle, config,
+   NULL, struct worm_config_data,
+   return -1);
+   return 0;
+
+}
+
 static NTSTATUS vfs_worm_create_file(vfs_handle_struct *handle,
 struct smb_request *req,
 struct files_struct *dirfsp,
@@ -48,12 +83,16 @@ static NTSTATUS vfs_worm_create_file(vfs_handle_struct 
*handle,
FILE_WRITE_ATTRIBUTES | DELETE_ACCESS |
WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS;
NTSTATUS status;
+   struct worm_config_data *config = NULL;
+
+   SMB_VFS_HANDLE_GET_DATA(handle, config,
+   struct worm_config_data,
+   return NT_STATUS_INTERNAL_ERROR);
 
if (VALID_STAT(smb_fname->st)) {
double age;
age = timespec_elapsed(_fname->st.st_ex_ctime);
-   if (age > lp_parm_int(SNUM(handle->conn), "worm",
- "grace_period", 3600)) {
+   if (age > config->grace_period) {
readonly = true;
}
}
@@ -83,6 +122,7 @@ static NTSTATUS vfs_worm_create_file(vfs_handle_struct 
*handle,
 }
 
 static struct vfs_fn_pointers vfs_worm_fns = {
+   .connect_fn = vfs_worm_connect,
.create_file_fn = 

[SCM] Samba Shared Repository - branch master updated

2024-01-04 Thread Günther Deschner
The branch, master has been updated
   via  7e0a18acde8 vfs_ceph: use extra 'ceph_*at()' calls when available
  from  f2dbcea6f04 lib: Confine the copy_no_nl memcpy to debug_gpfs_log()

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


- Log -
commit 7e0a18acde8ea4801ad4f56a0b2d8daa2120f6e5
Author: Shachar Sharon 
Date:   Mon Nov 13 15:47:24 2023 +0200

vfs_ceph: use extra 'ceph_*at()' calls when available

As of libcephfs version-10.0.3 the high-level API has few more '*at()'
calls. Prefer those newer hooks over path-based when having an
appropriate directory fd (namely: ceph_mkdirat, ceph_openat,
cepth_unlinkat, ceph_symlinkat, ceph_readlinkat).

Ceph commit: 
https://github.com/ceph/ceph/commit/3831aa12f3067d8cc362f39f7136dd53cb946d22

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15516

Signed-off-by: Shachar Sharon 
Reviewed-by: Gunther Deschner 
Reviewed-by: Anoop C S 

Autobuild-User(master): Günther Deschner 
Autobuild-Date(master): Thu Jan  4 21:09:54 UTC 2024 on atb-devel-224

---

Summary of changes:
 source3/modules/vfs_ceph.c | 132 +
 source3/wscript|  10 
 2 files changed, 121 insertions(+), 21 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index b1039ee36ef..7f0bad8ae33 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -473,8 +473,22 @@ static int cephwrap_mkdirat(struct vfs_handle_struct 
*handle,
const struct smb_filename *smb_fname,
mode_t mode)
 {
+   int result = -1;
+#ifdef HAVE_CEPH_MKDIRAT
+   int dirfd = fsp_get_pathref_fd(dirfsp);
+
+   DBG_DEBUG("[CEPH] mkdirat(%p, %d, %s)\n",
+ handle,
+ dirfd,
+ smb_fname->base_name);
+
+   result = ceph_mkdirat(handle->data, dirfd, smb_fname->base_name, mode);
+
+   DBG_DEBUG("[CEPH] mkdirat(...) = %d\n", result);
+
+   WRAP_RETURN(result);
+#else
struct smb_filename *full_fname = NULL;
-   int result;
 
full_fname = full_path_from_dirfsp_atname(talloc_tos(),
dirfsp,
@@ -490,7 +504,8 @@ static int cephwrap_mkdirat(struct vfs_handle_struct 
*handle,
 
TALLOC_FREE(full_fname);
 
-   return WRAP_RETURN(result);
+   WRAP_RETURN(result);
+#endif
 }
 
 static int cephwrap_closedir(struct vfs_handle_struct *handle, DIR *dirp)
@@ -517,15 +532,44 @@ static int cephwrap_openat(struct vfs_handle_struct 
*handle,
bool have_opath = false;
bool became_root = false;
int result = -ENOENT;
+#ifdef HAVE_CEPH_OPENAT
+   int dirfd = -1;
+#endif
 
if (how->resolve != 0) {
errno = ENOSYS;
return -1;
}
 
-   /*
-* ceph doesn't have openat().
-*/
+   if (smb_fname->stream_name) {
+   goto out;
+   }
+
+#ifdef O_PATH
+   have_opath = true;
+   if (fsp->fsp_flags.is_pathref) {
+   flags |= O_PATH;
+   }
+#endif
+
+#ifdef HAVE_CEPH_OPENAT
+   dirfd = fsp_get_pathref_fd(dirfsp);
+
+   DBG_DEBUG("[CEPH] openat(%p, %d, %p, %d, %d)\n",
+ handle, dirfd, fsp, flags, mode);
+
+   if (fsp->fsp_flags.is_pathref && !have_opath) {
+   become_root();
+   became_root = true;
+   }
+
+   result = ceph_openat(handle->data,
+dirfd,
+smb_fname->base_name,
+flags,
+mode);
+
+#else
if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
name = full_path_from_dirfsp_atname(talloc_tos(),
dirfsp,
@@ -539,28 +583,16 @@ static int cephwrap_openat(struct vfs_handle_struct 
*handle,
DBG_DEBUG("[CEPH] openat(%p, %s, %p, %d, %d)\n", handle,
  smb_fname_str_dbg(smb_fname), fsp, flags, mode);
 
-   if (smb_fname->stream_name) {
-   goto out;
-   }
-
-#ifdef O_PATH
-   have_opath = true;
-   if (fsp->fsp_flags.is_pathref) {
-   flags |= O_PATH;
-   }
-#endif
-
if (fsp->fsp_flags.is_pathref && !have_opath) {
become_root();
became_root = true;
}
 
result = ceph_open(handle->data, smb_fname->base_name, flags, mode);
-
+#endif
if (became_root) {
unbecome_root();
}
-
 out:
TALLOC_FREE(name);
fsp->fsp_flags.have_proc_fds = false;
@@ -992,8 +1024,28 @@ static int cephwrap_unlinkat(struct vfs_handle_struct 
*handle,
const struct smb_filename *smb_fname,

[SCM] Samba Shared Repository - branch master updated

2024-01-04 Thread Volker Lendecke
The branch, master has been updated
   via  f2dbcea6f04 lib: Confine the copy_no_nl memcpy to debug_gpfs_log()
   via  c3399cd46f7 lib: Avoid memcpy in debug_lttng_log()
   via  f8a75f83077 lib: Avoid memcpy in debug_systemd_log()
  from  16d802f9c1f script/autobuild.py: add some --private-libraries=ALL 
testing

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


- Log -
commit f2dbcea6f0499e81cf5b3215459925bb1dffd4a8
Author: Volker Lendecke 
Date:   Tue Dec 19 15:34:50 2023 +0100

lib: Confine the copy_no_nl memcpy to debug_gpfs_log()

gpfswrap_add_trace() seems not to have a format string that could
understand the %.*s notation.

While there this removes >4k of r/w memory from every smbd.

Signed-off-by: Volker Lendecke 
Reviewed-by: Stefan Metzmacher 

Autobuild-User(master): Volker Lendecke 
Autobuild-Date(master): Thu Jan  4 17:06:19 UTC 2024 on atb-devel-224

commit c3399cd46f7a33db516b5716a2ce0ebf50fd117a
Author: Volker Lendecke 
Date:   Tue Dec 19 14:47:24 2023 +0100

lib: Avoid memcpy in debug_lttng_log()

tracef() understands the %.*s format.

Signed-off-by: Volker Lendecke 
Reviewed-by: Stefan Metzmacher 

commit f8a75f830774a6f32ed834cd3d17ba8804fddb82
Author: Volker Lendecke 
Date:   Tue Dec 19 14:44:12 2023 +0100

lib: Avoid memcpy in debug_systemd_log()

sd_journal_send() understands the %.*s format.

Signed-off-by: Volker Lendecke 
Reviewed-by: Stefan Metzmacher 

---

Summary of changes:
 lib/util/debug.c | 145 ---
 1 file changed, 62 insertions(+), 83 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/debug.c b/lib/util/debug.c
index f1f91ebe7a7..86f13f181cf 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -100,9 +100,7 @@ static struct {
debug_callback_fn callback;
void *callback_private;
char header_str[300];
-   char header_str_no_nl[300];
size_t hs_len;
-   char msg_no_nl[FORMAT_BUFR_SIZE];
 } state = {
.settings = {
.timestamp_logs = true
@@ -244,48 +242,6 @@ static int debug_level_to_priority(int level)
 }
 #endif
 
-/* -- 
**
- * Produce a version of the given buffer without any trailing newlines.
- */
-#if defined(HAVE_LIBSYSTEMD_JOURNAL) || defined(HAVE_LIBSYSTEMD) || \
-   defined(HAVE_LTTNG_TRACEF) || defined(HAVE_GPFS)
-static void copy_no_nl(char *out,
-  size_t out_size,
-  const char *in,
-  size_t in_len)
-{
-   size_t len;
-   /*
-* Some backends already add an extra newline, so also provide
-* a buffer without the newline character.
-*/
-   len = MIN(in_len, out_size - 1);
-   if ((len > 0) && (in[len - 1] == '\n')) {
-   len--;
-   }
-
-   memcpy(out, in, len);
-   out[len] = '\0';
-}
-
-static void ensure_copy_no_nl(char *out,
- size_t out_size,
- const char *in,
- size_t in_len)
-{
-   /*
-* Assume out is a static buffer that is reused as a cache.
-* If it isn't empty then this has already been done with the
-* same input.
-*/
-   if (out[0] != '\0') {
-   return;
-   }
-
-   copy_no_nl(out, out_size, in, in_len);
-}
-#endif
-
 /* -- 
**
  * Debug backends. When logging to DEBUG_FILE, send the log entries to
  * all active backends.
@@ -366,24 +322,33 @@ static void debug_syslog_log(int msg_level, const char 
*msg, size_t msg_len)
 static void debug_systemd_log(int msg_level, const char *msg, size_t msg_len)
 {
if (state.hs_len > 0) {
-   ensure_copy_no_nl(state.header_str_no_nl,
- sizeof(state.header_str_no_nl),
- state.header_str,
- state.hs_len);
-   sd_journal_send("MESSAGE=%s",
-   state.header_str_no_nl,
+   size_t len = state.hs_len;
+
+   if (state.header_str[len - 1] == '\n') {
+   len -= 1;
+   }
+
+   sd_journal_send("MESSAGE=%.*s",
+   (int)len,
+   state.header_str,
"PRIORITY=%d",
debug_level_to_priority(msg_level),
"LEVEL=%d",
msg_level,
NULL);
}
-   ensure_copy_no_nl(state.msg_no_nl,
- 

Re: [SCM] Samba Shared Repository - branch master updated

2024-01-04 Thread Stefan Metzmacher

Am 04.01.24 um 15:36 schrieb Brown, James William:

On 1/4/2024 7:46 AM, Stefan Metzmacher wrote:

@@ -3905,7 +3937,24 @@ static int moveip(TALLOC_CTX *mem_ctx, struct 
ctdb_context *ctdb,
 return ret;
 }

-   return 0;
+   /*
+* It isn't strictly necessary to wait until takeover runs are
+* re-enabled but doing so can't hurt.
+*/
+   ret = disable_takeover_runs(mem_ctx,
+   ctdb,
+   0,
+   connected_pnn,
+   connected_count);
+   if (ret != 0) {
+   fprintf(stderr, "Failed to enable takeover runs\n");
+   return ret;
+   }

Message should be "Failed to disable takeover runs\n" like previous change at 
3886.


This is a bit confusing but correct, the function name is strange.

We have "disable" with a timeout of 2*options.timelimit
and "enable" with a timeout of 0.

metze



Re: [SCM] Samba Shared Repository - branch master updated

2024-01-04 Thread Brown, James William
On 1/4/2024 7:46 AM, Stefan Metzmacher wrote:

@@ -3905,7 +3937,24 @@ static int moveip(TALLOC_CTX *mem_ctx, struct 
ctdb_context *ctdb,
return ret;
}

-   return 0;
+   /*
+* It isn't strictly necessary to wait until takeover runs are
+* re-enabled but doing so can't hurt.
+*/
+   ret = disable_takeover_runs(mem_ctx,
+   ctdb,
+   0,
+   connected_pnn,
+   connected_count);
+   if (ret != 0) {
+   fprintf(stderr, "Failed to enable takeover runs\n");
+   return ret;
+   }

Message should be "Failed to disable takeover runs\n" like previous change at 
3886.


[SCM] Samba Shared Repository - branch master updated

2024-01-04 Thread Stefan Metzmacher
The branch, master has been updated
   via  16d802f9c1f script/autobuild.py: add some --private-libraries=ALL 
testing
   via  6da49582c21 wafsamba: fix the usage of --private-extension-exception
   via  f22df59b065 wscript: use 
opt.PRIVATE_EXTENSION_DEFAULT('private-samba')
   via  3ae5afa6ad0 script/autobuild.py: nonshared-test works now
   via  a80614fe309 third_party/*_wrapper: use 
SAMBA_LIBRARY(force_unversioned=True)
   via  533e5daf772 wafsamba: introduce 
SAMBA_LIBRARY(force_unversioned=False)
   via  318fd95d5ea s3:smbd multichannel: always refresh the network 
information
   via  62654f0aeb1 ctdb: add comments to "addip"/"delip" when 
CTDB_{CONTROL,EVENT,SRVID}_IPREALLOCATED happens
   via  589ebabc95e ctdb: let "moveip" end with CTDB_CONTROL_IPREALLOCATED 
to all connected nodes
   via  2c6b455bd76 ctdb: remove unused ctdb_message_disable_ip_check()
   via  cad1969b171 ctdb: let "moveip" also use disable_takeover_runs()
   via  b1d0d5d5142 ctdb: send a CTDB_SRVID_IPREALLOCATED message after 
CTDB_EVENT_IPREALLOCATED
  from  1134c4f3a63 s3:utils: Fix the auth function to print correct values 
to the user

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


- Log -
commit 16d802f9c1f61cebb3699942242fbd3717f0dc4e
Author: Stefan Metzmacher 
Date:   Fri Dec 29 15:28:37 2023 +

script/autobuild.py: add some --private-libraries=ALL testing

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15545

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Björn Jacke 
Reviewed-by: Ralph Boehme 

Autobuild-User(master): Stefan Metzmacher 
Autobuild-Date(master): Thu Jan  4 12:45:58 UTC 2024 on atb-devel-224

commit 6da49582c212aefe859c71688a2d7beb72125fa9
Author: Stefan Metzmacher 
Date:   Fri Dec 29 10:05:18 2023 +

wafsamba: fix the usage of --private-extension-exception

It was completely unused...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15545

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Björn Jacke 
Reviewed-by: Ralph Boehme 

commit f22df59b0655f9bb812c39734782b0ff3c71c954
Author: Stefan Metzmacher 
Date:   Fri Dec 29 10:04:59 2023 +

wscript: use opt.PRIVATE_EXTENSION_DEFAULT('private-samba')

The problem was that we used opt.PRIVATE_EXTENSION_DEFAULT('samba4') and
libndr as private will become libndr-samba4 and that already exists as
libndr-samba4 as we don't append the extension if it's already there.

So meant with --private-libraries=ALL we hit the following problem:

$ ./configure --private-libraries=ALL
$ make smbd/smbd
Waf: Leaving directory `/samba/bin/default'
Task dependency cycle in "run_after" constraints:
{task ...: cshlib dcerpc-samba4.empty.c.12.o,ndr_winbind_c.c.229.o -> 
libdcerpc-samba4.so}
make: *** [Makefile:131: smbd/smbd] Error 1

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15545

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Björn Jacke 
Reviewed-by: Ralph Boehme 

commit 3ae5afa6ad0421f479c5fe63ed692593eaed7078
Author: Stefan Metzmacher 
Date:   Fri Dec 29 15:27:38 2023 +

script/autobuild.py: nonshared-test works now

I guess the problem was related to wrapper libraries...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15545

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Björn Jacke 
Reviewed-by: Ralph Boehme 

commit a80614fe3098be42f330a73c5af28e646a86a042
Author: Stefan Metzmacher 
Date:   Fri Dec 29 14:32:51 2023 +

third_party/*_wrapper: use SAMBA_LIBRARY(force_unversioned=True)

This prevents --private-libraries=ALL from creating unuseable
wrapper libraries, as they can't work with symbol versioning.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15545

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Björn Jacke 
Reviewed-by: Ralph Boehme 

commit 533e5daf772b38e21830251d779f083da7197058
Author: Stefan Metzmacher 
Date:   Fri Dec 29 14:32:02 2023 +

wafsamba: introduce SAMBA_LIBRARY(force_unversioned=False)

This can be used in order to avoid a library to be
catched by --private-libraries=ALL.
It is needed for our wrapper libraries.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15545

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Björn Jacke 
Reviewed-by: Ralph Boehme 

commit 318fd95d5ea63724798592eb6b4eebaecfa0cbfb
Author: Jones Syue 
Date:   Thu Jan 4 09:42:15 2024 +0800

s3:smbd multichannel: always refresh the network information

To maintain SMB Multichannel, windows client might periodically query with
FSCTL_QUERY_NETWORK_INTERFACE_INFO to get SMB server's network information,
in my case windows server 2022 would do this every 10 minutes (600 seconds).

Consider a scenario: the network information might 

[SCM] Samba Shared Repository - branch master updated

2024-01-04 Thread Volker Lendecke
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 
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 
Reviewed-by: Volker Lendecke 

Autobuild-User(master): Volker Lendecke 
Autobuild-Date(master): Thu Jan  4 11:26:52 UTC 2024 on atb-devel-224

commit 25021b836f74d3d247bce44c6c02a2d8b2cc39ea
Author: Andreas Schneider 
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 
Reviewed-by: Volker Lendecke 

---

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, );
-   if (username != NULL) {
+   domain = cli_credentials_get_domain_and_obtained(creds, );
+   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, );
-   if (password != NULL) {
+   username = cli_credentials_get_username_and_obtained(creds, );
+   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, );
-   if (domain != NULL) {
+   password = cli_credentials_get_password_and_obtained(creds, );
+   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 {
-