#8009 Missing execution bit on `ipa-run-tests` within virtualenv
Closed: fixed 4 years ago by abbra. Opened 4 years ago by slev.

During IPA testing I have to run ipa-run-tests within a virtualenv via tox.
Currently this is done as {envpython} -bb {envbindir}/ipa-run-tests ...
But what if I need to run it as a pytest fixture?

Let's try to set the tox command as {envbindir}/ipa-run-tests ...:

setting PATH=/freeipa/.tox/py36/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ERROR: invocation failed (errno 13), args: /freeipa/.tox/py36/bin/ipa-run-tests --junitxml=/freeipa/.tox/py36/junit-py36.xml --ipaclient-unittests, cwd: /freeipa/.tox/py36
py36 finish: runtests after 0.43 seconds
Traceback (most recent call last):
...
PermissionError: [Errno 13] Permission denied: '/freeipa/.tox/py36/bin/ipa-run-tests'
# ls -la /freeipa/.tox/py36/bin/ipa-run-tests 
-rw-r--r--. 1 root root 2301 Jul 11 21:53 /freeipa/.tox/py36/bin/ipa-run-tests

But the file has executable bit in source tree. The only thing which can influence is pip.

> /freeipa/.tox/py36/lib/python3.6/site-packages/pip/_internal/wheel.py(417)clobber()
-> if os.access(srcfile, os.X_OK):                                              
(Pdb) srcfile                                                                   
'/tmp/pip-install-bnjh4ila/ipatests/ipatests-4.9.0.dev201907111427+gite616fb5dd.data/scripts/ipa-run-tests'
(Pdb) l                                                                         
412                     # If our file is executable, then make our destination file
413                     # executable.                                           
414                     if "ipa-run-tests" in srcfile:                          
415                         import pdb;pdb.set_trace()                          
416                                                                             
417  ->                 if os.access(srcfile, os.X_OK):                         
418                         st = os.stat(srcfile)                               
419                         permissions = (                                     
420                             st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
421                         )                                                   
422                         os.chmod(destfile, permissions)                     
(Pdb) s.access(srcfile, os.X_OK) 
False                

So, noexec eats the executable bit for non-entry_point scripts, installed by pip.
Fortunately, the latter provides option to change build directory through command line
--build or correspondig environ variable PIP_BUILD.


I faced this issue on Travis + freeipa/freeipa-test-runner:master-latest docker image.

master:

  • 2312b38 Simplify ipa-run-tests script
  • a2d4e2a Make use of Azure Pipeline slicing
  • c750022 Avoid use of '/tmp' for pip operations

ipa-4-8:

  • 8aa3ef0 Simplify ipa-run-tests script
  • 5780d6a Make use of Azure Pipeline slicing
  • 0ec908b Avoid use of '/tmp' for pip operations

Metadata Update from @abbra:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata