acelyc111 commented on code in PR #1914:
URL:
https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1503552270
##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -157,29 +177,58 @@ zookeeper_session::zookeeper_session(const
service_app_info &node) : _handle(nul
int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
{
utils::auto_write_lock l(_watcher_lock);
- if (nullptr == _handle) {
- if (FLAGS_enable_zookeeper_kerberos) {
- zoo_sasl_params_t sasl_params = {0};
- sasl_params.service = FLAGS_zookeeper_kerberos_service_name;
- sasl_params.mechlist = "GSSAPI";
-
CHECK(dsn::rpc_address::from_host_port(FLAGS_zookeeper_sasl_service_fqdn),
- "zookeeper_sasl_service_fqdn {} is invalid",
- FLAGS_zookeeper_sasl_service_fqdn);
- sasl_params.host = FLAGS_zookeeper_sasl_service_fqdn;
- _handle = zookeeper_init_sasl(FLAGS_hosts_list,
- global_watcher,
- FLAGS_timeout_ms,
- nullptr,
- this,
- 0,
- NULL,
- &sasl_params);
- } else {
+ do {
+ if (nullptr != _handle) {
+ break;
+ }
+ if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
_handle = zookeeper_init(
FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr,
this, 0);
+ break;
}
- CHECK_NOTNULL(_handle, "zookeeper session init failed");
- }
+ int err = sasl_client_init(nullptr);
+ CHECK_EQ_MSG(err,
+ SASL_OK,
+ "Unable to initialize SASL library {}",
+ sasl_errstring(err, nullptr, nullptr));
+
+ if (!utils::is_empty(FLAGS_sasl_password_file)) {
+ CHECK(utils::filesystem::file_exists(FLAGS_sasl_password_file),
+ "sasl_password_file {} not exist!",
+ FLAGS_sasl_password_file);
+ }
+
+ auto param_host = "";
+ if (!utils::is_empty(FLAGS_sasl_service_fqdn)) {
+ rpc_address addr;
Review Comment:
```suggestion
```
##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -157,29 +177,58 @@ zookeeper_session::zookeeper_session(const
service_app_info &node) : _handle(nul
int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
{
utils::auto_write_lock l(_watcher_lock);
- if (nullptr == _handle) {
- if (FLAGS_enable_zookeeper_kerberos) {
- zoo_sasl_params_t sasl_params = {0};
- sasl_params.service = FLAGS_zookeeper_kerberos_service_name;
- sasl_params.mechlist = "GSSAPI";
-
CHECK(dsn::rpc_address::from_host_port(FLAGS_zookeeper_sasl_service_fqdn),
- "zookeeper_sasl_service_fqdn {} is invalid",
- FLAGS_zookeeper_sasl_service_fqdn);
- sasl_params.host = FLAGS_zookeeper_sasl_service_fqdn;
- _handle = zookeeper_init_sasl(FLAGS_hosts_list,
- global_watcher,
- FLAGS_timeout_ms,
- nullptr,
- this,
- 0,
- NULL,
- &sasl_params);
- } else {
+ do {
+ if (nullptr != _handle) {
+ break;
+ }
+ if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
_handle = zookeeper_init(
FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr,
this, 0);
+ break;
}
- CHECK_NOTNULL(_handle, "zookeeper session init failed");
- }
+ int err = sasl_client_init(nullptr);
+ CHECK_EQ_MSG(err,
+ SASL_OK,
+ "Unable to initialize SASL library {}",
+ sasl_errstring(err, nullptr, nullptr));
+
+ if (!utils::is_empty(FLAGS_sasl_password_file)) {
+ CHECK(utils::filesystem::file_exists(FLAGS_sasl_password_file),
+ "sasl_password_file {} not exist!",
+ FLAGS_sasl_password_file);
+ }
+
+ auto param_host = "";
+ if (!utils::is_empty(FLAGS_sasl_service_fqdn)) {
+ rpc_address addr;
+ CHECK(dsn::rpc_address::from_host_port(FLAGS_sasl_service_fqdn),
+ "sasl_service_fqdn {} is invalid",
Review Comment:
```suggestion
"sasl_service_fqdn '{}' is invalid",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]