[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: svn commit: rev 1694 - trunk/subversion/tests/clients/cmdline/svntest

From: Sander Striker <striker_at_apache.org>
Date: 2002-04-15 15:05:39 CEST

> From: Greg Stein [mailto:gstein@lyra.org]
> Sent: 15 April 2002 09:15

> Hmm. That change should not have had to go in. shutil.copytree() *does* try
> to copy the permission information. It calls os.chmod() to do so. (it also
> copies the timestamp)
>
> Are you sure it wasn't copying the mode bits, and it is simply that the
> Apache process needed the a+rw ? i.e. your source files didn't have the
> right permissions?
>
> Basically, I'm suspicious of this change. I'd tend to be at a -1 on it
> without knowing more about the source and destinations perms that you were
> trying to achieve.
>
> Cheers,
> -g

Ok, some more testing and fiddling, first remove the lines I committed:

Index: ./subversion/tests/clients/cmdline/svntest/actions.py
===================================================================
--- ./subversion/tests/clients/cmdline/svntest/actions.py
+++ ./subversion/tests/clients/cmdline/svntest/actions.py Mon Apr 15 13:06:14 2002
@@ -91,9 +91,6 @@
     os.makedirs(os.path.dirname(path))
   shutil.copytree(main.pristine_dir, path)

- # make the repos world-writeable, for mod_dav_svn's sake.
- os.system('chmod -R a+rw ' + path)
-
   if os.path.exists(main.current_repo_dir):
     os.unlink(main.current_repo_dir)
   os.symlink(os.path.basename(path), main.current_repo_dir)

Then add this patch to reset a restrictive umask setting:

Index: ./subversion/tests/clients/cmdline/svntest/main.py
===================================================================
--- ./subversion/tests/clients/cmdline/svntest/main.py
+++ ./subversion/tests/clients/cmdline/svntest/main.py Mon Apr 15 12:55:33 2002
@@ -365,6 +365,8 @@
       except ValueError:
         pass

+ os.umask(0);
+
   exit_code = _internal_run_tests(test_list, testnum)

   # remove all scratchwork: the 'pristine' repository, greek tree, etc.

$ cd subversion/tests/clients/cmdline

Now, step through the code in guarantee_greek_repository. We first create
a pristine repos. This gets its perms set very relaxed by the obscure
'chmod' call. This should be replaced by something more portable, but
it gives us this:

$ ls -lR local_tmp/repos
local_tmp/repos:
total 6
-rw-rw-rw- 1 striker striker 376 Apr 15 13:57 README
drwxrwxrwx 2 striker striker 48 Apr 15 13:57 conf
drwxrwxrwx 2 striker striker 48 Apr 15 13:57 dav
drwxrwxrwx 2 striker striker 376 Apr 15 13:57 db
drwxrwxrwx 2 striker striker 232 Apr 15 13:57 hooks
drwxrwxrwx 2 striker striker 72 Apr 15 13:57 locks

local_tmp/repos/conf:
total 0

local_tmp/repos/dav:
total 0

local_tmp/repos/db:
total 424
-rw-rw-rw- 1 striker striker 328 Apr 15 13:57 DB_CONFIG
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:57 __db.001
-rw-rw-rw- 1 striker striker 270336 Apr 15 13:57 __db.002
-rw-rw-rw- 1 striker striker 327680 Apr 15 13:57 __db.003
-rw-rw-rw- 1 striker striker 360448 Apr 15 13:57 __db.004
-rw-rw-rw- 1 striker striker 16384 Apr 15 13:57 __db.005
-rw-rw-rw- 1 striker striker 44369 Apr 15 13:57 log.0000000001
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:57 nodes
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:57 representations
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:57 revisions
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:57 strings
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:57 transactions

local_tmp/repos/hooks:
total 20
-rw-rw-rw- 1 striker striker 1302 Apr 15 13:57 post-commit.tmpl
-rw-rw-rw- 1 striker striker 1366 Apr 15 13:57 pre-commit.tmpl
-rw-rw-rw- 1 striker striker 99 Apr 15 13:57 read-sentinels.tmpl
-rw-rw-rw- 1 striker striker 1322 Apr 15 13:57 start-commit.tmpl
-rw-rw-rw- 1 striker striker 101 Apr 15 13:57 write-sentinels.tmpl

local_tmp/repos/locks:
total 4
-rw-rw-rw- 1 striker striker 460 Apr 15 13:57 db.lock

Then an import takes place giving us this:

$ ls -lR local_tmp/repos/
local_tmp/repos:
total 6
-rw-rw-rw- 1 striker striker 376 Apr 15 13:58 README
drwxrwxrwx 2 striker striker 1024 Apr 15 13:58 conf
drwxrwxrwx 2 striker striker 1024 Apr 15 13:58 dav
drwxrwxrwx 2 striker striker 1024 Apr 15 13:58 db
drwxrwxrwx 2 striker striker 1024 Apr 15 13:58 hooks
drwxrwxrwx 2 striker striker 1024 Apr 15 13:58 locks

local_tmp/repos/conf:
total 0

local_tmp/repos/dav:
total 8
-rwxr-xr-x 1 httpd httpd 12288 Apr 15 13:58 activities

local_tmp/repos/db:
total 489
-rw-rw-rw- 1 striker striker 328 Apr 15 13:58 DB_CONFIG
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:58 __db.001
-rw-rw-rw- 1 striker striker 270336 Apr 15 13:58 __db.002
-rw-rw-rw- 1 striker striker 327680 Apr 15 13:58 __db.003
-rw-rw-rw- 1 striker striker 360448 Apr 15 13:58 __db.004
-rw-rw-rw- 1 striker striker 16384 Apr 15 13:58 __db.005
-rw-rw-rw- 1 striker striker 105388 Apr 15 13:58 log.0000000001
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:58 nodes
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:58 representations
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:58 revisions
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:58 strings
-rw-rw-rw- 1 striker striker 8192 Apr 15 13:58 transactions

local_tmp/repos/hooks:
total 8
-rw-rw-rw- 1 striker striker 1302 Apr 15 13:58 post-commit.tmpl
-rw-rw-rw- 1 striker striker 1366 Apr 15 13:58 pre-commit.tmpl
-rw-rw-rw- 1 striker striker 99 Apr 15 13:58 read-sentinels.tmpl
-rw-rw-rw- 1 striker striker 1322 Apr 15 13:58 start-commit.tmpl
-rw-rw-rw- 1 striker striker 101 Apr 15 13:58 write-sentinels.tmpl

local_tmp/repos/locks:
total 1
-rw-rw-rw- 1 striker striker 460 Apr 15 13:58 db.lock

All seems fine. Now, the pristine repos gets copied (using shutil.copytree).
All permissions copy fine now, but we see a different problem:

$ ls -lR repositories/basic_tests-3/dav/
repositories/basic_tests-3/dav:
total 12
-rwxr-xr-x 1 striker striker 12288 Apr 15 13:59 activities

Ownership changed. And since the perms on activities stay the same,
my httpd user doesn't have write access to that file anymore.
And this causes tests to fail for obvious reasons.

I would love to help out here, but my py-fu would only get me a very
pale belt. Someone with a black belt that wasn't washed that many
times is very welcome to jump in ;)

Sander

PS. Would something like this work to recursively set perms?

def relax_perms(dir):
    "Recursively set the perms to be very relaxed."

    mode = os.stat(dir)[ST_MODE]
    os.chmod(dir, S_IMODE(mode) | 0022)

    for path in os.listdir(dir):
        pathname = '%s/%s' % (dir, path)
        mode = os.stat(pathname)[ST_MODE]
        if S_ISDIR(mode):
            # It's a directory, recurse into it
            relax_perms(pathname)
        elif S_ISREG(mode):
            # It's a file, set its perms
            os.chmod(pathname, S_IMODE(mode) | 0022)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Apr 15 15:00:15 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.