Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion proxy_agent_extension/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::structs;
use crate::structs::FormattedMessage;
use crate::structs::HandlerEnvironment;
use crate::structs::TopLevelStatus;
#[cfg(windows)]
use proxy_agent_shared::service;
use proxy_agent_shared::{misc_helpers, telemetry};
use std::fs;
Expand Down Expand Up @@ -167,7 +168,28 @@ pub fn get_current_seq_no(exe_path: &Path) -> String {
}

pub fn get_proxy_agent_service_path() -> PathBuf {
service::query_service_executable_path(constants::PROXY_AGENT_SERVICE_NAME)
#[cfg(windows)]
{
match service::query_service_executable_path(constants::PROXY_AGENT_SERVICE_NAME) {
Ok(path) => path,
Err(e) => {
logger::write(format!(
"get_proxy_agent_service_path: query failed with error: {e}"
));
PathBuf::new()
}
}
}
// On Linux the GPA binary is always installed at a well-known fixed path by the
// setup tool. Avoid querying `systemctl show --property=ExecStart` here: the
// systemd unit-file cache may not be hot right after install, causing
// ExecStart to come back empty, which previously triggered a false
// VersionMismatch and a spurious re-install on every enable invocation.
#[cfg(not(windows))]
{
PathBuf::from(proxy_agent_shared::linux::EXE_FOLDER_PATH)
.join(constants::PROXY_AGENT_SERVICE_NAME)
}
}

pub fn get_proxy_agent_exe_path() -> PathBuf {
Expand Down
14 changes: 11 additions & 3 deletions proxy_agent_setup/src/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ pub fn proxy_agent_running_folder(_service_name: &str) -> PathBuf {
let path;
#[cfg(windows)]
{
path = match service::query_service_executable_path(_service_name).parent() {
Some(p) => p.to_path_buf(),
None => proxy_agent_parent_folder().join("Package"),
path = match service::query_service_executable_path(_service_name) {
Ok(exe_path) => match exe_path.parent() {
Some(p) => p.to_path_buf(),
None => proxy_agent_parent_folder().join("Package"),
},
Err(e) => {
logger::write(format!(
"query_service_executable_path failed for {_service_name}: {e}"
));
proxy_agent_parent_folder().join("Package")
}
};
}
#[cfg(not(windows))]
Expand Down
15 changes: 4 additions & 11 deletions proxy_agent_shared/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,23 @@ pub fn update_service(
}
}

pub fn query_service_executable_path(service_name: &str) -> PathBuf {
pub fn query_service_executable_path(service_name: &str) -> Result<PathBuf> {
#[cfg(windows)]
{
match windows_service::query_service_config(service_name) {
Ok(service_config) => {
logger_manager::write_info(format!("Service {service_name} successfully queried",));
service_config.executable_path.to_path_buf()
Ok(service_config.executable_path.to_path_buf())
}
Err(e) => {
logger_manager::write_info(format!("Service {service_name} query failed: {e}",));
eprintln!("Service {service_name} query failed: {e}");
PathBuf::new()
Err(e)
}
}
}
#[cfg(not(windows))]
{
match linux_service::query_service_executable_path(service_name) {
Ok(path) => path,
Err(e) => {
eprintln!("Service {service_name} query failed: {e}");
PathBuf::new()
}
}
linux_service::query_service_executable_path(service_name)
}
}

Expand Down
Loading