mirror of
https://github.com/samba-team/samba.git
synced 2025-03-03 12:58:35 +03:00
s3-lib: Parse WORKGROUP\username in set_cmdline_auth_info_username()
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
5328325f94
commit
0c4e132438
@ -54,8 +54,49 @@ const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_inf
|
||||
void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
|
||||
const char *username)
|
||||
{
|
||||
char *s;
|
||||
char *p;
|
||||
bool contains_domain = false;
|
||||
|
||||
s = talloc_strdup(auth_info, username);
|
||||
if (s == NULL) {
|
||||
exit(ENOMEM);
|
||||
}
|
||||
|
||||
p = strchr_m(s, '\\');
|
||||
if (p != NULL) {
|
||||
contains_domain = true;
|
||||
}
|
||||
if (!contains_domain) {
|
||||
p = strchr_m(s, '/');
|
||||
if (p != NULL) {
|
||||
contains_domain = true;
|
||||
}
|
||||
}
|
||||
if (!contains_domain) {
|
||||
char sep = *lp_winbind_separator();
|
||||
|
||||
if (sep != '\0') {
|
||||
p = strchr_m(s, *lp_winbind_separator());
|
||||
if (p != NULL) {
|
||||
contains_domain = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contains_domain) {
|
||||
*p = '\0';
|
||||
username = p + 1;
|
||||
|
||||
/* s is now the workgroup part */
|
||||
set_cmdline_auth_info_domain(auth_info, s);
|
||||
}
|
||||
|
||||
TALLOC_FREE(auth_info->username);
|
||||
auth_info->username = talloc_strdup(auth_info, username);
|
||||
|
||||
TALLOC_FREE(s);
|
||||
|
||||
if (!auth_info->username) {
|
||||
exit(ENOMEM);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user