Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35843
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <lars@gustaebel.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'root': 0.04; 'method.': 0.05; 'assign': 0.07; 'extracted': 0.07; 'rewrite': 0.07; 'command.': 0.09; 'subset': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'archive': 0.11; 'library': 0.15; 'dec': 0.15; 'overriding': 0.16; 'tarfile': 0.16; 'wrote:': 0.17; 'documented': 0.17; 'yield': 0.17; 'examples': 0.18; '(on': 0.22; 'cc:2**0': 0.23; 'example': 0.23; 'user.': 0.23; 'cc:no real name:2**0': 0.24; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'archives': 0.29; 'tar': 0.29; 'class': 0.29; 'expect': 0.31; 'url:python': 0.32; 'file': 0.32; 'anywhere': 0.33; 'extract': 0.33; "can't": 0.34; 'filter': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'should': 0.36; 'does': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'url:docs': 0.38; 'shows': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'from:no real name:2**0': 0.60; 'content-disposition:inline': 0.60; 'received:79': 0.61; 'kind': 0.61; '30,': 0.62; 'information': 0.63; 'behavior': 0.64; 'computers': 0.69; 'stated': 0.69; 'user,': 0.69; 'members:': 0.84; 'albert': 0.91 |
| From | lars@gustaebel.de |
| Date | Mon, 31 Dec 2012 09:47:30 +0100 |
| To | Albert Hopkins <marduk@letterboxes.org> |
| Subject | Re: Tarfile and usernames |
| Mail-Followup-To | Lars Gustäbel <lars@gustaebel.de>, Albert Hopkins <marduk@letterboxes.org>, python-list@python.org |
| References | <CAAu18heZvrTXWTNDP-Cm116nO--9EUyxzRHOwwjpt4mZGBjj_A@mail.gmail.com> <1356898025.24306.140661171657165.332324AA@webmail.messagingengine.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| In-Reply-To | <1356898025.24306.140661171657165.332324AA@webmail.messagingengine.com> |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| 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.1493.1356944398.29569.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356944398 news.xs4all.nl 6842 [2001:888:2000:d::a6]:33714 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35843 |
Show key headers only | View raw
On Sun, Dec 30, 2012 at 03:07:05PM -0500, Albert Hopkins wrote:
> > 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.
> 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.
Please take a look at the second example in the Examples section of the tarfile
docs:
http://docs.python.org/2.7/library/tarfile.html#examples
It shows how to extract a subset of an archive using a generator as some kind
of filter for the extractall() method. Just rewrite the example so that every
tarinfo is patched with the required user and group name information before
being yielded:
def filter(members):
for tarinfo in members:
tarinfo.uname = "root"
tarinfo.gname = "root"
yield tarinfo
That's it.
--
Lars Gustäbel
lars@gustaebel.de
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Tarfile and usernames lars@gustaebel.de - 2012-12-31 09:47 +0100
csiph-web