From dev-return-37475-archive-asf-public=cust-asf.ponee.io@subversion.apache.org Wed Feb 14 11:03:47 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 642F7180621 for ; Wed, 14 Feb 2018 11:03:47 +0100 (CET) Received: (qmail 79522 invoked by uid 500); 14 Feb 2018 10:03:46 -0000 Mailing-List: contact dev-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@subversion.apache.org Delivered-To: moderator for dev@subversion.apache.org Received: (qmail 37095 invoked by uid 99); 14 Feb 2018 09:47:09 -0000 X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=disabled X-Virus-Scanned: Debian amavisd-new at eu.adacore.com Date: Wed, 14 Feb 2018 10:46:57 +0100 From: Thomas Quinot To: dev@subversion.apache.org Cc: Thomas Quinot Subject: [PATCH] Virtual host mode with user name in URL Message-ID: <20180214094632.gssa4zozx3546w4l@malevil.eu.adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zfi5ejwfayj6ebdg" Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) --zfi5ejwfayj6ebdg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Bug reproduced on Debian GNU/Linux 9 with trunk version as of revision 1824204, building with default options. When operating svnserve in virtual host mode (--virtual-host), any attempt to access a repository through a URL that includes a user name will fail: $ mkdir -p /tmp/repos/localhost $ svnadmin create /tmp/repos/localhost/Dev $ svnserve -r /tmp/repos -d --virtual-host $ svn ls svn://localhost/Dev $ svn ls svn://foo@localhost/Dev svn: E170013: Unable to connect to a repository at URL 'svn://foo@localhost/Dev' svn: E210005: No repository found in 'svn://foo@localhost/Dev' The reason for this is that svnserve will in this case include the user name in the repository path, which can be shown as follows: $ ln -s localhost /tmp/repos/foo@localhost $ svn ls svn://foo@localhost/Dev $ svn ls svn://bar@localhost/Dev svn: E170013: Unable to connect to a repository at URL 'svn://bar@localhost/Dev' svn: E210005: No repository found in 'svn://bar@localhost/Dev' A simple fix is attached. -- Thomas Quinot, Ph.D. ** quinot@adacore.com ** IT Lead Engineer AdaCore -- Paris, France -- New York, USA --zfi5ejwfayj6ebdg Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="svnserve-vhost-username.diff" [[[ Fix failure to find repo in virtual host mode if user name present * subversion/svnserve/serve.c (find_repos): In vhost mode, skip past user name and password, if present. ]]] Index: subversion/svnserve/serve.c =================================================================== --- subversion/svnserve/serve.c (revision 1824204) +++ subversion/svnserve/serve.c (working copy) @@ -3806,12 +3806,21 @@ find_repos(const char *url, return svn_error_createf(SVN_ERR_BAD_URL, NULL, "Non-svn URL passed to svn server: '%s'", url); - if (! vhost) + /* In virtual host mode, skip past any USER[:PASSWORD]@ part, + else skip past [USER[:PASSWORD]@]HOST/. */ + if (vhost) { + const char *h_path = strchr(path, '@'); + if (h_path != NULL) + path = h_path + 1; + } + else + { path = strchr(path, '/'); if (path == NULL) path = ""; } + path = svn_relpath_canonicalize(path, scratch_pool); path = svn_path_uri_decode(path, scratch_pool); --zfi5ejwfayj6ebdg--