:: [DNG] New release of simple-netaid …
Startseite
Nachricht löschen
Nachricht beantworten
Autor: aitor
Datum:  
To: dng
Betreff: [DNG] New release of simple-netaid relaying on OpenWRT system bus
Hi,

Recently I packaged a new version of simple-netaid based on the U-Bus framework (OpenWRT microversion of D-Bus),
an inter-process communication that allows users to access and use services from the same place.

The main piece of U-Bus is the ubusd daemon. It provides an interface for other daemons to register themselves
as well as sending messages. Therefore, ubusd must be run in first place before the daemon of simple-netaid can
be started.

Often, U-Bus makes use of a collection of utilities widely used in the OpenWRT project, and taken from U-Box
(micro Box) such as polling, event handling, socket helper functions, and so on.

The ubus command line tool allows to interact with the ubusd server, giving us a very powerful tool for accessing
services both locally and remotely.

From the shell, we can list what services are available on the bus using the 'ubus list' command. In the live images
of gnuinos chimaera, we will get:

# ubus list

ering.netaid

To find out what procedures a certain service provides, we add '-v' in addition to the namespace path:

# ubus list -v ering.netaid

'ering.netaid' @068347bd

    "interface":{"id":"Integer","ifname":"String","flag":"Integer"}

    "ifupdown":{"id":"Integer","ifname":"String","flag":"Integer"}

    "ipaddr_flush":{"id":"Integer","ifname":"String","flag":"Integer"}

    "disconnect":{"id":"Integer","ifname":"String"}

    "wired_connection":{"id":"Integer","ifname":"String"}

    "wireless_connection":{"id":"Integer","ifname":"String","essid":"String","passwd":"String"}

    "install_and_connect":{"id":"Integer","ifname":"String","essid":"String","passwd":"String","filename":"String"}

    "connect_to_saved":{"id":"Integer","ifname":"String","filename":"String"}

    "uninstall":{"id":"Integer","filename":"String"}

    "scan_active_wifis":{"id":"Integer","ifname":"String"}

To call a concrete procedure, say 'wired_connection', within the given 'ering.snetaid' namespace:

$ ubus call ering.netaid wired_connection '{ "ifname": "eth0" }'

{

    "Server reply - Request is being proceeded: ": "blahblahblah"

}

Note that i'm running the above command as a regular user without granted permissions, because the 'netaid'
group is already assigned to my current user account.

The ACLs are defined in /usr/share/acl.c/netaid-server.json:

{

  "group": "netaid",

  "access": {

    "ering.netaid": {

      "methods": [ "interface" , "ifupdown" , "ipaddr_flush" ,    .......   , "scan_active_wifis" ]

    }

  }

}

This configuration is customizable. For instance, you can replace "group": "netaid" with "user": "devuanita",
or use wildcards (*) instead.

On the other hand, in the given example i'm ignoring the ID when passing the arguments to the procedure. This
integer is for internal use so far.

Another example, to beep down the wired interface:


$ ubus call ering.netaid interface '{ "ifname": "eth0" , "flag": "0" }'

Connecting to snetaid via the ubus command line interface, we'll be able to rewrite Edward Bartolo's original
backend, that may turn into a very simple bash script relaying on the 'libnetaid' library.

Cheers,

Aitor.