Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2891485
ssh-connect.php
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
ssh-connect.php
View Options
#!/usr/bin/env php
<?php
// This is a wrapper script for Git, Mercurial, and Subversion. It primarily
// serves to inject "-o StrictHostKeyChecking=no" into the SSH arguments.
$root
=
dirname
(
dirname
(
dirname
(
__FILE__
)
)
)
;
require_once
$root
.
'/scripts/__init_script__.php'
;
$target_name
=
getenv
(
'PHABRICATOR_SSH_TARGET'
)
;
if
(
!
$target_name
)
{
throw
new
Exception
(
pht
(
"No 'PHABRICATOR_SSH_TARGET' in environment!"
)
)
;
}
$viewer
=
PhabricatorUser
::
getOmnipotentUser
(
)
;
$repository
=
id
(
new
PhabricatorRepositoryQuery
(
)
)
->
setViewer
(
$viewer
)
->
withCallsigns
(
array
(
$target_name
)
)
->
executeOne
(
)
;
if
(
!
$repository
)
{
throw
new
Exception
(
pht
(
'No repository with callsign "%s"!'
,
$target_name
)
)
;
}
$pattern
=
array
(
)
;
$arguments
=
array
(
)
;
$pattern
[
]
=
'ssh'
;
$pattern
[
]
=
'-o'
;
$pattern
[
]
=
'StrictHostKeyChecking=no'
;
$credential_phid
=
$repository
->
getCredentialPHID
(
)
;
if
(
$credential_phid
)
{
$key
=
PassphraseSSHKey
::
loadFromPHID
(
$credential_phid
,
$viewer
)
;
$pattern
[
]
=
'-l %P'
;
$arguments
[
]
=
$key
->
getUsernameEnvelope
(
)
;
$pattern
[
]
=
'-i %P'
;
$arguments
[
]
=
$key
->
getKeyfileEnvelope
(
)
;
}
$pattern
[
]
=
'--'
;
$passthru_args
=
array_slice
(
$argv
,
1
)
;
foreach
(
$passthru_args
as
$passthru_arg
)
{
$pattern
[
]
=
'%s'
;
$arguments
[
]
=
$passthru_arg
;
}
$pattern
=
implode
(
' '
,
$pattern
)
;
array_unshift
(
$arguments
,
$pattern
)
;
$err
=
newv
(
'PhutilExecPassthru'
,
$arguments
)
->
execute
(
)
;
exit
(
$err
)
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 19, 15:16 (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125889
Default Alt Text
ssh-connect.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment