You are not logged in.
Pages: 1
I'm triying to do an "automount for PenDrivers and Optical Devices" with the following code:
!/usr/bin/env python
# -*- encoding: utf-8 -*-
import dbus
import dbus.service
import gobject
#from dbus.mainloop.glib import DBusGMainLoop
#DBusGMainLoop(set_as_default=True)
if getattr(dbus, 'version', (0,0,0))>= (0,41,0):
import dbus.glib
import sys
import os
#import time
class DeviceManager:
def __init__(self):
self.bus = dbus.SystemBus()
print self.bus
res = self.bus.add_signal_receiver(self.device_added,
'DeviceAdded',
'org.freedesktop.Hal.Manager',
'org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
print res
res = self.bus.add_signal_receiver(self.device_removed,
'DeviceRemoved',
'org.freedesktop.Hal.Manager',
'org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
print res
def udi_to_device(self, udi):
return self.bus.get_object("org.freedesktop.Hal", udi)
def device_added(self, udi):
'DeviceRemoved',
'org.freedesktop.Hal.Manager',
'org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
print res
def udi_to_device(self, udi):
return self.bus.get_object("org.freedesktop.Hal", udi)
def device_added(self, udi):
print 'Added', udi
device = self.udi_to_device(udi)
print "Device: ", device
properties = device.GetAllProperties()
if properties.get('info.category') == u'volume':
label, dev = properties.get('volume.label'), properties.get('block.device')
if not label:
os.system("pmount '%s'" %(dev))
else:
os.system("pmount %s /media/'%s'" %(dev, label))
def device_removed(self, udi):
print 'Removed', udi
if __name__ == '__main__':
m = DeviceManager()
mainloop = gobject.MainLoop()
try:
mainloop.run()
except KeyboardInterrupt:
mainloop.quit()
print "Exiting..."
sys.exit(0)
I have already start d-bus and hal daemons.
When I execute this script as root, i receive the following error:
DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.22" (uid=0 pid=2569 comm="python hal-automount.py ") interface="(unset)" member="GetAllProperties" error name="(unset)" requested_reply=0 destination=":1.0" (uid=0 pid=1759 comm="/usr/sbin/hald "))
in the line:
properties = device.GetAllProperties()
My system.conf of dbus (/etc/dbus-1/system.conf) has allow the following call:
<!-- Signals and reply messages (method returns, errors) are allowed
by default -->
<allow send_type="signal"/>
<allow send_requested_reply="true" send_type="method_call"/>
<allow send_requested_reply="true" send_type="method_return"/>
<allow send_requested_reply="true" send_type="error"/>
<!-- All messages may be received by default -->
<allow receive_type="method_call"/>
<allow receive_type="method_return"/>
<allow receive_type="error"/>
<allow receive_type="signal"/>
what am i doing bad? I think is a problem with any config file of dbus or hal.
Thanks a lot for your time.
Offline
I think you should check the receiving dbus configuration for hald, because it might be dropping it upon reception. It would be somewhere like /etc/dbus-1/system.d/hald.conf or /etc/dbus-1/session.d/hald.conf (I'm not on my box, so I can't check).
Offline
I added this lines to /etc/dbus-1/system.d/hal.conf:
<policy group="storage">
<allow send_interface="org.freedesktop.Hal.Device.Volume" />
<allow send_interface="org.freedesktop.Hal.Device.Volume.Crypto" />
</policy>
And my /etc/dbus-1/system.d/hal.conf configuration file has the following lines:
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- This configuration file specifies the required security policies
for the HAL to work. -->
<!-- Only root or user hal can own the HAL service -->
<policy user="hal">
<allow own="org.freedesktop.Hal"/>
</policy>
<policy user="root">
<allow own="org.freedesktop.Hal"/>
</policy>
<!-- Allow anyone to invoke methods on the Manager and Device interfaces -->
<policy context="default">
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.DBus.Introspectable"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.DBus.Properties" />
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Manager"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.CPUFreq"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.DockStation"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.KillSwitch"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.KeyboardBacklight"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Leds"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.LightSensor"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Storage"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Storage.Removable"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Volume"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.WakeOnLan"/>
</policy>
</busconfig>
How may I configure the hal.conf file? I don't have any idea
Thanks a lot!
Offline
sorry, forget it. I run the scrip as root and root is member of storage group.
Offline
Any news? Thanks!
Offline
What? There was still a problem? Your last post made me think you figured it out.
Offline
Oh sorry. I didn't explain well. I did these changes in the hald.conf file, but it still withour work. I received the same error:
DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.22" (uid=0 pid=2569 comm="python hal-automount.py ") interface="(unset)" member="GetAllProperties" error name="(unset)" requested_reply=0 destination=":1.0" (uid=0 pid=1759 comm="/usr/sbin/hald "))
Offline
Hello Watashi!
Offline
I have already allow theses:
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- This configuration file specifies the required security policies
for the HAL to work. -->
<!-- Only root or user hal can own the HAL service -->
<policy user="hal">
<allow own="org.freedesktop.Hal"/>
</policy>
<policy user="root">
<allow own="org.freedesktop.Hal"/>
</policy>
<!-- Allow anyone to invoke methods on the Manager and Device interfaces -->
<policy context="default">
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.DBus.Introspectable"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.DBus.Properties" />
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Manager"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.CPUFreq"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.DockStation"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.KillSwitch"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.KeyboardBacklight"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Leds"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.LightSensor"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Storage"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Storage.Removable"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Volume"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.WakeOnLan"/>
</policy>
</busconfig>
Maybe I need aditional interfaces? I'm not sure
Offline
Ok guys. I fixed it finally. I allow every interface in every file.conf ot every directory. And finally it work good. I haven't got a exact idea of how I should to set up theses files, but finally work. Thanks for each advise. I hope I could help you in something in the future.
Offline
Pages: 1