cli_credentials_parse_string: fix parsing of principals
authorAlexander Bokovoy <ab@samba.org>
Wed, 7 Oct 2020 16:25:24 +0000 (19:25 +0300)
committerAlexander Bokovoy <ab@samba.org>
Wed, 4 Nov 2020 14:59:34 +0000 (14:59 +0000)
commiteb0474d27bae4592b25ac6bf600da29c6a1cb9f8
tree539a40fe82c32b5f262b41149679ec7b2e349865
parenta1b021200e3d068631798942a1f219b26afadca7
cli_credentials_parse_string: fix parsing of principals

When parsing a principal-like name, user name was left with full
principal instead of taking only the left part before '@' sign.

>>> from samba import credentials
>>> t = credentials.Credentials()
>>> t.parse_string('admin@realm.test', credentials.SPECIFIED)
>>> t.get_username()
'admin@realm.test'

The issue is that cli_credentials_set_username() does a talloc_strdup()
of the argument, so we need to change order of assignment to allow
talloc_strdup() to copy the right part of the string.

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
auth/credentials/credentials.c
auth/credentials/tests/test_creds.c
python/samba/tests/credentials.py