dbus에서 모든 서비스 목록을 가져오는 방법을 알고 있지만 각 서비스 내의 인터페이스 목록을 보고 싶습니다.
dbus-send --session \
--dest=org.freedesktop.DBus \
--type=method_call \
--print-reply \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames
사용 가능한 모든 서비스 목록이 제공됩니다.
답변1
이를 재귀적으로 처리할 수 있는 여러 유틸리티가 있지만 dbus-send만 있다고 가정하면 다음과 같이 하려는 작업을 계속 수행할 수 있습니다.
런타임 시 $SERVICE로 표시되는 관심 있는 서비스 목록을 가져옵니다.
dbus-send --session --dest=${SERVICE} --type=method_call --print-reply "/" org.freedesktop.DBus.Introspectable.Introspect
그러면 다음과 같은 내용이 제공됩니다.
method return time=1563564828.143670 sender=:1.107 -> destination=:1.13227 serial=167 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">
<!-- GDBus 2.58.3 -->
<node>
<node name="org"/>
</node>
"
각 노드에 대해 하위 경로에 대해 명령을 다시 실행할 수 있으므로 NODE_PATH=/org의 경우
dbus-send --session --dest=${SERVICE} --type=method_call --print-reply "${NODE_PATH}" org.freedesktop.DBus.Introspectable.Introspect
마침내 메소드를 나열하는 인터페이스에 도달할 때까지 프로세스를 반복할 수 있는 또 다른 노드 세트가 제공됩니다. 예는 다음과 같습니다.
dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply "/org/freedesktop" org.freedesktop.DBus.Introspectable.Introspect
method return time=1563565305.203169 sender=org.freedesktop.DBus -> destination=:1.13267 serial=3 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">
<method name="Hello">
<arg direction="out" type="s"/>
</method>
<method name="RequestName">
<arg direction="in" type="s"/>
<arg direction="in" type="u"/>
<arg direction="out" type="u"/>
</method>
<method name="ReleaseName">
<arg direction="in" type="s"/>
<arg direction="out" type="u"/>
</method>
<method name="StartServiceByName">
<arg direction="in" type="s"/>
<arg direction="in" type="u"/>
<arg direction="out" type="u"/>
</method>
<method name="UpdateActivationEnvironment">
<arg direction="in" type="a{ss}"/>
</method>
<method name="NameHasOwner">
<arg direction="in" type="s"/>
<arg direction="out" type="b"/>
</method>
<method name="ListNames">
<arg direction="out" type="as"/>
</method>
<method name="ListActivatableNames">
<arg direction="out" type="as"/>
</method>
<method name="AddMatch">
<arg direction="in" type="s"/>
</method>
<method name="RemoveMatch">
<arg direction="in" type="s"/>
</method>
<method name="GetNameOwner">
<arg direction="in" type="s"/>
<arg direction="out" type="s"/>
</method>
<method name="ListQueuedOwners">
<arg direction="in" type="s"/>
<arg direction="out" type="as"/>
</method>
<method name="GetConnectionUnixUser">
<arg direction="in" type="s"/>
<arg direction="out" type="u"/>
</method>
<method name="GetConnectionUnixProcessID">
<arg direction="in" type="s"/>
<arg direction="out" type="u"/>
</method>
<method name="GetAdtAuditSessionData">
<arg direction="in" type="s"/>
<arg direction="out" type="ay"/>
</method>
<method name="GetConnectionSELinuxSecurityContext">
<arg direction="in" type="s"/>
<arg direction="out" type="ay"/>
</method>
<method name="ReloadConfig">
</method>
<method name="GetId">
<arg direction="out" type="s"/>
</method>
<method name="GetConnectionCredentials">
<arg direction="in" type="s"/>
<arg direction="out" type="a{sv}"/>
</method>
<property name="Features" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<property name="Interfaces" type="as" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<signal name="NameOwnerChanged">
<arg type="s"/>
<arg type="s"/>
<arg type="s"/>
</signal>
<signal name="NameLost">
<arg type="s"/>
</signal>
<signal name="NameAcquired">
<arg type="s"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg direction="out" type="s"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="GetMachineId">
<arg direction="out" type="s"/>
</method>
<method name="Ping">
</method>
</interface>
<node name="DBus"/>
</node>
"