Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P1227
WindowsZeroConf.php
Active
Public
Actions
Authored by
hach-que
on Aug 11 2014, 1:09 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Flag For Later
Award Token
Tags
None
Referenced Files
F188887: WindowsZeroConf.php
Aug 11 2014, 1:09 PM
2014-08-11 13:09:24 (UTC+0)
Subscribers
None
<?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
;
}
}
Event Timeline
hach-que
edited the content of this paste.
(Show Details)
Aug 11 2014, 1:09 PM
2014-08-11 13:09:24 (UTC+0)
hach-que
changed the title of this paste from untitled to
WindowsZeroConf.php
.
hach-que
updated the paste's language from
autodetect
to
autodetect
.
Log In to Comment