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

[PATCH] Improve the way svnserve handles the --root option

From: Vlad Georgescu <vgeorgescu_at_gmail.com>
Date: 2006-12-04 21:41:09 CET

Hi,

This patch does two things:
1. Checks that the path passed to --root exists and is a directory.
2. Makes the --root option mandatory on Windows, because the default
that we currently use ('/') only makes sense on Unix-like OS's.

[[[
Improve the way svnserve handles the --root option.

* subversion/svnserve/main.c:
  Include "svn_io.h".
  (main): Make the --root option mandatory on Windows. Make sure the
   path passed to --root actually exists.
]]]

Index: subversion/svnserve/main.c
===================================================================
--- subversion/svnserve/main.c (revision 22552)
+++ subversion/svnserve/main.c (working copy)
@@ -40,6 +40,7 @@
 #include "svn_repos.h"
 #include "svn_fs.h"
 #include "svn_version.h"
+#include "svn_io.h"

 #include "svn_private_config.h"
 #include "winservice.h"
@@ -324,6 +325,7 @@
   int family = APR_INET;
   int mode_opt_count = 0;
   const char *pid_filename = NULL;
+ svn_node_kind_t kind;

   /* Initialize the app. */
   if (svn_cmdline_init("svnserve", stderr) != EXIT_SUCCESS)
@@ -360,7 +362,11 @@
   if (err)
     return svn_cmdline_handle_exit_error(err, pool, "svnserve: ");

+#ifdef WIN32
+ params.root = NULL;
+#else
   params.root = "/";
+#endif /* WIN32 */
   params.tunnel = FALSE;
   params.tunnel_user = NULL;
   params.read_only = FALSE;
@@ -432,6 +438,24 @@

         case 'r':
           SVN_INT_ERR(svn_utf_cstring_to_utf8(&params.root, arg, pool));
+
+ err = svn_io_check_resolved_path(params.root, &kind, pool);
+ if (err)
+ {
+ svn_handle_error2(err, stderr, FALSE, "svnserve: ");
+ svn_error_clear(err);
+ return EXIT_FAILURE;
+ }
+ if (kind != svn_node_dir)
+ {
+ svn_error_clear
+ (svn_cmdline_fprintf
+ (stderr, pool,
+ _("svnserve: Root path '%s' does not exist "
+ "or is not a directory.\n"), params.root));
+ return EXIT_FAILURE;
+ }
+
           params.root = svn_path_internal_style(params.root, pool);
           SVN_INT_ERR(svn_path_get_absolute(&params.root, params.root, pool));
           break;
@@ -463,6 +487,18 @@

         }
     }
+
+#ifdef WIN32
+ if (! params.root)
+ {
+ svn_error_clear
+ (svn_cmdline_fputs
+ (_("You must specify a root path with the --root option.\n"),
+ stderr, pool));
+ return EXIT_FAILURE;
+ }
+#endif /* WIN32 */
+
   if (os->ind != argc)
     usage(argv[0], pool);

-- 
Vlad
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Dec 4 21:41:32 2006

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.