diff options
author | Andreas Schneider <asn@samba.org> | 2023-03-29 08:48:12 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2023-04-05 01:06:29 +0000 |
commit | 0e07d0ac220226306c10f39dad1031382264d4e4 (patch) | |
tree | e5b9375e565c25e623df74c28fe2b780b6f0be6e /source3 | |
parent | 34d4ac9907c47d6183efd2f850c2293207fa32fa (diff) | |
download | samba-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>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/smbget.c | 28 |
1 files changed, 26 insertions, 2 deletions
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; |