Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Dec 2, 2024
1 parent b270737 commit 38e4376
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cpp/wedpr-storage/ppc-storage/src/hdfs/HDFSStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ HDFSStorage::HDFSStorage(FileStorageConnectionOption::Ptr const& _option)
// init the auth information
if (_option->authConfig)
{
// set auth type to Kerberos
hdfsBuilderConfSetStr(m_builder.get(), "hadoop.security.authentication", "Kerberos");
// init and store the auth information into the cache
auto ctx = std::make_shared<Krb5Context>(_option->authConfig);
ctx->init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ void Krb5Context::init()
checkResult(error, "krb5_parse_name");
// init credential
error = krb5_get_init_creds_password(
m_ctx, m_creds, m_principal, m_config->password.c_str(), NULL, NULL, 0, NULL, NULL);
m_ctx, &m_credsObj, m_principal, m_config->password.c_str(), NULL, NULL, 0, NULL, NULL);
checkResult(error, "krb5_get_init_creds_password");
m_creds = &m_credsObj;
// init the ccache
error = krb5_cc_resolve(m_ctx, m_config->ccachePath.c_str(), &m_ccache);
checkResult(error, "krb5_cc_resolve");
Expand All @@ -54,6 +55,7 @@ void Krb5Context::checkResult(krb5_error_code const& error, std::string const& m
{
if (!error)
{
HDFS_AUTH_LOG(INFO) << LOG_DESC("init Krb5Context: ") << method << " success";
return;
}
auto msg = krb5_get_error_message(m_ctx, error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Krb5Context
ppc::protocol::Krb5AuthConfig::Ptr m_config;
krb5_context m_ctx = NULL;
krb5_principal m_principal = NULL;
krb5_creds m_credsObj;
krb5_creds* m_creds = NULL;
krb5_ccache m_ccache = NULL;
};
Expand Down

0 comments on commit 38e4376

Please sign in to comment.