How to find methods exposed in a D-Bus interface - dbus

Question: Is there any way in which we can find out the methods (and their signatures) which are exposed in a D-Bus interface?
Issue Description: In my phone, I am calling BlueZ methods using D-Bus to adapter interface, when checked on phone 2 of these methods are not available.
Intention is to check if the method name/signatures are modified in other device, I don't have access to code so looking to find the methods in an interface

Using dbus-send, you can list the available services on your system:
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
You'll get an answer like that:
array [
string "org.freedesktop.DBus"
string ":1.1"
string ":1.26"
string "org.asamk.Signal"
]
And if you want to list all methods available behind a dbus service, you can still use dbus-send to introspect the dbus service.
For example with org.asamk.Signal:
dbus-send --system --type=method_call --print-reply \
--dest=org.asamk.Signal \
/org/asamk/Signal \
org.freedesktop.DBus.Introspectable.Introspect
You'll get this kind of result (truncated)
<node name="/org/asamk/Signal">
<interface name="org.asamk.Signal">
<method name="sendMessage" >
...parameters
</method>
<method name="sendGroupMessage" >
...parameters
</method>
</interface>
</node>
Here there are 2 methods, sendMessage and sendGroupMessage

You can also take a look at D-Feet.

With an extra google search and dbus understanding, using D-Bus Introspection helps to get the methods (with signatures) exposed on that particular interface. More information available at link.

Related

How to send method call by dbus-send?

I am analyzing Chromium OS.
I have captured a dbus method call using dbus-monitor and want to reappear it by dbus-send.
Below is what I want to reappear.
my-chromiumos ! # dbus-monitor --system "path=/org/chromium/SessionManager"
method call time=1632639141.486152 sender=:1.325 -> destination=org.chromium.SessionManager serial=402 path=/org/chromium/SessionManager; interface=org.chromium.SessionManagerInterface; member=RestartJob
file descriptor
inode: 489350
type: socket
address family: unix
name #
peer #
array [
string "/opt/google/chrome/chrome"
string "--gpu-sandbox-failures-fatal=no"
string "--enable-logging"
string "--use-cras"
string "--use-gl=egl"
string "--user-data-dir=/home/chronos"
string "--vmodule=*night_light*=1,*/ash/wm/tablet_mode/*=1,wizard_controller=1,*/webui/chromeos/login/*=1,*/browser/chromeos/login/screens/*=1,enrollment_screen_handler=1,*/browser/chromeos/login/enrollment/*=1,*/ui/ozone/*=1,*/ui/display/manager/chromeos/*=1"
string "--enable-wayland-server"
string "--aura-legacy-power-button"
string "--login-profile=user"
string "--system-developer-mode"
string "--bwsi"
string "--homepage=chrome://newtab/"
string "--incognito"
string "--log-level=1"
string "--login-user=$guest"
]
uint32 0
Please take a look at dbus-send documentation for more details.
dbus-send --dest=org.chromium.SessionManager \
--print-reply \
--type=method_call \
/org/chromium/SessionManager \
org.chromium.SessionManagerInterface.RestartJob
It looks like the above method call do not take any argument, but you should confirm with the available API documentation.
Also, I found this Chrome OS D-Bus Best Practices guide, please take a look at it as well.

libvirt qemu-system-arm, error: XML error: No PCI buses available

I am trying to run a linux image i created with buildroot with libvirt.
If i use qemu-system-arm directly, everything works as intended:
/usr/bin/qemu-system-arm \
-M versatilepb \
-kernel output/images/zImage \
-dtb output/images/versatile-pb.dtb \
-drive index=0,file=output/images/rootfs.ext2,if=scsi,format=raw \
-append "root=/dev/sda console=ttyAMA0,115200" \
-net nic,model=rtl8139 \
-net user \
-nographic
However, when i try to create the xml from my qemu cmdline, it fails:
$ virsh domxml-from-native qemu-argv qemu.args
error: XML error: No PCI buses available
I also tried to create a basic XML by hand:
<?xml version='1.0'?>
<domain type='qemu'>
<name>Linux ARM</name>
<uuid>ce1326f0-a9a0-11e3-a5e2-0800200c9a66</uuid>
<memory>131072</memory>
<currentMemory>131072</currentMemory>
<vcpu>1</vcpu>
<os>
<type machine='versatilepb'>hvm</type>
<kernel>zImage</kernel>
<cmdline>root=/dev/sda console=ttyAMA0,115200</cmdline>
<dtb>versatile-pb.dtb</dtb>
</os>
<devices>
<disk type='file' device='disk'>
<source file='rootfs.ext2'/>
<target dev="sda" bus="scsi"/>
</disk>
<interface type='network'>
<source network='default'/>
</interface>
</devices>
</domain>
which fails with the same error:
$ virsh create guest-test.xml
error: Failed to create domain from guest-test.xml
error: XML error: No PCI buses available
I already tried with the brand-new and latest libvirt-3.0.0, without any success
What do i need to change in my cmdline/xml?
virsh domxml-from-native issue
The reason why the domxml-from-native command does not work is because the underlying code in libvirt that does the parsing expects the suffix of qemu-system- to be a canonical architecture name, and arm is not. In your case it would seem you want arm to map to armv7l which is a cannonical architecture name. You can pull this of by creating a soft-link qemu-system-armv7l that points you your system's qemu-system-arm and then use the location of the softlink in your qemu.args
code references
https://github.com/libvirt/libvirt/blob/v4.0.0/src/qemu/qemu_parse_command.c#L1906
https://github.com/libvirt/libvirt/blob/v4.0.0/src/util/virarch.c#L135
xml issues
Your xml is giving you the same error for multiple unrelated reasons. In the type element under os you need to specify arch="armv7l" (or some other canonical arm arch name). Note also that the kernel and dtb references need to be absolute paths or prefixed with a .. Finally some of the devices you have require a PCI bus and will not work with the machine you are going for. Consider the following alternative.
<domain type='qemu'>
<name>Linux ARM</name>
<uuid>ce1326f0-a9a0-11e3-a5e2-0800200c9a66</uuid>
<memory>131072</memory>
<currentMemory>131072</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="armv7l" machine='versatilepb'>hvm</type>
<kernel>/path/to/zImage</kernel>
<cmdline>root=/dev/sda console=ttyAMA0,115200</cmdline>
<dtb>/path/to/versatile-pb.dtb</dtb>
</os>
<devices>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"></driver>
<source file="/path/to/root.qcow2"></source>
<target dev="sda" bus="sd"></target>
</disk>
<serial type="tcp">
<source mode="bind" host="localhost" service="4000"></source>
<protocol type="telnet"></protocol>
</serial>
</devices>
</domain>

Custom build of openSSL for OS X - limit ciphers suites

Main goal
I need openSSL. Apple deprecated this library since 10.7 It is even impossible to create context when ignoring warnings about deprecation.
I decided to build openSSL and tweak it to my needs:
disable SSL protocol (only TLS should be supported)
limit cipher suites to secure one
What I have done
How I'm trying to build it.
I've downloaded sources version 1.0.2d and configured it this way:
./Configure -openssldir=$(pwd)/output-build \
enable-ec_nistp_64_gcc_128 \
no-ssl2 no-ssl3 \
no-shared no-comp \
enable-TLS_DHE_RSA_WITH_AES_256_CBC_SHA \
enable-TLS_DH_RSA_WITH_AES_256_CBC_SHA \
enable-TLS_DHE_DSS_WITH_AES_256_CBC_SHA \
enable-TLS_DH_DSS_WITH_AES_256_CBC_SHA \
enable-TLS_RSA_WITH_AES_256_CBC_SHA \
enable-TLS_DHE_RSA_WITH_AES_128_CBC_SHA \
enable-TLS_DH_RSA_WITH_AES_128_CBC_SHA \
enable-TLS_DHE_DSS_WITH_AES_128_CBC_SHA \
enable-TLS_DH_DSS_WITH_AES_128_CBC_SHA \
enable-TLS_RSA_WITH_AES_128_CBC_SHA \
enable-TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA \
enable-TLS_RSA_WITH_3DES_EDE_CBC_SHA \
darwin64-x86_64-cc
Problem
Switches for disabling SSL are clear and I'm happy with it.
Switches for cipher suites are very inconvenient, I'm not sure how they work. They are not documented, ./Configure --help prints this:
Usage: Configure [no-<cipher> ...] [enable-<cipher> ...]
[experimental-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx]
[no-hw-xxx|no-hw] [[no-]threads] [[no-]shared]
[[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [sctp] [386]
[--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]]
[--test-sanity] os/compiler[:flags]
I just want listed cipher suites and nothing else. Format of this switches give me impression that I have to disable quite long list of other cipher suites. Is there better way so I can disabled all but those listed above?

Can you retrieve a D-Bus property without calling org.freedesktop.DBus.Properties.Get?

Say I want to programmatically get the interface name of my ethernet card. This seems to work:
dbus-send --print-reply \
--type=method_call \
--system \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/Devices/0 \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.NetworkManager.Device \
string:Interface
Which returns:
method return sender=:1.5 -> dest=:1.135 reply_serial=2
variant string "eth0"
Is there some way of cutting out the middleman org.freedesktop.DBus.Properties.Get and retrieve the property more directly? Alas, calling it as a method does not work:
dbus-send --print-reply \
--type=method_call \
--system \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/Devices/0 \
org.freedesktop.NetworkManager.Device.Interface
Returns:
Error org.freedesktop.DBus.Error.UnknownMethod:
Method "Interface" with signature "" on interface
"org.freedesktop.NetworkManager.Device" doesn't exist
I ask because having to call org.freedesktop.DBus.Properties.Get looks like having to call a object.getProp("someproperty") instead of object.getSomeProperty() in Python/Java/etc.
Yep, you can do that if you use qdbus. I don't have NetworkManager with me, but a command like that should work:
qdbus --system \
org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/Devices/0 \
org.freedesktop.NetworkManager.Device.Interface
There are various command-line clients for talking to D-Bus, some are more convenient than others. Here's the list of the ones I know.
dbus-send (provided with D-Bus itself)
gdbus (provided by GLib)
qdbus (provided by Qt)
busctl (provided by systemd)
No.
Most likely org.freedesktop.DBus.Properties.GetAll will return you same value, but internally every service implement properties as handlers to messages with org.freedesktop.DBus.Properties.Get/org.freedesktop.DBus.Properties.GetAll method calls.
It looks like object.getProp("someproperty") because it actually is more like this pseudo-code
bus.handleMessage({
service: "org.freedesktop.NetworkManager",
object: "/org/freedesktop/NetworkManager/Devices/0",
iface: "org.freedesktop.NetworkManager.Device.Interface",
body: [ "org.freedesktop.NetworkManager.Device", "Interface"],
thisMessageIsReplyTo: null
})
Internally every method call/signal/reply is just a message with big signature (service name/object path/interface) and body

In AIX 7.1 Apache modules not building as shared

I want all my modules built with a .so extension so that they are shared. However, all my modules are building with a .la extension. Here are the contents of the module directory:
httpd.exp libmod_proxy_ajp.a libmod_speling.a mod_info.la mod_proxy_scgi.la
libmod_cern_meta.a libmod_proxy_balancer.a libmod_ssl.a mod_proxy.la mod_rewrite.la
libmod_dbd.a libmod_proxy_connect.a libmod_vhost_alias.a mod_proxy_ajp.la mod_speling.la
libmod_deflate.a libmod_proxy_ftp.a mod_cern_meta.la mod_proxy_balancer.la mod_ssl.la
libmod_expires.a libmod_proxy_http.a mod_dbd.la mod_proxy_connect.la mod_vhost_alias.la
libmod_info.a libmod_proxy_scgi.a mod_deflate.la mod_proxy_ftp.la
libmod_proxy.a libmod_rewrite.a mod_expires.la mod_proxy_http.la
Here is my configure command:
./configure \
--with-mpm=prefork \
--with-ssl=/opt/freeware \
--enable-cern-meta \
--enable-dbd \
--enable-deflate \
--enable-expires \
--enable-info \
--enable-proxy \
--enable-rewrite \
--enable-speling \
--enable-ssl \
--enable-vhost-alias \
--enable-mods-shared="cern_meta dbd deflate expires info proxy rewrite speling ssl vhost_alias"
I have done this many times in the past on AIX 5.2, 5.3 and 6.1 without issue.
.la files are libtool's library control file syntax. Notice they are really just small scripts. Check for your shared library objects inside the .libs directory. You might also explicitly tell configure that you want shared libraries with --enable-shared

Resources