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: 12 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ meson setup -Dprofile=development build
ninja -C build
```

credentialsd-ui disables core dumps for itself, because it handles the PINs
that users type. To debug a crash in the UI, turn core dumps back on:

```
meson configure -Denable_core_dumps=true build
ninja -C build
```

## Building patched xdg-desktop-portal

For more context on the patch, see the [instructions above](#installing-credentialsd-and-credentialsd-ui).
Expand Down Expand Up @@ -209,6 +217,10 @@ cargo_locked false [True, False] Whether
cargo_offline false [True, False] Whether to perform an offline build with
Cargo. Defaults to false to download crates
from registries.
enable_core_dumps false [True, False] Allow credentialsd-ui to write core dumps,
for debugging crashes. Defaults to false
because the UI handles PINs typed by the
user.
feature_daemon enabled [enabled, disabled, Whether to build the credentialsd daemon
auto]
feature_demo_client auto [enabled, disabled, Whether to build the demo client
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- daemon: Build the list of devices offered to the user from libwebauthn's `available_transports()`, the same source discovery uses (#32)
- ui: Pass the caller's activation token to the compositor when showing the dialog, so it can take focus when the requesting window is in the background (#152)
- ui: Disable core dumps for the UI process, which handles typed PINs. Build with `-Denable_core_dumps=true` to allow them for debugging (#209)

# 0.4.0 [2026-11-05]

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions credentialsd-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ wayland = ["gdk-wayland"]
credentialsd-common = { path = "../credentialsd-common" }

futures-lite.workspace = true
libc.workspace = true
serde.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
Expand Down
1 change: 1 addition & 0 deletions credentialsd-ui/src/config.rs.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub const APP_ID: &str = @APP_ID@;
pub const ENABLE_CORE_DUMPS: bool = @ENABLE_CORE_DUMPS@;
pub const GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@;
pub const LOCALEDIR: &str = @LOCALEDIR@;
pub const PKGDATADIR: &str = @PKGDATADIR@;
Expand Down
39 changes: 39 additions & 0 deletions credentialsd-ui/src/hardening.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! Process-level protections for the UI, which handles PINs typed by the user.

use std::io;

/// Sets the core dump size limit to zero, both soft and hard, so the kernel
/// and systemd-coredump write no core dump for this process.
///
/// `prctl(PR_SET_DUMPABLE, 0)` would additionally block same-user ptrace, but
/// it also makes `/proc/<pid>/root` unreadable to xdg-desktop-portal, which
/// then rejects every portal call from this process, including the Settings
/// portal GTK uses for the colour scheme. Ptrace protection is left to Yama.
pub(crate) fn disable_core_dumps() -> io::Result<()> {
let limit = libc::rlimit {
rlim_cur: 0,
rlim_max: 0,
};
// SAFETY: `limit` is a valid rlimit that outlives the call.
if unsafe { libc::setrlimit(libc::RLIMIT_CORE, &limit) } != 0 {
return Err(io::Error::last_os_error());
}
Ok(())
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn core_limit_is_zero_afterwards() {
disable_core_dumps().unwrap();
let mut limit = libc::rlimit {
rlim_cur: 1,
rlim_max: 1,
};
// SAFETY: `limit` is a valid, writable rlimit.
assert_eq!(unsafe { libc::getrlimit(libc::RLIMIT_CORE, &mut limit) }, 0);
assert_eq!((limit.rlim_cur, limit.rlim_max), (0, 0));
}
}
7 changes: 7 additions & 0 deletions credentialsd-ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod client;
mod config;
mod dbus;
mod gui;
mod hardening;

use std::error::Error;

Expand All @@ -13,6 +14,12 @@ use crate::dbus::CredentialPortalBackend;

fn main() -> Result<(), Box<dyn Error>> {
tracing_subscriber::fmt::init();
// Keep typed PINs out of core dumps.
if config::ENABLE_CORE_DUMPS {
tracing::info!("Core dumps are enabled by the enable_core_dumps build option");
} else if let Err(err) = hardening::disable_core_dumps() {
tracing::warn!(%err, "Failed to disable core dumps");
}
tracing::debug!("Starting credentials UI service");
async_std::task::block_on(run())
}
Expand Down
1 change: 1 addition & 0 deletions credentialsd-ui/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ endif
global_conf.set_quoted('PROFILE', profile)
global_conf.set_quoted('VERSION', version + version_suffix)
global_conf.set_quoted('GETTEXT_PACKAGE', gettext_package)
global_conf.set('ENABLE_CORE_DUMPS', get_option('enable_core_dumps').to_string())
configure_file(input: 'config.rs.in', output: 'config.rs', configuration: global_conf)

# Copy the config.rs output to the source directory.
Expand Down
6 changes: 6 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ option(
value: false,
description: 'Whether to perform an offline build with Cargo. Defaults to false to download crates from registries.',
)
option(
'enable_core_dumps',
type: 'boolean',
value: false,
description: 'Allow credentialsd-ui to write core dumps, for debugging crashes. Defaults to false because the UI handles PINs typed by the user.',
)

# Features
option(
Expand Down