Skip to content

Commit 7ebd452

Browse files
committed
feat(pedm): desktop agent refinement
1 parent f86e114 commit 7ebd452

File tree

8 files changed

+244
-136
lines changed

8 files changed

+244
-136
lines changed

crates/devolutions-pedm-shared/src/desktop.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use win_api_wrappers::raw::Win32::Security::TOKEN_QUERY;
77
use windows_registry::LOCAL_MACHINE;
88

99
pub fn install_dir() -> Result<PathBuf> {
10+
// TODO: lookup from registry only works when installed by MSI
1011
Ok(PathBuf::from_str(
1112
&LOCAL_MACHINE
1213
.open(r"SOFTWARE\Devolutions\Agent")?
@@ -17,7 +18,8 @@ pub fn install_dir() -> Result<PathBuf> {
1718
pub fn desktop_exe() -> Result<PathBuf> {
1819
let mut exe = install_dir()?;
1920

20-
exe.push("desktop/DevolutionsPedmDesktop.exe");
21+
exe.push("desktop");
22+
exe.push("DevolutionsDesktopAgent.exe");
2123

2224
Ok(exe)
2325
}
@@ -28,6 +30,7 @@ pub enum DesktopMode {
2830

2931
pub fn launch(mode: &DesktopMode) -> Result<()> {
3032
let mut base_command = Command::new(desktop_exe()?);
33+
base_command.arg(desktop_exe()?);
3134
base_command.arg(
3235
Process::current_process()
3336
.token(TOKEN_QUERY)?

crates/devolutions-pedm/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use camino::Utf8PathBuf;
55
use win_api_wrappers::process::Module;
66
use win_api_wrappers::raw::Win32::Foundation::LUID;
77

8-
pub(crate) static PEDM_DESKTOP_RELPATH: &str = r"desktop/DevolutionsPedmDesktop.exe";
8+
pub(crate) static PEDM_DESKTOP_RELPATH: &str = r"desktop/DevolutionsDesktopAgent.exe";
99

1010
pub(crate) static PIPE_NAME: &str = r"\\.\pipe\DevolutionsPEDM";
1111

crates/devolutions-pedm/src/desktop.rs

Lines changed: 0 additions & 113 deletions
This file was deleted.

crates/devolutions-pedm/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ cfg_if::cfg_if! {
55
if #[cfg(target_os = "windows")] {
66
pub mod api;
77
mod config;
8-
mod desktop;
98
mod elevations;
109
mod elevator;
1110
mod error;

crates/devolutions-pedm/src/policy.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use win_api_wrappers::utils::CommandLine;
3131
use anyhow::{anyhow, bail, Result};
3232

3333
use crate::config;
34-
use crate::desktop::launch_consent;
3534
use crate::error::Error;
3635
use crate::utils::{ensure_protected_directory, file_hash, AccountExt, MultiHasher};
3736
use devolutions_pedm_shared::policy;
@@ -324,17 +323,7 @@ impl Policy {
324323

325324
match elevation_type {
326325
policy::ElevationKind::AutoApprove => Ok(()),
327-
policy::ElevationKind::Confirm => {
328-
if !launch_consent(
329-
session_id,
330-
&Sid::try_from(request.asker.user.account_sid.as_str())?,
331-
&request.target.path,
332-
)? {
333-
bail!(Error::Cancelled);
334-
}
335-
336-
Ok(())
337-
}
326+
policy::ElevationKind::Confirm => bail!(Error::InvalidParameter),
338327
policy::ElevationKind::ReasonApproval => bail!(Error::InvalidParameter),
339328
policy::ElevationKind::Deny => bail!(Error::AccessDenied),
340329
}

dotnet/DesktopAgent/DesktopAgent.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<RootNamespace>Devolutions.Agent.Desktop</RootNamespace>
1010
<AssemblyName>DevolutionsDesktopAgent</AssemblyName>
1111
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<LangVersion>latest</LangVersion>
1213
<FileAlignment>512</FileAlignment>
1314
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1415
<Deterministic>true</Deterministic>
@@ -24,6 +25,7 @@
2425
<DefineConstants>DEBUG;TRACE</DefineConstants>
2526
<ErrorReport>prompt</ErrorReport>
2627
<WarningLevel>4</WarningLevel>
28+
<Prefer32Bit>false</Prefer32Bit>
2729
</PropertyGroup>
2830
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2931
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -40,6 +42,7 @@
4042
<ItemGroup>
4143
<Reference Include="System" />
4244
<Reference Include="System.Core" />
45+
<Reference Include="System.Runtime.Remoting" />
4346
<Reference Include="System.Xml.Linq" />
4447
<Reference Include="System.Data.DataSetExtensions" />
4548
<Reference Include="Microsoft.CSharp" />
@@ -84,5 +87,11 @@
8487
<ItemGroup>
8588
<Content Include="Resources\AppIcon.ico" />
8689
</ItemGroup>
90+
<ItemGroup>
91+
<ProjectReference Include="..\..\crates\devolutions-pedm\openapi\dotnet-client\src\Devolutions.Pedm.Client\Devolutions.Pedm.Client.csproj">
92+
<Project>{2d633ac7-9fdc-4cda-bbb8-7fd33493d79f}</Project>
93+
<Name>Devolutions.Pedm.Client</Name>
94+
</ProjectReference>
95+
</ItemGroup>
8796
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8897
</Project>

dotnet/DesktopAgent/DesktopAgent.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.10.35201.131
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopAgent", "DesktopAgent.csproj", "{6DFAA3D7-4F38-4329-8CEE-D6968959A701}"
77
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Devolutions.Pedm.Client", "..\..\crates\devolutions-pedm\openapi\dotnet-client\src\Devolutions.Pedm.Client\Devolutions.Pedm.Client.csproj", "{2D633AC7-9FDC-4CDA-BBB8-7FD33493D79F}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{6DFAA3D7-4F38-4329-8CEE-D6968959A701}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{6DFAA3D7-4F38-4329-8CEE-D6968959A701}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{6DFAA3D7-4F38-4329-8CEE-D6968959A701}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{2D633AC7-9FDC-4CDA-BBB8-7FD33493D79F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{2D633AC7-9FDC-4CDA-BBB8-7FD33493D79F}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{2D633AC7-9FDC-4CDA-BBB8-7FD33493D79F}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{2D633AC7-9FDC-4CDA-BBB8-7FD33493D79F}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)