Linux 以非根用户身份访问Bluez库

Linux 以非根用户身份访问Bluez库,linux,bluetooth,bluetooth-lowenergy,bluez,Linux,Bluetooth,Bluetooth Lowenergy,Bluez,我使用bluez4库API开发了BLE扫描应用程序。我可以使用root用户运行应用程序,但由于安全原因,我需要使用非root用户运行应用程序 使用setcap软件包,我可以作为非root用户进行“hcitool lescan”操作 =>sudo setcap'cap\u net\u raw,cap\u net\u admin+eip'哪个hcitool =>getcap$ getcap哪个hcitool 但这些更改在以非root用户身份运行我的ble扫描应用程序时不起作用,它被API“hci_s

我使用bluez4库API开发了BLE扫描应用程序。我可以使用root用户运行应用程序,但由于安全原因,我需要使用非root用户运行应用程序

使用setcap软件包,我可以作为非root用户进行“hcitool lescan”操作

=>sudo setcap'cap\u net\u raw,cap\u net\u admin+eip'
哪个hcitool
=>getcap$ getcap
哪个hcitool

但这些更改在以非root用户身份运行我的ble扫描应用程序时不起作用,它被API“hci_send_req”卡住,该API返回错误“未能设置扫描参数数据。不允许操作”

请找个人来帮我

问候
尼希思可能晚了两年,但我也犯了同样的错误,答案很简单。 您只需要对要执行的二进制文件执行setcap操作,这样它就可以访问蓝牙操作。命令如下:

sudo setcap 'cap_net_raw,cap_net_admin+eip' /absolute/path/to/your/executable/file
希望有帮助