Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(host): devolutions-session bootstrap #997

Merged
merged 10 commits into from
Sep 9, 2024

Conversation

pacmancoder
Copy link
Contributor

@pacmancoder pacmancoder commented Aug 27, 2024

This PR adds the following:

  • Bootstraps devolution-session executable, which will be hosting RDP dynamic virtual channel server for remote execution / other tasks specified in the NowProto protocol
    • Basic config/logging
    • MSRDPEX test code for further testing
  • Adds Logic to track sessions state and start DevolutionSession.exe in RDP sessions and terminating it after session termination
  • Add new WinAPI wrappers for process/session/permissions management which were required for new agent logic

Blocked by #1005

@pacmancoder pacmancoder force-pushed the feat/agent-session-manager branch 5 times, most recently from 3131bbd to e3f5b1f Compare August 27, 2024 14:06
ci/tlk.ps1 Outdated
@@ -345,6 +345,7 @@ class TlkRecipe
if ($this.Target.IsWindows()) {
$agentPackages += [TlkPackage]::new("devolutions-pedm-hook", "crates/devolutions-pedm-hook", $true)
$agentPackages += [TlkPackage]::new("devolutions-pedm-contextmenu", "crates/devolutions-pedm-contextmenu", $true)
$agentPackages += [TlkPackage]::new("devolutions-host", "crates/devolutions-host", $false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes just to build binary; Packaging + Installer changes will be in the follow-up PR soon

@@ -556,7 +673,18 @@ pub fn create_process_as_user(
let application_name = application_name.map(WideString::from).unwrap_or_default();
let current_directory = current_directory.map(WideString::from).unwrap_or_default();

let environment = environment.map(serialize_environment).transpose()?;
let environment = if let Some(env) = environment {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we correctly spawn the user's environment variables for the process if environment is not explicitly specified

/// Devolutions PEDM configuration
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pedm: Option<PedmConf>,

/// Devolutions Session Host configuration
#[serde(default, skip_serializing_if = "Option::is_none")]
pub session_host: Option<SessionHostConf>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is debatable - maybe someone has a better idea instead of "host"?

Copy link
Member

@CBenoit CBenoit Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions:

  • now_host: NowHostConf
  • now_dvc: NowDvcConf
  • remote_desktop_host: RemoteDesktopHostConf
  • remote_desktop_dvc: RemoteDesktopDvcConf

By the way, is the name "Devolutions Host" already agreed upon?
Should it be "Devolutions Now" or "Devolutions Now Host" or "Devolutions Now Dvc", or something else?

@@ -0,0 +1,46 @@
// Start the program without a console window.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing fancy here yet; Just logic to initialize log and config and copy-pasted test logic for DVC from MSRDPEX

@pacmancoder pacmancoder changed the title Devolutions host bootstrap feat(host): devolutions-host bootstrap Aug 27, 2024
@pacmancoder pacmancoder marked this pull request as ready for review August 27, 2024 15:23
Copy link
Member

@CBenoit CBenoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cargo.toml Outdated Show resolved Hide resolved
crates/win-api-wrappers/src/process.rs Outdated Show resolved Hide resolved
crates/win-api-wrappers/src/process.rs Outdated Show resolved Hide resolved
crates/win-api-wrappers/src/process.rs Outdated Show resolved Hide resolved
crates/win-api-wrappers/src/process.rs Outdated Show resolved Hide resolved
crates/win-api-wrappers/src/token.rs Outdated Show resolved Hide resolved
devolutions-agent/src/main.rs Show resolved Hide resolved
devolutions-agent/src/service.rs Outdated Show resolved Hide resolved
devolutions-agent/src/session_manager/mod.rs Outdated Show resolved Hide resolved
devolutions-agent/src/session_manager/mod.rs Outdated Show resolved Hide resolved
@pacmancoder pacmancoder force-pushed the feat/agent-session-manager branch 2 times, most recently from 7741b2a to 9bfc56e Compare September 2, 2024 08:03
Copy link
Member

@CBenoit CBenoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll leave you squash and merge when you are satisfied!

devolutions-agent/src/session_manager/mod.rs Outdated Show resolved Hide resolved
crates/win-api-wrappers/src/process.rs Show resolved Hide resolved
@CBenoit
Copy link
Member

CBenoit commented Sep 3, 2024

There is also this comment that you may want to check again: #997 (comment)

@pacmancoder
Copy link
Contributor Author

There is also this comment that you may want to check again: #997 (comment)

Yep, I'll clarify the naming with Marc-Andre 👍

@pacmancoder
Copy link
Contributor Author

NOTE: #1005 should be merged first; do not enable auto-merge

@pacmancoder pacmancoder requested review from a team as code owners September 4, 2024 14:45
Comment on lines 546 to 547


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You may have added unintentional blank lines

/// # Safety
///
/// - The caller should ensure that `handle` is a pseudo handle, as its validity is not checked.
pub unsafe fn new_pseudo_handle(handle: HANDLE) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CBenoit FYI I was pulling my hair while trying to find why the process didn't want to start after my last refactoring, but it turned out that current_process function has been broken after #998 was merged :( I added the separate new_pseudo_handle function to create handle without invalid_handle check (CurrentProcess returns (HANDLE)-1 value)

@pacmancoder pacmancoder changed the title feat(host): devolutions-host bootstrap feat(host): devolutions-session bootstrap Sep 9, 2024
@pacmancoder pacmancoder merged commit f8b291d into master Sep 9, 2024
25 checks passed
@pacmancoder pacmancoder deleted the feat/agent-session-manager branch September 9, 2024 11:17
package.ps1 Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pacmancoder Can you document the purpose of this file, please? Is it an helper or something we use in the CI? Should it go in the ci folder or the tools folder instead of the root?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was reverted already in the last commit, - I accidentally committed it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, got you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants