Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35812

Re: Tarfile and usernames

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <nicholas.cole@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'root': 0.04; 'method.': 0.05; 'retrieved': 0.05; '*not*': 0.07; 'assign': 0.07; 'extracted': 0.07; 'command.': 0.09; 'preserve': 0.09; 'cc:addr :python-list': 0.10; 'library': 0.15; 'dec': 0.15; '"member"': 0.16; 'archives.': 0.16; 'chown': 0.16; 'op.': 0.16; 'overriding': 0.16; 'tarfile': 0.16; '\xa0you': 0.16; 'wrote:': 0.17; 'documented': 0.17; "shouldn't": 0.17; 'module': 0.19; '(on': 0.22; '\xa0if': 0.22; '\xa0so': 0.22; 'defined': 0.22; 'cc:2**0': 0.23; 'specified': 0.23; 'user.': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'creating': 0.26; 'guess': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'archives': 0.29; 'behaviour': 0.29; 'tar': 0.29; 'skip:& 10': 0.29; 'probably': 0.29; 'class': 0.29; 'this.': 0.29; "i'm": 0.29; 'expect': 0.31; 'file': 0.32; 'running': 0.32; 'anywhere': 0.33; 'extract': 0.33; 'wishes,': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'should': 0.36; 'thank': 0.36; 'too': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'things': 0.38; 'list,': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'days': 0.60; '30,': 0.62; 'between': 0.63; 'behavior': 0.64; 'dear': 0.66; 'computers': 0.69; 'stated': 0.69; 'user,': 0.69; 'hoping': 0.72; '01:57': 0.84; 'cole': 0.84; 'computers.': 0.84; '\xa0but': 0.84; 'albert': 0.91; 'careful': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=t9QNsj3g8RJd2vLxsYsGWsV2xN/9+j1b/zrrbaV4Olw=; b=h93PkWJH0qxHwm4JangoZ67pz8k3gPTABhWkfk179rKhcakfbm/q8fYmcMQU/d/abE Y1xuzDAFGAzkx2y2wyApp9w73RNcdIEuAvkyeE/XqFz0KoYU0m6HvKCHUjXLRJK190qC EMdwaulvTXMtlIPaLOjDHEo0FQNMgEhKCso1pl6a1nYsik5tDRrQ97vH78Z6z7govREf Yqhwcj13kxO9Bqt5o2ElZTXwlbYV6di4ryit+ZjyrXlrWy/cAtINE7rR19Q00xsbJMpV 293Bgeu7LWYkGjQqjILlmZRVQZuLrfMuUhOYk7VxVJSdca0sM0N9YnHNbRvgQIhvf/Sx cY0g==
MIME-Version 1.0
In-Reply-To <1356898025.24306.140661171657165.332324AA@webmail.messagingengine.com>
References <CAAu18heZvrTXWTNDP-Cm116nO--9EUyxzRHOwwjpt4mZGBjj_A@mail.gmail.com> <1356898025.24306.140661171657165.332324AA@webmail.messagingengine.com>
Date Sun, 30 Dec 2012 20:48:00 +0000
Subject Re: Tarfile and usernames
From Nicholas Cole <nicholas.cole@gmail.com>
To Albert Hopkins <marduk@letterboxes.org>
Content-Type multipart/alternative; boundary=047d7b6d81022976f104d2180328
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1472.1356900490.29569.python-list@python.org> (permalink)
Lines 101
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1356900490 news.xs4all.nl 6880 [2001:888:2000:d::a6]:34511
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35812

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sun, Dec 30, 2012 at 8:07 PM, Albert Hopkins <marduk@letterboxes.org>wrote:
>
>
> On Sun, Dec 30, 2012, at 01:57 PM, Nicholas Cole wrote:
>
> Dear List,
>
> I'm hoping to use the tarfile module in the standard library to move some
> files between computers.
>
> I can't see documented anywhere what this library does with userids and
> groupids.  I can't guarantee that the computers involved will have the same
> users and groups, and would like the archives to be extracted so that the
> files are all owned by the extracting user.
>
> Essentially, I do *not* with to preserve the owner and groups specified in
> the archives.
>
>
> Each "member" in the tar file has misc. metadata associated with it, which
> can be retrieved with the get_info() method.  You can add/modify this
> metadata if creating a TarFile.
>
> However, it should be stated that by default (on *nix anyway) if the user
> is not root then user/groups are assigned to the user exctracting the file
> (because only root can assign userids/non-member-groups).   The TarFile
> extract*() methods pretty much inherit the same behavior as the *nix tar
> command.  So if you are extracting as a non-root user, you should expect
> the same behavoir.  If you are extracting as root but don't want to change
> user/groups may have to extract it manually or create your own class by
> inheriting TarFile and overriding the .chown() method.
>
>

Thank you for this.  I guess that since the behaviour is not defined in the
documentation, it would probably be safest to inherit and change chown into
a no op.

I know that on *most* systems these days ordinary users cannot chown, and
also that people shouldn't be running things as root.  But you can't be too
careful - and predicting what a given user will do is always dangerous!

Best wishes,

N.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Tarfile and usernames Nicholas Cole <nicholas.cole@gmail.com> - 2012-12-30 20:48 +0000

csiph-web