-
Notifications
You must be signed in to change notification settings - Fork 601
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
cmd/snap-discard-ns: asssert process capabilities #15144
base: master
Are you sure you want to change the base?
cmd/snap-discard-ns: asssert process capabilities #15144
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #15144 +/- ##
========================================
Coverage 78.07% 78.07%
========================================
Files 1182 1184 +2
Lines 157743 158224 +481
========================================
+ Hits 123154 123538 +384
- Misses 26943 27005 +62
- Partials 7646 7681 +35
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Fri Feb 28 09:55:13 UTC 2025 Failures:Preparing:
Executing:
Restoring:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a typo fix inline.
@@ -63,6 +90,11 @@ int main(int argc, char** argv) { | |||
sc_instance_name_validate(snap_instance_name, &err); | |||
sc_die_on_error(err); | |||
|
|||
/* time to asssert we have the right capabilities to perform the job */ | |||
assert_caps(); | |||
/* TODO: drop superfluous capabiltiies and keep only the ones that are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* TODO: drop superfluous capabiltiies and keep only the ones that are | |
/* TODO: drop superfluous capabilities and keep only the ones that are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to a typo assert_caps()
repeatedly queries for only CAP_SYS_ADMIN
rather than each cap in expected_caps
.
const char* cap_name SC_CLEANUP(cap_free) = cap_to_name(cap); | ||
|
||
cap_flag_value_t set = CAP_CLEAR; | ||
if (cap_get_flag(current, CAP_SYS_ADMIN, CAP_EFFECTIVE, &set) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a typo - I am guessing CAP_SYS_ADMIN
be cap
so we query each capability rather than repeatedly querying for CAP_SYS_ADMIN
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching. I've pushed a fixup.
Assert process capabilities, to ensure correctness when invoked from snap-confine. Signed-off-by: Maciej Borzecki <[email protected]>
bc6da80
to
15d2157
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Assert process capabilities, to ensure correctness when invoked from snap-confine.
Cherry picked from #15094. This is a preparatory step for having snap-discard-ns be invoked by a user with privileges carried by capabilities.
Related: SNAPDENG-34419