简体   繁体   English

系统上下文中的延迟CustomAction被拒绝访问

[英]Deferred CustomAction in System context get access denied

I'm having some problems with privileges when running a CustomAction in deferred mode. 在延迟模式下运行CustomAction时,我遇到了一些特权问题。

I want to kill some Service processes which could be running using different user accounts, from Local System to regular users, but the CA succeeds only when the processes and the CA are executed as the same user. 我想杀死一些可能使用不同用户帐户运行的服务进程,从本地系统到常规用户,但只有当进程和CA作为同一用户执行时,CA才会成功。 Here are some cases and results: 以下是一些案例和结果:

  • "process1.exe" is a process running as the same user running the installation. “process1.exe”是运行安装的同一用户运行的进程。 If the kill CA is run in System context using Impersonate="no" the access is denied . 如果使用Impersonate =“no”在系统上下文中运行kill CA, 则拒绝访问
  • "process1.exe" is a process running as the same user running the installation. “process1.exe”是运行安装的同一用户运行的进程。 If the kill CA is run in User context using Impersonate="yes" the process is killed . 如果使用Impersonate =“yes”在用户上下文中运行kill CA,则该进程将被终止
  • "process1.exe" is a process running as another user. “process1.exe”是另一个用户运行的进程。 If the kill CA is run in User context using Impersonate="yes" the access is denied . 如果使用Impersonate =“yes”在用户上下文中运行kill CA, 则拒绝访问
  • "process1.exe" is a process running as another user. “process1.exe”是另一个用户运行的进程。 If the kill CA is run in System context using Impersonate="no" the access is denied 如果使用Impersonate =“no”在系统上下文中运行kill CA, 则拒绝访问
  • "process1.exe" is a process running as Local System. “process1.exe”是作为本地系统运行的进程。 If the kill CA is run in User context using Impersonate="yes" the access is denied. 如果使用Impersonate =“yes”在用户上下文中运行kill CA,则拒绝访问。
  • "process1.exe" is a process running as Local System. “process1.exe”是作为本地系统运行的进程。 If the kill CA is run in System context using Impersonate="no" the process is killed. 如果使用Impersonate =“no”在系统上下文中运行kill CA,则该进程将被终止。
<SetProperty Id="KillUserProcess" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM process1.exe' After="CostFinalize" />
<CustomAction Id="KillUserProcess" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Impersonate="no" Return="check" />

<SetProperty Id="KillSysProcess" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM process2.exe' After="CostFinalize" />
<CustomAction Id="KillSysProcess" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Impersonate="no" Return="check" />

<InstallExecuteSequence>
    <Custom Action="KillUserProcess" After="InstallInitialize"></Custom>
    <Custom Action="KillSysProcess" After="KillUserProcess"></Custom>
</InstallExecuteSequence>

Action=KillUserProcess,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData="C:\\Windows\\System32\\taskkill.exe" /F /IM process1.exe) CAQuietExec: "C:\\Windows\\System32\\taskkill.exe" /F /IM process1.exe CAQuietExec: ERROR: The process "process1.exe" with PID 3164 could not be terminated. CAQuietExec: Reason: Access is denied. CAQuietExec: CAQuietExec: Error 0x80070001: Command line returned an error. CAQuietExec: Error 0x80070001: QuietExec Failed CAQuietExec: Error 0x80070001: Failed in ExecCommon method

Action=KillSysProcess,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData="C:\\Windows\\System32\\taskkill.exe" /F /IM process2.exe) CAQuietExec: "C:\\Windows\\System32\\taskkill.exe" /F /IM process2.exe CAQuietExec: SUCCESS: The process "process2.exe" with PID 4596 has been terminated.

If LocalSystem doesn't have the rights to kill the processes, who does? 如果LocalSystem没有权限杀死进程,谁呢? Running these commands from Command Prompt work without problem when elevated. 从命令提示符运行这些命令在提升时没有问题。 Even using psexec from SysInternal to run the command as System work without a problem. 甚至使用SysInternal的psexec来运行命令作为系统工作没有问题。 Only when running through MSI are these issues faced. 只有在通过MSI运行时才会遇到这些问题。

Is it possible to make a Custom Action running as a System kill processes not owned only by System? 是否可以将自定义操作作为不仅仅由System拥有的系统终止进程运行?

This question is tagged DTF but I don't see any .NET code. 这个问题标记为DTF,但我没有看到任何.NET代码。

FWIW, I've googled this topic and it's too much to speculate on... the reality is you need a bigger hammer and C#/DTF is that hammer. FWIW,我已经搜索了这个主题,而且推测太多了......现实是你需要一把更大的锤子而C#/ DTF就是锤子。 You can do way more complicated API calls with it and better error handling / logging. 您可以使用它进行更复杂的API调用以及更好的错误处理/日志记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM