From: Stefan Metzmacher Date: Thu, 7 Mar 2024 13:40:10 +0000 (+0100) Subject: s3:net: add net_context->explicit_credentials to check if credentials were passed X-Git-Tag: tdb-1.4.11~744 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be1051f3792689209496c8039658b02b6ebdf53d;p=thirdparty%2Fsamba.git s3:net: add net_context->explicit_credentials to check if credentials were passed Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source3/utils/net.c b/source3/utils/net.c index a4726c1ca17..2d9df0a5723 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -1369,6 +1369,10 @@ static struct functable net_func[] = { c->creds = samba_cmdline_get_creds(); { + enum credentials_obtained principal_obtained = + cli_credentials_get_principal_obtained(c->creds); + enum credentials_obtained password_obtained = + cli_credentials_get_password_obtained(c->creds); enum credentials_obtained username_obtained = CRED_UNINITIALISED; enum smb_encryption_setting encrypt_state = @@ -1377,6 +1381,13 @@ static struct functable net_func[] = { cli_credentials_get_kerberos_state(c->creds); uint32_t gensec_features; + if (principal_obtained == CRED_SPECIFIED) { + c->explicit_credentials = true; + } + if (password_obtained == CRED_SPECIFIED) { + c->explicit_credentials = true; + } + c->opt_user_name = cli_credentials_get_username_and_obtained( c->creds, &username_obtained); diff --git a/source3/utils/net.h b/source3/utils/net.h index 559e97930a6..c14ec35915b 100644 --- a/source3/utils/net.h +++ b/source3/utils/net.h @@ -45,6 +45,7 @@ struct net_context { const char *opt_password; const char *opt_user_name; bool opt_user_specified; + bool explicit_credentials; const char *opt_workgroup; int opt_long_list_entries; int opt_reboot; diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index 9c7c74b5292..757228a72e2 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -275,6 +275,7 @@ int net_use_krb_machine_account(struct net_context *c) c->opt_user_specified = true; cli_credentials_set_machine_account(c->creds, c->lp_ctx); + c->explicit_credentials = true; return 0; } diff --git a/source3/utils/py_net.c b/source3/utils/py_net.c index 86c210fd4ee..90c570de03e 100644 --- a/source3/utils/py_net.c +++ b/source3/utils/py_net.c @@ -127,6 +127,7 @@ static PyObject *py_net_join_member(py_net_Object *self, PyObject *args, PyObjec r->in.debug = debug; c->creds = self->creds; + c->explicit_credentials = true; c->opt_user_name = cli_credentials_get_username(self->creds); c->opt_password = cli_credentials_get_password(self->creds); c->opt_kerberos = cli_credentials_get_kerberos_state(self->creds);