You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2011/02/12 18:09:14 UTC

svn commit: r1070113 - in /subversion/trunk/subversion: libsvn_repos/repos.c tests/cmdline/svnadmin_tests.py

Author: stsp
Date: Sat Feb 12 17:09:14 2011
New Revision: 1070113

URL: http://svn.apache.org/viewvc?rev=1070113&view=rev
Log:
* subversion/libsvn_repos/repos.c
  (svn_repos-create): Prevent repository creation within all subdirectories
   of a repository, not just within the top-level one, if the current working
   directory is somewhere within the repository.
   While here, show absolute paths in error messages, and send a less
   confusing error message when the user tries to create a repository
   at the location of an existing repository.
 
* subversion/tests/cmdline/svnadmin_tests.py
  (create_in_repo_subdir): Expand this test to cover the case where the
   current working directory is within the repository.

With help from: danielsh

Modified:
    subversion/trunk/subversion/libsvn_repos/repos.c
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py

Modified: subversion/trunk/subversion/libsvn_repos/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.c?rev=1070113&r1=1070112&r2=1070113&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.c (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.c Sat Feb 12 17:09:14 2011
@@ -1369,6 +1369,7 @@ svn_repos_create(svn_repos_t **repos_p,
   svn_repos_t *repos;
   svn_error_t *err;
   const char *root_path;
+  const char *local_abspath;
 
   /* Allocate a repository object, filling in the format we will create. */
   repos = create_svn_repos_t(path, pool);
@@ -1388,13 +1389,21 @@ svn_repos_create(svn_repos_t **repos_p,
     repos->fs_type = DEFAULT_FS_TYPE;
 
   /* Don't create a repository inside another repository. */
-  root_path = svn_repos_find_root_path(path, pool);
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+  root_path = svn_repos_find_root_path(local_abspath, pool);
   if (root_path != NULL)
-    return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL, _("'%s' is a "
-                              "subdirectory of an existing repository rooted "
-                              "at '%s'"),
-                              svn_dirent_local_style(path, pool),
-                              svn_dirent_local_style(root_path, pool));
+    {
+      if (strcmp(root_path, local_abspath) == 0)
+        return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL,
+                                 _("'%s' is an existing repository"),
+                                 svn_dirent_local_style(root_path, pool));
+      else
+        return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL,
+                                 _("'%s' is a subdirectory of an existing "
+                                   "repository " "rooted at '%s'"),
+                                 svn_dirent_local_style(local_abspath, pool),
+                                 svn_dirent_local_style(root_path, pool));
+    }
 
   /* Create the various files and subdirectories for the repository. */
   SVN_ERR_W(create_repos_structure(repos, path, fs_config, pool),

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1070113&r1=1070112&r2=1070113&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Sat Feb 12 17:09:14 2011
@@ -919,6 +919,17 @@ def create_in_repo_subdir(sbox):
     subdir = os.path.join(repo_dir, 'Z')
     svntest.main.create_repos(subdir)
   except svntest.main.SVNRepositoryCreateFailure:
+    pass
+
+  cwd = os.getcwd()
+  try:
+    # This should fail, too
+    subdir = os.path.join(repo_dir, 'db', 'revs')
+    os.chdir(subdir)
+    svntest.main.create_repos('Z')
+    os.chdir(cwd)
+  except svntest.main.SVNRepositoryCreateFailure:
+    os.chdir(cwd)
     return
 
   # No SVNRepositoryCreateFailure raised?



Re: svn commit: r1070113 - in /subversion/trunk/subversion: libsvn_repos/repos.c tests/cmdline/svnadmin_tests.py

Posted by Stefan Sperling <st...@elego.de>.
On Sat, Feb 12, 2011 at 07:22:09PM +0200, Daniel Shahaf wrote:
> stsp@apache.org wrote on Sat, Feb 12, 2011 at 17:09:14 -0000:
> > +++ subversion/trunk/subversion/libsvn_repos/repos.c Sat Feb 12 17:09:14 2011
> > @@ -1369,6 +1369,7 @@ svn_repos_create(svn_repos_t **repos_p,
> 
> +1
> 
> > Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
> > URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1070113&r1=1070112&r2=1070113&view=diff
> > ==============================================================================
> > --- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
> > +++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Sat Feb 12 17:09:14 2011
> > @@ -919,6 +919,17 @@ def create_in_repo_subdir(sbox):
> >      subdir = os.path.join(repo_dir, 'Z')
> >      svntest.main.create_repos(subdir)
> >    except svntest.main.SVNRepositoryCreateFailure:
> > +    pass
> 
> The test used to fail if this except() block didn't run.  Could you
> restore that behaviour?

See r1070117.

> > +
> > +  cwd = os.getcwd()
> > +  try:
> > +    # This should fail, too
> > +    subdir = os.path.join(repo_dir, 'db', 'revs')
> > +    os.chdir(subdir)
> > +    svntest.main.create_repos('Z')
> > +    os.chdir(cwd)
> > +  except svntest.main.SVNRepositoryCreateFailure:
> > +    os.chdir(cwd)
> >      return
> >  
> 
> +1, except that db/revs doesn't exist in BDB repositories.

Oops! See r1070116.

Thanks!

Re: svn commit: r1070113 - in /subversion/trunk/subversion: libsvn_repos/repos.c tests/cmdline/svnadmin_tests.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
stsp@apache.org wrote on Sat, Feb 12, 2011 at 17:09:14 -0000:
> +++ subversion/trunk/subversion/libsvn_repos/repos.c Sat Feb 12 17:09:14 2011
> @@ -1369,6 +1369,7 @@ svn_repos_create(svn_repos_t **repos_p,

+1

> Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1070113&r1=1070112&r2=1070113&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
> +++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Sat Feb 12 17:09:14 2011
> @@ -919,6 +919,17 @@ def create_in_repo_subdir(sbox):
>      subdir = os.path.join(repo_dir, 'Z')
>      svntest.main.create_repos(subdir)
>    except svntest.main.SVNRepositoryCreateFailure:
> +    pass

The test used to fail if this except() block didn't run.  Could you
restore that behaviour?

> +
> +  cwd = os.getcwd()
> +  try:
> +    # This should fail, too
> +    subdir = os.path.join(repo_dir, 'db', 'revs')
> +    os.chdir(subdir)
> +    svntest.main.create_repos('Z')
> +    os.chdir(cwd)
> +  except svntest.main.SVNRepositoryCreateFailure:
> +    os.chdir(cwd)
>      return
>  

+1, except that db/revs doesn't exist in BDB repositories.

Re: svn commit: r1070113 - in /subversion/trunk/subversion: libsvn_repos/repos.c tests/cmdline/svnadmin_tests.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
stsp@apache.org wrote on Sat, Feb 12, 2011 at 17:09:14 -0000:
> +++ subversion/trunk/subversion/libsvn_repos/repos.c Sat Feb 12 17:09:14 2011
> @@ -1369,6 +1369,7 @@ svn_repos_create(svn_repos_t **repos_p,

+1

> Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1070113&r1=1070112&r2=1070113&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
> +++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Sat Feb 12 17:09:14 2011
> @@ -919,6 +919,17 @@ def create_in_repo_subdir(sbox):
>      subdir = os.path.join(repo_dir, 'Z')
>      svntest.main.create_repos(subdir)
>    except svntest.main.SVNRepositoryCreateFailure:
> +    pass

The test used to fail if this except() block didn't run.  Could you
restore that behaviour?

> +
> +  cwd = os.getcwd()
> +  try:
> +    # This should fail, too
> +    subdir = os.path.join(repo_dir, 'db', 'revs')
> +    os.chdir(subdir)
> +    svntest.main.create_repos('Z')
> +    os.chdir(cwd)
> +  except svntest.main.SVNRepositoryCreateFailure:
> +    os.chdir(cwd)
>      return
>  

+1, except that db/revs doesn't exist in BDB repositories.