how to expose methods on system bus using Qtdbus - dbus

I want to expose methods of my application on System bus using Qt Dbus in Qt Creator.
while using session bus ,the methods get exposed, but with system bus I am only able to see the Service name with which i registered but no methods to be exposed under it.(I am checking it in D-feet)
What should i do ?

You have to place your config file (e.g: example-dbus.conf) in /etc/dbus-1/system.d/
The example-dbus.conf file looks like:
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only root user can own the service -->
<policy user="root">
<allow own="com.company.qtdbus"/>
</policy>
<!-- Allow anyone to invoke methods on server, except SetHostName -->
<policy context="default">
<allow send_destination="com.company.qtdbus"/>
<allow receive_sender="com.company.qtdbus"/>
<deny send_destination="com.company.qtdbus"
send_interface="com.company.qtdbus.Server" send_member="SetHostName"/>
</policy>
<!-- Allow everything, including access to SetHostName -->
<policy user="root">
<allow send_destination="com.company.qtdbus"/>
<allow receive_sender="com.company.qtdbus"/>
</policy>
</busconfig>
Restart the dbus daemon with /etc/init.d/d-bus restart and now you should be allowed to connect to the system bus. In fact, if you not allowed to connect to the system bus, a error message will be shown.

Related

What permission of DBUS-Daemon Helper? Own daemon

I have tried to create my trace dbus daemon, needed to kio terminal autospawning routines. Problem is, I have got:
method call time=1666778936.233014 sender=:1.1 -> destination=org.kde.kio.appkinddetector.system_helper serial=2 path=/org/kde/framework/kio/console_systemdaemon; interface=org.kde.framework.kio.console_systemdaemon.mobj; member=registerProcess
uint32 32765
error time=1666778936.270515 sender=org.freedesktop.DBus -> destination=:1.1 error_name=org.freedesktop.DBus.Error.Spawn.PermissionsInvalid reply_serial=2
string "The permission of the setuid helper is not correct"
Config files are:
# cat /etc/dbus-1/system.d/org.kde.kio.appkinddetector.system_helper.conf
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow own="org.kde.kio.appkinddetector.system_helper"/>
</policy>
<policy context="default">
<allow send_destination="org.kde.kio.appkinddetector.system_helper"
send_interface="org.kde.framework.kio.console_systemdaemon.mobj"/>
</policy>
</busconfig>
# cat /usr/share/dbus-1/system-services /org.kde.kio.appkinddetector.system_helper.service
[D-BUS Service]
Name=org.kde.kio.appkinddetector.system_helper
Exec=/kde/src/build/franework/kio/bin/kio-appkinddetector-systemservice
User=root
I think, there exist an configuration error, but I cannot figure out, where.
I work inside docker daemon, which OpenSUSE Tumbleweed installed. I also give high access/permission of host to container.

Turning off custom errors in Windows Service

I have a Windows Service that uses .NET Remoting (yes I know remoting has been replaced by WCF but this is a legacy application).
When I run the service I get this:
Exception Type: System.Runtime.Remoting.RemotingException Message:
Server encountered an internal error. For more information, turn off
customErrors in the server's .config file.
I have this in my application's config file:
<configuration>
<system.runtime.remoting>
<!-- other settings go here -->
<customErrors mode="Off" />
</system.runtime.remoting>
</configuration>
Oddly, I still get this exception. What am I doing wrong?

Accessing Avahi through dbus-send

In the process of hacking around with dbus-monitor, I tried connecting to the Avahi daemon:
$ dbus-monitor --system \
"type='signal',interface='org.freedesktop.Avahi.Server',member='StateChanged'"
This will respond to changes in the state of the Avahi daemon.
$ sudo restart avahi-daemon
signal sender=org.freedesktop.DBus ->
dest=:1.315
serial=2
path=/org/freedesktop/DBus;
interface=org.freedesktop.DBus;
member=NameAcquired
string ":1.315"
signal sender=:1.318 ->
dest=(null destination)
serial=4
path=/;
interface=org.freedesktop.Avahi.Server;
member=StateChanged
int32 1
string "org.freedesktop.Avahi.Success"
signal sender=:1.318 ->
dest=(null destination)
serial=13
path=/;
interface=org.freedesktop.Avahi.Server;
member=StateChanged
int32 2
string "org.freedesktop.Avahi.Success"
However, I cannot browse services like this.
$ dbus-send --system --dest=org.freedesktop.Avahi --print-reply \
/ org.freedesktop.Avahi.Server.ServiceBrowserNew \
int32:-1 int32:-1 string:'_http._tcp' string:'local' uint32:0
method return sender=:1.345 ->
dest=:1.354
reply_serial=2
object path "/Client5/ServiceBrowser1"
$ dbus-monitor --system \
"type='signal',interface='org.freedesktop.Avahi.ServiceBrowser'"
As far as I understand, this should respond to new/removed http service
instances, but it does not.
Why?
Update:
Executing the equivalent of the above shell commands with the python and c APIs
worked as expected. However, they could not connect to a ServiceBrowser which I
had constructed using dbus-send and I could not use dbus-monitor to listen
to a ServiceBrowser they constructed.
At this point, my best guesses are:
Once the connection is closed (by the termination of the dbus-send command),
the ServiceBrowser I created is destroyed. However this does not explain why
dbus-monitor is unable to connect to a ServiceBrowser which is in active
communication with my python script.
The signals from the ServiceBrowser are emitted only to the connection which
instantiated them.
I believe the problem is caused by the dbus policy.
Try to change the avahi dbus policy in /etc/dbus-1/system.d/avahi-dbus.conf like this (remember to restart avahi daemon):
<busconfig>
<policy context="default">
<!-- All messages may be received by default -->
<allow receive_requested_reply="false" receive_type="method_call" eavesdrop="true"/>
<allow receive_requested_reply="false" receive_type="method_return" eavesdrop="true"/>
<allow receive_requested_reply="false" receive_type="error" eavesdrop="true"/>
<allow receive_requested_reply="false" receive_type="signal" eavesdrop="true"/>
<allow eavesdrop="true"/>
</policy>
<policy user="root">
<allow send_destination="*" eavesdrop="true"/>
<allow receive_sender="*" eavesdrop="true"/>
</policy>
</busconfig>
And use root privilege to run dbus-monitor:
sudo dbus-monitor --system \
"type='signal',interface='org.freedesktop.Avahi.ServiceBrowser'"
reference: http://blog.nutsfactory.net/2011/03/08/test-and-debug-dbus/

WCF RIA Services domain service over https client access policy problems

We have a WCF RIA domain service with
[EnableClientAccess(RequiresSecureEndpoint = true)]
We have the website set to use http and https. We have a client access policy file in the root of the website like this:
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
When we access the Silverlight application over https everything is fine. When we access it over http we get the following error:
Invoke operation 'Working' failed. An error occurred while trying to make a request to URI 'https://localhost/ClientBin/SilverlightApplication3-Web-DomainService1.svc/binary/Working'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
Which implies that our policy file is incorrect, but can't see what. Any ideas?
The reason that it wasn't working was that we were using a self-signed certificate, generated withe the machine name and then using localhost on the url. The url has to match to ensure that the ssl gets no certificate errors.
A good way to check this was to run the entire site over https and ensure that the browsers do not give a certificate error.

Silverlight 4 WCF "Cross-Domain" error

We have a WCF service running on a remote server. It runs as a Windows Service, not hosted in IIS. We can hit this WCF service from our WinForms and WFP apps without any problem. However, when we attempt to hit it from a Silverlight 4 app, we get the following error:
An error occurred while trying to make a request to URI 'http://111.111.111.111/8484/Psn'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
Could someone put this into English and explain what I might be able to do to satisfy Silverlight?
The first thing to check is that you have a clientaccesspolicy.xml file or crossdomain.xml file on the WCF service host. Either of these files can be used to control which domains have access to your service. Without them no one has any access from Silverlight. These files live in the root of the WCF service host:
If, for example, the service is hosted in http://fabrikam.com then the file must be located at http://fabrikam.com/clientaccesspolicy.xml ... [or] ... http://fabrikam.com/crossdomain.xml.
The following clientaccesspolicy.xml file will allow access from http://www.example.com but block it from everywhere else:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://www.example.com"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
A similar crossdomain.xml file would be:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="http://www.example.com" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
Source

Resources