Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix basic.OutDirectoryIsExecutable #428

Conversation

perillo
Copy link
Contributor

@perillo perillo commented Mar 17, 2024

Commit 4b4cb9c (Merge pull request #426 from perillo/fix-argv-parsing) added a regression test, but the test failed due to ptrace errors on Linux.
The "Operation not permitted" error was caused by kcov trying to trace the "/bin/usr/python".

The solution is to execute an executable having user permission. Restore the short-test.py executable, and use it instead of python. short-test.py always exits with exit status 0.

Commit 4b4cb9c (Merge pull request SimonKagstrom#426 from perillo/fix-argv-parsing)
added a regression test, but the test failed due to ptrace errors on
Linux.
The "Operation not permitted" error was caused by kcov trying to trace
the "/bin/usr/python".

The solution is to execute an executable having user permission.
Restore the short-test.py executable, and use it instead of python.
short-test.py always exits with exit status 0.
Copy link

codecov bot commented Mar 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.72%. Comparing base (692d41c) to head (402b735).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #428      +/-   ##
==========================================
- Coverage   65.81%   65.72%   -0.10%     
==========================================
  Files          58       58              
  Lines        4520     4508      -12     
  Branches     4177     4165      -12     
==========================================
- Hits         2975     2963      -12     
  Misses       1545     1545              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@perillo
Copy link
Contributor Author

perillo commented Mar 17, 2024

For the reason of the ptrace error with the old test, see
https://bugs.launchpad.net/ubuntu/+source/linux-signed/+bug/1860822

In Linux, process tracing is tied with the process dumping flag. The dumpable flag is cleared at execve(2) time when a setuid or setgid application is executed. This flag persists to child processes created by fork(2) and will only be reset when a process calls execve(2) again.

> stat -L /usr/bin/python3
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
stat tests/python/short-test.py 
Access: (0750/-rwxr-x---)  Uid: ( 1000/  manlio)   Gid: ( 1000/  manlio)

The kcov test suite runs correctly on my system, without using sudo and with /proc/sys/kernel/yama/ptrace_scope set to 1 (the default value).

@SimonKagstrom SimonKagstrom merged commit 0f07787 into SimonKagstrom:master Mar 17, 2024
10 checks passed
@SimonKagstrom
Copy link
Owner

OK, thanks for the PR and the well-made analysis! Merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants