Skip to content

Commit d959515

Browse files
committed
fixup! linux: switch to target process UID/GID
1 parent 077f161 commit d959515

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ci_core_dumper/linux.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def setns(F, nstype=0):
9595
# must open all NS files first (from init mount ns)
9696
# before entering any (including mount ns)
9797
for ns in os.listdir('/proc/%d/ns'%pid):
98+
if ns not in ('mnt',):
99+
continue
98100
NSs.append((ns,
99101
open('/proc/%d/ns/%s'%(pid, ns), 'rb'),
100102
open('/proc/self/ns/%s'%ns, 'rb')))
@@ -294,7 +296,7 @@ def dump(outdir, gdb, extra_cmds):
294296

295297
def dump2(pid, gdb, extra_cmds):
296298
# running as root, fully in the target/container namespaces
297-
print('Initial root is uid %d, gid %d'%(os.getuid(), os.getgid()))
299+
print('Initial uid %d, gid %d'%(os.getuid(), os.getgid()))
298300

299301
uid = gid = None
300302
with open('/proc/{}/status'.format(pid)) as F:
@@ -306,9 +308,9 @@ def dump2(pid, gdb, extra_cmds):
306308
gid = int(line.split()[1])
307309

308310
if gid:
309-
os.setegid(gid)
311+
os.setgid(gid)
310312
if uid:
311-
os.seteuid(uid)
313+
os.setuid(uid)
312314
print('Target UID %s/%s'%(uid, gid))
313315

314316
# os.environ is still from the init namespaces.

0 commit comments

Comments
 (0)