2014-08-06 20:43:59 +04:00
|
|
|
#require unix-permissions
|
2010-08-30 07:46:19 +04:00
|
|
|
|
2014-08-06 20:43:59 +04:00
|
|
|
test that new files created in .hg inherit the permissions from .hg/store
|
2010-08-30 07:46:19 +04:00
|
|
|
|
|
|
|
$ mkdir dir
|
|
|
|
|
|
|
|
just in case somebody has a strange $TMPDIR
|
|
|
|
|
|
|
|
$ chmod g-s dir
|
|
|
|
$ cd dir
|
|
|
|
|
|
|
|
$ cat >printmodes.py <<EOF
|
2017-08-23 00:15:09 +03:00
|
|
|
> from __future__ import absolute_import, print_function
|
|
|
|
> import os
|
|
|
|
> import sys
|
2010-08-30 07:46:19 +04:00
|
|
|
>
|
|
|
|
> allnames = []
|
|
|
|
> isdir = {}
|
|
|
|
> for root, dirs, files in os.walk(sys.argv[1]):
|
|
|
|
> for d in dirs:
|
2010-10-16 20:09:01 +04:00
|
|
|
> name = os.path.join(root, d)
|
|
|
|
> isdir[name] = 1
|
|
|
|
> allnames.append(name)
|
2010-08-30 07:46:19 +04:00
|
|
|
> for f in files:
|
2010-10-16 20:09:01 +04:00
|
|
|
> name = os.path.join(root, f)
|
|
|
|
> allnames.append(name)
|
2010-08-30 07:46:19 +04:00
|
|
|
> allnames.sort()
|
|
|
|
> for name in allnames:
|
|
|
|
> suffix = name in isdir and '/' or ''
|
2017-08-23 00:15:09 +03:00
|
|
|
> print('%05o %s%s' % (os.lstat(name).st_mode & 0o7777, name, suffix))
|
2010-08-30 07:46:19 +04:00
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ cat >mode.py <<EOF
|
2017-08-23 00:15:09 +03:00
|
|
|
> from __future__ import absolute_import, print_function
|
2010-08-30 07:46:19 +04:00
|
|
|
> import os
|
2017-08-23 00:15:09 +03:00
|
|
|
> import sys
|
2017-06-15 21:22:25 +03:00
|
|
|
> print('%05o' % os.lstat(sys.argv[1]).st_mode)
|
2010-08-30 07:46:19 +04:00
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ umask 077
|
|
|
|
|
|
|
|
$ hg init repo
|
|
|
|
$ cd repo
|
|
|
|
|
|
|
|
$ chmod 0770 .hg/store
|
|
|
|
|
|
|
|
before commit
|
|
|
|
store can be written by the group, other files cannot
|
|
|
|
store is setgid
|
|
|
|
|
2017-06-20 16:45:02 +03:00
|
|
|
$ $PYTHON ../printmodes.py .
|
2010-08-30 07:46:19 +04:00
|
|
|
00700 ./.hg/
|
|
|
|
00600 ./.hg/00changelog.i
|
|
|
|
00600 ./.hg/requires
|
|
|
|
00770 ./.hg/store/
|
2018-09-15 13:15:46 +03:00
|
|
|
00600 ./.hg/store/requires
|
2010-08-30 07:46:19 +04:00
|
|
|
|
|
|
|
$ mkdir dir
|
|
|
|
$ touch foo dir/bar
|
|
|
|
$ hg ci -qAm 'add files'
|
|
|
|
|
|
|
|
after commit
|
|
|
|
working dir files can only be written by the owner
|
|
|
|
files created in .hg can be written by the group
|
|
|
|
(in particular, store/**, dirstate, branch cache file, undo files)
|
|
|
|
new directories are setgid
|
|
|
|
|
2017-06-20 16:45:02 +03:00
|
|
|
$ $PYTHON ../printmodes.py .
|
2010-08-30 07:46:19 +04:00
|
|
|
00700 ./.hg/
|
|
|
|
00600 ./.hg/00changelog.i
|
|
|
|
00660 ./.hg/dirstate
|
|
|
|
00660 ./.hg/last-message.txt
|
|
|
|
00600 ./.hg/requires
|
|
|
|
00770 ./.hg/store/
|
|
|
|
00660 ./.hg/store/00changelog.i
|
|
|
|
00660 ./.hg/store/00manifest.i
|
|
|
|
00770 ./.hg/store/data/
|
|
|
|
00770 ./.hg/store/data/dir/
|
|
|
|
00660 ./.hg/store/data/dir/bar.i
|
|
|
|
00660 ./.hg/store/data/foo.i
|
|
|
|
00660 ./.hg/store/fncache
|
2011-11-11 03:15:22 +04:00
|
|
|
00660 ./.hg/store/phaseroots
|
2018-09-15 13:15:46 +03:00
|
|
|
00600 ./.hg/store/requires
|
2010-08-30 07:46:19 +04:00
|
|
|
00660 ./.hg/store/undo
|
2015-01-17 05:34:14 +03:00
|
|
|
00660 ./.hg/store/undo.backupfiles
|
2011-11-07 15:27:25 +04:00
|
|
|
00660 ./.hg/store/undo.phaseroots
|
2018-07-28 03:58:22 +03:00
|
|
|
00700 ./.hg/treestate/
|
|
|
|
00600 ./.hg/treestate/* (glob)
|
2015-11-18 12:36:58 +03:00
|
|
|
00660 ./.hg/undo.backup.dirstate
|
2011-05-01 15:07:00 +04:00
|
|
|
00660 ./.hg/undo.bookmarks
|
2010-08-30 07:46:19 +04:00
|
|
|
00660 ./.hg/undo.branch
|
|
|
|
00660 ./.hg/undo.desc
|
|
|
|
00660 ./.hg/undo.dirstate
|
|
|
|
00700 ./dir/
|
|
|
|
00600 ./dir/bar
|
|
|
|
00600 ./foo
|
|
|
|
|
|
|
|
$ umask 007
|
|
|
|
$ hg init ../push
|
|
|
|
|
|
|
|
before push
|
|
|
|
group can write everything
|
|
|
|
|
2017-06-20 16:45:02 +03:00
|
|
|
$ $PYTHON ../printmodes.py ../push
|
2010-08-30 07:46:19 +04:00
|
|
|
00770 ../push/.hg/
|
|
|
|
00660 ../push/.hg/00changelog.i
|
|
|
|
00660 ../push/.hg/requires
|
|
|
|
00770 ../push/.hg/store/
|
2018-09-15 13:15:46 +03:00
|
|
|
00660 ../push/.hg/store/requires
|
2010-08-30 07:46:19 +04:00
|
|
|
|
|
|
|
$ umask 077
|
|
|
|
$ hg -q push ../push
|
|
|
|
|
|
|
|
after push
|
|
|
|
group can still write everything
|
|
|
|
|
2017-06-20 16:45:02 +03:00
|
|
|
$ $PYTHON ../printmodes.py ../push
|
2010-08-30 07:46:19 +04:00
|
|
|
00770 ../push/.hg/
|
|
|
|
00660 ../push/.hg/00changelog.i
|
2016-05-12 00:18:52 +03:00
|
|
|
00660 ../push/.hg/dirstate
|
2010-08-30 07:46:19 +04:00
|
|
|
00660 ../push/.hg/requires
|
|
|
|
00770 ../push/.hg/store/
|
|
|
|
00660 ../push/.hg/store/00changelog.i
|
|
|
|
00660 ../push/.hg/store/00manifest.i
|
|
|
|
00770 ../push/.hg/store/data/
|
|
|
|
00770 ../push/.hg/store/data/dir/
|
|
|
|
00660 ../push/.hg/store/data/dir/bar.i
|
|
|
|
00660 ../push/.hg/store/data/foo.i
|
|
|
|
00660 ../push/.hg/store/fncache
|
2018-09-15 13:15:46 +03:00
|
|
|
00660 ../push/.hg/store/requires
|
2010-08-30 07:46:19 +04:00
|
|
|
00660 ../push/.hg/store/undo
|
2015-01-17 05:34:14 +03:00
|
|
|
00660 ../push/.hg/store/undo.backupfiles
|
2011-11-07 15:27:25 +04:00
|
|
|
00660 ../push/.hg/store/undo.phaseroots
|
2018-07-28 03:58:22 +03:00
|
|
|
00700 ../push/.hg/treestate/
|
|
|
|
00600 ../push/.hg/treestate/* (glob)
|
2011-05-01 15:07:00 +04:00
|
|
|
00660 ../push/.hg/undo.bookmarks
|
2010-08-30 07:46:19 +04:00
|
|
|
00660 ../push/.hg/undo.branch
|
|
|
|
00660 ../push/.hg/undo.desc
|
|
|
|
00660 ../push/.hg/undo.dirstate
|
|
|
|
|
|
|
|
|
|
|
|
Test that we don't lose the setgid bit when we call chmod.
|
|
|
|
Not all systems support setgid directories (e.g. HFS+), so
|
|
|
|
just check that directories have the same mode.
|
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
$ hg init setgid
|
|
|
|
$ cd setgid
|
|
|
|
$ chmod g+rwx .hg/store
|
2012-03-02 03:29:52 +04:00
|
|
|
$ chmod g+s .hg/store 2> /dev/null || true
|
2010-08-30 07:46:19 +04:00
|
|
|
$ mkdir dir
|
|
|
|
$ touch dir/file
|
|
|
|
$ hg ci -qAm 'add dir/file'
|
2017-06-20 16:45:02 +03:00
|
|
|
$ storemode=`$PYTHON ../mode.py .hg/store`
|
|
|
|
$ dirmode=`$PYTHON ../mode.py .hg/store/data/dir`
|
2010-08-30 07:46:19 +04:00
|
|
|
$ if [ "$storemode" != "$dirmode" ]; then
|
|
|
|
> echo "$storemode != $dirmode"
|
2012-06-11 03:38:32 +04:00
|
|
|
> fi
|
|
|
|
$ cd ..
|
|
|
|
|
|
|
|
$ cd .. # g-s dir
|