дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
fix(updates): install RPM updates with --nosignature on RPM 6 (#7268)
In-app updates of the RPM build failed on Fedora 43+ (RPM 6), which refuses packages without an OpenPGP signature; the release RPMs carry none and the plugin's error was swallowed. On Linux RPM installs the IDE now runs `pkexec rpm -U --nosignature` itself: the update has passed the updater's minisign check and rpm still checks the payload digests. The verified bytes are written to a new file in a private (0700) temporary folder for rpm rather than re-read from the download cache, and rpm's message goes into the error and the log, as do other install failures. --nosignature can go once CI signs the RPMs. Co-authored-by: marioserrano09 <[email protected]>
Цей коміт міститься в:
1 джерело
7f40257632
коміт
ef986fbeca
3 files changed
+57
-2
No files matched your search
@@ -69,10 +69,12 @@ ide-extension = { path = "../crates/ide-extension" }
|
||||
ide-docker = { path = "../crates/ide-docker" }
|
||||
ide-android = { path = "../crates/ide-android" }
|
||||
|
||||
# The RPM update package is written to a private temporary folder before `pkexec rpm` installs it.
|
||||
tempfile.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
# The updater's version order (tauri-plugin-updater compares with semver).
|
||||
semver = "1"
|
||||
tempfile.workspace = true
|
||||
|
||||
[[test]]
|
||||
name = "background_tab_appkit"
|
||||
|
||||
@@ -883,7 +883,13 @@ pub async fn app_install_update(
|
||||
let exe = tauri::utils::platform::current_exe()?;
|
||||
return ide_tools::portable_update::install(&exe, &bytes);
|
||||
}
|
||||
update.install(bytes).map_err(|e| IdeError::internal(e.to_string()))
|
||||
if crate::updates::installs_rpm(std::env::consts::OS, tauri::utils::platform::bundle_type()) {
|
||||
return crate::updates::install_rpm(&bytes);
|
||||
}
|
||||
update.install(bytes).map_err(|e| {
|
||||
tracing::error!(target = %update.target, error = %e, "update install failed");
|
||||
IdeError::internal(e.to_string())
|
||||
})
|
||||
})
|
||||
.await
|
||||
.map_err(|e| IdeError::internal(e.to_string()))?;
|
||||
|
||||
@@ -25,6 +25,41 @@ pub(crate) struct DownloadedUpdate {
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
/// Whether this build installs its updates as an `.rpm`, through [`install_rpm`] rather than the plugin.
|
||||
///
|
||||
/// The plugin's own `rpm -U` fails on RPM 6 (Fedora 43+), which refuses packages without an OpenPGP
|
||||
/// signature, and the release RPMs carry none.
|
||||
pub fn installs_rpm(os: &str, bundle: Option<tauri::utils::config::BundleType>) -> bool {
|
||||
os == "linux" && bundle == Some(tauri::utils::config::BundleType::Rpm)
|
||||
}
|
||||
|
||||
/// The `pkexec` arguments that install `package`. The package has passed the updater's minisign
|
||||
/// check (`verify_file`) and rpm still checks the payload digests; drop `--nosignature` once CI
|
||||
/// signs the RPMs with `rpmsign --addsign`.
|
||||
pub fn rpm_install_args(package: &Path) -> Vec<std::ffi::OsString> {
|
||||
["rpm", "-U", "--nosignature"].map(Into::into).into_iter().chain([package.into()]).collect()
|
||||
}
|
||||
|
||||
/// Installs the verified `bytes` with `pkexec rpm`, keeping rpm's own message in the error and the
|
||||
/// log. They go to a new file in a private temporary folder rather than being read again from the
|
||||
/// download cache, so what rpm installs as root is what the signature check saw.
|
||||
pub fn install_rpm(bytes: &[u8]) -> IdeResult<()> {
|
||||
let dir = tempfile::Builder::new().prefix("openidea-update-").tempdir()?;
|
||||
let package = dir.path().join("update.rpm");
|
||||
std::fs::write(&package, bytes)?;
|
||||
let output = std::process::Command::new("pkexec")
|
||||
.args(rpm_install_args(&package))
|
||||
.output()
|
||||
.map_err(|error| IdeError::unavailable(format!("cannot run pkexec: {error}")))?;
|
||||
if output.status.success() {
|
||||
return Ok(());
|
||||
}
|
||||
let text = String::from_utf8_lossy(&output.stderr);
|
||||
let message = format!("rpm update failed ({}): {}", output.status, text.trim());
|
||||
tracing::error!("{message}");
|
||||
Err(IdeError::internal(message))
|
||||
}
|
||||
|
||||
/// Tauri patches the installer copies; the raw exe shipped in the portable zip keeps no bundle type.
|
||||
pub fn portable_target(os: &str, arch: &str, bundle: Option<tauri::utils::config::BundleType>) -> Option<String> {
|
||||
(os == "windows" && bundle.is_none()).then(|| format!("windows-{arch}-portable"))
|
||||
@@ -292,6 +327,18 @@ fn ready_owner(preferred: Option<&str>, live: &[String], ready: &HashSet<String>
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn rpm_installs_on_linux_skip_the_signature_check_only() {
|
||||
use tauri::utils::config::BundleType;
|
||||
let args = rpm_install_args(Path::new("/tmp/openidea-update-x/update.rpm"));
|
||||
assert_eq!(args, ["rpm", "-U", "--nosignature", "/tmp/openidea-update-x/update.rpm"]);
|
||||
assert!(installs_rpm("linux", Some(BundleType::Rpm)));
|
||||
assert!(!installs_rpm("linux", Some(BundleType::Deb)));
|
||||
assert!(!installs_rpm("linux", Some(BundleType::AppImage)));
|
||||
assert!(!installs_rpm("linux", None));
|
||||
assert!(!installs_rpm("macos", Some(BundleType::Rpm)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_unbundled_windows_builds_select_portable_updates() {
|
||||
use tauri::utils::config::BundleType;
|
||||
|
||||
Reference in new issue
Заблокувати користувача