|
|
a02485 |
From 1875213788f4472cc11ce8e732cd4780e99ca477 Mon Sep 17 00:00:00 2001
|
|
|
a02485 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
a02485 |
Date: Fri, 8 May 2020 15:38:36 +0200
|
|
|
a02485 |
Subject: [PATCH] [containers_common] collect rootless containers info
|
|
|
a02485 |
|
|
|
a02485 |
Add the ability to collect data/info about rootless podman/buildah
|
|
|
a02485 |
containers, in particular:
|
|
|
a02485 |
|
|
|
a02485 |
- containers_common plugopt 'rootlessusers' as a list of users to inspect
|
|
|
a02485 |
- for each user, collect:
|
|
|
a02485 |
- its containers config
|
|
|
a02485 |
- [podman|buildah] info and [UID|GID] map
|
|
|
a02485 |
- collect user-status and few user-related config files
|
|
|
a02485 |
|
|
|
a02485 |
Resolves: #2055
|
|
|
a02485 |
|
|
|
a02485 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
a02485 |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
a02485 |
---
|
|
|
a02485 |
sos/plugins/containers_common.py | 29 +++++++++++++++++++++++++
|
|
|
a02485 |
1 file changed, 29 insertions(+)
|
|
|
a02485 |
|
|
|
a02485 |
diff --git a/sos/plugins/containers_common.py b/sos/plugins/containers_common.py
|
|
|
a02485 |
index 99ae88fe..9a878849 100644
|
|
|
a02485 |
--- a/sos/plugins/containers_common.py
|
|
|
a02485 |
+++ b/sos/plugins/containers_common.py
|
|
|
a02485 |
@@ -9,6 +9,7 @@
|
|
|
a02485 |
# See the LICENSE file in the source distribution for further information.
|
|
|
a02485 |
|
|
|
a02485 |
from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
|
|
|
a02485 |
+import os
|
|
|
a02485 |
|
|
|
a02485 |
|
|
|
a02485 |
class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
|
|
|
a02485 |
@@ -17,11 +18,39 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
|
|
|
a02485 |
plugin_name = 'containers_common'
|
|
|
a02485 |
profiles = ('container', )
|
|
|
a02485 |
packages = ('containers-common', )
|
|
|
a02485 |
+ option_list = [
|
|
|
a02485 |
+ ('rootlessusers', 'colon-separated list of users\' containers info',
|
|
|
a02485 |
+ '', ''),
|
|
|
a02485 |
+ ]
|
|
|
a02485 |
|
|
|
a02485 |
def setup(self):
|
|
|
a02485 |
self.add_copy_spec([
|
|
|
a02485 |
'/etc/containers/*',
|
|
|
a02485 |
'/usr/share/containers/*',
|
|
|
a02485 |
+ '/etc/subuid',
|
|
|
a02485 |
+ '/etc/subgid',
|
|
|
a02485 |
])
|
|
|
a02485 |
+ self.add_cmd_output(['loginctl user-status'])
|
|
|
a02485 |
+
|
|
|
a02485 |
+ users_opt = self.get_option('rootlessusers')
|
|
|
a02485 |
+ users_list = []
|
|
|
a02485 |
+ if users_opt:
|
|
|
a02485 |
+ users_list = [x for x in users_opt.split(':') if x]
|
|
|
a02485 |
+
|
|
|
a02485 |
+ user_subcmds = [
|
|
|
a02485 |
+ 'info',
|
|
|
a02485 |
+ 'unshare cat /proc/self/uid_map',
|
|
|
a02485 |
+ 'unshare cat /proc/self/gid_map'
|
|
|
a02485 |
+ ]
|
|
|
a02485 |
+ for user in users_list:
|
|
|
a02485 |
+ # collect user's containers' config
|
|
|
a02485 |
+ self.add_copy_spec(
|
|
|
a02485 |
+ '%s/.config/containers/' % (os.path.expanduser('~%s') % user))
|
|
|
a02485 |
+ # collect the user's podman/buildah info and uid/guid maps
|
|
|
a02485 |
+ for binary in ['/usr/bin/podman', '/usr/bin/buildah']:
|
|
|
a02485 |
+ for cmd in user_subcmds:
|
|
|
a02485 |
+ self.add_cmd_output([
|
|
|
a02485 |
+ 'machinectl -q shell %s@ %s %s' % (user, binary, cmd)
|
|
|
a02485 |
+ ])
|
|
|
a02485 |
|
|
|
a02485 |
# vim: set et ts=4 sw=4 :
|
|
|
a02485 |
--
|
|
|
a02485 |
2.21.3
|
|
|
a02485 |
|
|
|
a02485 |
From c2d4c7d1f3ecf6ac59c665cb5138cb2ddda71b3d Mon Sep 17 00:00:00 2001
|
|
|
a02485 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
a02485 |
Date: Fri, 22 May 2020 08:17:30 +0200
|
|
|
a02485 |
Subject: [PATCH] [containers_common] fix user's home expansion
|
|
|
a02485 |
|
|
|
a02485 |
Apply os.path.expanduser on ~[user], not ~%s .
|
|
|
a02485 |
|
|
|
a02485 |
Relates to: #2082
|
|
|
a02485 |
|
|
|
a02485 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
a02485 |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
a02485 |
---
|
|
|
a02485 |
sos/plugins/containers_common.py | 2 +-
|
|
|
a02485 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
a02485 |
|
|
|
a02485 |
diff --git a/sos/plugins/containers_common.py b/sos/plugins/containers_common.py
|
|
|
a02485 |
index 9a878849..da360c7e 100644
|
|
|
a02485 |
--- a/sos/plugins/containers_common.py
|
|
|
a02485 |
+++ b/sos/plugins/containers_common.py
|
|
|
a02485 |
@@ -45,7 +45,7 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
|
|
|
a02485 |
for user in users_list:
|
|
|
a02485 |
# collect user's containers' config
|
|
|
a02485 |
self.add_copy_spec(
|
|
|
a02485 |
- '%s/.config/containers/' % (os.path.expanduser('~%s') % user))
|
|
|
a02485 |
+ '%s/.config/containers/' % (os.path.expanduser('~%s' % user)))
|
|
|
a02485 |
# collect the user's podman/buildah info and uid/guid maps
|
|
|
a02485 |
for binary in ['/usr/bin/podman', '/usr/bin/buildah']:
|
|
|
a02485 |
for cmd in user_subcmds:
|
|
|
a02485 |
--
|
|
|
a02485 |
2.21.3
|
|
|
a02485 |
|
|
|
a02485 |
From 569f261801d3a4da2852c0b40be78b701056edaa Mon Sep 17 00:00:00 2001
|
|
|
a02485 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
a02485 |
Date: Fri, 22 May 2020 08:20:11 +0200
|
|
|
a02485 |
Subject: [PATCH] [containers_common] Call machinectl on foreground
|
|
|
a02485 |
|
|
|
a02485 |
Commands like:
|
|
|
a02485 |
|
|
|
a02485 |
machinectl -q shell user1@ ..
|
|
|
a02485 |
|
|
|
a02485 |
hang if not called on foreground / with terminal.
|
|
|
a02485 |
|
|
|
a02485 |
Resolves: #2082
|
|
|
a02485 |
|
|
|
a02485 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
a02485 |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
a02485 |
---
|
|
|
a02485 |
sos/plugins/containers_common.py | 2 +-
|
|
|
a02485 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
a02485 |
|
|
|
a02485 |
diff --git a/sos/plugins/containers_common.py b/sos/plugins/containers_common.py
|
|
|
a02485 |
index da360c7e..92c2e9e8 100644
|
|
|
a02485 |
--- a/sos/plugins/containers_common.py
|
|
|
a02485 |
+++ b/sos/plugins/containers_common.py
|
|
|
a02485 |
@@ -51,6 +51,6 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
|
|
|
a02485 |
for cmd in user_subcmds:
|
|
|
a02485 |
self.add_cmd_output([
|
|
|
a02485 |
'machinectl -q shell %s@ %s %s' % (user, binary, cmd)
|
|
|
a02485 |
- ])
|
|
|
a02485 |
+ ], foreground=True)
|
|
|
a02485 |
|
|
|
a02485 |
# vim: set et ts=4 sw=4 :
|
|
|
a02485 |
--
|
|
|
a02485 |
2.21.3
|
|
|
a02485 |
|