Ir a contenido
Página 1 de 2312345»sig.Última »

Howto to intercommunicate processes in different(remote) machines through DBus


Introduction

In this post I’m going to try to connect two processes in different machines through DBus. The method is a little bit complex, so be patient if you try.
Also is to advert that this has been the result of 3 days of tests (reference1). So maybe this method may be improved with time and use reference2.

Tools (The actors)

  • dbus
  • gabriel
    • socat
    • libssh
  • SSH
  • your apps

Debian official packages are dbus libssh-2 socat
gabriel is not part of Debian yet (but I’ve build one for myself)

Knowledge (Actors curriculum)

In this section I will describe the basics about the tools we are going to use.

DBus. Extracted from DBus page:

D-Bus is a message bus system, a simple way for applications to talk to one another. In addition to interprocess communication, D-Bus helps coordinate process lifecycle; it makes it simple and reliable to code a “single instance” application or daemon, and to launch applications and daemons on demand when their services are needed.

D-Bus supplies both a system daemon (for events such as “new hardware device added” or “printer queue changed”) and a per-user-login-session daemon (for general IPC needs among user applications). Also, the message bus is built on top of a general one-to-one message passing framework, which can be used by any two apps to communicate directly (without going through the message bus daemon). Currently the communicating applications are on one computer, or through unencrypted TCP/IP suitable for use behind a firewall with shared NFS home directories.

Gabriel is a simple utility to enable D-Bus clients to connect to a D-Bus daemon running on a remote machine, through SSH.
This is the main piece of this puzzle. If you are interested in understanding how it works you should take a look at socat and libssh. As I’ve had to take a look at code, and make some modifications, you should read it as a punishment.

Extracted from socat man page:

socat - Multipurpose relay (SOcket CAT)
socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them. Because the streams can be constructed from a large set of different types of data sinks and sources (see address types), and because lots of address options may be applied to the streams, socat can be used for many different purposes. It might be one of the tools that one ‘has already needed´.

Libssh. Extracted from libssh page:

The SSH library was designed to be used by programmers needing a working SSH implementation by the mean of a library. The complete control of the client is made by the programmer. With libssh, you can remotely execute programs, transfer files, use a secure and transparent tunnel for your remote programs. With its Secure FTP implementation, you can play with remote files easily, without third-party programs others than libcrypto (from openssl).

You should know about SSH and about your application.

Architecture

Local host will run gabriel and your application.
Remove host will need a running SSH server, a running dbus server and will need socat installed and ready to use.
We need to run gabriel, that will act as a server that will connect our host to the remote host through SSH. After that gabriel will use this SSH connection to intercommunicate our local application with remote DBus applications by using socat.

Remote DBus communication

Remote DBus communication

Howto (Main action)

At the moment I’ve only achieved to connect a process using session-bus, I’m still testing until I get connection through system-bus which was my initial purpose.
After reading next information, you will be able to connect using session bus and system bus.

As I commented somewhere else, I’ve made some modifications on gabriel code. I needed some common parameters as SSH port (my virtualbox testing environment ), better help explanations or add a verbose output.
Gabriel establish a connection with the remote SSH and by socat commands it communicates with the remote DBus “environment”. You should administrate SSH parameters and Dbus parameters to gabriel.

user@machine:~/svn/gabriel/gabriel$ src/gabriel –help
Usage:
gabriel [OPTION...] - Gabriel
Help Options:
-?, –help Show help options
Application Options:
-h, –host=HOSTNAME Hostname or IP of the remote host
-p, –port-ssh=PORT-SSH SSH port on the remote host
-u, –username=USERNAME SSH username on the remote host
-w, –password=PASSWORD SSH password on the remote host
-m, –method=DBUS_TRANSPORT_METHOD The D-Bus transport method to use (TCP, UNIX, abstract-UNIX)
-b, –bind=HOSTNAME The bind-address to listen for D-Bus client connections on
-d, –bus-address=BUS_ADDRESS The DBus session bus address of the remote D-Bus daemon
-t, –port-tcp=PORT-TCP The TCP port to listen for DBus client connections on
-v, –verbose=VERBOSE Set verbosity level (3, 2, 1, 0, -1)=(packet,protocol,functions,important,none)

We have to put special attention to -d, –bus-address=BUS_ADDRESS because this info must be gotten from the REMOTE machine.
That address is the one used by processes to communicate through DBUS. It’s something “internal” and automatically done when you use DBus API/library. I’m going to show you where to get it.

DBUS_SESSION_BUS_ADDRESS, DBUS_SYSTEM_BUS_ADDRESS, DBUS_SYSTEM_BUS_DEFAULT_ADDRESS

Again, this info should be gotten from REMOTE machine.
At the moment I don’t know any nice command where to get this info.
We have two main options of DBus buses. System and Session (more info in DBus page).
If you need SESSION bus address, you can choose what it better fits you:

  • You can can get it from process environment
  • You can stole it from any other process suspicious from being involved in DBus activities…
  • You can create your own dbus-daemon (which, actually, I don’t know if it uses it’s own BUS_ADDRESS)

If you need SYSTEM bus address, you can choose what it better fits you:

  • You can can get it from process environment. If it’s not defined, take a look at /etc/dbus-1/system.conf where you should locate a string like <listen>unix:path=/var/run/dbus/system_bus_socket</listen>
  • You can stole it from any other process suspicious from being involved in DBus activities…

Examples:

// C++ code
#include <stdio.h>
#include <stdlib.h>
char * env;
// env = getenv (”DBUS_SESSION_BUS_ADDRESS”);
env = getenv (”DBUS_SYSTEM_BUS_ADDRESS”);
if (env!=NULL){
cout << env << endl;
}

user@REMOTE-machine:~ $ grep -z BUS_ADDRESS /proc/2047/environ
HALD_RUNNER_DBUS_ADDRESS=unix:abstract=/var/run/hald/dbus-bonbZtoykd,guid=8b5aff565de0dc7c467fef414832dd98

This command gives you a dbus-daemon in your session with the one you can contact.

user@REMOTE-machine:~ $ dbus-daemon –session –print-address
unix:abstract=/tmp/dbus-j2npbTXDwD,guid=d69f66d43e354de5733e4a1a48335bd6

user@REMOTE-machine:~ $ grep unix /etc/dbus-1/system.conf
<listen>unix:path=/var/run/dbus/system_bus_socket</listen>

Howto (Main action): Back to local host

Those ugly unix:stri:ngs/asdkaj/numbers we have seen is what we need for -d, –bus-address=BUS_ADDRESS.
See a session example:

user@machine:~/svn/gabriel/gabriel$ src/gabriel -h localhost -p 2222 -d unix:abstract=/tmp/dbus-j2npbTXDwD,guid=d69f66d43e354de5733e4a1a48335bd6
Listening to D-Bus clients on: “unix:abstract=/tmp/gabriel”
bla ble blu bla

See a system example:

user@machine:~/svn/gabriel/gabriel$ src/gabriel -h localhost -p 2222 -d unix:path=/var/run/dbus/system_bus_socket
Listening to D-Bus clients on: “unix:abstract=/tmp/gabriel”
bla ble blu bla

The moment we have or gabriel server running we (may have nothing) need to set DBUS_XXX_BUS_ADDRESS. Many apps would use, or have, this environment variable to connect to a DBus instance and intercommunicate with other process.
This is is easy, DBUS_XXX_BUS_ADDRESS should be the address gabriel shows few instants after being launched.
When we have defined this environment variable (in command line) we can execute our app, and it will happily communicate with the remote DBus world.
Example:

user@machine:~/svn/dbusmm/trunk/examples/glib$ export DBUS_SESSION_BUS_ADDRESS=”unix:abstract=/tmp/gabriel”
user@machine:~/svn/dbusmm/trunk/examples/glib$ ./dbus-browser

dbus-browser is a program that uses a session bus.

Curiosity: DBus protocol messages interchanged

Modifying a couple of lines in gabriel can let you see DBus raw protocol messages. It’s a didactic info.
If you enable verbose code at least at level 2, you will get raw DBus protocol messages.

My modifications and hacks

Code will be publish under GLKM project page.

Links and references
Etiquetas: , , , , , , , , , , , , ,

¡Que no Bajamos!


“Le mètre cube de sperme” by Philippe Meste


SPERMCUBE, it’s… collecting 1 cubic meter of sperm preserved frozen in a transparent cube. A collective artwork, international, open to all, universal. PARTICIPATE!

If you think you’re prepared, click to read more… (Continuar leyendo…)

Etiquetas: , , , , , , ,

Google daily traffic patterns


Weeks ago I watch a talk, starring Robert Love and Google and Open Source.
What it was funny was the moment he showed some Google daily traffic patterns. He, as part of the audience, suggested the siesta was maybe responsible of that pattern in Spain.
Well, Spain is now more cosmopolitan and very few people take siesta daily. Although many people take more than one hour at midday meal. I think this is a most real explanation.

Robert Love - Google and Open Source

Robert Love - Google and Open Source

It should have been better comparing U.S.A. and Europe. Don’t you think?

Etiquetas: , , , , ,

Análisis de viajes destinia.com


Esta entrada está patrocinada a través de zync.es.

Destinia.com es una página más para buscar viajes: pack de viaje, hoteles, vuelos, coches. Más o menos lo que se espera hoy en día de una página de viajes. Aunque el nombre mola, destinia, des-tinia… des-ti-nia :D.
Nos vamos a centrar en analizar su sección de viajes.

El buscador de viajes es muy sencillo con lo que puede ser usado, como se ha visto toda la vida en las cajas de muchos juguetes, por personas de 0 a 99+ años.
Lo cojon**** interesante es que su sencillez, según lo vas usando, te va encandilando hasta el punto de parecerte genial. Con tan sólo elegir una opción tienes ante ti, !zas¡, una visión general de viajes que pueden ser de tu interés. Luego está claro puedes ir pormenorizando en los detalles.
Lo malo del tipo de presentación que tiene la página es que, como pasa en los folletos de las agencias de viajes, siempre te destacan el precio mínimo y luego cuando vas a ver por cuánto puede salir el viaje al final se te queda una cara imbécil que “pa que contate”.

Entre los tipos de viajes entre los que se puede escoger me han parecido destacables los siguientes planes: bucear, las típicas escapadas, un especial familias, esquí, las habitaciones con encanto, las ofertas, las ofertas de último minuto, también hay rebajas de invierno, singles (solteros en español).

Marketín

Como con el nombre de la web, en marketín son los número uno. Vaya vídeo promoción sutil que se han marcado…

[youtube.com] “Triki Triki Triki” anuncio Destinia.com

Triki, triki, triiiiiki, triiiki, triki, Mon Amour, triki, triki, triki, triiiiii es el estribillo de Velvet Mornings de Demis Roussos (que sólo era uno)

Resumiendo

Una página para empezar a buscar cuando no tienes claro un destino.
Cómo siempre digo, ahora ya sólo queda que me paguen un viaje para probar plenamente el servicio….

Referencias y enlaces
Etiquetas: , , , , , , , ,

60 años


Lo siento por algunos, pero no puedo usar más palabras.

foto tradicional de la cantera de estudiantes 2008 conmemorando el 60 aniversario

foto tradicional de la cantera de estudiantes 2008 conmemorando el 60 aniversario


Enlace al vídeo conmemorativo 60 aniversario del club de baloncesto Estudiantes.

Durante el descanso del partido del pasado fin de semana, 3 de febrero, se visionó en las pantallas, por sorpresa, para algunos como yo, este vídeo. Una sonora ovación tuvo lugar a su finalización.

Yo soy de los que se quiere comprar el libro conmemorativo del 60 aniversario para leerlo y conservarlo junto alguna de mis “intifadas”, del gigantes de la copa del rey y de un ejemplar de los que se repartían en el palacio en el que sale en portada mijailov….

clubestudiantes.com

Etiquetas: , , , , ,

Perdidos. Lost. Descargas de capítulos de la 4ª Temporada


Otro año más, la serie continua.
Esta serie que tiene algo. Uno no sabe qué, pero lo tiene. Te engancha. A pesar de que a mí cada vez me cuesta más engancharme a la puta mierda de la televisión que se emite en las horas que a mi me apetecería ver. Pese a ello, Perdidos puede conmigo y me hace olvidar la basura que me hace pensar tan mal de los que ven la tele y los que la programan.

Poco a poco iremos desvelando, mediante cada capítulo, las sorpresas que nos tienen reservadas los cabrones que llevan a cabo esta serie. Porque son unos cabrones :D.

Gracias a los avisos de lostzilla puedo ir avanzando los nombres de los primeros capítulos de esta cuarta temporada. Gracia a ellos disponemos de subtítulos.

~ Cuarta Temporada/Fourth Season ~

Aquí los enlaces a los vídeos. Con las voces en inglés. Podéis descargar los vídeos ya con vuestro programa P2P favorito.

caricatura Jack

caricatura Jack

caricatura Lock

caricatura Lock

~ Cuarta Temporada. Los subtítulos/The subtitles. ~

Aquí los enlaces a los subtítulos en inglés y en español. Porque para gustos se hicieron los colores.

caricatura Hurley

caricatura Hurley

caricatura Kate

caricatura Kate

Referencias y enlaces:
Etiquetas: , , , , , , , , , , , , , , , , ,

El Hierro empieza su conversión en isla con 100% energías renovables


Tras cerca de una década en despachos y estudios de ingeniería, el proyecto para transformar la isla canaria de El Hierro en un lugar autosuficiente que pueda abastecerse de energía 100% renovable se ha puesto por fin en marcha. La inminente adjudicación del parque eólico marca el comienzo de un conjunto de obras valoradas en 54 millones de euros que deben garantizar el suministro de electricidad ‘limpia’ a sus 10.600 habitantes para el año 2010.

[...]

La obra principal consta de dos elementos: un pequeño parque eólico de 10 megavatios (MW) de potencia y dos grandes depósitos de agua construidos a diferentes alturas (con una diferencia de 700 metros de desnivel). La pega de los aerogeneradores es que puede que no haya viento cuando se requiera la electricidad o, al contrario, que las palas se muevan justamente cuando menos se necesite. La idea consiste en aprovechar la energía eólica que no se vaya a consumir para bombear agua al tanque superior desde el inferior. De esta forma, se puede disponer de electricidad de forma inmediata y continuada con sólo abrir la salida del depósito superior para crear una corriente hacia abajo que sea aprovechada por varias turbinas.

“Se trata de almacenar agua en altura para dejarla caer cuando no haya viento y se necesite electricidad”, simplifica Piernavieja, que indica que en caso de necesidad los 500.000 m3 de capacidad del tanque superior (ubicado dentro de un cráter impermeabilizado) permitirían garantizar el suministro de luz de toda la isla durante una semana. “Explicarlo es fácil, pero crear un sistema aislado como este todo renovable no resulta tan sencillo, pues no existe precedente”.

El Hierro será una isla con 100% energías renovables

El Hierro será una isla con 100% energías renovables

La idea de que esta isla de 278 km2 hoy en día completamente dependiente del petróleo consiguiese autoabastecerse sólo con energías ‘limpias’ surgió allá por el año 1997 dentro de un plan de desarrollo sostenible elaborado por el Cabildo. Como detalla este técnico del ITC, luego el proyecto fue tomando cuerpo al entrar en un programa europeo para promover el uso de 100% de energías renovables entre distintas islas del continente. Este es el caso de Samso, una pequeña ínsula danesa de cerca de 4.000 habitantes que ya consiguió este objetivo. “Lo nuestro es más complicado, porque Samso no deja de estar conectada al continente con un cable por si le falla el suministro”, recalca el canario. El Hierro estará aislada.

[...]

Claro que esto no bastaría para poder prescindir por completo de los combustibles fósiles y que los petroleros que ahora abastecen a las islas canarias dejasen de llegar un día a El Hierro. Para ello, se necesitaría suplir también el carburante con el que se rellena el depósito de los coches, una cuestión que el ITC trata de resolver a partir de distintas alternativas que estudia en estos momentos: hidrógeno, biogás, biocarburantes…

“Esperamos tener listo para mayo un coche de hidrógeno”, adelanta el técnico canario, que asegura que reciben muchas visitas de otras islas del mundo para conocer el proyecto. “Somos un laboratorio energético”.

Referencias y enlaces
Etiquetas: , , , , , , , , , , ,

Página 1 de 2312345»sig.Última »