Inappropriate ioctl for device

I am trying to run Qark Security Scan on my apk using the Script Step. In the bash script I run a python command:

python ${source_dir}/build/qark/qark/ -s 1 -p ${path_to_apk}/${FILE_NAME} -e 1 -d 10 -b ${ANDROID_HOME}

I get this error:

Traceback (most recent call last):
  File "/bitrise/src/build/qark/qark/", line 1281, in <module>
  File "/bitrise/src/build/qark/qark/", line 462, in nonAutomatedParseArgs
  File "/bitrise/src/build/qark/qark/", line 790, in main
  File "/bitrise/src/build/qark/qark/modules/", line 162, in decompile
    with common.term.cbreak():
  File "/usr/lib/python2.7/", line 17, in __enter__
  File "/bitrise/src/build/qark/qark/lib/blessed/", line 572, in cbreak
    save_mode = termios.tcgetattr(self.keyboard_fd)
termios.error: (25, 'Inappropriate ioctl for device')

I think the hint is in line Inappropriate ioctl for device. When I do set | grep TERM, I get dumb and I think that means the Terminal running the script is very limited. How do I get over this issue?

Edit 1:
I found that the script is waiting for button to be pressed if user wants to cancel.

Decompilation may hang/take too long (usually happens when the source is obfuscated).
At any time,Press C to continue and QARK will attempt to run SCA on whatever was decompiled.

This is why it’s failing. Can it be resolved from bitrise end?

Hi @accolademobile,

The terminal is indeed very limited, so much so that you don’t have interactive input at all :wink: It’s running in non-interactive mode, because during a build you can’t just stop and wait for a user input, that would defeat the purpose of the automation.

From the logs it seems that might cause your issue, that your script might expect interactive input from a user - can that be?

Yes I found the cause. I really don’t want to fork the Qark library. Is there a way to a way around this?

You should ask that from Qark, it depends on the tool. From our side, as this is a non-interactive environment, there’s no way to make it to be one, as there’s no user interaction is possible during the build.

I forked the library and disabled the code that was causing issue. Now I am hit with new issue explained here Python issue: Couldn't find a tree builder with the features you requested

1 Like