From: Stefan Metzmacher Date: Wed, 6 Nov 2019 16:37:45 +0000 (+0100) Subject: auth:creds: Introduce CRED_SMB_CONF X-Git-Tag: talloc-2.3.2~814 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9135035400494ed198e2a1964463c42db7a00c2;p=thirdparty%2Fsamba.git auth:creds: Introduce CRED_SMB_CONF We have several places where we check '> CRED_UNINITIALISED', so we better don't use CRED_UNINITIALISED for values from our smb.conf. Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/auth/credentials/credentials.c b/auth/credentials/credentials.c index 81f9dbb9eb3..80a31b248ae 100644 --- a/auth/credentials/credentials.c +++ b/auth/credentials/credentials.c @@ -902,12 +902,12 @@ _PUBLIC_ void cli_credentials_set_conf(struct cli_credentials *cred, if (lpcfg_parm_is_cmdline(lp_ctx, "workgroup")) { cli_credentials_set_domain(cred, lpcfg_workgroup(lp_ctx), CRED_SPECIFIED); } else { - cli_credentials_set_domain(cred, lpcfg_workgroup(lp_ctx), CRED_UNINITIALISED); + cli_credentials_set_domain(cred, lpcfg_workgroup(lp_ctx), CRED_SMB_CONF); } if (lpcfg_parm_is_cmdline(lp_ctx, "netbios name")) { cli_credentials_set_workstation(cred, lpcfg_netbios_name(lp_ctx), CRED_SPECIFIED); } else { - cli_credentials_set_workstation(cred, lpcfg_netbios_name(lp_ctx), CRED_UNINITIALISED); + cli_credentials_set_workstation(cred, lpcfg_netbios_name(lp_ctx), CRED_SMB_CONF); } if (realm != NULL && strlen(realm) == 0) { realm = NULL; @@ -915,7 +915,7 @@ _PUBLIC_ void cli_credentials_set_conf(struct cli_credentials *cred, if (lpcfg_parm_is_cmdline(lp_ctx, "realm")) { cli_credentials_set_realm(cred, realm, CRED_SPECIFIED); } else { - cli_credentials_set_realm(cred, realm, CRED_UNINITIALISED); + cli_credentials_set_realm(cred, realm, CRED_SMB_CONF); } sep = lpcfg_winbind_separator(lp_ctx); diff --git a/auth/credentials/credentials.h b/auth/credentials/credentials.h index c2a17fef445..9fc511d8389 100644 --- a/auth/credentials/credentials.h +++ b/auth/credentials/credentials.h @@ -42,6 +42,7 @@ struct db_context; /* In order of priority */ enum credentials_obtained { CRED_UNINITIALISED = 0, /* We don't even have a guess yet */ + CRED_SMB_CONF, /* Current value should be used, which comes from smb.conf */ CRED_CALLBACK, /* Callback should be used to obtain value */ CRED_GUESS_ENV, /* Current value should be used, which was guessed */ CRED_GUESS_FILE, /* A guess from a file (or file pointed at in env variable) */ diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c index a5d0f9e051c..68edc282741 100644 --- a/auth/credentials/pycredentials.c +++ b/auth/credentials/pycredentials.c @@ -1275,6 +1275,7 @@ MODULE_INIT_FUNC(credentials) return NULL; PyModule_AddObject(m, "UNINITIALISED", PyLong_FromLong(CRED_UNINITIALISED)); + PyModule_AddObject(m, "SMB_CONF", PyLong_FromLong(CRED_SMB_CONF)); PyModule_AddObject(m, "CALLBACK", PyLong_FromLong(CRED_CALLBACK)); PyModule_AddObject(m, "GUESS_ENV", PyLong_FromLong(CRED_GUESS_ENV)); PyModule_AddObject(m, "GUESS_FILE", PyLong_FromLong(CRED_GUESS_FILE)); diff --git a/python/samba/tests/credentials.py b/python/samba/tests/credentials.py index 3df99ee783f..3dac57651a3 100644 --- a/python/samba/tests/credentials.py +++ b/python/samba/tests/credentials.py @@ -324,7 +324,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir): os.environ["USER"] = "env_user" creds.guess(lp) realm = "realm.example.com" - creds.set_realm(realm, credentials.UNINITIALISED) + creds.set_realm(realm, credentials.SMB_CONF) creds.parse_string("user") self.assertEqual(creds.get_username(), "user") self.assertEqual(creds.get_domain(), lp.get("workgroup").upper()) @@ -352,7 +352,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir): os.environ["USER"] = "env_user" creds.guess(lp) realm = "realm.example.com" - creds.set_realm(realm, credentials.UNINITIALISED) + creds.set_realm(realm, credentials.SMB_CONF) self.assertEqual(creds.get_username(), "env_user") self.assertEqual(creds.get_domain(), lp.get("workgroup").upper()) self.assertEqual(creds.get_realm(), realm.upper())