Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
struct smbXcli_tcon *tcon;
struct idr_context *open_handles;
} smb2;
+
+ /*
+ * We don't want to kinit twice if
+ * cli_session_creds_prepare_krb5()
+ * is called more than once for a given
+ * cli_state cli_credentials combination.
+ */
+ const struct cli_credentials *last_prepared_creds;
};
struct file_info {
* only if required!
*/
setenv(KRB5_ENV_CCNAME, "MEMORY:cliconnect", 1);
+
+ if (cli->last_prepared_creds == creds) {
+ DBG_DEBUG("Re-using previously prepared Kerberos credentials "
+ "for %s to access %s.\n",
+ user_principal,
+ target_hostname);
+ TALLOC_FREE(frame);
+ return NT_STATUS_OK;
+ }
+
+ cli->last_prepared_creds = NULL;
+
ret = kerberos_kinit_password_ext(user_principal,
pass,
0,
canon_principal,
target_hostname);
+ cli->last_prepared_creds = creds;
+
TALLOC_FREE(frame);
return NT_STATUS_OK;
}