auth/credentials: let cli_credentials_parse_string() handle the "winbind separator"
authorStefan Metzmacher <metze@samba.org>
Fri, 28 Oct 2016 13:55:48 +0000 (15:55 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 9 Dec 2016 08:24:27 +0000 (09:24 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
auth/credentials/credentials.c
auth/credentials/credentials_internal.h

index b8171f3f797fcff3fe0a5d4ddf1a593fd355838a..2ec494a1a4a6da55b9259abe911b72a35ca1fb8c 100644 (file)
@@ -115,6 +115,8 @@ _PUBLIC_ struct cli_credentials *cli_credentials_init(TALLOC_CTX *mem_ctx)
 
        cred->forced_sasl_mech = NULL;
 
+       cred->winbind_separator = '\\';
+
        return cred;
 }
 
@@ -746,7 +748,10 @@ _PUBLIC_ void cli_credentials_parse_string(struct cli_credentials *credentials,
                *p = 0;
                cli_credentials_set_realm(credentials, p+1, obtained);
                return;
-       } else if ((p = strchr_m(uname,'\\')) || (p = strchr_m(uname, '/'))) {
+       } else if ((p = strchr_m(uname,'\\'))
+                  || (p = strchr_m(uname, '/'))
+                  || (p = strchr_m(uname, credentials->winbind_separator)))
+       {
                *p = 0;
                cli_credentials_set_domain(credentials, uname, obtained);
                uname = p+1;
@@ -794,6 +799,8 @@ _PUBLIC_ const char *cli_credentials_get_unparsed_name(struct cli_credentials *c
 _PUBLIC_ void cli_credentials_set_conf(struct cli_credentials *cred, 
                              struct loadparm_context *lp_ctx)
 {
+       const char *sep = NULL;
+
        cli_credentials_set_username(cred, "", CRED_UNINITIALISED);
        if (lpcfg_parm_is_cmdline(lp_ctx, "workgroup")) {
                cli_credentials_set_domain(cred, lpcfg_workgroup(lp_ctx), CRED_SPECIFIED);
@@ -810,6 +817,11 @@ _PUBLIC_ void cli_credentials_set_conf(struct cli_credentials *cred,
        } else {
                cli_credentials_set_realm(cred, lpcfg_realm(lp_ctx), CRED_UNINITIALISED);
        }
+
+       sep = lpcfg_winbind_separator(lp_ctx);
+       if (sep != NULL && sep[0] != '\0') {
+               cred->winbind_separator = *lpcfg_winbind_separator(lp_ctx);
+       }
 }
 
 /**
index aa01ccc1c4975eb5b09b3f5cc67efb0088d792d9..f88ae7070707a6b214990337f5df10c7f39296a9 100644 (file)
@@ -113,6 +113,8 @@ struct cli_credentials {
 
        /* Whether any callback is currently running */
        bool callback_running;
+
+       char winbind_separator;
 };
 
 #endif /* __CREDENTIALS_INTERNAL_H__ */