[Bug 1974015] Re: apt.Cache(rootdir='/') causes PermissionError

Benjamin Drung 1974015 at bugs.launchpad.net
Fri Jul 21 11:00:03 UTC 2023


** Description changed:

  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
+ ```
+ #!/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()
+   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'

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

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

Status in python-apt package in Ubuntu:
  New

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'

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-apt/+bug/1974015/+subscriptions




More information about the foundations-bugs mailing list