Merge lp:~brian-murray/apport/system-slice into lp:~ubuntu-core-dev/ubuntu/hirsute/apport/ubuntu

Proposed by Brian Murray
Status: Merged
Merged at revision: 2829
Proposed branch: lp:~brian-murray/apport/system-slice
Merge into: lp:~ubuntu-core-dev/ubuntu/hirsute/apport/ubuntu
Diff against target: 77 lines (+48/-0)
3 files modified
data/apport (+12/-0)
debian/changelog (+8/-0)
test/test_signal_crashes.py (+28/-0)
To merge this branch: bzr merge lp:~brian-murray/apport/system-slice
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+393269@code.launchpad.net
To post a comment you must log in.
lp:~brian-murray/apport/system-slice updated
2830. By Brian Murray

remove extra comment

2831. By Brian Murray

switch from using grep to opening the cgroup file

Revision history for this message
Brian Murray (brian-murray) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/apport'
2--- data/apport 2020-10-12 20:44:02 +0000
3+++ data/apport 2020-11-04 18:59:12 +0000
4@@ -355,6 +355,18 @@
5 else:
6 raise
7
8+ # check to see if the process is part of the system.slice (LP: #1870060)
9+ if os.path.exists('/proc/%s/cgroup' % pid):
10+
11+ global proc_pid_fd
12+ proc_pid_fd = os.open('/proc/%s' % pid, os.O_RDONLY | os.O_PATH | os.O_DIRECTORY)
13+
14+ with open('cgroup', opener=proc_pid_opener) as cgroup:
15+ for line in cgroup:
16+ fields = line.split(':')
17+ if fields[-1].startswith('/system.slice'):
18+ return True
19+
20 return False
21
22
23
24=== modified file 'debian/changelog'
25--- debian/changelog 2020-10-12 21:43:36 +0000
26+++ debian/changelog 2020-11-04 18:59:12 +0000
27@@ -1,3 +1,11 @@
28+apport (2.20.11-0ubuntu51) UNRELEASED; urgency=medium
29+
30+ * data/apport: Modify the check for whether or not a process is running in
31+ the same namespace so that crashes from processes running protected in the
32+ system.slice are considered as being from the same namespace. (LP: #1870060)
33+
34+ -- Brian Murray <brian@ubuntu.com> Tue, 03 Nov 2020 09:01:34 -0800
35+
36 apport (2.20.11-0ubuntu50) groovy; urgency=medium
37
38 * etc/apport/crashdb.conf: Disable Launchpad crash reports for 20.10
39
40=== modified file 'test/test_signal_crashes.py'
41--- test/test_signal_crashes.py 2020-06-24 16:15:42 +0000
42+++ test/test_signal_crashes.py 2020-11-04 18:59:12 +0000
43@@ -626,6 +626,34 @@
44 self.do_crash(False, command=myexe, expect_corefile=False, uid=8)
45 self.assertEqual(apport.fileutils.get_all_reports(), [])
46
47+ @unittest.skipIf(os.geteuid() != 0, 'this test needs to be run as root')
48+ def test_crash_system_slice(self):
49+ '''report generation for a protected process running in the system slice'''
50+
51+ self.create_test_process(command='/usr/bin/systemd-run',
52+ args=['-t', '-q', '--slice=system.slice',
53+ '-p', 'ProtectSystem=true',
54+ '/usr/bin/yes'])
55+ yes_pid = int(subprocess.check_output(['pidof',
56+ '/usr/bin/yes']).strip())
57+ os.kill(yes_pid, signal.SIGSEGV)
58+
59+ # wait max 10 seconds for apport to finish
60+ timeout = 50
61+ while timeout >= 0:
62+ pidof = subprocess.Popen(['pidof', '-x', 'apport'],
63+ stdout=subprocess.PIPE)
64+ pidof.communicate()
65+ if pidof.returncode != 0:
66+ break
67+ time.sleep(0.2)
68+ timeout -= 1
69+
70+ # check crash report
71+ reports = apport.fileutils.get_all_reports()
72+ self.assertEqual(len(reports), 1)
73+ self.assertEqual(reports[0], '/var/crash/_usr_bin_yes.0.crash')
74+
75 @unittest.skipUnless(os.path.exists('/bin/ping'), 'this test needs /bin/ping')
76 @unittest.skipIf(os.geteuid() != 0, 'this test needs to be run as root')
77 def test_crash_setuid_drop(self):

Subscribers

People subscribed via source and target branches