voice-changer: fix review findings (install-folder ACL, scoped uninstall delete, comm-mode APO, reconnect)
- installer: lock the install folder (admins/SYSTEM full, Users read) and grant Users modify only on data dirs (models/training/datasets/config/cache/env/engine/tools); download the engine as the original (non-elevated) user; refuse non-empty folders; uninstall deletes only app-managed dirs - mic-apo.ps1: backup/list/log moved to admin-only apo\; register SFX for DEFAULT, COMMUNICATIONS, SPEECH and MEDIA when the endpoint has no mode list; admin TEMP for Add-Type; run log + trap - app: '마이크 다시 연결' launches one elevated PowerShell via ShellExecuteExW(runas) with double-quoted -File args and waits for its exit code; shows apo\mic-apo.log on failure - tests: reconnect argument splitting (Korean/space/quote/drive root) Verified on the Windows 11 VM: basic-user token gets ERROR_ACCESS_DENIED on scripts/apo/exe/ uninstall/app and write access only on data dirs; Communications-category capture receives the converted signal (440 Hz); reconnect exits 0 from a Korean+space install path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,10 +44,6 @@ ko.DiskSpaceMBLabel=설치 중에 약 8GB 를 더 내려받습니다. 15GB 이
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "바탕 화면에 바로 가기 만들기"; Flags: unchecked
|
||||
|
||||
[Dirs]
|
||||
; 설치 폴더는 관리자 권한으로 만들지만, 앱(일반 권한)이 모델 · 설정을 써야 하므로 사용자 쓰기 권한을 준다
|
||||
Name: "{app}"; Permissions: users-modify
|
||||
|
||||
[Files]
|
||||
Source: "..\dist\payload\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs ignoreversion
|
||||
|
||||
@@ -62,12 +58,77 @@ Filename: "{app}\VoiceChanger.exe"; Description: "음성 변환기 실행"; Flag
|
||||
Filename: "powershell.exe"; Parameters: "-NoProfile -ExecutionPolicy Bypass -File ""{app}\scripts\mic-apo.ps1"" -Uninstall -Root ""{app}"""; Flags: runhidden waituntilterminated; RunOnceId: "MicApoUninstall"
|
||||
|
||||
[Code]
|
||||
const
|
||||
{ 일반 사용자가 쓸 수 있는 폴더: 앱(일반 권한)이 만드는 데이터와, 일반 권한으로 내려받는 엔진 · Python.
|
||||
관리자 권한으로 실행되는 것(설치 폴더 루트의 exe, app\, scripts\, apo\, uninstall\)은 여기에 두지 않는다. }
|
||||
UserDirs = 'models,training,datasets,config,cache,env,engine,tools';
|
||||
|
||||
function PowerShell(const Args: String; const Show: Integer; var Code: Integer): Boolean;
|
||||
begin
|
||||
Result := Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'),
|
||||
'-NoProfile -ExecutionPolicy Bypass ' + Args, ExpandConstant('{app}'), Show, ewWaitUntilTerminated, Code);
|
||||
end;
|
||||
|
||||
function IsEmptyDir(const Dir: String): Boolean;
|
||||
var
|
||||
F: TFindRec;
|
||||
begin
|
||||
Result := True;
|
||||
if FindFirst(AddBackslash(Dir) + '*', F) then
|
||||
try
|
||||
repeat
|
||||
if (F.Name <> '.') and (F.Name <> '..') then
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
until not FindNext(F);
|
||||
finally
|
||||
FindClose(F);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ 다른 파일이 들어 있는 폴더에는 설치하지 않는다. 설치 폴더의 권한을 잠그고, 제거할 때 지우기 때문.
|
||||
이 앱을 이미 설치한 폴더(업데이트)나 비어 있는 · 새 폴더만 받는다. }
|
||||
function NextButtonClick(CurPageID: Integer): Boolean;
|
||||
var
|
||||
Dir: String;
|
||||
begin
|
||||
Result := True;
|
||||
if CurPageID <> wpSelectDir then Exit;
|
||||
Dir := WizardDirValue;
|
||||
if DirExists(Dir) and not IsEmptyDir(Dir) and not FileExists(AddBackslash(Dir) + 'uninstall\unins000.exe') then
|
||||
begin
|
||||
SuppressibleMsgBox('이 폴더에는 이미 다른 파일이 있습니다.' + #13#10 +
|
||||
'비어 있는 폴더나 새 폴더를 골라 주세요. (예: ' + AddBackslash(Dir) + 'VoiceChanger)', mbError, MB_OK, IDOK);
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ 설치 폴더는 관리자 · SYSTEM 만 고칠 수 있게 잠그고(상위 폴더에서 물려받는 "인증된 사용자 수정" 권한을 끊음),
|
||||
일반 사용자에게는 UserDirs 폴더만 수정 권한을 준다. 일반 사용자가 관리자 권한으로 실행되는
|
||||
scripts\mic-apo.ps1 · 제거 프로그램 · APO DLL 을 바꿔치기할 수 없게 하기 위함. }
|
||||
procedure LockDownAppDir;
|
||||
var
|
||||
Code, I: Integer;
|
||||
App, Rest, D: String;
|
||||
begin
|
||||
App := ExpandConstant('{app}');
|
||||
Exec(ExpandConstant('{sys}\icacls.exe'), '"' + App + '" /inheritance:r /grant:r *S-1-5-18:(OI)(CI)F *S-1-5-32-544:(OI)(CI)F *S-1-5-32-545:(OI)(CI)RX',
|
||||
'', SW_HIDE, ewWaitUntilTerminated, Code);
|
||||
Log('icacls lock exit=' + IntToStr(Code));
|
||||
Rest := UserDirs + ',';
|
||||
while Rest <> '' do
|
||||
begin
|
||||
I := Pos(',', Rest);
|
||||
D := Copy(Rest, 1, I - 1);
|
||||
Rest := Copy(Rest, I + 1, Length(Rest));
|
||||
ForceDirectories(App + '\' + D);
|
||||
Exec(ExpandConstant('{sys}\icacls.exe'), '"' + App + '\' + D + '" /grant *S-1-5-32-545:(OI)(CI)M', '', SW_HIDE, ewWaitUntilTerminated, Code);
|
||||
Log('icacls user dir ' + D + ' exit=' + IntToStr(Code));
|
||||
end;
|
||||
end;
|
||||
|
||||
function PrepareToInstall(var NeedsRestart: Boolean): String;
|
||||
var
|
||||
Code: Integer;
|
||||
@@ -85,6 +146,7 @@ var
|
||||
Code: Integer;
|
||||
begin
|
||||
if CurStep <> ssPostInstall then Exit;
|
||||
LockDownAppDir;
|
||||
|
||||
WizardForm.StatusLabel.Caption := '마이크에 변환 모듈을 붙이는 중... (윈도우 소리가 잠깐 끊깁니다)';
|
||||
if not PowerShell('-File "' + ExpandConstant('{app}\scripts\mic-apo.ps1') + '" -Install -Root "' + ExpandConstant('{app}') + '"', SW_HIDE, Code) or (Code <> 0) then
|
||||
@@ -94,7 +156,10 @@ begin
|
||||
end;
|
||||
|
||||
WizardForm.StatusLabel.Caption := 'Python · 변환 엔진 · 기본 모델을 설치 폴더로 내려받는 중... (10~20분, 검은 창에 진행 상황이 나옵니다)';
|
||||
if not PowerShell('-File "' + ExpandConstant('{app}\scripts\install.ps1') + '"', SW_SHOWNORMAL, Code) or (Code <> 0) then
|
||||
{ 일반 권한(설치를 시작한 사용자)으로 받는다. 관리자 권한으로 사용자 쓰기 폴더(env · engine)의 코드를 돌리지 않게. }
|
||||
if not ExecAsOriginalUser(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'),
|
||||
'-NoProfile -ExecutionPolicy Bypass -File "' + ExpandConstant('{app}\scripts\install.ps1') + '"',
|
||||
ExpandConstant('{app}'), SW_SHOWNORMAL, ewWaitUntilTerminated, Code) or (Code <> 0) then
|
||||
SuppressibleMsgBox('엔진을 내려받지 못했습니다 (인터넷 연결을 확인해 주세요).' + #13#10 +
|
||||
'설치 폴더의 install.bat 을 실행하면 받은 곳부터 이어서 받습니다.', mbError, MB_OK, IDOK);
|
||||
end;
|
||||
@@ -114,16 +179,20 @@ begin
|
||||
DelTree(App + '\app\__pycache__', True, True, True);
|
||||
RemoveDir(App + '\app');
|
||||
{ 사용자가 만든 것은 물어보고 지운다. 조용히 제거할 때는 남겨 둔다 }
|
||||
{ 앱이 만든 폴더만 지운다. 설치 폴더 자체는 비어 있을 때만 지운다 (RemoveDir 는 빈 폴더만 지움) }
|
||||
if (not UninstallSilent) and (MsgBox('만든 목소리 모델 · 학습 파일 · 녹음 · 설정도 지울까요?' + #13#10 +
|
||||
'(models, training, datasets, config 폴더)' + #13#10#13#10 + '"아니요" 를 누르면 남겨 둡니다.', mbConfirmation, MB_YESNO) = IDYES) then
|
||||
DelTree(App, True, True, True)
|
||||
else
|
||||
begin
|
||||
{ 남긴 폴더 중 비어 있는 것은 정리 (RemoveDir 는 빈 폴더만 지운다) }
|
||||
RemoveDir(App + '\models');
|
||||
RemoveDir(App + '\training');
|
||||
RemoveDir(App + '\datasets');
|
||||
RemoveDir(App + '\config');
|
||||
RemoveDir(App);
|
||||
DelTree(App + '\models', True, True, True);
|
||||
DelTree(App + '\training', True, True, True);
|
||||
DelTree(App + '\datasets', True, True, True);
|
||||
DelTree(App + '\config', True, True, True);
|
||||
end;
|
||||
RemoveDir(App + '\models');
|
||||
RemoveDir(App + '\training');
|
||||
RemoveDir(App + '\datasets');
|
||||
RemoveDir(App + '\config');
|
||||
DeleteFile(App + '\apo\mic-apo.log');
|
||||
RemoveDir(App + '\apo');
|
||||
RemoveDir(App);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user