[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2020-03-13 Thread Francis Ginther
** Tags added: id-5e540609ebb75b15e089ff0e

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2020-01-29 Thread Launchpad Bug Tracker
This bug was fixed in the package apport - 2.20.11-0ubuntu16

---
apport (2.20.11-0ubuntu16) focal; urgency=medium

  * SECURITY REGRESSION: 'module' object has no attribute 'O_PATH'
(LP: #1851806)
- apport/report.py, apport/ui.py: use file descriptors for /proc/pid
  directory access only when running under python 3; prevent reading /proc
  maps under python 2 as it does not provide a secure way to do so; use
  io.open for better compatibility between python 2 and 3.
  * data/apport: fix number of arguments passed through socks into a container.
  * test/test_report.py: test login session with both pid and proc_pid_fd.

 -- Tiago Stürmer Daitx   Mon, 06 Jan 2020
13:28:40 +

** Changed in: apport (Ubuntu)
   Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2020-01-09 Thread Sebastien Bacher
** Changed in: apport (Ubuntu)
 Assignee: (unassigned) => Tiago Stürmer Daitx (tdaitx)

** Changed in: apport (Ubuntu)
   Importance: Undecided => High

** Changed in: apport (Ubuntu)
   Status: Confirmed => In Progress

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2020-01-08 Thread Brian Murray
** Branch linked: lp:~tdaitx/ubuntu/focal/apport/lp-1851806-fix

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-12-20 Thread Francis Ginther
** Tags added: id-5dd454a1dd84728273703743

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-12-06 Thread Albert Pool
The above looks like some Python 3 code ended up in a Python 2.7
document, given opener= was added in Python 3.3 it seems.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-12-06 Thread Albert Pool
Simply removing O_PATH from the line in question leads to:

Traceback (most recent call last):
  File "/usr/share/apport/apport-gtk", line 597, in 
app.run_argv()
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 661, in run_argv
return self.run_update_report()
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 559, in 
run_update_report
self.report.add_proc_environ()
  File "/usr/lib/python2.7/dist-packages/apport/report.py", line 592, in 
add_proc_environ
env = _read_file('environ', dir_fd=proc_pid_fd).replace('\n', '\\n')
  File "/usr/lib/python2.7/dist-packages/apport/report.py", line 73, in 
_read_file
with open(path, 'rb', opener=lambda path, mode: os.open(path, mode, 
dir_fd=dir_fd)) as fd:
TypeError: 'opener' is an invalid keyword argument for this function

(Linux Mint 18.2, python-apport 2.20.1-0ubuntu2.21)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-12-06 Thread Launchpad Bug Tracker
Status changed to 'Confirmed' because the bug affects multiple users.

** Changed in: apport (Ubuntu)
   Status: New => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-11-14 Thread Sebastien Bacher
** Tags added: regression-update

** Changed in: apport (Ubuntu)
   Status: Incomplete => New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-11-14 Thread Benjamin Curtiss
Here's a reproduction of the error:

bcurtiss@bcurtiss-laptop:~$ ipython
Python 2.7.12 (default, Oct  8 2019, 14:14:10) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help  -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import apport_python_hook; 
apport_python_hook.apport_excepthook(Exception, Exception(), None)
Exception
---
AttributeErrorTraceback (most recent call last)
 in ()
> 1 import apport_python_hook; 
apport_python_hook.apport_excepthook(Exception, Exception(), None)

/usr/lib/python2.7/dist-packages/apport_python_hook.pyc in 
apport_excepthook(exc_type, exc_obj, exc_tb)
107 traceback.print_exception(exc_type, exc_obj, exc_tb, 
file=tb_file)
108 pr['Traceback'] = tb_file.getvalue().strip()
--> 109 pr.add_proc_info(extraenv=['PYTHONPATH', 'PYTHONHOME'])
110 pr.add_user_info()
111 # override the ExecutablePath with the script that was actually 
running

/usr/lib/python2.7/dist-packages/apport/report.pyc in add_proc_info(self, pid, 
proc_pid_fd, extraenv)
517 self.pid = int(pid)
518 pid = str(pid)
--> 519 proc_pid_fd = os.open('/proc/%s' % pid, os.O_RDONLY | 
os.O_PATH | os.O_DIRECTORY)
520 
521 try:

AttributeError: 'module' object has no attribute 'O_PATH'

In [2]: exit
bcurtiss@bcurtiss-laptop:~$ ipython3
Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help  -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import apport_python_hook; 
apport_python_hook.apport_excepthook(Exception, Exception(), None)
Exception

In [2]: exit
bcurtiss@bcurtiss-laptop:~$

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-11-14 Thread Benjamin Curtiss
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=ecd7418b02911c6649b69a592cca74cfbac8813d

```
@@ -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)
 
 try:
-self['ProcCwd'] = os.readlink('/proc/' + pid + '/cwd')
+self['ProcCwd'] = os.readlink('cwd', dir_fd=proc_pid_fd)
 except OSError:
 pass
 self.add_proc_environ(pid, extraenv)
-self['ProcStatus'] = _read_file('/proc/' + pid + '/status')
-self['ProcCmdline'] = _read_file('/proc/' + pid + 
'/cmdline').rstrip('\0')
-self['ProcMaps'] = _read_maps(int(pid))
+self['ProcStatus'] = _read_file('status', dir_fd=proc_pid_fd)
+self['ProcCmdline'] = _read_file('cmdline', 
dir_fd=proc_pid_fd).rstrip('\0')
+self['ProcMaps'] = _read_maps(proc_pid_fd)
 try:
-self['ExecutablePath'] = os.readlink('/proc/' + pid + '/exe')
+self['ExecutablePath'] = os.readlink('exe', dir_fd=proc_pid_fd)
 except OSError as e:
 if e.errno == errno.ENOENT:
 raise ValueError('invalid process')
```

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@bcurtiss-laptop:~$ python3 -c 'import os; print(os.O_PATH)'
2097152
bcurtiss@bcurtiss-laptop:~$ python -c 'import os; print(os.O_PATH)'
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'O_PATH'
bcurtiss@bcurtiss-laptop:~$
```

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1851806] Re: 'module' object has no attribute 'O_PATH'

2019-11-11 Thread Sebastien Bacher
Thank you for your bug report. Could you give some steps to trigger the
issue?

** Changed in: apport (Ubuntu)
   Status: New => Incomplete

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1851806

Title:
  'module' object has no attribute 'O_PATH'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1851806/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs