Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F188887
WindowsZeroConf.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
hach-que
Aug 11 2014, 1:09 PM
2014-08-11 13:09:24 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
WindowsZeroConf.php
View Options
<?php
final
class
WindowsZeroConf
extends
Phobject
{
public
function
getEncodedUserData
(
PassphraseCredential
$credential
)
{
return
base64_encode
(
$this
->
getUserData
(
$credential
));
}
private
function
getUserData
(
PassphraseCredential
$credential
)
{
$type
=
PassphraseCredentialType
::
getTypeByConstant
(
$credential
->
getCredentialType
());
if
(!
$type
)
{
throw
new
Exception
(
pht
(
'Credential has invalid type "%s"!'
,
$type
));
}
if
(!
$type
->
hasPublicKey
())
{
throw
new
Exception
(
pht
(
'Credential has no public key!'
));
}
$username
=
$credential
->
getUsername
();
$publickey
=
$type
->
getPublicKey
(
PhabricatorUser
::
getOmnipotentUser
(),
$credential
);
$publickey
=
trim
(
$publickey
);
$username
=
str_replace
(
'"'
,
'`"'
,
$username
);
$publickey
=
str_replace
(
'"'
,
'`"'
,
$publickey
);
$start
=
'<powershell>'
;
$data
=
<<<EOF
\$username = "$username";
\$publickey = "$publickey";
EOF;
$script
=
<<<'EOF'
# Create Cygwin64 directory
mkdir C:\cygwin64
# Download Cygwin64
wget https://s3-us-west-2.amazonaws.com/windows-build-agent/CygwinPack.zip `
-OutFile C:\CygwinPack.zip
# Extract Cygwin64
$shell = new-object -com shell.application
$zip = $shell.NameSpace("C:\CygwinPack.zip")
foreach($item in $zip.items())
{
$shell.Namespace("C:\cygwin64").copyhere($item)
}
# Setup SSHD
$env:PATH = $env:PATH + ";c:\cygwin64\bin"
C:\cygwin64\bin\chmod.exe +r /etc/passwd
C:\cygwin64\bin\chmod.exe +r /etc/group
C:\cygwin64\bin\chmod.exe a+x /var
C:\cygwin64\bin\bash.exe C:\cygwin64\bin\ssh-host-config -y -w SSHPRIV1@
$objOu = [ADSI]"WinNT://localhost"
$objUser = $objOU.Create("User", $username)
$objUser.setpassword("SSHPRIV1@")
$objUser.SetInfo()
C:\cygwin64\bin\mkpasswd.exe > C:\cygwin64\etc\passwd
mkdir C:\cygwin64\home\$username\.ssh
$keyline = "$publickey Automatically Defined Key"
Set-Content `
-Path C:\cygwin64\home\$username\.ssh\authorized_keys `
-Value $keyline
Set-Service sshd -StartupType Automatic
Start-Service sshd
</powershell>
EOF;
echo
$start
.
$data
.
$script
;
return
$start
.
$data
.
$script
;
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/tl/tn/j6lo2wrv3pad5p25
Default Alt Text
WindowsZeroConf.php (2 KB)
Attached To
Mode
P1227 WindowsZeroConf.php
Attached
Detach File
Event Timeline
Log In to Comment