-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate: fix cap validation #488
Conversation
d160875
to
1333713
Compare
This is not a correct fix. The manpage says |
My understanding is that both the |
On Thu, Sep 28, 2017 at 08:24:38AM +0000, Zhou Hao wrote:
Also we need to change `effective` to `permitted`.
I agree with this, but as @Mashimiao points out [1], we want to keep
&&. Demonstrating in Python, but the boolean logic is true regardless
of language:
for permitted in (True, False):
for inheritable in (True, False):
ambient_legal = (permitted and inheritable)
print('permitted: {}, inheritable: {}, ambient legal: {}'.format(permitted, inheritable, ambient_legal))
permitted: True, inheritable: True, ambient legal: True
permitted: True, inheritable: False, ambient legal: False
permitted: False, inheritable: True, ambient legal: False
permitted: False, inheritable: False, ambient legal: False
However, the code you have in 1333713 produces:
for permitted in (True, False):
for inheritable in (True, False):
ambient_legal = (permitted or inheritable)
print('permitted: {}, inheritable: {}, ambient legal: {}'.format(permitted, inheritable, ambient_legal))
# permitted: True, inheritable: True, ambient legal: True
# permitted: True, inheritable: False, ambient legal: True
# permitted: False, inheritable: True, ambient legal: True
# permitted: False, inheritable: False, ambient legal: False
If the currrent !(A && B) is confusing, you can unpack with DeMorgan's
law [2]:
ambient && (!permitted || !inheritable)
And a great way to make sure we're doing this right is to have unit
tests excercising CheckCapabilities in the different cases :).
[1]: #488 (comment)
[2]: https://en.wikipedia.org/wiki/De_Morgan's_laws
|
I think this is the right result, exactly what I want. So my changes are correct and do not need to be modified.Only if permitted and inheritable are false, ambient is false. |
This is not both permitted and inheritable. |
Sorry, I misunderstood. |
Signed-off-by: zhouhao <[email protected]>
1333713
to
4beb2a6
Compare
ping @liangchenye @hqhq @mrunalp |
@liangchenye @hqhq PTAL |
Signed-off-by: zhouhao [email protected]