Skip to content
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

[docker] Fix runtime check_is_active sysroot consideration #3375

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sos/policies/runtimes/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class DockerContainerRuntime(ContainerRuntime):
name = 'docker'
binary = 'docker'

def check_is_active(self, sysroot=None):
def check_is_active(self):
# the daemon must be running
if (is_executable('docker', sysroot) and
if (is_executable('docker', self.policy.sysroot) and
(self.policy.init_system.is_running('docker') or
self.policy.init_system.is_running('snap.docker.dockerd'))):
self.active = True
return True
return False

def check_can_copy(self):
return self.check_is_active(sysroot=self.policy.sysroot)
return self.active
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.active = False until check_is_active is called (applies both for ContainerRuntime and DockerContainerRuntime). Can't we get wrong False return here just because we haven't called check_is_active?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current flow, no, because a runtime is only loaded if check_is_active() returns True when the policy is loaded. If this call returns False during policy instantiation, we drop the runtime entirely.

If someone were to separately try to leverage a runtime here, theoretically yes they could end up calling this before check_is_acitve(), but that's not something we support.


# vim: set et ts=4 sw=4 :