2

我在我的 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: 权限不足。”<br>

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

<policy user=”www-data”&gt;
<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>

,但它不会改变任何东西。我还将 www-data 添加到 root 和 netdev 组,但这也无济于事。

4

0 回答 0