Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,14 @@ void Acl::InitLimitUser(const std::string& bl, bool limit_exist) {
auto u = GetUser(DefaultLimitUser);
if (limit_exist) {
if (!bl.empty()) {
u->SetUser("+@all");
for(auto& cmd : blacklist) {
cmd = pstd::StringTrim(cmd, " ");
u->SetUser("-" + cmd);
}
u->SetUser("on");
if (!pass.empty()) {
u->SetUser(">"+pass);
}
}
if (!pass.empty()) {
u->SetUser(">"+pass);
Comment on lines +497 to +499

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper handling of user passwords.

The code sets the user password directly without checking if the password is already set or if it needs to be updated. This could lead to unintended overwrites. Consider adding checks or a method to update the password only if it differs from the current one.


Refactor password setting logic.

The password setting logic in the InitLimitUser method could be refactored into a separate method to improve readability and reusability. This would also make it easier to handle different password setting scenarios more cleanly.

- u->SetUser(">"+pass);
+ u->SetPassword(pass);

Committable suggestion was skipped due to low confidence.

}
} else {
if (pass.empty()) {
Expand Down