Skip to content

Commit 7949fa8

Browse files
committed
Change how we assemble user names in ASC
Use a DOMAIN\Username format to insure proper detection of enterprise names versus classic GSS formatted names. In general using the DOMAIN\username form is always preferred as it allows to express all valid name formats without escaping. Signed-off-by: Simo Sorce <[email protected]>
1 parent 6f5a131 commit 7949fa8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/gss_sec_ctx.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -855,20 +855,28 @@ uint32_t gssntlm_accept_sec_context(uint32_t *minor_status,
855855
}
856856
}
857857

858+
/* Use domain\username format as that allows to pass in
859+
* enterprise names without the need to escape them */
858860
ulen = strlen(usr_name);
859861
dlen = strlen(dom_name);
860862
if (ulen + dlen + 2 > 1024) {
861863
set_GSSERR(ERR_NAMETOOLONG);
862864
goto done;
863865
}
864-
memcpy(useratdom, usr_name, ulen);
865-
uadlen = ulen;
866+
uadlen = dlen;
866867
if (dlen) {
867-
useratdom[uadlen] = '@';
868-
uadlen++;
869-
memcpy(&useratdom[uadlen], dom_name, dlen);
870-
uadlen += dlen;
868+
memcpy(useratdom, dom_name, dlen);
871869
}
870+
871+
/* always add the domain separator, this way if the username
872+
* is an enteprise name ([email protected] form) it will be
873+
* correctly recognized by gssntlm_import_name() as such */
874+
useratdom[uadlen] = '\\';
875+
uadlen++;
876+
877+
/* finally add usernmae part */
878+
memcpy(&useratdom[uadlen], usr_name, ulen);
879+
uadlen += ulen;
872880
useratdom[uadlen] = '\0';
873881

874882
usrname.value = useratdom;

0 commit comments

Comments
 (0)