Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't connect to system bus #3

Open
jollm opened this issue Jan 16, 2012 · 7 comments
Open

can't connect to system bus #3

jollm opened this issue Jan 16, 2012 · 7 comments

Comments

@jollm
Copy link

jollm commented Jan 16, 2012

Debian squeeze, dbus 1.2.24-4

Example:

(dbus:with-open-bus (bus (dbus:system-server-addresses))
(dbus:with-introspected-object (wicd-wireless bus "/org/wicd/daemon/wireless" "org.wicd.daemon")))

Error: No more mechanisms to try.

Seems to be related to cookie sha1 auth

Python and scheme bindings via libdbus are working

Working example in scheme:

(define wicd-wireless-context (dbus:make-context
bus: dbus:system-bus
service: 'org.wicd.daemon
interface: 'org.wicd.daemon.wireless
path: '/org/wicd/daemon/wireless))
(dbus:call wicd-wireless-context "GetWirelessProperty" 0 "bssid")
("88:43:E1:13:FC:B2")

I don't yet know enough to attempt a fix unfortunately.

@lucashpandolfo
Copy link
Contributor

That's the expected result (i think).

Look at 'system-server-addresses' function. It retrieves DBUS address from the environment variables.
If env variables are not defined then you won't be able to connect to the bus.

The 'standard' way to retrieve the bus address is to read the file ".dbus/session-bus/[machine-id]-[display]".

try

(defun get-machine-id ()
  (with-open-file (machine-id-file "/var/lib/dbus/machine-id" 
                   :direction :input)
    (read-line machine-id-file)))

(defun get-display-number ()
  (let ((display (getenv "DISPLAY")))
    (if (null display)
    (error "DISPLAY variable not set.")
    (handler-case
        (parse-integer (subseq display (1+ (position #\: display)) (position #\. display)))
      (parse-error () (error "Can not parse DISPLAY variable."))))))

(defun update-environment-variables ()
  "Sets the 'DBUS_SESSION_BUS_ADDRESS' environment variable (if not present)."
  (when (not (getenv "DBUS_SESSION_BUS_ADDRESS"))
    (let (machine-id display)
      (setq machine-id (get-machine-id))
      (setq display (format nil "~d" (get-display-number)))
      (iolib.syscalls:setenv 
       "DBUS_SESSION_BUS_ADDRESS" 
       (get-session-bus-address-from-file 
    (concatenate 'string "~/.dbus/session-bus/" machine-id "-" display))
       t))))

That is how i got it working (take a look at my fork, i also have EXTERNAL auth method)

@jollm
Copy link
Author

jollm commented Feb 2, 2012

I appreciate the thorough response. The system bus connection is obtained through /var/run/dbus/system_bus_socket by default. This seems the correct approach, but it doesn't work. I will try your fork.

@jollm
Copy link
Author

jollm commented Feb 2, 2012

That does in fact work! Is it the external auth that makes the difference? I will need to investigate further to eliminate the mystery.

@jollm
Copy link
Author

jollm commented Feb 2, 2012

After playing around some more, I discovered the proper syntax for variant type signatures:

(with-open-bus (bus (system-server-addresses))
  (with-introspected-object (wicd-wireless bus "/org/wicd/daemon/wireless" "org.wicd.daemon")
    (wicd-wireless "org.wicd.daemon.wireless" "GetWirelessProperty" '((:int32) 0) '((:string) "bssid"))))

This is cumbersome for auto-generating functions to the interface. Is there a mechanism to introspecting further into a variant type, or is the only way to guess from the type of arguments passed in?

@jollm
Copy link
Author

jollm commented Feb 7, 2012

The external SASL authentication method fixes this issue. I would suggest pulling this in from lucashpandolfo.

@futuro
Copy link

futuro commented Jul 21, 2012

I can verify this issue as well. The most basic replication method is to run (notify-example) from examples/notify.lisp.

@death
Copy link
Owner

death commented Jul 22, 2012

Hello (after a long vacation :)

  1. Joseph tried to use the system bus, but Lucas's code deals with the session bus.
  2. I gather by Joseph's comment that the system bus code should work given support for EXTERNAL auth mechanism.
  3. If Lucas could extract a set of patches I will review and apply them.
  4. Perhaps Joseph could further explain his issue with the variant type signatures in another issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants