1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00
phorge-phorge/scripts
epriestley 9b359affe7 Prepare SSH connections for proxying
Summary:
Ref T7034.

In a cluster environment, when a user connects with a VCS request over SSH (like `git pull`), the receiving server may need to proxy it to a server which can actually satisfy the request.

In order to proxy the request, we need to know which repository the user is interested in accessing.

Split the SSH workflow into two steps:

  # First, identify the repository.
  # Then, execute the operation.

In the future, this will allow us to put a possible "proxy the whole thing somewhere else" step in the middle, mirroring the behavior of Conduit.

This is trivially easy in `git` and `hg`. Both identify the repository on the commmand line.

This is fiendishly complex in `svn`, for the same reasons that hosting SVN was hard in the first place. Specifically:

  - The client doesn't tell us what it's after.
  - To get it to tell us, we have to send it a server capabilities string //first//.
  - We can't just start an `svnserve` process and read the repository out after a little while, because we may need to proxy the request once we figure out the repository.
  - We can't consume the client protocol frame that tells us what the client wants, because when we start the real server request it won't know what the client is after if it never receives that frame.
  - On the other hand, we must consume the second copy of the server protocol frame that would be sent to the client, or they'll get two "HELLO" messages and not know what to do.

The approach here is straightforward, but the implementation is not trivial. Roughly:

  - Start `svnserve`, read the "hello" frame from it.
  - Kill `svnserve`.
  - Send the "hello" to the client.
  - Wait for the client to send us "I want repository X".
  - Save the message it sent us in the "peekBuffer".
  - Return "this is a request for repository X", so we can proxy it.

Then, to continue the request:

  - Start the real `svnserve`.
  - Read the "hello" frame from it and throw it away.
  - Write the data in the "peekBuffer" to it, as though we'd just received it from the client.
  - State of the world is normal again, so we can continue.

Also fixed some other issues:

  - SVN could choke if `repository.default-local-path` contained extra slashes.
  - PHP might emit some complaints when executing the commit hook; silence those.

Test Plan: Pushed and pulled repositories in SVN, Mercurial and Git.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7034

Differential Revision: https://secure.phabricator.com/D11541
2015-01-28 10:18:07 -08:00
..
almanac Implement storage of a host ID and a public key for authorizing Conduit between servers 2014-10-03 22:52:41 +10:00
aphront Applied various linter fixes. 2014-06-09 16:04:12 -07:00
cache Discover workflows automatically. 2014-06-16 09:00:25 +10:00
calendar Change double quotes to single quotes. 2014-06-09 11:36:50 -07:00
celerity Delete app icons 2015-01-27 12:36:39 -08:00
daemon Discover workflows automatically. 2014-06-16 09:00:25 +10:00
diviner Make all bin/* scripts locate their workflows dynamically 2013-12-27 13:15:48 -08:00
drydock Make all bin/* scripts locate their workflows dynamically 2013-12-27 13:15:48 -08:00
fact Make all bin/* scripts locate their workflows dynamically 2013-12-27 13:15:48 -08:00
files Make all bin/* scripts locate their workflows dynamically 2013-12-27 13:15:48 -08:00
fpm Delete license headers from files 2012-11-05 11:16:51 -08:00
install Update Aphlict documentation for new server management commands 2014-06-05 12:40:53 -07:00
lipsum Make all bin/* scripts locate their workflows dynamically 2013-12-27 13:15:48 -08:00
mail Change double quotes to single quotes. 2014-06-09 11:36:50 -07:00
repository Prepare SSH connections for proxying 2015-01-28 10:18:07 -08:00
search Remove various old things in scripts/ 2014-05-01 18:23:48 -07:00
setup Add bin/trigger, for testing event triggers 2015-01-20 11:31:32 -08:00
sms Add SMS support 2014-05-09 12:47:21 -07:00
sql Minor linter fixes 2014-12-09 18:37:32 +11:00
ssh Pass cluster.instance to ssh-exec if it is defined 2015-01-28 10:17:40 -08:00
symbols Use new FutureIterator instead of Futures 2014-12-30 23:13:38 +11:00
user Change double quotes to single quotes. 2014-06-09 11:36:50 -07:00
util Add a CanCDN flag to uploaded files 2014-08-07 18:56:20 -07:00
__init_script__.php Consolidate environmental initialization 2012-12-25 06:15:28 -08:00