Skip to content

skip tests that raise PermissionError in test_tarfile (non-root user on Android) #73367

Closed

Description

@xdegaye
mannequin
BPO 29181
Nosy @gustaebel, @xdegaye, @serhiy-storchaka
PRs
  • bpo-29181: Skip test_tarfile tests on PermissionError raised by Android #4375
  • Files
  • test_tarfile.patch
  • issue29181_01.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-11-12.17:03:40.042>
    created_at = <Date 2017-01-06.16:31:35.929>
    labels = ['3.7', 'type-bug', 'tests']
    title = 'skip tests that raise PermissionError in test_tarfile (non-root user on Android)'
    updated_at = <Date 2017-11-12.17:03:40.041>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2017-11-12.17:03:40.041>
    actor = 'xdegaye'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-12.17:03:40.042>
    closer = 'xdegaye'
    components = ['Tests']
    creation = <Date 2017-01-06.16:31:35.929>
    creator = 'xdegaye'
    dependencies = []
    files = ['46199', '46233']
    hgrepos = []
    issue_num = 29181
    keywords = ['patch']
    message_count = 6.0
    messages = ['284832', '284931', '284935', '284938', '285066', '306124']
    nosy_count = 3.0
    nosy_names = ['lars.gustaebel', 'xdegaye', 'serhiy.storchaka']
    pr_nums = ['4375']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29181'
    versions = ['Python 3.7']

    Activity

    1. xdegaye commented on Jan 6, 2017

      xdegayemannequin
      MannequinAuthor

      ====================================================================== [339/2616]
      ERROR: test_link_size (test.test_tarfile.Bz2WriteTest)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "/sdcard/org.bitbucket.pyona/lib/python3.7/test/test_tarfile.py", line 1102, in test_link_siz
      e
          os.link(target, link)
      PermissionError: [Errno 13] Permission denied: '/data/local/tmp/test_python_2295/@test_2295_tmp-tard
      ir/link_target' -> '/data/local/tmp/test_python_2295/@test_2295_tmp-tardir/link'

      ======================================================================
      ERROR: test_link_size (test.test_tarfile.GzipWriteTest)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "/sdcard/org.bitbucket.pyona/lib/python3.7/test/test_tarfile.py", line 1102, in test_link_siz
      e
          os.link(target, link)
      PermissionError: [Errno 13] Permission denied: '/data/local/tmp/test_python_2295/@test_2295_tmp-tard
      ir/link_target' -> '/data/local/tmp/test_python_2295/@test_2295_tmp-tardir/link'

      ======================================================================
      ERROR: test_add_hardlink (test.test_tarfile.HardlinkTest)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "/sdcard/org.bitbucket.pyona/lib/python3.7/test/test_tarfile.py", line 1563, in setUp
          os.link(self.foo, self.bar)
      PermissionError: [Errno 13] Permission denied: '/data/local/tmp/test_python_2295/@test_2295_tmp-tard
      ir/foo' -> '/data/local/tmp/test_python_2295/@test_2295_tmp-tardir/bar'

      ======================================================================
      ERROR: test_add_twice (test.test_tarfile.HardlinkTest)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "/sdcard/org.bitbucket.pyona/lib/python3.7/test/test_tarfile.py", line 1563, in setUp
          os.link(self.foo, self.bar)
      PermissionError: [Errno 13] Permission denied: '/data/local/tmp/test_python_2295/@test_2295_tmp-tard
      ir/foo' -> '/data/local/tmp/test_python_2295/@test_2295_tmp-tardir/bar'

      ======================================================================
      ERROR: test_dereference_hardlink (test.test_tarfile.HardlinkTest)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "/sdcard/org.bitbucket.pyona/lib/python3.7/test/test_tarfile.py", line 1563, in setUp
          os.link(self.foo, self.bar)
      PermissionError: [Errno 13] Permission denied: '/data/local/tmp/test_python_2295/@test_2295_tmp-tard
      ir/foo' -> '/data/local/tmp/test_python_2295/@test_2295_tmp-tardir/bar'

      ======================================================================
      ERROR: test_link_size (test.test_tarfile.WriteTest)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "/sdcard/org.bitbucket.pyona/lib/python3.7/test/test_tarfile.py", line 1102, in test_link_siz
      e
          os.link(target, link)
      PermissionError: [Errno 13] Permission denied: '/data/local/tmp/test_python_2295/@test_2295_tmp-tard
      ir/link_target' -> '/data/local/tmp/test_python_2295/@test_2295_tmp-tardir/link'

      Ran 426 tests in 17.296s

      FAILED (errors=6, skipped=80)
      test test_tarfile failed

    2. self-assigned this
      on Jan 6, 2017
    3. added
      testsTests in the Lib/test dir
      type-bugAn unexpected behavior, bug, or error
      on Jan 6, 2017
    4. xdegaye commented on Jan 7, 2017

      xdegayemannequin
      MannequinAuthor

      Patch attached.

    5. serhiy-storchaka commented on Jan 7, 2017

      @serhiy-storchaka
      Member

      Why os.link() is failed? If hard links are not supported on Android, shouldn't os.link be not implemented? tarfile try to make a copy of the referenced file instead of a link if a link can't be created.

    6. xdegaye commented on Jan 7, 2017

      xdegayemannequin
      MannequinAuthor

      Why os.link() is failed? If hard links are not supported on Android, shouldn't os.link be not implemented?

      Android has a restrictive security model based on SELinux [1].

      With the Android adb shell on the emulator at API level 24:

      $ >foo
      $ ln foo bar
      ln: cannot create hard link from 'foo' to 'bar': Permission denied
      $ su
      # ln foo bar
      # ls -li foo bar
      15688 -rw-rw-rw- 2 shell shell 0 2017-01-07 22:29 bar
      15688 -rw-rw-rw- 2 shell shell 0 2017-01-07 22:29 foo

      Here is the Android commit message that does not grant hard link capabilities by default:
      https://android.googlesource.com/platform/external/sepolicy/+/85ce2c7

      [1] https://source.android.com/security/selinux/

    7. xdegaye commented on Jan 9, 2017

      xdegayemannequin
      MannequinAuthor

      New patch following Serhiy's suggestion in msg285008.

    8. removed their assignment
      on Feb 3, 2017
    9. xdegaye commented on Nov 12, 2017

      xdegayemannequin
      MannequinAuthor

      New changeset d7d4fea by xdegaye in branch 'master':
      bpo-29181: Skip test_tarfile tests on PermissionError raised by Android (GH-4375)
      d7d4fea

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifetestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions