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(agent): Devolutions Gateway service updater #889

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Conversation

pacmancoder
Copy link
Contributor

This PR implements Gateway updater logic in devolutions-agent.

This update mechanism is triggered by changing ProgramData/Devolutions/Agent/update.json file, setting the required version to update the gateway.

Example update.json:

{
    "Gateway": {
        "TargetVersion": "2024.2.1"
    }
}

Features:

  • Feature quite generic, so additional products could be updated later with the same mechanism by extending it
  • Updater checks for already installed products on the system via MSI's upgrade code, so no spurious same-version MSI invocation is possible
  • Requested Gateway version's MSI is gathered from devolutions.net
  • update.json is created on first service start, and correct DACL is set to allow NT AUTHORITY/Network Service (which is used by Gateway) to edit this file
  • Downloaded MSI hash is validated
  • MSI signature and certificate thumbprint are validated
  • All downloaded MSIs, Installation logs temp files are marked for removal after use

/// BUILTIN\Administrators Allow FullControl
/// BUILTIN\Users Allow ReadAndExecute, Synchronize
/// </remarks>
internal static string PROGRAM_DATA_SDDL = "O:SYG:SYD:PAI(A;OICI;FA;;;SY)(A;OICI;0x1201bf;;;LS)(A;OICI;0x1301bf;;;NS)(A;OICI;FA;;;BA)(A;OICI;0x1200a9;;;BU)";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted DACL as @thenextman commented here

/// for upgrade code table.
///
/// e.g.: `{82318d3c-811f-4d5d-9a82-b7c31b076755}` => `C3D81328F118D5D4A9287B3CB1707655`
pub fn uuid_to_reversed_hex(uuid: &str) -> Result<String, UpdaterError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Windows UUIDs are weird 😄

use crate::updater::{Product, UpdaterCtx, UpdaterError};

/// List of allowed thumbprints for Devolutions code signing certificates
const DEVOLUTIONS_CERT_THUMBPRINTS: &[&str] = &[
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allowed devolutions certs thumbprints which @awakecoding shared with me

@pacmancoder pacmancoder self-assigned this Jun 18, 2024
@pacmancoder pacmancoder marked this pull request as ready for review June 18, 2024 08:05
@CBenoit CBenoit changed the title feat(agent): Gateway updater feat(agent): Devolutions Gateway service updater Jun 18, 2024
Comment on lines +128 to +130
/// Enable updater module (enabled by default)
#[serde(default)]
pub disable: bool,
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: I think it would be better the other way around. You override the default value to "true" if that’s what you want.

Suggested change
/// Enable updater module (enabled by default)
#[serde(default)]
pub disable: bool,
/// Enable updater module (enabled by default)
#[serde(default = "true")]
pub enabled: bool,

@CBenoit CBenoit enabled auto-merge (squash) June 18, 2024 13:11
@CBenoit CBenoit merged commit 92f86bf into master Jun 20, 2024
24 checks passed
@CBenoit CBenoit deleted the feat/agent-udpater branch June 20, 2024 13:41
CBenoit added a commit that referenced this pull request Jun 21, 2024
CBenoit added a commit that referenced this pull request Jun 21, 2024
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.

3 participants