From df094dd4bc122d0d1539ee01130dd2b4ed006549 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 24 Nov 2023 11:09:15 +0100 Subject: [PATCH] Do not unregister a D-Bus service which is a unique name * lisp/net/dbus.el (dbus-unregister-service): Check, whether SERVICE is a known name. (Bug#67386) --- lisp/net/dbus.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index f35d11db152..95f92cf7786 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el @@ -682,7 +682,9 @@ operation. One of the following keywords is returned: `:non-existent': Service name does not exist on this bus. `:not-owner': We are neither the primary owner nor waiting in the -queue of this service." +queue of this service. + +When SERVICE is not a known name but a unique name, the function returns nil." (maphash (lambda (key value) @@ -694,14 +696,17 @@ queue of this service." (puthash key (delete elt value) dbus-registered-objects-table) (remhash key dbus-registered-objects-table))))))) dbus-registered-objects-table) - (let ((reply (dbus-call-method - bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus - "ReleaseName" service))) - (pcase reply - (1 :released) - (2 :non-existent) - (3 :not-owner) - (_ (signal 'dbus-error (list "Could not unregister service" service)))))) + + (unless (string-prefix-p ":" service) + (let ((reply (dbus-call-method + bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus + "ReleaseName" service))) + (pcase reply + (1 :released) + (2 :non-existent) + (3 :not-owner) + (_ (signal + 'dbus-error (list "Could not unregister service" service))))))) (defun dbus-register-signal (bus service path interface signal handler &rest args) -- 2.39.2