Missing CAP_NET_ADMIN permission
-
Yes there is another way: modify dbus config to allow your user to use the permission.
To do this, edit file
/etc/dbus-1/system.d/bluetooth.conf
and paste
the following:<policy user="yourUserName"> <allow own="org.bluez"/> <allow send_destination="org.bluez"/> <allow send_interface="org.bluez.Agent1"/> <allow send_interface="org.bluez.MediaEndpoint1"/> <allow send_interface="org.bluez.MediaPlayer1"/> <allow send_interface="org.bluez.Profile1"/> <allow send_interface="org.bluez.GattCharacteristic1"/> <allow send_interface="org.bluez.GattDescriptor1"/> <allow send_interface="org.bluez.LEAdvertisement1"/> <allow send_interface="org.freedesktop.DBus.ObjectManager"/> <allow send_interface="org.freedesktop.DBus.Properties"/> </policy>
Of course, replace
yourUserName
with actual name of your unix user. You may need to reboot your system afterwards. This solution is permanent (you don't need to rerun it like you do withsetcap
).BTW. with
sudo setcap
it should work, too, but you need to set it on your executable, not on some library. -
@Etesravan said in Missing CAP_NET_ADMIN permission:
@sierdzio I'm using Ubuntu on Oracle VM ViritualBox and I'm very new to using it. Can't seem to find any /etc/ folder or bluetooth.conf file.
etc
is in root folder, and you need admin permissions - maybe your file browser does not have root access.The
.conf
file might not be there at all, in such case you can create it. Here's a command do to it from terminal if you like:sudo nano /etc/dbus-1/system.d/bluetooth.conf # now copy-paste the file contents Click Ctrl+X Click y Click Enter # Now verify that file is there: cat /etc/dbus-1/system.d/bluetooth.conf # And reboot sudo reboot
-
so when I write "sudo nano /etc/dbus-1/system.d/bluetooth.conf" it gives me the file with something already in it.
It looks like what you posted above only with the user as root.
Do I copy the lines you wrote above and replace the root-lines with them or should I add them so I have two separate ones (one for root and one for my user)?
Or would it be enough to just change "root" to my username in the code that is already there?
-
@Etesravan said in Missing CAP_NET_ADMIN permission:
so when I write "sudo nano /etc/dbus-1/system.d/bluetooth.conf" it gives me the file with something already in it.
It looks like what you posted above only with the user as root.
Hm, that should work.
Do I copy the lines you wrote above and replace the root-lines with them or should I add them so I have two separate ones (one for root and one for my user)?
Add to have 2 separate ones. This code is "punching holes" in default config (which denies all BT access).
Or would it be enough to just change "root" to my username in the code that is already there?
You can try, but better add a separate entry.
Since you write it's a VM - are you sure Bluetooth works at all? Can you connect to any device from the system itself?
-
@sierdzio I have managed to connect a USB bluetooth dongle that activates the bluetooth in Ubuntu. It's searching for devices and has managed to find my phone and other unknown devices.
I'm still getting the same error after doing what you recommended above. Any other ideas?
-
@Etesravan said in Missing CAP_NET_ADMIN permission:
@sierdzio I have managed to connect a USB bluetooth dongle that activates the bluetooth in Ubuntu. It's searching for devices and has managed to find my phone and other unknown devices.
I'm still getting the same error after doing what you recommended above. Any other ideas?
Which Qt version are you using?
I think there was some bug before 5.12.x where this error was showing, the conf was being ignored.
-
@Etesravan said in Missing CAP_NET_ADMIN permission:
Qt Creator 4.10.2 based on Qt 5.13.2
This only says which Qt version was used to build QtCreator.
It is not necessarily the version you're using.
Check your Kit if you want to know which Qt version you're using. -
@Etesravan "Tools/Options.../Kits" ...
-
Kits:
Auto-detected:
Desktop Qt 5.13.2 GCC 64bit (default)
Qt 5.13.2 WebAssemblyQt Versions
Auto-detected:
Qt 5.13.2 for Android ARM64-v8a
Qt 5.13.2 for Android ARMv7
Qt 5.13.2 for Android x86
Qt 5.13.2 for Android x86_64
Qt 5.13.2 GCC 64bit
Qt 5.13.2 WebAssemblyManual:
Qt 5.9.5 in PATH (qt5) -
@Etesravan said in Missing CAP_NET_ADMIN permission:
Qt 5.9.5 in PATH (qt5)
Make sure you don't use this one when trying to use Bluetooth and you should be fine.
-
@sierdzio said in Missing CAP_NET_ADMIN permission:
Make sure you don't use this one when trying to use Bluetooth and you should be fine.
How do I know I'm not using it?
Sorry about stupid questions, I'm new to Qt and C++ and I'm forced to use it for a project.
-
If you are compiling your project in Qt Creator, click on the computer icon at the bottom of left-hand side panel (just above the green Run button). This will unfold the build setup information.
-
No ideas, then, sorry
-
@Etesravan ,
I'm working on a project using QT API on ubuntu 20.04, i' got this error but i can still scan & find devices. -