-
Notifications
You must be signed in to change notification settings - Fork 5k
fix:auth config #33528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix:auth config #33528
Conversation
Summary of ChangesHello @Pengrongkun, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the handling of authentication configurations by ensuring that the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request fixes the dynamic configuration update for authentication settings. The change from CFG_DYN_SERVER_LAZY to CFG_DYN_SERVER for authReqUrl is now correctly handled by the new logic in taosCfgDynamicOptionsForServer. However, the new code block introduces a critical bug that could lead to a deadlock, and it also contains repetitive code. I've provided a refactoring suggestion to address these issues.
| #ifdef TD_ENTERPRISE | ||
| if (strcasecmp(name, "authServer") == 0) { | ||
| tsAuthServer = pItem->bval; | ||
| code = TSDB_CODE_SUCCESS; | ||
| goto _exit; | ||
| } | ||
| if (strcasecmp(name, "authReq") == 0) { | ||
| tsAuthReq = pItem->bval; | ||
| code = TSDB_CODE_SUCCESS; | ||
| goto _exit; | ||
| } | ||
| if (strcasecmp(name, "authReqInterval") == 0) { | ||
| tsAuthReqInterval = pItem->i32; | ||
| code = TSDB_CODE_SUCCESS; | ||
| goto _exit; | ||
| } | ||
| if (strcasecmp(name, "authReqUrl") == 0) { | ||
| TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN)); | ||
| tstrncpy(tsAuthReqUrl, pItem->str, TSDB_FQDN_LEN); | ||
| code = TSDB_CODE_SUCCESS; | ||
| goto _exit; | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new block of code has a potential bug and can be refactored for better maintainability.
-
Potential Bug (Lock not released): The
TAOS_CHECK_RETURNmacro likely expands to areturnstatement. Since this code is within acfgLock/cfgUnLockpair, returning directly would skip thecfgUnLockcall at the_exitlabel, leading to a deadlock. The error code should be stored and agoto _exitshould be used instead. -
Code Duplication: The structure of the
ifblocks is very repetitive, especially thecode = TSDB_CODE_SUCCESS; goto _exit;part. This can be consolidated to make the code cleaner and easier to maintain.
Here is a suggested refactoring that addresses both points:
#ifdef TD_ENTERPRISE
bool config_handled = false;
if (strcasecmp(name, "authServer") == 0) {
tsAuthServer = pItem->bval;
config_handled = true;
} else if (strcasecmp(name, "authReq") == 0) {
tsAuthReq = pItem->bval;
config_handled = true;
} else if (strcasecmp(name, "authReqInterval") == 0) {
tsAuthReqInterval = pItem->i32;
config_handled = true;
} else if (strcasecmp(name, "authReqUrl") == 0) {
code = taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN);
if (code != TSDB_CODE_SUCCESS) {
goto _exit;
}
tstrncpy(tsAuthReqUrl, pItem->str, TSDB_FQDN_LEN);
config_handled = true;
}
if (config_handled) {
code = TSDB_CODE_SUCCESS;
goto _exit;
}
#endif
source/common/src/tglobal.c
Outdated
| #ifdef TD_ENTERPRISE | ||
| if (strcasecmp(name, "authServer") == 0) { | ||
| tsAuthServer = pItem->bval; | ||
| code = TSDB_CODE_SUCCESS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
虽然之前都是这样写的,实际上,code = TSDB_CODE_SUCCESS 都是冗余的吧。
source/common/src/tglobal.c
Outdated
| } | ||
| if (strcasecmp(name, "authReq") == 0) { | ||
| tsAuthReq = pItem->bval; | ||
| code = TSDB_CODE_SUCCESS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
冗余
source/common/src/tglobal.c
Outdated
| } | ||
| if (strcasecmp(name, "authReqInterval") == 0) { | ||
| tsAuthReqInterval = pItem->i32; | ||
| code = TSDB_CODE_SUCCESS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
冗余
source/common/src/tglobal.c
Outdated
| goto _exit; | ||
| } | ||
| if (strcasecmp(name, "authReqUrl") == 0) { | ||
| TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
返回的话,_exit 处的 cfgUnLock(pCfg) 未执行。
source/common/src/tglobal.c
Outdated
| if (strcasecmp(name, "authReqUrl") == 0) { | ||
| TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN)); | ||
| tstrncpy(tsAuthReqUrl, pItem->str, TSDB_FQDN_LEN); | ||
| code = TSDB_CODE_SUCCESS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
冗余
Description
Please briefly describe the code changes in this pull request.
Checklist
Please check the items in the checklist if applicable.