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)
This commit is contained in:
Michael Albinus 2023-11-24 11:09:15 +01:00
parent e6ad97a333
commit df094dd4bc

View file

@ -682,7 +682,9 @@ operation. One of the following keywords is returned:
`:non-existent': Service name does not exist on this bus. `:non-existent': Service name does not exist on this bus.
`:not-owner': We are neither the primary owner nor waiting in the `: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 (maphash
(lambda (key value) (lambda (key value)
@ -694,14 +696,17 @@ queue of this service."
(puthash key (delete elt value) dbus-registered-objects-table) (puthash key (delete elt value) dbus-registered-objects-table)
(remhash key dbus-registered-objects-table))))))) (remhash key dbus-registered-objects-table)))))))
dbus-registered-objects-table) dbus-registered-objects-table)
(let ((reply (dbus-call-method
bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus (unless (string-prefix-p ":" service)
"ReleaseName" service))) (let ((reply (dbus-call-method
(pcase reply bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus
(1 :released) "ReleaseName" service)))
(2 :non-existent) (pcase reply
(3 :not-owner) (1 :released)
(_ (signal 'dbus-error (list "Could not unregister service" service)))))) (2 :non-existent)
(3 :not-owner)
(_ (signal
'dbus-error (list "Could not unregister service" service)))))))
(defun dbus-register-signal (defun dbus-register-signal
(bus service path interface signal handler &rest args) (bus service path interface signal handler &rest args)