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. Using QProcess Sending command "ifconfig eth0 up" in Android 7.1 causes error
QtWS25 Last Chance

Using QProcess Sending command "ifconfig eth0 up" in Android 7.1 causes error

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.4k Views
  • 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.
  • V Offline
    V Offline
    victor wang
    wrote on last edited by victor wang
    #1

    Dear All,
    I'm using QT5.9 on my Windows to build the app for my other arm-based device which is Android 7.1.
    Please refer to the below code. While I sending the command "ifconfig eht0 down",

    Process::executeProcessSync(QString("sh"),QStringList()<<"-c"<<"ifconfig eth0 down",&wifi_client_scipt_M);
    

    It would give the error like below.

    ifconfig: ioctl 8914: Operation not permitted
    

    However, if I only send the command ifconfig, I success.
    Also, I tried to execute the command directly from the terminal, It success.

    Is the right of the QT not enough to use the command ifconfig eth0 down ?
    Or any other possibility that could cause this issue?
    How can I solve it?

    Thanks in Advanced!

    raven-worxR 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      As what user are you running ipconfig on your Android device ?
      As what user is your Qt application run ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply
      0
      • V victor wang

        Dear All,
        I'm using QT5.9 on my Windows to build the app for my other arm-based device which is Android 7.1.
        Please refer to the below code. While I sending the command "ifconfig eht0 down",

        Process::executeProcessSync(QString("sh"),QStringList()<<"-c"<<"ifconfig eth0 down",&wifi_client_scipt_M);
        

        It would give the error like below.

        ifconfig: ioctl 8914: Operation not permitted
        

        However, if I only send the command ifconfig, I success.
        Also, I tried to execute the command directly from the terminal, It success.

        Is the right of the QT not enough to use the command ifconfig eth0 down ?
        Or any other possibility that could cause this issue?
        How can I solve it?

        Thanks in Advanced!

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @victor-wang said in Using QProcess Sending command "ifconfig eth0 up" in Android 7.1 causes error:

        How can I solve it?

        root your device or use the corresponding native Android API

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        V 1 Reply Last reply
        2
        • SGaistS SGaist

          Hi,

          As what user are you running ipconfig on your Android device ?
          As what user is your Qt application run ?

          V Offline
          V Offline
          victor wang
          wrote on last edited by
          #4

          @SGaist
          Thanks for the reply.
          As what user are you running ipconfig on your Android device ?
          => I used root to run ipconfig
          As what user is your Qt application run ?
          =>Probably with the non-root. For this situation, how can I run my app with root access?

          1 Reply Last reply
          0
          • raven-worxR raven-worx

            @victor-wang said in Using QProcess Sending command "ifconfig eth0 up" in Android 7.1 causes error:

            How can I solve it?

            root your device or use the corresponding native Android API

            V Offline
            V Offline
            victor wang
            wrote on last edited by
            #5

            @raven-worx
            Thanks for the reply.
            My device has already root access. Is there any corresponding native Android API in the QT library?
            If yes which should I use?

            raven-worxR 1 Reply Last reply
            0
            • V victor wang

              @raven-worx
              Thanks for the reply.
              My device has already root access. Is there any corresponding native Android API in the QT library?
              If yes which should I use?

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @victor-wang
              Does your app have the Internet permission set?
              Also note that Android is very vendor specific, meaning that while it works on one device it might not work on another device, because of vendor specific modifications, etc.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              V 1 Reply Last reply
              1
              • raven-worxR raven-worx

                @victor-wang
                Does your app have the Internet permission set?
                Also note that Android is very vendor specific, meaning that while it works on one device it might not work on another device, because of vendor specific modifications, etc.

                V Offline
                V Offline
                victor wang
                wrote on last edited by
                #7

                @raven-worx
                I don't think it has.
                Maybe I have to add something in Android.mk to set the user as a system for my Application?

                raven-worxR 1 Reply Last reply
                0
                • V victor wang

                  @raven-worx
                  I don't think it has.
                  Maybe I have to add something in Android.mk to set the user as a system for my Application?

                  raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  @victor-wang
                  you would need to add the permission your AndroidManisfest.xml, or maybe even not when executing it as root, i can't tell. simply give it a try.

                  Anyway, first try if your command works as root with adb shell:

                  adb shell "su -c 'ifconfig eth0 down'"
                  

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  1

                  • Login

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