PHP通过Dbus与NetworkManager通信

时间:2013-03-19 21:44:19

标签: php debian dbus

我在debian系统上设置了NetworkManager,Dbus,Nginx Web服务器,PHP和Dbus PHP扩展。

我正试图通过我的PHP Web应用程序通过Dbus与NetworkManager“交谈”。 检索有关连接的信息时,它可以正常工作,例如:

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

,但是当我想添加新连接时:

$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 );

,我收到此错误:

致命错误:未捕获的异常“异常”,消息“DBusObject :: _ call():org.freedesktop.NetworkManagerSettings.System.NotPrivileged:权限不足。”

我已将www-data用户添加到/etc/dbus-1/system.d/NetworkManager.conf并赋予他与root相同的权利

<policy user=”www-data”>
<allow own=”org.freedesktop.NetworkManager”/>
<allow own=”org.freedesktop.NetwoekManagerSystemSettings”/>
<allow own=”org.freedesktop.NetworkManagerSettings”/>
<allow own=”org.freedesktop.NetworkManagerSettings.System”/>
<allow send_destinations=”org.freedesktop.NetworkManager”/>
<allow send_destinations=”org.freedesktop.NetworkManagerSystemSettings”/>
<allow send_destinations=”org.freedesktop.NetworkManagerSettings”/>
<allow send_destinations=”org.freedesktop.NetworkManagerSettings.System”/>
<allow send_destinations=”org.freedesktop.NetworkManager”
    send_interface=”org.freedesktop.NetworkManager.PPP”/>
</policy>

,但它没有改变任何东西。我还在root和netdev组中添加了www-data,但这也无济于事。

0 个答案:

没有答案