Skip to content

Commit 1b86e89

Browse files
committed
Fix CI failures (#1997)
Ubuntu, why are you doing this to us? I seriously mean that Ubuntu is the most silly distro. Like, they probably updated their docker (or VM) images last week, then Github got it, and we started getting failures. They totally changed the behaviour of that 'apport' thing, and it now drops core files in /var/lib/apport/coredump instead of the current working directory. Why is that even... ugh. Nevermind. It works now, at least. But for how long?
1 parent 0c769bd commit 1b86e89

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
ulimit -c unlimited
7373
cat /proc/sys/kernel/core_pattern
7474
cat /proc/sys/kernel/core_uses_pid
75-
( cd $(mktemp -d); sh -c 'kill -11 $$' || true; ls -la ./*core* /var/crash/*.crash;) || true
75+
( cd $(mktemp -d); sh -c 'kill -11 $$' || true; ls -la ./*core* /var/crash/*.crash /var/lib/apport/coredump/core*) || true
7676
7777
- name: Set up SSH
7878
run: |

pwnlib/commandline/unhex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def main(args):
2828
o.write(unhex(''.join(args.hex)))
2929
except TypeError as e:
3030
sys.stderr.write(str(e) + '\n')
31+
raise
3132

3233
if __name__ == '__main__':
3334
common.main(__file__)

pwnlib/elf/corefile.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ class Corefile(ELF):
400400
automatically invokes GDB to attach and dump a corefile.
401401
402402
>>> core = io.corefile
403+
>>> io.close()
403404
404405
The corefile can be inspected and read from, and even exposes various mappings
405406
@@ -1456,6 +1457,10 @@ def native_corefile_pipe(self):
14561457
f.write(apport_core)
14571458
return filename
14581459

1460+
filename = self.apport_coredump()
1461+
if filename:
1462+
return filename
1463+
14591464
# Pretend core_pattern was just 'core', and see if we come up with anything
14601465
self.kernel_core_pattern = 'core'
14611466
return self.native_corefile_pattern()
@@ -1545,6 +1550,42 @@ def qemu_corefile(self):
15451550
for corefile in sorted(glob.glob(corefile_path), reverse=True):
15461551
return corefile
15471552

1553+
def apport_coredump(self):
1554+
"""Find new-style apport coredump of executables not belonging
1555+
to a system package
1556+
"""
1557+
# Now Ubuntu, which is the most silly distro of all, doesn't follow
1558+
# anybody else's rules either...
1559+
# ...and it uses apport FROM SOME OTHER REPO THAN THE DOCS SAY
1560+
# Hey, thanks for making our lives easier, Canonical :----)
1561+
# Seriously, why is Ubuntu even considered to be the default distro
1562+
# on GH Actions?
1563+
#
1564+
# core.<_path_to_target_binary>.<uid>.<boot_id>.<pid>.<timestamp>
1565+
#
1566+
# Note that we don't give any fucks about the timestamp, since the PID
1567+
# should be unique enough that we can just glob.
1568+
1569+
boot_id = read('/proc/sys/kernel/random/boot_id').strip().decode()
1570+
path = self.exe.replace('/', '_')
1571+
1572+
# Format the name
1573+
corefile_name = 'core.{path}.{uid}.{boot_id}.{pid}.*'.format(
1574+
path=path,
1575+
uid=self.uid,
1576+
boot_id=boot_id,
1577+
pid=self.pid,
1578+
)
1579+
1580+
# Get the full path
1581+
corefile_path = os.path.join('/var/lib/apport/coredump', corefile_name)
1582+
1583+
log.debug("Trying corefile_path: %r" % corefile_path)
1584+
1585+
# Glob all of them, return the *most recent* based on numeric sort order.
1586+
for corefile in sorted(glob.glob(corefile_path), reverse=True):
1587+
return corefile
1588+
15481589
def binfmt_lookup(self):
15491590
"""Parses /proc/sys/fs/binfmt_misc to find the interpreter for a file"""
15501591

pwnlib/gdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ def version(program='gdb'):
13351335
program = misc.which(program)
13361336
expr = br'([0-9]+\.?)+'
13371337

1338-
with tubes.process.process([program, '--version'], level='error') as gdb:
1338+
with tubes.process.process([program, '--version'], level='error', stdout=tubes.process.PIPE) as gdb:
13391339
version = gdb.recvline()
13401340

13411341
versions = re.search(expr, version).group()

pwnlib/tubes/process.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ class process(tube):
117117
118118
Examples:
119119
120-
>>> p = process('python2')
121-
>>> p.sendline(b"print 'Hello world'")
122-
>>> p.sendline(b"print 'Wow, such data'");
120+
>>> p = process('python')
121+
>>> p.sendline(b"print('Hello world')")
122+
>>> p.sendline(b"print('Wow, such data')")
123123
>>> b'' == p.recv(timeout=0.01)
124124
True
125125
>>> p.shutdown('send')

pwnlib/tubes/ssh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ def is_exe(path):
10791079
if result == 0:
10801080
self.error("%r does not exist or is not executable" % executable)
10811081
elif result == 3:
1082-
self.error(error_message)
1082+
self.error("%r" % error_message)
10831083
elif result == 2:
10841084
self.error("python is not installed on the remote system %r" % self.host)
10851085
elif result != 1:

0 commit comments

Comments
 (0)