한국어
Linux Programming
 

dbus-send 명령을 사용하면 시스템에서 사용 가능한 서비스를 출력할 수 있다.

 

Session 버스 :

dbus-send --session           \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply               \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames

 

System 버스 :

dbus-send --system            \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply               \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames

다음과 같은 결과를 출력해 준다.

method return time=1672301936.016979 sender=org.freedesktop.DBus -> destination=:1.28 serial=3 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string "org.freedesktop.login1"
      string "org.freedesktop.timesync1"
      string "org.freedesktop.systemd1"
      string "org.freedesktop.Avahi"
      string "org.bluez"
      string ":1.12"
      string ":1.0"
      string ":1.1"
      string ":1.2"
      string ":1.3"
      string ":1.28"
      string "fi.epitest.hostap.WPASupplicant"
      string ":1.4"
      string "fi.w1.wpa_supplicant1"
      string ":1.5"
   ]

 

특히 유용한 D-Bus 기본 인터페이스org.freedesktop.DBus.Introspectable.Introspect 를 호출하면 관심있는 서비스의 인터페이스를 검사할 수 있다:

dbus-send --system --type=method_call --print-reply \
   --dest=org.bluez \
   / \
   org.freedesktop.DBus.Introspectable.Introspect

결과는 다음과 같다.

method return time=1672302110.949720 sender=:1.5 -> destination=:1.31 serial=30 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node><interface name="org.freedesktop.DBus.Introspectable"><method name="Introspect"><arg name="xml" type="s" direction="out"/>
</method></interface><interface name="org.freedesktop.DBus.ObjectManager"><method name="GetManagedObjects"><arg name="objects" type="a{oa{sa{sv}}}" direction="out"/>
</method><signal name="InterfacesAdded"><arg name="object" type="o"/>
<arg name="interfaces" type="a{sa{sv}}"/>
</signal>
<signal name="InterfacesRemoved"><arg name="object" type="o"/>
<arg name="interfaces" type="as"/>
</signal>
</interface><node name="org"/></node>"