summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2023-03-29 08:48:12 +0200
committerAndrew Bartlett <abartlet@samba.org>2023-04-05 01:06:29 +0000
commit0e07d0ac220226306c10f39dad1031382264d4e4 (patch)
treee5b9375e565c25e623df74c28fe2b780b6f0be6e
parent34d4ac9907c47d6183efd2f850c2293207fa32fa (diff)
downloadsamba-0e07d0ac220226306c10f39dad1031382264d4e4.tar.gz
s3:utils: Add support for parsing domain/UPN in username for smbget
The smbget utility doesn't use the common command line parser, so it doesn't support paring of DOMAIN/user or user@realm. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15345 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--selftest/knownfail.d/smbget_msdfs2
-rw-r--r--source3/utils/smbget.c28
2 files changed, 26 insertions, 4 deletions
diff --git a/selftest/knownfail.d/smbget_msdfs b/selftest/knownfail.d/smbget_msdfs
deleted file mode 100644
index 4c2b71b5245..00000000000
--- a/selftest/knownfail.d/smbget_msdfs
+++ /dev/null
@@ -1,2 +0,0 @@
-^samba3.blackbox.smbget.msdfs.domain.fileserver
-^samba3.blackbox.smbget.msdfs.upn.fileserver
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index 9463f333eb2..dca5ded4a9c 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -21,6 +21,7 @@
#include "lib/cmdline/cmdline.h"
#include "libsmbclient.h"
#include "cmdline_contexts.h"
+#include "lib/param/param.h"
static int columns = 0;
@@ -841,7 +842,7 @@ int main(int argc, char **argv)
.argInfo = POPT_ARG_STRING,
.arg = &opt.workgroup,
.val = 'w',
- .descrip = "Workgroup to use (optional)"
+ .descrip = "Workgroup/domain to use (optional)"
},
{
.longName = "user",
@@ -992,6 +993,11 @@ int main(int argc, char **argv)
}
free(rcfile);
+ ok = lp_load_client(lp_default_path());
+ if (!ok) {
+ goto done;
+ }
+
#ifdef SIGWINCH
signal(SIGWINCH, change_columns);
#endif
@@ -1014,7 +1020,8 @@ int main(int argc, char **argv)
case 'e':
smb_encrypt = true;
break;
- case 'U':
+ case 'U': {
+ const char *separator = lp_winbind_separator();
opt.username_specified = true;
opt.username = talloc_strdup(frame, opt.username);
p = strchr(opt.username,'%');
@@ -1023,7 +1030,24 @@ int main(int argc, char **argv)
opt.password = p + 1;
opt.password_specified = true;
}
+
+ /* UPN support */
+ p = strchr(opt.username, '@');
+ if (p != NULL && opt.workgroup == NULL) {
+ *p = '\0';
+ opt.workgroup = p + 1;
+ }
+
+ /* Domain support */
+ p = strchr(opt.username, separator[0]);
+ if (p != NULL && opt.workgroup == NULL) {
+ *p = '\0';
+ opt.workgroup = opt.username;
+ opt.username = p + 1;
+ }
+
break;
+ }
case 'n':
opt.nonprompt = true;
break;