mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Merge pull request #572 from efiop/master
win: innosetup: don't add symlink perms
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
param (
|
||||
[string]$mytype = 'system'
|
||||
)
|
||||
|
||||
function addSymLinkPermissions($accountToAdd){
|
||||
Write-Host "Checking SymLink permissions.."
|
||||
$sidstr = $null
|
||||
if ( "$accountToAdd" -eq "Everyone" ) {
|
||||
$sidstr = "S-1-1-0"
|
||||
} else {
|
||||
try {
|
||||
$ntprincipal = new-object System.Security.Principal.NTAccount "$accountToAdd"
|
||||
$sid = $ntprincipal.Translate([System.Security.Principal.SecurityIdentifier])
|
||||
$sidstr = $sid.Value.ToString()
|
||||
} catch {
|
||||
$sidstr = $null
|
||||
}
|
||||
}
|
||||
Write-Host "Account: $($accountToAdd)" -ForegroundColor DarkCyan
|
||||
if( [string]::IsNullOrEmpty($sidstr) ) {
|
||||
Write-Host "Account not found!" -ForegroundColor Red
|
||||
exit -1
|
||||
}
|
||||
Write-Host "Account SID: $($sidstr)" -ForegroundColor DarkCyan
|
||||
$tmp = [System.IO.Path]::GetTempFileName()
|
||||
Write-Host "Export current Local Security Policy" -ForegroundColor DarkCyan
|
||||
secedit.exe /export /cfg "$($tmp)"
|
||||
$c = Get-Content -Path $tmp
|
||||
$currentSetting = ""
|
||||
foreach($s in $c) {
|
||||
if( $s -like "SECreateSymbolicLinkPrivilege*") {
|
||||
$x = $s.split("=",[System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
$currentSetting = $x[1].Trim()
|
||||
}
|
||||
}
|
||||
if( $currentSetting -notlike "*$($sidstr)*" ) {
|
||||
Write-Host "Need to add permissions to SymLink" -ForegroundColor Yellow
|
||||
|
||||
Write-Host "Modify Setting ""Create SymLink""" -ForegroundColor DarkCyan
|
||||
|
||||
if( [string]::IsNullOrEmpty($currentSetting) ) {
|
||||
$currentSetting = "*$($sidstr)"
|
||||
} else {
|
||||
$currentSetting = "*$($sidstr),$($currentSetting)"
|
||||
}
|
||||
Write-Host "$currentSetting"
|
||||
$outfile = @"
|
||||
[Unicode]
|
||||
Unicode=yes
|
||||
[Version]
|
||||
signature="`$CHICAGO`$"
|
||||
Revision=1
|
||||
[Privilege Rights]
|
||||
SECreateSymbolicLinkPrivilege = $($currentSetting)
|
||||
"@
|
||||
$tmp2 = [System.IO.Path]::GetTempFileName()
|
||||
Write-Host "Import new settings to Local Security Policy" -ForegroundColor DarkCyan
|
||||
$outfile | Set-Content -Path $tmp2 -Encoding Unicode -Force
|
||||
Push-Location (Split-Path $tmp2)
|
||||
try {
|
||||
secedit.exe /configure /db "secedit.sdb" /cfg "$($tmp2)" /areas USER_RIGHTS
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
} else {
|
||||
Write-Host "NO ACTIONS REQUIRED! Account already in ""Create SymLink""" -ForegroundColor DarkCyan
|
||||
Write-Host "Account $accountToAdd already has permissions to SymLink" -ForegroundColor Green
|
||||
return $true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( "$mytype" -eq "user" ) {
|
||||
addSymLinkPermissions $(Get-WMIObject -class Win32_ComputerSystem | select username).username
|
||||
} else {
|
||||
addSymLinkPermissions Everyone
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
procedure AddSymLink();
|
||||
var
|
||||
ErrorCode: Integer;
|
||||
SRCdir: String;
|
||||
begin
|
||||
SRCdir := ExpandConstant('{app}');
|
||||
if isUninstaller() = false then begin
|
||||
if not ShellExec('', 'powershell.exe', '-noninteractive -windowstyle hidden -executionpolicy bypass -File "' + SRCdir + '\addSymLinkPermissions.ps1" -mytype ' + SymLinkType, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) then begin
|
||||
MsgBox('Failed to automatically grant SeCreateSymbolicLinkPrivilege. Please download Polsedit(www.southsoftware.com/polsedit.zip). Launch polseditx32.exe or polseeditx64.exe (depending on your Windows version), navigate to "Security Settings" -> "User Rights Assignment", add the account(s) to the list named "Create symbolic links", logoff and login back into your account. More info at https://github.com/git-for-windows/git/wiki/Symbolic-Links.', mbInformation, MB_OK);
|
||||
end else begin
|
||||
MsgBox('Automatically added SeCreateSymbolicLinkPrivilege. Please logoff and login back into your account in order for the change to take effect.', mbInformation, MB_OK);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@@ -35,18 +35,14 @@ Source: "{#MyAppDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs c
|
||||
[Tasks]
|
||||
Name: modifypath; Description: Adds dvc's application directory to environmental path; Flags: checkablealone;
|
||||
Name: modifypath\system; Description: Adds dvc's application directory to enviromental path for all users;
|
||||
Name: addsymlinkpermissions; Description: Add permission for creating symbolic links; Flags: checkablealone;
|
||||
Name: addsymlinkpermissions\system; Description: Add permissions for creating symbolic links for all users;
|
||||
|
||||
[Code]
|
||||
const
|
||||
ModPathName = 'modifypath';
|
||||
ModPathPath = '{app}';
|
||||
SymLinkName = 'addsymlinkpermissions';
|
||||
|
||||
var
|
||||
ModPathType: String;
|
||||
SymLinkType: String;
|
||||
|
||||
function GetDefaultDirName(Dummy: string): string;
|
||||
begin
|
||||
@@ -58,7 +54,6 @@ begin
|
||||
end;
|
||||
|
||||
#include "modpath.iss"
|
||||
#include "addsymlink.iss"
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
@@ -69,15 +64,7 @@ begin
|
||||
ModPathType := 'user';
|
||||
end;
|
||||
|
||||
if IsTaskSelected(SymLinkName + '\system') then begin
|
||||
SymLinkType := 'system';
|
||||
end else begin
|
||||
SymLinkType := 'user';
|
||||
end;
|
||||
|
||||
if IsTaskSelected(ModPathName) then
|
||||
ModPath();
|
||||
if IsTaskSelected(SymLinkName) then
|
||||
AddSymLink();
|
||||
end;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user