apt.Cache(rootdir='/') causes PermissionError

Bug #1974015 reported by Benjamin Drung
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
Triaged
Low
Unassigned

Bug Description

The apport test case test_run_report_bug_kernel_thread fails in my schroot environment. My schroot environment has only one /etc/apt/sources.list.d/ubuntu.sources file and no /etc/apt/sources.list file.

Running following test script as non-root will fail:

```
#!/usr/bin/python3
import apt
apt.Cache(rootdir='/')
```

$ ./test
Traceback (most recent call last):
  File "./test", line 3, in <module>
    apt.Cache(rootdir='/')
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 143, in __init__
    self._check_and_create_required_dirs(rootdir)
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 186, in _check_and_create_required_dirs
    open(rootdir + f, "w").close()
PermissionError: [Errno 13] Permission denied: '//etc/apt/sources.list'

Benjamin Drung (bdrung)
description: updated
Revision history for this message
Julian Andres Klode (juliank) wrote :

rootdir generally expects a writable directory, but it seems like a nice idea to make it not write a sources.list if sources.list.d exist

Changed in python-apt (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Benjamin Drung (bdrung) wrote :

And apport should use `apt.Cache()` instead of `apt.Cache(rootdir='/')`.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.