Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
8119259b
Commit
8119259b
authored
Oct 27, 2020
by
Madelyn Olson
Committed by
Oran Agra
Jan 12, 2021
Browse files
White space tweaks and skip categories already applied
(cherry picked from commit
d310beb4
)
parent
e664f381
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
8119259b
...
...
@@ -484,6 +484,12 @@ sds ACLDescribeUserCommandRules(user *u) {
* already applied. */
user
tu
=
{
0
};
user
*
tempuser
=
&
tu
;
/* Keep track of the categories that have been applied, to prevent
* applying them twice. */
char
applied
[
sizeof
(
ACLCommandCategories
)
/
sizeof
(
ACLCommandCategories
[
0
])];
memset
(
applied
,
0
,
sizeof
(
applied
));
memcpy
(
tempuser
->
allowed_commands
,
u
->
allowed_commands
,
sizeof
(
u
->
allowed_commands
));
...
...
@@ -491,9 +497,10 @@ sds ACLDescribeUserCommandRules(user *u) {
int
best
=
-
1
;
unsigned
long
mindiff
=
INT_MAX
,
maxsame
=
0
;
for
(
int
j
=
0
;
ACLCommandCategories
[
j
].
flag
!=
0
;
j
++
)
{
if
(
applied
[
j
])
continue
;
unsigned
long
on
,
off
,
diff
,
same
;
ACLCountCategoryBitsForUser
(
tempuser
,
&
on
,
&
off
,
ACLCommandCategories
[
j
].
name
);
/* Check if the current category is the best this loop:
* * It has more commands in common with the user than commands
* that are different.
...
...
@@ -505,7 +512,8 @@ sds ACLDescribeUserCommandRules(user *u) {
diff
=
additive
?
off
:
on
;
same
=
additive
?
on
:
off
;
if
(
same
>
diff
&&
((
diff
<
mindiff
)
||
(
diff
==
mindiff
&&
same
>
maxsame
)))
{
((
diff
<
mindiff
)
||
(
diff
==
mindiff
&&
same
>
maxsame
)))
{
best
=
j
;
mindiff
=
diff
;
maxsame
=
same
;
...
...
@@ -527,8 +535,9 @@ sds ACLDescribeUserCommandRules(user *u) {
rules
=
sdscatlen
(
rules
,
" "
,
1
);
sdsfree
(
op
);
sdsfree
(
invop
);
}
applied
[
best
]
=
1
;
}
/* Fix the final ACLs with single commands differences. */
dictIterator
*
di
=
dictGetIterator
(
server
.
orig_commands
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment