mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-02 15:25:27 +00:00
Fix the changehat_wrapper regression test
The capabilities tests where failing in the changehat_wrapper test. This was because they could not the changehat_wrapper sub executable, which trying to exec a binary in the tmpdir. Specifically if the test was for syscall_ptrace. It would generate a profile with a hat for ^syscall_ptrace and attempt to execute ./syscall_ptrace. However this was failing in some situations, including when trying to debug from the tmpdir, as the syscall_XXX binary is no longer local. Instead use the fully qualified path for the hat name, and the exec path. Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
@@ -109,16 +109,16 @@ for TEST in ${TESTS} ; do
|
|||||||
# okay, now check to see if the capability functions from within
|
# okay, now check to see if the capability functions from within
|
||||||
# a subprofile.
|
# a subprofile.
|
||||||
settest ${testwrapper}
|
settest ${testwrapper}
|
||||||
genprofile hat:${TEST} addimage:${bin}/${TEST} ${my_entries}
|
genprofile hat:$bin/${TEST} addimage:${bin}/${TEST} ${my_entries}
|
||||||
runchecktest "${TEST} changehat -- no caps" fail ${TEST} ${my_arg}
|
runchecktest "${TEST} changehat -- no caps" fail $bin/${TEST} ${my_arg}
|
||||||
for cap in ${CAPABILITIES} ; do
|
for cap in ${CAPABILITIES} ; do
|
||||||
if [ "X$(eval echo \${${TEST}_${cap}})" == "XTRUE" ] ; then
|
if [ "X$(eval echo \${${TEST}_${cap}})" == "XTRUE" ] ; then
|
||||||
expected_result=pass
|
expected_result=pass
|
||||||
else
|
else
|
||||||
expected_result=fail
|
expected_result=fail
|
||||||
fi
|
fi
|
||||||
genprofile hat:${TEST} addimage:${bin}/${TEST} cap:${cap} ${my_entries}
|
genprofile hat:$bin/${TEST} addimage:${bin}/${TEST} cap:${cap} ${my_entries}
|
||||||
runchecktest "${TEST} changehat -- capability ${cap}" ${expected_result} ${TEST} ${my_arg}
|
runchecktest "${TEST} changehat -- capability ${cap}" ${expected_result} $bin/${TEST} ${my_arg}
|
||||||
done
|
done
|
||||||
|
|
||||||
done
|
done
|
||||||
|
@@ -154,7 +154,7 @@ int main(int argc, char *argv[]) {
|
|||||||
perror ("FAIL: child malloc");
|
perror ("FAIL: child malloc");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sprintf (pname, "./%s", argv[optind]);
|
sprintf (pname, "%s", argv[optind]);
|
||||||
|
|
||||||
rc = !manual ? change_hat(argv[optind], magic_token)
|
rc = !manual ? change_hat(argv[optind], magic_token)
|
||||||
: manual_change_hat(argv[optind], manual_string);
|
: manual_change_hat(argv[optind], manual_string);
|
||||||
|
Reference in New Issue
Block a user