mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
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
This commit is contained in:
parent
8203461120
commit
1209dc2277
16
src/acl.c
16
src/acl.c
@ -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();
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
/* For missing commands, we print out more information since
|
||||||
|
* it shouldn't contain any sensitive information. */
|
||||||
|
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,
|
errors = sdscatprintf(errors,
|
||||||
"%s:%d: %s. ",
|
"%s:%d: %s. ",
|
||||||
server.acl_filename, linenum, errmsg);
|
server.acl_filename, linenum, errmsg);
|
||||||
continue;
|
syntax_error = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user