Subject: bug#44298: 28.0.50; D-Bus GetManagedObjects doesn't enumerate all paths.

From: Hugh Daschbach <[email-masked]>
Date: Wed, 28 Oct 2020 19:55:29 -0700

If a D-Bus interface is registered on more than one path, processing an
incoming GetManagedObjects method call only reports a single path.

The attached patch adds a test case to demonstrate this issue.

>From 43a446ce12485d669daed978796dc032113d73e5 Mon Sep 17 00:00:00 2001
From: Hugh Daschbach <[email-masked]>
Date: Wed, 28 Oct 2020 19:36:19 -0700
Subject: [PATCH] Add tests for D-Bus GetManagedObjects inquiry.

* test/lisp/net/dbus-tests.el (dbus-test09-get-managed-objects): New test.
---
 test/lisp/net/dbus-tests.el | 82 +++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/test/lisp/net/dbus-tests.el b/test/lisp/net/dbus-tests.el
index 2186d454aee..3bb2264defb 100644
--- a/test/lisp/net/dbus-tests.el
+++ b/test/lisp/net/dbus-tests.el
@@ -1889,6 +1889,88 @@ dbus-test08-register-monitor
     ;; Cleanup.
     (dbus-unregister-service :session dbus--test-service)))
 
+(ert-deftest dbus-test09-get-managed-objects ()
+  "Check `dbus-get-all-managed-objects'."
+  (skip-unless dbus--test-enabled-session-bus)
+  (dbus-ignore-errors (dbus-unregister-service :session dbus--test-service))
+  (dbus-register-service :session dbus--test-service)
+
+  (unwind-protect
+      (let ((path1 (concat dbus--test-path "/path1"))
+            (path2 (concat dbus--test-path "/path2"))
+            (path3 (concat dbus--test-path "/path3")))
+
+        (should-not
+         (dbus-get-all-managed-objects :session dbus--test-service dbus--test-path))
+
+        (should
+         (equal
+          (dbus-register-property
+           :session dbus--test-service path1 dbus--test-interface
+           "Property1" :readwrite "Simple string one.")
+          `((:property :session ,dbus--test-interface "Property1")
+            (,dbus--test-service ,path1))))
+
+        (should
+         (equal
+          (dbus-get-property
+           :session dbus--test-service path1 dbus--test-interface
+           "Property1")
+          "Simple string one."))
+
+        (should
+         (equal
+          (dbus-register-property
+           :session dbus--test-service path2 dbus--test-interface
+           "Property1" :readwrite "Simple string two.")
+          `((:property :session ,dbus--test-interface "Property1")
+            (,dbus--test-service ,path2))))
+
+        (should
+         (equal
+          (dbus-register-property
+           :session dbus--test-service path3 dbus--test-interface
+           "Property1" :readwrite "Simple string three.")
+          `((:property :session ,dbus--test-interface "Property1")
+            (,dbus--test-service ,path3))))
+
+        (should
+         (equal
+          (dbus-get-property
+           :session dbus--test-service path1 dbus--test-interface
+           "Property1")
+          "Simple string one."))
+
+        (should
+         (equal
+          (dbus-get-property
+           :session dbus--test-service path2 dbus--test-interface
+           "Property1")
+          "Simple string two."))
+
+        (should
+         (equal
+          (dbus-get-property
+           :session dbus--test-service path3 dbus--test-interface
+           "Property1")
+          "Simple string three."))
+
+        (let ((result (dbus-get-all-managed-objects :session dbus--test-service dbus--test-path)))
+          (should
+           (= 3 (length result)))
+
+          (should
+           (assoc-string path1 result))
+
+          (should
+           (assoc-string path2 result))
+
+          (should
+           (assoc-string path3 result))))
+
+    ;; Cleanup.
+    (dbus-unregister-service :session dbus--test-service)))
+
 (defun dbus-test-all (&optional interactive)
   "Run all tests for \\[dbus]."
   (interactive "p")

base-commit: bb3d13ac3586d3577605d3d8809d31c62a267c99
-- 
2.28.0

Cheers,
Hugh

In GNU Emacs 28.0.50 (build 20, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.3, Xaw3d scroll bars)
 of 2020-10-11 built on klaatu
Repository revision: 0f79544368c0dc343edcd97c3c7992aeab415b68
Repository branch: submission
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Artix Linux

Configured using:
 'configure --with-x-toolkit=lucid'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB
NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ERT-Results

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
thingatpt edmacro kmacro cl-extra vc-git diff-mode easy-mmode
bug-reference dbus-tests dbus cl-seq cl-macs pcase xml subr-x seq
byte-opt gv bytecomp byte-compile cconv ert-x ert pp ewoc debug
backtrace help-mode easymenu find-func cl-loaddefs cl-lib tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win
x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
x multi-tty make-network-process emacs)

Memory information:
((conses 16 122955 5639)
 (symbols 48 10363 1)
 (strings 32 26544 1387)
 (string-bytes 1 832865)
 (vectors 16 15402)
 (vector-slots 8 202326 11404)
 (floats 8 68 231)
 (intervals 56 612 0)
 (buffers 992 14))