umask option for tarfile extract

Discussion in 'Python' started by Faik Uygur, Jun 15, 2006.

  1. Faik Uygur

    Faik Uygur Guest

    Hello,

    While extracting a tar file, is there a way to give an umask option for
    creating the non-existing upper directories of the file within the tar
    archive.

    The default behaviour is to create the directories with 0777 permission bits.

    Code taken from tarfile.py of python version 2.4.3:

    # Create all upper directories.
    upperdirs = os.path.dirname(targetpath)
    if upperdirs and not os.path.exists(upperdirs):
    ti = TarInfo()
    ti.name = upperdirs
    ti.type = DIRTYPE
    ti.mode = 0777
    ^^^^^^
    ti.mtime = tarinfo.mtime
    ti.uid = tarinfo.uid
    ti.gid = tarinfo.gid
    ti.uname = tarinfo.uname
    ti.gname = tarinfo.gname
    try:
    self._extract_member(ti, ti.name)
    except:
    pass

    Regards,
    - Faik
     
    Faik Uygur, Jun 15, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yves Glodt

    spawnle & umask

    Yves Glodt, Dec 8, 2005, in forum: Python
    Replies:
    0
    Views:
    359
    Yves Glodt
    Dec 8, 2005
  2. Yves Glodt

    Re: spawnle & umask

    Yves Glodt, Dec 8, 2005, in forum: Python
    Replies:
    3
    Views:
    481
    Donn Cave
    Dec 8, 2005
  3. Faik Uygur

    getting umask without changing it

    Faik Uygur, Jun 16, 2006, in forum: Python
    Replies:
    0
    Views:
    291
    Faik Uygur
    Jun 16, 2006
  4. Daniel Berger

    umask vs umask

    Daniel Berger, Apr 13, 2008, in forum: Ruby
    Replies:
    8
    Views:
    300
    Heesob Park
    Apr 16, 2008
  5. Ingmar Hamer

    ZipFile.extract overwrite option

    Ingmar Hamer, Oct 8, 2009, in forum: Ruby
    Replies:
    2
    Views:
    1,309
    Ingmar Hamer
    Oct 9, 2009
  6. JVarsoke

    umask and CPAN installs

    JVarsoke, Feb 28, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    303
    Todd de Gruyl
    Feb 28, 2004
  7. E Arredondo

    Perl's umask equivalent command

    E Arredondo, Oct 4, 2005, in forum: Perl Misc
    Replies:
    6
    Views:
    914
    Paul Lalli
    Oct 5, 2005
  8. Antoon Pardon

    3.2 can't extract tarfile produced by 2.7

    Antoon Pardon, Dec 26, 2012, in forum: Python
    Replies:
    0
    Views:
    242
    Antoon Pardon
    Dec 26, 2012
Loading...