summaryrefslogtreecommitdiff
path: root/source3/lib/util_cmdline.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2016-09-15 12:08:24 +0200
committerStefan Metzmacher <metze@samba.org>2016-09-25 09:05:27 +0200
commit0c4e13243826871e0597fcd37bd90b184c296e21 (patch)
tree8629ea2e46640b6ed871b46b1e9cf22d9b7c367c /source3/lib/util_cmdline.c
parent5328325f94fc2b49f34cf5f2c699ec7440ef1ec9 (diff)
downloadsamba-0c4e13243826871e0597fcd37bd90b184c296e21.tar.gz
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>
Diffstat (limited to 'source3/lib/util_cmdline.c')
-rw-r--r--source3/lib/util_cmdline.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/source3/lib/util_cmdline.c b/source3/lib/util_cmdline.c
index d2381f03732..3ef1d09d027 100644
--- a/source3/lib/util_cmdline.c
+++ b/source3/lib/util_cmdline.c
@@ -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);
}