PHP talk to NetworkManager via Dbus

I have setup NetworkManager, Dbus, Nginx web server, PHP and a Dbus PHP extension on my debian system.
I am trying to „talk“ to NetworkManager via Dbus from my PHP web application.
It works fine when retrieving information about connections, like in this code:

[php]$dbus = new Dbus( Dbus::BUS_SYSTEM, true);
$proxy = $dbus->createProxy(“org.freedesktop.NetworkManager”, “/org/freedesktop/NetworkManagerSettings”, “org.freedesktop.NetworkManagerSettings”);
$d = $proxy->ListConnections();[/php]

, but when I want to add a new connection:

[php]$d = new Dbus( Dbus::BUS_SYSTEM, true );
$n = $d->createProxy( “org.freedesktop.NetworkManagerSystemSettings”, “/org/freedesktop/NetworkManagerSettings”, “org.freedesktop.NetworkManagerSettings”);
$args = new DBusDict( DBus::STRUCT,
array( ‘connection’ => new DBusDict( DBus::VARIANT,
array( ‘uuid’ => new DBusVariant( “06bd5fb0-45f1-0bb0-7ffb-5f3ed6edd604” ),
‘id’ => new DBusVariant( “PHP Added Network Connection” ),
‘type’ => new DBusVariant( “802-3-ethernet” ),
‘autoconnect’ => new DBusVariant(FALSE)
)
),
‘802-3-ethernet’ => new DBusDict( DBus::VARIANT,
array(‘duplex’ => new DBusVariant( “full” )))),
‘{sa{sv}}’);
$n->AddConnection( $args );[/php]

, I get this error:

Fatal error: Uncaught exception “Exception” with message “DBusObject::_call(): org.freedesktop.NetworkManagerSettings.System.NotPrivileged: Insufficient privileges.”

I have added the www-data user to /etc/dbus-1/system.d/NetworkManager.conf and giving him the same rights as root

, but it does not change anything. I have also added www-data to the root and netdev group, but that did not help either.

Sponsor our Newsletter | Privacy Policy | Terms of Service