Repository navigation
Conversation
6c3224f to
1c0ef03
Compare
1c0ef03 to
b5d35fc
Compare
b5d35fc to
00fcee8
Compare
Replace 'xsltproc' with 'libxslt' in dependencies.
|
@ryanrhughes fixed the build dependencied. Now it passes |
|
Tested this fix (GNOME MR !111) on an Omarchy machine with the default passwordless keyring and SDDM autologin. Two findings that may help this PR: 1. It also fixes silent loss of secrets that contain backslashes, not only newlines. gnome-keyring writes the textual keyring with 2. Check that |
|
Could this GNOME Keyring package also carry the separate OpenSession crash fix from GNOME MR !112? I backported its two-file diff at revision A fresh Secret Service client can reach Environment: x86_64 Omarchy 4.0.0.alpha, Measured regression test: 16 threads × 200 fresh GDBus connections, each calling
The tested package is installed and running locally. Longer-term desktop observation is pending, and !112 is still unmerged. The recipe below preserves Arch's dependencies, install hook, Cinnamon autostart patch, and installed file list. Its version This is additional to !111 in this PR. The reference recipe below contains !112 only; it should not replace your multiline-secret fix. I have not tested the combined patches. I also confirmed the repository-order concern already raised in this thread applies to my machine ( All source files needed to reproduce and build are included below. No core dump, keyring data, or credentials are included. To reproduce, save gcc -O2 -Wall -Wextra reproduce.c -o reproduce $(pkg-config --cflags --libs gio-2.0)
python run-isolated.py /path/to/stock/gnome-keyring-daemon plain 200 stock
python run-isolated.py /path/to/patched/gnome-keyring-daemon plain 200 patched
python run-isolated.py /path/to/patched/gnome-keyring-daemon dh-ietf1024-sha256-aes128-cbc-pkcs7 200 patchedRun through the wrapper, not directly against a desktop session bus. The wrapper disables core dumps and automatic service activation. The PKGBUILD's To build, save upstream-mr112.patch--- a/daemon/dbus/gkd-secret-service.c
+++ b/daemon/dbus/gkd-secret-service.c
@@ -422,18 +422,30 @@ service_method_open_session (GkdExportedService *skeleton,
GError *error = NULL;
const gchar *caller;
GVariant *input_payload;
+ gboolean opened;
caller = g_dbus_method_invocation_get_sender (invocation);
/* Now we can create a session with this information */
session = gkd_secret_session_new (self, caller);
input_payload = g_variant_get_variant (input);
- gkd_secret_session_handle_open (session, algorithm, input_payload,
- &output, &result,
- &error);
+ opened = gkd_secret_session_handle_open (session, algorithm, input_payload,
+ &output, &result,
+ &error);
g_variant_unref (input_payload);
- if (error != NULL) {
+ /* Branch on the return value, not on the error alone: a negotiate helper
+ * that bails out through g_return_val_if_fail() reports failure without
+ * ever setting one, and completing the call with a NULL body makes
+ * g_variant_new() abort the whole daemon. */
+ if (!opened || output == NULL || result == NULL) {
+ if (error == NULL)
+ g_set_error_literal (&error, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Couldn't open a session for this caller.");
+ if (output != NULL)
+ g_variant_unref (g_variant_ref_sink (output));
+ g_free (result);
g_dbus_method_invocation_take_error (invocation, error);
} else {
gkd_secret_service_publish_dispatch (self, caller,
@@ -1246,7 +1258,16 @@ gkd_secret_service_get_pkcs11_session (GkdSecretService *self, const gchar *call
g_return_val_if_fail (caller, NULL);
client = g_hash_table_lookup (self->clients, caller);
- g_return_val_if_fail (client, NULL);
+ if (client == NULL) {
+ /* The record is normally created by a high priority idle queued from
+ * the message filter, but that idle is not ordered against the method
+ * call that queued it: a peer which connects and calls straight away
+ * can reach us first. Create it here instead of failing the call --
+ * it is a hash table insert, not I/O. */
+ gkd_secret_service_ensure_client (self, caller);
+ client = g_hash_table_lookup (self->clients, caller);
+ g_return_val_if_fail (client, NULL);
+ }
/* Open a new session if necessary */
if (!client->pkcs11_session) {
@@ -1381,6 +1402,10 @@ gkd_secret_service_publish_dispatch (GkdSecretService *self, const gchar *caller
/* Take ownership of the session */
client = g_hash_table_lookup (self->clients, caller);
+ if (client == NULL) {
+ gkd_secret_service_ensure_client (self, caller);
+ client = g_hash_table_lookup (self->clients, caller);
+ }
g_return_if_fail (client);
path = gkd_secret_dispatch_get_object_path (object);
g_return_if_fail (!g_hash_table_lookup (client->dispatch, path));
--- a/daemon/dbus/gkd-secret-session.c
+++ b/daemon/dbus/gkd-secret-session.c
@@ -183,7 +183,12 @@ aes_negotiate (GkdSecretSession *self,
gboolean ret;
session = gkd_secret_service_get_pkcs11_session (self->service, self->caller);
- g_return_val_if_fail (session, FALSE);
+ if (session == NULL) {
+ g_set_error_literal (error_out, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Couldn't open a session for this caller.");
+ return FALSE;
+ }
if (!aes_create_dh_keys (session, "ietf-ike-grp-modp-1024", &pub, &priv)) {
g_set_error_literal (error_out, G_DBUS_ERROR,
@@ -250,7 +255,12 @@ plain_negotiate (GkdSecretSession *self,
GckSession *session;
session = gkd_secret_service_get_pkcs11_session (self->service, self->caller);
- g_return_val_if_fail (session, FALSE);
+ if (session == NULL) {
+ g_set_error_literal (error_out, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Couldn't open a session for this caller.");
+ return FALSE;
+ }
gck_builder_add_ulong (&builder, CKA_CLASS, CKO_SECRET_KEY);
gck_builder_add_ulong (&builder, CKA_KEY_TYPE, CKK_G_NULL);reproduce.c#include <gio/gio.h>
#include <stdio.h>
#include <string.h>
static gint failed, succeeded;
static gint rounds = 200;
static const char *algorithm;
static gpointer worker(gpointer unused) {
(void)unused;
for (int i = 0; i < rounds; i++) {
GError *error = NULL;
GDBusConnection *c = g_dbus_connection_new_for_address_sync(
g_getenv("DBUS_SESSION_BUS_ADDRESS"),
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
NULL, NULL, &error);
if (!c) {
g_atomic_int_inc(&failed);
g_clear_error(&error);
continue;
}
g_dbus_connection_set_exit_on_close(c, FALSE);
const guint8 public_key[] = {2};
GVariant *input = strcmp(algorithm, "plain") == 0
? g_variant_new_string("")
: g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, public_key, 1, 1);
GVariant *reply = g_dbus_connection_call_sync(c,
"org.freedesktop.secrets", "/org/freedesktop/secrets",
"org.freedesktop.Secret.Service", "OpenSession",
g_variant_new("(sv)", algorithm, input), G_VARIANT_TYPE("(vo)"),
G_DBUS_CALL_FLAGS_NO_AUTO_START, 3000, NULL, &error);
if (reply) {
g_atomic_int_inc(&succeeded);
g_variant_unref(reply);
} else {
if (g_atomic_int_add(&failed, 1) == 0)
fprintf(stderr, "First failure: %s\n", error ? error->message : "unknown");
g_clear_error(&error);
}
g_dbus_connection_close_sync(c, NULL, NULL);
g_object_unref(c);
}
return NULL;
}
int main(int argc, char **argv) {
algorithm = argc > 1 ? argv[1] : "plain";
if (argc > 2) rounds = atoi(argv[2]);
GThread *threads[16];
for (unsigned i = 0; i < G_N_ELEMENTS(threads); i++)
threads[i] = g_thread_new("fresh-client", worker, NULL);
for (unsigned i = 0; i < G_N_ELEMENTS(threads); i++)
g_thread_join(threads[i]);
printf("algorithm=%s succeeded=%d failed=%d total=%d\n",
algorithm, succeeded, failed, succeeded + failed);
return failed != 0;
}run-isolated.py#!/usr/bin/python
"""Exercise a daemon using only temporary keyrings and a private, activation-free bus."""
import os
from pathlib import Path
import resource
import subprocess
import sys
import tempfile
import time
root = Path(__file__).resolve().parent
binary = Path(sys.argv[1]).resolve()
algorithm = sys.argv[2] if len(sys.argv) > 2 else "plain"
rounds = sys.argv[3] if len(sys.argv) > 3 else "200"
label = sys.argv[4] if len(sys.argv) > 4 else binary.parent.parent.name
# Prevent intentional baseline crashes from creating persistent core dumps.
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
with tempfile.TemporaryDirectory(prefix="keyring-repro-") as scratch:
tmp = Path(scratch)
for name in ("data", "config", "runtime", "keyrings", "control"):
(tmp / name).mkdir(mode=0o700)
# Avoid falling back to an existing ~/.gnome2/keyrings directory.
(tmp / "data" / "keyrings").mkdir(mode=0o700)
config = tmp / "bus.conf"
config.write_text('''<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig><type>session</type><listen>unix:tmpdir=/tmp</listen>
<auth>EXTERNAL</auth><policy context="default"><allow send_destination="*"/>
<allow receive_sender="*"/><allow own="*"/></policy></busconfig>''')
bus = subprocess.Popen(["dbus-daemon", "--nofork", "--print-address=1",
f"--config-file={config}"], stdout=subprocess.PIPE, text=True)
daemon = None
try:
address = bus.stdout.readline().strip()
assert address.startswith("unix:"), "Private bus did not start"
env = os.environ.copy()
for name in ("GNOME_KEYRING_CONTROL", "GNOME_KEYRING_PID", "LISTEN_PID", "LISTEN_FDS"):
env.pop(name, None)
env.update(DBUS_SESSION_BUS_ADDRESS=address,
XDG_DATA_HOME=str(tmp / "data"), XDG_CONFIG_HOME=str(tmp / "config"),
XDG_RUNTIME_DIR=str(tmp / "runtime"),
GNOME_KEYRING_TEST_PATH=str(tmp / "keyrings"))
log = root / f"test-{label}-{algorithm}.log"
with log.open("w") as output:
daemon = subprocess.Popen([str(binary), "--foreground", "--components=secrets,pkcs11",
f"--control-directory={tmp / 'control'}"],
env=env, stdout=output, stderr=subprocess.STDOUT)
for _ in range(100):
check = subprocess.run(["gdbus", "call", "--session", "--dest", "org.freedesktop.DBus",
"--object-path", "/org/freedesktop/DBus", "--method",
"org.freedesktop.DBus.NameHasOwner", "org.freedesktop.secrets"],
env=env, capture_output=True, text=True)
if "true" in check.stdout:
break
if daemon.poll() is not None:
raise RuntimeError("Test daemon exited during startup; see " + str(log))
time.sleep(0.05)
else:
raise RuntimeError("Test daemon not ready")
result = subprocess.run([str(root / "reproduce"), algorithm, rounds], env=env, timeout=120)
time.sleep(0.1)
print(f"daemon_alive={daemon.poll() is None} daemon_exit={daemon.poll()} log={log.name}", flush=True)
sys.exit(0 if result.returncode == 0 and daemon.poll() is None else 1)
finally:
for process in (daemon, bus):
if process is not None and process.poll() is None:
process.terminate()
try:
process.wait(timeout=5)
except subprocess.TimeoutExpired:
process.kill()
process.wait()PKGBUILD# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan De Groot <jgc@archlinux.org>
pkgname=gnome-keyring
pkgver=50.0
pkgrel=1.1
epoch=1
pkgdesc="Stores passwords and encryption keys"
url="https://gitlab.gnome.org/GNOME/gnome-keyring"
arch=(x86_64)
license=(
GPL-2.0-or-later
LGPL-2.1-or-later
)
depends=(
dconf
gcr
gcr-4
glib2
glibc
libcap-ng
libgcc
libgcrypt
pam
systemd-libs
)
makedepends=(
docbook-xsl
git
glib2-devel
meson
p11-kit
python
)
provides=(org.freedesktop.secrets)
groups=(gnome)
install=gnome-keyring.install
# Backport GNOME/gnome-keyring!112, revision 8fcdeffe67ae8c1600eae9637816acbf73f66b81.
# Release archive checksum published by download.gnome.org.
source=(
"https://download.gnome.org/sources/$pkgname/${pkgver%%.*}/$pkgname-$pkgver.tar.xz"
0001-daemon-Add-Cinnamon-to-autostart-files.patch
upstream-mr112.patch
)
sha256sums=('cbd72062c53c9702bc2c4733991ad5f051ca682882b30905a2829bcf1a8ecc7c'
'138ad9a41dcbf9faede3a8b7fcb61dd5894ca8b66599802e58f8bb81e9607eb2'
'b1436245720f8f0a85e2018f6b5ae6c799b3f20f535f94bdaa17cafdeec14328')
prepare() {
cd "$pkgname-$pkgver"
# Autolaunch in Cinnamon
patch -Np1 -i ../0001-daemon-Add-Cinnamon-to-autostart-files.patch
patch -Np1 -i ../upstream-mr112.patch
}
build() {
local meson_options=(
-D selinux=disabled
)
arch-meson "$pkgname-$pkgver" build "${meson_options[@]}"
meson compile -C build
}
check() (
# Test daemons must not use the builder's actual keyring, even if the
# build disables GNOME_KEYRING_TEST_PATH support.
local test_root
test_root=$(mktemp -d)
trap 'rm -rf "$test_root"' EXIT
mkdir -p "$test_root/data/keyrings" "$test_root/config" "$test_root/cache" "$test_root/runtime"
chmod 700 "$test_root/runtime"
ulimit -c 0
env -u GNOME_KEYRING_CONTROL -u GNOME_KEYRING_PID \
XDG_DATA_HOME="$test_root/data" XDG_CONFIG_HOME="$test_root/config" \
XDG_CACHE_HOME="$test_root/cache" XDG_RUNTIME_DIR="$test_root/runtime" \
dbus-run-session meson test -C build --print-errorlogs
)
package() {
meson install -C build --destdir "$pkgdir"
}
# vim:set sw=2 sts=-1 et:gnome-keyring.installpost_install() {
# Enable socket by default
systemctl --global enable gnome-keyring-daemon.socket
}
post_upgrade() {
if (( $(vercmp $2 1:42.0-1) < 0)); then
systemctl --global enable gnome-keyring-daemon.socket
fi
}
pre_remove() {
systemctl --global disable gnome-keyring-daemon.socket
}0001-daemon-Add-Cinnamon-to-autostart-files.patchFrom 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Sat, 21 May 2022 18:47:23 +0000
Subject: [PATCH] daemon: Add Cinnamon to autostart files
Cinnamon also wants to use gnome-keyring-daemon.
---
daemon/gnome-keyring-pkcs11.desktop.in.in | 2 +-
daemon/gnome-keyring-secrets.desktop.in.in | 2 +-
daemon/gnome-keyring-ssh.desktop.in.in | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/daemon/gnome-keyring-pkcs11.desktop.in.in b/daemon/gnome-keyring-pkcs11.desktop.in.in
index 3e36603fac70..bb729caddfd1 100644
--- a/daemon/gnome-keyring-pkcs11.desktop.in.in
+++ b/daemon/gnome-keyring-pkcs11.desktop.in.in
@@ -3,7 +3,7 @@ Type=Application
Name=Certificate and Key Storage
Comment=GNOME Keyring: PKCS#11 Component
Exec=@bindir@/gnome-keyring-daemon --start --components=pkcs11
-OnlyShowIn=GNOME;Unity;MATE;
+OnlyShowIn=GNOME;Unity;MATE;Cinnamon;
NoDisplay=true
X-GNOME-Autostart-Phase=PreDisplayServer
X-GNOME-AutoRestart=false
diff --git a/daemon/gnome-keyring-secrets.desktop.in.in b/daemon/gnome-keyring-secrets.desktop.in.in
index 799caeea4306..6c836a2a7ec9 100644
--- a/daemon/gnome-keyring-secrets.desktop.in.in
+++ b/daemon/gnome-keyring-secrets.desktop.in.in
@@ -3,7 +3,7 @@ Type=Application
Name=Secret Storage Service
Comment=GNOME Keyring: Secret Service
Exec=@bindir@/gnome-keyring-daemon --start --components=secrets
-OnlyShowIn=GNOME;Unity;MATE;
+OnlyShowIn=GNOME;Unity;MATE;Cinnamon;
NoDisplay=true
X-GNOME-Autostart-Phase=PreDisplayServer
X-GNOME-AutoRestart=false
diff --git a/daemon/gnome-keyring-ssh.desktop.in.in b/daemon/gnome-keyring-ssh.desktop.in.in
index fd7657a4d0cc..8f9847033507 100644
--- a/daemon/gnome-keyring-ssh.desktop.in.in
+++ b/daemon/gnome-keyring-ssh.desktop.in.in
@@ -3,7 +3,7 @@ Type=Application
Name=SSH Key Agent
Comment=GNOME Keyring: SSH Agent
Exec=@bindir@/gnome-keyring-daemon --start --components=ssh
-OnlyShowIn=GNOME;Unity;MATE;
+OnlyShowIn=GNOME;Unity;MATE;Cinnamon;
X-GNOME-Autostart-Phase=PreDisplayServer
X-GNOME-AutoRestart=false
X-GNOME-Autostart-Notify=truePrepared and tested with GPT-6 via Codex; posted at the machine owner's request. Upstream patch authorship belongs to the authors of GNOME MR !112. |
|
Update with GNOME Keyring 51.1 results, tested October 27. An ordinary system update on October 26 replaced our locally patched I rebuilt 51.1 with the same unchanged GNOME MR !112 patch from my October 10 comment, revision
The regression tests used temporary keyrings/XDG directories and a private D-Bus with service activation disabled. No real credentials were used. The resulting The 51.1 release archive SHA-256 is What is the preferred next step to get this shipped to other Omarchy users?
I have temporarily held only Prepared and tested with GPT-6 via Codex; posted at the machine owner's request. Upstream patch authorship remains with the authors of GNOME MR !112. |
Backports GNOME MR GNOME/gnome-keyring!111to fix secret corruption when storing multiline secrets (e.g. JSON certificates) in textual keyrings.