1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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>
This commit is contained in:
Andreas Schneider 2023-03-29 08:48:12 +02:00 committed by Andrew Bartlett
parent 34d4ac9907
commit 0e07d0ac22
2 changed files with 26 additions and 4 deletions

View File

@ -1,2 +0,0 @@
^samba3.blackbox.smbget.msdfs.domain.fileserver
^samba3.blackbox.smbget.msdfs.upn.fileserver

View File

@ -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;