5 # A test for running "darcs get" when the parent directory has restrictive
6 # permissions. The bug is that darcs trys to "chdir" to the current directory
7 # using the full path. The permissions on the parent directory prevent this
8 # from working, even though the current repo and the remote have sufficient
11 # The real-world case where this would happen would be a web-server with
12 # restrictive permissions on "/home", with a user running darcs within that.
14 # Also find the right path from the bugs directory.
15 use lib
('lib/perl', '../tests/lib/perl');
16 use Test
::More
'no_plan';
22 # Start in a randomly named temporary directory that deletes itself when we're done.
23 use File
::Temp
'tempdir';
24 chdir tempdir
( CLEANUP
=> 1 );
28 # Set up a "remote" repo
29 # and a directory with restrictive permissions with
30 ok
(mkpath
('tmp_remote'), "tmp_remote created");
31 ok
(mkpath
('tmp_restrictive/liberal'), "tmp_restrictive/liberal created");
33 ok
(chdir('tmp_remote'), "chdir tmp_remote");
36 ok
( chdir('../tmp_restrictive/liberal'), "chdir to liberal") || die;;
39 # Get the path just above these repos;
40 my $top_path = realpath
();
41 $top_path =~ s?tmp_restrictive
/liberal??
;
42 my $remote_full_path = "$top_path/tmp_remote";
44 ok
(chmod('0111', '../../tmp_restrictive'), 'chmod 0111 of tmp_restrictive');
46 ok
( chdir('../..'), 'can cd out of our darcs repository');
48 ok
( chdir('tmp_restrictive/liberal'), 'can cd back into our darcs repository');
50 if (realpath
() =~ qr/tmp_restrictive.liberal/) {
52 my $out = darcs
"get $remote_full_path";
53 unlike
($out, qr/permission denied/i, "Avoid permission denied error");
57 local $TODO = 'it seems that solaris does not allow CD into directory?';
58 ok
(0,"Can't do restrictive_upstream_permissions.pl on this platform.");
62 ok
(chdir("$top_path"), "chdir $top_path");
63 # We have to fix the permissions, just so we can delete it.
64 ok
(chmod('0755', 'tmp_restrictive'), 'chmod 0755 of tmp_restrictive');