Follow upstream changes -- rest
[git-darcs-import.git] / tests / issue595_get_permissions.sh
blob87a631456638e515cf62d6826ad96b65e162561d
1 #!/usr/bin/env bash
2 set -ev
4 # Issue595
6 # A test for running "darcs get" when the parent directory has restrictive
7 # permissions. The bug is that darcs trys to "chdir" to the current directory
8 # using the full path. The permissions on the parent directory prevent this
9 # from working, even though the current repo and the remote have sufficient
10 # permissions.
12 # The real-world case where this would happen would be a web-server with
13 # restrictive permissions on "/home", with a user running darcs within that.
15 not () { "$@" && exit 1 || :; }
17 if echo $OS | grep -i windows; then
18 echo This test does not work on Windows
19 exit 0
22 rm -rf temp1 temp2
24 # Set up a "remote" repo
25 mkdir tmp_remote
26 cd tmp_remote
27 darcs 'init'
28 cd ..
30 # this is an ugly hack for Cygwin and pwd
31 IFS=''
32 DIR=`hspwd`
34 # Set up a directory with restrictive permissions
35 mkdir -p tmp_restrictive/liberal
36 cd tmp_restrictive/liberal
37 chmod 0111 ../../tmp_restrictive
38 # sanity check that we can cd out and back
39 cd ../..; cd tmp_restrictive/liberal
40 # TODO: we avoid this test on Solaris because it seems we can't create
41 # anything in tmp_restrictive/liberal
42 touch can_touch
43 if [ -e can_touch ]; then
44 if hwpwd; then
45 darcs get $DIR/tmp_remote 2> log
46 not grep -i 'permission denied' log
47 else
48 echo "Apparently I can't do `basename $0` on this platform"
50 else
51 echo "Can't do `basename $0` on this platform"
53 cd $DIR
54 # We have to fix the permissions, just so we can delete it.
55 chmod 0755 tmp_restrictive
57 rm -rf tmp_remote tmp_restrictive