Skip to content
Merged
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
12 changes: 11 additions & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ GitHub's "latest" never points at a draft or a pre-release, and that is
the only thing keeping both away from listeners; the app doesn't filter
them itself. `latest.json` points each platform at its file through the
GitHub API (`api.github.com/repos/…/releases/assets/<id>`), and the app
checks every download's signature before installing it.
checks every download's signature before installing it. It installs an
`.rpm` with `pkexec rpm -U --nosignature`: the `.rpm` has no OpenPGP
signature, which RPM 6 refuses by default
(`docs/adr/0005-rpm-updates-skip-rpm-signature-check.md`).

### Where the version lives

Expand Down Expand Up @@ -272,3 +275,10 @@ Answers from updating a real install 1.0.0 → 1.0.1 on each OS (#10).
- *Not yet tested.*
- **Linux (.deb / .rpm):** is the `pkexec` password prompt acceptable?
- *Not yet tested.*
- **Linux (.rpm, Fedora's RPM 6 with signature checking enforced):** releases up to 1.5.0
can't update themselves. Their updater runs a plain `rpm -U`, which
refuses the unsigned package after the password prompt (`package … does
not verify: no signature`). Those installs have to take one release by
hand (`sudo dnf install ./Reverb-<version>-1.x86_64.rpm`); the release
after 1.5.0 and everything since update in the app. Found on Fedora 45
with RPM 6.1.
70 changes: 34 additions & 36 deletions THIRD-PARTY-LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Reverb itself is licensed under the GNU General Public License v3.0 (see `LICENSE`). It bundles the third-party components listed here, whose licences require that their copyright notices and terms travel with any distributed build.

This file is generated — run `python3 scripts/gen-third-party.py` after changing dependencies. It covers 552 Rust crates (`cargo tree -e normal`, all targets) and 16 npm packages (runtime `dependencies`). Build-only tooling is excluded because it contributes no code to the shipped binary.
This file is generated — run `python3 scripts/gen-third-party.py` after changing dependencies. It covers 552 Rust crates (`cargo tree -e normal`, all targets) and 15 npm packages (runtime `dependencies`). Build-only tooling is excluded because it contributes no code to the shipped binary.

## Source availability for MPL-2.0 components

Expand Down Expand Up @@ -593,7 +593,6 @@ The Mozilla Public License 2.0 requires that recipients of a binary be told how
- @tauri-apps/plugin-opener 2.7.2 — MIT OR Apache-2.0
- @tauri-apps/plugin-process 2.4.0 — MIT OR Apache-2.0
- @tauri-apps/plugin-store 2.4.4 — MIT OR Apache-2.0
- @tauri-apps/plugin-updater 2.14.0 — MIT OR Apache-2.0
- lucide-react 1.28.0 — ISC
- markdown-to-jsx 9.10.3 — MIT
- motion 13.0.0 — MIT
Expand Down Expand Up @@ -2866,40 +2865,6 @@ ICU 1.8.1 to ICU 57.1 © 1995-2016 International Business Machines Corporation a

### 10. Applies to 8 package(s)

- @tauri-apps/plugin-opener 2.7.2 (MIT OR Apache-2.0)
- @tauri-apps/plugin-process 2.4.0 (MIT OR Apache-2.0)
- @tauri-apps/plugin-store 2.4.4 (MIT OR Apache-2.0)
- @tauri-apps/plugin-updater 2.14.0 (MIT OR Apache-2.0)
- tauri-plugin-log 2.9.0 (Apache-2.0 OR MIT)
- tauri-plugin-opener 2.7.2 (Apache-2.0 OR MIT)
- tauri-plugin-process 2.4.0 (Apache-2.0 OR MIT)
- tauri-plugin-updater 2.14.0 (Apache-2.0 OR MIT)

```
SPDXVersion: SPDX-2.1
DataLicense: CC0-1.0
PackageName: tauri
DataFormat: SPDXRef-1
PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy
PackageHomePage: https://tauri.app
PackageLicenseDeclared: Apache-2.0
PackageLicenseDeclared: MIT
PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy
PackageSummary: <text>Tauri is a rust project that enables developers to make secure
and small desktop applications using a web frontend.
</text>
PackageComment: <text>The package includes the following libraries; see
Relationship information.
</text>
Created: 2019-05-20T09:00:00Z
PackageDownloadLocation: git://github.com/tauri-apps/tauri
PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git
PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git
Creator: Person: Daniel Thompson-Yvetot
```

### 11. Applies to 8 package(s)

- android_system_properties 0.1.6 (MIT OR Apache-2.0)
- nanoid 6.0.1 (MIT)
- phf 0.13.1 (MIT)
Expand Down Expand Up @@ -2940,6 +2905,39 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

### 11. Applies to 7 package(s)

- @tauri-apps/plugin-opener 2.7.2 (MIT OR Apache-2.0)
- @tauri-apps/plugin-process 2.4.0 (MIT OR Apache-2.0)
- @tauri-apps/plugin-store 2.4.4 (MIT OR Apache-2.0)
- tauri-plugin-log 2.9.0 (Apache-2.0 OR MIT)
- tauri-plugin-opener 2.7.2 (Apache-2.0 OR MIT)
- tauri-plugin-process 2.4.0 (Apache-2.0 OR MIT)
- tauri-plugin-updater 2.14.0 (Apache-2.0 OR MIT)

```
SPDXVersion: SPDX-2.1
DataLicense: CC0-1.0
PackageName: tauri
DataFormat: SPDXRef-1
PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy
PackageHomePage: https://tauri.app
PackageLicenseDeclared: Apache-2.0
PackageLicenseDeclared: MIT
PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy
PackageSummary: <text>Tauri is a rust project that enables developers to make secure
and small desktop applications using a web frontend.
</text>
PackageComment: <text>The package includes the following libraries; see
Relationship information.
</text>
Created: 2019-05-20T09:00:00Z
PackageDownloadLocation: git://github.com/tauri-apps/tauri
PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git
PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git
Creator: Person: Daniel Thompson-Yvetot
```

### 12. Applies to 6 package(s)

- aho-corasick 1.1.5 (Unlicense OR MIT)
Expand Down
11 changes: 11 additions & 0 deletions docs/adr/0005-rpm-updates-skip-rpm-signature-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
status: accepted
---

# Reverb installs .rpm updates itself, without rpm's signature check

The updater plugin installs an .rpm update with `pkexec rpm -U`, and Reverb's .rpm has no OpenPGP signature. Fedora's RPM 6 refuses such a package unless told otherwise (`%_pkgverify_level all`, since its [Enforcing signature checking by default](https://fedoraproject.org/wiki/Changes/Enforcing_signature_checking_by_default) change), so on those systems every in-app update failed after the password prompt, with `package … does not verify: no signature`. The plugin offers no way to change that command, so Reverb drives the update itself (`src-tauri/src/commands/update.rs`): the plugin still finds, downloads and checks the release against the updater key, and for an .rpm install Reverb runs `pkexec rpm -U --nosignature` instead. Skipping rpm's check gives nothing up, because the updater key check that comes before it is what proves the package is a Reverb release; rpm still checks the package's digests. Signing the .rpm with a GPG key was the alternative, but rpm only trusts keys imported into its database, so every listener would have had to import Reverb's key by hand before an update could install, and the release would have needed a second signing key to keep safe.

## Consequences

An install still on a release from before this change runs the plugin's plain `rpm -U` and cannot update itself on RPM 6. It has to install one release by hand (`sudo dnf install ./Reverb-<version>-1.x86_64.rpm`), and updates in the app from then on. The plugin's fallbacks after a failed `pkexec` (a zenity or kdialog password prompt, then `sudo`) are gone for .rpm installs: the update fails with the reason instead, and can be tried again. If the plugin ever lets an app pass its own arguments to `rpm`, or stops depending on rpm's signature check, the .rpm path can go back to the plugin's install.
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-process": "^2.4.0",
"@tauri-apps/plugin-store": "^2.4.4",
"@tauri-apps/plugin-updater": "^2.14.0",
"lucide-react": "^1.28.0",
"markdown-to-jsx": "^9.10.3",
"motion": "^13.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ serde_json.workspace = true
thiserror.workspace = true
log.workspace = true

[target.'cfg(target_os = "linux")'.dependencies]
# The private directory an .rpm update is written to before rpm installs it.
tempfile = "3"

[dev-dependencies]
tempfile = "3"
1 change: 0 additions & 1 deletion src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"permissions": [
"core:default",
"core:window:allow-set-fullscreen",
"updater:default",
"process:allow-restart",
"opener:default"
]
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub mod player;
pub mod services;
pub mod settings;
pub mod stats;
pub mod update;
203 changes: 203 additions & 0 deletions src-tauri/src/commands/update.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
//! Updating Reverb to a newer release: looking for one, downloading it and
//! installing it. The frontend's update controller decides when.
//!
//! The updater plugin finds the release, downloads it and checks it against
//! the updater key Reverb shipped with. Installing is the plugin's too, except
//! for an .rpm install, which Reverb does itself (see [`rpm`]).

use std::sync::{Arc, Mutex, MutexGuard, PoisonError};

use serde::Serialize;
use tauri::{AppHandle, State};
use tauri_plugin_updater::{Update, UpdaterExt};

use crate::error::ReverbError;

/// The release the last check found, and its package once downloaded.
#[derive(Default)]
pub struct PendingUpdate(Mutex<Option<Pending>>);

struct Pending {
update: Update,
/// The downloaded package, already checked against the updater key.
package: Option<Arc<Vec<u8>>>,
}

impl PendingUpdate {
fn lock(&self) -> MutexGuard<'_, Option<Pending>> {
self.0.lock().unwrap_or_else(PoisonError::into_inner)
}
}

/// A newer release, as the update panel shows it.
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateInfo {
version: String,
/// Release notes, Markdown.
notes: String,
/// When the release was published (RFC 3339).
date: Option<String>,
}

fn info_of(update: &Update) -> UpdateInfo {
UpdateInfo {
version: update.version.clone(),
notes: update.body.clone().unwrap_or_default(),
date: update
.date
.and_then(|d| chrono::DateTime::from_timestamp(d.unix_timestamp(), d.nanosecond()))
.map(|d| d.to_rfc3339()),
}
}

/// The plugin's message alone stops at "error sending request for url (…)";
/// the reason (DNS, TLS, a refused connection) is further down the chain.
fn update_error(e: tauri_plugin_updater::Error) -> ReverbError {
let mut message = e.to_string();
let mut source = std::error::Error::source(&e);
while let Some(cause) = source {
message.push_str(": ");
message.push_str(&cause.to_string());
source = cause.source();
}
ReverbError::Update(message)
}

/// Ask the update endpoint for a newer release; `None` when this is the newest.
#[tauri::command]
pub async fn update_check(
app: AppHandle,
pending: State<'_, PendingUpdate>,
) -> Result<Option<UpdateInfo>, ReverbError> {
let update = app.updater().map_err(update_error)?.check().await.map_err(update_error)?;
let info = update.as_ref().map(info_of);
*pending.lock() = update.map(|update| Pending { update, package: None });
Ok(info)
}

/// Download the release the last check found, and check it against the
/// updater key.
#[tauri::command]
pub async fn update_download(pending: State<'_, PendingUpdate>) -> Result<(), ReverbError> {
let update = pending
.lock()
.as_ref()
.map(|p| p.update.clone())
.ok_or_else(|| ReverbError::Update("no update to download".into()))?;
let package = update.download(|_, _| {}, || {}).await.map_err(update_error)?;
if let Some(p) = pending.lock().as_mut().filter(|p| p.update.version == update.version) {
p.package = Some(Arc::new(package));
}
Ok(())
}

/// Install the downloaded release over this one. The frontend relaunches
/// afterwards; on Windows the installer takes over and Reverb exits here.
/// After a failure the package stays downloaded, so it can be tried again.
#[tauri::command]
pub async fn update_install(pending: State<'_, PendingUpdate>) -> Result<(), ReverbError> {
let (update, package) = pending
.lock()
.as_ref()
.and_then(|p| Some((p.update.clone(), p.package.clone()?)))
.ok_or_else(|| ReverbError::Update("no downloaded update to install".into()))?;
let version = update.version.clone();
// Blocking: it waits for the password prompt and the package manager.
tauri::async_runtime::spawn_blocking(move || install(&update, &package))
.await
.map_err(|e| ReverbError::State(e.to_string()))?
.inspect_err(|e| log::warn!("could not install update {version}: {e}"))
}

fn install(update: &Update, package: &[u8]) -> Result<(), ReverbError> {
#[cfg(target_os = "linux")]
if matches!(
tauri::utils::platform::bundle_type(),
Some(tauri::utils::config::BundleType::Rpm)
) {
update.verify(package).map_err(update_error)?;
return rpm::install(package);
}
update.install(package).map_err(update_error)
}

/// Installing an .rpm update: what the plugin does (`rpm -U` through
/// `pkexec`), plus `--nosignature`.
///
/// Fedora's RPM 6 refuses a package without an OpenPGP signature unless told
/// otherwise (`%_pkgverify_level all`, since Fedora's "Enforcing signature
/// checking by default" change), and Reverb's .rpm has none. With the plugin's plain `rpm -U`, every update on those systems
/// failed after the password prompt. Skipping rpm's signature check gives
/// nothing up: the package has just been checked against the updater key
/// ([`Update::verify`]), which is what proves it is a Reverb release. rpm
/// still checks the package's digests.
#[cfg(target_os = "linux")]
mod rpm {
use std::process::Command;

use crate::error::ReverbError;

pub fn install(package: &[u8]) -> Result<(), ReverbError> {
// A fresh directory only this user can write to, so nothing can swap
// the package between writing it and rpm reading it as root.
let dir = tempfile::Builder::new().prefix("reverb-update-").tempdir()?;
let path = dir.path().join("reverb.rpm");
std::fs::write(&path, package)?;
let output = Command::new("pkexec")
.args(["rpm", "-U", "--nosignature"])
.arg(&path)
.output()
.map_err(|e| ReverbError::Update(format!("could not run pkexec: {e}")))?;
if output.status.success() {
Ok(())
} else {
Err(ReverbError::Update(failure(output.status.code(), &output.stderr)))
}
}

/// What went wrong, from `pkexec rpm`'s exit code and rpm's complaint.
pub(super) fn failure(code: Option<i32>, stderr: &[u8]) -> String {
match code {
Some(126) => "the password prompt was dismissed".into(),
Some(127) => "not authorized to install the update".into(),
_ => {
let stderr = String::from_utf8_lossy(stderr);
match (stderr.trim(), code) {
("", Some(code)) => format!("rpm failed with exit code {code}"),
("", None) => "rpm was stopped by a signal".into(),
(reason, _) => format!("rpm failed: {reason}"),
}
}
}
}
}

#[cfg(all(test, target_os = "linux"))]
mod tests {
use super::rpm::failure;

#[test]
fn says_when_the_password_prompt_was_dismissed() {
assert_eq!(failure(Some(126), b""), "the password prompt was dismissed");
}

#[test]
fn says_when_pkexec_refused() {
assert_eq!(failure(Some(127), b""), "not authorized to install the update");
}

#[test]
fn passes_on_what_rpm_said() {
assert_eq!(
failure(Some(1), b"\tpackage reverb-0:1.5.0-1.x86_64 does not verify: no signature\n"),
"rpm failed: package reverb-0:1.5.0-1.x86_64 does not verify: no signature"
);
}

#[test]
fn falls_back_to_the_exit_code() {
assert_eq!(failure(Some(2), b" \n"), "rpm failed with exit code 2");
assert_eq!(failure(None, b""), "rpm was stopped by a signal");
}
}
Loading
Loading