Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Missing CAP_NET_ADMIN permission
Forum Updated to NodeBB v4.3 + New Features

Missing CAP_NET_ADMIN permission

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 4 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Etesravan
    wrote on last edited by
    #1

    When I'm trying to run a project I get this error:

    "qt.bluetooth.bluez: Missing CAP_NET_ADMIN permission. Cannot determine whether a found address is of random or public type."

    Any simple solution for this?

    I have tried this from somewhere else:
    "sudo setcap 'cap_net_raw,cap_net_admin+eip' /usr/lib/..."
    But this just gave a new error and had to rebuild project.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by sierdzio
      #2

      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 with setcap).

      BTW. with sudo setcap it should work, too, but you need to set it on your executable, not on some library.

      (Z(:^

      1 Reply Last reply
      6
      • E Offline
        E Offline
        Etesravan
        wrote on last edited by
        #3

        @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.

        sierdzioS 1 Reply Last reply
        0
        • E Etesravan

          @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.

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @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
          

          (Z(:^

          1 Reply Last reply
          4
          • E Offline
            E Offline
            Etesravan
            wrote on last edited by
            #5

            @sierdzio

            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?

            sierdzioS 1 Reply Last reply
            0
            • E Etesravan

              @sierdzio

              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?

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @Etesravan said in Missing CAP_NET_ADMIN permission:

              @sierdzio

              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?

              (Z(:^

              1 Reply Last reply
              1
              • E Offline
                E Offline
                Etesravan
                wrote on last edited by
                #7

                @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?

                sierdzioS 1 Reply Last reply
                0
                • E Etesravan

                  @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?

                  sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  @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.

                  (Z(:^

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    Etesravan
                    wrote on last edited by
                    #9

                    @sierdzio I'm using Qt Creator 4.10.2 based on Qt 5.13.2.

                    jsulmJ 1 Reply Last reply
                    0
                    • E Etesravan

                      @sierdzio I'm using Qt Creator 4.10.2 based on Qt 5.13.2.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @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.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      E 1 Reply Last reply
                      3
                      • jsulmJ jsulm

                        @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.

                        E Offline
                        E Offline
                        Etesravan
                        wrote on last edited by
                        #11

                        @jsulm said in Missing CAP_NET_ADMIN permission:

                        Check your Kit if you want to know which Qt version you're using.

                        Where/how do I check this my kit?

                        jsulmJ 1 Reply Last reply
                        0
                        • E Etesravan

                          @jsulm said in Missing CAP_NET_ADMIN permission:

                          Check your Kit if you want to know which Qt version you're using.

                          Where/how do I check this my kit?

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Etesravan "Tools/Options.../Kits" ...

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1
                          • E Offline
                            E Offline
                            Etesravan
                            wrote on last edited by
                            #13

                            @sierdzio @jsulm ¨

                            Kits:
                            Auto-detected:
                            Desktop Qt 5.13.2 GCC 64bit (default)
                            Qt 5.13.2 WebAssembly

                            Qt 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 WebAssembly

                            Manual:
                            Qt 5.9.5 in PATH (qt5)

                            sierdzioS 1 Reply Last reply
                            0
                            • E Etesravan

                              @sierdzio @jsulm ¨

                              Kits:
                              Auto-detected:
                              Desktop Qt 5.13.2 GCC 64bit (default)
                              Qt 5.13.2 WebAssembly

                              Qt 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 WebAssembly

                              Manual:
                              Qt 5.9.5 in PATH (qt5)

                              sierdzioS Offline
                              sierdzioS Offline
                              sierdzio
                              Moderators
                              wrote on last edited by
                              #14

                              @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.

                              (Z(:^

                              E 1 Reply Last reply
                              2
                              • sierdzioS sierdzio

                                @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.

                                E Offline
                                E Offline
                                Etesravan
                                wrote on last edited by
                                #15

                                @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.

                                1 Reply Last reply
                                0
                                • sierdzioS Offline
                                  sierdzioS Offline
                                  sierdzio
                                  Moderators
                                  wrote on last edited by
                                  #16

                                  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.

                                  (Z(:^

                                  E 1 Reply Last reply
                                  2
                                  • sierdzioS sierdzio

                                    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.

                                    E Offline
                                    E Offline
                                    Etesravan
                                    wrote on last edited by
                                    #17

                                    @sierdzio It says I'm using Desktop Qt 5.13.2 GCC 64bit. Still not working.

                                    1 Reply Last reply
                                    0
                                    • sierdzioS Offline
                                      sierdzioS Offline
                                      sierdzio
                                      Moderators
                                      wrote on last edited by
                                      #18

                                      No ideas, then, sorry

                                      (Z(:^

                                      1 Reply Last reply
                                      1
                                      • E Offline
                                        E Offline
                                        Etesravan
                                        wrote on last edited by
                                        #19

                                        @sierdzio Okay, thank you very much for trying! Really appreciate you taking the time to answer.

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          Salah_dex
                                          wrote on last edited by
                                          #20

                                          @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.

                                          1 Reply Last reply
                                          0
                                          • A Anonymous_Banned275 referenced this topic on

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved