summaryrefslogtreecommitdiff
path: root/src/acl.c
diff options
context:
space:
mode:
authorMadelyn Olson <34459052+madolson@users.noreply.github.com>2022-07-09 21:02:22 -0700
committerGitHub <noreply@github.com>2022-07-09 21:02:22 -0700
commit1209dc2277342491b100f298d311510c86b0a2f2 (patch)
tree4327d656b8459a0164ab5dfeef7c58d7b678d02a /src/acl.c
parent8203461120bf244e5c0576222c6aa5d986587bca (diff)
downloadredis-1209dc2277342491b100f298d311510c86b0a2f2.tar.gz
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
Diffstat (limited to 'src/acl.c')
-rw-r--r--src/acl.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/acl.c b/src/acl.c
index 3443ee691..b22761411 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -2169,15 +2169,25 @@ sds ACLLoadFromFile(const char *filename) {
server.acl_filename, linenum);
}
- int j;
- for (j = 0; j < merged_argc; j++) {
+ int syntax_error = 0;
+ for (int j = 0; j < merged_argc; j++) {
acl_args[j] = sdstrim(acl_args[j],"\t\r\n");
if (ACLSetUser(u,acl_args[j],sdslen(acl_args[j])) != C_OK) {
const char *errmsg = ACLSetUserStringError();
- errors = sdscatprintf(errors,
- "%s:%d: %s. ",
- server.acl_filename, linenum, errmsg);
- continue;
+ 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,
+ "%s:%d: %s. ",
+ server.acl_filename, linenum, errmsg);
+ syntax_error = 1;
+ }
}
}