```
@@ -510,22 +510,24 @@ class Report(problem_report.ProblemReport):
- _LogindSession: logind cgroup path, if present (Used for filtering
out crashes that happened in a session that is not running any more)
'''
- if not pid:
- pid = self.pid or os.getpid()
- if not self.pid:
- self.pid = int(pid)
- pid = str(pid)
+ if not proc_pid_fd:
+ if not pid:
+ pid = self.pid or os.getpid()
+ if not self.pid:
+ self.pid = int(pid)
+ pid = str(pid)
+ proc_pid_fd = os.open('/proc/%s' % pid, os.O_RDONLY | os.O_PATH | os.O_DIRECTORY)
I'm not exactly sure how to reproduce this bug, but I did encounter the same issue. It looks like the bug was recently introduced in this commit: https:/ /git.launchpad. net/ubuntu/ +source/ apport/ commit/ ?h=applied/ ubuntu/ xenial- security& id=ecd7418b0291 1c6649b69a592cc a74cfbac8813d
``` problem_ report. ProblemReport) :
@@ -510,22 +510,24 @@ class Report(
- _LogindSession: logind cgroup path, if present (Used for filtering
out crashes that happened in a session that is not running any more)
'''
- if not pid:
- pid = self.pid or os.getpid()
- if not self.pid:
- self.pid = int(pid)
- pid = str(pid)
+ if not proc_pid_fd:
+ if not pid:
+ pid = self.pid or os.getpid()
+ if not self.pid:
+ self.pid = int(pid)
+ pid = str(pid)
+ proc_pid_fd = os.open('/proc/%s' % pid, os.O_RDONLY | os.O_PATH | os.O_DIRECTORY)
try: '/proc/ ' + pid + '/cwd')
self. add_proc_ environ( pid, extraenv) ).rstrip( '\0') int(pid) ) 'status' , dir_fd=proc_pid_fd) 'cmdline' , dir_fd= proc_pid_ fd).rstrip( '\0') proc_pid_ fd) ePath'] = os.readlink( '/proc/ ' + pid + '/exe') ePath'] = os.readlink('exe', dir_fd=proc_pid_fd)
raise ValueError('invalid process')
- self['ProcCwd'] = os.readlink(
+ self['ProcCwd'] = os.readlink('cwd', dir_fd=proc_pid_fd)
except OSError:
pass
- self['ProcStatus'] = _read_file('/proc/' + pid + '/status')
- self['ProcCmdline'] = _read_file('/proc/' + pid + '/cmdline'
- self['ProcMaps'] = _read_maps(
+ self['ProcStatus'] = _read_file(
+ self['ProcCmdline'] = _read_file(
+ self['ProcMaps'] = _read_maps(
try:
- self['Executabl
+ self['Executabl
except OSError as e:
if e.errno == errno.ENOENT:
```
The problem is that os.O_PATH does not exist in python2, and only exists in python3. However, python-apport is a python2 package.
``` bcurtiss- laptop: ~$ python3 -c 'import os; print(os.O_PATH)' bcurtiss- laptop: ~$ python -c 'import os; print(os.O_PATH)' bcurtiss- laptop: ~$
bcurtiss@
2097152
bcurtiss@
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'O_PATH'
bcurtiss@
```