Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14355876
D15754.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D15754.diff
View Options
diff --git a/src/applications/almanac/util/AlmanacKeys.php b/src/applications/almanac/util/AlmanacKeys.php
--- a/src/applications/almanac/util/AlmanacKeys.php
+++ b/src/applications/almanac/util/AlmanacKeys.php
@@ -48,4 +48,22 @@
return $device;
}
+ public static function getClusterSSHUser() {
+ // NOTE: When instancing, we currently use the SSH username to figure out
+ // which instance you are connecting to. We can't use the host name because
+ // we have no way to tell which host you think you're reaching: the SSH
+ // protocol does not have a mechanism like a "Host" header.
+ $username = PhabricatorEnv::getEnvConfig('cluster.instance');
+ if (strlen($username)) {
+ return $username;
+ }
+
+ $username = PhabricatorEnv::getEnvConfig('diffusion.ssh-user');
+ if (strlen($username)) {
+ return $username;
+ }
+
+ return null;
+ }
+
}
diff --git a/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php b/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
--- a/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
+++ b/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
@@ -62,15 +62,12 @@
protected function getProxyCommand() {
$uri = new PhutilURI($this->proxyURI);
- $username = PhabricatorEnv::getEnvConfig('cluster.instance');
- if (!strlen($username)) {
- $username = PhabricatorEnv::getEnvConfig('diffusion.ssh-user');
- if (!strlen($username)) {
- throw new Exception(
- pht(
- 'Unable to determine the username to connect with when trying '.
- 'to proxy an SSH request within the Phabricator cluster.'));
- }
+ $username = AlmanacKeys::getClusterSSHUser();
+ if ($username === null) {
+ throw new Exception(
+ pht(
+ 'Unable to determine the username to connect with when trying '.
+ 'to proxy an SSH request within the Phabricator cluster.'));
}
$port = $uri->getPort();
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -1348,8 +1348,8 @@
$uri->setPath($uri->getPath().$this->getCloneName().'/');
}
- $ssh_user = PhabricatorEnv::getEnvConfig('diffusion.ssh-user');
- if ($ssh_user) {
+ $ssh_user = AlmanacKeys::getClusterSSHUser();
+ if ($ssh_user !== null) {
$uri->setUser($ssh_user);
}
@@ -2324,7 +2324,12 @@
'refusing new writes.'));
}
- $max_version = $this->synchronizeWorkingCopyBeforeRead();
+ try {
+ $max_version = $this->synchronizeWorkingCopyBeforeRead();
+ } catch (Exception $ex) {
+ $write_lock->unlock();
+ throw $ex;
+ }
PhabricatorRepositoryWorkingCopyVersion::willWrite(
$repository_phid,
diff --git a/src/applications/repository/storage/PhabricatorRepositoryURI.php b/src/applications/repository/storage/PhabricatorRepositoryURI.php
--- a/src/applications/repository/storage/PhabricatorRepositoryURI.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryURI.php
@@ -227,7 +227,7 @@
private function getForcedUser() {
switch ($this->getBuiltinProtocol()) {
case self::BUILTIN_PROTOCOL_SSH:
- return PhabricatorEnv::getEnvConfig('diffusion.ssh-user');
+ return AlmanacKeys::getClusterSSHUser();
default:
return null;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 6:47 PM (13 h, 43 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6911629
Default Alt Text
D15754.diff (3 KB)
Attached To
Mode
D15754: Consolidate handling of SSH usernames
Attached
Detach File
Event Timeline
Log In to Comment