1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

s3:smbd: Fix %U substitutions if it contains a domain name

'valid users = DOMAIN\%U' worked with Samba 3.6 and broke in a newer
version.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Aug 19 06:43:10 UTC 2020 on sn-devel-184
This commit is contained in:
Andreas Schneider 2020-08-17 14:12:48 +02:00 committed by Andreas Schneider
parent 53b6dd9512
commit 5de7c91e6d
2 changed files with 17 additions and 2 deletions

View File

@ -1 +0,0 @@
^samba3.substitutions.Test.login.to.share.with.substitution.for.valid.users

View File

@ -79,7 +79,23 @@ static bool token_contains_name(TALLOC_CTX *mem_ctx,
enum lsa_SidType type;
if (username != NULL) {
name = talloc_sub_basic(mem_ctx, username, domain, name);
size_t domain_len = strlen(domain);
/* Check if username starts with domain name */
if (domain_len > 0) {
const char *sep = lp_winbind_separator();
int cmp = strncasecmp_m(username, domain, domain_len);
if (cmp == 0 && sep[0] == username[domain_len]) {
/* Move after the winbind separator */
domain_len += 1;
} else {
domain_len = 0;
}
}
name = talloc_sub_basic(mem_ctx,
username + domain_len,
domain,
name);
}
if (sharename != NULL) {
name = talloc_string_sub(mem_ctx, name, "%S", sharename);