Comments (7)
I've run your test on Ubuntu 12.04 and saw no issues.
Can you narrow down a bit more what is going on there, is it trying to add() a file to a tarball that has a different owner without specifying the target owner?
from archive-tar-wrapper-perl.
It also fails on an OS X 10.8.5 system.
The following hunk of stuff demonstrates that there's something odd or magical on the mac about directories created in $ENV{TMPDIR} vs things in other places (e.g. ~/tmp).
I can mkdir ~/tmp/poodle, call chown on it and get a successful return value (1, in this case).
On the other hand, when I mkdir something under $ENV{TMPDIR} and call chown on it I get an unsuccessful return value (0, in this case).
ls -ld@
, doesn't indicate anything magical about the $ENV{TMPDIR} directory, nor does a series of `ls -ld@' walking up the tree above $ENV{TMPDIR}.
georgewh-L0DKQ1:foo georgewh$ perl -d -Ilib t/tester.t
Loading DB routines from perl5db.pl version 1.39_10
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
use main::(t/tester.t:8): my $tzil = Builder->from_config(
main::(t/tester.t:9): { dist_root => 'corpus/dist/DZT' },
main::(t/tester.t:10): { add_files => {
main::(t/tester.t:11): 'source/zero' => '',
main::(t/tester.t:12): 'source/dist.ini' => simple_ini({
main::(t/tester.t:13): name => 'DZT',
DB<1> Archive::Tar::Wrapper
DB<2> f Wrapper.pm
Choosing /Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm matching 'Wrapper.pm':
DB<3> b 248
DB<4> c
Archive::Tar::Wrapper::perm_set(/Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm:248):
248: chown($perms->[1], $perms->[2], $filename) or
249: LOGDIE "Cannot chown $filename ($!)";
DB<4> x $filename
0 '/var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/cJHoBccbLD/tar/DZT-0.001'
DB<5> ^Z
[1]+ Stopped perl -d -Ilib t/tester.t
georgewh-L0DKQ1:foo georgewh$ ls -l@d /var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/cJHoBccbLD/tar/DZT-0.001
drwxr-xr-x 2 georgewh FOO\Domain Users 68 Mar 31 09:46 /var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/cJHoBccbLD/tar/DZT-0.001
georgewh-L0DKQ1:foo georgewh$ fg
perl -d -Ilib t/tester.t
x $perms
0 ARRAY(0x7f82fe7862a0)
0 16877
1 1722774870
2 20
DB<6> x chown(1722774870, 20, "/var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/cJHoBccbLD/tar/DZT-0.001")
0 0
DB<7> x mkdir("/Users/georgewh/tmp/poodle")
0 1
DB<8> x chown(1722774870, 20, "/Users/georgewh/tmp/poodle")
0 1
DB<9> ^Z
[1]+ Stopped perl -d -Ilib t/tester.t
georgewh-L0DKQ1:foo georgewh$ ls -ld@ /var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/cJHoBccbLD/tar/DZT-0.001
drwxr-xr-x 2 georgewh FOO\Domain Users 68 Mar 31 09:46 /var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/cJHoBccbLD/tar/DZT-0.001
georgewh-L0DKQ1:foo georgewh$ ls -ld@ /Users/georgewh/tmp/poodle
drwxr-xr-x 2 georgewh staff 68 Mar 31 09:48 /Users/georgewh/tmp/poodle
DB<10> x $ENV{TMPDIR}
0 '/var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/'
DB<11> x mkdir($ENV{TMPDIR} . "/moose")
0 1
DB<12> ^Z
[1]+ Stopped perl -d -Ilib t/tester.t
georgewh-L0DKQ1:foo georgewh$ ls -ld@ /var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/moose
drwxr-xr-x 2 georgewh FOO\Domain Users 68 Mar 31 09:52 /var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/moose
georgewh-L0DKQ1:foo georgewh$ fg
perl -d -Ilib t/tester.t
DB<12> x chown(1722774870, 20, $ENV{TMPDIR} . "/moose")
0 0
DB<13>
So it seems as if there's something magical about $ENV{TMPDIR}.
from archive-tar-wrapper-perl.
And after more digging, the problem seems to be that the gid of the directory being chowned is not the same as the gid in the perms arrayref.
georgewh-L0DKQ1:foo georgewh$ perl -d -Ilib t/tester.t
Loading DB routines from perl5db.pl version 1.39_10
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(t/tester.t:8): my $tzil = Builder->from_config(
main::(t/tester.t:9): { dist_root => 'corpus/dist/DZT' },
main::(t/tester.t:10): { add_files => {
main::(t/tester.t:11): 'source/zero' => '',
main::(t/tester.t:12): 'source/dist.ini' => simple_ini({
main::(t/tester.t:13): name => 'DZT',
DB<1> use Archive::Tar::Wrapper
DB<2> f Wrapper.pm
Choosing /Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm matching 'Wrapper.pm':
DB<3> b 248
DB<4> c
Archive::Tar::Wrapper::perm_set(/Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm:248):
248: chown($perms->[1], $perms->[2], $filename) or
249: LOGDIE "Cannot chown $filename ($!)";
DB<4> x $perms
0 ARRAY(0x7ffa6f786eb8)
0 16877
1 1722774870
2 20
DB<5> use POSIX
DB<6> x getgid
0 897519590
DB<7> x chown($perms->[1], $perms->[2], $filename)
0 0
DB<8> x chown($perms->[1], 897519590, $filename)
0 1
DB<9> q
georgewh-L0DKQ1:foo georgewh$ grep 20 /etc/group
staff:*:20:root
[...]
The gid
of my home directory is staff (20), which is odd because I do not appear to be in group staff (looking at /etc/group).
perm_set
is trying to chown to group staff because it is being called by perm_cp
, which is trying to copy the permissions from something that was created in my home dir and has a gid of 20.
@ = DB::DB called from file '/Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm' line 248
$ = Archive::Tar::Wrapper::perm_set('/var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/BBir54HZBQ/tar/DZT-0.001', ref(ARRAY)) called from file '/Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm' line 229
$ = Archive::Tar::Wrapper::perm_cp('/Users/georgewh/foo/tmp/Rt1fyBwAOI/build', '/var/folders/wt/qq_npw8n6sjgwnd38thzd6hxl_yx_p/T/BBir54HZBQ/tar/DZT-0.001') called from file '/Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm' line 215
. = Archive::Tar::Wrapper::add(ref(Archive::Tar::Wrapper), 'DZT-0.001', '/Users/georgewh/foo/tmp/Rt1fyBwAOI/build') called from file '/Users/georgewh/.perlbrew/libs/perl-5.18.2@critical/lib/perl5/Archive/Tar/Wrapper.pm' line 177
. = Archive::Tar::Wrapper::add(ref(Archive::Tar::Wrapper), 'DZT-0.001/zero', '/Users/georgewh/foo/tmp/Rt1fyBwAOI/build/zero', ref(HASH)) called from file 'lib/Dist/Zilla/Dist/Builder.pm' line 513
Odd....
from archive-tar-wrapper-perl.
And for what it's worth, the man page for the chgrp command (/usr/bin/chgrp) includes the following quote:
The user invoking chgrp must belong to the specified group and be the owner of the file, or be the super-user.
I checked another cow-orker's mac; his home directory is group=staff and he is not in the staff group. It still might be company related weirdness, will check a couple of other macs at home this evening.
from archive-tar-wrapper-perl.
I've checked two simply configured OS X systems (not using netgroups or ldap or ...).
In both cases my home directory and my $TMPDIR directory are owned by staff
and in neither case am I a member of that group.
So the common thread seems to be that the tar ball is created in/under my homedir and it is noted that things were in group staff
. It gets untar'ed somewhere as me and ends up in a different group. Archive::Tar tries to chown them to staff
and kerblooey.
The tar application doesn't try to preserve owner/group info unless one specifies the -p
flag, but it seems to be the default behavior for Archive::Tar.
Is the best solution for OS X users/developers of Dist::Zilla to convince RJBS to set
$Archive::Tar::CHOWN=0;
or is there something cleaner?
from archive-tar-wrapper-perl.
I'm not sure the correct solution, but I'm still seeing this issue too, in Archive-Tar-Wrapper-0.19.
from archive-tar-wrapper-perl.
If you ask Archive::Tar::Wrapper (not to be confused with Archive::Tar, which is a native tar algorithm implementation, whereas Archive::Tar::Wrapper is just a wrapper around the system tar) to add a file to a tarball, it copies it into a temporary directory and then calls the system tar to wrap up that directory into a tarball.
This approach has limitations when it comes to file permissions: If the file to be added belongs to a different user/group, Archive::Tar::Wrapper will adjust the uid/gid/permissions of the target file in the temporary directory to reflect the original file's settings, to make sure the system tar will add it like that to the tarball, just like a regular tar run on the original file would. But this will fail of course if the original file's uid is different from the current user's, unless the script is running with superuser rights. The tar program by itself (without Archive::Tar::Wrapper) works differently: It'll just make a note of a file's uid/gid/permissions in the tarball (which it can do without superuser rights) and upon extraction, it'll adjust the permissions of newly generated files if the -p option is given (default for superuser).
Long story short, I've just released Archive::Tar::Wrapper 0.20 to CPAN which will ignore the different uid/gid/permissions if there's no way to change them. Hope that helps!
from archive-tar-wrapper-perl.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from archive-tar-wrapper-perl.