Skip to content

File permission on zip member reported incorrectly #1

Open
@travcunn

Description

@travcunn

https://code.google.com/p/python-libarchive/issues/detail?id=6

Reported by ch...@screef.com, Jan 10, 2015

What steps will reproduce the problem?

  $ cd /tmp
  $ cp /etc/resolv.conf test1
  $ cp /etc/resolv.conf test2
  $ chmod 444 test1
  $ chmod 666 test2
  $ zip test.zip test1 test2
  $ /tmp/t1.py

What is the expected output? What do you see instead?
Expected output is:

  test2
  33206
  test1
  33060

Output displayed is:

  test2
  33206
  test1
  33206

What version of the product are you using? On what operating system?
libarchive-3.1.2, python-libarchive-3.1.2-1
RHEL6

Please provide any additional information below.
The problem is most likely with libarchive/init.py. I wrote another python program, /tmp/t2.py, using the raw libarchive commands and it gave the expected output.

/tmp/t1.py

#!/opt/fsw/pkgutils16/lib/aux/python/bin/python

import os
import sys

import libarchive.zip

zipfile = '/tmp/test.zip'

z = libarchive.zip.ZipFile (zipfile, 'r')

for entry in z:
  print entry.pathname
  print entry.mode

z.close ()

/tmp/t2.py

#!/opt/fsw/pkgutils16/lib/aux/python/bin/python

import os
import sys

from libarchive import _libarchive

zipfile = '/tmp/test.zip'

a = _libarchive.archive_read_new()
_libarchive.archive_read_support_format_zip(a)

_libarchive.archive_read_open_filename(a, zipfile, 10240)

e = _libarchive.archive_entry_new()
while True:
  r = _libarchive.archive_read_next_header2(a, e)
  if r == _libarchive.ARCHIVE_EOF:
    break
  path = _libarchive.archive_entry_pathname(e).decode('utf-8')
  mode = _libarchive.archive_entry_filetype(e)
  perm = _libarchive.archive_entry_perm(e)

  print path, mode, perm, mode | perm

_libarchive.archive_entry_free(e)
_libarchive.archive_read_close(a)
_libarchive.archive_read_free(a)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions