Unverified Commit 1209dc22 authored by Madelyn Olson's avatar Madelyn Olson Committed by GitHub
Browse files

Only print ACL syntax errors once and include command names in errors (#10922)

* Only print ACL syntax errors once and include command names in errors
parent 82034611
...@@ -2169,15 +2169,25 @@ sds ACLLoadFromFile(const char *filename) { ...@@ -2169,15 +2169,25 @@ sds ACLLoadFromFile(const char *filename) {
server.acl_filename, linenum); server.acl_filename, linenum);
} }
int j; int syntax_error = 0;
for (j = 0; j < merged_argc; j++) { for (int j = 0; j < merged_argc; j++) {
acl_args[j] = sdstrim(acl_args[j],"\t\r\n"); acl_args[j] = sdstrim(acl_args[j],"\t\r\n");
if (ACLSetUser(u,acl_args[j],sdslen(acl_args[j])) != C_OK) { if (ACLSetUser(u,acl_args[j],sdslen(acl_args[j])) != C_OK) {
const char *errmsg = ACLSetUserStringError(); const char *errmsg = ACLSetUserStringError();
errors = sdscatprintf(errors, if (errno == ENOENT) {
"%s:%d: %s. ", /* For missing commands, we print out more information since
server.acl_filename, linenum, errmsg); * it shouldn't contain any sensitive information. */
continue; errors = sdscatprintf(errors,
"%s:%d: Error in applying operation '%s': %s. ",
server.acl_filename, linenum, acl_args[j], errmsg);
} else if (syntax_error == 0) {
/* For all other errors, only print out the first error encountered
* since it might affect future operations. */
errors = sdscatprintf(errors,
"%s:%d: %s. ",
server.acl_filename, linenum, errmsg);
syntax_error = 1;
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment