2017-06-27 06:58:29 +02:00
|
|
|
|
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
|
|
|
|
|
Import-Module $PSScriptRoot\OpenSSHUtils -Force
|
|
|
|
|
<#
|
2017-03-24 20:35:52 +01:00
|
|
|
|
.Synopsis
|
|
|
|
|
Finds the root of the git repository
|
|
|
|
|
|
|
|
|
|
.Outputs
|
2017-06-27 06:58:29 +02:00
|
|
|
|
A System.IO.DirectoryInfo for the location of the root if root is found; otherwise, script root.
|
2017-03-24 20:35:52 +01:00
|
|
|
|
|
|
|
|
|
.Inputs
|
|
|
|
|
None
|
|
|
|
|
#>
|
|
|
|
|
function Get-RepositoryRoot
|
2017-06-27 06:58:29 +02:00
|
|
|
|
{
|
|
|
|
|
$start = $currentDir = (Get-Item -Path $PSScriptRoot)
|
2017-03-24 20:35:52 +01:00
|
|
|
|
while ($null -ne $currentDir.Parent)
|
|
|
|
|
{
|
|
|
|
|
$path = Join-Path -Path $currentDir.FullName -ChildPath '.git'
|
|
|
|
|
if (Test-Path -Path $path)
|
|
|
|
|
{
|
|
|
|
|
return $currentDir
|
|
|
|
|
}
|
|
|
|
|
$currentDir = $currentDir.Parent
|
|
|
|
|
}
|
2017-06-27 06:58:29 +02:00
|
|
|
|
return $start
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<#
|
|
|
|
|
.Synopsis
|
|
|
|
|
add a file permission to an account
|
|
|
|
|
|
|
|
|
|
.Outputs
|
|
|
|
|
N/A
|
|
|
|
|
|
|
|
|
|
.Inputs
|
|
|
|
|
FilePath - The path to the file
|
|
|
|
|
User - account name
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Perms - The permission to grant.
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
#>
|
2017-06-27 06:58:29 +02:00
|
|
|
|
function Add-PermissionToFileACL
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
{
|
2017-05-24 06:45:38 +02:00
|
|
|
|
param (
|
|
|
|
|
[parameter(Mandatory=$true)]
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
[string]$FilePath,
|
2017-05-24 06:45:38 +02:00
|
|
|
|
[parameter(Mandatory=$true)]
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
[System.Security.Principal.NTAccount] $User,
|
2017-05-24 06:45:38 +02:00
|
|
|
|
[parameter(Mandatory=$true)]
|
|
|
|
|
[System.Security.AccessControl.FileSystemRights[]]$Perms
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
)
|
|
|
|
|
|
2017-05-24 06:45:38 +02:00
|
|
|
|
$myACL = Get-ACL $FilePath
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
|
2017-05-24 06:45:38 +02:00
|
|
|
|
if($Perms)
|
|
|
|
|
{
|
|
|
|
|
$Perms | % {
|
|
|
|
|
$userACE = New-Object System.Security.AccessControl.FileSystemAccessRule `
|
|
|
|
|
($User, $_, "None", "None", "Allow")
|
|
|
|
|
$myACL.AddAccessRule($userACE)
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Enable-Privilege SeRestorePrivilege | out-null
|
2017-05-24 06:45:38 +02:00
|
|
|
|
Set-Acl -Path $FilePath -AclObject $myACL
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Export-ModuleMember -Function Get-RepositoryRoot, Add-PermissionToFileACL
|